7837-testToMaster_2432 #2834
|
@ -24,7 +24,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx, userId: ctx.req.accessToken.userId};
|
const options = {transaction: tx, userId: ctx.req.accessToken.userId};
|
||||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
|
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileMultiConfig', null, options);
|
||||||
|
|
||||||
const updatableFiles = [];
|
const updatableFiles = [];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
@ -54,7 +54,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const tables = await Self.rawSql(`
|
const tables = await Self.rawSql(`
|
||||||
SELECT fileName, toTable, file
|
SELECT fileName, toTable, file
|
||||||
FROM edi.tableConfig
|
FROM edi.tableMultiConfig
|
||||||
WHERE file IN (?)`, [fileNames], options);
|
WHERE file IN (?)`, [fileNames], options);
|
||||||
|
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
|
@ -85,9 +85,9 @@ module.exports = Self => {
|
||||||
for (const file of updatableFiles) {
|
for (const file of updatableFiles) {
|
||||||
console.log(`Updating file ${file.name} checksum...`);
|
console.log(`Updating file ${file.name} checksum...`);
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
UPDATE edi.fileConfig
|
UPDATE edi.fileMultiConfig
|
||||||
SET checksum = ?
|
SET checksum = ?
|
||||||
WHERE name = ?`,
|
WHERE name = ?`,
|
||||||
[file.checksum, file.name], options);
|
[file.checksum, file.name], options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
await Self.rawSql(sqlTemplate, [filePath], options);
|
await Self.rawSql(sqlTemplate, [filePath], options);
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
UPDATE edi.tableConfig
|
UPDATE edi.tableMultiConfig
|
||||||
SET updated = ?
|
SET updated = ?
|
||||||
WHERE fileName = ?
|
WHERE fileName = ?
|
||||||
`, [Date.vnNew(), baseName], options);
|
`, [Date.vnNew(), baseName], options);
|
||||||
|
|
|
@ -13,7 +13,7 @@ module.exports = Self => {
|
||||||
required: true
|
required: true
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: 'boolean',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -39,6 +39,7 @@ module.exports = Self => {
|
||||||
const xmlString = response.data;
|
const xmlString = response.data;
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||||
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||||
|
return result.toLowerCase().includes('se ha cancelado correctamente');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "salix.defaultViewConfig"
|
"table": "salix.defaultViewMultiConfig"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "userConfig"
|
"table": "userMultiConfig"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -10,9 +10,6 @@ SET foreign_key_checks = 0;
|
||||||
INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
|
INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
|
||||||
VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
|
VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
|
||||||
|
|
||||||
INSERT INTO util.binlogQueue (code,logName, `position`)
|
|
||||||
VALUES ('mylogger', 'bin.000001', 4);
|
|
||||||
|
|
||||||
/* #5483
|
/* #5483
|
||||||
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
|
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
|
||||||
VALUES(1, NULL, 1, 300, 1);
|
VALUES(1, NULL, 1, 300, 1);
|
||||||
|
|
|
@ -1516,23 +1516,23 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
|
||||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
|
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
|
||||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '');
|
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '');
|
||||||
|
|
||||||
INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`)
|
INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleQuantity`, `saleInternalWaste`, `saleExternalWaste`)
|
||||||
VALUES
|
VALUES
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '1777', '13', '12.02', '53.12'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '3182', '59', '51', '56.20'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '1747', '13', '53.12', '53.12'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '7182', '59', '51', '53.12'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '1777', '13', '89.69', '89.69'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 8, 1, '4181', '59', '53.12', '53.12'),
|
||||||
('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'),
|
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 9, 1, '7268', '59', '12.02', '56.20'),
|
||||||
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '-74', '0', '51', '89.69'),
|
||||||
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '-7', '0', '12.02', '53.12'),
|
||||||
('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '1100', '0', '51', '56.20'),
|
||||||
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '848', '-187', '12.02', '89.69'),
|
||||||
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12'),
|
||||||
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0');
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20');
|
||||||
|
|
||||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -1968,7 +1968,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
|
||||||
(21, 21),
|
(21, 21),
|
||||||
(22, 22);
|
(22, 22);
|
||||||
|
|
||||||
INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
INSERT INTO `vn`.`userMultiConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 69),
|
(1, 1, 69),
|
||||||
(5, 1, 442),
|
(5, 1, 442),
|
||||||
|
|
|
@ -1,31 +1,50 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vWeek INT;
|
DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(CURDATE()) DAY;
|
||||||
DECLARE vYear INT;
|
DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY;
|
||||||
|
|
||||||
|
CALL cache.last_buy_refresh(FALSE);
|
||||||
|
|
||||||
SELECT week, year
|
|
||||||
INTO vWeek, vYear
|
|
||||||
FROM vn.time
|
|
||||||
WHERE dated = util.VN_CURDATE();
|
|
||||||
|
|
||||||
REPLACE bs.waste
|
REPLACE bs.waste
|
||||||
SELECT *, 100 * mermas / total as porcentaje
|
SELECT YEAR(t.shipped),
|
||||||
FROM (
|
WEEK(t.shipped, 4),
|
||||||
SELECT buyer,
|
it.workerFk,
|
||||||
year,
|
it.id,
|
||||||
week,
|
s.itemFk,
|
||||||
family,
|
SUM(s.quantity),
|
||||||
itemFk,
|
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) `value`,
|
||||||
itemTypeFk,
|
SUM (
|
||||||
floor(sum(value)) as total,
|
IF(
|
||||||
floor(sum(IF(typeFk = 'loses', value, 0))) as mermas
|
aw.`type` = 'internal',
|
||||||
FROM vn.saleValue
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
where year = vYear and week = vWeek
|
0
|
||||||
|
)
|
||||||
GROUP BY family, itemFk
|
) internalWaste,
|
||||||
|
SUM (
|
||||||
) sub
|
IF(
|
||||||
ORDER BY mermas DESC;
|
aw.`type` = 'external',
|
||||||
|
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||||
|
IF(c.code = 'manaClaim',
|
||||||
|
sc.value * s.quantity,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) externalWaste
|
||||||
|
FROM vn.sale s
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk
|
||||||
|
LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id
|
||||||
|
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||||
|
JOIN cache.last_buy lb ON lb.item_id = i.id
|
||||||
|
AND lb.warehouse_id = w.id
|
||||||
|
JOIN vn.buy b ON b.id = lb.buy_id
|
||||||
|
LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||||
|
LEFT JOIN vn.component c ON c.id = sc.componentFk
|
||||||
|
WHERE t.shipped BETWEEN vDateFrom AND vDateTo
|
||||||
|
AND w.isManaged
|
||||||
|
GROUP BY it.id, i.id;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -10,5 +10,5 @@ AS SELECT `q`.`name` AS `name`,
|
||||||
`c`.`ringInUse` AS `ringinuse`
|
`c`.`ringInUse` AS `ringinuse`
|
||||||
FROM (
|
FROM (
|
||||||
`pbx`.`queue` `q`
|
`pbx`.`queue` `q`
|
||||||
JOIN `pbx`.`queueConfig` `c` ON(`q`.`config` = `c`.`id`)
|
JOIN `pbx`.`queueMultiConfig` `c` ON(`q`.`config` = `c`.`id`)
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,7 +7,7 @@ DECLARE vCompanyFk INT;
|
||||||
SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk)
|
SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk)
|
||||||
INTO vCompanyFk
|
INTO vCompanyFk
|
||||||
FROM vn.routeConfig rc
|
FROM vn.routeConfig rc
|
||||||
LEFT JOIN userConfig uc ON uc.userFk = workerFk;
|
LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk;
|
||||||
|
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
@ -216,7 +216,7 @@ BEGIN
|
||||||
i.transactionTypeSageFk,
|
i.transactionTypeSageFk,
|
||||||
@vTaxCodeGeneral := i.taxClassCodeFk
|
@vTaxCodeGeneral := i.taxClassCodeFk
|
||||||
FROM tmp.ticketServiceTax tst
|
FROM tmp.ticketServiceTax tst
|
||||||
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
|
JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tst.code
|
||||||
WHERE i.isService
|
WHERE i.isService
|
||||||
HAVING taxableBase
|
HAVING taxableBase
|
||||||
) sub;
|
) sub;
|
||||||
|
@ -229,7 +229,7 @@ BEGIN
|
||||||
i.taxTypeSageFk ,
|
i.taxTypeSageFk ,
|
||||||
i.transactionTypeSageFk
|
i.transactionTypeSageFk
|
||||||
FROM tmp.ticketTax tt
|
FROM tmp.ticketTax tt
|
||||||
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
|
JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tt.code
|
||||||
WHERE !i.isService
|
WHERE !i.isService
|
||||||
GROUP BY tt.pgcFk
|
GROUP BY tt.pgcFk
|
||||||
HAVING taxableBase
|
HAVING taxableBase
|
||||||
|
|
|
@ -10,19 +10,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`(
|
||||||
)
|
)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
/**
|
/**
|
||||||
* Genera una tabla de comparativa de artículos por itemType/comprador/fecha.
|
* Generates a comparison table of items by itemType/buyer/date.
|
||||||
* Los datos se calculan en función de los parámetros proporcionados.
|
* The data is calculated based on the provided parameters.
|
||||||
*
|
*
|
||||||
* @param vDate La fecha para la cual se generará la comparativa.
|
* @param vDate The date for which the comparison will be generated.
|
||||||
* @param vDayRange El rango de días a considerar para la comparativa.
|
* @param vDayRange The range of days to consider for the comparison.
|
||||||
* @param vWarehouseFk El identificador del almacén para filtrar los artículos.
|
* @param vWarehouseFk The warehouse identifier to filter the items.
|
||||||
* @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles.
|
* @param vAvailableSince The availability date from which the items are considered available.
|
||||||
* @param vBuyerFk El identificador del comprador para filtrar los artículos.
|
* @param vBuyerFk The buyer identifier to filter the items.
|
||||||
* @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional).
|
* @param vIsFloramondo Indicates whether only Floramondo items should be included (optional).
|
||||||
* @param vCountryFk El identificador del país.
|
* @param vCountryFk The country identifier.
|
||||||
* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT)
|
* @param tmp.comparativeFilterType(filterFk INT, itemTypeFk INT)
|
||||||
* @return tmp.comparative
|
* @return tmp.comparative
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DECLARE vDayRangeStart DATE;
|
DECLARE vDayRangeStart DATE;
|
||||||
DECLARE vDayRangeEnd DATE;
|
DECLARE vDayRangeEnd DATE;
|
||||||
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
|
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
|
||||||
|
|
|
@ -42,7 +42,7 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT warehouseFk INTO vWarehouseFk
|
SELECT warehouseFk INTO vWarehouseFk
|
||||||
FROM userConfig
|
FROM userMultiConfig
|
||||||
WHERE userFk = account.myUser_getId();
|
WHERE userFk = account.myUser_getId();
|
||||||
|
|
||||||
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
|
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
|
||||||
|
|
|
@ -46,12 +46,18 @@ BEGIN
|
||||||
i.tag8 = JSON_VALUE(vTags, '$.8'),
|
i.tag8 = JSON_VALUE(vTags, '$.8'),
|
||||||
i.tag9 = JSON_VALUE(vTags, '$.9'),
|
i.tag9 = JSON_VALUE(vTags, '$.9'),
|
||||||
i.tag10 = JSON_VALUE(vTags, '$.10'),
|
i.tag10 = JSON_VALUE(vTags, '$.10'),
|
||||||
|
i.tag11 = JSON_VALUE(vTags, '$.11'),
|
||||||
|
i.tag12 = JSON_VALUE(vTags, '$.12'),
|
||||||
|
i.tag13 = JSON_VALUE(vTags, '$.13'),
|
||||||
i.value5 = JSON_VALUE(vValues, '$.5'),
|
i.value5 = JSON_VALUE(vValues, '$.5'),
|
||||||
i.value6 = JSON_VALUE(vValues, '$.6'),
|
i.value6 = JSON_VALUE(vValues, '$.6'),
|
||||||
i.value7 = JSON_VALUE(vValues, '$.7'),
|
i.value7 = JSON_VALUE(vValues, '$.7'),
|
||||||
i.value8 = JSON_VALUE(vValues, '$.8'),
|
i.value8 = JSON_VALUE(vValues, '$.8'),
|
||||||
i.value9 = JSON_VALUE(vValues, '$.9'),
|
i.value9 = JSON_VALUE(vValues, '$.9'),
|
||||||
i.value10 = JSON_VALUE(vValues, '$.10'),
|
i.value10 = JSON_VALUE(vValues, '$.10'),
|
||||||
|
i.value11 = JSON_VALUE(vValues, '$.11'),
|
||||||
|
i.value12 = JSON_VALUE(vValues, '$.12'),
|
||||||
|
i.value13 = JSON_VALUE(vValues, '$.13'),
|
||||||
i.producerFk = p.id,
|
i.producerFk = p.id,
|
||||||
i.inkFk = k.id,
|
i.inkFk = k.id,
|
||||||
i.originFk = IFNULL(o.id, i.originFk)
|
i.originFk = IFNULL(o.id, i.originFk)
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(vRoute INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(
|
||||||
|
vSelf INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Actualiza el volumen de la ruta.
|
||||||
|
*
|
||||||
|
* @param vSelf Id ruta
|
||||||
|
*/
|
||||||
|
DECLARE vVolume DECIMAL(10,1)
|
||||||
|
DEFAULT (SELECT SUM(volume) FROM saleVolume WHERE routeFk = vSelf);
|
||||||
|
|
||||||
UPDATE vn.route r
|
UPDATE `route`
|
||||||
LEFT JOIN (
|
SET m3 = IFNULL(vVolume, 0)
|
||||||
SELECT routeFk, SUM(volume) AS m3
|
WHERE id = vSelf;
|
||||||
FROM saleVolume
|
|
||||||
WHERE routeFk = vRoute
|
|
||||||
) v ON v.routeFk = r.id
|
|
||||||
SET r.m3 = IFNULL(v.m3,0)
|
|
||||||
WHERE r.id =vRoute;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL;
|
||||||
|
USE vn;
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tBuyers
|
||||||
|
ENGINE = MEMORY
|
||||||
|
WITH tDistinctBuyers AS (
|
||||||
|
SELECT DISTINCT buyer
|
||||||
|
FROM bs.waste w
|
||||||
|
)
|
||||||
|
SELECT buyer, u.id
|
||||||
|
FROM tDistinctBuyers tdb
|
||||||
|
JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
UPDATE bs.waste w
|
||||||
|
JOIN tBuyers tb ON tb.buyer = w.buyer
|
||||||
|
SET w.buyerFk = tb.id;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tBuyers;
|
||||||
|
|
||||||
|
ALTER TABLE bs.waste
|
||||||
|
DROP PRIMARY KEY,
|
||||||
|
DROP COLUMN family,
|
||||||
|
DROP COLUMN rate,
|
||||||
|
DROP COLUMN buyer;
|
||||||
|
|
||||||
|
ALTER TABLE bs.waste CHANGE buyerFk buyerFk int(10) unsigned NOT NULL AFTER `week`;
|
||||||
|
ALTER TABLE bs.waste ADD CONSTRAINT waste_user_FK FOREIGN KEY (buyerFk) REFERENCES account.user(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||||
|
ALTER TABLE bs.waste ADD saleQuantity int(11) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste MODIFY COLUMN saleTotal decimal(10,2) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste MODIFY COLUMN saleWaste decimal(10,2) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste CHANGE saleWaste saleInternalWaste decimal(10,2) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste ADD saleExternalWaste decimal(10,2) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE bs.waste CHANGE saleQuantity saleQuantity decimal(10,2) DEFAULT NULL NULL AFTER itemTypeFk;
|
||||||
|
ALTER TABLE bs.waste CHANGE itemFk itemFk int(11) DEFAULT 0 NOT NULL AFTER itemTypeFk;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tWasteUnique
|
||||||
|
SELECT *
|
||||||
|
FROM bs.waste
|
||||||
|
GROUP BY `year`, `week`, buyerFk, itemTypeFk, itemFk
|
||||||
|
HAVING COUNT(*) > 1;
|
||||||
|
|
||||||
|
DELETE w.* FROM bs.waste w
|
||||||
|
JOIN tWasteUnique twu ON twu.`year` = w.`year`
|
||||||
|
AND twu.`week` = w.`week`
|
||||||
|
AND twu.`buyerFk` = w.`buyerFk`
|
||||||
|
AND twu.`itemTypeFk` = w.`itemTypeFk`
|
||||||
|
AND twu.`itemFk` = w.`itemFk`;
|
||||||
|
|
||||||
|
INSERT INTO bs.waste
|
||||||
|
SELECT * FROM tWasteUnique;
|
||||||
|
|
||||||
|
ALTER TABLE bs.waste ADD CONSTRAINT waste_pk PRIMARY KEY (`year`, `week`, buyerFk, itemTypeFk, itemFk);
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tWasteUnique;
|
|
@ -0,0 +1,11 @@
|
||||||
|
RENAME TABLE hedera.shelfConfig TO hedera.shelfMultiConfig ;
|
||||||
|
RENAME TABLE pbx.queueConfig TO pbx.queueMultiConfig ;
|
||||||
|
RENAME TABLE salix.defaultViewConfig TO salix.defaultViewMultiConfig;
|
||||||
|
RENAME TABLE edi.fileConfig TO edi.fileMultiConfig;
|
||||||
|
RENAME TABLE edi.imapConfig TO edi.imapMultiConfig;
|
||||||
|
RENAME TABLE edi.tableConfig TO edi.tableMultiConfig;
|
||||||
|
RENAME TABLE vn.invoiceOutTaxConfig TO vn.invoiceOutTaxMultiConfig;
|
||||||
|
RENAME TABLE vn.userConfig TO vn.userMultiConfig;
|
||||||
|
RENAME TABLE vn.conveyorConfig TO vn.conveyorMultiConfig;
|
||||||
|
|
||||||
|
GRANT SELECT ON TABLE hedera.shelfMultiConfig TO employee;
|
|
@ -0,0 +1,8 @@
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS tag11 varchar(20) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS value11 varchar(50) DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS tag12 varchar(20) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS value12 varchar(50) DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS tag13 varchar(20) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE vn.item ADD IF NOT EXISTS value13 varchar(50) DEFAULT NULL NULL;
|
|
@ -60,7 +60,7 @@ module.exports = Self => {
|
||||||
DISTINCT c.id clientFk,
|
DISTINCT c.id clientFk,
|
||||||
c.name clientName,
|
c.name clientName,
|
||||||
c.salesPersonFk,
|
c.salesPersonFk,
|
||||||
c.businessTypeFk,
|
c.businessTypeFk = 'worker' isWorker,
|
||||||
u.name salesPersonName,
|
u.name salesPersonName,
|
||||||
d.amount,
|
d.amount,
|
||||||
co.created,
|
co.created,
|
||||||
|
@ -71,14 +71,23 @@ module.exports = Self => {
|
||||||
d.defaulterSinced,
|
d.defaulterSinced,
|
||||||
cn.name country,
|
cn.name country,
|
||||||
c.countryFk,
|
c.countryFk,
|
||||||
pm.name payMethod
|
pm.name payMethod,
|
||||||
FROM vn.defaulter d
|
r.finished IS NULL hasRecovery,
|
||||||
JOIN vn.client c ON c.id = d.clientFk
|
dp.id departmentFk,
|
||||||
JOIN vn.country cn ON cn.id = c.countryFk
|
dp.name departmentName
|
||||||
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
FROM defaulter d
|
||||||
LEFT JOIN vn.clientObservation co ON co.clientFk = c.id
|
JOIN client c ON c.id = d.clientFk
|
||||||
|
JOIN country cn ON cn.id = c.countryFk
|
||||||
|
JOIN payMethod pm ON pm.id = c.payMethodFk
|
||||||
|
LEFT JOIN clientObservation co ON co.clientFk = c.id
|
||||||
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
||||||
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT MAX(started), clientFk, finished
|
||||||
|
FROM recovery
|
||||||
|
) r ON r.clientFk = c.id
|
||||||
|
LEFT JOIN workerDepartment wd ON wd.workerFk = u.id
|
||||||
|
JOIN department dp ON dp.id = wd.departmentFk
|
||||||
WHERE
|
WHERE
|
||||||
d.created = ?
|
d.created = ?
|
||||||
AND d.amount > 0
|
AND d.amount > 0
|
||||||
|
|
|
@ -27,28 +27,42 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getWasteByItem = async(buyer, family, options) => {
|
Self.getWasteByItem = async(buyer, family, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const user = await models.VnUser.findOne({
|
||||||
|
fields: ['id'],
|
||||||
|
where: {name: buyer}
|
||||||
|
});
|
||||||
|
|
||||||
|
const itemType = await models.ItemType.findOne({
|
||||||
|
fields: ['id'],
|
||||||
|
where: {name: family}
|
||||||
|
}, options);
|
||||||
|
|
||||||
const date = Date.vnNew();
|
const date = Date.vnNew();
|
||||||
date.setHours(0, 0, 0, 0);
|
date.setHours(0, 0, 0, 0);
|
||||||
const wastes = await Self.rawSql(`
|
const wastes = await Self.rawSql(`
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total percentage
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT u.name buyer,
|
||||||
ws.family,
|
it.name family,
|
||||||
ws.itemFk,
|
w.itemFk,
|
||||||
sum(ws.saleTotal) AS total,
|
SUM(w.saleTotal) total,
|
||||||
sum(ws.saleWaste) AS dwindle
|
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||||
FROM bs.waste ws
|
FROM bs.waste w
|
||||||
WHERE buyer = ? AND family = ?
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
WHERE w.buyerFk = ? AND w.itemTypeFk = ?
|
||||||
GROUP BY buyer, itemFk
|
AND w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||||
) sub
|
AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||||
ORDER BY family, percentage DESC`, [buyer, family, date, date], myOptions);
|
GROUP BY w.buyerFk, w.itemFk
|
||||||
|
) sub
|
||||||
|
ORDER BY family, percentage DESC
|
||||||
|
`, [user.id, itemType.id, date, date], myOptions);
|
||||||
|
|
||||||
const details = [];
|
const details = [];
|
||||||
|
|
||||||
|
|
|
@ -22,31 +22,37 @@ module.exports = Self => {
|
||||||
const date = Date.vnNew();
|
const date = Date.vnNew();
|
||||||
date.setHours(0, 0, 0, 0);
|
date.setHours(0, 0, 0, 0);
|
||||||
const wastes = await Self.rawSql(`
|
const wastes = await Self.rawSql(`
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total percentage
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT u.name buyer,
|
||||||
ws.family,
|
it.name family,
|
||||||
sum(ws.saleTotal) AS total,
|
w.itemFk,
|
||||||
sum(ws.saleWaste) AS dwindle
|
SUM(w.saleTotal) total,
|
||||||
FROM bs.waste ws
|
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||||
WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
FROM bs.waste w
|
||||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
GROUP BY buyer, family
|
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||||
) sub
|
WHERE year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||||
ORDER BY percentage DESC`, [date, date], myOptions);
|
AND week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||||
|
GROUP BY buyerFk, itemTypeFk
|
||||||
|
) sub
|
||||||
|
ORDER BY percentage DESC
|
||||||
|
`, [date, date], myOptions);
|
||||||
|
|
||||||
const wastesTotal = await Self.rawSql(`
|
const wastesTotal = await Self.rawSql(`
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total percentage
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT u.name buyer,
|
||||||
sum(ws.saleTotal) AS total,
|
SUM(w.saleTotal) total,
|
||||||
sum(ws.saleWaste) AS dwindle
|
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||||
FROM bs.waste ws
|
FROM bs.waste w
|
||||||
WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
WHERE w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||||
GROUP BY buyer
|
AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||||
|
GROUP BY w.buyerFk
|
||||||
) sub
|
) sub
|
||||||
ORDER BY percentage DESC`, [date, date], myOptions);
|
ORDER BY percentage DESC
|
||||||
|
`, [date, date], myOptions);
|
||||||
|
|
||||||
const details = [];
|
const details = [];
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ describe('Item getWasteByItem()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await models.Item.getWasteByItem('CharlesXavier', 'Cymbidium', options);
|
const result = await models.Item.getWasteByItem('buyer', 'Crisantemo', options);
|
||||||
|
|
||||||
const length = result.length;
|
const length = result.length;
|
||||||
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||||
|
|
||||||
expect(anyResult.buyer).toEqual('CharlesXavier');
|
expect(anyResult.buyer).toEqual('buyer');
|
||||||
expect(anyResult.family).toEqual('Cymbidium');
|
expect(anyResult.family).toEqual('Crisantemo');
|
||||||
expect(anyResult.lines.length).toBeGreaterThanOrEqual(2);
|
expect(anyResult.lines.length).toBeGreaterThanOrEqual(2);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -11,9 +11,9 @@ describe('Item getWasteByWorker()', () => {
|
||||||
const length = result.length;
|
const length = result.length;
|
||||||
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||||
|
|
||||||
expect(anyResult.buyer).toMatch(/(CharlesXavier|HankPym|DavidCharlesHaller)/);
|
expect(anyResult.buyer).toMatch(/(buyer|it)/);
|
||||||
expect(anyResult.total).toBeGreaterThanOrEqual(1000);
|
expect(anyResult.total).toBeGreaterThanOrEqual(1000);
|
||||||
expect(anyResult.lines.length).toBeGreaterThanOrEqual(3);
|
expect(anyResult.lines.length).toBeGreaterThanOrEqual(1);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
||||||
LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
||||||
JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||||
JOIN vn.agency ag ON ag.id = am.agencyFk
|
JOIN vn.agency ag ON ag.id = am.agencyFk
|
||||||
LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId()
|
LEFT JOIN vn.userMultiConfig uc ON uc.userFk = account.myUser_getId()
|
||||||
WHERE t.routeFk = ?
|
WHERE t.routeFk = ?
|
||||||
GROUP BY t.addressFk, e.itemPackingTypeFk
|
GROUP BY t.addressFk, e.itemPackingTypeFk
|
||||||
) sub
|
) sub
|
||||||
|
|
|
@ -44,15 +44,21 @@ module.exports = Self => {
|
||||||
|
|
||||||
const expedition = await models.Expedition.findOne(filter);
|
const expedition = await models.Expedition.findOne(filter);
|
||||||
const {code} = expedition.agencyMode();
|
const {code} = expedition.agencyMode();
|
||||||
|
let isDeleted = true;
|
||||||
|
|
||||||
if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') {
|
if (code?.toLowerCase()?.includes('mrw')) {
|
||||||
const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
const result = await models.MrwConfig.cancelShipment(expeditionId);
|
||||||
|
isDeleted = result;
|
||||||
|
}
|
||||||
|
|
||||||
if (isDeleted === 'true') {
|
if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') {
|
||||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
const result = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
||||||
deletedExpeditions.push(deletedExpedition);
|
if (result !== 'true') isDeleted = false;
|
||||||
} else notDeletedExpeditions.push(expeditionId);
|
}
|
||||||
} else {
|
|
||||||
|
if (!isDeleted)
|
||||||
|
notDeletedExpeditions.push(expeditionId);
|
||||||
|
else {
|
||||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
||||||
deletedExpeditions.push(deletedExpedition);
|
deletedExpeditions.push(deletedExpedition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,13 +53,22 @@ module.exports = Self => {
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
|
|
||||||
const stmt = new ParameterizedSQL(
|
const stmt = new ParameterizedSQL(
|
||||||
`SELECT t.id AS ticketFk, c.id AS clientFk, c.name AS clientName, tw.weekDay,
|
`SELECT t.id AS ticketFk,
|
||||||
wh.name AS warehouseName, u.id AS workerFk, u.name AS userName, u.nickName, tw.agencyModeFk
|
c.id AS clientFk,
|
||||||
|
c.name AS clientName,
|
||||||
|
tw.weekDay,
|
||||||
|
wh.name AS warehouseName,
|
||||||
|
u.id AS workerFk,
|
||||||
|
u.name AS userName,
|
||||||
|
u.nickName,
|
||||||
|
tw.agencyModeFk,
|
||||||
|
am.name agencyModeName
|
||||||
FROM ticketWeekly tw
|
FROM ticketWeekly tw
|
||||||
JOIN ticket t ON t.id = tw.ticketFk
|
JOIN ticket t ON t.id = tw.ticketFk
|
||||||
JOIN client c ON c.id = t.clientFk
|
JOIN client c ON c.id = t.clientFk
|
||||||
JOIN account.user u ON u.id = c.salesPersonFk
|
JOIN account.user u ON u.id = c.salesPersonFk
|
||||||
JOIN warehouse wh ON wh.id = t.warehouseFk`
|
JOIN warehouse wh ON wh.id = t.warehouseFk
|
||||||
|
LEFT JOIN agencyMode am ON am.id = tw.agencyModeFk`
|
||||||
);
|
);
|
||||||
|
|
||||||
stmt.merge(conn.makeSuffix(filter));
|
stmt.merge(conn.makeSuffix(filter));
|
||||||
|
|
|
@ -71,7 +71,8 @@ module.exports = Self => {
|
||||||
JSON_ARRAYAGG(
|
JSON_ARRAYAGG(
|
||||||
JSON_OBJECT(
|
JSON_OBJECT(
|
||||||
'ticketId', ticketFk,
|
'ticketId', ticketFk,
|
||||||
'reason', reason
|
'reason', reason,
|
||||||
|
'clientId', clientFk
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)errors
|
)errors
|
||||||
|
@ -83,7 +84,8 @@ module.exports = Self => {
|
||||||
IF(hasErrorDeleted, 'Eliminado', NULL),
|
IF(hasErrorDeleted, 'Eliminado', NULL),
|
||||||
IF(hasErrorItemTaxCountry, 'Impuesto no informado', NULL),
|
IF(hasErrorItemTaxCountry, 'Impuesto no informado', NULL),
|
||||||
IF(hasErrorAddress, 'Sin dirección', NULL),
|
IF(hasErrorAddress, 'Sin dirección', NULL),
|
||||||
IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones', NULL)) reason
|
IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones', NULL)) reason,
|
||||||
|
clientFk
|
||||||
FROM (
|
FROM (
|
||||||
SELECT t.id ticketFk,
|
SELECT t.id ticketFk,
|
||||||
SUM(NOT c.hasToInvoice) hasErrorToInvoice,
|
SUM(NOT c.hasToInvoice) hasErrorToInvoice,
|
||||||
|
@ -93,7 +95,8 @@ module.exports = Self => {
|
||||||
SUM(a.id IS NULL) hasErrorAddress,
|
SUM(a.id IS NULL) hasErrorAddress,
|
||||||
SUM(ios.code IS NOT NULL
|
SUM(ios.code IS NOT NULL
|
||||||
AND(ad.customsAgentFk IS NULL
|
AND(ad.customsAgentFk IS NULL
|
||||||
OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld
|
OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld,
|
||||||
|
t.clientFk clientFk
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
LEFT JOIN address ad ON ad.id = t.addressFk
|
LEFT JOIN address ad ON ad.id = t.addressFk
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
|
|
|
@ -42,7 +42,7 @@ fixtures:
|
||||||
- ACL
|
- ACL
|
||||||
- fieldAcl
|
- fieldAcl
|
||||||
- module
|
- module
|
||||||
- defaultViewConfig
|
- defaultViewMultiConfig
|
||||||
vn:
|
vn:
|
||||||
- alertLevel
|
- alertLevel
|
||||||
- bookingPlanner
|
- bookingPlanner
|
||||||
|
@ -363,7 +363,7 @@ localFixtures:
|
||||||
- travelConfig
|
- travelConfig
|
||||||
- travelRecalc
|
- travelRecalc
|
||||||
- travelThermograph
|
- travelThermograph
|
||||||
- userConfig
|
- userMultiConfig
|
||||||
- vehicle
|
- vehicle
|
||||||
- wagonConfig
|
- wagonConfig
|
||||||
- wagonType
|
- wagonType
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total `percentage`
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT u.name buyer,
|
||||||
sum(saleTotal) as total,
|
SUM(saleTotal) total,
|
||||||
sum(saleWaste) as dwindle
|
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||||
FROM bs.waste w
|
FROM bs.waste w
|
||||||
JOIN vn.time t ON w.year = t.year AND w.week = t.week
|
JOIN account.user u ON u.id = w.buyerFk
|
||||||
WHERE t.dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK)
|
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||||
GROUP BY buyer
|
WHERE w.year = YEAR(util.VN_CURDATE() - INTERVAL 1 WEEK)
|
||||||
|
AND w.week = WEEK(util.VN_CURDATE() - INTERVAL 1 WEEK, 4)
|
||||||
|
GROUP BY buyerFk
|
||||||
) sub
|
) sub
|
||||||
ORDER BY percentage DESC;
|
ORDER BY `percentage` DESC;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<div v-for="ticket in tickets" class="grid-block vn-px-ml">
|
<div v-for="ticket in tickets" class="grid-block vn-px-ml">
|
||||||
<p v-if="ticket.ticketId"><b>{{ $t('ticketId') }}:</b> {{ticket.ticketId}}</p>
|
<p v-if="ticket.ticketId"><b>{{ $t('ticketId') }}:</b> {{ticket.ticketId}}</p>
|
||||||
<p v-if="ticket.reason"><b>{{ $t('reason') }}:</b> {{ticket.reason}}</p>
|
<p v-if="ticket.reason"><b>{{ $t('reason') }}:</b> {{ticket.reason}}</p>
|
||||||
|
<p v-if="ticket.clientId"><b>{{ $t('clientId')}}</b>{{ticket.clientId}}</p>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
subject: Nightly ticket closing process report
|
subject: Nightly ticket closing process report
|
||||||
title: Nightly ticket closing process report
|
title: Nightly ticket closing process report
|
||||||
reason: Reason
|
reason: Reason
|
||||||
ticketId: Ticket
|
ticketId: Ticket
|
||||||
|
clientId: Client
|
|
@ -1,4 +1,5 @@
|
||||||
subject: Informe proceso de cierre de tickets nocturno
|
subject: Informe proceso de cierre de tickets nocturno
|
||||||
title: Informe proceso de cierre de tickets nocturno
|
title: Informe proceso de cierre de tickets nocturno
|
||||||
reason: Motivo
|
reason: Motivo
|
||||||
ticketId: Ticket
|
ticketId: Ticket
|
||||||
|
clientId: Cliente
|
Loading…
Reference in New Issue