Merge pull request 'refs #3126 changes' (!1776) from 3126-changePackageFkTopackagingFk into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1776
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Pablo Natek 2023-10-20 05:13:42 +00:00
commit 4dea8c59ac
29 changed files with 1735 additions and 150 deletions

View File

@ -0,0 +1,5 @@
ALTER TABLE `vn`.`buy` CHANGE `packageFk` `packagingFk` varchar(10)
CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT '--' NULL;
ALTER TABLE `vn`.`buy`
ADD COLUMN `packageFk` varchar(10) AS (`packagingFk`) VIRTUAL;

View File

@ -0,0 +1,146 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Compres`
AS SELECT `c`.`id` AS `Id_Compra`,
`c`.`entryFk` AS `Id_Entrada`,
`c`.`itemFk` AS `Id_Article`,
`c`.`buyingValue` AS `Costefijo`,
`c`.`quantity` AS `Cantidad`,
`c`.`packagingFk` AS `Id_Cubo`,
`c`.`stickers` AS `Etiquetas`,
`c`.`freightValue` AS `Portefijo`,
`c`.`packageValue` AS `Embalajefijo`,
`c`.`comissionValue` AS `Comisionfija`,
`c`.`packing` AS `Packing`,
`c`.`grouping` AS `grouping`,
`c`.`groupingMode` AS `caja`,
`c`.`location` AS `Nicho`,
`c`.`price1` AS `Tarifa1`,
`c`.`price2` AS `Tarifa2`,
`c`.`price3` AS `Tarifa3`,
`c`.`minPrice` AS `PVP`,
`c`.`printedStickers` AS `Vida`,
`c`.`isChecked` AS `punteo`,
`c`.`ektFk` AS `buy_edi_id`,
`c`.`created` AS `odbc_date`,
`c`.`isIgnored` AS `Novincular`,
`c`.`isPickedOff` AS `isPickedOff`,
`c`.`workerFk` AS `Id_Trabajador`,
`c`.`weight` AS `weight`,
`c`.`dispatched` AS `dispatched`,
`c`.`containerFk` AS `container_id`,
`c`.`itemOriginalFk` AS `itemOriginalFk`
FROM `vn`.`buy` `c`;
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`buySource`
AS SELECT `b`.`entryFk` AS `Id_Entrada`,
`b`.`isPickedOff` AS `isPickedOff`,
NULL AS `tarifa0`,
`e`.`kop` AS `kop`,
`b`.`id` AS `Id_Compra`,
`i`.`typeFk` AS `tipo_id`,
`b`.`itemFk` AS `Id_Article`,
`i`.`size` AS `Medida`,
`i`.`stems` AS `Tallos`,
`b`.`stickers` AS `Etiquetas`,
`b`.`packagingFk` AS `Id_Cubo`,
`b`.`buyingValue` AS `Costefijo`,
`b`.`packing` AS `Packing`,
`b`.`grouping` AS `Grouping`,
`b`.`quantity` AS `Cantidad`,
`b`.`price2` AS `Tarifa2`,
`b`.`price3` AS `Tarifa3`,
`b`.`isChecked` AS `Punteo`,
`b`.`groupingMode` AS `Caja`,
`i`.`isToPrint` AS `Imprimir`,
`i`.`name` AS `Article`,
`vn`.`ink`.`picture` AS `Tinta`,
`i`.`originFk` AS `id_origen`,
`i`.`minPrice` AS `PVP`,
NULL AS `Id_Accion`,
`s`.`company_name` AS `pro`,
`i`.`hasMinPrice` AS `Min`,
`b`.`isIgnored` AS `Novincular`,
`b`.`freightValue` AS `Portefijo`,
round(`b`.`buyingValue` * `b`.`quantity`, 2) AS `Importe`,
`b`.`printedStickers` AS `Vida`,
`i`.`comment` AS `reference`,
`b`.`workerFk` AS `Id_Trabajador`,
`e`.`s1` AS `S1`,
`e`.`s2` AS `S2`,
`e`.`s3` AS `S3`,
`e`.`s4` AS `S4`,
`e`.`s5` AS `S5`,
`e`.`s6` AS `S6`,
0 AS `price_fixed`,
`i`.`producerFk` AS `producer_id`,
`i`.`subName` AS `tag1`,
`i`.`value5` AS `tag2`,
`i`.`value6` AS `tag3`,
`i`.`value7` AS `tag4`,
`i`.`value8` AS `tag5`,
`i`.`value9` AS `tag6`,
`s`.`company_name` AS `company_name`,
`b`.`weight` AS `weightPacking`,
`i`.`packingOut` AS `packingOut`,
`b`.`itemOriginalFk` AS `itemOriginalFk`,
`io`.`longName` AS `itemOriginalName`,
`it`.`gramsMax` AS `gramsMax`
FROM (
(
(
(
(
(
`vn`.`item` `i`
JOIN `vn`.`itemType` `it` ON(`it`.`id` = `i`.`typeFk`)
)
LEFT JOIN `vn`.`ink` ON(`vn`.`ink`.`id` = `i`.`inkFk`)
)
LEFT JOIN `vn`.`buy` `b` ON(`b`.`itemFk` = `i`.`id`)
)
LEFT JOIN `vn`.`item` `io` ON(`io`.`id` = `b`.`itemOriginalFk`)
)
LEFT JOIN `edi`.`ekt` `e` ON(`e`.`id` = `b`.`ektFk`)
)
LEFT JOIN `edi`.`supplier` `s` ON(`e`.`pro` = `s`.`supplier_id`)
);
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`awbVolume`
AS SELECT `d`.`awbFk` AS `awbFk`,
`b`.`stickers` * `i`.`density` * IF(
`p`.`volume` > 0,
`p`.`volume`,
`p`.`width` * `p`.`depth` * IF(`p`.`height` = 0, `i`.`size` + 10, `p`.`height`)
) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,
`b`.`id` AS `buyFk`
FROM (
(
(
(
(
(
(
(
`vn`.`buy` `b`
JOIN `vn`.`item` `i` ON(`b`.`itemFk` = `i`.`id`)
)
JOIN `vn`.`itemType` `it` ON(`i`.`typeFk` = `it`.`id`)
)
JOIN `vn`.`packaging` `p` ON(`p`.`id` = `b`.`packagingFk`)
)
JOIN `vn`.`entry` `e` ON(`b`.`entryFk` = `e`.`id`)
)
JOIN `vn`.`travel` `t` ON(`t`.`id` = `e`.`travelFk`)
)
JOIN `vn`.`duaEntry` `de` ON(`de`.`entryFk` = `e`.`id`)
)
JOIN `vn`.`dua` `d` ON(`d`.`id` = `de`.`duaFk`)
)
JOIN `vn`.`volumeConfig` `vc`
)
WHERE `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1, 1);

