Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into 7524-hotfix-addNoLimit
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
commit
b16c2bed2b
|
@ -3953,3 +3953,7 @@ VALUES
|
||||||
(4, 'Referencia Transferencias', 'trnRef'),
|
(4, 'Referencia Transferencias', 'trnRef'),
|
||||||
(5, 'Referencia Nominas', 'payRef'),
|
(5, 'Referencia Nominas', 'payRef'),
|
||||||
(6, 'ABA', 'aba');
|
(6, 'ABA', 'aba');
|
||||||
|
|
||||||
|
INSERT INTO vn.ormConfig SET
|
||||||
|
id = 1,
|
||||||
|
selectLimit = 1000;
|
|
@ -1,5 +1,10 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(
|
||||||
|
OUT `vCalc` INT,
|
||||||
|
`vRefresh` INT,
|
||||||
|
`vWarehouse` INT,
|
||||||
|
`vDated` DATE
|
||||||
|
)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
DECLARE vStartDate DATE;
|
DECLARE vStartDate DATE;
|
||||||
DECLARE vReserveDate DATETIME;
|
DECLARE vReserveDate DATETIME;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_updateItem`(
|
||||||
|
`vItem` INT,
|
||||||
|
`vWarehouse` INT,
|
||||||
|
`vDated` DATE,
|
||||||
|
`vQuantity` INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Immediately deduct/add an amount from the available cache (if exists).
|
||||||
|
*
|
||||||
|
* @param vItem The item id
|
||||||
|
* @param vWarehouse The warehouse id
|
||||||
|
* @param vDated Available cache date
|
||||||
|
* @param vQuantity The amount to be deducted from the cache
|
||||||
|
*/
|
||||||
|
DECLARE vCalc INT;
|
||||||
|
|
||||||
|
SELECT id INTO vCalc
|
||||||
|
FROM cache_calc
|
||||||
|
WHERE cacheName = 'available'
|
||||||
|
AND params = CONCAT_WS('/', vWarehouse, vDated);
|
||||||
|
|
||||||
|
IF vCalc IS NOT NULL THEN
|
||||||
|
UPDATE available
|
||||||
|
SET available = available - vQuantity
|
||||||
|
WHERE calc_id = vCalc
|
||||||
|
AND item_id = vItem;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -47,11 +47,15 @@ BEGIN
|
||||||
FROM tmp.zoneGetShipped
|
FROM tmp.zoneGetShipped
|
||||||
WHERE warehouseFk = vWarehouse;
|
WHERE warehouseFk = vWarehouse;
|
||||||
|
|
||||||
SELECT IFNULL(available, 0) INTO vAvailable
|
SELECT available INTO vAvailable
|
||||||
FROM tmp.ticketLot
|
FROM tmp.ticketLot
|
||||||
WHERE warehouseFk = vWarehouse
|
WHERE warehouseFk = vWarehouse
|
||||||
AND itemFk = vItem;
|
AND itemFk = vItem;
|
||||||
|
|
||||||
|
IF vAvailable IS NULL THEN
|
||||||
|
SET vAvailable = 0;
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF vAmount > vAvailable THEN
|
IF vAmount > vAvailable THEN
|
||||||
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
|
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -102,6 +106,8 @@ BEGIN
|
||||||
amount = vAdd,
|
amount = vAdd,
|
||||||
price = vPrice;
|
price = vPrice;
|
||||||
|
|
||||||
|
CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd);
|
||||||
|
|
||||||
SET vRow = LAST_INSERT_ID();
|
SET vRow = LAST_INSERT_ID();
|
||||||
|
|
||||||
INSERT INTO orderRowComponent (rowFk, componentFk, price)
|
INSERT INTO orderRowComponent (rowFk, componentFk, price)
|
||||||
|
|
|
@ -2,25 +2,33 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPrices`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPrices`()
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Recalcula los precios para las compras insertadas en tmp.buyRecalc
|
* Recalcula los precios para las compras insertadas en tmp.buyRecalc.
|
||||||
*
|
*
|
||||||
* @param tmp.buyRecalc (id)
|
* @param tmp.buyRecalc (id)
|
||||||
*/
|
*/
|
||||||
DECLARE vLanded DATE;
|
DECLARE vLanded DATE;
|
||||||
DECLARE vWarehouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
DECLARE vHasNotPrice BOOL;
|
|
||||||
DECLARE vBuyingValue DECIMAL(10,4);
|
|
||||||
DECLARE vPackagingFk VARCHAR(10);
|
|
||||||
DECLARE vIsWarehouseFloramondo BOOL;
|
DECLARE vIsWarehouseFloramondo BOOL;
|
||||||
|
DECLARE vDone BOOL;
|
||||||
SELECT t.landed, t.warehouseInFk, (w.`name` = 'Floramondo')
|
DECLARE vTravels CURSOR FOR
|
||||||
INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo
|
SELECT t.landed, t.warehouseInFk, (w.code = 'flm')
|
||||||
FROM tmp.buyRecalc br
|
FROM tmp.buyRecalc br
|
||||||
JOIN buy b ON b.id = br.id
|
JOIN buy b ON b.id = br.id
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||||
LIMIT 1;
|
GROUP BY t.landed, t.warehouseInFk;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
OPEN vTravels;
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH vTravels INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
CALL rate_getPrices(vLanded, vWarehouseFk);
|
CALL rate_getPrices(vLanded, vWarehouseFk);
|
||||||
|
|
||||||
|
@ -40,13 +48,12 @@ BEGIN
|
||||||
b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)),
|
b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)),
|
||||||
b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0
|
b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0
|
||||||
b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2),
|
b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2),
|
||||||
b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2);
|
b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2)
|
||||||
|
WHERE tr.landed = vLanded
|
||||||
SELECT (b.buyingValue = b.price2), b.buyingValue, b.packagingFk
|
AND tr.warehouseInFk = vWarehouseFk;
|
||||||
INTO vHasNotPrice, vBuyingValue, vPackagingFk
|
|
||||||
FROM vn.buy b
|
|
||||||
WHERE b.id = @buyId AND b.buyingValue <> 0.01;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.rate;
|
DROP TEMPORARY TABLE tmp.rate;
|
||||||
|
END LOOP;
|
||||||
|
CLOSE vTravels;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -17,6 +17,7 @@ BEGIN
|
||||||
DECLARE vHasDailyInvoice BOOL;
|
DECLARE vHasDailyInvoice BOOL;
|
||||||
DECLARE vWithPackage BOOL;
|
DECLARE vWithPackage BOOL;
|
||||||
DECLARE vHasToInvoice BOOL;
|
DECLARE vHasToInvoice BOOL;
|
||||||
|
DECLARE vSerial VARCHAR(2);
|
||||||
|
|
||||||
DECLARE cur CURSOR FOR
|
DECLARE cur CURSOR FOR
|
||||||
SELECT ticketFk FROM tmp.ticket_close;
|
SELECT ticketFk FROM tmp.ticket_close;
|
||||||
|
@ -83,14 +84,17 @@ BEGIN
|
||||||
GROUP BY e.freightItemFk);
|
GROUP BY e.freightItemFk);
|
||||||
|
|
||||||
IF(vHasDailyInvoice) AND vHasToInvoice THEN
|
IF(vHasDailyInvoice) AND vHasToInvoice THEN
|
||||||
|
SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial;
|
||||||
|
IF vSerial IS NULL THEN
|
||||||
|
CALL util.throw('Cannot booking without a serial');
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- Facturacion rapida
|
|
||||||
CALL ticket_setState(vCurTicketFk, 'DELIVERED');
|
CALL ticket_setState(vCurTicketFk, 'DELIVERED');
|
||||||
-- Facturar si está contabilizado
|
|
||||||
IF vIsTaxDataChecked THEN
|
IF vIsTaxDataChecked THEN
|
||||||
CALL invoiceOut_newFromClient(
|
CALL invoiceOut_newFromClient(
|
||||||
vClientFk,
|
vClientFk,
|
||||||
(SELECT invoiceSerial(vClientFk, vCompanyFk, 'multiple')),
|
vSerial,
|
||||||
vShipped,
|
vShipped,
|
||||||
vCompanyFk,
|
vCompanyFk,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
|
||||||
|
use vn;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `material` (
|
||||||
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(50) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `name_UNIQUE` (`name`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Abedul');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Acacia');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Acero');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Acero Galvanizado');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Acetato');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Acrílico');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Alambre');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Algodón');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Aluminio');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Antracita');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Arcilla');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Bambú');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Banano');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Canneté');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cartón');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cartulina');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Celofán');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cemento');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cera');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cerámica');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Chapa');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Chenilla');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cloruro de polivinilo');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cobre');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Corcho');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cordel');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton Chess');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cristal');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cubo Asa');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cuerda');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Cuero');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Raso');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Velvet');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Eco Glass');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Encaje');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Esparto');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Espuma');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Felpa');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Coco');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Vidrio y Resina');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Fieltro');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Foam');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Gamuza');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Gasa');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Glass');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Goma');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Grafito');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Hierro');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja Carbono');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja de Mirto');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Hormigón');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Jute');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Kraft');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Lana');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Látex');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Latrix');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Lienzo');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Lino');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Lurex');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Madera');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Metacrilato');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Metal');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Mimbre');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Musgo');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Nonwoven');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Nylon');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Organza');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Paja');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Pana');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Papel');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Paperweb');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Paulownia');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Peluche');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Piedra');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Pizarra');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Plástico');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Poliestireno');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Polipropileno');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Poliresina');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Polyester');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Porcelana');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Puntilla');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('PVC');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Rafia');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Rama');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Raso');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Rattan');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Rayon');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Reciclable');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Red');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Resina');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Roca');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Rope');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Saco');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Salim');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Seagrass');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Silicona');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Sisal');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Tejido');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Tela');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Terciopelo');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Terracota');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Textil');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Titanio');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Tul');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Velvet');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Vidrio');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Yute');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Zinc');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Base de goma');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Base de madera');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Plumas');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Protección Uva');
|
||||||
|
INSERT IGNORE INTO `material` (`name`) VALUES ('Purpurina');
|
||||||
|
|
||||||
|
UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name= 'Material';
|
||||||
|
UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name='Material secundario';
|
|
@ -0,0 +1,19 @@
|
||||||
|
INSERT INTO hedera.message (code,description)
|
||||||
|
VALUES ('ORDER_ROW_UNAVAILABLE','The ordered quantity exceeds the available');
|
||||||
|
INSERT INTO hedera.message (code,description)
|
||||||
|
VALUES ('AMOUNT_NOT_MATCH_GROUPING','The quantity ordered does not match the grouping');
|
||||||
|
|
||||||
|
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||||
|
VALUES ('ORDER_ROW_UNAVAILABLE','es','La cantidad pedida excede el disponible');
|
||||||
|
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||||
|
VALUES ('AMOUNT_NOT_MATCH_GROUPING','es','La cantidad pedida no coincide con el agrupado');
|
||||||
|
|
||||||
|
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||||
|
VALUES ('ORDER_ROW_UNAVAILABLE','fr','La quantité demandée dépasse ce qui est disponible');
|
||||||
|
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||||
|
VALUES ('AMOUNT_NOT_MATCH_GROUPING','fr','La quantité commandée ne correspond pas au regroupement');
|
||||||
|
|
||||||
|
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||||
|
VALUES ('ORDER_ROW_UNAVAILABLE','pt','A quantidade de entrega excede a disponibilidade');
|
||||||
|
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||||
|
VALUES ('AMOUNT_NOT_MATCH_GROUPING','pt','A quantidade solicitada não corresponde ao agrupamento');
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
* Flattens an array of objects by converting each object into a flat structure.
|
||||||
|
*
|
||||||
|
* @param {Array} dataArray Array of objects to be flattened
|
||||||
|
* @return {Array} Array of flattened objects
|
||||||
|
*/
|
||||||
|
function flatten(dataArray) {
|
||||||
|
return dataArray.map(item => flattenObj(item.__data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively flattens an object, converting nested properties into a single level object
|
||||||
|
* with keys representing the original nested structure.
|
||||||
|
*
|
||||||
|
* @param {Object} data The object to be flattened
|
||||||
|
* @param {String} [prefix=''] Optional prefix for nested keys
|
||||||
|
* @return {Object} Flattened object
|
||||||
|
*/
|
||||||
|
function flattenObj(data, prefix = '') {
|
||||||
|
let result = {};
|
||||||
|
try {
|
||||||
|
for (let key in data) {
|
||||||
|
if (!data[key]) continue;
|
||||||
|
|
||||||
|
const newKey = prefix ? `${prefix}_${key}` : key;
|
||||||
|
const value = data[key];
|
||||||
|
|
||||||
|
if (typeof value === 'object' && value !== null && !Array.isArray(value))
|
||||||
|
Object.assign(result, flattenObj(value.__data, newKey));
|
||||||
|
else
|
||||||
|
result[newKey] = value;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
flatten,
|
||||||
|
flattenObj,
|
||||||
|
};
|
|
@ -23,6 +23,7 @@ class Controller extends Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
set clientFk(value) {
|
set clientFk(value) {
|
||||||
|
if (!value) return;
|
||||||
this.receipt.clientFk = value;
|
this.receipt.clientFk = value;
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
|
@ -32,6 +33,7 @@ class Controller extends Dialog {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.getAmountPaid();
|
||||||
this.$http.get(`Clients/findOne`, {filter})
|
this.$http.get(`Clients/findOne`, {filter})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.receipt.email = res.data.email;
|
this.receipt.email = res.data.email;
|
||||||
|
@ -50,7 +52,6 @@ class Controller extends Dialog {
|
||||||
|
|
||||||
set companyFk(value) {
|
set companyFk(value) {
|
||||||
this.receipt.companyFk = value;
|
this.receipt.companyFk = value;
|
||||||
this.getAmountPaid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set description(value) {
|
set description(value) {
|
||||||
|
@ -152,7 +153,7 @@ class Controller extends Dialog {
|
||||||
getAmountPaid() {
|
getAmountPaid() {
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {
|
where: {
|
||||||
clientFk: this.$params.id,
|
clientFk: this.$params.id ?? this.clientFk,
|
||||||
companyFk: this.receipt.companyFk
|
companyFk: this.receipt.companyFk
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -210,8 +211,8 @@ ngModule.vnComponent('vnClientBalanceCreate', {
|
||||||
payed: '<?',
|
payed: '<?',
|
||||||
bankFk: '<?',
|
bankFk: '<?',
|
||||||
amountPaid: '<?',
|
amountPaid: '<?',
|
||||||
|
clientFk: '<?',
|
||||||
companyFk: '<?',
|
companyFk: '<?',
|
||||||
description: '<?',
|
description: '<?',
|
||||||
clientFk: '<?'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
const {toCSV} = require('vn-loopback/util/csv');
|
||||||
|
const {flatten} = require('vn-loopback/util/flatten');
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('getBuysCsv', {
|
||||||
|
description: 'Returns buys for one entry in CSV file format',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The entry id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
|
root: true
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: `/:id/getBuysCsv`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getBuysCsv = async(ctx, id, options) => {
|
||||||
|
const data = await Self.getBuys(ctx, id, null, options);
|
||||||
|
if (!data.length) throw new UserError('The entry has no lines or does not exist');
|
||||||
|
const dataFlatted = flatten(data);
|
||||||
|
return [toCSV(dataFlatted), 'text/csv', `inline; filename="buys-${id}.csv"`];
|
||||||
|
};
|
||||||
|
};
|
|
@ -3,6 +3,7 @@ module.exports = Self => {
|
||||||
require('../methods/entry/filter')(Self);
|
require('../methods/entry/filter')(Self);
|
||||||
require('../methods/entry/getEntry')(Self);
|
require('../methods/entry/getEntry')(Self);
|
||||||
require('../methods/entry/getBuys')(Self);
|
require('../methods/entry/getBuys')(Self);
|
||||||
|
require('../methods/entry/getBuysCsv')(Self);
|
||||||
require('../methods/entry/importBuys')(Self);
|
require('../methods/entry/importBuys')(Self);
|
||||||
require('../methods/entry/importBuysPreview')(Self);
|
require('../methods/entry/importBuysPreview')(Self);
|
||||||
require('../methods/entry/lastItemBuys')(Self);
|
require('../methods/entry/lastItemBuys')(Self);
|
||||||
|
|
|
@ -105,7 +105,8 @@ class Controller extends Section {
|
||||||
addressId: address.id,
|
addressId: address.id,
|
||||||
invoiceDate: this.invoiceDate,
|
invoiceDate: this.invoiceDate,
|
||||||
maxShipped: this.maxShipped,
|
maxShipped: this.maxShipped,
|
||||||
companyFk: this.companyFk
|
companyFk: this.companyFk,
|
||||||
|
serialType: 'global'
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$http.post(`InvoiceOuts/invoiceClient`, params)
|
this.$http.post(`InvoiceOuts/invoiceClient`, params)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('item getVisibleAvailable()', () => {
|
describe('item getVisibleAvailable()', () => {
|
||||||
it('should check available visible for today', async() => {
|
it('should check available visible for tomorrow', async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ describe('item getVisibleAvailable()', () => {
|
||||||
const itemFk = 1;
|
const itemFk = 1;
|
||||||
const warehouseFk = 1;
|
const warehouseFk = 1;
|
||||||
const dated = Date.vnNew();
|
const dated = Date.vnNew();
|
||||||
|
dated.setDate(dated.getDate() + 1);
|
||||||
|
|
||||||
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
|
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ module.exports = Self => {
|
||||||
if (hasProblems === true) {
|
if (hasProblems === true) {
|
||||||
whereProblems = {or: [
|
whereProblems = {or: [
|
||||||
{'tp.isFreezed': true},
|
{'tp.isFreezed': true},
|
||||||
{'tp.risk': {lt: 0}},
|
{'tp.hasRisk': true},
|
||||||
{'tp.hasTicketRequest': true},
|
{'tp.hasTicketRequest': true},
|
||||||
{'tp.hasComponentLack': true},
|
{'tp.hasComponentLack': true},
|
||||||
{'tp.isTaxDataChecked': false},
|
{'tp.isTaxDataChecked': false},
|
||||||
|
@ -295,7 +295,7 @@ module.exports = Self => {
|
||||||
} else if (hasProblems === false) {
|
} else if (hasProblems === false) {
|
||||||
whereProblems = {and: [
|
whereProblems = {and: [
|
||||||
{'tp.isFreezed': false},
|
{'tp.isFreezed': false},
|
||||||
{'tp.risk': 0},
|
{'tp.hasRisk': false},
|
||||||
{'tp.hasTicketRequest': false},
|
{'tp.hasTicketRequest': false},
|
||||||
{'tp.hasComponentLack': false},
|
{'tp.hasComponentLack': false},
|
||||||
{'tp.isTaxDataChecked': true},
|
{'tp.isTaxDataChecked': true},
|
||||||
|
|
|
@ -13,7 +13,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
|
||||||
const failedtickets = [];
|
const failedtickets = [];
|
||||||
for (const ticket of tickets) {
|
for (const ticket of tickets) {
|
||||||
try {
|
try {
|
||||||
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'multiple');
|
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick');
|
||||||
await Self.rawSql(
|
await Self.rawSql(
|
||||||
`CALL vn.ticket_closeByTicket(?)`,
|
`CALL vn.ticket_closeByTicket(?)`,
|
||||||
[ticket.id],
|
[ticket.id],
|
||||||
|
|
|
@ -343,7 +343,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const problems = {[condition]: [
|
const problems = {[condition]: [
|
||||||
{'tp.isFreezed': hasProblem},
|
{'tp.isFreezed': hasProblem},
|
||||||
{'tp.risk': hasProblem},
|
{'tp.hasRisk': hasProblem},
|
||||||
{'tp.hasTicketRequest': hasProblem},
|
{'tp.hasTicketRequest': hasProblem},
|
||||||
{'tp.itemShortage': range},
|
{'tp.itemShortage': range},
|
||||||
{'tp.hasRounding': hasProblem}
|
{'tp.hasRounding': hasProblem}
|
||||||
|
|
|
@ -196,7 +196,7 @@ module.exports = Self => {
|
||||||
const problems = {
|
const problems = {
|
||||||
[condition]: [
|
[condition]: [
|
||||||
{'tp.isFreezed': hasProblem},
|
{'tp.isFreezed': hasProblem},
|
||||||
{'tp.risk': hasProblem},
|
{'tp.hasRisk': hasProblem},
|
||||||
{'tp.hasTicketRequest': hasProblem},
|
{'tp.hasTicketRequest': hasProblem},
|
||||||
{'tp.itemShortage': range},
|
{'tp.itemShortage': range},
|
||||||
{'tp.hasComponentLack': hasProblem},
|
{'tp.hasComponentLack': hasProblem},
|
||||||
|
|
Loading…
Reference in New Issue