feat: refs #6739 transferInvoice new functionality #2412

Merged
jon merged 10 commits from 6739-transferInvoiceOut into dev 2024-05-10 04:51:42 +00:00
2 changed files with 22 additions and 29 deletions
Showing only changes of commit 9d75ba0bc5 - Show all commits

View File

@ -1,15 +1,3 @@
<vn-crud-model
auto-load="true"
url="CplusRectificationTypes"
data="cplusRectificationTypes"
order="description">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="SiiTypeInvoiceOuts"
data="siiTypeInvoiceOuts"
where="{code: {like: 'R%'}}">
</vn-crud-model>
<vn-crud-model
auto-load="true"
url="InvoiceCorrectionTypes"
@ -211,15 +199,14 @@
vn-one
vn-id="cplusRectificationType"
required="true"
data="cplusRectificationTypes"
data="$ctrl.cplusRectificationTypes"
show-field="description"
value-field="id"
ng-model="$ctrl.cplusRectificationType"
ng-init="$ctrl.cplusRectificationType = (cplusRectificationTypes.length > 0 ? cplusRectificationTypes[1].id : null)"
search-function="{or: [{id: $search}, {description: {like: '%'+ $search +'%'}}]}"
label="Rectificative type">
<tpl-item>
{{::description}}
{{ ::description}}
</tpl-item>
</vn-autocomplete>
</vn-horizontal>
@ -227,13 +214,12 @@
<vn-autocomplete
vn-one
vn-id="siiTypeInvoiceOut"
data="siiTypeInvoiceOuts"
data="$ctrl.siiTypeInvoiceOuts"
show-field="description"
value-field="id"
fields="['id','code','description']"
required="true"
ng-model="$ctrl.siiTypeInvoiceOut"
ng-init="$ctrl.siiTypeInvoiceOut = (siiTypeInvoiceOuts.length > 0 ? siiTypeInvoiceOuts[3].id : null)"
label="Class">
<tpl-item>
{{::code}} - {{::description}}

View File

@ -8,6 +8,16 @@ class Controller extends Section {
this.vnReport = vnReport;
this.vnEmail = vnEmail;
this.checked = true;
this.$http.get(`CplusRectificationTypes`, {filter: {order: 'description'}})
.then(res => {
this.cplusRectificationTypes = res.data;
this.cplusRectificationType = res.data.filter(type => type.description == 'I Por diferencias')[0].id;
});
this.$http.get(`SiiTypeInvoiceOuts`, {filter: {where: {code: {like: 'R%'}}}})
.then(res => {
this.siiTypeInvoiceOuts = res.data;
this.siiTypeInvoiceOut = res.data.filter(type => type.code == 'R4')[0].id;
});
}
get invoiceOut() {
@ -149,23 +159,20 @@ class Controller extends Section {
checked: this.checked
};
const transferInvoiceRequest = () => {
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
const invoiceId = res.data;
this.vnApp.showSuccess(this.$t('Transferred invoice'));
this.$state.go('invoiceOut.card.summary', {id: invoiceId});
});
};
this.$http.get(`Clients/${this.clientId}`).then(response => {
const clientData = response.data;
const hasToInvoiceByAddress = clientData.hasToInvoiceByAddress;
if (this.checked && hasToInvoiceByAddress) {
if (window.confirm('El cliente destino tiene marcado facturar por consignatario, ¿desea continuar?'))
transferInvoiceRequest();
} else
transferInvoiceRequest();
if (!window.confirm('El cliente destino tiene marcado facturar por consignatario, ¿desea continuar?'))
return;
}
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
const invoiceId = res.data;
this.vnApp.showSuccess(this.$t('Transferred invoice'));
this.$state.go('invoiceOut.card.summary', {id: invoiceId});
});
});
}
}