From acefad27b6344b6e67fbce58cad0975fccb5f72c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 14 Jan 2024 16:17:49 +1100 Subject: [PATCH] transition partial_due_dates to casts --- app/Models/Invoice.php | 9 +++++---- lang/en/t.php | 7 ------- tests/Unit/InvoiceTest.php | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) delete mode 100644 lang/en/t.php diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 7ea31ef191..81acdcd0d7 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -204,6 +204,7 @@ class Invoice extends BaseModel 'is_deleted' => 'bool', 'is_amount_discount' => 'bool', 'tax_data' => 'object', + 'partial_due_date' => 'date:Y-m-d' ]; protected $with = []; @@ -244,10 +245,10 @@ class Invoice extends BaseModel return $value ? $this->dateMutator($value) : null; } - public function getPartialDueDateAttribute($value) - { - return $value ? $this->dateMutator($value) : null; - } + // public function getPartialDueDateAttribute($value) + // { + // return $value ? $this->dateMutator($value) : null; + // } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo diff --git a/lang/en/t.php b/lang/en/t.php deleted file mode 100644 index e6474222c5..0000000000 --- a/lang/en/t.php +++ /dev/null @@ -1,7 +0,0 @@ - 'Client Settings', -); - -return $lang; diff --git a/tests/Unit/InvoiceTest.php b/tests/Unit/InvoiceTest.php index 1a60d8f2ec..10a580200d 100644 --- a/tests/Unit/InvoiceTest.php +++ b/tests/Unit/InvoiceTest.php @@ -49,7 +49,27 @@ class InvoiceTest extends TestCase $this->invoice_calc = new InvoiceSum($this->invoice); } + public function testPartialDueDateCast() + { + $i = Invoice::factory() + ->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'client_id' => $this->user->id + ]); + $this->assertNull($i->partial_due_date); + + $i = Invoice::factory() + ->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'client_id' => $this->user->id, + 'partial_due_date' => '2023-10-10', + ]); + + $this->assertEquals('2023-10-10', $i->partial_due_date->format('Y-m-d')); + } public function testMarkPaidWithPartial() {