From 0837252c476b2c9817f7a6c609db45c0e5d6ad61 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 30 Jul 2021 15:55:02 +1000 Subject: [PATCH] Working on deleted invoice accounting --- app/Services/Invoice/MarkInvoiceDeleted.php | 2 ++ tests/Feature/DeleteInvoiceTest.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Services/Invoice/MarkInvoiceDeleted.php b/app/Services/Invoice/MarkInvoiceDeleted.php index 7fb898a29c8e..e92a31457fbd 100644 --- a/app/Services/Invoice/MarkInvoiceDeleted.php +++ b/app/Services/Invoice/MarkInvoiceDeleted.php @@ -108,10 +108,12 @@ class MarkInvoiceDeleted extends AbstractService ->where('paymentable_type', '=', 'invoices') ->where('paymentable_id', $this->invoice->id) ->sum(DB::raw('amount')); + //->sum(DB::raw('amount - refunded')); } $this->total_payments = $this->invoice->payments->sum('amount'); + // $this->total_payments = $this->invoice->payments->sum('amount - refunded'); return $this; } diff --git a/tests/Feature/DeleteInvoiceTest.php b/tests/Feature/DeleteInvoiceTest.php index 4e5ae5f5cef2..42b28c143129 100644 --- a/tests/Feature/DeleteInvoiceTest.php +++ b/tests/Feature/DeleteInvoiceTest.php @@ -172,10 +172,11 @@ class DeleteInvoiceTest extends TestCase $client_hash_id = $arr['data']['id']; $client = Client::find($this->decodePrimaryKey($client_hash_id)); + //new client $this->assertEquals($client->balance, 0); $this->assertEquals($client->paid_to_date, 0); - //create new invoice. + //create new invoice. $line_items = []; $item = InvoiceItemFactory::create();