From 528b9b78bb4162d6de689a922b3831547c304c9d Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Wed, 7 Jul 2021 16:16:37 +0300 Subject: [PATCH 1/9] Create global variable for default payment term --- resources/views/partials/admin/scripts.blade.php | 1 + 1 file changed, 1 insertion(+) 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') From efe21a74c45034bd7989f1fb87e710e073e19501 Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Wed, 7 Jul 2021 16:20:46 +0300 Subject: [PATCH 2/9] Show due date calendar after start date is changed to another month --- .../assets/js/components/AkauntingDate.vue | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/resources/assets/js/components/AkauntingDate.vue b/resources/assets/js/components/AkauntingDate.vue index bef161a20..1ec3f6b2b 100644 --- a/resources/assets/js/components/AkauntingDate.vue +++ b/resources/assets/js/components/AkauntingDate.vue @@ -117,16 +117,14 @@ 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; } - - this.$emit('interface', this.real_model); }, methods: { @@ -147,16 +145,30 @@ export default { wrapper.classList.remove('hidden-year-flatpickr'); }); } - } + }, + + addDays(dateInput) { + if(!default_payment_terms) return; + + const dateString = new Date(dateInput); + const aMillisec = 86400000; + const dateInMillisecs = dateString.getTime(); + const settingPaymentTermInMs = default_payment_terms * aMillisec; + const prospectedDueDate = new Date(dateInMillisecs + settingPaymentTermInMs); + + return prospectedDueDate; + }, }, watch: { - value: function(val) { - this.real_model = val; - }, + dateConfig: function() { + if(!default_payment_terms || this.real_model < this.dateConfig.minDate){ + this.real_model = this.dateConfig.minDate; + } - dataValueMin: function(val) { - this.dateConfig.minDate = val; + if(this.dateConfig.minDate && this.real_model > this.dateConfig.minDate ){ + this.real_model = this.addDays(this.real_model); + } }, } } @@ -166,4 +178,4 @@ export default { .hidden-year-flatpickr { display: none !important; } - \ No newline at end of file + From c90ec1e510cc014c7eb72a0fba15e06643966143 Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Wed, 7 Jul 2021 16:22:08 +0300 Subject: [PATCH 3/9] Use settings payments due to calculate due date in portal --- resources/views/partials/portal/scripts.blade.php | 1 + 1 file changed, 1 insertion(+) 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') From 40f5a49dc8c76e0ad3ba612f73fe2d4777e136d9 Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Wed, 7 Jul 2021 17:43:29 +0300 Subject: [PATCH 4/9] Fix varibles --- resources/assets/js/components/AkauntingDate.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/components/AkauntingDate.vue b/resources/assets/js/components/AkauntingDate.vue index 1ec3f6b2b..53f5f24d8 100644 --- a/resources/assets/js/components/AkauntingDate.vue +++ b/resources/assets/js/components/AkauntingDate.vue @@ -150,13 +150,15 @@ export default { addDays(dateInput) { if(!default_payment_terms) return; + console.log(dateInput) const dateString = new Date(dateInput); const aMillisec = 86400000; const dateInMillisecs = dateString.getTime(); - const settingPaymentTermInMs = default_payment_terms * aMillisec; + const settingPaymentTermInMs = parseInt(default_payment_terms) * aMillisec; const prospectedDueDate = new Date(dateInMillisecs + settingPaymentTermInMs); return prospectedDueDate; + debugger; }, }, @@ -167,7 +169,7 @@ export default { } if(this.dateConfig.minDate && this.real_model > this.dateConfig.minDate ){ - this.real_model = this.addDays(this.real_model); + this.real_model = this.addDays(this.dateConfig.minDate); } }, } From 3843344abb0574a38aa659c3a9d312e01d38f783 Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Thu, 8 Jul 2021 10:28:10 +0300 Subject: [PATCH 5/9] Remove debugger and add discharged functions back --- resources/assets/js/components/AkauntingDate.vue | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/resources/assets/js/components/AkauntingDate.vue b/resources/assets/js/components/AkauntingDate.vue index 53f5f24d8..7405fec2e 100644 --- a/resources/assets/js/components/AkauntingDate.vue +++ b/resources/assets/js/components/AkauntingDate.vue @@ -110,7 +110,7 @@ export default { real_model: '', } }, - + created() { if (this.locale !== 'en') { const lang = require(`flatpickr/dist/l10n/${this.locale}.js`).default[this.locale]; @@ -125,6 +125,8 @@ export default { if (this.model) { this.real_model = this.model; } + + this.$emit('interface', this.real_model); }, methods: { @@ -150,7 +152,6 @@ export default { addDays(dateInput) { if(!default_payment_terms) return; - console.log(dateInput) const dateString = new Date(dateInput); const aMillisec = 86400000; const dateInMillisecs = dateString.getTime(); @@ -158,17 +159,20 @@ export default { const prospectedDueDate = new Date(dateInMillisecs + settingPaymentTermInMs); return prospectedDueDate; - debugger; }, }, watch: { + value: function(val) { + this.real_model = val; + }, + dateConfig: function() { - if(!default_payment_terms || this.real_model < this.dateConfig.minDate){ + if(!default_payment_terms || this.real_model < this.dateConfig.minDate) { this.real_model = this.dateConfig.minDate; } - if(this.dateConfig.minDate && this.real_model > this.dateConfig.minDate ){ + if(this.dateConfig.minDate && this.real_model > this.dateConfig.minDate ) { this.real_model = this.addDays(this.dateConfig.minDate); } }, From c21857df9c351f0747faeaf528e1f6cab7932115 Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Thu, 8 Jul 2021 15:05:28 +0300 Subject: [PATCH 6/9] Add payment period prop to reconciliations blade --- resources/views/banking/reconciliations/create.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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') }} From 5e291f0332a97b8bc7af6ecaa633c4dbc98f2b6d Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Thu, 8 Jul 2021 15:08:45 +0300 Subject: [PATCH 7/9] Update date component with props and functionality --- .../assets/js/components/AkauntingDate.vue | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/resources/assets/js/components/AkauntingDate.vue b/resources/assets/js/components/AkauntingDate.vue index 7405fec2e..1d73bcd7f 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" }, + props: { + type: Number, + description: "Payment period" + }, disabled: { type: Boolean, default: false, @@ -150,12 +154,12 @@ export default { }, addDays(dateInput) { - if(!default_payment_terms) return; + if(!this.period) return; const dateString = new Date(dateInput); const aMillisec = 86400000; const dateInMillisecs = dateString.getTime(); - const settingPaymentTermInMs = parseInt(default_payment_terms) * aMillisec; + const settingPaymentTermInMs = parseInt(this.period) * aMillisec; const prospectedDueDate = new Date(dateInMillisecs + settingPaymentTermInMs); return prospectedDueDate; @@ -168,12 +172,10 @@ export default { }, dateConfig: function() { - if(!default_payment_terms || this.real_model < this.dateConfig.minDate) { - this.real_model = this.dateConfig.minDate; - } - - if(this.dateConfig.minDate && this.real_model > this.dateConfig.minDate ) { - this.real_model = this.addDays(this.dateConfig.minDate); + if(this.dateConfig.minDate) { + if(this.real_model < this.dateConfig.minDate){ + this.real_model = this.addDays(this.dateConfig.minDate); + } } }, } From 3061bf786ee24427234a0348761fa2a834fbe43a Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Thu, 8 Jul 2021 15:11:28 +0300 Subject: [PATCH 8/9] Add payment period for invoicesand bills --- resources/views/components/documents/form/metadata.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 2f9f69c0a2c3b6cad34d6938b0a82f9330f8f0a7 Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Thu, 8 Jul 2021 15:14:33 +0300 Subject: [PATCH 9/9] Correct prop name --- resources/assets/js/components/AkauntingDate.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/js/components/AkauntingDate.vue b/resources/assets/js/components/AkauntingDate.vue index 1d73bcd7f..ed0fddd15 100644 --- a/resources/assets/js/components/AkauntingDate.vue +++ b/resources/assets/js/components/AkauntingDate.vue @@ -60,7 +60,7 @@ export default { default: false, description: "Input readonly status" }, - props: { + period: { type: Number, description: "Payment period" },