Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4774-translationsVn
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2024-11-11 07:15:22 +01:00
commit 0437756256
144 changed files with 1657 additions and 1254 deletions

View File

@ -1,132 +0,0 @@
const {models} = require('vn-loopback/server/server');
describe('machineWorker updateInTime()', () => {
const itBoss = 104;
const davidCharles = 1106;
beforeAll(async() => {
ctx = {
req: {
accessToken: {},
headers: {origin: 'http://localhost'},
__: value => value
}
};
});
it('should throw an error if the plate does not exist', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
const plate = 'RE-123';
ctx.req.accessToken.userId = 1106;
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toContain('the plate does not exist');
await tx.rollback();
}
});
it('should grab a machine where is not in use', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
const plate = 'RE-003';
ctx.req.accessToken.userId = 1107;
try {
const totalBefore = await models.MachineWorker.find(null, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const totalAfter = await models.MachineWorker.find(null, options);
expect(totalAfter.length).toEqual(totalBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
describe('less than 12h', () => {
const plate = 'RE-001';
it('should trow an error if it is not himself', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = davidCharles;
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toContain('This machine is already in use');
await tx.rollback();
}
});
it('should throw an error if it is himself with a different machine', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = itBoss;
const plate = 'RE-003';
try {
await models.MachineWorker.updateInTime(ctx, plate, options);
await tx.rollback();
} catch (e) {
const error = e;
expect(error.message).toEqual('You are already using a machine');
await tx.rollback();
}
});
it('should set the out time if it is himself', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = itBoss;
try {
const isNotParked = await models.MachineWorker.findOne({
where: {workerFk: itBoss}
}, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const isParked = await models.MachineWorker.findOne({
where: {workerFk: itBoss}
}, options);
expect(isNotParked.outTime).toBeNull();
expect(isParked.outTime).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});
describe('equal or more than 12h', () => {
const plate = 'RE-002';
it('should set the out time and grab the machine', async() => {
const tx = await models.MachineWorker.beginTransaction({});
const options = {transaction: tx};
ctx.req.accessToken.userId = davidCharles;
const filter = {
where: {workerFk: davidCharles, machineFk: 2}
};
try {
const isNotParked = await models.MachineWorker.findOne(filter, options);
const totalBefore = await models.MachineWorker.find(null, options);
await models.MachineWorker.updateInTime(ctx, plate, options);
const isParked = await models.MachineWorker.findOne(filter, options);
const totalAfter = await models.MachineWorker.find(null, options);
expect(isNotParked.outTime).toBeNull();
expect(isParked.outTime).toBeDefined();
expect(totalAfter.length).toEqual(totalBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});
});

View File

@ -1,77 +0,0 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('updateInTime', {
description: 'Updates the corresponding registry if the worker has been registered in the last few hours',
accessType: 'WRITE',
accepts: [
{
arg: 'plate',
type: 'string',
}
],
http: {
path: `/updateInTime`,
verb: 'POST'
}
});
Self.updateInTime = async(ctx, plate, options) => {
const models = Self.app.models;
const userId = ctx.req.accessToken.userId;
const $t = ctx.req.__;
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const machine = await models.Machine.findOne({
fields: ['id', 'plate'],
where: {plate}
}, myOptions);
if (!machine)
throw new UserError($t('the plate does not exist', {plate}));
const machineWorker = await Self.findOne({
where: {
or: [{machineFk: machine.id}, {workerFk: userId}],
outTime: null,
}
}, myOptions);
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
const hoursDifference = (Date.vnNow() - machineWorker?.inTime?.getTime() ?? 0) / (60 * 60 * 1000);
if (machineWorker) {
const isHimself = userId == machineWorker.workerFk;
const isSameMachine = machine.id == machineWorker.machineFk;
if (hoursDifference < maxHours && !isHimself)
throw new UserError($t('This machine is already in use.'));
if (hoursDifference < maxHours && isHimself && !isSameMachine)
throw new UserError($t('You are already using a machine'));
await machineWorker.updateAttributes({
outTime: Date.vnNew()
}, myOptions);
}
if (!machineWorker || hoursDifference >= maxHours)
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -88,12 +88,6 @@
"Machine": {
"dataSource": "vn"
},
"MachineWorker": {
"dataSource": "vn"
},
"MachineWorkerConfig": {
"dataSource": "vn"
},
"MobileAppVersionControl": {
"dataSource": "vn"
},

View File

@ -1,18 +0,0 @@
{
"name": "MachineWorkerConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.machineWorkerConfig"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"maxHours": {
"type": "number"
}
}
}

View File

@ -1,3 +0,0 @@
module.exports = Self => {
require('../methods/machine-worker/updateInTime')(Self);
};

View File

@ -1,33 +0,0 @@
{
"name": "MachineWorker",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.machineWorker"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"workerFk": {
"type": "number"
},
"machineFk": {
"type": "number"
},
"inTime": {
"type": "date",
"mysql": {
"columnName": "inTimed"
}
},
"outTime": {
"type": "date",
"mysql": {
"columnName": "outTimed"
}
}
}
}

View File

@ -1723,7 +1723,6 @@ INSERT INTO `ACL` VALUES (378,'OsTicket','osTicketReportEmail','WRITE','ALLOW','
INSERT INTO `ACL` VALUES (379,'Item','buyerWasteEmail','WRITE','ALLOW','ROLE','system',NULL);
INSERT INTO `ACL` VALUES (380,'Claim','claimPickupPdf','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (381,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','claimManager',NULL);
INSERT INTO `ACL` VALUES (382,'Item','labelPdf','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (383,'Sector','*','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (384,'Sector','*','WRITE','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee',NULL);

View File

@ -404,7 +404,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses');
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), UPPER(CONCAT(name, 'Street')), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1
FROM `account`.`role` `r`
WHERE `r`.`hasLogin` = 1;
@ -1505,32 +1505,32 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`)
VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1),
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2),
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3),
(4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4),
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5),
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6),
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7),
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10),
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10),
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4),
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4);
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `daysInForward`)
VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, NULL),
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, NULL),
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, NULL),
(4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, NULL),
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, NULL),
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, NULL),
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, 2),
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, NULL),
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, 2),
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL),
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL);
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`)
VALUES
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, 0, ''),
(2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 0, 'observation two'),
(3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 0, 'observation three'),
(4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 0, 'observation four'),
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'),
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'),
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'),
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''),
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, ''),
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, '');
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, ''),
(2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 'observation two'),
(3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 'observation three'),
(4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 'observation four'),
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 'observation five'),
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 'observation six'),
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven'),
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1,''),
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, ''),
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, ''),
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, '');
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
VALUES (2, 4, 1);
@ -2454,7 +2454,7 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `
INSERT INTO `vn`.`dmsType`
(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
VALUES
(1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'),
(1, 'Facturas Recibidas', 1, 1, 'invoiceIn'),
(2, 'Doc oficial', NULL, NULL, 'officialDoc'),
(3, 'Laboral', 37, 37, 'hhrrData'),
(4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote'),
@ -2842,12 +2842,6 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen
('RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442),
('RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442);
INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`)
VALUES
(1106, 1, util.VN_CURDATE(), util.VN_CURDATE()),
(1106, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)),
(1106, 2, util.VN_CURDATE(), NULL),
(1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY));
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
VALUES
@ -3831,8 +3825,6 @@ UPDATE vn.collection
UPDATE vn.sale
SET isPicked =FALSE;
INSERT INTO vn.machineWorkerConfig(id, maxHours)
VALUES(1, 12);
INSERT INTO vn.workerAppTester(workerFk) VALUES(66);
@ -3840,9 +3832,6 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen
VALUES
('RE-003', 'IRON', 'JPH-24', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442);
INSERT INTO vn.machineWorker(workerFk,machineFk,inTimed) VALUES (104,1,'2001-01-01 10:00:00.00.000');
UPDATE vn.buy SET itemOriginalFk = 1 WHERE id = 1;
UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5;

