feat: refs #6739 transferInvoice new functionality #2412
|
@ -33,7 +33,6 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
await Self.makePdf(id, options);
|
await Self.makePdf(id, options);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
|
||||||
throw new UserError('Error while generating PDF', 'pdfError');
|
throw new UserError('Error while generating PDF', 'pdfError');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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
|
<vn-crud-model
|
||||||
auto-load="true"
|
auto-load="true"
|
||||||
url="InvoiceCorrectionTypes"
|
url="InvoiceCorrectionTypes"
|
||||||
|
@ -211,7 +199,7 @@
|
||||||
vn-one
|
vn-one
|
||||||
vn-id="cplusRectificationType"
|
vn-id="cplusRectificationType"
|
||||||
required="true"
|
required="true"
|
||||||
data="cplusRectificationTypes"
|
data="$ctrl.cplusRectificationTypes"
|
||||||
show-field="description"
|
show-field="description"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
ng-model="$ctrl.cplusRectificationType"
|
ng-model="$ctrl.cplusRectificationType"
|
||||||
|
@ -226,7 +214,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
vn-id="siiTypeInvoiceOut"
|
vn-id="siiTypeInvoiceOut"
|
||||||
data="siiTypeInvoiceOuts"
|
data="$ctrl.siiTypeInvoiceOuts"
|
||||||
show-field="description"
|
show-field="description"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
fields="['id','code','description']"
|
fields="['id','code','description']"
|
||||||
|
@ -248,6 +236,14 @@
|
||||||
label="Type">
|
label="Type">
|
||||||
jon marked this conversation as resolved
Outdated
|
|||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-check
|
||||||
|
ng-model="$ctrl.isChecked"
|
||||||
|
label="destinationClient"
|
||||||
|
info="transferInvoiceInfo"
|
||||||
|
/>
|
||||||
|
</vn-check>
|
||||||
|
</vn-horizontal>
|
||||||
</section>
|
</section>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
<tpl-buttons>
|
<tpl-buttons>
|
||||||
|
|
|
@ -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,26 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$onInit() {
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
loadData() {
|
loadData() {
|
||||||
const filter = {
|
const filter = {
|
||||||
include: [
|
include: [
|
||||||
|
@ -34,7 +55,7 @@ class Controller extends Section {
|
||||||
}, {
|
}, {
|
||||||
relation: 'client',
|
relation: 'client',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id', 'name', 'email']
|
fields: ['id', 'name', 'email', 'hasToInvoiceByAddress']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -136,13 +157,25 @@ 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;
|
||||||
jon marked this conversation as resolved
Outdated
jgallego
commented
usar el negado para no llamar 2 veces a la funcion usar el negado para no llamar 2 veces a la funcion
|
|||||||
|
const hasToInvoiceByAddress = clientData.hasToInvoiceByAddress;
|
||||||
|
|
||||||
|
if (this.checked && hasToInvoiceByAddress) {
|
||||||
|
if (!window.confirm(this.$t('confirmTransferInvoice')))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
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});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
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
|
||||||
|
transferInvoiceInfo: New tickets from the destination customer will be generated in the default consignee.
|
||||||
|
confirmTransferInvoice: Destination customer has marked to bill by consignee, do you want to continue?
|
|
@ -24,3 +24,7 @@ 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
|
||||||
|
transferInvoiceInfo: Los nuevos tickets del cliente destino serán generados en el consignatario por defecto.
|
||||||
jgallego marked this conversation as resolved
Outdated
jgallego
commented
esta clave checkinfo es ambigua, podria tener colisiones con otras secciones y ser de algo totalmente distinto, pon algo mas concreto si no te viene nada chatgpt esta clave checkinfo es ambigua, podria tener colisiones con otras secciones y ser de algo totalmente distinto, pon algo mas concreto si no te viene nada chatgpt
|
|||||||
|
confirmTransferInvoice: El cliente destino tiene marcado facturar por consignatario, ¿desea continuar?
|
Loading…
Reference in New Issue
no poner numeros