mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 22:04:35 -04:00
Tests for deleting and restoring an invoice
This commit is contained in:
parent
4f0776a323
commit
d8efdc6817
@ -20,6 +20,8 @@ class HandleRestore extends AbstractService
|
|||||||
|
|
||||||
private $invoice;
|
private $invoice;
|
||||||
|
|
||||||
|
private $payment_total = 0;
|
||||||
|
|
||||||
public function __construct(Invoice $invoice)
|
public function __construct(Invoice $invoice)
|
||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
@ -61,6 +63,7 @@ class HandleRestore extends AbstractService
|
|||||||
$payment->is_deleted = false;
|
$payment->is_deleted = false;
|
||||||
$payment->save();
|
$payment->save();
|
||||||
|
|
||||||
|
$this->payment_total += $payment_amount;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -68,6 +71,8 @@ class HandleRestore extends AbstractService
|
|||||||
$payment->amount += ($payment_amount - $pre_restore_amount);
|
$payment->amount += ($payment_amount - $pre_restore_amount);
|
||||||
$payment->applied += ($payment_amount - $pre_restore_amount);
|
$payment->applied += ($payment_amount - $pre_restore_amount);
|
||||||
$payment->save();
|
$payment->save();
|
||||||
|
|
||||||
|
$this->payment_total += ($payment_amount - $pre_restore_amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -76,11 +81,11 @@ class HandleRestore extends AbstractService
|
|||||||
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance, 'Restored invoice {$this->invoice->number}')->save();
|
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance, 'Restored invoice {$this->invoice->number}')->save();
|
||||||
|
|
||||||
//adjust paid to dates
|
//adjust paid to dates
|
||||||
$this->invoice->client->service()->updatePaidToDate($payment_amount - $pre_restore_amount)->save();
|
$this->invoice->client->service()->updatePaidToDate($this->payment_total)->save();
|
||||||
|
|
||||||
$this->invoice->client->service()->updateBalance($this->invoice->balance)->save();
|
$this->invoice->client->service()->updateBalance($this->invoice->balance)->save();
|
||||||
|
|
||||||
$this->invoice->ledger()->updatePaymentBalance(($payment_amount - $pre_restore_amount), 'Restored payment for invoice {$this->invoice->number}')->save();
|
$this->invoice->ledger()->updatePaymentBalance($this->payment_total, 'Restored payment for invoice {$this->invoice->number}')->save();
|
||||||
|
|
||||||
$this->windBackInvoiceNumber();
|
$this->windBackInvoiceNumber();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user