Don't apply payment terms to quotes

This commit is contained in:
Hillel Coren 2018-04-15 13:25:28 +03:00
parent 73e2f070a9
commit 748c1d38fb
3 changed files with 14 additions and 12 deletions

View File

@ -392,7 +392,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 (empty($data['partial_due_date'])) { if ($entityType == ENTITY_INVOICE && 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 ? ' ' : $account->present()->dueDatePlaceholder()) ->placeholder($invoice->id || $invoice->isQuote() ? ' ' : $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,16 +25,18 @@ function ViewModel(data) {
} }
self.setDueDate = function() { self.setDueDate = function() {
var paymentTerms = parseInt(self.invoice().client().payment_terms()); @if ($entityType == ENTITY_INVOICE)
if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date()) { var paymentTerms = parseInt(self.invoice().client().payment_terms());
if (paymentTerms == -1) paymentTerms = 0; if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date()) {
var dueDate = $('#invoice_date').datepicker('getDate'); if (paymentTerms == -1) paymentTerms = 0;
dueDate.setDate(dueDate.getDate() + paymentTerms); var dueDate = $('#invoice_date').datepicker('getDate');
dueDate = moment(dueDate).format("{{ $account->getMomentDateFormat() }}"); dueDate.setDate(dueDate.getDate() + paymentTerms);
$('#due_date').attr('placeholder', dueDate); dueDate = moment(dueDate).format("{{ $account->getMomentDateFormat() }}");
} else { $('#due_date').attr('placeholder', dueDate);
$('#due_date').attr('placeholder', "{{ $invoice->id ? ' ' : $account->present()->dueDatePlaceholder() }}"); } else {
} $('#due_date').attr('placeholder', "{{ $invoice->id ? ' ' : $account->present()->dueDatePlaceholder() }}");
}
@endif
} }
self.clearBlankContacts = function() { self.clearBlankContacts = function() {