mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add stale gateway fee checks
This commit is contained in:
parent
1d07d48165
commit
1feff63c1b
@ -59,15 +59,12 @@ class CleanStaleInvoiceOrder implements ShouldQueue
|
|||||||
Invoice::query()
|
Invoice::query()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->where('status_id', Invoice::STATUS_SENT)
|
->where('status_id', Invoice::STATUS_SENT)
|
||||||
->whereBetween('created_at', [now()->subHours(1), now()->subMinutes(30)])
|
->where('created_at', '<', now()->subMinutes(30))
|
||||||
->where('balance', '>', 0)
|
->where('balance', '>', 0)
|
||||||
|
->whereJsonContains('line_items', ['type_id' => '3'])
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function ($invoice) {
|
->each(function ($invoice) {
|
||||||
|
$invoice->service()->removeUnpaidGatewayFees();
|
||||||
if (collect($invoice->line_items)->contains('type_id', 3)) {
|
|
||||||
$invoice->service()->removeUnpaidGatewayFees();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -86,6 +83,18 @@ class CleanStaleInvoiceOrder implements ShouldQueue
|
|||||||
$invoice->is_proforma = false;
|
$invoice->is_proforma = false;
|
||||||
$repo->delete($invoice);
|
$repo->delete($invoice);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Invoice::query()
|
||||||
|
->withTrashed()
|
||||||
|
->where('status_id', Invoice::STATUS_SENT)
|
||||||
|
->where('created_at', '<', now()->subMinutes(30))
|
||||||
|
->where('balance', '>', 0)
|
||||||
|
->whereJsonContains('line_items', ['type_id' => '3'])
|
||||||
|
->cursor()
|
||||||
|
->each(function ($invoice) {
|
||||||
|
$invoice->service()->removeUnpaidGatewayFees();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,12 +453,6 @@ class InvoiceService
|
|||||||
if ((int) $pre_count != (int) $post_count) {
|
if ((int) $pre_count != (int) $post_count) {
|
||||||
$adjustment = $balance - $new_balance;
|
$adjustment = $balance - $new_balance;
|
||||||
|
|
||||||
// $this->invoice
|
|
||||||
// ->client
|
|
||||||
// ->service()
|
|
||||||
// ->updateBalance($adjustment * -1)
|
|
||||||
// ->save();
|
|
||||||
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->ledger()
|
->ledger()
|
||||||
->updateInvoiceBalance($adjustment * -1, 'Adjustment for removing gateway fee');
|
->updateInvoiceBalance($adjustment * -1, 'Adjustment for removing gateway fee');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user