feat: updates
This commit is contained in:
68
app/Observers/ExpenseObserver.php
Normal file
68
app/Observers/ExpenseObserver.php
Normal 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
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user