feat: add inserts in printQueue
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
69ca28ae14
commit
31aafc0719
|
@ -2642,3 +2642,7 @@ INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`,
|
|||
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
|
||||
VALUES
|
||||
(1, 9);
|
||||
|
||||
INSERT INTO `vn`.`report` (`id`, `name`)
|
||||
VALUES
|
||||
(3, 'invoice');
|
|
@ -79,6 +79,13 @@ module.exports = Self => {
|
|||
const minShipped = new Date();
|
||||
minShipped.setFullYear(minShipped.getFullYear() - 1);
|
||||
|
||||
if (args.fromClientId = args.toClientId) {
|
||||
minShipped.setFullYear(2021);
|
||||
minShipped.setMonth(1);
|
||||
minShipped.setDate(1);
|
||||
minShipped.setHours(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Packaging liquidation
|
||||
const vIsAllInvoiceable = false;
|
||||
const clientsWithPackaging = await getClientsWithPackaging(ctx, myOptions);
|
||||
|
@ -138,8 +145,34 @@ module.exports = Self => {
|
|||
if (newInvoice.id) {
|
||||
await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], myOptions);
|
||||
|
||||
query = `INSERT IGNORE INTO invoiceOut_queue(invoiceFk) VALUES(?)`;
|
||||
await Self.rawSql(query, [newInvoice.id], myOptions);
|
||||
// query = `INSERT IGNORE INTO invoiceOut_queue(invoiceFk) VALUES(?)`;
|
||||
// await Self.rawSql(query, [newInvoice.id], myOptions);
|
||||
|
||||
query = `SELECT id FROM vn.report WHERE name ='invoice'`;
|
||||
const [reportFk] = await Self.rawSql(query, null, myOptions);
|
||||
|
||||
query = `SELECT ref FROM vn.invoiceOut WHERE id = ?`;
|
||||
const [invoiceRef] = await Self.rawSql(query, [newInvoice.id], myOptions);
|
||||
|
||||
// Print invoice
|
||||
const args = {
|
||||
invoiceOutFk: newInvoice.id,
|
||||
refFk: invoiceRef.ref,
|
||||
hasToForcePdf: true,
|
||||
email: ''
|
||||
};
|
||||
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
query = `INSERT INTO vn.printQueue (priorityFk, reportFk, workerFk, printerFk) VALUES (?, ?, ?, NULL)`;
|
||||
await Self.rawSql(query, [2, reportFk.id, userId], myOptions); // La prioridad de donde se la saca? 'adPriorityBelowNormal'
|
||||
|
||||
const [lastInsertedPrintQueue] = await Self.rawSql('SELECT LAST_INSERT_ID() AS id', null, myOptions);
|
||||
|
||||
for (let key in args) {
|
||||
query = `INSERT INTO vn.printQueueArgs (printQueueFk, name, value) VALUES (?, ?, ?)`;
|
||||
await Self.rawSql(query, [lastInsertedPrintQueue.id, key, args[key]], myOptions);
|
||||
}
|
||||
|
||||
invoicesIds.push(newInvoice.id);
|
||||
}
|
||||
|
@ -192,8 +225,10 @@ module.exports = Self => {
|
|||
const query = `SELECT DISTINCT clientFk AS id
|
||||
FROM ticket t
|
||||
JOIN ticketPackaging tp ON t.id = tp.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE t.shipped BETWEEN '2017-11-21' AND ?
|
||||
AND t.clientFk BETWEEN ? AND ?`;
|
||||
AND t.clientFk BETWEEN ? AND ?
|
||||
AND c.isActive`;
|
||||
return models.InvoiceOut.rawSql(query, [
|
||||
args.maxShipped,
|
||||
args.fromClientId,
|
||||
|
|
Loading…
Reference in New Issue