Merge branch 'dev' into 5546-codigo-registro
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
b4ef49cf24
|
@ -0,0 +1,74 @@
|
|||
DROP TABLE `vn`.`dmsRecover`;
|
||||
|
||||
ALTER TABLE `vn`.`delivery` DROP FOREIGN KEY delivery_FK;
|
||||
ALTER TABLE `vn`.`delivery` DROP COLUMN addressFk;
|
||||
ALTER TABLE `vn`.`delivery` ADD ticketFk INT NOT NULL;
|
||||
ALTER TABLE `vn`.`delivery` ADD CONSTRAINT delivery_ticketFk_FK FOREIGN KEY (`ticketFk`) REFERENCES `vn`.`ticket`(`id`);
|
||||
|
||||
DELETE FROM `salix`.`ACL` WHERE `property` = 'saveSign';
|
||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||
VALUES
|
||||
('Ticket','saveSign','WRITE','ALLOW','employee');
|
||||
|
||||
DROP PROCEDURE IF EXISTS vn.route_getTickets;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_getTickets`(vRouteFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Pasado un RouteFk devuelve la información
|
||||
* de sus tickets.
|
||||
*
|
||||
* @param vRouteFk
|
||||
*
|
||||
* @select Información de los tickets
|
||||
*/
|
||||
|
||||
SELECT
|
||||
t.id Id,
|
||||
t.clientFk Client,
|
||||
a.id Address,
|
||||
t.packages Packages,
|
||||
a.street AddressName,
|
||||
a.postalCode PostalCode,
|
||||
a.city City,
|
||||
sub2.itemPackingTypeFk PackingType,
|
||||
c.phone ClientPhone,
|
||||
c.mobile ClientMobile,
|
||||
a.phone AddressPhone,
|
||||
a.mobile AddressMobile,
|
||||
d.longitude Longitude,
|
||||
d.latitude Latitude,
|
||||
wm.mediaValue SalePersonPhone,
|
||||
tob.Note Note,
|
||||
t.isSigned Signed
|
||||
FROM ticket t
|
||||
JOIN client c ON t.clientFk = c.id
|
||||
JOIN address a ON t.addressFk = a.id
|
||||
LEFT JOIN delivery d ON t.id = d.ticketFk
|
||||
LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk
|
||||
LEFT JOIN
|
||||
(SELECT tob.description Note, t.id
|
||||
FROM ticketObservation tob
|
||||
JOIN ticket t ON tob.ticketFk = t.id
|
||||
JOIN observationType ot ON ot.id = tob.observationTypeFk
|
||||
WHERE t.routeFk = vRouteFk
|
||||
AND ot.code = 'delivery'
|
||||
)tob ON tob.id = t.id
|
||||
LEFT JOIN
|
||||
(SELECT sub.ticketFk,
|
||||
CONCAT('(', GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk ORDER BY sub.items DESC SEPARATOR ','), ') ') itemPackingTypeFk
|
||||
FROM (SELECT s.ticketFk , i.itemPackingTypeFk, COUNT(*) items
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE t.routeFk = vRouteFk
|
||||
GROUP BY t.id,i.itemPackingTypeFk)sub
|
||||
GROUP BY sub.ticketFk
|
||||
) sub2 ON sub2.ticketFk = t.id
|
||||
WHERE t.routeFk = vRouteFk
|
||||
GROUP BY t.id
|
||||
ORDER BY t.priority;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,67 @@
|
|||
DELETE FROM `salix`.`ACL` WHERE `property` = 'saveSign';
|
||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||
VALUES
|
||||
('Ticket','saveSign','WRITE','ALLOW','employee');
|
||||
|
||||
DROP PROCEDURE IF EXISTS vn.route_getTickets;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_getTickets`(vRouteFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Pasado un RouteFk devuelve la información
|
||||
* de sus tickets.
|
||||
*
|
||||
* @param vRouteFk
|
||||
*
|
||||
* @select Información de los tickets
|
||||
*/
|
||||
|
||||
SELECT
|
||||
t.id Id,
|
||||
t.clientFk Client,
|
||||
a.id Address,
|
||||
t.packages Packages,
|
||||
a.street AddressName,
|
||||
a.postalCode PostalCode,
|
||||
a.city City,
|
||||
sub2.itemPackingTypeFk PackingType,
|
||||
c.phone ClientPhone,
|
||||
c.mobile ClientMobile,
|
||||
a.phone AddressPhone,
|
||||
a.mobile AddressMobile,
|
||||
d.longitude Longitude,
|
||||
d.latitude Latitude,
|
||||
wm.mediaValue SalePersonPhone,
|
||||
tob.Note Note,
|
||||
t.isSigned Signed
|
||||
FROM ticket t
|
||||
JOIN client c ON t.clientFk = c.id
|
||||
JOIN address a ON t.addressFk = a.id
|
||||
LEFT JOIN delivery d ON t.id = d.ticketFk
|
||||
LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk
|
||||
LEFT JOIN
|
||||
(SELECT tob.description Note, t.id
|
||||
FROM ticketObservation tob
|
||||
JOIN ticket t ON tob.ticketFk = t.id
|
||||
JOIN observationType ot ON ot.id = tob.observationTypeFk
|
||||
WHERE t.routeFk = vRouteFk
|
||||
AND ot.code = 'delivery'
|
||||
)tob ON tob.id = t.id
|
||||
LEFT JOIN
|
||||
(SELECT sub.ticketFk,
|
||||
CONCAT('(', GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk ORDER BY sub.items DESC SEPARATOR ','), ') ') itemPackingTypeFk
|
||||
FROM (SELECT s.ticketFk , i.itemPackingTypeFk, COUNT(*) items
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE t.routeFk = vRouteFk
|
||||
GROUP BY t.id,i.itemPackingTypeFk)sub
|
||||
GROUP BY sub.ticketFk
|
||||
) sub2 ON sub2.ticketFk = t.id
|
||||
WHERE t.routeFk = vRouteFk
|
||||
GROUP BY t.id
|
||||
ORDER BY t.priority;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,83 @@
|
|||
CREATE TABLE `vn`.`dmsRecover` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`ticketFk` int(11) DEFAULT NULL,
|
||||
`sign` text DEFAULT NULL,
|
||||
`created` timestamp NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `ticketFk_idx` (`ticketFk`),
|
||||
CONSTRAINT `ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=31917 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
ALTER TABLE `vn`.`delivery` ADD addressFk INT;
|
||||
|
||||
DROP PROCEDURE IF EXISTS `vn`.`route_getTickets`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_getTickets`(vRouteFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Pasado un RouteFk devuelve la información
|
||||
* de sus tickets.
|
||||
*
|
||||
* @param vRouteFk
|
||||
* @select Información de los tickets
|
||||
*/
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT t.id Id,
|
||||
t.clientFk Client,
|
||||
a.id Address,
|
||||
a.nickname ClientName,
|
||||
t.packages Packages,
|
||||
a.street AddressName,
|
||||
a.postalCode PostalCode,
|
||||
a.city City,
|
||||
sub2.itemPackingTypeFk PackingType,
|
||||
c.phone ClientPhone,
|
||||
c.mobile ClientMobile,
|
||||
a.phone AddressPhone,
|
||||
a.mobile AddressMobile,
|
||||
d.longitude Longitude,
|
||||
d.latitude Latitude,
|
||||
wm.mediaValue SalePersonPhone,
|
||||
tob.description Note,
|
||||
t.isSigned Signed,
|
||||
t.priority
|
||||
FROM ticket t
|
||||
JOIN client c ON t.clientFk = c.id
|
||||
JOIN address a ON t.addressFk = a.id
|
||||
LEFT JOIN delivery d ON d.addressFk = a.id
|
||||
LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk
|
||||
LEFT JOIN(
|
||||
SELECT tob.description, t.id
|
||||
FROM ticketObservation tob
|
||||
JOIN ticket t ON tob.ticketFk = t.id
|
||||
JOIN observationType ot ON ot.id = tob.observationTypeFk
|
||||
WHERE t.routeFk = vRouteFk
|
||||
AND ot.code = 'delivery'
|
||||
)tob ON tob.id = t.id
|
||||
LEFT JOIN(
|
||||
SELECT sub.ticketFk,
|
||||
CONCAT('(',
|
||||
GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk
|
||||
ORDER BY sub.items DESC SEPARATOR ','),
|
||||
') ') itemPackingTypeFk
|
||||
FROM (
|
||||
SELECT s.ticketFk, i.itemPackingTypeFk, COUNT(*) items
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE t.routeFk = vRouteFk
|
||||
GROUP BY t.id, i.itemPackingTypeFk
|
||||
)sub
|
||||
GROUP BY sub.ticketFk
|
||||
)sub2 ON sub2.ticketFk = t.id
|
||||
WHERE t.routeFk = vRouteFk
|
||||
ORDER BY d.id DESC
|
||||
LIMIT 10000000000000000000
|
||||
)sub3
|
||||
GROUP BY sub3.id
|
||||
ORDER BY sub3.priority;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -56,7 +56,7 @@ module.exports = Self => {
|
|||
reference: invoiceOut.ref,
|
||||
recipientId: invoiceOut.clientFk
|
||||
});
|
||||
const stream = await invoiceReport.toPdfStream();
|
||||
const buffer = await invoiceReport.toPdfStream();
|
||||
|
||||
const issued = invoiceOut.issued;
|
||||
const year = issued.getFullYear().toString();
|
||||
|
@ -66,7 +66,7 @@ module.exports = Self => {
|
|||
const fileName = `${year}${invoiceOut.ref}.pdf`;
|
||||
|
||||
// Store invoice
|
||||
print.storage.write(stream, {
|
||||
await print.storage.write(buffer, {
|
||||
type: 'invoice',
|
||||
path: `${year}/${month}/${day}`,
|
||||
fileName: fileName
|
||||
|
|
|
@ -100,16 +100,23 @@ class Controller extends Section {
|
|||
};
|
||||
|
||||
this.$http.post(`InvoiceOuts/invoiceClient`, params)
|
||||
.then(() => this.invoiceNext())
|
||||
.catch(res => {
|
||||
this.errors.unshift({
|
||||
address,
|
||||
message: res.data.error.message
|
||||
});
|
||||
const message = res.data?.error?.message || res.message;
|
||||
if (res.status >= 400 && res.status < 500) {
|
||||
this.errors.unshift({address, message});
|
||||
this.invoiceNext();
|
||||
} else {
|
||||
this.invoicing = false;
|
||||
this.status = 'done';
|
||||
throw new UserError(`Critical invoicing error, proccess stopped`);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.addressIndex++;
|
||||
this.invoiceOut();
|
||||
});
|
||||
}
|
||||
|
||||
invoiceNext() {
|
||||
this.addressIndex++;
|
||||
this.invoiceOut();
|
||||
}
|
||||
|
||||
get nAddresses() {
|
||||
|
|
|
@ -18,3 +18,4 @@ Invoice out: Facturar
|
|||
One client: Un solo cliente
|
||||
Choose a valid client: Selecciona un cliente válido
|
||||
Stop: Parar
|
||||
Critical invoicing error, proccess stopped: Error crítico al facturar, proceso detenido
|
|
@ -41,6 +41,7 @@
|
|||
type="number"
|
||||
label="Km Price"
|
||||
ng-model="$ctrl.supplierAgencyTerm.kmPrice"
|
||||
step="0.01"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
|
|
|
@ -46,7 +46,7 @@ module.exports = async function(Self, tickets, reqArgs = {}) {
|
|||
const fileName = `${year}${invoiceOut.ref}.pdf`;
|
||||
|
||||
// Store invoice
|
||||
storage.write(stream, {
|
||||
await storage.write(stream, {
|
||||
type: 'invoice',
|
||||
path: `${year}/${month}/${day}`,
|
||||
fileName: fileName
|
||||
|
|
|
@ -4,40 +4,38 @@ const {cpus} = require('os');
|
|||
|
||||
module.exports = {
|
||||
init() {
|
||||
if (!this.pool) {
|
||||
Cluster.launch({
|
||||
concurrency: Cluster.CONCURRENCY_CONTEXT,
|
||||
maxConcurrency: cpus().length,
|
||||
puppeteerOptions: {
|
||||
headless: true,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
'--no-zygote'
|
||||
]
|
||||
}
|
||||
})
|
||||
.then(cluster => {
|
||||
this.pool = cluster;
|
||||
if (this.pool) return;
|
||||
Cluster.launch({
|
||||
concurrency: Cluster.CONCURRENCY_CONTEXT,
|
||||
maxConcurrency: cpus().length,
|
||||
puppeteerOptions: {
|
||||
headless: true,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
'--no-zygote'
|
||||
]
|
||||
}
|
||||
}).then(cluster => {
|
||||
this.pool = cluster;
|
||||
|
||||
log4js.configure({
|
||||
appenders: {
|
||||
out: {type: 'stdout'}
|
||||
},
|
||||
categories: {default: {appenders: ['out'], level: 'info'}},
|
||||
});
|
||||
log4js.configure({
|
||||
appenders: {
|
||||
out: {type: 'stdout'}
|
||||
},
|
||||
categories: {default: {appenders: ['out'], level: 'info'}},
|
||||
});
|
||||
|
||||
const logger = log4js.getLogger();
|
||||
const logger = log4js.getLogger();
|
||||
|
||||
cluster.on('taskerror', (err, data, willRetry) => {
|
||||
if (willRetry)
|
||||
logger.warn(`[Print] => ${err.message}\nThis job will be retried`);
|
||||
else
|
||||
logger.error(`[Print] => ${err.message}`);
|
||||
});
|
||||
cluster.on('taskerror', (err, data, willRetry) => {
|
||||
if (willRetry)
|
||||
logger.warn(`[Print] => ${err.message}\nThis job will be retried`);
|
||||
else
|
||||
logger.error(`[Print] => ${err.message}`);
|
||||
});
|
||||
|
||||
cluster.on('queue', () => logger.info('Printing task initialized by pool'));
|
||||
});
|
||||
}
|
||||
cluster.on('queue', () => logger.info('Printing task initialized by pool'));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,28 +32,31 @@ class Report extends Component {
|
|||
if (fs.existsSync(fullPath))
|
||||
options = require(optionsPath);
|
||||
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Cluster.pool.queue({}, async({page}) => {
|
||||
await page.emulateMediaType('screen');
|
||||
await page.setContent(template);
|
||||
try {
|
||||
await page.emulateMediaType('screen');
|
||||
await page.setContent(template);
|
||||
|
||||
const element = await page.$('#pageFooter');
|
||||
const element = await page.$('#pageFooter');
|
||||
|
||||
let footer = '\n';
|
||||
if (element) {
|
||||
footer = await page.evaluate(el => {
|
||||
const html = el.innerHTML;
|
||||
el.remove();
|
||||
return html;
|
||||
}, element);
|
||||
let footer = '\n';
|
||||
if (element) {
|
||||
footer = await page.evaluate(el => {
|
||||
const html = el.innerHTML;
|
||||
el.remove();
|
||||
return html;
|
||||
}, element);
|
||||
}
|
||||
|
||||
options.headerTemplate = '\n';
|
||||
options.footerTemplate = footer;
|
||||
|
||||
const buffer = await page.pdf(options);
|
||||
resolve(buffer);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
options.headerTemplate = '\n';
|
||||
options.footerTemplate = footer;
|
||||
|
||||
const stream = await page.pdf(options);
|
||||
|
||||
resolve(stream);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,26 +3,14 @@ const path = require('path');
|
|||
const fs = require('fs-extra');
|
||||
|
||||
module.exports = {
|
||||
async write(stream, options) {
|
||||
async write(buffer, options) {
|
||||
const storage = config.storage[options.type];
|
||||
|
||||
if (!storage) return;
|
||||
|
||||
const src = path.join(storage.root, options.path);
|
||||
const fileSrc = path.join(src, options.fileName);
|
||||
|
||||
await fs.mkdir(src, {recursive: true});
|
||||
|
||||
const writeStream = fs.createWriteStream(fileSrc);
|
||||
writeStream.on('open', () => writeStream.write(stream));
|
||||
writeStream.on('finish', () => writeStream.end());
|
||||
|
||||
return new Promise(resolve => {
|
||||
writeStream.on('close', () => resolve());
|
||||
});
|
||||
},
|
||||
|
||||
load(type, data) {
|
||||
|
||||
await fs.writeFile(fileSrc, buffer);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ SELECT ep.id palletFk,
|
|||
JOIN vn.expedition e ON e.id = es.expeditionFk
|
||||
JOIN vn.ticket t ON t.id = e.ticketFk
|
||||
JOIN vn.route r ON r.id = t.routeFk
|
||||
LEFT JOIN vn2008.Rutas_monitor rm ON rm.Id_Ruta = r.id
|
||||
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
|
||||
LEFT JOIN vn.expeditionTruck et2 ON et2.id = rm.expeditionTruckFk
|
||||
WHERE ep.id = ?
|
||||
GROUP BY ep.id, t.routeFk
|
||||
|
|
Loading…
Reference in New Issue