feat: clear cache for default account after cash transactions to ensure data consistency
This commit is contained in:
parent
c16cfac861
commit
ef90f8361f
@ -95,6 +95,8 @@ function () use ($cashAccount, $validated, $user): CashTransaction {
|
|||||||
'Gagal melakukan setoran kas',
|
'Gagal melakukan setoran kas',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('finance:default_account');
|
||||||
|
|
||||||
$this->pushNotificationService->sendToRoles(
|
$this->pushNotificationService->sendToRoles(
|
||||||
'💰 Setoran Kas',
|
'💰 Setoran Kas',
|
||||||
"Setoran kas baru {$transaction->amount_formatted} dengan keterangan: {$transaction->description} oleh {$user->profile?->full_name}.",
|
"Setoran kas baru {$transaction->amount_formatted} dengan keterangan: {$transaction->description} oleh {$user->profile?->full_name}.",
|
||||||
@ -138,6 +140,8 @@ function () use ($cashAccount, $validated, $user): CashTransaction {
|
|||||||
'Gagal melakukan tarik kas',
|
'Gagal melakukan tarik kas',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('finance:default_account');
|
||||||
|
|
||||||
$this->pushNotificationService->sendToRoles(
|
$this->pushNotificationService->sendToRoles(
|
||||||
'🏦 Tarik Kas',
|
'🏦 Tarik Kas',
|
||||||
"Tarik kas {$transaction->amount_formatted} dengan keterangan: {$transaction->description} oleh {$user->profile?->full_name}.",
|
"Tarik kas {$transaction->amount_formatted} dengan keterangan: {$transaction->description} oleh {$user->profile?->full_name}.",
|
||||||
@ -155,7 +159,7 @@ public function recordOutgoing(
|
|||||||
User $user,
|
User $user,
|
||||||
?CashAccount $cashAccount = null,
|
?CashAccount $cashAccount = null,
|
||||||
): CashTransaction {
|
): CashTransaction {
|
||||||
return $this->runInTransaction(
|
$transaction = $this->runInTransaction(
|
||||||
function () use ($reference, $amount, $description, $user, $cashAccount): CashTransaction {
|
function () use ($reference, $amount, $description, $user, $cashAccount): CashTransaction {
|
||||||
$account = CashAccount::query()->lockForUpdate()->findOrFail(
|
$account = CashAccount::query()->lockForUpdate()->findOrFail(
|
||||||
($cashAccount ?? $this->getDefaultAccount())->id,
|
($cashAccount ?? $this->getDefaultAccount())->id,
|
||||||
@ -187,6 +191,10 @@ function () use ($reference, $amount, $description, $user, $cashAccount): CashTr
|
|||||||
},
|
},
|
||||||
'Gagal mencatat transaksi keluar kas',
|
'Gagal mencatat transaksi keluar kas',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('finance:default_account');
|
||||||
|
|
||||||
|
return $transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function recordIncoming(
|
public function recordIncoming(
|
||||||
@ -196,7 +204,7 @@ public function recordIncoming(
|
|||||||
User $user,
|
User $user,
|
||||||
?CashAccount $cashAccount = null,
|
?CashAccount $cashAccount = null,
|
||||||
): CashTransaction {
|
): CashTransaction {
|
||||||
return $this->runInTransaction(
|
$transaction = $this->runInTransaction(
|
||||||
function () use ($reference, $amount, $description, $user, $cashAccount): CashTransaction {
|
function () use ($reference, $amount, $description, $user, $cashAccount): CashTransaction {
|
||||||
$account = CashAccount::query()->lockForUpdate()->findOrFail(
|
$account = CashAccount::query()->lockForUpdate()->findOrFail(
|
||||||
($cashAccount ?? $this->getDefaultAccount())->id,
|
($cashAccount ?? $this->getDefaultAccount())->id,
|
||||||
@ -222,6 +230,10 @@ function () use ($reference, $amount, $description, $user, $cashAccount): CashTr
|
|||||||
},
|
},
|
||||||
'Gagal mencatat transaksi masuk kas',
|
'Gagal mencatat transaksi masuk kas',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('finance:default_account');
|
||||||
|
|
||||||
|
return $transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateDeposit(CashTransaction $transaction, array $validated, User $user): void
|
public function updateDeposit(CashTransaction $transaction, array $validated, User $user): void
|
||||||
@ -250,6 +262,8 @@ function () use ($transaction, $validated): void {
|
|||||||
'Gagal memperbarui setoran kas',
|
'Gagal memperbarui setoran kas',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('finance:default_account');
|
||||||
|
|
||||||
$this->pushNotificationService->sendToRoles(
|
$this->pushNotificationService->sendToRoles(
|
||||||
'✏️ Transaksi Kas Diperbarui',
|
'✏️ Transaksi Kas Diperbarui',
|
||||||
"Transaksi kas dengan keterangan {$transaction->description} diperbarui menjadi senilai {$transaction->amount_formatted} oleh {$user->profile?->full_name}.",
|
"Transaksi kas dengan keterangan {$transaction->description} diperbarui menjadi senilai {$transaction->amount_formatted} oleh {$user->profile?->full_name}.",
|
||||||
@ -283,6 +297,8 @@ function () use ($transaction): void {
|
|||||||
'Gagal menghapus transaksi kas',
|
'Gagal menghapus transaksi kas',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('finance:default_account');
|
||||||
|
|
||||||
$this->pushNotificationService->sendToRoles(
|
$this->pushNotificationService->sendToRoles(
|
||||||
'🗑️ Transaksi Kas Dihapus',
|
'🗑️ Transaksi Kas Dihapus',
|
||||||
"Transaksi kas senilai {$amountFormatted} dengan keterangan {$description} telah dihapus oleh {$user->profile?->full_name}.",
|
"Transaksi kas senilai {$amountFormatted} dengan keterangan {$description} telah dihapus oleh {$user->profile?->full_name}.",
|
||||||
@ -317,6 +333,8 @@ function () use ($transaction, $amount, $description): void {
|
|||||||
},
|
},
|
||||||
'Gagal memperbarui transaksi kas referensi',
|
'Gagal memperbarui transaksi kas referensi',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('finance:default_account');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteReferencedTransaction(CashTransaction $transaction): void
|
public function deleteReferencedTransaction(CashTransaction $transaction): void
|
||||||
@ -338,6 +356,8 @@ function () use ($transaction): void {
|
|||||||
},
|
},
|
||||||
'Gagal menghapus transaksi kas referensi',
|
'Gagal menghapus transaksi kas referensi',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->cacheForget('finance:default_account');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function recalculateBalances(CashAccount $cashAccount): void
|
private function recalculateBalances(CashAccount $cashAccount): void
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user