prevent history creation after invoice/bill delete
This commit is contained in:
parent
2ef3d2cf42
commit
72c7946459
@ -26,12 +26,16 @@ class DeleteBill extends Job
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
session(['deleting_bill' => true]);
|
||||||
|
|
||||||
$this->deleteRelationships($this->bill, [
|
$this->deleteRelationships($this->bill, [
|
||||||
'items', 'item_taxes', 'histories', 'transactions', 'recurring', 'totals'
|
'items', 'item_taxes', 'histories', 'transactions', 'recurring', 'totals'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->bill->delete();
|
$this->bill->delete();
|
||||||
|
|
||||||
|
session()->forget('deleting_bill');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,16 @@ class DeleteInvoice extends Job
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
session(['deleting_invoice' => true]);
|
||||||
|
|
||||||
$this->deleteRelationships($this->invoice, [
|
$this->deleteRelationships($this->invoice, [
|
||||||
'items', 'item_taxes', 'histories', 'transactions', 'recurring', 'totals'
|
'items', 'item_taxes', 'histories', 'transactions', 'recurring', 'totals'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->invoice->delete();
|
$this->invoice->delete();
|
||||||
|
|
||||||
|
session()->forget('deleting_invoice');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,10 @@ class Transaction
|
|||||||
|
|
||||||
protected function updateInvoice($transaction)
|
protected function updateInvoice($transaction)
|
||||||
{
|
{
|
||||||
|
if (session('deleting_invoice')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$invoice = $transaction->invoice;
|
$invoice = $transaction->invoice;
|
||||||
|
|
||||||
$invoice->status = ($invoice->transactions->count() > 1) ? 'partial' : 'sent';
|
$invoice->status = ($invoice->transactions->count() > 1) ? 'partial' : 'sent';
|
||||||
@ -41,6 +45,10 @@ class Transaction
|
|||||||
|
|
||||||
protected function updateBill($transaction)
|
protected function updateBill($transaction)
|
||||||
{
|
{
|
||||||
|
if (session('deleting_bill')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$bill = $transaction->bill;
|
$bill = $transaction->bill;
|
||||||
|
|
||||||
$bill->status = ($bill->transactions->count() > 1) ? 'partial' : 'received';
|
$bill->status = ($bill->transactions->count() > 1) ? 'partial' : 'received';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user