diff --git a/resources/assets/js/components/AkauntingDate.vue b/resources/assets/js/components/AkauntingDate.vue
index bef161a20..ed0fddd15 100644
--- a/resources/assets/js/components/AkauntingDate.vue
+++ b/resources/assets/js/components/AkauntingDate.vue
@@ -60,6 +60,10 @@ export default {
default: false,
description: "Input readonly status"
},
+ period: {
+ type: Number,
+ description: "Payment period"
+ },
disabled: {
type: Boolean,
default: false,
@@ -110,18 +114,18 @@ export default {
real_model: '',
}
},
-
+
created() {
if (this.locale !== 'en') {
const lang = require(`flatpickr/dist/l10n/${this.locale}.js`).default[this.locale];
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);
+ }
+ }
},
}
}
@@ -166,4 +186,4 @@ export default {
.hidden-year-flatpickr {
display: none !important;
}
-
\ No newline at end of file
+
diff --git a/resources/views/banking/reconciliations/create.blade.php b/resources/views/banking/reconciliations/create.blade.php
index 0cd6eb7c7..0cb2360c3 100644
--- a/resources/views/banking/reconciliations/create.blade.php
+++ b/resources/views/banking/reconciliations/create.blade.php
@@ -18,7 +18,7 @@
{{ 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') }}
diff --git a/resources/views/components/documents/form/metadata.blade.php b/resources/views/components/documents/form/metadata.blade.php
index 02c9f7412..0613d033a 100644
--- a/resources/views/components/documents/form/metadata.blade.php
+++ b/resources/views/components/documents/form/metadata.blade.php
@@ -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
diff --git a/resources/views/partials/admin/scripts.blade.php b/resources/views/partials/admin/scripts.blade.php
index 650026f6b..3c82b055c 100644
--- a/resources/views/partials/admin/scripts.blade.php
+++ b/resources/views/partials/admin/scripts.blade.php
@@ -5,6 +5,7 @@
@stack('scripts_start')
diff --git a/resources/views/partials/portal/scripts.blade.php b/resources/views/partials/portal/scripts.blade.php
index f093d94a6..0153d2c1b 100644
--- a/resources/views/partials/portal/scripts.blade.php
+++ b/resources/views/partials/portal/scripts.blade.php
@@ -5,6 +5,7 @@
@stack('scripts_start')