7489-testToMaster #2515
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
|
@ -54,6 +54,12 @@ For end-to-end tests run from project's root.
|
||||||
$ npm run test:e2e
|
$ npm run test:e2e
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Generate changeLog test → master
|
||||||
|
```
|
||||||
|
$ bash changelog.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Visual Studio Code extensions
|
## Visual Studio Code extensions
|
||||||
|
|
||||||
Open Visual Studio Code, press Ctrl+P and paste the following commands.
|
Open Visual Studio Code, press Ctrl+P and paste the following commands.
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
features_types=(chore feat style)
|
||||||
|
changes_types=(refactor perf)
|
||||||
|
fix_types=(fix revert)
|
||||||
|
file="CHANGELOG.md"
|
||||||
|
file_tmp="temp_log.txt"
|
||||||
|
file_current_tmp="temp_current_log.txt"
|
||||||
|
|
||||||
|
setType(){
|
||||||
|
echo "### $1" >> $file_tmp
|
||||||
|
arr=("$@")
|
||||||
|
echo "" > $file_current_tmp
|
||||||
|
for i in "${arr[@]}"
|
||||||
|
do
|
||||||
|
git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp
|
||||||
|
done
|
||||||
|
# remove duplicates
|
||||||
|
sort -o $file_current_tmp -u $file_current_tmp
|
||||||
|
cat $file_current_tmp >> $file_tmp
|
||||||
|
echo "" >> $file_tmp
|
||||||
|
# remove tmp current file
|
||||||
|
[ -e $file_current_tmp ] && rm $file_current_tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp
|
||||||
|
echo "" >> $file_tmp
|
||||||
|
|
||||||
|
setType "Added 🆕" "${features_types[@]}"
|
||||||
|
setType "Changed 📦" "${changes_types[@]}"
|
||||||
|
setType "Fixed 🛠️" "${fix_types[@]}"
|
||||||
|
|
||||||
|
cat $file >> $file_tmp
|
||||||
|
mv $file_tmp $file
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_clone`(vEntryFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Clone buys to an entry
|
||||||
|
*
|
||||||
|
* @param vEntryFk The entry id
|
||||||
|
* @table tmp.buy(id)
|
||||||
|
*/
|
||||||
|
INSERT INTO buy(
|
||||||
|
entryFk,
|
||||||
|
itemFk,
|
||||||
|
quantity,
|
||||||
|
buyingValue,
|
||||||
|
freightValue,
|
||||||
|
isIgnored,
|
||||||
|
stickers,
|
||||||
|
packagingFk,
|
||||||
|
packing,
|
||||||
|
`grouping`,
|
||||||
|
groupingMode,
|
||||||
|
containerFk,
|
||||||
|
comissionValue,
|
||||||
|
packageValue,
|
||||||
|
price1,
|
||||||
|
price2,
|
||||||
|
price3,
|
||||||
|
minPrice,
|
||||||
|
isChecked,
|
||||||
|
location,
|
||||||
|
weight,
|
||||||
|
itemOriginalFk)
|
||||||
|
SELECT vEntryFk,
|
||||||
|
b.itemFk,
|
||||||
|
b.quantity,
|
||||||
|
b.buyingValue,
|
||||||
|
b.freightValue,
|
||||||
|
b.isIgnored,
|
||||||
|
b.stickers,
|
||||||
|
b.packagingFk,
|
||||||
|
b.packing,
|
||||||
|
b.`grouping`,
|
||||||
|
b.groupingMode,
|
||||||
|
b.containerFk,
|
||||||
|
b.comissionValue,
|
||||||
|
b.packageValue,
|
||||||
|
b.price1,
|
||||||
|
b.price2,
|
||||||
|
b.price3,
|
||||||
|
b.minPrice,
|
||||||
|
b.isChecked,
|
||||||
|
b.location,
|
||||||
|
b.weight,
|
||||||
|
b.itemOriginalFk
|
||||||
|
FROM tmp.buy tb
|
||||||
|
JOIN vn.buy b ON b.id = tb.id;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -9,8 +9,8 @@ BEGIN
|
||||||
* Clones an entry header.
|
* Clones an entry header.
|
||||||
*
|
*
|
||||||
* @param vSelf The entry id
|
* @param vSelf The entry id
|
||||||
|
* @param OUT vNewEntryFk The new entry id
|
||||||
* @param vTravelFk Travel for the new entry or %NULL to use the source entry travel
|
* @param vTravelFk Travel for the new entry or %NULL to use the source entry travel
|
||||||
* @param vNewEntryFk The new entry id
|
|
||||||
*/
|
*/
|
||||||
INSERT INTO entry(
|
INSERT INTO entry(
|
||||||
travelFk,
|
travelFk,
|
||||||
|
|
|
@ -1,59 +1,18 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vCopyTo INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vDestinationEntryFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Copies an entry buys to another buy.
|
* Copies all buys from an entry to an entry.
|
||||||
*
|
*
|
||||||
* @param vSelf The entry id
|
* @param vSelf The entry id
|
||||||
* @param vCopyTo The destination entry id
|
* @param vDestinationEntryFk The destination entry id
|
||||||
*/
|
*/
|
||||||
INSERT INTO buy(
|
CREATE OR REPLACE TEMPORARY TABLE tmp.buy
|
||||||
entryFk,
|
SELECT id
|
||||||
itemFk,
|
|
||||||
quantity,
|
|
||||||
buyingValue,
|
|
||||||
freightValue,
|
|
||||||
isIgnored,
|
|
||||||
stickers,
|
|
||||||
packing,
|
|
||||||
`grouping`,
|
|
||||||
groupingMode,
|
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
|
||||||
packageValue,
|
|
||||||
packagingFk,
|
|
||||||
price1,
|
|
||||||
price2,
|
|
||||||
price3,
|
|
||||||
minPrice,
|
|
||||||
isChecked,
|
|
||||||
location,
|
|
||||||
weight,
|
|
||||||
itemOriginalFk
|
|
||||||
)
|
|
||||||
SELECT vCopyTo,
|
|
||||||
itemFk,
|
|
||||||
quantity,
|
|
||||||
buyingValue,
|
|
||||||
freightValue,
|
|
||||||
isIgnored,
|
|
||||||
stickers,
|
|
||||||
packing,
|
|
||||||
`grouping`,
|
|
||||||
groupingMode,
|
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
|
||||||
packageValue,
|
|
||||||
packagingFk,
|
|
||||||
price1,
|
|
||||||
price2,
|
|
||||||
price3,
|
|
||||||
minPrice,
|
|
||||||
isChecked,
|
|
||||||
location,
|
|
||||||
weight,
|
|
||||||
itemOriginalFk
|
|
||||||
FROM buy
|
FROM buy
|
||||||
WHERE entryFk = vSelf;
|
WHERE entryFk = vSelf;
|
||||||
|
|
||||||
|
CALL buy_clone(vDestinationEntryFk);
|
||||||
|
DROP TEMPORARY TABLE tmp.buy;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(
|
||||||
|
vBarcodeItem INT,
|
||||||
|
vShelvingFK VARCHAR(10)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Obtiene el precio y visible de un item
|
||||||
|
*
|
||||||
|
* @param vBarcodeItem barcode de artículo
|
||||||
|
* @param vShelvingFK Ubicación actual del artículo
|
||||||
|
*/
|
||||||
|
DECLARE vIsItem BOOL;
|
||||||
|
DECLARE vBuyFk INT;
|
||||||
|
DECLARE vWarehouseFk INT;
|
||||||
|
|
||||||
|
SELECT COUNT(*) > 0 INTO vIsItem
|
||||||
|
FROM item
|
||||||
|
WHERE id = vBarcodeItem;
|
||||||
|
|
||||||
|
IF vIsItem THEN
|
||||||
|
SELECT warehouseFk INTO vWarehouseFk
|
||||||
|
FROM operator
|
||||||
|
WHERE workerFk = account.myUser_getId();
|
||||||
|
|
||||||
|
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
|
SELECT buyFk INTO vBuyFk
|
||||||
|
FROM tmp.buyUltimate
|
||||||
|
WHERE itemFk = vBarcodeItem
|
||||||
|
AND warehouseFk = vWarehouseFk;
|
||||||
|
|
||||||
|
DELETE FROM tmp.buyUltimate;
|
||||||
|
ELSE
|
||||||
|
SELECT vBarcodeItem INTO vBuyFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
WITH visible AS(
|
||||||
|
SELECT itemFk,
|
||||||
|
IFNULL(buyingValue, 0) +
|
||||||
|
IFNULL(freightValue, 0) +
|
||||||
|
IFNULL(comissionValue, 0) +
|
||||||
|
IFNULL(packageValue, 0) itemCost
|
||||||
|
FROM vn.buy b
|
||||||
|
WHERE b.id = vBuyFk
|
||||||
|
) SELECT v.itemFk,
|
||||||
|
vShelvingFK,
|
||||||
|
v.itemCost,
|
||||||
|
SUM(ish.visible) visible
|
||||||
|
FROM vn.itemShelving ish
|
||||||
|
JOIN visible v
|
||||||
|
WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci
|
||||||
|
AND ish.itemFk = v.itemFk;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,411 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_devalueA2`(
|
||||||
|
vSelf INT,
|
||||||
|
vShelvingFK VARCHAR(10),
|
||||||
|
vBuyingValue DECIMAL(10,4),
|
||||||
|
vQuantity INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devalua un item modificando su calidad de A1 a A2.
|
||||||
|
* Si no existe el item A2 lo crea y genera los movimientos de las entradas
|
||||||
|
* de almacén y shelvings correspondientes
|
||||||
|
*
|
||||||
|
* @param vSelf Id de artículo a devaluar
|
||||||
|
* @param vShelvingFK Ubicación actual del artículo
|
||||||
|
* @param vBuyingValue Nuevo precio de coste
|
||||||
|
* @param vQuantity Cantidad del ítem a pasar a A2
|
||||||
|
*/
|
||||||
|
DECLARE vItemA2Fk INT;
|
||||||
|
DECLARE vLastBuyFk BIGINT;
|
||||||
|
DECLARE vA1BuyFk INT;
|
||||||
|
DECLARE vA2BuyFk INT;
|
||||||
|
DECLARE vTargetEntryFk INT;
|
||||||
|
DECLARE vTargetEntryDate DATE;
|
||||||
|
DECLARE vTargetItemShelvingFk BIGINT;
|
||||||
|
DECLARE vWarehouseFk INT;
|
||||||
|
DECLARE vCacheFk INT;
|
||||||
|
DECLARE vLastEntryFk INT;
|
||||||
|
DECLARE vCurrentVisible INT;
|
||||||
|
DECLARE vDevalueTravelFk INT;
|
||||||
|
DECLARE vCurdate DATE;
|
||||||
|
DECLARE vBuyingValueOriginal DECIMAL(10,4);
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK;
|
||||||
|
RESIGNAL;
|
||||||
|
END;
|
||||||
|
|
||||||
|
IF (SELECT TRUE FROM item WHERE id = vSelf AND (category <> 'A1' OR category IS NULL)) THEN
|
||||||
|
CALL util.throw('Item has not category A1');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT warehouseFk INTO vWarehouseFk
|
||||||
|
FROM userConfig
|
||||||
|
WHERE userFk = account.myUser_getId();
|
||||||
|
|
||||||
|
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
|
||||||
|
CALL util.throw ('Operator has not a valid warehouse');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vQuantity <= 0 OR vQuantity IS NULL THEN
|
||||||
|
CALL util.throw ('The quantity is incorrect');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT util.VN_CURDATE() INTO vCurdate;
|
||||||
|
|
||||||
|
SELECT t.id INTO vDevalueTravelFk
|
||||||
|
FROM travel t
|
||||||
|
JOIN travelConfig tc
|
||||||
|
WHERE t.shipped = vCurdate
|
||||||
|
AND t.landed = vCurdate
|
||||||
|
AND t.warehouseInFk = vWarehouseFk
|
||||||
|
AND t.warehouseOutFk = tc.devalueWarehouseOutFk
|
||||||
|
AND t.agencyModeFk = tc.devalueAgencyModeFk
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
IF NOT vDevalueTravelFk OR vDevalueTravelFk IS NULL THEN
|
||||||
|
INSERT INTO travel (
|
||||||
|
shipped,
|
||||||
|
landed,
|
||||||
|
warehouseInFk,
|
||||||
|
warehouseOutFk,
|
||||||
|
`ref`,
|
||||||
|
isReceived,
|
||||||
|
agencyModeFk)
|
||||||
|
SELECT vCurdate,
|
||||||
|
vCurdate,
|
||||||
|
vWarehouseFk,
|
||||||
|
tc.devalueWarehouseOutFk,
|
||||||
|
tc.devalueRef,
|
||||||
|
TRUE,
|
||||||
|
tc.devalueAgencyModeFk
|
||||||
|
FROM travelConfig tc;
|
||||||
|
SET vDevalueTravelFk = LAST_INSERT_ID();
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT id, DATE(dated) INTO vTargetEntryFk, vTargetEntryDate
|
||||||
|
FROM `entry` e
|
||||||
|
WHERE DATE(dated) = vCurdate
|
||||||
|
AND typeFk = 'devaluation'
|
||||||
|
AND travelFk = vDevalueTravelFk
|
||||||
|
ORDER BY created DESC
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
CALL buyUltimate(vWarehouseFk, vCurdate);
|
||||||
|
|
||||||
|
SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal
|
||||||
|
FROM tmp.buyUltimate bu
|
||||||
|
JOIN vn.buy b ON b.id = bu.buyFk
|
||||||
|
WHERE bu.itemFk = vSelf
|
||||||
|
AND bu.warehouseFk = vWarehouseFk;
|
||||||
|
|
||||||
|
IF vBuyingValue > vBuyingValueOriginal THEN
|
||||||
|
CALL util.throw ('Price not valid');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vLastEntryFk IS NULL OR vLastBuyFk IS NULL THEN
|
||||||
|
CALL util.throw ('The item has not a buy');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible
|
||||||
|
FROM itemShelving
|
||||||
|
WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
|
||||||
|
AND itemFk = vSelf
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
IF vCurrentVisible IS NULL THEN
|
||||||
|
CALL util.throw ('The shelving has not a visible for this item');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vQuantity > vCurrentVisible THEN
|
||||||
|
CALL util.throw('Quantity is greater than visible');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
IF NOT vTargetEntryFk OR vTargetEntryFk IS NULL
|
||||||
|
OR NOT vTargetEntryDate <=> vCurdate THEN
|
||||||
|
INSERT INTO entry(
|
||||||
|
travelFk,
|
||||||
|
supplierFk,
|
||||||
|
dated,
|
||||||
|
commission,
|
||||||
|
currencyFk,
|
||||||
|
companyFk,
|
||||||
|
clonedFrom,
|
||||||
|
typeFk
|
||||||
|
)
|
||||||
|
SELECT vDevalueTravelFk,
|
||||||
|
supplierFk,
|
||||||
|
vCurdate,
|
||||||
|
commission,
|
||||||
|
currencyFk,
|
||||||
|
companyFk,
|
||||||
|
vLastEntryFk,
|
||||||
|
'devaluation'
|
||||||
|
FROM entry
|
||||||
|
WHERE id = vLastEntryFk;
|
||||||
|
|
||||||
|
SET vTargetEntryFk = LAST_INSERT_ID();
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT i.id INTO vItemA2Fk
|
||||||
|
FROM item i
|
||||||
|
JOIN (
|
||||||
|
SELECT i.id,
|
||||||
|
i.name,
|
||||||
|
i.subname,
|
||||||
|
i.value5,
|
||||||
|
i.value6,
|
||||||
|
i.value7,
|
||||||
|
i.value8,
|
||||||
|
i.value9,
|
||||||
|
i.value10,
|
||||||
|
i.NumberOfItemsPerCask,
|
||||||
|
i.EmbalageCode,
|
||||||
|
i.quality
|
||||||
|
FROM item i
|
||||||
|
WHERE i.id = vSelf
|
||||||
|
)i2 ON i2.name <=> i.name
|
||||||
|
AND i2.subname <=> i.subname
|
||||||
|
AND i2.value5 <=> i.value5
|
||||||
|
AND i2.value6 <=> i.value6
|
||||||
|
AND i2.value8 <=> i.value8
|
||||||
|
AND i2.value9 <=> i.value9
|
||||||
|
AND i2.value10 <=> i.value10
|
||||||
|
AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask
|
||||||
|
AND i2.EmbalageCode <=> i.EmbalageCode
|
||||||
|
AND i2.quality <=> i.quality
|
||||||
|
WHERE i.id <> i2.id
|
||||||
|
AND i.category = 'A2'
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
IF vItemA2Fk IS NULL THEN
|
||||||
|
INSERT INTO item (
|
||||||
|
equivalent,
|
||||||
|
name,
|
||||||
|
`size`,
|
||||||
|
stems,
|
||||||
|
minPrice,
|
||||||
|
isToPrint,
|
||||||
|
family,
|
||||||
|
box,
|
||||||
|
category,
|
||||||
|
originFk,
|
||||||
|
doPhoto,
|
||||||
|
image,
|
||||||
|
inkFk,
|
||||||
|
intrastatFk,
|
||||||
|
hasMinPrice,
|
||||||
|
created,
|
||||||
|
comment,
|
||||||
|
typeFk,
|
||||||
|
generic,
|
||||||
|
producerFk,
|
||||||
|
description,
|
||||||
|
density,
|
||||||
|
relevancy,
|
||||||
|
expenseFk,
|
||||||
|
isActive,
|
||||||
|
longName,
|
||||||
|
subName,
|
||||||
|
minimum,
|
||||||
|
upToDown,
|
||||||
|
supplyResponseFk,
|
||||||
|
hasKgPrice,
|
||||||
|
isFloramondo,
|
||||||
|
isFragile,
|
||||||
|
numberOfItemsPerCask,
|
||||||
|
embalageCode,
|
||||||
|
quality,
|
||||||
|
stemMultiplier,
|
||||||
|
itemPackingTypeFk,
|
||||||
|
packingOut,
|
||||||
|
genericFk,
|
||||||
|
isLaid,
|
||||||
|
lastUsed,
|
||||||
|
weightByPiece,
|
||||||
|
editorFk,
|
||||||
|
recycledPlastic,
|
||||||
|
nonRecycledPlastic)
|
||||||
|
SELECT equivalent,
|
||||||
|
name,
|
||||||
|
`size`,
|
||||||
|
stems,
|
||||||
|
minPrice,
|
||||||
|
isToPrint,
|
||||||
|
family,
|
||||||
|
box,
|
||||||
|
'A2',
|
||||||
|
originFk,
|
||||||
|
doPhoto,
|
||||||
|
image,
|
||||||
|
inkFk,
|
||||||
|
intrastatFk,
|
||||||
|
hasMinPrice,
|
||||||
|
created,
|
||||||
|
comment,
|
||||||
|
typeFk,
|
||||||
|
generic,
|
||||||
|
producerFk,
|
||||||
|
description,
|
||||||
|
density,
|
||||||
|
relevancy,
|
||||||
|
expenseFk,
|
||||||
|
isActive,
|
||||||
|
longName,
|
||||||
|
subName,
|
||||||
|
minimum,
|
||||||
|
upToDown,
|
||||||
|
supplyResponseFk,
|
||||||
|
hasKgPrice,
|
||||||
|
isFloramondo,
|
||||||
|
isFragile,
|
||||||
|
numberOfItemsPerCask,
|
||||||
|
embalageCode,
|
||||||
|
quality,
|
||||||
|
stemMultiplier,
|
||||||
|
itemPackingTypeFk,
|
||||||
|
packingOut,
|
||||||
|
genericFk,
|
||||||
|
isLaid,
|
||||||
|
lastUsed,
|
||||||
|
weightByPiece,
|
||||||
|
editorFk,
|
||||||
|
recycledPlastic,
|
||||||
|
nonRecycledPlastic
|
||||||
|
FROM item
|
||||||
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
SET vItemA2Fk = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
INSERT INTO itemTag (itemFk, tagFk, `value`, intValue, priority, editorFk)
|
||||||
|
SELECT vItemA2Fk, tagFk, `value`, intValue, priority, editorFk
|
||||||
|
FROM itemTag
|
||||||
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
UPDATE itemTaxCountry itc
|
||||||
|
JOIN itemTaxCountry itc2 ON itc2.itemFk = vSelf
|
||||||
|
AND itc2.countryFk = itc.countryFk
|
||||||
|
SET itc2.taxClassFk = itc.taxClassFk
|
||||||
|
WHERE itc.id = vItemA2Fk;
|
||||||
|
|
||||||
|
INSERT INTO itemBotanical (itemFk, genusFk, specieFk)
|
||||||
|
SELECT vItemA2Fk, genusFk, specieFk
|
||||||
|
FROM itemBotanical
|
||||||
|
WHERE itemFk = vSelf;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vQuantity = vCurrentVisible THEN
|
||||||
|
DELETE FROM itemShelving
|
||||||
|
WHERE id = vTargetItemShelvingFk;
|
||||||
|
ELSE
|
||||||
|
UPDATE itemShelving
|
||||||
|
SET visible = vCurrentVisible - vQuantity
|
||||||
|
WHERE id = vTargetItemShelvingFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
INSERT INTO buy(
|
||||||
|
entryFk,
|
||||||
|
itemFk,
|
||||||
|
quantity,
|
||||||
|
buyingValue,
|
||||||
|
freightValue,
|
||||||
|
isIgnored,
|
||||||
|
stickers,
|
||||||
|
packagingFk,
|
||||||
|
packing,
|
||||||
|
`grouping`,
|
||||||
|
groupingMode,
|
||||||
|
containerFk,
|
||||||
|
comissionValue,
|
||||||
|
packageValue,
|
||||||
|
price1,
|
||||||
|
price2,
|
||||||
|
price3,
|
||||||
|
minPrice,
|
||||||
|
isChecked,
|
||||||
|
location,
|
||||||
|
weight,
|
||||||
|
itemOriginalFk)
|
||||||
|
SELECT vTargetEntryFk,
|
||||||
|
itemFk,
|
||||||
|
- LEAST(vQuantity, vCurrentVisible),
|
||||||
|
buyingValue,
|
||||||
|
freightValue,
|
||||||
|
TRUE,
|
||||||
|
stickers,
|
||||||
|
packagingFk,
|
||||||
|
packing,
|
||||||
|
`grouping`,
|
||||||
|
groupingMode,
|
||||||
|
containerFk,
|
||||||
|
comissionValue,
|
||||||
|
packageValue,
|
||||||
|
price1,
|
||||||
|
price2,
|
||||||
|
price3,
|
||||||
|
minPrice,
|
||||||
|
isChecked,
|
||||||
|
location,
|
||||||
|
weight,
|
||||||
|
itemOriginalFk
|
||||||
|
FROM vn.buy
|
||||||
|
WHERE id = vLastBuyFk
|
||||||
|
UNION
|
||||||
|
SELECT vTargetEntryFk,
|
||||||
|
vItemA2Fk,
|
||||||
|
vQuantity,
|
||||||
|
vBuyingValue,
|
||||||
|
freightValue,
|
||||||
|
TRUE,
|
||||||
|
stickers,
|
||||||
|
packagingFk,
|
||||||
|
packing,
|
||||||
|
`grouping`,
|
||||||
|
groupingMode,
|
||||||
|
containerFk,
|
||||||
|
comissionValue,
|
||||||
|
packageValue,
|
||||||
|
price1,
|
||||||
|
price2,
|
||||||
|
price3,
|
||||||
|
minPrice,
|
||||||
|
isChecked,
|
||||||
|
location,
|
||||||
|
weight,
|
||||||
|
itemOriginalFk
|
||||||
|
FROM vn.buy
|
||||||
|
WHERE id = vLastBuyFk;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO itemShelving (
|
||||||
|
itemFk,
|
||||||
|
shelvingFk,
|
||||||
|
visible,
|
||||||
|
`grouping`,
|
||||||
|
packing,
|
||||||
|
packagingFk,
|
||||||
|
userFk,
|
||||||
|
isChecked)
|
||||||
|
SELECT vItemA2Fk,
|
||||||
|
shelvingFk,
|
||||||
|
vQuantity ,
|
||||||
|
`grouping`,
|
||||||
|
packing,
|
||||||
|
packagingFk,
|
||||||
|
account.myUser_getId(),
|
||||||
|
isChecked
|
||||||
|
FROM itemShelving
|
||||||
|
WHERE itemFK = vSelf
|
||||||
|
AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
visible = vQuantity + VALUES(visible);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
CALL cache.visible_refresh(vCacheFk, TRUE, vWarehouseFk);
|
||||||
|
CALL cache.available_refresh(vCacheFk, TRUE, vWarehouseFk, vCurdate);
|
||||||
|
CALL buy_recalcPricesByBuy(vA2BuyFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,24 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_checkMultipleDevice`(
|
||||||
|
vSelf INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Verify if a worker has multiple assigned devices,
|
||||||
|
* except for freelancers.
|
||||||
|
*
|
||||||
|
* @param vUserFk worker id.
|
||||||
|
*/
|
||||||
|
DECLARE vHasPda BOOLEAN;
|
||||||
|
DECLARE vIsFreelance BOOLEAN;
|
||||||
|
DECLARE vMaxDevicesPerUser INT;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = vSelf;
|
||||||
|
SELECT IFNULL(isFreelance, FALSE) INTO vIsFreelance FROM worker WHERE id = vSelf;
|
||||||
|
SELECT IFNULL(maxDevicesPerUser, FALSE) INTO vMaxDevicesPerUser FROM deviceProductionConfig LIMIT 1;
|
||||||
|
|
||||||
|
IF NOT vIsFreelance AND vHasPda > vMaxDevicesPerUser THEN
|
||||||
|
CALL util.throw('You can only have one PDA');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_afterInsert`
|
||||||
|
AFTER INSERT ON `deviceProductionUser`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL worker_checkMultipleDevice(NEW.userFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_
|
||||||
BEFORE UPDATE ON `deviceProductionUser`
|
BEFORE UPDATE ON `deviceProductionUser`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
|
CALL worker_checkMultipleDevice(NEW.userFk);
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
INSERT IGNORE INTO vn.entryType (code, description)
|
||||||
|
VALUES ('devaluation', 'Devaluación');
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueWarehouseOutFk SMALLINT(6) UNSIGNED NULL
|
||||||
|
COMMENT 'Datos del travel para las entradas generadas al devaluar artículos de A1 a A2';
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueAgencyModeFk INT(11) NULL;
|
||||||
|
ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueRef varchar(20) NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig DROP FOREIGN KEY IF EXISTS travelConfig_agencyMode_FK;
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_agencyMode_FK
|
||||||
|
FOREIGN KEY (devalueAgencyModeFk) REFERENCES vn.agencyMode(id) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig DROP FOREIGN KEY IF EXISTS travelConfig_warehouse_FK;
|
||||||
|
ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_warehouse_FK
|
||||||
|
FOREIGN KEY (devalueWarehouseOutFk) REFERENCES vn.warehouse(id) ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@ -0,0 +1,21 @@
|
||||||
|
ALTER TABLE vn.deviceProductionUser DROP INDEX IF EXISTS deviceProductionUser_UN;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser DROP FOREIGN KEY IF EXISTS deviceProductionUser_FK;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser DROP PRIMARY KEY;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser ADD IF NOT EXISTS id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY FIRST;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_deviceProduction_FK FOREIGN KEY IF NOT EXISTS (deviceProductionFk) REFERENCES vn.deviceProduction(id);
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_unique UNIQUE KEY IF NOT EXISTS (deviceProductionFk);
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser ADD IF NOT EXISTS simSerialNumber TEXT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionConfig ADD IF NOT EXISTS maxDevicesPerUser INT UNSIGNED NULL;
|
||||||
|
|
||||||
|
UPDATE vn.deviceProductionConfig SET maxDevicesPerUser=1 WHERE id=1;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('Worker','getAvailablePda','READ','ALLOW','ROLE','hr');
|
||||||
|
|
|
@ -225,5 +225,6 @@
|
||||||
"ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)",
|
"ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)",
|
||||||
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
|
"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",
|
"They're not your subordinate": "They're not your subordinate",
|
||||||
"InvoiceIn is already booked": "InvoiceIn is already booked"
|
"InvoiceIn is already booked": "InvoiceIn is already booked",
|
||||||
|
"This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency"
|
||||||
}
|
}
|
|
@ -356,5 +356,7 @@
|
||||||
"InvoiceIn is already booked": "La factura recibida está contabilizada",
|
"InvoiceIn is already booked": "La factura recibida está contabilizada",
|
||||||
"This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
|
"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",
|
"Select ticket or client": "Elija un ticket o un client",
|
||||||
"It was not able to create the invoice": "No se pudo crear la factura"
|
"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)"
|
||||||
}
|
}
|
|
@ -138,12 +138,10 @@ module.exports = Self => {
|
||||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||||
JOIN zone z ON z.id = t.zoneFk
|
|
||||||
SET t.routeFk = NULL
|
SET t.routeFk = NULL
|
||||||
WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?)
|
WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?)
|
||||||
AND al.code NOT IN('DELIVERED','PACKED')
|
AND al.code NOT IN ('DELIVERED', 'PACKED')
|
||||||
AND t.routeFk
|
AND t.routeFk`, [toDate, toDate], {userId: ctx.req.accessToken.userId});
|
||||||
AND z.name LIKE '%MADRID%'`, [toDate, toDate], {userId: ctx.req.accessToken.userId});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: 'Success'
|
message: 'Success'
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getAvailablePda', {
|
||||||
|
description: 'returns devices without user',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [],
|
||||||
|
returns: {
|
||||||
|
type: 'array',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/getAvailablePda`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Self.getAvailablePda = async() => {
|
||||||
|
return Self.app.models.DeviceProduction.rawSql(
|
||||||
|
`SELECT d.*
|
||||||
|
FROM deviceProduction d
|
||||||
|
LEFT JOIN deviceProductionUser du ON du.deviceProductionFk = d.id
|
||||||
|
WHERE du.deviceProductionFk IS NULL`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,13 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('worker getAvailablePda()', () => {
|
||||||
|
it('should return a Pda that has no user assigned', async() => {
|
||||||
|
const [{id}] = await models.Worker.getAvailablePda();
|
||||||
|
|
||||||
|
const deviceProductionUser = await models.DeviceProductionUser.findOne({
|
||||||
|
where: {deviceProductionFk: id}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(!deviceProductionUser).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.rewriteDbError(function(err) {
|
||||||
|
if (err.code === 'ER_DUP_ENTRY')
|
||||||
|
return new UserError(`This PDA is already assigned to another user`);
|
||||||
|
return err;
|
||||||
|
});
|
||||||
|
};
|
|
@ -14,6 +14,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
"deviceProductionFk": {
|
"deviceProductionFk": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"id": true
|
"id": true
|
||||||
|
@ -21,6 +25,9 @@
|
||||||
"userFk": {
|
"userFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"simSerialNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"created": {
|
"created": {
|
||||||
"type": "date"
|
"type": "date"
|
||||||
}
|
}
|
||||||
|
@ -36,5 +43,10 @@
|
||||||
"model": "User",
|
"model": "User",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"scope": {
|
||||||
|
"include":{
|
||||||
|
"relation": "deviceProduction"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ module.exports = Self => {
|
||||||
require('../methods/worker/search')(Self);
|
require('../methods/worker/search')(Self);
|
||||||
require('../methods/worker/isAuthorized')(Self);
|
require('../methods/worker/isAuthorized')(Self);
|
||||||
require('../methods/worker/setPassword')(Self);
|
require('../methods/worker/setPassword')(Self);
|
||||||
|
require('../methods/worker/getAvailablePda')(Self);
|
||||||
|
|
||||||
Self.validateAsync('fi', tinIsValid, {
|
Self.validateAsync('fi', tinIsValid, {
|
||||||
message: 'Invalid TIN'
|
message: 'Invalid TIN'
|
||||||
|
|
|
@ -62,7 +62,23 @@
|
||||||
},
|
},
|
||||||
"isFreelance": {
|
"isFreelance": {
|
||||||
"type" : "boolean"
|
"type" : "boolean"
|
||||||
|
},
|
||||||
|
"fiDueDate": {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"hasMachineryAuthorized": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"seniority": {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"isDisable": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"isSsDiscounted": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"user": {
|
"user": {
|
||||||
|
|
Loading…
Reference in New Issue