View File

@ -53,7 +53,7 @@ proc: BEGIN
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
AND t.warehouseInFk = vWarehouse
AND s.name != 'INVENTARIO'
AND NOT e.isRaid
AND NOT t.daysInForward
GROUP BY b.itemFk
) c
JOIN vn.item i ON i.id = c.itemFk

View File

@ -14,7 +14,7 @@ BEGIN
b.stickers = NEW.NumberOfUnits
WHERE i.supplyResponseFk = NEW.ID
AND am.name = 'LOGIFLORA'
AND e.isRaid
AND tr.daysInForward
AND tr.landed >= util.VN_CURDATE();
END$$

View File

@ -59,7 +59,7 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.landed BETWEEN vDateInv AND vDate
AND t.warehouseInFk = vWarehouse
AND NOT e.isRaid
AND NOT t.daysInForward
UNION ALL
SELECT b.itemFk, -b.quantity
FROM vn.buy b
@ -67,7 +67,7 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseOutFk = vWarehouse
AND NOT e.isRaid
AND NOT t.daysInForward
AND t.isDelivered
UNION ALL
SELECT m.itemFk, -m.quantity

View File

@ -4,5 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeInsert`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
IF NEW.`property` = '*' THEN
CALL util.throw('The property field cannot be *');
END IF;
END$$
DELIMITER ;

View File

@ -11,7 +11,7 @@ BEGIN
e.id entryFk,
t.id travelFk,
b.itemFk,
e.isRaid,
t.daysInForward,
ADDTIME(t.shipped,
IFNULL(t.shipmentHour, '00:00:00')) shipped,
t.warehouseOutFk,
@ -50,7 +50,7 @@ BEGIN
itemFk,
TIMESTAMPADD(DAY, life, @dated),
quantity,
IF(isIn, isReceived, isDelivered) AND !isRaid
IF(isIn, isReceived, isDelivered) AND NOT daysInForward
FROM tValues
WHERE isIn OR !lessThanInventory;
@ -65,7 +65,7 @@ BEGIN
itemFk,
created,
quantity,
IF(isIn, isDelivered, isReceived) AND !isRaid
IF(isIn, isDelivered, isReceived) AND NOT daysInForward
FROM tValues
WHERE !isIn OR !lessThanInventory;

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaig_add`
ON SCHEDULE EVERY 1 DAY
STARTS '2024-10-18 03:00:00.000'
ON COMPLETION PRESERVE
ENABLE
DO CALL itemCampaign_add()$$
DELIMITER ;

View File

@ -1,8 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`raidUpdate`
ON SCHEDULE EVERY 1 DAY
STARTS '2017-12-29 00:05:00.000'
ON COMPLETION PRESERVE
ENABLE
DO CALL raidUpdate$$
DELIMITER ;

View File

