Tweak payment dates in demo data

This commit is contained in:
David Bomba 2020-07-13 13:35:28 +10:00
parent 708422dd9b
commit 583a92d5bc
2 changed files with 14 additions and 1 deletions

View File

@ -361,6 +361,10 @@ class DemoMode extends Command
$invoice = $invoice->service()->markPaid()->save();
$invoice->payments->each(function ($payment){
$payment->date = now()->addDays(rand(0,90));
$payment->save();
});
}
//@todo this slow things down, but gives us PDFs of the invoices for inspection whilst debugging.
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars()));

View File

@ -50,11 +50,20 @@ class AutoBillInvoice extends AbstractService
if(!$gateway_token)
return $this->invoice;
if($this->invoice->partial){
$fee = $gateway_token->gateway->calcGatewayFee($this->invoice->partial);
$amount = $this->invoice->partial + $fee;
}
else{
$fee = $gateway_token->gateway->calcGatewayFee($this->invoice->balance);
$amount = $this->invoice->balance + $fee;
}
if($fee > 0)
$this->purgeStaleGatewayFees()->addFeeToInvoice($fee);
$response = $gateway_token->gateway->driver($this->client)->tokenBilling($gateway_token, $amount, $this->invoice);
//if response was successful, toggle the fee type_id to paid