From 7fa4eabf86df48b01a25ee1981e7f0475d3a12c4 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 14 Jun 2023 14:59:18 +0200 Subject: [PATCH] refs #5842 fix: recalcula invoiceDate cuando se cambia la company --- .../front/global-invoicing/index.html | 3 +- .../front/global-invoicing/index.js | 34 +++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/modules/invoiceOut/front/global-invoicing/index.html b/modules/invoiceOut/front/global-invoicing/index.html index 6d5b16329..1df01c7f0 100644 --- a/modules/invoiceOut/front/global-invoicing/index.html +++ b/modules/invoiceOut/front/global-invoicing/index.html @@ -118,7 +118,8 @@ label="Company" show-field="code" value-field="id" - ng-model="$ctrl.companyFk"> + ng-model="$ctrl.companyFk" + on-change="$ctrl.recalcInvoiceDate($ctrl.companyFk)"> { - this.companyFk = res.data.companyFk; - const params = { - companyFk: this.companyFk - }; - return this.$http.get('InvoiceOuts/getInvoiceDate', {params}); - }) - .then(res => { - this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; - this.invoiceDate = this.minInvoicingDate; - }); - } + .then(res => { + this.companyFk = res.data.companyFk; + this.recalcInvoiceDate(this.companyFk); + }); + } + + recalcInvoiceDate(companyFk) { + const params = { companyFk: companyFk }; + this.fetchInvoiceDate(params); + } + + fetchInvoiceDate(params) { + this.$http.get('InvoiceOuts/getInvoiceDate', { params }) + .then(res => { + this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; + this.invoiceDate = this.minInvoicingDate; + }); + } stopInvoicing() { this.status = 'stopping';