diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index ae7d629b39ca..aed41f0826ec 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -390,7 +390,7 @@ class InvoiceRepository extends BaseRepository $invoice->custom_taxes2 = $account->custom_invoice_taxes2 ?: false; // set the default due date - if ($entityType == ENTITY_INVOICE && empty($data['partial_due_date'])) { + if (empty($data['partial_due_date'])) { $client = Client::scope()->whereId($data['client_id'])->first(); $invoice->due_date = $account->defaultDueDate($client); } diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 5c619ea9b756..fbaa3d94f705 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -190,7 +190,7 @@ {!! Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")->label($account->getLabel("{$entityType}_date")) ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('invoice_date') !!} {!! Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'")->label($account->getLabel($invoice->getDueDateLabel())) - ->placeholder($invoice->id || $invoice->isQuote() ? ' ' : $account->present()->dueDatePlaceholder()) + ->placeholder($invoice->id ? ' ' : $account->present()->dueDatePlaceholder()) ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('due_date') !!}
diff --git a/resources/views/invoices/knockout.blade.php b/resources/views/invoices/knockout.blade.php index f3221ae8a483..a63e96e09c28 100644 --- a/resources/views/invoices/knockout.blade.php +++ b/resources/views/invoices/knockout.blade.php @@ -25,18 +25,16 @@ function ViewModel(data) { } self.setDueDate = function() { - @if ($entityType == ENTITY_INVOICE) - var paymentTerms = parseInt(self.invoice().client().payment_terms()); - if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date()) { - if (paymentTerms == -1) paymentTerms = 0; - var dueDate = $('#invoice_date').datepicker('getDate'); - dueDate.setDate(dueDate.getDate() + paymentTerms); - dueDate = moment(dueDate).format("{{ $account->getMomentDateFormat() }}"); - $('#due_date').attr('placeholder', dueDate); - } else { - $('#due_date').attr('placeholder', "{{ $invoice->id || $invoice->isQuote() ? ' ' : $account->present()->dueDatePlaceholder() }}"); - } - @endif + var paymentTerms = parseInt(self.invoice().client().payment_terms()); + if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date()) { + if (paymentTerms == -1) paymentTerms = 0; + var dueDate = $('#invoice_date').datepicker('getDate'); + dueDate.setDate(dueDate.getDate() + paymentTerms); + dueDate = moment(dueDate).format("{{ $account->getMomentDateFormat() }}"); + $('#due_date').attr('placeholder', dueDate); + } else { + $('#due_date').attr('placeholder', "{{ $invoice->id ? ' ' : $account->present()->dueDatePlaceholder() }}"); + } } self.clearBlankContacts = function() {