feat: refs #6739 transferInvoice new functionality
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-05-06 14:51:53 +02:00
parent 2cdc64cbe7
commit 4e78307a8d
5 changed files with 58 additions and 10 deletions

View File

@ -36,6 +36,11 @@ module.exports = Self => {
type: 'number', type: 'number',
required: true required: true
}, },
{
arg: 'checked',
type: 'boolean',
required: true
},
], ],
returns: { returns: {
type: 'boolean', type: 'boolean',
@ -51,6 +56,7 @@ module.exports = Self => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {userId: ctx.req.accessToken.userId}; const myOptions = {userId: ctx.req.accessToken.userId};
const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args; const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args;
const checked = ctx.args.checked;
let tx; let tx;
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
@ -96,9 +102,10 @@ module.exports = Self => {
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions); await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
if (!checked) {
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions); const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
return invoiceId; return invoiceId;
}
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
throw e; throw e;

View File

@ -215,6 +215,7 @@
show-field="description" show-field="description"
value-field="id" value-field="id"
ng-model="$ctrl.cplusRectificationType" ng-model="$ctrl.cplusRectificationType"
ng-init="$ctrl.cplusRectificationType = (cplusRectificationTypes.length > 0 ? cplusRectificationTypes[1].id : null)"
search-function="{or: [{id: $search}, {description: {like: '%'+ $search +'%'}}]}" search-function="{or: [{id: $search}, {description: {like: '%'+ $search +'%'}}]}"
label="Rectificative type"> label="Rectificative type">
<tpl-item> <tpl-item>
@ -232,6 +233,7 @@
fields="['id','code','description']" fields="['id','code','description']"
required="true" required="true"
ng-model="$ctrl.siiTypeInvoiceOut" ng-model="$ctrl.siiTypeInvoiceOut"
ng-init="$ctrl.siiTypeInvoiceOut = (siiTypeInvoiceOuts.length > 0 ? siiTypeInvoiceOuts[3].id : null)"
label="Class"> label="Class">
<tpl-item> <tpl-item>
{{::code}} - {{::description}} {{::code}} - {{::description}}
@ -248,6 +250,14 @@
label="Type"> label="Type">
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal>
<vn-check
ng-model="$ctrl.isChecked"
label="destinationClient"
info="checkinfo"
/>
</vn-check>
</vn-horizontal>
</section> </section>
</tpl-body> </tpl-body>
<tpl-buttons> <tpl-buttons>

View File

@ -7,6 +7,7 @@ class Controller extends Section {
super($element, $); super($element, $);
this.vnReport = vnReport; this.vnReport = vnReport;
this.vnEmail = vnEmail; this.vnEmail = vnEmail;
this.checked = true;
} }
get invoiceOut() { get invoiceOut() {
@ -23,6 +24,14 @@ class Controller extends Section {
return this.aclService.hasAny(['invoicing']); return this.aclService.hasAny(['invoicing']);
} }
get isChecked() {
return this.checked;
}
set isChecked(value) {
this.checked = value;
}
loadData() { loadData() {
const filter = { const filter = {
include: [ include: [
@ -34,7 +43,7 @@ class Controller extends Section {
}, { }, {
relation: 'client', relation: 'client',
scope: { scope: {
fields: ['id', 'name', 'email'] fields: ['id', 'name', 'email', 'hasToInvoiceByAddress']
} }
} }
] ]
@ -136,14 +145,30 @@ class Controller extends Section {
newClientFk: this.clientId, newClientFk: this.clientId,
cplusRectificationTypeFk: this.cplusRectificationType, cplusRectificationTypeFk: this.cplusRectificationType,
siiTypeInvoiceOutFk: this.siiTypeInvoiceOut, siiTypeInvoiceOutFk: this.siiTypeInvoiceOut,
invoiceCorrectionTypeFk: this.invoiceCorrectionType invoiceCorrectionTypeFk: this.invoiceCorrectionType,
checked: this.checked
}; };
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?')) {
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => { this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
const invoiceId = res.data; const invoiceId = res.data;
this.vnApp.showSuccess(this.$t('Transferred invoice')); this.vnApp.showSuccess(this.$t('Transferred invoice'));
this.$state.go('invoiceOut.card.summary', {id: invoiceId}); this.$state.go('invoiceOut.card.summary', {id: invoiceId});
}); });
} }
} else {
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});
});
}
});
}
} }
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];

View File

@ -1,3 +1,6 @@
The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}" The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}"
Transfer invoice to...: Transfer invoice to... Transfer invoice to...: Transfer invoice to...
Cplus Type: Cplus Type Cplus Type: Cplus Type
transferInvoice: Transfer Invoice
destinationClient: Bill destination client
checkinfo: New tickets from the destination customer will be generated in the consignee by default.

View File

@ -24,3 +24,6 @@ Refund...: Abono...
Transfer invoice to...: Transferir factura a... Transfer invoice to...: Transferir factura a...
Rectificative type: Tipo rectificativa Rectificative type: Tipo rectificativa
Transferred invoice: Factura transferida Transferred invoice: Factura transferida
transferInvoice: Transferir factura
destinationClient: Facturar cliente destino
checkinfo: Los nuevos tickets del cliente destino, serán generados en el consignatario por defecto.