feat: updates
This commit is contained in:
23
app/Commands/Expenses/GenerateVoucher.php
Normal file
23
app/Commands/Expenses/GenerateVoucher.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Expenses;
|
||||
|
||||
use App\Models\Branch;
|
||||
use App\Models\Expense;
|
||||
|
||||
class GenerateVoucher
|
||||
{
|
||||
public static function execute(Branch $branch): string
|
||||
{
|
||||
$year = now()->format('y');
|
||||
$lastVoucher = Expense::query()->where('branch_id', $branch->id)->orderBy('created_at', 'desc')->first();
|
||||
|
||||
if (! $lastVoucher) {
|
||||
return $year.'-'.str_pad(1, 6, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$voucherNumber = (int) explode('-', $lastVoucher->voucher_number)[1];
|
||||
|
||||
return $year.'-'.str_pad($voucherNumber + 1, 6, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
27
app/Commands/Ledgers/CreateLedgerCommand.php
Normal file
27
app/Commands/Ledgers/CreateLedgerCommand.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Ledgers;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\Ledger;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateLedgerCommand implements Command
|
||||
{
|
||||
public function execute(array $data): mixed
|
||||
{
|
||||
return DB::transaction(function () use ($data) {
|
||||
return Ledger::query()->updateOrCreate([
|
||||
'id' => $data['id'] ?? null,
|
||||
'transaction_id' => $data['transaction_id'] ?? null,
|
||||
'account_id' => $data['account_id'] ?? null,
|
||||
], [
|
||||
'credit_amount' => $data['credit_amount'] ?? null,
|
||||
'debit_amount' => $data['debit_amount'] ?? null,
|
||||
'description' => $data['description'] ?? null,
|
||||
'branch_id' => $data['branch_id'] ?? null,
|
||||
'client_id' => $data['client_id'] ?? null,
|
||||
]);
|
||||
}, attempts: 2);
|
||||
}
|
||||
}
|
||||
13
app/Commands/Transactions/CreateTransactionCommand.php
Normal file
13
app/Commands/Transactions/CreateTransactionCommand.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Transactions;
|
||||
|
||||
use App\Commands\Command;
|
||||
|
||||
class CreateTransactionCommand implements Command
|
||||
{
|
||||
public function execute(array $data): mixed
|
||||
{
|
||||
// TODO: Implement execute() method.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user