Document issue and due at enhancement

This commit is contained in:
Cüneyt Şentürk 2021-02-08 16:06:31 +03:00
parent 394698ee26
commit 4f6d2a0435

View File

@ -537,7 +537,7 @@ abstract class DocumentForm extends Base
if (request()->has($issued_at)) { if (request()->has($issued_at)) {
$issuedAt = request()->get($issued_at); $issuedAt = request()->get($issued_at);
} else { } else {
$issuedAt = request()->get('invoiced_at', Date::now()->toDateString()); $issuedAt = request()->get('invoice_at', Date::now()->toDateString());
} }
return $issuedAt; return $issuedAt;
@ -572,20 +572,19 @@ abstract class DocumentForm extends Base
return $document->due_at; return $document->due_at;
} }
$addDays = (setting($type . '.payment_terms', 0)) ? setting($type . '.payment_terms', 0) : setting('invoice.payment_terms', 0); $issued_at = $type . '_at';
switch ($type) { if (request()->has($issued_at)) {
case 'bill': $issuedAt = request()->get($issued_at);
case 'expense': } else {
case 'purchase': $issuedAt = Date::now()->toDateString();
$due_at = request()->get('billed_at', Date::now()->toDateString());
break;
default:
$due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays($addDays)->toDateString();
break;
} }
return $due_at; $addDays = (setting($type . '.payment_terms', 0)) ? setting($type . '.payment_terms', 0) : 0;
$dueAt = Date::parse($issuedAt)->addDays($addDays)->toDateString();
return $dueAt;
} }
protected function getOrderNumber($type, $document, $orderNumber) protected function getOrderNumber($type, $document, $orderNumber)