diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index 40b5e6af9f83..b6a53c24546d 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -69,7 +69,8 @@ class InvoiceRepository extends BaseRepository return $invoice; } - $invoice->service()->markDeleted()->handleCancellation()->save(); +// $invoice->service()->markDeleted()->handleCancellation()->save(); + $invoice->service()->markDeleted()->save(); parent::delete($invoice); diff --git a/app/Services/Invoice/MarkInvoiceDeleted.php b/app/Services/Invoice/MarkInvoiceDeleted.php index 489c0f2566fd..9d514e73c4a7 100644 --- a/app/Services/Invoice/MarkInvoiceDeleted.php +++ b/app/Services/Invoice/MarkInvoiceDeleted.php @@ -14,6 +14,7 @@ namespace App\Services\Invoice; use App\Models\Invoice; use App\Services\AbstractService; use App\Utils\Traits\GeneratesCounter; +use Illuminate\Support\Facades\DB; class MarkInvoiceDeleted extends AbstractService { @@ -44,12 +45,14 @@ class MarkInvoiceDeleted extends AbstractService ->adjustPayments() ->adjustPaidToDate() ->adjustLedger(); + + return $this->invoice; } private function adjustLedger() { $this->invoice->ledger()->updatePaymentBalance($this->adjustment_amount * -1); - + return $this; } @@ -66,7 +69,7 @@ class MarkInvoiceDeleted extends AbstractService 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 {