Use default terms when creating a new quote

This commit is contained in:
Hillel Coren 2018-02-21 16:15:15 +02:00
parent aaab3b1fcf
commit 663d26ede4
3 changed files with 12 additions and 14 deletions

View File

@ -390,7 +390,7 @@ class InvoiceRepository extends BaseRepository
$invoice->custom_taxes2 = $account->custom_invoice_taxes2 ?: false; $invoice->custom_taxes2 = $account->custom_invoice_taxes2 ?: false;
// set the default due date // 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(); $client = Client::scope()->whereId($data['client_id'])->first();
$invoice->due_date = $account->defaultDueDate($client); $invoice->due_date = $account->defaultDueDate($client);
} }

View File

@ -190,7 +190,7 @@
{!! Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")->label($account->getLabel("{$entityType}_date")) {!! 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') !!} ->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())) {!! 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') !!} ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('due_date') !!}
<div class="form-group partial"> <div class="form-group partial">

View File

@ -25,7 +25,6 @@ function ViewModel(data) {
} }
self.setDueDate = function() { self.setDueDate = function() {
@if ($entityType == ENTITY_INVOICE)
var paymentTerms = parseInt(self.invoice().client().payment_terms()); var paymentTerms = parseInt(self.invoice().client().payment_terms());
if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date()) { if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date()) {
if (paymentTerms == -1) paymentTerms = 0; if (paymentTerms == -1) paymentTerms = 0;
@ -34,9 +33,8 @@ function ViewModel(data) {
dueDate = moment(dueDate).format("{{ $account->getMomentDateFormat() }}"); dueDate = moment(dueDate).format("{{ $account->getMomentDateFormat() }}");
$('#due_date').attr('placeholder', dueDate); $('#due_date').attr('placeholder', dueDate);
} else { } else {
$('#due_date').attr('placeholder', "{{ $invoice->id || $invoice->isQuote() ? ' ' : $account->present()->dueDatePlaceholder() }}"); $('#due_date').attr('placeholder', "{{ $invoice->id ? ' ' : $account->present()->dueDatePlaceholder() }}");
} }
@endif
} }
self.clearBlankContacts = function() { self.clearBlankContacts = function() {