Merge pull request #2182 from bengu-thon-mai-mochi/datepicker-should-adjust-due-date
Date inputs update in relation to admin payment term settings
This commit is contained in:
commit
281f3c58a6
@ -60,6 +60,10 @@ export default {
|
||||
default: false,
|
||||
description: "Input readonly status"
|
||||
},
|
||||
period: {
|
||||
type: Number,
|
||||
description: "Payment period"
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@ -117,11 +121,11 @@ export default {
|
||||
|
||||
this.dateConfig.locale = lang;
|
||||
}
|
||||
|
||||
this.real_model = this.value;
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.real_model = this.value;
|
||||
|
||||
if (this.model) {
|
||||
this.real_model = this.model;
|
||||
}
|
||||
@ -147,7 +151,19 @@ export default {
|
||||
wrapper.classList.remove('hidden-year-flatpickr');
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addDays(dateInput) {
|
||||
if(!this.period) return;
|
||||
|
||||
const dateString = new Date(dateInput);
|
||||
const aMillisec = 86400000;
|
||||
const dateInMillisecs = dateString.getTime();
|
||||
const settingPaymentTermInMs = parseInt(this.period) * aMillisec;
|
||||
const prospectedDueDate = new Date(dateInMillisecs + settingPaymentTermInMs);
|
||||
|
||||
return prospectedDueDate;
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
@ -155,8 +171,12 @@ export default {
|
||||
this.real_model = val;
|
||||
},
|
||||
|
||||
dataValueMin: function(val) {
|
||||
this.dateConfig.minDate = val;
|
||||
dateConfig: function() {
|
||||
if(this.dateConfig.minDate) {
|
||||
if(this.real_model < this.dateConfig.minDate){
|
||||
this.real_model = this.addDays(this.dateConfig.minDate);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
<div class="row align-items-center">
|
||||
{{ Form::dateGroup('started_at', trans('reconciliations.start_date'), 'calendar', ['id' => 'started_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'change' => 'setDueMinDate'], request('started_at', Date::now()->firstOfMonth()->toDateString()), 'col-xl-3') }}
|
||||
|
||||
{{ Form::dateGroup('ended_at', trans('reconciliations.end_date'), 'calendar', ['id' => 'ended_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'min-date' => 'form.started_at', 'min-date-dynamic' => 'min_due_date', 'data-value-min' => true], request('ended_at', Date::now()->endOfMonth()->toDateString()), 'col-xl-3') }}
|
||||
{{ Form::dateGroup('ended_at', trans('reconciliations.end_date'), 'calendar', ['id' => 'ended_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'min-date' => 'form.started_at', 'min-date-dynamic' => 'min_due_date', 'data-value-min' => true, 'period' => 30], request('ended_at', Date::now()->endOfMonth()->toDateString()), 'col-xl-3') }}
|
||||
|
||||
{{ Form::moneyGroup('closing_balance', trans('reconciliations.closing_balance'), 'balance-scale', ['required' => 'required', 'autofocus' => 'autofocus', 'currency' => $currency, 'dynamic-currency' => 'currency', 'input' => 'onCalculate'], request('closing_balance', 0.00), 'col-xl-2') }}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
@endif
|
||||
|
||||
@if (!$hideDueAt)
|
||||
{{ Form::dateGroup('due_at', trans($textDueAt), 'calendar', ['id' => 'due_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'min-date' => 'form.issued_at', 'min-date-dynamic' => 'min_due_date', 'data-value-min' => true], $dueAt) }}
|
||||
{{ Form::dateGroup('due_at', trans($textDueAt), 'calendar', ['id' => 'due_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'period' => setting('invoice.payment_terms') , 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'min-date' => 'form.issued_at', 'min-date-dynamic' => 'min_due_date', 'data-value-min' => true], $dueAt) }}
|
||||
@else
|
||||
{{ Form::hidden('due_at', old('issued_at', $issuedAt), ['id' => 'due_at', 'v-model' => 'form.issued_at']) }}
|
||||
@endif
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
var company_currency_code = '{{ setting("default.currency") }}';
|
||||
var default_payment_terms = '{{ setting("invoice.payment_terms") }}';
|
||||
</script>
|
||||
|
||||
@stack('scripts_start')
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
var company_currency_code = '{{ setting("default.currency") }}';
|
||||
var default_payment_terms = '{{ setting("invoice.payment_terms") }}';
|
||||
</script>
|
||||
|
||||
@stack('scripts_start')
|
||||
|
Loading…
x
Reference in New Issue
Block a user