@ -0,0 +1,31 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`(
vItemFk INT,
vWarehouseFk INT,
vDated DATE
)
RETURNS int(11)
DETERMINISTIC
BEGIN
/**
* Calcula las últimas compras realizadas hasta una fecha.
*
* @param vItemFk Id del artículo
* @param vWarehouseFk Id del almacén
* @param vDated Compras hasta fecha
* @return Id de compra
*/
DECLARE vBuyFk INT;
CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated);
SELECT buyFk INTO vBuyFk
FROM tmp.buyUltimate;
DROP TEMPORARY TABLE IF EXISTS
tmp.buyUltimate,
tmp.buyUltimateFromInterval;
RETURN vBuyFk;
END$$
DELIMITER ;

View File

@ -1,23 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`workerMachinery_isRegistered`(vWorkerFk VARCHAR(10))
RETURNS tinyint(1)
NOT DETERMINISTIC
READS SQL DATA
BEGIN
/**
* Comprueba si existen registros en las últimas horas (maxHours de machineWorkerConfig) del trabajador vWorkerFk y si tiene a nulo la hora outTimed (indica la hora que deja el vehículo)
*
* @param vWorkerFk id del trabajador
* @return Devuelve TRUE/FALSE en caso de que haya o no registros
*/
IF (SELECT COUNT(*)
FROM machineWorker m
WHERE m.workerFk = vWorkerFk
AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), util.VN_NOW()) AND ISNULL(m.outTimed))
THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END$$
DELIMITER ;

View File

@ -39,7 +39,7 @@ BEGIN
AND vWarehouseFk IN (tr.warehouseInFk, 0)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND NOT tr.daysInForward
UNION ALL
SELECT tr.shipped,
NULL,
@ -58,7 +58,7 @@ BEGIN
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND NOT tr.daysInForward
UNION ALL
SELECT t.shipped,
NULL,

View File

@ -42,7 +42,7 @@ proc: BEGIN
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
AND t.warehouseInFk = vWarehouseLanding
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND NOT t.daysInForward
GROUP BY c.itemFk;
-- Tabla con el ultimo dia de last_buy para cada producto
@ -57,7 +57,7 @@ proc: BEGIN
JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
WHERE t.warehouseFk = vWarehouseShipment
AND NOT e.isRaid
AND NOT tr.daysInForward
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
tr.landed);
@ -94,7 +94,7 @@ proc: BEGIN
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
WHERE NOT e.isExcludedFromAvailable
AND b.quantity <> 0
AND NOT e.isRaid
AND NOT t.daysInForward
AND t.warehouseInFk = vWarehouseLanding
AND t.landed >= vDatedFrom
AND (ir.dated IS NULL OR t.landed <= ir.dated)

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
vItemFk INT,
vWarehouseFk SMALLINT,
vWarehouseFk INT,
vDated DATE
)
BEGIN

View File

@ -28,7 +28,7 @@ BEGIN
JOIN agencyMode am ON am.id = tr.agencyModeFk
WHERE NOT b.quantity
AND am.code = 'logiflora'
AND e.isRaid;
AND tr.daysInForward;
START TRANSACTION;

View File

@ -30,7 +30,9 @@ BEGIN
t.warehouseFk,
w.id salesPersonFk,
IFNULL(ob.description,'') observaciones,
cc.rgb
cc.rgb,
p.code parkingCode,
IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.ticket t
LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
@ -43,6 +45,9 @@ BEGIN
LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
LEFT JOIN observation ob ON ob.ticketFk = t.id
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
LEFT JOIN vn.parking p ON tp.parkingFk = p.id
LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE t.id = vParamFk
AND t.shipped >= vYesterday
UNION
@ -52,7 +57,9 @@ BEGIN
t.warehouseFk,
w.id salesPersonFk,
ob.description,
IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`
IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`,
p.code parkingCode,
IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.ticket t
JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
@ -65,6 +72,9 @@ BEGIN
LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
LEFT JOIN observation ob ON ob.ticketFk = t.id
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
LEFT JOIN vn.parking p ON tp.parkingFk = p.id
LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE tc.collectionFk = vParamFk
UNION
SELECT sg.ticketFk,
@ -73,7 +83,9 @@ BEGIN
t.warehouseFk,
c.salesPersonFk,
ob.description,
NULL `rgb`
NULL `rgb`,
p.code parkingCode,
IF (ps.ticketFk, TRUE, FALSE) isAdvanced
FROM vn.sectorCollection sc
JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk
@ -82,6 +94,9 @@ BEGIN
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN observation ob ON ob.ticketFk = t.id
LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
LEFT JOIN vn.parking p ON tp.parkingFk = p.id
LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id
WHERE sc.id = vParamFk
AND t.shipped >= vYesterday
GROUP BY ticketFk;

View File

@ -17,7 +17,6 @@ BEGIN
supplierFk,
dated,
isExcludedFromAvailable,
isRaid,
commission,
currencyFk,
companyFk,
@ -28,7 +27,6 @@ BEGIN
supplierFk,
dated,
isExcludedFromAvailable,
isRaid,
commission,
currencyFk,
companyFk,

View File

@ -166,7 +166,7 @@ BEGIN
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
WHERE ic.display
AND NOT e.isRaid
AND NOT tr.daysInForward
AND (ti.visible OR ti.available)
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;

View File

@ -16,7 +16,8 @@ BEGIN
a.nickname,
sub2.itemPackingTypeConcat,
est.code,
es.isScanned
es2.isScanned,
es2.scanOrder
FROM expedition e
JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = e.ticketFk
@ -38,6 +39,7 @@ BEGIN
SELECT MAX(id)
FROM expeditionState es
WHERE expeditionFk = e.id)
LEFT JOIN expeditionState es2 ON es2.id = es.id
WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE
ORDER BY r.created, t.priority DESC;
END$$

View File

@ -137,7 +137,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseInFk = vWarehouseFk
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
AND NOT isRaid
AND NOT tr.daysInForward
GROUP BY b.itemFk;
-- Transfers
@ -150,7 +150,7 @@ BEGIN
JOIN travel tr ON tr.id = e.travelFk
WHERE tr.warehouseOutFk = vWarehouseFk
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
AND NOT isRaid
AND NOT tr.daysInForward
GROUP BY b.itemFk
) sub
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;

View File

@ -0,0 +1,54 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemCampaign_add`()
proc: BEGIN
/**
* Añade registros a tabla itemCampaign.
*
* @param vDateFrom Fecha desde
* @param vDateTo Fecha hasta
* @param vCampaign Código de la campaña
*/
DECLARE vYesterday DATE;
DECLARE vCampaign VARCHAR(100);
DECLARE vScopeDays INT;
DECLARE vPreviousDays INT;
DECLARE vDateSumFrom DATE;
DECLARE vDateSumTo DATE;
SET vYesterday = util.yesterday();
SELECT dated, code, scopeDays, previousDays
INTO vDateSumTo, vCampaign, vScopeDays, vPreviousDays
FROM campaign
WHERE dated >= vYesterday
ORDER BY dated
LIMIT 1;
IF vCampaign IS NULL THEN
CALL util.throw('Missing data in campaign table');
END IF;
IF NOT vYesterday BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY
AND vDateSumTo THEN
LEAVE proc;
END IF;
SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY;
SET vDateSumTo = vDateSumTo - INTERVAL 1 DAY;
INSERT INTO itemCampaign(dated, itemFk, quantity, total, campaign)
SELECT vYesterday,
s.itemFk,
SUM(s.quantity) quantity,
SUM((s.quantity * s.price) * (100 - s.discount) / 100) total,
vCampaign
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN client c ON c.id = t.clientFk
WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo)
AND c.typeFk = 'normal'
AND NOT t.isDeleted
GROUP BY s.itemFk
HAVING quantity;
END$$
DELIMITER ;

View File

@ -20,6 +20,7 @@ proc: BEGIN
DECLARE vUserFk INT;
DECLARE vTotalReservedQuantity INT;
DECLARE vSaleQuantity INT;
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
DECLARE vItemShelvingAvailable CURSOR FOR
SELECT ish.id itemShelvingFk,
@ -44,11 +45,11 @@ proc: BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL;
END;
START TRANSACTION;
CALL util.tx_start(vIsRequiredTx);
SELECT id INTO vSaleFk
FROM sale
@ -65,7 +66,7 @@ proc: BEGIN
WHERE s.id = vSaleFk;
IF vOutStanding <= 0 THEN
COMMIT;
CALL util.tx_commit(vIsRequiredTx);
LEAVE proc;
END IF;
@ -93,7 +94,7 @@ proc: BEGIN
LEAVE l;
END IF;
SELECT id INTO vItemShelvingFk
SELECT id INTO vItemShelvingFk
FROM itemShelving
WHERE id = vItemShelvingFk
FOR UPDATE;
@ -102,19 +103,19 @@ proc: BEGIN
SET vOutStanding = vOutStanding - vReservedQuantity;
IF vReservedQuantity > 0 THEN
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
INSERT INTO itemShelvingSale(
itemShelvingFk,
saleFk,
quantity,
userFk,
isPicked)
SELECT vItemShelvingFk,
vSaleFk,
vReservedQuantity,
vUserFk,
FALSE;
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
INSERT INTO itemShelvingSale(
itemShelvingFk,
saleFk,
quantity,
userFk,
isPicked)
SELECT vItemShelvingFk,
vSaleFk,
vReservedQuantity,
vUserFk,
FALSE;
UPDATE itemShelving
SET available = available - vReservedQuantity
@ -123,6 +124,6 @@ proc: BEGIN
END IF;
END LOOP;
CLOSE vItemShelvingAvailable;
COMMIT;
CALL util.tx_commit(vIsRequiredTx);
END$$
DELIMITER ;

