Temp fix for partial due dates

This commit is contained in:
David Bomba 2024-01-05 09:51:41 +11:00
parent 8d07c4d2c5
commit 5ccd6949bd
3 changed files with 6 additions and 7 deletions

View File

@ -97,13 +97,9 @@ class BaseModel extends Model
public function dateMutator($value) public function dateMutator($value)
{ {
if (! empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value;
}
// public function __call($method, $params) // public function __call($method, $params)
// { // {
// $entity = strtolower(class_basename($this)); // $entity = strtolower(class_basename($this));

View File

@ -245,6 +245,9 @@ class Invoice extends BaseModel
public function getPartialDueDateAttribute($value) public function getPartialDueDateAttribute($value)
{ {
if($value == "0000-00-00 00:00:00")
return null;
return $this->dateMutator($value); return $this->dateMutator($value);
} }
@ -396,7 +399,7 @@ class Invoice extends BaseModel
public function getStatusAttribute() public function getStatusAttribute()
{ {
$due_date = $this->due_date ? Carbon::parse($this->due_date) : false; $due_date = $this->due_date ? Carbon::parse($this->due_date) : false;
$partial_due_date = $this->partial_due_Date ? Carbon::parse($this->partial_due_date) : false; $partial_due_date = $this->partial_due_date ? Carbon::parse($this->partial_due_date) : false;
if ($this->status_id == self::STATUS_SENT && $due_date && $due_date->gt(now())) { if ($this->status_id == self::STATUS_SENT && $due_date && $due_date->gt(now())) {
return self::STATUS_UNPAID; return self::STATUS_UNPAID;

View File

@ -132,7 +132,7 @@ class InvoiceTransformer extends EntityTransformer
'is_amount_discount' => (bool) ($invoice->is_amount_discount ?: false), 'is_amount_discount' => (bool) ($invoice->is_amount_discount ?: false),
'footer' => $invoice->footer ?: '', 'footer' => $invoice->footer ?: '',
'partial' => (float) ($invoice->partial ?: 0.0), 'partial' => (float) ($invoice->partial ?: 0.0),
'partial_due_date' => $invoice->partial_due_date ?: '', 'partial_due_date' => ($invoice->partial_due_date && $invoice->partial_due_date != "-0001-11-30") ?: '',
'custom_value1' => (string) $invoice->custom_value1 ?: '', 'custom_value1' => (string) $invoice->custom_value1 ?: '',
'custom_value2' => (string) $invoice->custom_value2 ?: '', 'custom_value2' => (string) $invoice->custom_value2 ?: '',
'custom_value3' => (string) $invoice->custom_value3 ?: '', 'custom_value3' => (string) $invoice->custom_value3 ?: '',