feat: updates

This commit is contained in:
JP
2024-08-15 20:11:21 +08:00
parent 52431a2c61
commit 3af7207ec3
61 changed files with 1674 additions and 480 deletions

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Observers;
use App\Commands\Ledgers\CreateLedgerCommand;
use App\Models\Expense;
use Illuminate\Support\Facades\DB;
class ExpenseObserver
{
/**
* Handle the Expense "created" event.
*/
public function created(Expense $expense): void
{
DB::transaction(
callback: function () use ($expense) {
$branch = $expense->branch;
//check if client is vatable
if ($branch->isClientVatable) {
// create a ledgers for vatable
$data = [
'transaction_id' => $expense->transaction_id,
];
$payload = new CreateLedgerCommand(data: $data);
} else {
// create a lkedgers for non vatable
}
//create cash transaction
},
attempts: 2
);
}
/**
* Handle the Expense "updated" event.
*/
public function updated(Expense $expense): void
{
//
}
/**
* Handle the Expense "deleted" event.
*/
public function deleted(Expense $expense): void
{
//
}
/**
* Handle the Expense "restored" event.
*/
public function restored(Expense $expense): void
{
//
}
/**
* Handle the Expense "force deleted" event.
*/
public function forceDeleted(Expense $expense): void
{
//
}
}