mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Fixed issue with recurring invoices
This commit is contained in:
parent
3b6a4a6100
commit
e08c80f23c
@ -106,11 +106,13 @@ class ActivityListener
|
||||
|
||||
public function deletedInvoice(InvoiceWasDeleted $event)
|
||||
{
|
||||
$invoice = $event->invoice;
|
||||
|
||||
$this->activityRepo->create(
|
||||
$event->invoice,
|
||||
$invoice,
|
||||
ACTIVITY_TYPE_DELETE_INVOICE,
|
||||
$event->invoice->balance * -1,
|
||||
$event->invoice->getAmountPaid() * -1
|
||||
$invoice->affectsBalance() ? $invoice->balance * -1 : 0,
|
||||
$invoice->affectsBalance() ? $invoice->getAmountPaid() * -1 : 0
|
||||
);
|
||||
}
|
||||
|
||||
@ -128,11 +130,13 @@ class ActivityListener
|
||||
|
||||
public function restoredInvoice(InvoiceWasRestored $event)
|
||||
{
|
||||
$invoice = $event->invoice;
|
||||
|
||||
$this->activityRepo->create(
|
||||
$event->invoice,
|
||||
$invoice,
|
||||
ACTIVITY_TYPE_RESTORE_INVOICE,
|
||||
$event->fromDeleted ? $event->invoice->balance : 0,
|
||||
$event->fromDeleted ? $event->invoice->getAmountPaid() : 0
|
||||
$invoice->affectsBalance() && $event->fromDeleted ? $invoice->balance : 0,
|
||||
$invoice->affectsBalance() && $event->fromDeleted ? $invoice->getAmountPaid() : 0
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,14 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return $this->is_recurring ? trans('texts.recurring') : $this->invoice_number;
|
||||
}
|
||||
|
||||
public function affectsBalance()
|
||||
{
|
||||
return !$this->is_quote && !$this->is_recurring;
|
||||
}
|
||||
|
||||
public function getAdjustment()
|
||||
{
|
||||
if ($this->is_quote || $this->is_recurring) {
|
||||
if (!$this->affectsBalance()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user