mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Working on invoice delete refactor
This commit is contained in:
parent
48f2f469d3
commit
73c9474912
@ -69,7 +69,8 @@ class InvoiceRepository extends BaseRepository
|
|||||||
return $invoice;
|
return $invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice->service()->markDeleted()->handleCancellation()->save();
|
// $invoice->service()->markDeleted()->handleCancellation()->save();
|
||||||
|
$invoice->service()->markDeleted()->save();
|
||||||
|
|
||||||
parent::delete($invoice);
|
parent::delete($invoice);
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ namespace App\Services\Invoice;
|
|||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class MarkInvoiceDeleted extends AbstractService
|
class MarkInvoiceDeleted extends AbstractService
|
||||||
{
|
{
|
||||||
@ -44,12 +45,14 @@ class MarkInvoiceDeleted extends AbstractService
|
|||||||
->adjustPayments()
|
->adjustPayments()
|
||||||
->adjustPaidToDate()
|
->adjustPaidToDate()
|
||||||
->adjustLedger();
|
->adjustLedger();
|
||||||
|
|
||||||
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function adjustLedger()
|
private function adjustLedger()
|
||||||
{
|
{
|
||||||
$this->invoice->ledger()->updatePaymentBalance($this->adjustment_amount * -1);
|
$this->invoice->ledger()->updatePaymentBalance($this->adjustment_amount * -1);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +69,7 @@ class MarkInvoiceDeleted extends AbstractService
|
|||||||
|
|
||||||
if($this->adjustment_amount == $this->total_payments) {
|
if($this->adjustment_amount == $this->total_payments) {
|
||||||
|
|
||||||
$this->invoice->payments()->update(['deleted_at'=> now(), 'is_deleted' => true]);
|
$this->invoice->payments()->update(['payments.deleted_at' => now(), 'payments.is_deleted' => true]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user