feat: refs #6021 add new field #2508
|
@ -186,5 +186,8 @@
|
|||
},
|
||||
"AgencyWorkCenter": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"RouteConfig": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "RouteConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "routeConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"kmMax": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2549,18 +2549,18 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV
|
|||
(7, 7, 1.00, 1.00, 1.00),
|
||||
(8, 8, 1.00, 1.00, 1.00);
|
||||
|
||||
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
|
||||
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`, `bookEntried`)
|
||||
VALUES
|
||||
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
|
||||
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1),
|
||||
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1),
|
||||
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1),
|
||||
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1),
|
||||
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1),
|
||||
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1),
|
||||
(8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1),
|
||||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1),
|
||||
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1);
|
||||
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1,util.VN_CURDATE()),
|
||||
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1,util.VN_CURDATE()),
|
||||
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1,util.VN_CURDATE()),
|
||||
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1,util.VN_CURDATE()),
|
||||
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1,util.VN_CURDATE()),
|
||||
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1,util.VN_CURDATE()),
|
||||
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1,util.VN_CURDATE()),
|
||||
(8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1,util.VN_CURDATE()),
|
||||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()),
|
||||
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`)
|
||||
VALUES
|
||||
|
@ -3792,3 +3792,10 @@ INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, stre
|
|||
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
|
||||
|
||||
UPDATE vn.locker SET workerFk = 1110 WHERE id = 147;
|
||||
|
||||
INSERT INTO `vn`.`ledgerCompany` SET
|
||||
fiscalYear = YEAR(util.VN_CURDATE()),
|
||||
bookEntry = 2;
|
||||
|
||||
INSERT INTO `vn`.`ledgerConfig` SET
|
||||
maxTolerance = 0.01;
|
||||
|
|
|
@ -81,7 +81,7 @@ BEGIN
|
|||
|
||||
-- Código redundante
|
||||
|
||||
DO vn.till_new(
|
||||
CALL vn.till_new(
|
||||
vCustomer
|
||||
,vBank
|
||||
,vAmount / 100
|
||||
|
|
|
@ -1,79 +1,73 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`till_new`(vClient INT
|
||||
,vBank INT
|
||||
,vAmount DOUBLE
|
||||
,vConcept VARCHAR(25)
|
||||
,vDated DATE
|
||||
,vSerie CHAR(1)
|
||||
,vBatch TINYINT
|
||||
,vNumber INT
|
||||
,vCompany SMALLINT
|
||||
,vWorker INT
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`till_new`(
|
||||
vClient INT,
|
||||
vBank INT,
|
||||
vAmount DOUBLE,
|
||||
vConcept VARCHAR(25),
|
||||
vDated DATE,
|
||||
vSerie CHAR(1),
|
||||
vBatch TINYINT,
|
||||
vNumber INT,
|
||||
vCompany SMALLINT,
|
||||
vWorker INT
|
||||
)
|
||||
RETURNS int(11)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
DECLARE vAccount VARCHAR(12);
|
||||
DECLARE vSubaccount VARCHAR(12);
|
||||
DECLARE vAsiento INT DEFAULT NULL;
|
||||
|
||||
-- Inserta el registro en cajas
|
||||
|
||||
INSERT INTO till
|
||||
SET
|
||||
workerFk = vWorker
|
||||
,bankFk = vBank
|
||||
,`in` = vAmount
|
||||
,concept = vConcept
|
||||
,dated = vDated
|
||||
,serie = vSerie
|
||||
,isAccountable = vBatch
|
||||
,`number` = vNumber
|
||||
,companyFk = vCompany;
|
||||
workerFk = vWorker,
|
||||
bankFk = vBank,
|
||||
`in` = vAmount,
|
||||
concept = vConcept,
|
||||
dated = vDated,
|
||||
serie = vSerie,
|
||||
isAccountable = vBatch,
|
||||
`number` = vNumber,
|
||||
companyFk = vCompany;
|
||||
|
||||
-- Inserta los asientos contables
|
||||
|
||||
SELECT account INTO vAccount
|
||||
FROM accounting WHERE id = vBank;
|
||||
|
||||
SELECT accountingAccount INTO vSubaccount
|
||||
FROM `client` WHERE id = vClient;
|
||||
|
||||
SET vAsiento = xdiario_new
|
||||
(
|
||||
vAsiento
|
||||
,vDated
|
||||
,vAccount
|
||||
,vSubaccount
|
||||
,vConcept
|
||||
,vAmount
|
||||
,0
|
||||
,0
|
||||
,NULL -- Serie
|
||||
,NULL -- Factura
|
||||
,NULL -- IVA
|
||||
,NULL -- Recargo
|
||||
,FALSE -- Auxiliar
|
||||
,vCompany
|
||||
);
|
||||
DO xdiario_new
|
||||
(
|
||||
vAsiento
|
||||
,vDated
|
||||
,vSubaccount
|
||||
,vAccount
|
||||
,vConcept
|
||||
,0
|
||||
,vAmount
|
||||
,0
|
||||
,NULL -- Serie
|
||||
,NULL -- Factura
|
||||
,NULL -- IVA
|
||||
,NULL -- Recargo
|
||||
,FALSE -- Auxiliar
|
||||
,vCompany
|
||||
);
|
||||
CALL xdiario_new(
|
||||
vAsiento,
|
||||
vDated,
|
||||
vAccount,
|
||||
vSubaccount,
|
||||
vConcept,
|
||||
vAmount,
|
||||
0,
|
||||
0,
|
||||
NULL, -- Serie
|
||||
NULL, -- Factura
|
||||
NULL, -- IVA
|
||||
NULL, -- Recargo
|
||||
FALSE, -- Auxiliar
|
||||
vCompany,
|
||||
vAsiento);
|
||||
|
||||
RETURN NULL;
|
||||
CALL xdiario_new(
|
||||
vAsiento,
|
||||
vDated,
|
||||
vSubaccount,
|
||||
vAccount,
|
||||
vConcept,
|
||||
0,
|
||||
vAmount,
|
||||
0,
|
||||
NULL, -- Serie
|
||||
NULL, -- Factura
|
||||
NULL, -- IVA
|
||||
NULL, -- Recargo
|
||||
FALSE, -- Auxiliar
|
||||
vCompany,
|
||||
vAsiento);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(
|
||||
vBookNumber INT,
|
||||
vDated DATE,
|
||||
vSubaccount VARCHAR(12),
|
||||
vAccount VARCHAR(12),
|
||||
vConcept VARCHAR(25),
|
||||
vDebit DOUBLE,
|
||||
vCredit DOUBLE,
|
||||
vEuro DOUBLE,
|
||||
vSerie CHAR(1),
|
||||
vInvoice VARCHAR(8),
|
||||
vVat DOUBLE,
|
||||
vRe DOUBLE,
|
||||
vAux TINYINT,
|
||||
vCompanyFk INT
|
||||
)
|
||||
RETURNS int(11)
|
||||
NOT DETERMINISTIC
|
||||
NO SQL
|
||||
BEGIN
|
||||
IF vBookNumber IS NULL THEN
|
||||
CALL ledger_next(YEAR(vDated), vBookNumber);
|
||||
END IF;
|
||||
|
||||
INSERT INTO XDiario
|
||||
SET ASIEN = vBookNumber,
|
||||
FECHA = vDated,
|
||||
SUBCTA = vSubaccount,
|
||||
CONTRA = vAccount,
|
||||
CONCEPTO = vConcept,
|
||||
EURODEBE = vDebit,
|
||||
EUROHABER = vCredit,
|
||||
BASEEURO = vEuro,
|
||||
SERIE = vSerie,
|
||||
FACTURA = vInvoice,
|
||||
IVA = vVat,
|
||||
RECEQUIV = vRe,
|
||||
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
|
||||
MONEDAUSO = 2,
|
||||
empresa_id = vCompanyFk;
|
||||
|
||||
RETURN vBookNumber;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -23,7 +23,6 @@ proc: BEGIN
|
|||
* @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;
|
||||
|
@ -59,14 +58,14 @@ proc: BEGIN
|
|||
END IF;
|
||||
|
||||
SELECT MIN(dated) INTO vDayRangeStart
|
||||
FROM vn.time
|
||||
FROM `time`
|
||||
WHERE dated <= vDate
|
||||
GROUP BY period
|
||||
ORDER BY dated desc
|
||||
LIMIT 1 OFFSET vWeekRange;
|
||||
|
||||
SELECT MAX(dated) INTO vDayRangeEnd
|
||||
FROM vn.time
|
||||
FROM `time`
|
||||
WHERE dated >= vDate
|
||||
GROUP BY period
|
||||
ORDER BY dated ASC
|
||||
|
@ -83,12 +82,11 @@ proc: BEGIN
|
|||
JOIN itemType t ON t.id = i.typeFk
|
||||
JOIN itemCategory c ON c.id = t.categoryFk
|
||||
LEFT JOIN worker w ON w.id = t.workerFk
|
||||
WHERE (NOT vHasTypeFilter
|
||||
OR t.id IN (SELECT itemTypeFk FROM tmp.comparativeFilterType))
|
||||
AND (vBuyerFk IS NULL
|
||||
OR t.workerFk = vBuyerFk)
|
||||
AND (vIsFloramondo IS NULL
|
||||
OR i.isFloramondo = vIsFloramondo);
|
||||
WHERE (NOT vHasTypeFilter OR t.id IN (
|
||||
SELECT itemTypeFk FROM tmp.comparativeFilterType
|
||||
))
|
||||
AND (vBuyerFk IS NULL OR t.workerFk = vBuyerFk)
|
||||
AND (vIsFloramondo IS NULL OR i.isFloramondo = vIsFloramondo);
|
||||
|
||||
IF vDate < util.VN_CURDATE() THEN
|
||||
ALTER TABLE tmp.itemInventory
|
||||
|
@ -115,10 +113,11 @@ proc: BEGIN
|
|||
SET i = i + 1;
|
||||
|
||||
SELECT t.period INTO vPeriod
|
||||
FROM vn.`time` t
|
||||
FROM `time` t
|
||||
WHERE t.dated = vDayRangeStart + INTERVAL (vWeekCount * (i - 1)) DAY;
|
||||
|
||||
INSERT IGNORE INTO tTable(cy, ly, zy) VALUES(vPeriod, vPeriod - 100, vPeriod - 200);
|
||||
INSERT IGNORE INTO tTable(cy, ly, zy)
|
||||
VALUES(vPeriod, vPeriod - 100, vPeriod - 200);
|
||||
UNTIL i = vWeekCount END REPEAT;
|
||||
|
||||
SELECT cy, ly, zy INTO w1, y1, z1 FROM tTable LIMIT 1;
|
||||
|
@ -130,7 +129,6 @@ proc: BEGIN
|
|||
SELECT cy, ly, zy INTO w7, y7, z7 FROM tTable WHERE cy > w6 LIMIT 1;
|
||||
|
||||
-- Genera una tabla con los datos del año pasado.
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tLastYear
|
||||
(KEY (lItemFk))
|
||||
ENGINE = MEMORY
|
||||
|
@ -151,15 +149,14 @@ proc: BEGIN
|
|||
SUM(IF(c.timePeriod = y7, c.price, 0)) lprice7
|
||||
FROM tmp.itemInventory ai
|
||||
JOIN comparative c ON c.itemFk = ai.id
|
||||
JOIN warehouse w on w.id = c.warehouseFk
|
||||
JOIN warehouse w ON w.id = c.warehouseFk
|
||||
JOIN tTable wt ON c.timePeriod = wt.ly
|
||||
WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk
|
||||
WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
|
||||
AND w.isComparative
|
||||
AND (vCountryFk IS NULL OR c.countryFk = vCountryFk)
|
||||
GROUP BY ai.id;
|
||||
|
||||
-- Genera una tabla con los datos de hace DOS años.
|
||||
|
||||
-- Genera una tabla con los datos de hace 2 años
|
||||
CREATE OR REPLACE TEMPORARY TABLE tTwoYearsAgo
|
||||
(KEY (tItemFk))
|
||||
ENGINE = MEMORY
|
||||
|
@ -180,59 +177,58 @@ proc: BEGIN
|
|||
SUM(IF(c.timePeriod = z7, c.price, 0)) vlprice7
|
||||
FROM tmp.itemInventory ai
|
||||
JOIN comparative c ON c.itemFk = ai.id
|
||||
JOIN warehouse w on w.id = c.warehouseFk
|
||||
JOIN warehouse w ON w.id = c.warehouseFk
|
||||
JOIN tTable wt ON c.timePeriod = wt.zy
|
||||
WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk
|
||||
WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
|
||||
AND w.isComparative
|
||||
AND (vCountryFk IS NULL OR c.countryFk = vCountryFk)
|
||||
GROUP BY ai.id;
|
||||
|
||||
-- Genera una tabla con los datos de este año.ss
|
||||
|
||||
-- Genera una tabla con los datos de este año
|
||||
CREATE OR REPLACE TEMPORARY TABLE tCurrentYear
|
||||
(KEY (cItemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.itemFk cItemFk,
|
||||
SUM(IF(week = w1, total, 0)) cweek1,
|
||||
SUM(IF(week = w2, total, 0)) cweek2,
|
||||
SUM(IF(week = w3, total, 0)) cweek3,
|
||||
SUM(IF(week = w4, total, 0)) cweek4,
|
||||
SUM(IF(week = w5, total, 0)) cweek5,
|
||||
SUM(IF(week = w6, total, 0)) cweek6,
|
||||
SUM(IF(week = w7, total, 0)) cweek7,
|
||||
SUM(IF(week = w1, price, 0)) cprice1,
|
||||
SUM(IF(week = w2, price, 0)) cprice2,
|
||||
SUM(IF(week = w3, price, 0)) cprice3,
|
||||
SUM(IF(week = w4, price, 0)) cprice4,
|
||||
SUM(IF(week = w5, price, 0)) cprice5,
|
||||
SUM(IF(week = w6, price, 0)) cprice6,
|
||||
SUM(IF(week = w7, price, 0)) cprice7
|
||||
SUM(IF(`week` = w1, total, 0)) cweek1,
|
||||
SUM(IF(`week` = w2, total, 0)) cweek2,
|
||||
SUM(IF(`week` = w3, total, 0)) cweek3,
|
||||
SUM(IF(`week` = w4, total, 0)) cweek4,
|
||||
SUM(IF(`week` = w5, total, 0)) cweek5,
|
||||
SUM(IF(`week` = w6, total, 0)) cweek6,
|
||||
SUM(IF(`week` = w7, total, 0)) cweek7,
|
||||
SUM(IF(`week` = w1, price, 0)) cprice1,
|
||||
SUM(IF(`week` = w2, price, 0)) cprice2,
|
||||
SUM(IF(`week` = w3, price, 0)) cprice3,
|
||||
SUM(IF(`week` = w4, price, 0)) cprice4,
|
||||
SUM(IF(`week` = w5, price, 0)) cprice5,
|
||||
SUM(IF(`week` = w6, price, 0)) cprice6,
|
||||
SUM(IF(`week` = w7, price, 0)) cprice7
|
||||
FROM (
|
||||
SELECT s.itemFk,
|
||||
ti.period `week`,
|
||||
SUM(s.quantity) total,
|
||||
TRUNCATE(SUM(s.quantity * s.priceFixed), 0) price
|
||||
FROM ticket t
|
||||
FROM ticket t FORCE INDEX (Fecha)
|
||||
JOIN sale s ON t.id = s.ticketFk
|
||||
JOIN tmp.itemInventory it ON it.id = s.itemFk
|
||||
JOIN time ti ON ti.dated = DATE(t.shipped)
|
||||
JOIN `time` ti ON ti.dated = DATE(t.shipped)
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemType tp ON tp.id = i.typeFk
|
||||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||
JOIN warehouse w ON w.id = t.warehouseFk
|
||||
STRAIGHT_JOIN address ad ON ad.id = t.addressFk
|
||||
JOIN `address` ad ON ad.id = t.addressFk
|
||||
JOIN province p ON p.id = ad.provinceFk
|
||||
JOIN `client` c ON c.id = ad.clientFk
|
||||
WHERE t.shipped BETWEEN vDayRangeStart AND util.dayEnd(vDayRangeEnd)
|
||||
AND c.typeFk IN ('Normal','handMaking')
|
||||
AND w.id = COALESCE(vWarehouseFk, w.id)
|
||||
AND w.isComparative
|
||||
AND c.typeFk IN ('normal', 'handMaking')
|
||||
AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id)
|
||||
AND (vCountryFk IS NULL OR p.countryFk = vCountryFk)
|
||||
GROUP BY i.id, week
|
||||
AND w.isComparative
|
||||
GROUP BY i.id, `week`
|
||||
) t
|
||||
GROUP BY t.itemFk;
|
||||
|
||||
-- Genera la tabla con la comparativa.
|
||||
-- Genera la tabla con la comparativa
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.comparative
|
||||
ENGINE = MEMORY
|
||||
SELECT it.subName productor,
|
||||
|
@ -240,13 +236,13 @@ proc: BEGIN
|
|||
b.buyingValue costefijo,
|
||||
b.groupingMode caja,
|
||||
it.image ArticleImage,
|
||||
IFNULL(it.inkFk,"?") color,
|
||||
IFNULL(it.inkFk, '?') color,
|
||||
tp.code tipo,
|
||||
it.typeFk tipo_id,
|
||||
o.code origen,
|
||||
it.category categoria,
|
||||
it.stems tallos,
|
||||
it.size medida,
|
||||
it.`size` medida,
|
||||
it.name article,
|
||||
w.code codigoTrabajador,
|
||||
tp.categoryFk reino_id,
|
||||
|
@ -264,17 +260,20 @@ proc: BEGIN
|
|||
e.id provider_id,
|
||||
it.comment comments,
|
||||
it.description itemDescription,
|
||||
IF(cy.cItemFk IS NULL AND i.visible = 0 AND i.avalaible = 0
|
||||
AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) filtret,
|
||||
IF(cy.cItemFk IS NULL AND i.visible = 0
|
||||
AND i.avalaible = 0 AND (i.sd IS NULL OR i.sd = 0),
|
||||
FALSE,
|
||||
TRUE
|
||||
) filtret,
|
||||
IF(it.hasMinPrice, FORMAT(it.minPrice, 2), "") pvp,
|
||||
s.company_name
|
||||
FROM tmp.itemInventory i
|
||||
JOIN item it ON it.id = i.id
|
||||
LEFT JOIN itemType tp ON tp.id = it.typeFk
|
||||
LEFT JOIN worker w ON w.id = tp.workerFk
|
||||
JOIN itemType tp ON tp.id = it.typeFk
|
||||
JOIN worker w ON w.id = tp.workerFk
|
||||
LEFT JOIN buy b ON b.id = i.buy_id
|
||||
LEFT JOIN entry e ON e.id = b.entryFk
|
||||
LEFT JOIN origin o ON o.id = it.originFk
|
||||
LEFT JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN origin o ON o.id = it.originFk
|
||||
LEFT JOIN tLastYear ly ON ly.lItemFk = it.id
|
||||
LEFT JOIN tCurrentYear cy ON cy.cItemFk = it.id
|
||||
LEFT JOIN tTwoYearsAgo zy ON zy.tItemFk = it.id
|
||||
|
@ -287,8 +286,8 @@ proc: BEGIN
|
|||
OR ly.lweek1 OR ly.lweek2 OR ly.lweek3 OR ly.lweek4 OR ly.lweek5 OR ly.lweek6 OR ly.lweek7
|
||||
OR zy.vlweek1 OR zy.vlweek2 OR zy.vlweek3 OR zy.vlweek4 OR zy.vlweek5 OR zy.vlweek6 OR zy.vlweek7;
|
||||
|
||||
-- Elimina las tablas temporales creadas...
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemInventory,
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
tmp.itemInventory,
|
||||
tTwoYearsAgo,
|
||||
tLastYear,
|
||||
tCurrentYear,
|
||||
|
|
|
@ -1,13 +1,55 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
|
||||
IN vFiscalYear INT,
|
||||
OUT vNewBookEntry INT
|
||||
OUT vLastBookEntry INT
|
||||
)
|
||||
BEGIN
|
||||
DECLARE vHasStartTransaction BOOLEAN;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
|
||||
IF vHasStartTransaction THEN
|
||||
ROLLBACK TO sp;
|
||||
RESIGNAL;
|
||||
ELSE
|
||||
ROLLBACK;
|
||||
CALL util.throw ('It has not been possible to generate a new ledger');
|
||||
END IF;
|
||||
END;
|
||||
|
||||
IF vFiscalYear IS NULL THEN
|
||||
CALL util.throw('Fiscal year is required');
|
||||
END IF;
|
||||
|
||||
SELECT @@in_transaction INTO vHasStartTransaction;
|
||||
|
||||
IF NOT vHasStartTransaction THEN
|
||||
START TRANSACTION;
|
||||
ELSE
|
||||
SAVEPOINT sp;
|
||||
END IF;
|
||||
|
||||
SELECT bookEntry + 1 INTO vLastBookEntry
|
||||
FROM ledgerCompany
|
||||
WHERE fiscalYear = vFiscalYear
|
||||
FOR UPDATE;
|
||||
|
||||
IF vLastBookEntry IS NULL THEN
|
||||
INSERT INTO ledgerCompany
|
||||
SET fiscalYear = vFiscalYear,
|
||||
bookEntry = 1;
|
||||
SET vLastBookEntry = 1;
|
||||
END IF;
|
||||
|
||||
UPDATE ledgerCompany
|
||||
SET bookEntry = LAST_INSERT_ID(bookEntry + 1)
|
||||
SET bookEntry = vLastBookEntry
|
||||
WHERE fiscalYear = vFiscalYear;
|
||||
|
||||
SET vNewBookEntry = LAST_INSERT_ID();
|
||||
IF vHasStartTransaction THEN
|
||||
RELEASE SAVEPOINT sp;
|
||||
ELSE
|
||||
COMMIT;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -12,12 +12,15 @@ BEGIN
|
|||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
(INDEX(saleFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem
|
||||
SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem
|
||||
FROM (
|
||||
SELECT s.id saleFk
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE t.shipped >= util.midnight()
|
||||
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk);
|
||||
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk)
|
||||
GROUP BY s.id) sub;
|
||||
|
||||
CALL sale_setProblem('hasComponentLack');
|
||||
|
||||
|
|
|
@ -20,15 +20,15 @@ BEGIN
|
|||
|
||||
CALL buyUltimate(vWarehouseFk, vShipped);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem
|
||||
FROM tmp.buyUltimate bu
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE bu.itemFk = vItemFk;
|
||||
|
||||
CALL sale_setProblem('hasRounding');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticket;
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -22,7 +22,7 @@ BEGIN
|
|||
SET t.hasProblem = TRUE
|
||||
WHERE c.isFreezed;
|
||||
|
||||
CALL ticket_setProblem('hasTicketRequest');
|
||||
CALL ticket_setProblem('isFreezed');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticket;
|
||||
END$$
|
||||
|
|
|
@ -19,7 +19,7 @@ BEGIN
|
|||
WHERE t.id = vSelf;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
SELECT vSelf ticketFk, vRisk hasProblem;
|
||||
SELECT vSelf ticketFk, vHasRisk hasProblem;
|
||||
|
||||
CALL ticket_setProblem('hasRisk');
|
||||
|
||||
|
|
|
@ -18,17 +18,17 @@ BEGIN
|
|||
|
||||
CALL buyUltimate(vWarehouseFk, vDated);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = tl.ticketFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE t.id = vSelf;
|
||||
|
||||
CALL sale_setProblem('hasRounding');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticket;
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -15,7 +15,7 @@ BEGIN
|
|||
WITH tickets AS(
|
||||
SELECT t.id ticketFk
|
||||
FROM vn.ticket t
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN vn.sale s ON s.ticketFk = t.id
|
||||
WHERE t.shipped >= util.midnight()
|
||||
AND (s.itemFk = vItemFk OR vItemFk IS NULL)
|
||||
GROUP BY t.id
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`xdiario_new`(
|
||||
vBookNumber INT,
|
||||
vDated DATE,
|
||||
vSubaccount VARCHAR(12),
|
||||
vAccount VARCHAR(12),
|
||||
vConcept VARCHAR(25),
|
||||
vDebit DOUBLE,
|
||||
vCredit DOUBLE,
|
||||
vEuro DOUBLE,
|
||||
vSerie CHAR(1),
|
||||
vInvoice VARCHAR(8),
|
||||
vVat DOUBLE,
|
||||
vRe DOUBLE,
|
||||
vAux TINYINT,
|
||||
vCompanyFk INT,
|
||||
OUT vNewBookNumber INT
|
||||
)
|
||||
/**
|
||||
* Este procedimiento se encarga de la inserción de registros en la tabla XDiario.
|
||||
* Si el número de asiento (vBookNumber) no está definido, se genera uno nuevo utilizando
|
||||
* vn.ledger_next.
|
||||
*
|
||||
* @param vBookNumber Número de asiento. Si es NULL, se generará uno nuevo.
|
||||
* @param vDated Fecha utilizada para generar un nuevo número de libro si vBookNumber es NULL.
|
||||
* @param vSubaccount Subcuenta para la transacción.
|
||||
* @param vAccount Cuenta para la transacción.
|
||||
* @param vConcept Concepto de la transacción.
|
||||
* @param vDebit Monto del débito para la transacción.
|
||||
* @param vCredit Monto del crédito para la transacción.
|
||||
* @param vEuro Monto en euros para la transacción.
|
||||
* @param vSerie Serie para la transacción.
|
||||
* @param vInvoice Número de factura para la transacción.
|
||||
* @param vVat Monto del IVA para la transacción.
|
||||
* @param vRe Monto del RE para la transacción.
|
||||
* @param vAux Variable auxiliar para la transacción.
|
||||
* @param vCompanyFk Clave foránea de la compañía para la transacción.
|
||||
* @return No retorna un valor, pero realiza una inserción en la tabla XDiario.
|
||||
*/
|
||||
BEGIN
|
||||
IF vBookNumber IS NULL THEN
|
||||
CALL ledger_next(YEAR(vDated), vBookNumber);
|
||||
END IF;
|
||||
|
||||
INSERT INTO XDiario
|
||||
SET ASIEN = vBookNumber,
|
||||
FECHA = vDated,
|
||||
SUBCTA = vSubaccount,
|
||||
CONTRA = vAccount,
|
||||
CONCEPTO = vConcept,
|
||||
EURODEBE = vDebit,
|
||||
EUROHABER = vCredit,
|
||||
BASEEURO = vEuro,
|
||||
SERIE = vSerie,
|
||||
FACTURA = vInvoice,
|
||||
IVA = vVat,
|
||||
RECEQUIV = vRe,
|
||||
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
|
||||
MONEDAUSO = 2,
|
||||
empresa_id = vCompanyFk;
|
||||
|
||||
SET vNewBookNumber = vBookNumber;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,4 @@
|
|||
-- Place your SQL code here
|
||||
INSERT INTO salix.defaultViewConfig
|
||||
(tableCode, `columns`)
|
||||
VALUES('routesList', '{"ID":true,"worker":true,"agency":true,"vehicle":true,"date":true,"volume":true,"description":true,"started":true,"finished":true,"actions":true}');
|
|
@ -0,0 +1,3 @@
|
|||
-- Place your SQL code here
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('RouteConfig','*','READ','ALLOW','ROLE','employee');
|
|
@ -226,5 +226,6 @@
|
|||
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
|
||||
"They're not your subordinate": "They're not your subordinate",
|
||||
"InvoiceIn is already booked": "InvoiceIn is already booked",
|
||||
"This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency"
|
||||
"This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency",
|
||||
"You can only have one PDA": "You can only have one PDA"
|
||||
}
|
|
@ -357,6 +357,7 @@
|
|||
"This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
|
||||
"Select ticket or client": "Elija un ticket o un client",
|
||||
"It was not able to create the invoice": "No se pudo crear la factura",
|
||||
"This PDA is already assigned to another user": "This PDA is already assigned to another user",
|
||||
"ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)"
|
||||
"ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)",
|
||||
"This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
|
||||
"You can only have one PDA": "Solo puedes tener un PDA"
|
||||
}
|
|
@ -95,9 +95,11 @@ module.exports = function(Self) {
|
|||
myOptions
|
||||
);
|
||||
} else if (accountingType.isAutoConciliated == true) {
|
||||
const description = `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`;
|
||||
const [xdiarioNew] = await Self.rawSql(
|
||||
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`,
|
||||
const description =
|
||||
`${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`;
|
||||
const [, [xdiarioNew]] = await Self.rawSql(
|
||||
`CALL xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @xdiarioNew);
|
||||
SELECT @xdiarioNew ledger;`,
|
||||
[
|
||||
null,
|
||||
date,
|
||||
|
@ -118,7 +120,7 @@ module.exports = function(Self) {
|
|||
);
|
||||
|
||||
await Self.rawSql(
|
||||
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`,
|
||||
`CALL xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @xdiarioNew);`,
|
||||
[
|
||||
xdiarioNew.ledger,
|
||||
date,
|
||||
|
|
|
@ -3,6 +3,9 @@ module.exports = Self => {
|
|||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError(`This PDA is already assigned to another user`);
|
||||
|
||||
if (err.code === 'ER_SIGNAL_EXCEPTION' && err.sqlMessage === 'You can only have one active PDA')
|
||||
return new UserError(err.sqlMessage);
|
||||
return err;
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue