Merge branch 'dev' into 7736-Añadir-parámetro-itemFk-a-buyUltimate
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
bf0f95f661
|
@ -24,7 +24,7 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
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 = [];
|
||||
for (const file of files) {
|
||||
|
@ -54,7 +54,7 @@ module.exports = Self => {
|
|||
|
||||
const tables = await Self.rawSql(`
|
||||
SELECT fileName, toTable, file
|
||||
FROM edi.tableConfig
|
||||
FROM edi.tableMultiConfig
|
||||
WHERE file IN (?)`, [fileNames], options);
|
||||
|
||||
for (const table of tables) {
|
||||
|
@ -85,9 +85,9 @@ module.exports = Self => {
|
|||
for (const file of updatableFiles) {
|
||||
console.log(`Updating file ${file.name} checksum...`);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.fileConfig
|
||||
SET checksum = ?
|
||||
WHERE name = ?`,
|
||||
UPDATE edi.fileMultiConfig
|
||||
SET checksum = ?
|
||||
WHERE name = ?`,
|
||||
[file.checksum, file.name], options);
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ module.exports = Self => {
|
|||
|
||||
await Self.rawSql(sqlTemplate, [filePath], options);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.tableConfig
|
||||
UPDATE edi.tableMultiConfig
|
||||
SET updated = ?
|
||||
WHERE fileName = ?
|
||||
`, [Date.vnNew(), baseName], options);
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = Self => {
|
|||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -39,6 +39,7 @@ module.exports = Self => {
|
|||
const xmlString = response.data;
|
||||
const parser = new DOMParser();
|
||||
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",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.defaultViewConfig"
|
||||
"table": "salix.defaultViewMultiConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "userConfig"
|
||||
"table": "userMultiConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
|
|
@ -10,9 +10,6 @@ SET foreign_key_checks = 0;
|
|||
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);
|
||||
|
||||
INSERT INTO util.binlogQueue (code,logName, `position`)
|
||||
VALUES ('mylogger', 'bin.000001', 4);
|
||||
|
||||
/* #5483
|
||||
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
|
||||
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, ''),
|
||||
(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
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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');
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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'),
|
||||
('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`)
|
||||
VALUES
|
||||
|
@ -1968,7 +1968,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
|
|||
(21, 21),
|
||||
(22, 22);
|
||||
|
||||
INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
||||
INSERT INTO `vn`.`userMultiConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
||||
VALUES
|
||||
(1, 1, 69),
|
||||
(5, 1, 442),
|
||||
|
|
|
@ -1,31 +1,50 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
||||
BEGIN
|
||||
DECLARE vWeek INT;
|
||||
DECLARE vYear INT;
|
||||
DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(CURDATE()) DAY;
|
||||
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
|
||||
SELECT *, 100 * mermas / total as porcentaje
|
||||
FROM (
|
||||
SELECT buyer,
|
||||
year,
|
||||
week,
|
||||
family,
|
||||
itemFk,
|
||||
itemTypeFk,
|
||||
floor(sum(value)) as total,
|
||||
floor(sum(IF(typeFk = 'loses', value, 0))) as mermas
|
||||
FROM vn.saleValue
|
||||
where year = vYear and week = vWeek
|
||||
|
||||
GROUP BY family, itemFk
|
||||
|
||||
) sub
|
||||
ORDER BY mermas DESC;
|
||||
SELECT YEAR(t.shipped),
|
||||
WEEK(t.shipped, 4),
|
||||
it.workerFk,
|
||||
it.id,
|
||||
s.itemFk,
|
||||
SUM(s.quantity),
|
||||
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) `value`,
|
||||
SUM (
|
||||
IF(
|
||||
aw.`type` = 'internal',
|
||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||
0
|
||||
)
|
||||
) internalWaste,
|
||||
SUM (
|
||||
IF(
|
||||
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$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -10,5 +10,5 @@ AS SELECT `q`.`name` AS `name`,
|
|||
`c`.`ringInUse` AS `ringinuse`
|
||||
FROM (
|
||||
`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)
|
||||
INTO vCompanyFk
|
||||
FROM vn.routeConfig rc
|
||||
LEFT JOIN userConfig uc ON uc.userFk = workerFk;
|
||||
LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk;
|
||||
|
||||
|
||||
SELECT
|
||||
|
|
|
@ -216,7 +216,7 @@ BEGIN
|
|||
i.transactionTypeSageFk,
|
||||
@vTaxCodeGeneral := i.taxClassCodeFk
|
||||
FROM tmp.ticketServiceTax tst
|
||||
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code
|
||||
JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tst.code
|
||||
WHERE i.isService
|
||||
HAVING taxableBase
|
||||
) sub;
|
||||
|
@ -229,7 +229,7 @@ BEGIN
|
|||
i.taxTypeSageFk ,
|
||||
i.transactionTypeSageFk
|
||||
FROM tmp.ticketTax tt
|
||||
JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code
|
||||
JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tt.code
|
||||
WHERE !i.isService
|
||||
GROUP BY tt.pgcFk
|
||||
HAVING taxableBase
|
||||
|
|
|
@ -10,19 +10,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`(
|
|||
)
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Genera una tabla de comparativa de artículos por itemType/comprador/fecha.
|
||||
* Los datos se calculan en función de los parámetros proporcionados.
|
||||
* Generates a comparison table of items by itemType/buyer/date.
|
||||
* The data is calculated based on the provided parameters.
|
||||
*
|
||||
* @param vDate La fecha para la cual se generará la comparativa.
|
||||
* @param vDayRange El rango de días a considerar para la comparativa.
|
||||
* @param vWarehouseFk El identificador del almacén para filtrar los artículos.
|
||||
* @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles.
|
||||
* @param vBuyerFk El identificador del comprador para filtrar los artículos.
|
||||
* @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional).
|
||||
* @param vCountryFk El identificador del país.
|
||||
* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT)
|
||||
* @param vDate The date for which the comparison will be generated.
|
||||
* @param vDayRange The range of days to consider for the comparison.
|
||||
* @param vWarehouseFk The warehouse identifier to filter the items.
|
||||
* @param vAvailableSince The availability date from which the items are considered available.
|
||||
* @param vBuyerFk The buyer identifier to filter the items.
|
||||
* @param vIsFloramondo Indicates whether only Floramondo items should be included (optional).
|
||||
* @param vCountryFk The country identifier.
|
||||
* @param tmp.comparativeFilterType(filterFk INT, itemTypeFk INT)
|
||||
* @return tmp.comparative
|
||||
*/
|
||||
|
||||
DECLARE vDayRangeStart DATE;
|
||||
DECLARE vDayRangeEnd DATE;
|
||||
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
|
||||
|
|
|
@ -42,7 +42,7 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
SELECT warehouseFk INTO vWarehouseFk
|
||||
FROM userConfig
|
||||
FROM userMultiConfig
|
||||
WHERE userFk = account.myUser_getId();
|
||||
|
||||
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
|
||||
|
|
|
@ -46,12 +46,18 @@ BEGIN
|
|||
i.tag8 = JSON_VALUE(vTags, '$.8'),
|
||||
i.tag9 = JSON_VALUE(vTags, '$.9'),
|
||||
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.value6 = JSON_VALUE(vValues, '$.6'),
|
||||
i.value7 = JSON_VALUE(vValues, '$.7'),
|
||||
i.value8 = JSON_VALUE(vValues, '$.8'),
|
||||
i.value9 = JSON_VALUE(vValues, '$.9'),
|
||||
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.inkFk = k.id,
|
||||
i.originFk = IFNULL(o.id, i.originFk)
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
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
|
||||
/**
|
||||
* 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
|
||||
LEFT JOIN (
|
||||
SELECT routeFk, SUM(volume) AS m3
|
||||
FROM saleVolume
|
||||
WHERE routeFk = vRoute
|
||||
) v ON v.routeFk = r.id
|
||||
SET r.m3 = IFNULL(v.m3,0)
|
||||
WHERE r.id =vRoute;
|
||||
UPDATE `route`
|
||||
SET m3 = IFNULL(vVolume, 0)
|
||||
WHERE id = vSelf;
|
||||
END$$
|
||||
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,
|
||||
c.name clientName,
|
||||
c.salesPersonFk,
|
||||
c.businessTypeFk,
|
||||
c.businessTypeFk = 'worker' isWorker,
|
||||
u.name salesPersonName,
|
||||
d.amount,
|
||||
co.created,
|
||||
|
@ -71,14 +71,23 @@ module.exports = Self => {
|
|||
d.defaulterSinced,
|
||||
cn.name country,
|
||||
c.countryFk,
|
||||
pm.name payMethod
|
||||
FROM vn.defaulter d
|
||||
JOIN vn.client c ON c.id = d.clientFk
|
||||
JOIN vn.country cn ON cn.id = c.countryFk
|
||||
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
||||
LEFT JOIN vn.clientObservation co ON co.clientFk = c.id
|
||||
pm.name payMethod,
|
||||
r.finished IS NULL hasRecovery,
|
||||
dp.id departmentFk,
|
||||
dp.name departmentName
|
||||
FROM defaulter d
|
||||
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 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
|
||||
d.created = ?
|
||||
AND d.amount > 0
|
||||
|
|
|
@ -27,28 +27,42 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.getWasteByItem = async(buyer, family, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
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();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const wastes = await Self.rawSql(`
|
||||
SELECT *, 100 * dwindle / total AS percentage
|
||||
FROM (
|
||||
SELECT buyer,
|
||||
ws.family,
|
||||
ws.itemFk,
|
||||
sum(ws.saleTotal) AS total,
|
||||
sum(ws.saleWaste) AS dwindle
|
||||
FROM bs.waste ws
|
||||
WHERE buyer = ? AND family = ?
|
||||
AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
||||
GROUP BY buyer, itemFk
|
||||
) sub
|
||||
ORDER BY family, percentage DESC`, [buyer, family, date, date], myOptions);
|
||||
SELECT *, 100 * dwindle / total percentage
|
||||
FROM (
|
||||
SELECT u.name buyer,
|
||||
it.name family,
|
||||
w.itemFk,
|
||||
SUM(w.saleTotal) total,
|
||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||
FROM bs.waste w
|
||||
JOIN account.user u ON u.id = w.buyerFk
|
||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||
WHERE w.buyerFk = ? AND w.itemTypeFk = ?
|
||||
AND w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||
AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||
GROUP BY w.buyerFk, w.itemFk
|
||||
) sub
|
||||
ORDER BY family, percentage DESC
|
||||
`, [user.id, itemType.id, date, date], myOptions);
|
||||
|
||||
const details = [];
|
||||
|
||||
|
|
|
@ -22,31 +22,37 @@ module.exports = Self => {
|
|||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
const wastes = await Self.rawSql(`
|
||||
SELECT *, 100 * dwindle / total AS percentage
|
||||
FROM (
|
||||
SELECT buyer,
|
||||
ws.family,
|
||||
sum(ws.saleTotal) AS total,
|
||||
sum(ws.saleWaste) AS dwindle
|
||||
FROM bs.waste ws
|
||||
WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
||||
GROUP BY buyer, family
|
||||
) sub
|
||||
ORDER BY percentage DESC`, [date, date], myOptions);
|
||||
SELECT *, 100 * dwindle / total percentage
|
||||
FROM (
|
||||
SELECT u.name buyer,
|
||||
it.name family,
|
||||
w.itemFk,
|
||||
SUM(w.saleTotal) total,
|
||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||
FROM bs.waste w
|
||||
JOIN account.user u ON u.id = w.buyerFk
|
||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||
WHERE year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||
AND week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||
GROUP BY buyerFk, itemTypeFk
|
||||
) sub
|
||||
ORDER BY percentage DESC
|
||||
`, [date, date], myOptions);
|
||||
|
||||
const wastesTotal = await Self.rawSql(`
|
||||
SELECT *, 100 * dwindle / total AS percentage
|
||||
SELECT *, 100 * dwindle / total percentage
|
||||
FROM (
|
||||
SELECT buyer,
|
||||
sum(ws.saleTotal) AS total,
|
||||
sum(ws.saleWaste) AS dwindle
|
||||
FROM bs.waste ws
|
||||
WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?))
|
||||
AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1)
|
||||
GROUP BY buyer
|
||||
SELECT u.name buyer,
|
||||
SUM(w.saleTotal) total,
|
||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||
FROM bs.waste w
|
||||
JOIN account.user u ON u.id = w.buyerFk
|
||||
WHERE w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?))
|
||||
AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1)
|
||||
GROUP BY w.buyerFk
|
||||
) sub
|
||||
ORDER BY percentage DESC`, [date, date], myOptions);
|
||||
ORDER BY percentage DESC
|
||||
`, [date, date], myOptions);
|
||||
|
||||
const details = [];
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@ describe('Item getWasteByItem()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const result = await models.Item.getWasteByItem('CharlesXavier', 'Cymbidium', options);
|
||||
const result = await models.Item.getWasteByItem('buyer', 'Crisantemo', options);
|
||||
|
||||
const length = result.length;
|
||||
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
|
||||
|
||||
expect(anyResult.buyer).toEqual('CharlesXavier');
|
||||
expect(anyResult.family).toEqual('Cymbidium');
|
||||
expect(anyResult.buyer).toEqual('buyer');
|
||||
expect(anyResult.family).toEqual('Crisantemo');
|
||||
expect(anyResult.lines.length).toBeGreaterThanOrEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
|
|
|
@ -11,9 +11,9 @@ describe('Item getWasteByWorker()', () => {
|
|||
const length = result.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.lines.length).toBeGreaterThanOrEqual(3);
|
||||
expect(anyResult.lines.length).toBeGreaterThanOrEqual(1);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
|||
LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
||||
JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
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 = ?
|
||||
GROUP BY t.addressFk, e.itemPackingTypeFk
|
||||
) sub
|
||||
|
|
|
@ -44,15 +44,21 @@ module.exports = Self => {
|
|||
|
||||
const expedition = await models.Expedition.findOne(filter);
|
||||
const {code} = expedition.agencyMode();
|
||||
let isDeleted = true;
|
||||
|
||||
if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') {
|
||||
const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
||||
if (code?.toLowerCase()?.includes('mrw')) {
|
||||
const result = await models.MrwConfig.cancelShipment(expeditionId);
|
||||
isDeleted = result;
|
||||
}
|
||||
|
||||
if (isDeleted === 'true') {
|
||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
||||
deletedExpeditions.push(deletedExpedition);
|
||||
} else notDeletedExpeditions.push(expeditionId);
|
||||
} else {
|
||||
if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') {
|
||||
const result = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
||||
if (result !== 'true') isDeleted = false;
|
||||
}
|
||||
|
||||
if (!isDeleted)
|
||||
notDeletedExpeditions.push(expeditionId);
|
||||
else {
|
||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
||||
deletedExpeditions.push(deletedExpedition);
|
||||
}
|
||||
|
|
|
@ -53,13 +53,22 @@ module.exports = Self => {
|
|||
const stmts = [];
|
||||
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT t.id AS ticketFk, 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
|
||||
`SELECT t.id AS ticketFk,
|
||||
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
|
||||
JOIN ticket t ON t.id = tw.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
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));
|
||||
|
|
|
@ -71,7 +71,8 @@ module.exports = Self => {
|
|||
JSON_ARRAYAGG(
|
||||
JSON_OBJECT(
|
||||
'ticketId', ticketFk,
|
||||
'reason', reason
|
||||
'reason', reason,
|
||||
'clientId', clientFk
|
||||
)
|
||||
)
|
||||
)errors
|
||||
|
@ -83,7 +84,8 @@ module.exports = Self => {
|
|||
IF(hasErrorDeleted, 'Eliminado', NULL),
|
||||
IF(hasErrorItemTaxCountry, 'Impuesto no informado', NULL),
|
||||
IF(hasErrorAddress, 'Sin dirección', NULL),
|
||||
IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones', NULL)) reason
|
||||
IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones', NULL)) reason,
|
||||
clientFk
|
||||
FROM (
|
||||
SELECT t.id ticketFk,
|
||||
SUM(NOT c.hasToInvoice) hasErrorToInvoice,
|
||||
|
@ -93,7 +95,8 @@ module.exports = Self => {
|
|||
SUM(a.id IS NULL) hasErrorAddress,
|
||||
SUM(ios.code IS NOT NULL
|
||||
AND(ad.customsAgentFk IS NULL
|
||||
OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld
|
||||
OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld,
|
||||
t.clientFk clientFk
|
||||
FROM ticket t
|
||||
LEFT JOIN address ad ON ad.id = t.addressFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
|
|
|
@ -42,7 +42,7 @@ fixtures:
|
|||
- ACL
|
||||
- fieldAcl
|
||||
- module
|
||||
- defaultViewConfig
|
||||
- defaultViewMultiConfig
|
||||
vn:
|
||||
- alertLevel
|
||||
- bookingPlanner
|
||||
|
@ -363,7 +363,7 @@ localFixtures:
|
|||
- travelConfig
|
||||
- travelRecalc
|
||||
- travelThermograph
|
||||
- userConfig
|
||||
- userMultiConfig
|
||||
- vehicle
|
||||
- wagonConfig
|
||||
- wagonType
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
SELECT *, 100 * dwindle / total AS percentage
|
||||
SELECT *, 100 * dwindle / total `percentage`
|
||||
FROM (
|
||||
SELECT buyer,
|
||||
sum(saleTotal) as total,
|
||||
sum(saleWaste) as dwindle
|
||||
SELECT u.name buyer,
|
||||
SUM(saleTotal) total,
|
||||
SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle
|
||||
FROM bs.waste w
|
||||
JOIN vn.time t ON w.year = t.year AND w.week = t.week
|
||||
WHERE t.dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK)
|
||||
GROUP BY buyer
|
||||
JOIN account.user u ON u.id = w.buyerFk
|
||||
JOIN vn.itemType it ON it.id = w.itemTypeFk
|
||||
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
|
||||
ORDER BY percentage DESC;
|
||||
ORDER BY `percentage` DESC;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<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.reason"><b>{{ $t('reason') }}:</b> {{ticket.reason}}</p>
|
||||
<p v-if="ticket.clientId"><b>{{ $t('clientId')}}</b>{{ticket.clientId}}</p>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
subject: Nightly ticket closing process report
|
||||
title: Nightly ticket closing process report
|
||||
reason: Reason
|
||||
ticketId: Ticket
|
||||
ticketId: Ticket
|
||||
clientId: Client
|
|
@ -1,4 +1,5 @@
|
|||
subject: Informe proceso de cierre de tickets nocturno
|
||||
title: Informe proceso de cierre de tickets nocturno
|
||||
reason: Motivo
|
||||
ticketId: Ticket
|
||||
ticketId: Ticket
|
||||
clientId: Cliente
|
Loading…
Reference in New Issue