Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
0b704db353
|
@ -22,6 +22,9 @@
|
|||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"isAutoConciliated": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
|
|
|
@ -65,6 +65,7 @@ module.exports = Self => {
|
|||
let clientId = args.clientFk;
|
||||
let maxShipped = args.maxShipped;
|
||||
let companyId;
|
||||
let newInvoice;
|
||||
let query;
|
||||
try {
|
||||
if (ticketId) {
|
||||
|
@ -137,18 +138,18 @@ module.exports = Self => {
|
|||
], myOptions);
|
||||
}
|
||||
|
||||
const [newInvoice] = await Self.rawSql(`SELECT @newInvoiceId id`, null, myOptions);
|
||||
[newInvoice] = await Self.rawSql(`SELECT @newInvoiceId id`, null, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
if (newInvoice.id)
|
||||
await Self.createPdf(ctx, newInvoice.id);
|
||||
|
||||
return newInvoice;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (newInvoice.id)
|
||||
await Self.createPdf(ctx, newInvoice.id);
|
||||
|
||||
return newInvoice;
|
||||
};
|
||||
|
||||
async function isInvoiceable(clientId, options) {
|
||||
|
|
|
@ -43,8 +43,6 @@ module.exports = Self => {
|
|||
|
||||
Self.globalInvoicing = async(ctx, options) => {
|
||||
const args = ctx.args;
|
||||
const invoicesIds = [];
|
||||
const failedClients = [];
|
||||
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
|
@ -57,6 +55,8 @@ module.exports = Self => {
|
|||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
const invoicesIds = [];
|
||||
const failedClients = [];
|
||||
let query;
|
||||
try {
|
||||
query = `
|
||||
|
@ -155,16 +155,16 @@ module.exports = Self => {
|
|||
await notifyFailures(ctx, failedClients, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
// Print invoices PDF
|
||||
for (let invoiceId of invoicesIds)
|
||||
await Self.createPdf(ctx, invoiceId);
|
||||
|
||||
return invoicesIds;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
// Print invoices PDF
|
||||
for (let invoiceId of invoicesIds)
|
||||
await Self.createPdf(ctx, invoiceId);
|
||||
|
||||
return invoicesIds;
|
||||
};
|
||||
|
||||
async function getNegativeBase(options) {
|
||||
|
|
|
@ -38,6 +38,8 @@ module.exports = function(Self) {
|
|||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
let serial;
|
||||
let invoiceId;
|
||||
try {
|
||||
const tickets = await models.Ticket.find({
|
||||
where: {
|
||||
|
@ -68,7 +70,7 @@ module.exports = function(Self) {
|
|||
companyId,
|
||||
'R'
|
||||
], myOptions);
|
||||
const serial = result.serial;
|
||||
serial = result.serial;
|
||||
|
||||
await Self.rawSql(`
|
||||
DROP TEMPORARY TABLE IF EXISTS ticketToInvoice;
|
||||
|
@ -83,7 +85,7 @@ module.exports = function(Self) {
|
|||
|
||||
const [resultInvoice] = await Self.rawSql('SELECT @invoiceId id', [], myOptions);
|
||||
|
||||
const invoiceId = resultInvoice.id;
|
||||
invoiceId = resultInvoice.id;
|
||||
|
||||
for (let ticket of tickets) {
|
||||
const ticketInvoice = await models.Ticket.findById(ticket.id, {
|
||||
|
@ -104,14 +106,14 @@ module.exports = function(Self) {
|
|||
await Self.rawSql('CALL invoiceOutBooking(?)', [invoiceId], myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
if (serial != 'R' && invoiceId)
|
||||
await models.InvoiceOut.createPdf(ctx, invoiceId);
|
||||
|
||||
return {invoiceFk: invoiceId, serial: serial};
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (serial != 'R' && invoiceId)
|
||||
await models.InvoiceOut.createPdf(ctx, invoiceId);
|
||||
|
||||
return {invoiceFk: invoiceId, serial: serial};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue