Fixes for entity dates (#3563)

This commit is contained in:
David Bomba 2020-03-30 08:29:00 +11:00 committed by GitHub
parent cdd562d3a5
commit 581654141b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 18 deletions

View File

@ -477,7 +477,7 @@ class CompanySettings extends BaseSettings
'$contact.email', '$contact.email',
], ],
'company_details' => [ 'company_details' => [
'$company.company_name', '$company.name',
'$company.id_number', '$company.id_number',
'$company.vat_number', '$company.vat_number',
'$company.website', '$company.website',
@ -519,7 +519,7 @@ class CompanySettings extends BaseSettings
'$product.cost', '$product.cost',
'$product.quantity', '$product.quantity',
'$product.discount', '$product.discount',
'$product.tax_name1', '$product.tax',
'$product.line_total', '$product.line_total',
], ],
'task_columns' =>[ 'task_columns' =>[
@ -528,7 +528,7 @@ class CompanySettings extends BaseSettings
'$task.cost', '$task.cost',
'$task.quantity', '$task.quantity',
'$task.discount', '$task.discount',
'$task.tax_name1', '$task.tax',
'$task.line_total', '$task.line_total',
], ],
]; ];

View File

@ -79,7 +79,7 @@ class Credit extends BaseModel
const STATUS_APPLIED = 4; const STATUS_APPLIED = 4;
public function getDateAttribute($value) { public function getDateAttribute($value) {
if (!$value) { if (!empty($value)) {
//$value format 'Y:m:d H:i:s' to 'Y-m-d H:i' //$value format 'Y:m:d H:i:s' to 'Y-m-d H:i'
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
@ -87,7 +87,7 @@ class Credit extends BaseModel
} }
public function getDueDateAttribute($value) { public function getDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
//$value format 'Y:m:d H:i:s' to 'Y-m-d H:i' //$value format 'Y:m:d H:i:s' to 'Y-m-d H:i'
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
@ -95,7 +95,7 @@ class Credit extends BaseModel
} }
public function getPartialDueDateAttribute($value) { public function getPartialDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
//$value format 'Y:m:d H:i:s' to 'Y-m-d H:i' //$value format 'Y:m:d H:i:s' to 'Y-m-d H:i'
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }

View File

@ -129,21 +129,21 @@ class Invoice extends BaseModel
const STATUS_REVERSED = -3; const STATUS_REVERSED = -3;
public function getDateAttribute($value) { public function getDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;
} }
public function getDueDateAttribute($value) { public function getDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;
} }
public function getPartialDueDateAttribute($value) { public function getPartialDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;

View File

@ -85,21 +85,21 @@ class Quote extends BaseModel
const STATUS_EXPIRED = -1; const STATUS_EXPIRED = -1;
public function getDateAttribute($value) { public function getDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;
} }
public function getDueDateAttribute($value) { public function getDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;
} }
public function getPartialDueDateAttribute($value) { public function getPartialDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;

View File

@ -112,21 +112,21 @@ class RecurringInvoice extends BaseModel
]; ];
public function getDateAttribute($value) { public function getDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;
} }
public function getDueDateAttribute($value) { public function getDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;
} }
public function getPartialDueDateAttribute($value) { public function getPartialDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;

View File

@ -95,21 +95,21 @@ class RecurringQuote extends BaseModel
]; ];
public function getDateAttribute($value) { public function getDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;
} }
public function getDueDateAttribute($value) { public function getDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;
} }
public function getPartialDueDateAttribute($value) { public function getPartialDueDateAttribute($value) {
if (!$value) { if (!empty($value)) {
return (new Carbon($value))->format('Y-m-d'); return (new Carbon($value))->format('Y-m-d');
} }
return $value; return $value;

View File

@ -185,6 +185,7 @@ trait MakesInvoiceValues
$data['$balance_due'] = &$data['$invoice.balance_due']; $data['$balance_due'] = &$data['$invoice.balance_due'];
$data['$invoice.partial_due'] = ['value' => Number::formatMoney($this->partial, $this->client) ?: ' ', 'label' => ctrans('texts.partial_due')]; $data['$invoice.partial_due'] = ['value' => Number::formatMoney($this->partial, $this->client) ?: ' ', 'label' => ctrans('texts.partial_due')];
$data['$total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.total')]; $data['$total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.total')];
$data['$amount'] = &$data['$total'];
$data['$quote.total'] = &$data['$total']; $data['$quote.total'] = &$data['$total'];
$data['$invoice.total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.invoice_total')]; $data['$invoice.total'] = ['value' => Number::formatMoney($calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.invoice_total')];
$data['$invoice.amount'] = &$data['$total']; $data['$invoice.amount'] = &$data['$total'];