mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Updates for cleaning stale fees
This commit is contained in:
parent
a5317ff093
commit
ae73f0aa0d
@ -59,7 +59,7 @@ class CleanStaleInvoiceOrder implements ShouldQueue
|
||||
|
||||
Invoice::query()
|
||||
->withTrashed()
|
||||
->where('status_id', Invoice::STATUS_SENT)
|
||||
->where('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||
->where('updated_at', '<', now()->subHour())
|
||||
->where('balance', '>', 0)
|
||||
->whereJsonContains('line_items', ['type_id' => '3'])
|
||||
|
@ -404,8 +404,8 @@ class BaseDriver extends AbstractPaymentDriver
|
||||
$item->gross_line_total = round($item->gross_line_total, 2);
|
||||
return $item;
|
||||
})
|
||||
->whereIn('type_id', ['3','4'])
|
||||
->where('gross_line_total', round($fee_total,2))
|
||||
->whereIn('type_id', ['3'])
|
||||
->where('gross_line_total', '<=', round($fee_total,2))
|
||||
->count();
|
||||
|
||||
if($invoice && $fee_count == 0){
|
||||
|
@ -98,7 +98,9 @@ class AutoBillInvoice extends AbstractService
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
info("Auto Bill - balance remains to be paid!! - {$amount}");
|
||||
nlog("Auto Bill - balance remains to be paid!! - {$amount}");
|
||||
nlog($this->invoice->amount);
|
||||
nlog($this->invoice->balance);
|
||||
|
||||
/* Retrieve the Client Gateway Token */
|
||||
/** @var \App\Models\ClientGatewayToken $gateway_token */
|
||||
@ -112,11 +114,15 @@ class AutoBillInvoice extends AbstractService
|
||||
// return $this->invoice;
|
||||
}
|
||||
|
||||
nlog('Gateway present - adding gateway fee');
|
||||
nlog("Gateway present - adding gateway fee on {$amount}");
|
||||
|
||||
/* $gateway fee */
|
||||
$this->invoice = $this->invoice->service()->addGatewayFee($gateway_token->gateway, $gateway_token->gateway_type_id, $amount)->save();
|
||||
|
||||
|
||||
nlog($this->invoice->amount);
|
||||
nlog($this->invoice->balance);
|
||||
|
||||
//change from $this->invoice->amount to $this->invoice->balance
|
||||
if ($is_partial) {
|
||||
$fee = $this->invoice->balance - $invoice_total;
|
||||
@ -124,6 +130,8 @@ class AutoBillInvoice extends AbstractService
|
||||
$fee = $this->invoice->balance - $amount;
|
||||
}
|
||||
|
||||
nlog("fee is {$fee}");
|
||||
|
||||
if ($fee > $amount) {
|
||||
$fee = 0;
|
||||
}
|
||||
@ -148,8 +156,7 @@ class AutoBillInvoice extends AbstractService
|
||||
]);
|
||||
|
||||
nlog("Payment hash created => {$payment_hash->id}");
|
||||
$this->invoice->saveQuietly();
|
||||
|
||||
|
||||
$payment = false;
|
||||
try {
|
||||
$payment = $gateway_token->gateway
|
||||
@ -171,8 +178,6 @@ class AutoBillInvoice extends AbstractService
|
||||
$this->invoice->auto_bill_tries = 0; //reset the counter here in case auto billing is turned on again in the future.
|
||||
}
|
||||
|
||||
$this->invoice->save();
|
||||
|
||||
if ($payment) {
|
||||
info('Auto Bill payment captured for '.$this->invoice->number);
|
||||
event(new InvoiceAutoBillSuccess($this->invoice, $this->invoice->company, Ninja::eventVars()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user