8032-devToTest_2440 #3009

Merged
alexm merged 262 commits from 8032-devToTest_2440 into test 2024-09-24 09:34:49 +00:00
13 changed files with 133 additions and 78 deletions
Showing only changes of commit 9e844c15b7 - Show all commits

View File

@ -37,7 +37,6 @@ module.exports = Self => {
}); });
const xmlString = response.data; const xmlString = response.data;
console.log('xmlString: ', xmlString);
const parser = new DOMParser(); const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;

View File

@ -53,7 +53,7 @@ module.exports = Self => {
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType, LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType,
IF(mw.weekdays, 'S', 'N') weekDays, IF(mw.weekdays, 'S', 'N') weekDays,
oa.description deliveryObservation ta.description deliveryObservation
FROM expedition e FROM expedition e
JOIN ticket t ON e.ticketFk = t.id JOIN ticket t ON e.ticketFk = t.id
JOIN agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
@ -62,8 +62,8 @@ module.exports = Self => {
AND mw.weekDays & (1 << WEEKDAY(t.landed)) AND mw.weekDays & (1 << WEEKDAY(t.landed))
JOIN client c ON t.clientFk = c.id JOIN client c ON t.clientFk = c.id
JOIN address a ON t.addressFk = a.id JOIN address a ON t.addressFk = a.id
LEFT JOIN addressObservation oa ON oa.addressFk = a.id LEFT JOIN ticketObservation ta ON ta.ticketFk = t.id
AND oa.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'delivery') AND ta.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'agency')
JOIN province p ON a.provinceFk = p.id JOIN province p ON a.provinceFk = p.id
JOIN country co ON co.id = p.countryFk JOIN country co ON co.id = p.countryFk
JOIN mrwConfig mc JOIN mrwConfig mc

View File

@ -20,9 +20,12 @@ proc:BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible
(PRIMARY KEY (item_id)) (PRIMARY KEY (item_id))
ENGINE = MEMORY ENGINE = MEMORY
SELECT item_id, amount stock, amount visible SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible
FROM cache.stock FROM stock s
WHERE warehouse_id = v_warehouse; JOIN vn.warehouse w ON w.id = s.warehouse_id
WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse)
AND w.isComparative
GROUP BY s.item_id;
-- Calculamos los movimientos confirmados de hoy -- Calculamos los movimientos confirmados de hoy
CALL vn.item_calcVisible(NULL, v_warehouse); CALL vn.item_calcVisible(NULL, v_warehouse);

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`travel_setDelivered`
ON SCHEDULE EVERY 1 DAY
STARTS '2024-07-12 00:10:00.000'
ON COMPLETION PRESERVE
ENABLE
DO BEGIN
UPDATE travel t
SET t.isDelivered = TRUE
WHERE t.shipped < util.VN_CURDATE();
END$$
DELIMITER ;

View File

@ -12,6 +12,7 @@ BEGIN
DECLARE vInvoiceFk INT; DECLARE vInvoiceFk INT;
DECLARE vBookEntry INT; DECLARE vBookEntry INT;
DECLARE vFiscalYear INT; DECLARE vFiscalYear INT;
DECLARE vIncorrectInvoiceInDueDay INT;
DECLARE vInvoicesIn CURSOR FOR DECLARE vInvoicesIn CURSOR FOR
SELECT DISTINCT e.invoiceInFk SELECT DISTINCT e.invoiceInFk
@ -24,6 +25,19 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SELECT GROUP_CONCAT(ii.id) INTO vIncorrectInvoiceInDueDay
FROM invoiceInDueDay iidd
JOIN invoiceIn ii ON iidd.invoiceInFk = ii.id
JOIN `entry` e ON e.invoiceInFk = ii.id
JOIN duaEntry de ON de.entryFk = e.id
JOIN invoiceInConfig iic
WHERE de.duaFk = vDuaFk
AND iidd.dueDated <= util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY;
IF vIncorrectInvoiceInDueDay THEN
CALL util.throw(CONCAT('Incorrect due date, invoice: ', vIncorrectInvoiceInDueDay));
END IF;
UPDATE invoiceIn ii UPDATE invoiceIn ii
JOIN entry e ON e.invoiceInFk = ii.id JOIN entry e ON e.invoiceInFk = ii.id
JOIN duaEntry de ON de.entryFk = e.id JOIN duaEntry de ON de.entryFk = e.id

