Merge branch 'master' into 7781-fixPalletMerge
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Pablo Natek 2024-09-10 06:35:06 +00:00
commit fd1370f2e0
10 changed files with 76 additions and 13 deletions

View File

@ -1,5 +1,10 @@
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
DECLARE vStartDate DATE;
DECLARE vReserveDate DATETIME;

View File

@ -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 ;

View File

@ -1,8 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_addItem`(
vSelf INT,
vWarehouse INT,
vItem INT,
vWarehouse INT,
vItem INT,
vAmount INT)
BEGIN
/**
@ -37,7 +37,7 @@ BEGIN
ROLLBACK;
RESIGNAL;
END;
CALL order_calcCatalogFromItem(vSelf, vItem);
START TRANSACTION;
@ -47,11 +47,15 @@ BEGIN
FROM tmp.zoneGetShipped
WHERE warehouseFk = vWarehouse;
SELECT IFNULL(available, 0) INTO vAvailable
SELECT available INTO vAvailable
FROM tmp.ticketLot
WHERE warehouseFk = vWarehouse
AND itemFk = vItem;
IF vAvailable IS NULL THEN
SET vAvailable = 0;
END IF;
IF vAmount > vAvailable THEN
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
END IF;
@ -102,6 +106,8 @@ BEGIN
amount = vAdd,
price = vPrice;
CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd);
SET vRow = LAST_INSERT_ID();
INSERT INTO orderRowComponent (rowFk, componentFk, price)
@ -121,6 +127,6 @@ BEGIN
END IF;
COMMIT;
CALL vn.ticketCalculatePurge;
CALL vn.ticketCalculatePurge;
END$$
DELIMITER ;

View File

@ -85,7 +85,7 @@ BEGIN
IF(vHasDailyInvoice) AND vHasToInvoice THEN
SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial;
IF NOT vSerial THEN
IF vSerial IS NULL THEN
CALL util.throw('Cannot booking without a serial');
END IF;

View File

@ -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');

View File

@ -105,7 +105,8 @@ class Controller extends Section {
addressId: address.id,
invoiceDate: this.invoiceDate,
maxShipped: this.maxShipped,
companyFk: this.companyFk
companyFk: this.companyFk,
serialType: 'global'
};
this.$http.post(`InvoiceOuts/invoiceClient`, params)

View File

@ -1,7 +1,7 @@
const models = require('vn-loopback/server/server').models;
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 options = {transaction: tx};
@ -9,6 +9,7 @@ describe('item getVisibleAvailable()', () => {
const itemFk = 1;
const warehouseFk = 1;
const dated = Date.vnNew();
dated.setDate(dated.getDate() + 1);
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);

View File

@ -285,7 +285,7 @@ module.exports = Self => {
if (hasProblems === true) {
whereProblems = {or: [
{'tp.isFreezed': true},
{'tp.risk': {lt: 0}},
{'tp.hasRisk': true},
{'tp.hasTicketRequest': true},
{'tp.hasComponentLack': true},
{'tp.isTaxDataChecked': false},
@ -295,7 +295,7 @@ module.exports = Self => {
} else if (hasProblems === false) {
whereProblems = {and: [
{'tp.isFreezed': false},
{'tp.risk': 0},
{'tp.hasRisk': false},
{'tp.hasTicketRequest': false},
{'tp.hasComponentLack': false},
{'tp.isTaxDataChecked': true},

View File

@ -343,7 +343,7 @@ module.exports = Self => {
const problems = {[condition]: [
{'tp.isFreezed': hasProblem},
{'tp.risk': hasProblem},
{'tp.hasRisk': hasProblem},
{'tp.hasTicketRequest': hasProblem},
{'tp.itemShortage': range},
{'tp.hasRounding': hasProblem}

View File

@ -196,7 +196,7 @@ module.exports = Self => {
const problems = {
[condition]: [
{'tp.isFreezed': hasProblem},
{'tp.risk': hasProblem},
{'tp.hasRisk': hasProblem},
{'tp.hasTicketRequest': hasProblem},
{'tp.itemShortage': range},
{'tp.hasComponentLack': hasProblem},