View File

@ -7,9 +7,10 @@ BEGIN
* @param vSelf matrícula del carro
**/
SELECT ish.itemFk item,
IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) description,
i.name,
i.longName,
i.size,
ish.visible,
CEIL(ish.visible/ish.packing) stickers,
ish.packing,
ish.grouping,
p.code,
@ -17,7 +18,8 @@ BEGIN
s.priority,
ish.isChecked,
ic.url,
ish.available
ish.available,
ish.buyFk
FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci

View File

@ -59,7 +59,7 @@ BEGIN
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND NOT tr.daysInForward
),
entriesOut AS (
SELECT 'entry',
@ -95,7 +95,7 @@ BEGIN
AND b.itemFk = vItemFk
AND NOT e.isExcludedFromAvailable
AND NOT w.isFeedStock
AND NOT e.isRaid
AND NOT tr.daysInForward
),
sales AS (
WITH itemSales AS (

View File

@ -63,7 +63,7 @@ BEGIN
AND NOT e.isExcludedFromAvailable
AND b.quantity <> 0
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
AND NOT e.isRaid
AND NOT t.daysInForward
UNION ALL
SELECT r.itemFk,
r.shipment,

View File

@ -30,7 +30,7 @@ BEGIN
AND NOT s.name = 'INVENTARIO'
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND w.isComparative
AND NOT e.isRaid
AND NOT t.daysInForward
GROUP BY i.id;
UPDATE tmp.itemInventory y

View File

@ -109,7 +109,7 @@ BEGIN
JOIN warehouse w ON w.id = tr.warehouseInFk
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
AND NOT e.isRaid
AND NOT tr.daysInForward
AND w.valuatedInventory
AND t.isInventory
AND e.supplierFk <> vInventorySupplierFk
@ -131,7 +131,7 @@ BEGIN
JOIN itemCategory ic ON ic.id = t.categoryFk
JOIN warehouse w ON w.id = tr.warehouseOutFk
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
AND NOT e.isRaid
AND NOT tr.daysInForward
AND w.valuatedInventory
AND t.isInventory
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
@ -196,7 +196,7 @@ BEGIN
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
WHERE vDated >= tr.shipped AND vDated < tr.landed
AND NOT isRaid
AND NOT tr.daysInForward
AND wIn.valuatedInventory
AND t.isInventory
AND e.isConfirmed

View File

@ -1,22 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT)
BEGIN
/**
* Inserta registro si el vWorkerFk no ha registrado nada en las últimas 12 horas
* @param vPlate número de matrícula
* @param vWorkerFk id del worker
*
*/
UPDATE vn.machineWorker mw
JOIN vn.machine m ON m.id = mw.machineFk
SET mw.outTimed = util.VN_NOW()
WHERE (mw.workerFk = vWorkerFk OR m.plate = vPlate)
AND ISNULL(mw.outTimed);
INSERT INTO machineWorker (machineFk, workerFk)
SELECT m.id, vWorkerFk
FROM machine m
WHERE m.plate= vPlate;
END$$
DELIMITER ;

View File

@ -1,21 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT)
BEGIN
/**
* Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea,
* si es jefe de producción muestra el historial completo.
*
* @param vPlate número de matrícula
* @param vWorkerFk id del trabajador
*
*/
DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vWorkerFk);
SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed
FROM machineWorker mw
JOIN machine m ON m.plate = vPlate
WHERE mw.machineFk = m.id
AND mw.workerFk = IF(account.user_hasRole(vWorkerName, 'coolerAssist'), mw.workerFk, vWorkerFk)
ORDER BY mw.inTimed DESC;
END$$
DELIMITER ;

View File

@ -1,38 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT)
BEGIN
/**
* Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) con vPlate,
*
* @param vPlate número de matrícula
* @param vWorkerFk id del trabajador
*
*/
DECLARE vMachineFk INT(10);
DECLARE vMaxHours INT(10);
SELECT m.id INTO vMachineFk
FROM machine m
WHERE m.plate = vPlate;
SELECT maxHours INTO vMaxHours
FROM machineWorkerConfig;
IF (SELECT COUNT(*)
FROM machineWorker m
WHERE m.workerFk = vWorkerFk
AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed)) THEN
UPDATE machineWorker m
SET m.outTimed = CURRENT_TIMESTAMP()
WHERE m.workerFk = vWorkerFk
AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW())
AND ISNULL(m.outTimed)
AND m.machineFk = vMachineFk;
END IF;
END$$
DELIMITER ;

View File