View File

@ -1,5 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`(vInvoiceInFk INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`(
vInvoiceInFk INT
)
BEGIN BEGIN
/** /**
* Calcula los vctos. de una factura recibida * Calcula los vctos. de una factura recibida
@ -56,12 +58,13 @@ BEGIN
COUNT(DISTINCT(pdd.detail)) cont, COUNT(DISTINCT(pdd.detail)) cont,
s.payDay, s.payDay,
ii.issued, ii.issued,
DATE(ii.created) + INTERVAL 2 DAY created DATE(ii.created) + INTERVAL iic.dueDateMarginDays DAY created
FROM invoiceIn ii FROM invoiceIn ii
JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk
JOIN supplier s ON s.id = ii.supplierFk JOIN supplier s ON s.id = ii.supplierFk
JOIN payDemDetail pdd ON pdd.id = s.payDemFk JOIN payDemDetail pdd ON pdd.id = s.payDemFk
JOIN invoiceInConfig iic
WHERE ii.id = vInvoiceInFk WHERE ii.id = vInvoiceInFk
GROUP BY ii.id GROUP BY ii.id
)sub )sub

View File

@ -21,6 +21,7 @@ BEGIN
FROM itemTicketOut i FROM itemTicketOut i
LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk
JOIN `state` s ON s.id = ts.stateFk JOIN `state` s ON s.id = ts.stateFk
JOIN warehouse w ON w.id = i.warehouseFk
LEFT JOIN ( LEFT JOIN (
SELECT DISTINCT st.saleFk SELECT DISTINCT st.saleFk
FROM saleTracking st FROM saleTracking st
@ -28,26 +29,31 @@ BEGIN
WHERE st.created > vDated WHERE st.created > vDated
AND (s.isPicked OR st.isChecked) AND (s.isPicked OR st.isChecked)
) stPrevious ON `stPrevious`.`saleFk` = i.saleFk ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk
WHERE IFNULL(vWarehouseFk, i.warehouseFk) = i.warehouseFk WHERE (vWarehouseFk IS NULL OR i.warehouseFk = vWarehouseFk)
AND (vSelf IS NULL OR i.itemFk = vSelf) AND (vSelf IS NULL OR i.itemFk = vSelf)
AND (s.isPicked OR i.reserved OR stPrevious.saleFk) AND (s.isPicked OR i.reserved OR stPrevious.saleFk)
AND i.shipped >= vDated AND i.shipped < vTomorrow AND i.shipped >= vDated AND i.shipped < vTomorrow
AND w.isComparative
UNION ALL UNION ALL
SELECT itemFk, quantity SELECT iei.itemFk, iei.quantity
FROM itemEntryIn FROM itemEntryIn iei
WHERE isReceived JOIN warehouse w ON w.id = iei.warehouseInFk
AND landed >= vDated AND landed < vTomorrow WHERE iei.isReceived
AND IFNULL(vWarehouseFk, warehouseInFk) = warehouseInFk AND iei.landed >= vDated AND iei.landed < vTomorrow
AND (vSelf IS NULL OR itemFk = vSelf) AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk)
AND NOT isVirtualStock AND (vSelf IS NULL OR iei.itemFk = vSelf)
AND NOT iei.isVirtualStock
AND w.isComparative
UNION ALL UNION ALL
SELECT itemFk, quantity SELECT ieo.itemFk, ieo.quantity
FROM itemEntryOut FROM itemEntryOut ieo
WHERE isDelivered JOIN warehouse w ON w.id = ieo.warehouseOutFk
AND shipped >= vDated WHERE ieo.isDelivered
AND shipped < vTomorrow AND ieo.shipped >= vDated
AND IFNULL(vWarehouseFk, warehouseOutFk) = warehouseOutFk AND ieo.shipped < vTomorrow
AND (vSelf IS NULL OR itemFk = vSelf) AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk)
AND (vSelf IS NULL OR ieo.itemFk = vSelf)
AND w.isComparative
) t ) t
GROUP BY itemFk GROUP BY itemFk
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE

View File

@ -75,13 +75,6 @@ proc: BEGIN
) sub ) sub
GROUP BY itemFk; GROUP BY itemFk;
UPDATE tmp.itemInventory ai
JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id
SET ai.inventory = iic.quantity,
ai.visible = iic.quantity,
ai.avalaible = iic.quantity,
ai.sd = iic.quantity;
-- Cálculo del visible -- Cálculo del visible
CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk);
@ -93,8 +86,12 @@ proc: BEGIN
WHERE calc_id = vCalcFk; WHERE calc_id = vCalcFk;
UPDATE tmp.itemInventory it UPDATE tmp.itemInventory it
JOIN tItemInventoryCalc iic ON iic.itemFk = it.id
JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id
SET it.visible = it.visible + ivc.visible; SET it.inventory = iic.quantity,
it.visible = ivc.visible,
it.avalaible = iic.quantity,
it.sd = iic.quantity;
-- Calculo del disponible -- Calculo del disponible
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
@ -142,31 +139,35 @@ proc: BEGIN
CALL item_getAtp(vDate); CALL item_getAtp(vDate);
CALL travel_upcomingArrivals(vWarehouseFk, vDate); CALL travel_upcomingArrivals(vWarehouseFk, vDate);
UPDATE tmp.itemInventory ai CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
JOIN ( (PRIMARY KEY (itemFk))
SELECT it.itemFk, ENGINE = MEMORY
SUM(it.quantity) quantity, SELECT it.itemFk,
im.quantity minQuantity SUM(it.quantity) quantity,
FROM tmp.itemCalc it im.quantity minQuantity
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk FROM tmp.itemCalc it
JOIN item i ON i.id = it.itemFk JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
LEFT JOIN origin o ON o.id = i.originFk JOIN item i ON i.id = it.itemFk
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk LEFT JOIN origin o ON o.id = i.originFk
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
t.landing, WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
vDateToTomorrow) t.landing,
GROUP BY it.itemFk vDateToTomorrow)
) sub ON sub.itemFk = ai.id GROUP BY it.itemFk;
SET ai.avalaible = IF(sub.minQuantity > 0,
ai.avalaible, UPDATE tmp.itemInventory it
ai.avalaible + sub.minQuantity), JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
ai.sd = ai.inventory + sub.quantity; SET it.avalaible = IF(iac.minQuantity > 0,
it.avalaible,
it.avalaible + iac.minQuantity),
it.sd = it.inventory + iac.quantity;
DROP TEMPORARY TABLE DROP TEMPORARY TABLE
tmp.itemTravel, tmp.itemTravel,
tmp.itemCalc, tmp.itemCalc,
tmp.itemAtp, tmp.itemAtp,
tItemInventoryCalc, tItemInventoryCalc,
tItemVisibleCalc; tItemVisibleCalc,
tItemAvailableCalc;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -174,27 +174,30 @@ proc: BEGIN
WHERE NOT `lines`; WHERE NOT `lines`;
-- Lineas por linea de encajado -- Lineas por linea de encajado
CREATE OR REPLACE TEMPORARY TABLE tItemPackingType
(PRIMARY KEY(ticketFk))
ENGINE = MEMORY
SELECT ticketFk,
SUM(sub.H) H,
SUM(sub.V) V,
SUM(sub.N) N
FROM (
SELECT t.ticketFk,
SUM(i.itemPackingTypeFk = 'H') H,
SUM(i.itemPackingTypeFk = 'V') V,
SUM(i.itemPackingTypeFk IS NULL) N
FROM tmp.productionTicket t
JOIN sale s ON s.ticketFk = t.ticketFk
JOIN item i ON i.id = s.itemFk
GROUP BY t.ticketFk, i.itemPackingTypeFk
) sub
GROUP BY ticketFk;
UPDATE tmp.productionBuffer pb UPDATE tmp.productionBuffer pb
JOIN ( JOIN tItemPackingType ti ON ti.ticketFk = pb.ticketFk
SELECT ticketFk, SET pb.H = ti.H,
SUM(sub.H) H, pb.V = ti.V,
SUM(sub.V) V, pb.N = ti.N;
SUM(sub.N) N
FROM (
SELECT t.ticketFk,
SUM(i.itemPackingTypeFk = 'H') H,
SUM(i.itemPackingTypeFk = 'V') V,
SUM(i.itemPackingTypeFk IS NULL) N
FROM tmp.productionTicket t
JOIN sale s ON s.ticketFk = t.ticketFk
JOIN item i ON i.id = s.itemFk
GROUP BY t.ticketFk, i.itemPackingTypeFk
) sub
GROUP BY ticketFk
) sub2 ON sub2.ticketFk = pb.ticketFk
SET pb.H = sub2.H,
pb.V = sub2.V,
pb.N = sub2.N;
-- Colecciones segun tipo de encajado -- Colecciones segun tipo de encajado
UPDATE tmp.productionBuffer pb UPDATE tmp.productionBuffer pb
@ -273,6 +276,7 @@ proc: BEGIN
tmp.risk, tmp.risk,
tmp.ticket_problems, tmp.ticket_problems,
tmp.ticketWithPrevia, tmp.ticketWithPrevia,
tItemShelvingStock; tItemShelvingStock,
tItemPackingType;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,7 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_splitItemPackingType`( CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_splitItemPackingType`(
vSelf INT, vSelf INT,
vItemPackingTypeFk VARCHAR(1) vOriginalItemPackingTypeFk VARCHAR(1)
) )
BEGIN BEGIN
/** /**
@ -9,7 +9,7 @@ BEGIN
* Respeta el id inicial para el tipo propuesto. * Respeta el id inicial para el tipo propuesto.
* *
* @param vSelf Id ticket * @param vSelf Id ticket
* @param vItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
*/ */
DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H';
@ -23,7 +23,7 @@ BEGIN
SELECT itemPackingTypeFk SELECT itemPackingTypeFk
FROM tSaleGroup FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL WHERE itemPackingTypeFk IS NOT NULL
ORDER BY (itemPackingTypeFk = vItemPackingTypeFk) DESC; ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.invoiceInConfig
ADD dueDateMarginDays INT UNSIGNED DEFAULT 2 NULL;

