refs #5874 feat: refactor code
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
af4de1895b
commit
aa666ee08d
|
@ -304,7 +304,5 @@
|
|||
"Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico",
|
||||
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado",
|
||||
"Valid priorities": "Prioridades válidas: %d",
|
||||
"There are no tickets to bill": "There are no tickets to bill",
|
||||
"Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}",
|
||||
"Base negativa para los tickets: 10": "Base negativa para los tickets: 10"
|
||||
}
|
||||
"Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}"
|
||||
}
|
||||
|
|
|
@ -74,7 +74,8 @@ module.exports = Self => {
|
|||
], options);
|
||||
}
|
||||
|
||||
const invoiceId = await models.Ticket.makeInvoice(ctx, 'G', args.companyFk, options);
|
||||
const invoiceType = 'G';
|
||||
const invoiceId = await models.Ticket.makeInvoice(ctx, invoiceType, args.companyFk, options);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
|
|
|
@ -56,15 +56,21 @@ module.exports = function(Self) {
|
|||
|
||||
const today = Date.vnNew();
|
||||
|
||||
const invalidTickets = tickets.some(ticket => {
|
||||
tickets.some(ticket => {
|
||||
const shipped = new Date(ticket.shipped);
|
||||
const shippingInFuture = shipped.getTime() > today.getTime();
|
||||
const isInvoiced = ticket.refFk;
|
||||
const priceZero = ticket.totalWithVat == 0;
|
||||
if (shippingInFuture)
|
||||
throw new UserError(`Can't invoice to future`);
|
||||
|
||||
return isInvoiced || priceZero || shippingInFuture;
|
||||
const isInvoiced = ticket.refFk;
|
||||
if (isInvoiced)
|
||||
throw new UserError(`This ticket is already invoiced`);
|
||||
|
||||
const priceZero = ticket.totalWithVat == 0;
|
||||
if (priceZero)
|
||||
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
||||
});
|
||||
|
||||
return !(invalidTickets || hasAnyNegativeBase);
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -59,9 +59,7 @@ module.exports = function(Self) {
|
|||
fields: ['id', 'clientFk']
|
||||
}, myOptions);
|
||||
|
||||
const ticketCanBeInvoiced = await models.Ticket.canBeInvoiced(ctx, ticketsIds, myOptions);
|
||||
if (!ticketCanBeInvoiced || !ticketToInvoice.length)
|
||||
throw new UserError(`Some of the selected tickets are not billable`);
|
||||
await models.Ticket.canBeInvoiced(ctx, ticketsIds, myOptions);
|
||||
|
||||
const [firstTicket] = tickets;
|
||||
const clientId = firstTicket.clientFk;
|
||||
|
|
Loading…
Reference in New Issue