Merge pull request '5842-hotfix_recalcularFechaFactura' (!1617) from 5842-hotfix_recalcularFechaFactura into master
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1617
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Alex Moreno 2023-06-15 08:32:03 +00:00
commit d9c7d3b8f0
2 changed files with 23 additions and 16 deletions

View File

@ -118,7 +118,8 @@
label="Company"
show-field="code"
value-field="id"
ng-model="$ctrl.companyFk">
ng-model="$ctrl.companyFk"
on-change="$ctrl.getInvoiceDate(value)">
</vn-autocomplete>
<vn-autocomplete
url="Printers"

View File

@ -14,11 +14,17 @@ class Controller extends Section {
this.$http.get('UserConfigs/getUserConfig')
.then(res => {
this.companyFk = res.data.companyFk;
const params = {
companyFk: this.companyFk
};
return this.$http.get('InvoiceOuts/getInvoiceDate', {params});
})
this.getInvoiceDate(this.companyFk);
});
}
getInvoiceDate(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;
@ -42,7 +48,7 @@ class Controller extends Section {
throw new UserError('Invoice date and the max date should be filled');
if (this.invoiceDate < this.maxShipped)
throw new UserError('Invoice date can\'t be less than max date');
if (this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
throw new UserError('Exists an invoice with a previous date');
if (!this.companyFk)
throw new UserError('Choose a valid company');