View File

@ -4,7 +4,17 @@ import getMainRoute from 'core/lib/get-main-route';
config.$inject = ['$stateProvider', '$urlRouterProvider']; config.$inject = ['$stateProvider', '$urlRouterProvider'];
function config($stateProvider, $urlRouterProvider) { function config($stateProvider, $urlRouterProvider) {
$urlRouterProvider $urlRouterProvider
.otherwise('/'); .otherwise(async($injector, {$location}) => {
const prefix = '#!';
if (!$location.$$path) return window.location.href = `/${prefix}/`;
const url = $location.$$absUrl
.replace('5000', '9000')
.replace('salix', 'lilium')
.replace(prefix, '#')
.replace('client', 'customer');
window.location.href = url;
});
$stateProvider $stateProvider
.state('layout', { .state('layout', {

View File

@ -85,6 +85,7 @@ module.exports = Self => {
LEFT JOIN ( LEFT JOIN (
SELECT MAX(started), clientFk, finished SELECT MAX(started), clientFk, finished
FROM recovery FROM recovery
GROUP BY clientFk
) r ON r.clientFk = c.id ) r ON r.clientFk = c.id
LEFT JOIN workerDepartment wd ON wd.workerFk = u.id LEFT JOIN workerDepartment wd ON wd.workerFk = u.id
JOIN department dp ON dp.id = wd.departmentFk JOIN department dp ON dp.id = wd.departmentFk