@ -1,16 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machine_getWorkerPlate`(vWorkerFk INT)
BEGIN
/**
* Selecciona la matrícula del vehículo del workerfk
*
* @param vWorkerFk el id del trabajador
*/
SELECT m.plate
FROM machine m
JOIN machineWorker mw ON mw.machineFk = m.id
WHERE mw.inTimed >= TIMESTAMPADD(HOUR , -12,util.VN_NOW())
AND ISNULL(mw.outTimed)
AND mw.workerFk = vWorkerFk;
END$$
DELIMITER ;

View File

@ -60,7 +60,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND NOT t.daysInForward
UNION ALL
SELECT b.itemFk, - b.quantity
FROM buy b
@ -71,7 +71,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND NOT t.daysInForward
) sub
GROUP BY itemFk;
@ -121,7 +121,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND NOT t.daysInForward
UNION ALL
SELECT b.itemFk, t.shipped, - b.quantity
FROM buy b
@ -132,7 +132,7 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND NOT t.daysInForward
) sub
GROUP BY sub.itemFk, sub.dated;

View File

@ -1,31 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`raidUpdate`()
BEGIN
/**
* Actualiza el travel de las entradas de redadas
*/
UPDATE entry e
JOIN entryVirtual ev ON ev.entryFk = e.id
JOIN travel t ON t.id = e.travelFk
JOIN (
SELECT *
FROM (
SELECT t.id, t.landed, tt.warehouseInFk, tt.warehouseOutFk
FROM travel t
JOIN (
SELECT t.warehouseInFk, t.warehouseOutFk
FROM entryVirtual ev
JOIN entry e ON e.id = ev.entryFk
JOIN travel t ON t.id = e.travelFk
GROUP BY t.warehouseInFk, t.warehouseOutFk
) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
WHERE shipped > util.VN_CURDATE() AND NOT isDelivered
ORDER BY t.landed
LIMIT 10000000000000000000
) t
GROUP BY t.warehouseInFk, t.warehouseOutFk
) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
SET e.travelFk = t.id;
END$$
DELIMITER ;

View File

@ -51,7 +51,8 @@ BEGIN
origin.companyFk futureCompanyFk,
IFNULL(dest.nickname, origin.nickname) nickname,
dest.landed,
dest.preparation
dest.preparation,
origin.departmentFk
FROM (
SELECT s.ticketFk,
c.salesPersonFk workerFk,
@ -71,9 +72,11 @@ BEGIN
t.addressFk,
t.warehouseFk,
t.companyFk,
t.agencyModeFk
t.agencyModeFk,
wd.departmentFk
FROM ticket t
JOIN client c ON c.id = t.clientFk
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
JOIN sale s ON s.ticketFk = t.id
JOIN saleVolume sv ON sv.saleFk = s.id
JOIN item i ON i.id = s.itemFk

View File

@ -10,7 +10,7 @@ BEGIN
JOIN vn.entry e ON e.travelFk = tr.id
JOIN vn.buy b ON b.entryFk = e.id
WHERE tr.landed BETWEEN vFromDated AND vToDated
AND e.isRaid = FALSE
AND NOT tr.daysInForward
AND tr.warehouseInFk = vWarehouseFk
GROUP BY tr.landed , a.name ;
END$$

View File

@ -62,7 +62,7 @@ BEGIN
END IF;
CALL entry_cloneHeader(vAuxEntryFk, vNewEntryFk, vNewTravelFk);
CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
SELECT evaNotes INTO vEvaNotes
FROM entry
@ -71,6 +71,8 @@ BEGIN
UPDATE entry
SET evaNotes = vEvaNotes
WHERE id = vNewEntryFk;
CALL buy_recalcPricesByEntry(vNewEntryFk);
END LOOP;
SET @isModeInventory = FALSE;

View File

@ -1,30 +1,31 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`()
BEGIN
/*
* Desplaza al dia siguiente los travels que contengan redadas y avisa a los compradores
/**
* Desplaza los travels en el futuro y avisa a los compradores
*
*/
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vWorkerName VARCHAR(50);
DECLARE vRaid TEXT;
DECLARE vWorker VARCHAR(50) DEFAULT '';
DECLARE vBuyerEmail VARCHAR(40);
DECLARE vTravelLink TEXT;
DECLARE vMailBody TEXT DEFAULT '';
DECLARE vCur CURSOR FOR
SELECT GROUP_CONCAT( DISTINCT CONCAT('https://salix.verdnatura.es/#!/travel/', ttr.id, '/summary ') ORDER BY ttr.id SEPARATOR '\n\r'),
u.name
FROM tmp.travel ttr
JOIN entry e ON e.travelFk = ttr.id
SELECT GROUP_CONCAT(DISTINCT
CONCAT('https://salix.verdnatura.es/#!/travel/',
ttm.travelFk,
'/summary ')
ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink,
CONCAT(u.name, '@verdnatura.es') buyerEmail
FROM tTravelToMove ttm
JOIN entry e ON e.travelFk = ttm.travelFk
JOIN buy b ON b.entryFk = e.id
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN account.user u ON u.id = it.workerFk
GROUP BY u.name;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@ -32,41 +33,36 @@ BEGIN
RESIGNAL;
END;
DROP TEMPORARY TABLE IF EXISTS tmp.travel;
CREATE TEMPORARY TABLE tmp.travel
SELECT tr.id,tr.landed
FROM travel tr
JOIN entry e ON e.travelFk = tr.id
WHERE tr.landed = util.tomorrow()
AND e.isRaid
GROUP BY tr.id;
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
SELECT id travelFk,
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
FROM travel
WHERE daysInForward;
START TRANSACTION;
UPDATE travel tr
JOIN tmp.travel ttr ON ttr.id = tr.id
SET tr.landed = TIMESTAMPADD(DAY, 1, tr.landed);
JOIN tTravelToMove ttm ON ttm.travelFk = tr.id
SET tr.landed = ttm.newLanded;
OPEN vCur;
l: LOOP
SET vDone = FALSE;
FETCH vCur INTO vRaid, vWorkerName;
FETCH vCur INTO vTravelLink, vBuyerEmail;
IF vDone THEN
LEAVE l;
END IF;
CALL `vn`.`mail_insert`(CONCAT(vWorkerName, '@verdnatura.es'),
'noreply@verdnatura.es',
'Cambio de fecha en Redadas',
CONCAT('Se ha movido las siguientes redadas: \n\r ', vRaid)
);
CALL `vn`.`mail_insert`(
vBuyerEmail,
'noreply@verdnatura.es',
'Cambio de fecha en Redadas',
CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink));
END LOOP;
CLOSE vCur;
COMMIT;
DROP TEMPORARY TABLE tmp.travel;
DROP TEMPORARY TABLE tTravelToMove;
END$$
DELIMITER ;

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate`
BEFORE UPDATE ON `entry`
FOR EACH ROW
BEGIN
DECLARE vIsVirtual BOOL;
DECLARE vDaysInForward INT;
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
DECLARE vTotalBuy INT;
@ -38,17 +38,19 @@ BEGIN
CALL travel_throwAwb(NEW.travelFk);
END IF;
SELECT COUNT(*) > 0 INTO vIsVirtual
FROM entryVirtual WHERE entryFk = NEW.id;
SELECT daysInForward INTO vDaysInForward
FROM travel t
JOIN entry e ON e.travelFk = t.id
WHERE entryFk = NEW.id;
SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
INTO vHasDistinctWarehouses
FROM travel o, travel n
WHERE o.id = OLD.travelFk
AND n.id = NEW.travelFk;
IF vIsVirtual AND vHasDistinctWarehouses THEN
IF vDaysInForward AND vHasDistinctWarehouses THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
END IF;

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_afterDelete`
AFTER DELETE ON `itemType`
FOR EACH ROW
BEGIN
INSERT INTO itemTypeLog
SET `action` = 'delete',
`changedModel` = 'ItemType',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeInsert`
BEFORE INSERT ON `itemType`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeUpdate`
BEFORE UPDATE ON `itemType`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
IF NEW.itemPackingTypeFk = '' THEN
SET NEW.itemPackingTypeFk = NULL;

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`productionConfig_afterD
AFTER DELETE ON `productionConfig`
FOR EACH ROW
BEGIN
INSERT INTO productionConfig
INSERT INTO productionConfigLog
SET `action` = 'delete',
`changedModel` = 'ProductionConfig',
`changedModelId` = OLD.id,

View File

@ -6,7 +6,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`,
`b`.`itemFk` AS `itemFk`,
`b`.`quantity` AS `quantity`,
`t`.`isReceived` AS `isReceived`,
`e`.`isRaid` AS `isVirtualStock`,
`t`.`daysInForward` AS `isVirtualStock`,
`e`.`id` AS `entryFk`
FROM (
(

View File

@ -15,5 +15,5 @@ FROM (
JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`)
)
WHERE `e`.`isExcludedFromAvailable` = 0
AND `e`.`isRaid` = 0
AND NOT `t`.`daysInForward`
AND `b`.`quantity` <> 0

View File

@ -31,5 +31,5 @@ FROM (
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
)
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
AND `e`.`isRaid` = 0
AND NOT `tr`.`daysInForward`
AND `b`.`stickers` > 0

View File

@ -10,11 +10,10 @@ FROM (
`vn`.`collection` `c`
JOIN `vn`.`client` `cl` ON(`cl`.`id` = `c`.`workerFk`)
)
LEFT JOIN `vn`.`machineWorker` `mw` ON(
`mw`.`workerFk` = `c`.`workerFk`
AND `mw`.`inTimed` > `util`.`VN_CURDATE`()
JOIN `vn`.`operator` `o` ON(
`o`.`workerFk` = `c`.`workerFk`
)
)
WHERE `c`.`created` > `util`.`VN_CURDATE`()
AND `mw`.`workerFk` IS NULL
AND `o`.`machineFk` IS NULL
GROUP BY `c`.`workerFk`

View File

@ -8,7 +8,6 @@ AS SELECT `e`.`id` AS `Id_Entrada`,
`e`.`isExcludedFromAvailable` AS `Inventario`,
`e`.`isConfirmed` AS `Confirmada`,
`e`.`isOrdered` AS `Pedida`,
`e`.`isRaid` AS `Redada`,
`e`.`commission` AS `comision`,
`e`.`created` AS `odbc_date`,
`e`.`evaNotes` AS `Notas_Eva`,

View File

@ -1,5 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Entradas_Auto`
AS SELECT `ev`.`entryFk` AS `Id_Entrada`
FROM `vn`.`entryVirtual` `ev`

View File

@ -8,7 +8,7 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`,
`e`.`isExcludedFromAvailable` AS `Inventario`,
`e`.`isConfirmed` AS `Confirmada`,
`e`.`isOrdered` AS `Pedida`,
`e`.`isRaid` AS `Redada`,
`tr`.`daysInForward` AS `daysInForward`,
`e`.`evaNotes` AS `notas`,
`e`.`supplierFk` AS `Id_Proveedor`,
`tr`.`shipped` AS `shipment`,

View File

@ -17,5 +17,6 @@ AS SELECT `t`.`id` AS `id`,
`t`.`cargoSupplierFk` AS `cargoSupplierFk`,
`t`.`totalEntries` AS `totalEntries`,
`t`.`appointment` AS `appointment`,
`t`.`awbFk` AS `awbFk`
`t`.`awbFk` AS `awbFk`,
`t`.`daysInForward` AS `daysInForward`
FROM `vn`.`travel` `t`

View File

@ -28,7 +28,6 @@ AS SELECT `TP`.`Id_Tipo` AS `Familia`,
`E`.`Id_Proveedor` AS `Id_Proveedor`,
`E`.`Fecha` AS `Fecha`,
`E`.`Confirmada` AS `Confirmada`,
`E`.`Redada` AS `Redada`,
`E`.`empresa_id` AS `empresa_id`,
`E`.`travel_id` AS `travel_id`,
`E`.`Pedida` AS `Pedida`,
@ -85,6 +84,6 @@ FROM (
)
JOIN `vn2008`.`Cubos` `cb` ON(`cb`.`Id_Cubo` = `C`.`Id_Cubo`)
)
WHERE `W_IN`.`isFeedStock` = 0
AND `E`.`Inventario` = 0
AND `E`.`Redada` = 0
WHERE NOT `W_IN`.`isFeedStock`
AND NOT `E`.`Inventario`
AND NOT `TR`.`daysInForward`

View File

@ -1 +0,0 @@
ALTER TABLE vn.autonomy MODIFY COLUMN isUeeMember tinyint(1) DEFAULT FALSE NOT NULL;

View File

@ -0,0 +1,27 @@
ALTER TABLE vn.itemType
ADD editorFk int(10) unsigned DEFAULT NULL NULL,
ADD CONSTRAINT itemType_user_FK FOREIGN KEY (editorFk) REFERENCES account.`user`(id);
CREATE TABLE `vn`.`itemTypeLog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`originFk` int(11) DEFAULT NULL,
`userFk` int(10) unsigned DEFAULT NULL,
`action` set('insert','update','delete') NOT NULL,
`creationDate` timestamp NULL DEFAULT current_timestamp(),
`description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`changedModel` enum('ItemType') NOT NULL DEFAULT 'ItemType',
`oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
`newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
`changedModelId` int(11) NOT NULL,
`changedModelValue` varchar(45) DEFAULT NULL,
`summaryId` varchar(30) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `itemTypeLogUserFk_idx` (`userFk`),
KEY `itemTypeLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
KEY `itemTypeLog_originFk` (`originFk`,`creationDate`),
KEY `itemTypeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE,
CONSTRAINT `itemTypeLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1;
INSERT IGNORE INTO salix.ACL (model,property,principalId)
VALUES ('ItemTypeLog','find','employee');

View File

@ -0,0 +1,3 @@
ALTER TABLE vn.itemType
ADD CONSTRAINT itemType_itemPackingType_FK FOREIGN KEY (itemPackingTypeFk)
REFERENCES vn.itemPackingType(code) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,25 @@
CREATE TABLE IF NOT EXISTS `vn`.`itemCampaign` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
dated date NOT NULL,
itemFk int(11) NOT NULL,
quantity decimal(10,2) NOT NULL,
total decimal(10,2) NOT NULL,
campaign varchar(100) NOT NULL,
UNIQUE KEY `itemCampaign_UNIQUE` (`dated`,`itemFk`),
CONSTRAINT itemCampaign_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb3
COLLATE=utf8mb3_unicode_ci
COMMENT='Tallos confirmados por día en los días de más producción de una campaña. La tabla está pensada para que sea una foto.';
ALTER TABLE vn.campaign
ADD previousDays int(10) unsigned DEFAULT 30 NOT NULL COMMENT 'Días previos para calcular e insertar en la tabla itemCampaign';
UPDATE vn.campaign
SET previousDays = 90
WHERE code = 'allSaints';
UPDATE vn.campaign
SET previousDays = 60
WHERE code IN ('valentinesDay', 'mothersDay');

View File

@ -0,0 +1,3 @@
DELETE FROM `salix`.`ACL`
WHERE `model` = 'Worker'
AND `property` IN ('find', 'findById', 'findOne');

View File

@ -0,0 +1,3 @@
DELETE FROM salix.ACL
WHERE property = 'labelPdf'
AND model = 'Item';

View File

@ -0,0 +1,7 @@
ALTER TABLE vn.travel ADD IF NOT EXISTS daysInForward INT UNSIGNED DEFAULT 0 NOT NULL
COMMENT 'Indica que sus entradas son redadas: 0 significa que no es un travel de redadas, y un valor distinto a 0 indica el número de días para el landed respecto a hoy';
ALTER TABLE vn.entry CHANGE isRaid isRaid_ tinyint(1) DEFAULT 0 NOT NULL COMMENT '@deprecated 2024-11-05';
RENAME TABLE vn.entryVirtual TO vn.entryVirtual__;
ALTER TABLE vn.entryVirtual__ COMMENT='@deprecated 2024-11-05';

View File

@ -0,0 +1,9 @@
USE vn;
RENAME TABLE machineWorker TO machineWorker__;
ALTER TABLE machineWorker__ COMMENT = '@deprecated 2024-10-23 not used';
RENAME TABLE machineWorkerConfig TO machineWorkerConfig__;
ALTER TABLE machineWorkerConfig__ COMMENT = '@deprecated 2024-10-23 not used';
DELETE FROM salix.ACL WHERE model = 'MachineWorker';

View File

@ -0,0 +1,3 @@
USE vn;
ALTER TABLE vn.expeditionState ADD scanOrder int(11) DEFAULT NULL NULL COMMENT 'Indica la posición al cargar la furgoneta';

View File

@ -0,0 +1,3 @@
INSERT INTO vn.report (name, `method`)
VALUES ('LabelItemBarcode','Items/{id}/label-barcode-pdf'),
('LabelItemQr','Items/{id}/label-qr-pdf');

View File

@ -0,0 +1,7 @@
UPDATE salix.ACL
SET property='buyLabelSupplier'
WHERE property = 'buyLabel'
AND model = 'Entry';
INSERT IGNORE INTO salix.ACL (model,property,principalId)
VALUES ('Entry','buyLabel','employee');

View File

@ -0,0 +1,7 @@
DELETE FROM vn.report
WHERE `name` = 'LabelItemQr';
UPDATE vn.report
SET `method` = 'Entries/{id}/{labelType}/buy-label',
`name` = 'LabelBuy'
WHERE `name` = 'LabelItemBarcode';

View File

@ -240,6 +240,10 @@
"There is already a tray with the same height": "There is already a tray with the same height",
"The height must be greater than 50cm": "The height must be greater than 50cm",
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line",
"There are tickets for this area, delete them first": "There are tickets for this area, delete them first"
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line",
"There are tickets for this area, delete them first": "There are tickets for this area, delete them first",
"ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}",
"null": "null",
"Invalid or expired verification code": "Invalid or expired verification code",
"Payment method is required": "Payment method is required"
}

View File

@ -384,5 +384,8 @@
"No valid travel thermograph found": "No se encontró un termógrafo válido",
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
"type cannot be blank": "Se debe rellenar el tipo",
"There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero"
"There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero",
"There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén",
"ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
"The web user's email already exists": "El correo del usuario web ya existe"
}

View File

@ -123,8 +123,8 @@
"Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
"Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",,
"Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})",
"Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",
"Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})",
"Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}",
"State": "État",
"regular": "normal",
@ -362,6 +362,8 @@
"The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré",
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré",
"Cannot send mail": "Impossible d'envoyer le mail",
"Original invoice not found": "Facture originale introuvable",
"The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne"
"Original invoice not found": "Facture originale introuvable",
"The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne",
"ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}",
"The web user's email already exists": "L'email de l'internaute existe déjà"
}