View File

@ -0,0 +1,57 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_afterUpdate`
AFTER UPDATE ON `buy`
FOR EACH ROW
trig: BEGIN
DECLARE vLanded DATE;
DECLARE vBuyerFk INT;
DECLARE vIsBuyerToBeEmailed BOOL;
DECLARE vItemName VARCHAR(50);
IF @isModeInventory OR @isTriggerDisabled THEN
LEAVE trig;
END IF;
IF !(NEW.id <=> OLD.id)
OR !(NEW.entryFk <=> OLD.entryFk)
OR !(NEW.itemFk <=> OLD.itemFk)
OR !(NEW.quantity <=> OLD.quantity)
OR !(NEW.created <=> OLD.created) THEN
CALL stock.log_add('buy', NEW.id, OLD.id);
END IF;
CALL buy_afterUpsert(NEW.id);
SELECT w.isBuyerToBeEmailed, t.landed
INTO vIsBuyerToBeEmailed, vLanded
FROM entry e
JOIN travel t ON t.id = e.travelFk
JOIN warehouse w ON w.id = t.warehouseInFk
WHERE e.id = NEW.entryFk;
SELECT it.workerFk, i.longName
INTO vBuyerFk, vItemName
FROM itemCategory k
JOIN itemType it ON it.categoryFk = k.id
JOIN item i ON i.typeFk = it.id
WHERE i.id = OLD.itemFk;
IF vIsBuyerToBeEmailed AND
vBuyerFk != account.myUser_getId() AND
vLanded = util.VN_CURDATE() THEN
IF !(NEW.itemFk <=> OLD.itemFk) OR
!(NEW.quantity <=> OLD.quantity) OR
!(NEW.packing <=> OLD.packing) OR
!(NEW.grouping <=> OLD.grouping) OR
!(NEW.packagingFk <=> OLD.packagingFk) OR
!(NEW.weight <=> OLD.weight) THEN
CALL vn.mail_insert(
CONCAT(account.user_getNameFromId(vBuyerFk),'@verdnatura.es'),
CONCAT(account.myUser_getName(),'@verdnatura.es'),
CONCAT('E ', NEW.entryFk ,' Se ha modificado item ', NEW.itemFk, ' ', vItemName),
'Este email se ha generado automáticamente'
);
END IF;
END IF;
END$$
DELIMITER ;

File diff suppressed because it is too large Load Diff

View File

@ -1454,7 +1454,7 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'), ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'),
('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0'); ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0');
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packageFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
VALUES VALUES
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),

View File

@ -1192,7 +1192,7 @@ export default {
secondBuyPacking: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.packing"]', secondBuyPacking: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.packing"]',
secondBuyWeight: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.weight"]', secondBuyWeight: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.weight"]',
secondBuyStickers: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.stickers"]', secondBuyStickers: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.stickers"]',
secondBuyPackage: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-autocomplete[ng-model="buy.packageFk"]', secondBuyPackage: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-autocomplete[ng-model="buy.packagingFk"]',
secondBuyQuantity: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.quantity"]', secondBuyQuantity: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.quantity"]',
secondBuyItem: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-autocomplete[ng-model="buy.itemFk"]', secondBuyItem: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-autocomplete[ng-model="buy.itemFk"]',
importButton: 'vn-entry-buy-index vn-icon[icon="publish"]', importButton: 'vn-entry-buy-index vn-icon[icon="publish"]',

View File

@ -1,20 +1,5 @@
import getBrowser from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
const $ = {
saveButton: 'vn-supplier-fiscal-data button[type="submit"]',
};
const $inputs = {
province: 'vn-supplier-fiscal-data [name="province"]',
country: 'vn-supplier-fiscal-data [name="country"]',
postcode: 'vn-supplier-fiscal-data [name="postcode"]',
city: 'vn-supplier-fiscal-data [name="city"]',
socialName: 'vn-supplier-fiscal-data [name="socialName"]',
taxNumber: 'vn-supplier-fiscal-data [name="taxNumber"]',
account: 'vn-supplier-fiscal-data [name="account"]',
sageWithholding: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageWithholdingFk"]',
sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]'
};
describe('Supplier fiscal data path', () => { describe('Supplier fiscal data path', () => {
let browser; let browser;
let page; let page;
@ -30,7 +15,7 @@ describe('Supplier fiscal data path', () => {
await browser.close(); await browser.close();
}); });
it('should attempt to edit the fiscal data and check data is saved', async() => { it('should attempt to edit the fiscal data and check data iss saved', async() => {
await page.accessToSection('supplier.card.fiscalData'); await page.accessToSection('supplier.card.fiscalData');
const form = 'vn-supplier-fiscal-data form'; const form = 'vn-supplier-fiscal-data form';
@ -40,16 +25,16 @@ describe('Supplier fiscal data path', () => {
postcode: null, postcode: null,
city: 'Valencia', city: 'Valencia',
socialName: 'Farmer King SL', socialName: 'Farmer King SL',
taxNumber: 'Wrong tax number', taxNumber: '12345678Z',
account: '0123456789', account: '0123456789',
sageWithholding: 'retencion estimacion objetiva', sageWithholding: 'retencion estimacion objetiva',
sageTaxType: 'operaciones no sujetas' sageTaxType: 'operaciones no sujetas'
}; };
const errorMessage = await page.sendForm(form, values); const errorMessage = await page.sendForm(form, {
const message = await page.sendForm(form, { taxNumber: 'Wrong tax number'
taxNumber: '12345678Z'
}); });
const message = await page.sendForm(form, values);
await page.reloadSection('supplier.card.fiscalData'); await page.reloadSection('supplier.card.fiscalData');
const formValues = await page.fetchForm(form, Object.keys(values)); const formValues = await page.fetchForm(form, Object.keys(values));

View File

@ -15,4 +15,4 @@ columns:
weight: weight weight: weight
entryFk: entry entryFk: entry
itemFk: item itemFk: item
packageFk: package packagingFk: package

View File

@ -15,4 +15,4 @@ columns:
weight: peso weight: peso
entryFk: entrada entryFk: entrada
itemFk: artículo itemFk: artículo
packageFk: paquete packagingFk: paquete

View File

@ -80,7 +80,7 @@ module.exports = Self => {
comissionValue: buyUltimate.comissionValue, comissionValue: buyUltimate.comissionValue,
packageValue: buyUltimate.packageValue, packageValue: buyUltimate.packageValue,
location: buyUltimate.location, location: buyUltimate.location,
packageFk: buyUltimate.packageFk, packagingFk: buyUltimate.packagingFk,
price1: buyUltimate.price1, price1: buyUltimate.price1,
price2: buyUltimate.price2, price2: buyUltimate.price2,
price3: buyUltimate.price3, price3: buyUltimate.price3,

View File

@ -44,7 +44,7 @@ module.exports = Self => {
'grouping', 'grouping',
'groupingMode', 'groupingMode',
'quantity', 'quantity',
'packageFk', 'packagingFk',
'weight', 'weight',
'buyingValue', 'buyingValue',
'price2', 'price2',

View File

@ -108,7 +108,7 @@ module.exports = Self => {
packing: buy.packing, packing: buy.packing,
grouping: buy.grouping, grouping: buy.grouping,
buyingValue: buy.buyingValue, buyingValue: buy.buyingValue,
packageFk: buy.packageFk, packagingFk: buy.packagingFk,
groupingMode: lastBuy.groupingMode, groupingMode: lastBuy.groupingMode,
weight: lastBuy.weight weight: lastBuy.weight
}); });

View File

@ -39,7 +39,7 @@ module.exports = Self => {
}, myOptions); }, myOptions);
if (packaging) if (packaging)
buy.packageFk = packaging.id; buy.packagingFk = packaging.id;
const reference = await models.ItemMatchProperties.findOne({ const reference = await models.ItemMatchProperties.findOne({
fields: ['itemFk'], fields: ['itemFk'],

View File

@ -153,64 +153,63 @@ module.exports = Self => {
const date = Date.vnNew(); const date = Date.vnNew();
date.setHours(0, 0, 0, 0); date.setHours(0, 0, 0, 0);
stmt = new ParameterizedSQL(` stmt = new ParameterizedSQL(`
SELECT SELECT i.image,
i.image, i.id AS itemFk,
i.id AS itemFk, i.size,
i.size, i.weightByPiece,
i.weightByPiece, it.code,
it.code, i.typeFk,
i.typeFk, i.family,
i.family, i.isActive,
i.isActive, i.minPrice,
i.minPrice, i.description,
i.description, i.name,
i.name, i.subName,
i.subName, i.packingOut,
i.packingOut, i.tag5,
i.tag5, i.value5,
i.value5, i.tag6,
i.tag6, i.value6,
i.value6, i.tag7,
i.tag7, i.value7,
i.value7, i.tag8,
i.tag8, i.value8,
i.value8, i.tag9,
i.tag9, i.value9,
i.value9, i.tag10,
i.tag10, i.value10,
i.value10, t.name AS type,
t.name AS type, intr.description AS intrastat,
intr.description AS intrastat, ori.code AS origin,
ori.code AS origin, b.entryFk,
b.entryFk, b.id,
b.id, b.quantity,
b.quantity, b.buyingValue,
b.buyingValue, b.freightValue,
b.freightValue, b.isIgnored,
b.isIgnored, b.packing,
b.packing, b.grouping,
b.grouping, b.groupingMode,
b.groupingMode, b.comissionValue,
b.comissionValue, b.packageValue,
b.packageValue, b.price2,
b.price2, b.price3,
b.price3, b.ektFk,
b.ektFk, b.weight,
b.weight, b.packagingFk,
b.packageFk, lb.landing
lb.landing FROM cache.last_buy lb
FROM cache.last_buy lb LEFT JOIN cache.visible v ON v.item_id = lb.item_id
LEFT JOIN cache.visible v ON v.item_id = lb.item_id AND v.calc_id = @calc_id
AND v.calc_id = @calc_id JOIN item i ON i.id = lb.item_id
JOIN item i ON i.id = lb.item_id JOIN itemType it ON it.id = i.typeFk AND lb.warehouse_id = ?
JOIN itemType it ON it.id = i.typeFk AND lb.warehouse_id = ? JOIN buy b ON b.id = lb.buy_id
JOIN buy b ON b.id = lb.buy_id LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN itemType t ON t.id = i.typeFk
LEFT JOIN itemType t ON t.id = i.typeFk LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk LEFT JOIN origin ori ON ori.id = i.originFk
LEFT JOIN origin ori ON ori.id = i.originFk LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR)
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR) LEFT JOIN supplier s ON s.id = e.supplierFk`
LEFT JOIN supplier s ON s.id = e.supplierFk`
, [userConfig.warehouseFk, date]); , [userConfig.warehouseFk, date]);
if (ctx.args.tags) { if (ctx.args.tags) {

View File

@ -33,7 +33,7 @@ describe('entry import()', () => {
packing: 1, packing: 1,
size: 1, size: 1,
volume: 1200, volume: 1200,
packageFk: '94' packagingFk: '94'
}, },
{ {
itemFk: 4, itemFk: 4,
@ -43,7 +43,7 @@ describe('entry import()', () => {
packing: 1, packing: 1,
size: 25, size: 25,
volume: 1125, volume: 1125,
packageFk: '94' packagingFk: '94'
} }
] ]
} }

View File

@ -10,12 +10,12 @@ describe('entry importBuysPreview()', () => {
}); });
}); });
it('should return the buys with the calculated packageFk', async() => { it('should return the buys with the calculated packagingFk', async() => {
const tx = await models.Entry.beginTransaction({}); const tx = await models.Entry.beginTransaction({});
const options = {transaction: tx}; const options = {transaction: tx};
try { try {
const expectedPackageFk = '3'; const expectedPackagingFk = '3';
const buys = [ const buys = [
{ {
itemFk: 1, itemFk: 1,
@ -39,7 +39,7 @@ describe('entry importBuysPreview()', () => {
const randomIndex = Math.floor(Math.random() * result.length); const randomIndex = Math.floor(Math.random() * result.length);
const buy = result[randomIndex]; const buy = result[randomIndex];
expect(buy.packageFk).toEqual(expectedPackageFk); expect(buy.packagingFk).toEqual(expectedPackagingFk);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -103,7 +103,7 @@
"package": { "package": {
"type": "belongsTo", "type": "belongsTo",
"model": "Packaging", "model": "Packaging",
"foreignKey": "packageFk" "foreignKey": "packagingFk"
}, },
"worker": { "worker": {
"type": "belongsTo", "type": "belongsTo",

View File

@ -83,14 +83,14 @@
<td center>{{::buy.packing | dashIfEmpty}}</td> <td center>{{::buy.packing | dashIfEmpty}}</td>
<td center>{{::buy.grouping | dashIfEmpty}}</td> <td center>{{::buy.grouping | dashIfEmpty}}</td>
<td>{{::buy.buyingValue | currency: 'EUR':2}}</td> <td>{{::buy.buyingValue | currency: 'EUR':2}}</td>
<td center title="{{::buy.packageFk | dashIfEmpty}}"> <td center title="{{::buy.packagingFk | dashIfEmpty}}">
<vn-autocomplete <vn-autocomplete
vn-one vn-one
url="Packagings" url="Packagings"
show-field="id" show-field="id"
value-field="id" value-field="id"
where="{isBox: true}" where="{isBox: true}"
ng-model="buy.packageFk"> ng-model="buy.packagingFk">
</vn-autocomplete> </vn-autocomplete>
</td> </td>
</tr> </tr>

View File

@ -88,12 +88,12 @@
<td center> <td center>
<vn-autocomplete <vn-autocomplete
vn-one vn-one
title="{{::buy.packageFk | dashIfEmpty}}" title="{{::buy.packagingFk | dashIfEmpty}}"
url="Packagings" url="Packagings"
show-field="id" show-field="id"
value-field="id" value-field="id"
where="{freightItemFk: true}" where="{freightItemFk: true}"
ng-model="buy.packageFk" ng-model="buy.packagingFk"
on-change="$ctrl.saveBuy(buy)"> on-change="$ctrl.saveBuy(buy)">
</vn-autocomplete> </vn-autocomplete>
</td> </td>

View File

@ -4,7 +4,7 @@ import Section from 'salix/components/section';
export default class Controller extends Section { export default class Controller extends Section {
saveBuy(buy) { saveBuy(buy) {
const missingData = !buy.itemFk || !buy.quantity || !buy.packageFk; const missingData = !buy.itemFk || !buy.quantity || !buy.packagingFk;
if (missingData) return; if (missingData) return;
let options; let options;

View File

@ -17,7 +17,7 @@ describe('Entry buy', () => {
describe('saveBuy()', () => { describe('saveBuy()', () => {
it(`should call the buys patch route if the received buy has an ID`, () => { it(`should call the buys patch route if the received buy has an ID`, () => {
const buy = {id: 1, itemFk: 1, quantity: 1, packageFk: 1}; const buy = {id: 1, itemFk: 1, quantity: 1, packagingFk: 1};
const query = `Buys/${buy.id}`; const query = `Buys/${buy.id}`;

View File

@ -104,7 +104,7 @@
<th field="weight"> <th field="weight">
<span translate>Weight</span> <span translate>Weight</span>
</th> </th>
<th field="packageFk"> <th field="packagingFk">
<span translate>Package</span> <span translate>Package</span>
</th> </th>
<th field="packingOut"> <th field="packingOut">
@ -207,7 +207,7 @@
<td number>{{::buy.minPrice | currency: 'EUR':3}}</td> <td number>{{::buy.minPrice | currency: 'EUR':3}}</td>
<td>{{::buy.ektFk | dashIfEmpty}}</td> <td>{{::buy.ektFk | dashIfEmpty}}</td>
<td>{{::buy.weight}}</td> <td>{{::buy.weight}}</td>
<td>{{::buy.packageFk}}</td> <td>{{::buy.packagingFk}}</td>
<td>{{::buy.packingOut}}</td> <td>{{::buy.packingOut}}</td>
<td>{{::buy.landing | date: 'dd/MM/yyyy'}}</td> <td>{{::buy.landing | date: 'dd/MM/yyyy'}}</td>
</tr> </tr>

View File

@ -48,7 +48,7 @@ export default class Controller extends Section {
} }
}, },
{ {
field: 'packageFk', field: 'packagingFk',
autocomplete: { autocomplete: {
url: 'Packagings', url: 'Packagings',
showField: 'id' showField: 'id'
@ -133,7 +133,7 @@ export default class Controller extends Section {
case 'price3': case 'price3':
case 'ektFk': case 'ektFk':
case 'weight': case 'weight':
case 'packageFk': case 'packagingFk':
return {[`b.${param}`]: value}; return {[`b.${param}`]: value};
} }
} }

View File

@ -105,7 +105,7 @@
<tr> <tr>
<th translate center field="quantity">Quantity</th> <th translate center field="quantity">Quantity</th>
<th translate center field="sticker">Stickers</th> <th translate center field="sticker">Stickers</th>
<th translate center field="packageFk">Package</th> <th translate center field="packagingFk">Package</th>
<th translate center field="weight">Weight</th> <th translate center field="weight">Weight</th>
<th translate center field="packing">Packing</th> <th translate center field="packing">Packing</th>
<th translate center field="grouping">Grouping</th> <th translate center field="grouping">Grouping</th>
@ -118,7 +118,7 @@
<tr> <tr>
<td center title="{{::line.quantity}}">{{::line.quantity}}</td> <td center title="{{::line.quantity}}">{{::line.quantity}}</td>
<td center title="{{::line.stickers | dashIfEmpty}}">{{::line.stickers | dashIfEmpty}}</td> <td center title="{{::line.stickers | dashIfEmpty}}">{{::line.stickers | dashIfEmpty}}</td>
<td center title="{{::line.packageFk | dashIfEmpty}}">{{::line.packageFk | dashIfEmpty}}</td> <td center title="{{::line.packagingFk | dashIfEmpty}}">{{::line.packagingFk | dashIfEmpty}}</td>
<td center title="{{::line.weight}}">{{::line.weight}}</td> <td center title="{{::line.weight}}">{{::line.weight}}</td>
<td center> <td center>
<vn-chip class="transparent" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}"> <vn-chip class="transparent" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}">

View File

@ -29,44 +29,44 @@ module.exports = Self => {
Object.assign(myOptions, options); Object.assign(myOptions, options);
const stmt = new ParameterizedSQL( const stmt = new ParameterizedSQL(
`SELECT `SELECT w.id AS warehouseFk,
w.id AS warehouseFk, w.name AS warehouse,
w.name AS warehouse, tr.landed,
tr.landed, b.id AS buyFk,
b.id AS buyFk, b.entryFk,
b.entryFk, b.isIgnored,
b.isIgnored, b.price2,
b.price2, b.price3,
b.price3, b.stickers,
b.stickers, b.packing,
b.packing, b.grouping,
b.grouping, b.groupingMode,
b.groupingMode, b.weight,
b.weight, i.stems,
i.stems, b.quantity,
b.quantity, b.buyingValue +
b.buyingValue + b.freightValue +
b.freightValue + b.comissionValue +
b.comissionValue + b.packageValue AS cost,
b.packageValue AS cost, b.buyingValue,
b.buyingValue, b.freightValue,
b.freightValue, b.comissionValue,
b.comissionValue, b.packageValue,
b.packageValue, b.packagingFk ,
b.packageFk , s.id AS supplierFk,
s.id AS supplierFk, s.name AS supplier
s.name AS supplier FROM itemType it
FROM itemType it RIGHT JOIN (entry e
RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk
LEFT JOIN supplier s ON s.id = e.supplierFk RIGHT JOIN buy b ON b.entryFk = e.id
RIGHT JOIN buy b ON b.entryFk = e.id LEFT JOIN item i ON i.id = b.itemFk
LEFT JOIN item i ON i.id = b.itemFk LEFT JOIN ink ON ink.id = i.inkFk
LEFT JOIN ink ON ink.id = i.inkFk LEFT JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN travel tr ON tr.id = e.travelFk LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
LEFT JOIN warehouse w ON w.id = tr.warehouseInFk LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk
) ON it.id = i.typeFk LEFT JOIN edi.ekt ek ON b.ektFk = ek.id`
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id`); );
stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeSuffix(filter));
return conn.executeStmt(stmt, myOptions); return conn.executeStmt(stmt, myOptions);

View File

@ -45,7 +45,7 @@
<vn-th field="quantity" number>Quantity</vn-th> <vn-th field="quantity" number>Quantity</vn-th>
<vn-th number class="expendable">Cost</vn-th> <vn-th number class="expendable">Cost</vn-th>
<vn-th number>Kg.</vn-th> <vn-th number>Kg.</vn-th>
<vn-th field="packageFk" number>Cube</vn-th> <vn-th field="packagingFk" number>Cube</vn-th>
<vn-th field="supplierFk" class="expendable">Provider</vn-th> <vn-th field="supplierFk" class="expendable">Provider</vn-th>
</vn-tr> </vn-tr>
</vn-thead> </vn-thead>
@ -94,7 +94,7 @@
</span> </span>
</vn-td> </vn-td>
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td> <vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
<vn-td number>{{::entry.packageFk | dashIfEmpty}}</vn-td> <vn-td number>{{::entry.packagingFk | dashIfEmpty}}</vn-td>
<vn-td class="expendable" title="{{::entry.supplier | dashIfEmpty}}">{{::entry.supplier | dashIfEmpty}}</vn-td> <vn-td class="expendable" title="{{::entry.supplier | dashIfEmpty}}">{{::entry.supplier | dashIfEmpty}}</vn-td>
</vn-tr> </vn-tr>
</vn-tbody> </vn-tbody>

View File

@ -71,7 +71,7 @@ class Controller extends Section {
switch (param) { switch (param) {
case 'id': case 'id':
case 'quantity': case 'quantity':
case 'packageFk': case 'packagingFk':
return {[`b.${param}`]: value}; return {[`b.${param}`]: value};
case 'supplierFk': case 'supplierFk':
return {[`s.id`]: value}; return {[`s.id`]: value};

View File

@ -132,12 +132,18 @@ module.exports = Self => {
s.nickname AS cargoSupplierNickname, s.nickname AS cargoSupplierNickname,
s.name AS supplierName, s.name AS supplierName,
CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg, CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg,
CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) as DECIMAL(10,0)) as volumeKg CAST(
SUM(
vc.aerealVolumetricDensity *
b.stickers *
IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000
) as DECIMAL(10,0)
) as volumeKg
FROM travel t FROM travel t
LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN supplier s ON s.id = t.cargoSupplierFk
LEFT JOIN entry e ON e.travelFk = t.id LEFT JOIN entry e ON e.travelFk = t.id
LEFT JOIN buy b ON b.entryFk = e.id LEFT JOIN buy b ON b.entryFk = e.id
LEFT JOIN packaging pkg ON pkg.id = b.packageFk LEFT JOIN packaging pkg ON pkg.id = b.packagingFk
LEFT JOIN item i ON i.id = b.itemFk LEFT JOIN item i ON i.id = b.itemFk
LEFT JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemType it ON it.id = i.typeFk
JOIN warehouse w ON w.id = t.warehouseInFk JOIN warehouse w ON w.id = t.warehouseInFk
@ -169,11 +175,17 @@ module.exports = Self => {
e.evaNotes, e.evaNotes,
e.invoiceAmount, e.invoiceAmount,
CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) as loadedkg, CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) as loadedkg,
CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) AS DECIMAL(10,0)) as volumeKg CAST(
SUM(
vc.aerealVolumetricDensity *
b.stickers *
IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000
) AS DECIMAL(10,0)
) as volumeKg
FROM tmp.travel tr FROM tmp.travel tr
JOIN entry e ON e.travelFk = tr.id JOIN entry e ON e.travelFk = tr.id
JOIN buy b ON b.entryFk = e.id JOIN buy b ON b.entryFk = e.id
JOIN packaging pkg ON pkg.id = b.packageFk JOIN packaging pkg ON pkg.id = b.packagingFk
JOIN item i ON i.id = b.itemFk JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk JOIN itemType it ON it.id = i.typeFk
JOIN supplier s ON s.id = e.supplierFk JOIN supplier s ON s.id = e.supplierFk

View File

@ -47,7 +47,7 @@ module.exports = Self => {
LEFT JOIN vn.buy b ON b.entryFk = e.id LEFT JOIN vn.buy b ON b.entryFk = e.id
LEFT JOIN vn.supplier s ON e.supplierFk = s.id LEFT JOIN vn.supplier s ON e.supplierFk = s.id
JOIN vn.item i ON i.id = b.itemFk JOIN vn.item i ON i.id = b.itemFk
LEFT JOIN vn.packaging p ON p.id = b.packageFk LEFT JOIN vn.packaging p ON p.id = b.packagingFk
JOIN vn.packaging pcc ON pcc.id = 'cc' JOIN vn.packaging pcc ON pcc.id = 'cc'
JOIN vn.packaging ppallet ON ppallet.id = 'pallet 100' JOIN vn.packaging ppallet ON ppallet.id = 'pallet 100'
JOIN vn.packagingConfig pconfig JOIN vn.packagingConfig pconfig