Working on autobill payments

This commit is contained in:
David Bomba 2020-07-15 16:08:57 +10:00
parent 0ff8b68fbe
commit 018340cd03
5 changed files with 18 additions and 8 deletions

View File

@ -42,6 +42,8 @@ class AutoBillInvoice extends AbstractService
if(!$this->invoice->isPayable()) if(!$this->invoice->isPayable())
return $this->invoice; return $this->invoice;
$this->invoice = $this->invoice->service()->markSent()->save();
if($this->invoice->balance > 0) if($this->invoice->balance > 0)
$gateway_token = $this->getGateway($this->invoice->balance); $gateway_token = $this->getGateway($this->invoice->balance);
else else
@ -70,12 +72,12 @@ class AutoBillInvoice extends AbstractService
if($payment){ if($payment){
$this->invoice->service()->toggleFeesPaid()->save(); $this->invoice = $this->invoice->service()->toggleFeesPaid()->save();
} }
else else
{ {
//autobill failed //TODO autobill failed
} }

View File

@ -182,9 +182,11 @@ class InvoiceService
{ {
$this->invoice->line_items = collect($this->invoice->line_items) $this->invoice->line_items = collect($this->invoice->line_items)
->where('type_id',3)->map(function ($item) { ->map(function ($item) {
$item->type_id=4; if($item->type_id == 3)
$item->type_id = 4;
return $item; return $item;
})->toArray(); })->toArray();

View File

@ -42,6 +42,10 @@ class MarkPaid extends AbstractService
$this->invoice->service()->markSent(); $this->invoice->service()->markSent();
} }
/*Don't double pay*/
if($this->invoice->statud_id == Invoice::STATUS_PAID)
return $this->invoice;
/* Create Payment */ /* Create Payment */
$payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id); $payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);

View File

@ -45,11 +45,11 @@ class TriggeredActions extends AbstractService
{ {
if($this->request->has('auto_bill')) { if($this->request->has('auto_bill')) {
$this->invoice->service()->autoBill()->save(); $this->invoice = $this->invoice->service()->autoBill()->save();
} }
if($this->request->has('paid') && (bool)$this->request->input('paid') !== false) { if($this->request->has('paid') && (bool)$this->request->input('paid') !== false) {
$this->invoice->service()->markPaid()->save(); $this->invoice = $this->invoice->service()->markPaid()->save();
} }
if($this->request->has('send_email') && (bool)$this->request->input('send_email') !== false) { if($this->request->has('send_email') && (bool)$this->request->input('send_email') !== false) {

View File

@ -189,7 +189,9 @@ trait MakesReminders
$client = $this->client; $client = $this->client;
//if the invoice //if the invoice
if ($client->getSetting('enable_reminder1') !== false && $this->inReminderWindow( if($this->balance == 0){
return 'invoice';
}elseif ($client->getSetting('enable_reminder1') !== false && $this->inReminderWindow(
$client->getSetting('schedule_reminder1'), $client->getSetting('schedule_reminder1'),
$client->getSetting('num_days_reminder1') $client->getSetting('num_days_reminder1')
)) { )) {