View File

@ -124,7 +124,7 @@
"Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"Created claim": "Reclamação criada [{{claimId}}]({{{claimUrl}}}) no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"Changed sale price": "Preço da venda alterado para [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* no ticket [{{ticketId}}]({{{ticketUrl}}})",
"Changed sale quantity": "Quantidade da venda alterada para {{changes}} no ticket [{{ticketId}}]({{{ticketUrl}}})",
"Changed sale quantity": "Quantidade da venda alterada para {{changes}} no ticket [{{ticketId}}]({{{ticketUrl}}})",
"Changes in sales": " [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* ",
"State": "Estado",
"regular": "normal",
@ -361,7 +361,9 @@
"It was not able to create the invoice": "Não foi possível criar a fatura",
"The invoices have been created but the PDFs could not be generated": "Foi faturado, mas o PDF não pôde ser gerado",
"It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso",
"Original invoice not found": "Fatura original não encontrada",
"Original invoice not found": "Fatura original não encontrada",
"Cannot send mail": "Não é possível enviar o email",
"The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha"
"The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha",
"ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}",
"The web user's email already exists": "O e-mail do utilizador da web já existe."
}

View File

@ -1,3 +1,4 @@
/* eslint max-len: ["error", { "code": 150 }]*/
const UserError = require('vn-loopback/util/user-error');
module.exports = function(Self) {
@ -98,6 +99,8 @@ module.exports = function(Self) {
return client;
} catch (e) {
if (tx) await tx.rollback();
if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`The web user's email already exists`);
throw e;
}
};

View File

@ -9,7 +9,6 @@ columns:
notes: notes
isConfirmed: confirmed
isVirtual: virtual
isRaid: raid
commission: commission
isOrdered: price3
created: created

View File

@ -9,7 +9,6 @@ columns:
notes: notas
isConfirmed: confirmado
isVirtual: virtual
isRaid: redada
commission: comisión
isOrdered: pedida
created: creado

View File

@ -1,14 +1,28 @@
module.exports = Self => {
Self.remoteMethodCtx('buyLabel', {
description: 'Returns the entry buy labels',
description: 'Returns the buy label',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The entry id',
description: 'The buy id',
http: {source: 'path'}
}, {
arg: 'labelType',
type: 'string',
required: true,
description: 'The label type',
http: {source: 'path'}
}, {
arg: 'packing',
type: 'number',
required: false
}, {
arg: 'copies',
type: 'number',
required: false
}
],
returns: [
@ -27,11 +41,16 @@ module.exports = Self => {
}
],
http: {
path: '/:id/buy-label',
path: '/:id/:labelType/buy-label',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label');
Self.buyLabel = (ctx, id, labelType) => {
if (labelType == 'qr')
return Self.printReport(ctx, id, 'buy-label-qr');
else
return Self.printReport(ctx, id, 'buy-label-barcode');
};
};

View File

@ -0,0 +1,37 @@
module.exports = Self => {
Self.remoteMethodCtx('buyLabelSupplier', {
description: 'Returns the entry buy labels',
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/buy-label-supplier',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.buyLabelSupplier = (ctx, id) => Self.printReport(ctx, id, 'buy-label-supplier');
};

View File

@ -194,7 +194,7 @@ module.exports = Self => {
e.evaNotes observation,
e.isConfirmed,
e.isOrdered,
e.isRaid,
t.daysInForward,
e.commission,
e.created,
e.travelFk,

View File

@ -48,7 +48,9 @@ module.exports = Self => {
'warehouseInFk',
'isReceived',
'isDelivered',
'ref'],
'ref',
'daysInForward',
],
include: [
{
relation: 'agency',
@ -85,7 +87,6 @@ module.exports = Self => {
}
],
};
return models.Entry.findOne(filter, myOptions);
};
};

View File

@ -2,4 +2,5 @@ module.exports = Self => {
require('../methods/entry/editLatestBuys')(Self);
require('../methods/entry/latestBuysFilter')(Self);
require('../methods/entry/deleteBuys')(Self);
require('../methods/entry/buyLabel')(Self);
};

View File

@ -33,15 +33,6 @@
"isConfirmed": {
"type": "boolean"
},
"isVirtual": {
"type": "boolean",
"mysql": {
"columnName": "isRaid"
}
},
"isRaid": {
"type": "boolean"
},
"commission": {
"type": "number"
},
@ -88,7 +79,8 @@
"travel": {
"type": "belongsTo",
"model": "Travel",
"foreignKey": "travelFk"
"foreignKey": "travelFk",
"daysInForward": "daysInForward"
},
"company": {
"type": "belongsTo",

View File

@ -23,14 +23,14 @@
</div>
<div class="icons">
<vn-icon
vn-tooltip="Is inventory entry"
vn-tooltip="It is a raid {{$ctrl.entryData.travel.daysInForward}} days forward"
icon="icon-inventory"
ng-if="$ctrl.entry.isExcludedFromAvailable">
</vn-icon>
<vn-icon
vn-tooltip="Is virtual entry"
icon="icon-net"
ng-if="$ctrl.entry.isRaid">
ng-if="$ctrl.entryData.travel.daysInForward">
</vn-icon>
</div>
<div class="quicklinks">

View File

@ -86,7 +86,7 @@ auto-load="true">
</vn-check>
<vn-check
label="Raid"
ng-model="$ctrl.entryData.isRaid"
ng-model="$ctrl.entryData.travel.daysInForward"
disabled="true">
</vn-check>
<vn-check

View File

@ -38,13 +38,23 @@ module.exports = Self => {
type: 'integer',
description: 'Type id',
},
{
arg: 'producerFk',
type: 'integer',
description: 'Producer id',
},
{
arg: 'instrastatFk',
type: 'string',
description: 'intrastat id',
},
{
arg: 'isActive',
type: 'boolean',
description: 'Whether the item is or not active',
},
{
arg: 'buyerFk',
arg: 'workerFk',
type: 'integer',
description: 'The buyer of the item',
},
@ -126,14 +136,16 @@ module.exports = Self => {
return {'i.stemMultiplier': value};
case 'categoryFk':
return {'ic.id': value};
case 'buyerFk':
case 'workerFk':
return {'it.workerFk': value};
case 'producerFk':
return {'pr.id': value};
case 'supplierFk':
return {'s.id': value};
case 'origin':
return {'ori.code': value};
case 'intrastat':
return {'intr.description': value};
case 'intrastatFk':
return {'i.intrastatFk': value};
case 'landed':
return {'lb.landed': value};
}
@ -172,6 +184,7 @@ module.exports = Self => {
u.name AS userName,
ori.code AS origin,
ic.name AS category,
i.intrastatFk,
intr.description AS intrastat,
b.grouping,
b.packing,

View File

@ -1,59 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('labelPdf', {
description: 'Returns the item label pdf',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The item id',
http: {source: 'path'}
},
{
arg: 'recipientId',
type: 'number',
description: 'The recipient id',
required: false
},
{
arg: 'warehouseId',
type: 'number',
description: 'The warehouse id',
required: true
},
{
arg: 'labelNumber',
type: 'number',
required: false
},
{
arg: 'totalLabels',
type: 'number',
required: false
}
],
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/label-pdf',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label');
};

View File

@ -86,7 +86,7 @@ describe('item filter()', () => {
try {
const filter = {};
const ctx = {args: {filter: filter, buyerFk: 16}, req: {accessToken: {userId: 1}}};
const ctx = {args: {filter: filter, workerFk: 16}, req: {accessToken: {userId: 1}}};
const result = await models.Item.filter(ctx, filter, options);
expect(result.length).toEqual(2);

View File

@ -47,6 +47,9 @@
"ItemType": {
"dataSource": "vn"
},
"ItemTypeLog": {
"dataSource": "vn"
},
"ItemTypeTag": {
"dataSource": "vn"
},

View File

@ -0,0 +1,9 @@
{
"name": "ItemTypeLog",
"base": "Log",
"options": {
"mysql": {
"table": "itemTypeLog"
}
}
}

View File

@ -29,6 +29,12 @@
},
"isLaid": {
"type": "boolean"
},
"maxRefs": {
"type": "string"
},
"isFragile": {
"type": "boolean"
}
},
"relations": {

View File

@ -15,7 +15,6 @@ module.exports = Self => {
require('../methods/item/getWasteByItem')(Self);
require('../methods/item/createIntrastat')(Self);
require('../methods/item/buyerWasteEmail')(Self);
require('../methods/item/labelPdf')(Self);
require('../methods/item/setVisibleDiscard')(Self);
require('../methods/item/get')(Self);

View File

@ -24,8 +24,8 @@
<vn-autocomplete
label="Worker"
ng-model="$ctrl.itemType.workerFk"
url="Workers"
show-field="firstName"
url="Workers/search"
show-field="nickname"
value-field="id"
rule>
</vn-autocomplete>

View File

@ -25,8 +25,8 @@
<vn-autocomplete
label="Worker"
ng-model="$ctrl.itemType.workerFk"
url="Workers"
show-field="firstName"
url="Workers/search"
show-field="nickname"
value-field="id"
rule>
</vn-autocomplete>

View File

@ -38,5 +38,13 @@
"model": "Sector",
"foreignKey": "sectorFk"
}
},
"scope": {
"include": {
"relation": "sector",
"scope": {
"fields": ["id", "description"]
}
}
}
}

View File

@ -44,6 +44,7 @@ module.exports = Self => {
const typeFk = expeditionStateType.id;
expeditionId = expedition.expeditionFk;
expeditionPosition = expedition?.scanOrder ?? null;
const isScannedExpedition = expedition.isScanned ?? false;
await models.ExpeditionState.create({
@ -51,6 +52,7 @@ module.exports = Self => {
typeFk,
userFk: userId,
isScanned: isScannedExpedition,
scanOrder: expeditionPosition
}, myOptions);
}

Some files were not shown because too many files have changed in this diff Show More