8144-devToTest_2448 #3216
|
@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -88,12 +88,6 @@
|
|||
"Machine": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MachineWorker": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MachineWorkerConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MobileAppVersionControl": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"name": "MachineWorkerConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "vn.machineWorkerConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"maxHours": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/machine-worker/updateInTime')(Self);
|
||||
};
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -1,7 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
|
||||
vItemFk INT,
|
||||
vWarehouseFk SMALLINT,
|
||||
vWarehouseFk INT,
|
||||
vDated DATE
|
||||
)
|
||||
BEGIN
|
||||
|
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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`
|
||||
|
|
|
@ -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');
|
|
@ -0,0 +1,3 @@
|
|||
DELETE FROM salix.ACL
|
||||
WHERE property = 'labelPdf'
|
||||
AND model = 'Item';
|
|
@ -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';
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO vn.report (name, `method`)
|
||||
VALUES ('LabelItemBarcode','Items/{id}/label-barcode-pdf'),
|
||||
('LabelItemQr','Items/{id}/label-qr-pdf');
|
|
@ -384,5 +384,6 @@
|
|||
"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"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('labelPdf', {
|
||||
description: 'Returns the item label pdf',
|
||||
Self.remoteMethodCtx('labelBarcodePdf', {
|
||||
description: 'Returns the item label pdf with barcode',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
|
@ -9,28 +9,24 @@ module.exports = Self => {
|
|||
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',
|
||||
}, {
|
||||
arg: 'packing',
|
||||
type: 'number',
|
||||
required: false
|
||||
},
|
||||
{
|
||||
arg: 'totalLabels',
|
||||
}, {
|
||||
arg: 'copies',
|
||||
type: 'number',
|
||||
required: false
|
||||
}, {
|
||||
arg: 'userId',
|
||||
type: 'number',
|
||||
description: 'The user id from accessToken',
|
||||
http: ctx => ctx.req.accessToken.userId,
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: [
|
||||
|
@ -49,11 +45,11 @@ module.exports = Self => {
|
|||
}
|
||||
],
|
||||
http: {
|
||||
path: '/:id/label-pdf',
|
||||
path: '/:id/label-barcode-pdf',
|
||||
verb: 'GET'
|
||||
},
|
||||
accessScopes: ['DEFAULT', 'read:multimedia']
|
||||
});
|
||||
|
||||
Self.labelPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label');
|
||||
Self.labelBarcodePdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-barcode');
|
||||
};
|
|
@ -0,0 +1,55 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('labelQrPdf', {
|
||||
description: 'Returns the item label pdf with qr',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The item id',
|
||||
http: {source: 'path'}
|
||||
}, {
|
||||
arg: 'warehouseId',
|
||||
type: 'number',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'packing',
|
||||
type: 'number',
|
||||
required: false
|
||||
}, {
|
||||
arg: 'copies',
|
||||
type: 'number',
|
||||
required: false
|
||||
}, {
|
||||
arg: 'userId',
|
||||
type: 'number',
|
||||
description: 'The user id from accessToken',
|
||||
http: ctx => ctx.req.accessToken.userId,
|
||||
required: true
|
||||
}
|
||||
],
|
||||
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-qr-pdf',
|
||||
verb: 'GET'
|
||||
},
|
||||
accessScopes: ['DEFAULT', 'read:multimedia']
|
||||
});
|
||||
|
||||
Self.labelQrPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr');
|
||||
};
|
|
@ -15,7 +15,8 @@ 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/labelBarcodePdf')(Self);
|
||||
require('../methods/item/labelQrPdf')(Self);
|
||||
require('../methods/item/setVisibleDiscard')(Self);
|
||||
require('../methods/item/get')(Self);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT es.created, u.name, u.id workerFk, est.description state
|
||||
`SELECT es.created, u.name, u.id workerFk, est.description state, es.isScanned
|
||||
FROM vn.expeditionState es
|
||||
JOIN vn.expeditionStateType est ON est.id = es.typeFk
|
||||
JOIN account.user u ON u.id = es.userFk
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
html {
|
||||
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
|
||||
margin-top: -9px;
|
||||
margin-left: -6px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
}
|
||||
td {
|
||||
border: 6px solid white;
|
||||
}
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
.right {
|
||||
text-align: right;
|
||||
}
|
||||
.cursive {
|
||||
font-style: italic;
|
||||
}
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.black-bg {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
.xs-txt {
|
||||
font-size: 18px;
|
||||
}
|
||||
.md-txt {
|
||||
font-size: 26px;
|
||||
}
|
||||
.xl-txt {
|
||||
font-size: 50px;
|
||||
}
|
||||
.cell {
|
||||
border: 2px solid black;
|
||||
box-sizing: content-box;
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.padding {
|
||||
padding: 7px;
|
||||
}
|
||||
.xs-height {
|
||||
height: 50px;
|
||||
max-height: 50px;
|
||||
}
|
||||
.md-height {
|
||||
height: 75px;
|
||||
max-height: 75px;
|
||||
}
|
||||
.sm-width {
|
||||
width: 60px;
|
||||
max-width: 60px;
|
||||
}
|
||||
.md-width {
|
||||
width: 125px;
|
||||
max-width: 125px;
|
||||
}
|
||||
.lg-width {
|
||||
width: 380px;
|
||||
max-width: 380px;
|
||||
}
|
||||
.overflow-multiline {
|
||||
max-height: inherit;
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
line-clamp: 2;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
.overflow-line {
|
||||
width: inherit;
|
||||
max-width: inherit;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body table v-for="item in items" style="break-before: page">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="md-txt bold center black-bg lg-width md-height">
|
||||
<div class="overflow-multiline">
|
||||
{{item.item}}
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="2" class="xl-txt bold center black-bg md-height md-width">
|
||||
<div class="overflow-line">
|
||||
{{item.size}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="right lg-width">
|
||||
<div class="overflow-line">
|
||||
{{
|
||||
(item.longName && item.size && item.subName)
|
||||
? `${item.longName} ${item.size} ${item.subName}`
|
||||
: item.comment
|
||||
}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="center sm-width">
|
||||
<div class="overflow-line">
|
||||
{{item.producerName || item.producerFk}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="center sm-width">
|
||||
<div class="overflow-line">
|
||||
{{item.inkFk}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md-txt xl-width bold center">
|
||||
<div class="overflow-line">
|
||||
{{item.itemFk}}
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="2" class="md-txt md-width center">
|
||||
<div class="overflow-line">
|
||||
{{`${(packing || item.packing)} x ${item.stems || ''}`}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2" class="center">
|
||||
<div v-html="getBarcode(item.buyFk)"></div>
|
||||
</td>
|
||||
<td colspan="2" class="center md-width xs-height xs-txt">
|
||||
<div class="overflow-line">
|
||||
{{item.entryFk}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="center xs-txt sm-width">
|
||||
<div class="overflow-line">
|
||||
{{item.buyerName}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="center xs-txt sm-width">
|
||||
<div class="overflow-line">
|
||||
{{item.origin}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="center xl-width">
|
||||
<div class="overflow-line">
|
||||
{{item.buyFk}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="xs-txt sm-width center">
|
||||
<div class="overflow-line">
|
||||
{{date}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="xs-txt sm-width cursive center bold">
|
||||
<div class="overflow-line">
|
||||
{{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,58 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const {DOMImplementation, XMLSerializer} = require('xmldom');
|
||||
const moment = require('moment');
|
||||
const jsbarcode = require('jsbarcode');
|
||||
|
||||
module.exports = {
|
||||
name: 'item-label-barcode',
|
||||
async serverPrefetch() {
|
||||
this.company = await this.findOneFromDef('company', [this.warehouseId]);
|
||||
if (!this.company)
|
||||
throw new UserError(`There is no company associated with that warehouse`);
|
||||
|
||||
this.date = Date.vnNew();
|
||||
this.lastBuy = await this.findOneFromDef('lastBuy', [
|
||||
this.id,
|
||||
this.warehouseId,
|
||||
this.date
|
||||
]);
|
||||
this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]);
|
||||
if (!this.items.length) throw new UserError(`Empty data source`);
|
||||
this.date = moment(this.date).format('WW/E');
|
||||
},
|
||||
methods: {
|
||||
getBarcode(data) {
|
||||
const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
|
||||
const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||
|
||||
jsbarcode(svgNode, data, {
|
||||
xmlDocument: document,
|
||||
format: 'code128',
|
||||
displayValue: false,
|
||||
width: 3.8,
|
||||
height: 85,
|
||||
margin: 0
|
||||
});
|
||||
return new XMLSerializer().serializeToString(svgNode);
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: {
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The item id'
|
||||
},
|
||||
warehouseId: {
|
||||
type: Number
|
||||
},
|
||||
packing: {
|
||||
type: Number
|
||||
},
|
||||
copies: {
|
||||
type: Number
|
||||
},
|
||||
userId: {
|
||||
type: Number
|
||||
}
|
||||
}
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
reportName: Etiqueta de artículo barcode
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"width": "10.4cm",
|
||||
"height": "4.9cm",
|
||||
"margin": {
|
||||
"top": "0.17cm",
|
||||
"right": "0.745cm",
|
||||
"bottom": "0cm",
|
||||
"left": "0cm"
|
||||
},
|
||||
"printBackground": true
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
SELECT co.code
|
||||
FROM warehouse w
|
||||
JOIN address a ON a.id = w.addressFk
|
||||
JOIN company co ON co.clientFk = a.clientFk
|
||||
WHERE w.id = ?
|
|
@ -0,0 +1,34 @@
|
|||
WITH RECURSIVE numbers AS (
|
||||
SELECT 1 n
|
||||
UNION ALL
|
||||
SELECT n + 1
|
||||
FROM numbers
|
||||
WHERE n < ?
|
||||
)
|
||||
SELECT ROW_NUMBER() OVER() labelNum,
|
||||
b.itemFk,
|
||||
i.name item,
|
||||
b.id buyFk,
|
||||
b.quantity,
|
||||
b.packing,
|
||||
b.entryFk,
|
||||
o.code origin,
|
||||
p.`name` producerName,
|
||||
p.id producerFk,
|
||||
i.`size`,
|
||||
i.category,
|
||||
i.stems,
|
||||
i.inkFk,
|
||||
ig.longName,
|
||||
ig.subName,
|
||||
i.comment,
|
||||
w.code buyerName
|
||||
FROM vn.buy b
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
|
||||
JOIN vn.origin o ON o.id = i.originFk
|
||||
LEFT JOIN vn.producer p ON p.id = i.producerFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN vn.worker w ON w.id = it.workerFk
|
||||
JOIN numbers num
|
||||
WHERE b.id = ?
|
|
@ -0,0 +1 @@
|
|||
SELECT buy_getUltimate(?, ?, ?) id
|
|
@ -0,0 +1,12 @@
|
|||
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||
|
||||
const path = require('path');
|
||||
const vnPrintPath = path.resolve('print');
|
||||
|
||||
module.exports = new Stylesheet([
|
||||
`${vnPrintPath}/common/css/spacing.css`,
|
||||
`${vnPrintPath}/common/css/misc.css`,
|
||||
`${vnPrintPath}/common/css/layout.css`,
|
||||
`${vnPrintPath}/common/css/report.css`,
|
||||
`${__dirname}/style.css`])
|
||||
.mergeStyles();
|
|
@ -0,0 +1,89 @@
|
|||
html {
|
||||
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
|
||||
margin-top: -7px;
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leftTable {
|
||||
width: 47%;
|
||||
font-size: 12px;
|
||||
float: left;
|
||||
text-align: center;
|
||||
}
|
||||
.leftTable img {
|
||||
margin-top: 3px;
|
||||
width: 110px;
|
||||
}
|
||||
.rightTable {
|
||||
width: 53%;
|
||||
font-size: 14px;
|
||||
float: right;
|
||||
}
|
||||
.rightTable td {
|
||||
border: 3px solid white;
|
||||
}
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
.cursive {
|
||||
font-style: italic;
|
||||
}
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.black-bg {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
.md-txt {
|
||||
font-size: 20px;
|
||||
}
|
||||
.xl-txt {
|
||||
font-size: 36px;
|
||||
}
|
||||
.cell {
|
||||
border: 2px solid black;
|
||||
box-sizing: content-box;
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.padding {
|
||||
padding: 7px;
|
||||
}
|
||||
.md-height {
|
||||
height: 68px;
|
||||
max-height: 68px;
|
||||
}
|
||||
.xs-width {
|
||||
width: 60px;
|
||||
max-width: 60px;
|
||||
}
|
||||
.sm-width {
|
||||
width: 130px;
|
||||
max-width: 130px;
|
||||
}
|
||||
.md-width {
|
||||
width: 190px;
|
||||
max-width: 190px;
|
||||
}
|
||||
.lg-width {
|
||||
width: 240px;
|
||||
max-width: 240px;
|
||||
}
|
||||
.overflow-multiline {
|
||||
max-height: inherit;
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
line-clamp: 2;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
.overflow-line {
|
||||
width: inherit;
|
||||
max-width: inherit;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body v-for="item in items" style="break-before: page">
|
||||
<table class="leftTable">
|
||||
<tr>
|
||||
<td>
|
||||
<img v-bind:src="qr"/>
|
||||
</td>
|
||||
<td>
|
||||
<img v-bind:src="qr"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{{item.buyFk}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img v-bind:src="qr"/>
|
||||
</td>
|
||||
<td>
|
||||
<img v-bind:src="qr"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="rightTable">
|
||||
<tr>
|
||||
<td colspan="3" class="lg-width black-bg center bold xl-txt padding">
|
||||
<div class="overflow-line">
|
||||
{{item.itemFk}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="black-bg center bold md-txt md-width md-height">
|
||||
<div class="overflow-multiline">
|
||||
{{item.item}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="xs-width black-bg center bold xl-txt">
|
||||
<div class="overflow-line">
|
||||
{{item.size}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="sm-width">
|
||||
<div class="overflow-line">
|
||||
<i>Color:</i> <b>{{item.inkFk}}</b>
|
||||
</div>
|
||||
</td>
|
||||
<td rowspan="2" class="xs-width center md-txt">
|
||||
<div class="overflow-line cell">
|
||||
{{packing || item.packing}}
|
||||
</div>
|
||||
</td>
|
||||
<td rowspan="2" class="xs-width center md-txt">
|
||||
<div class="overflow-line cell">
|
||||
{{item.stems}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="sm-width">
|
||||
<div class="overflow-line">
|
||||
<i>Origen:</i> {{item.origin}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="md-width">
|
||||
<div class="overflow-line">
|
||||
<i>Productor:</i> {{item.producerName || item.producerFk}}
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="sm-width">
|
||||
<div class="overflow-line">
|
||||
<i>Comprador:</i> {{item.buyerName}}
|
||||
</div>
|
||||
</td>
|
||||
<td rowspan="2" class="xs-width">
|
||||
<div class="overflow-line">
|
||||
<i>F:</i> {{date}}
|
||||
</div>
|
||||
</td>
|
||||
<td rowspan="2" class="xs-width center cursive bold md-txt">
|
||||
<div class="overflow-line">
|
||||
{{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="sm-width">
|
||||
<div class="overflow-line">
|
||||
<i>Entrada:</i> {{item.entryFk}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="lg-width center cursive bold">
|
||||
<div class="overflow-line">
|
||||
{{
|
||||
(item.longName && item.size && item.subName)
|
||||
? `${item.longName} ${item.size} ${item.subName}`
|
||||
: item.comment
|
||||
}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,57 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const moment = require('moment');
|
||||
const qrcode = require('qrcode');
|
||||
|
||||
module.exports = {
|
||||
name: 'item-label-qr',
|
||||
async serverPrefetch() {
|
||||
this.company = await this.findOneFromDef('company', [this.warehouseId]);
|
||||
if (!this.company)
|
||||
throw new UserError(`There is no company associated with that warehouse`);
|
||||
|
||||
this.date = Date.vnNew();
|
||||
this.lastBuy = await this.findOneFromDef('lastBuy', [
|
||||
this.id,
|
||||
this.warehouseId,
|
||||
this.date
|
||||
]);
|
||||
this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]);
|
||||
if (!this.items.length) throw new UserError(`Empty data source`);
|
||||
this.qr = await this.getQr(this.items[0].buyFk);
|
||||
this.date = moment(this.date).format('WW/E');
|
||||
},
|
||||
methods: {
|
||||
getQr(data) {
|
||||
data = {
|
||||
company: this.company,
|
||||
user: this.userId,
|
||||
created: this.date,
|
||||
table: 'buy',
|
||||
id: data
|
||||
};
|
||||
return qrcode.toDataURL(JSON.stringify(data), {
|
||||
margin: 0,
|
||||
errorCorrectionLevel: 'L'
|
||||
});
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: {
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The item id'
|
||||
},
|
||||
warehouseId: {
|
||||
type: Number
|
||||
},
|
||||
packing: {
|
||||
type: Number
|
||||
},
|
||||
copies: {
|
||||
type: Number
|
||||
},
|
||||
userId: {
|
||||
type: Number
|
||||
}
|
||||
}
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
reportName: Etiqueta de artículo QR
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"width": "10.4cm",
|
||||
"height": "4.8cm",
|
||||
"height": "4.9cm",
|
||||
"margin": {
|
||||
"top": "0cm",
|
||||
"right": "0cm",
|
||||
"top": "0.17cm",
|
||||
"right": "0.6cm",
|
||||
"bottom": "0cm",
|
||||
"left": "0cm"
|
||||
},
|
|
@ -0,0 +1,5 @@
|
|||
SELECT co.code
|
||||
FROM warehouse w
|
||||
JOIN address a ON a.id = w.addressFk
|
||||
JOIN company co ON co.clientFk = a.clientFk
|
||||
WHERE w.id = ?
|
|
@ -0,0 +1,34 @@
|
|||
WITH RECURSIVE numbers AS (
|
||||
SELECT 1 n
|
||||
UNION ALL
|
||||
SELECT n + 1
|
||||
FROM numbers
|
||||
WHERE n < ?
|
||||
)
|
||||
SELECT ROW_NUMBER() OVER() labelNum,
|
||||
b.itemFk,
|
||||
i.name item,
|
||||
b.id buyFk,
|
||||
b.quantity,
|
||||
b.packing,
|
||||
b.entryFk,
|
||||
o.code origin,
|
||||
p.`name` producerName,
|
||||
p.id producerFk,
|
||||
i.`size`,
|
||||
i.category,
|
||||
i.stems,
|
||||
i.inkFk,
|
||||
ig.longName,
|
||||
ig.subName,
|
||||
i.comment,
|
||||
w.code buyerName
|
||||
FROM vn.buy b
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
|
||||
JOIN vn.origin o ON o.id = i.originFk
|
||||
LEFT JOIN vn.producer p ON p.id = i.producerFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN vn.worker w ON w.id = it.workerFk
|
||||
JOIN numbers num
|
||||
WHERE b.id = ?
|
|
@ -0,0 +1 @@
|
|||
SELECT buy_getUltimate(?, ?, ?) id
|
|
@ -1,88 +0,0 @@
|
|||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.label {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.barcode {
|
||||
float: left;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.barcode h1 {
|
||||
text-align: center;
|
||||
font-size: 1.8em;
|
||||
margin: 0 0 10px 0
|
||||
}
|
||||
|
||||
.barcode .image {
|
||||
text-align: center
|
||||
}
|
||||
|
||||
.barcode .image img {
|
||||
width: 170px
|
||||
}
|
||||
|
||||
.data {
|
||||
float: left;
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.data .header {
|
||||
background-color: #000;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
margin-bottom: 25px;
|
||||
text-align: right;
|
||||
font-size: 1.2em;
|
||||
padding: 0.2em;
|
||||
color: #FFF
|
||||
}
|
||||
|
||||
.data .color,
|
||||
.data .producer {
|
||||
text-transform: uppercase;
|
||||
text-align: right;
|
||||
font-size: 1.5em;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.data .producer {
|
||||
text-justify: inter-character;
|
||||
}
|
||||
|
||||
.data .details {
|
||||
border-top: 4px solid #000;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.data .details .package {
|
||||
padding-right: 5px;
|
||||
float: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.package .packing,
|
||||
.package .dated,
|
||||
.package .labelNumber {
|
||||
text-align: right
|
||||
}
|
||||
|
||||
.package .packing {
|
||||
font-size: 1.8em;
|
||||
font-weight: 400
|
||||
}
|
||||
|
||||
.data .details .size {
|
||||
background-color: #000;
|
||||
text-align: center;
|
||||
font-size: 3em;
|
||||
padding: 0.2em 0;
|
||||
float: left;
|
||||
width: 50%;
|
||||
color: #FFF
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
<report-body v-bind="$props">
|
||||
<template v-slot:header>
|
||||
<span></span>
|
||||
</template>
|
||||
<div class="label">
|
||||
<div class="barcode">
|
||||
<h1>{{item.id}}</h1>
|
||||
<div class="image">
|
||||
<img v-bind:src="barcode" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="data">
|
||||
<div class="header">{{item.name}}</div>
|
||||
<div class="color">{{tags.color}}</div>
|
||||
<div class="producer">{{tags.producer}}</div>
|
||||
<div class="details">
|
||||
<div class="package">
|
||||
<div class="packing">{{packing()}}</div>
|
||||
<div class="dated">{{formatDate(new Date(), '%W/%d')}}</div>
|
||||
<div class="labelNumber">{{labelPage}}</div>
|
||||
</div>
|
||||
<div class="size">{{item.size}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template v-slot:footer>
|
||||
<span></span>
|
||||
</template>
|
||||
</report-body>
|
|
@ -1,58 +0,0 @@
|
|||
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||
const qrcode = require('qrcode');
|
||||
|
||||
module.exports = {
|
||||
name: 'item-label',
|
||||
mixins: [vnReport],
|
||||
async serverPrefetch() {
|
||||
this.item = await this.findOneFromDef('item', [this.id, this.warehouseId]);
|
||||
this.checkMainEntity(this.item);
|
||||
this.tags = await this.fetchItemTags(this.id);
|
||||
this.barcode = await this.getBarcodeBase64(this.id);
|
||||
},
|
||||
|
||||
computed: {
|
||||
labelPage() {
|
||||
const labelNumber = this.labelNumber ? this.labelNumber : 1;
|
||||
const totalLabels = this.totalLabels ? this.totalLabels : 1;
|
||||
|
||||
return `${labelNumber}/${totalLabels}`;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchItemTags(id) {
|
||||
return this.rawSqlFromDef('itemTags', [id]).then(rows => {
|
||||
const tags = {};
|
||||
rows.forEach(row => tags[row.code] = row.value);
|
||||
|
||||
return tags;
|
||||
});
|
||||
},
|
||||
getBarcodeBase64(id) {
|
||||
const data = String(id);
|
||||
|
||||
return qrcode.toDataURL(data, {margin: 0});
|
||||
},
|
||||
packing() {
|
||||
const stems = this.item.stems ? this.item.stems : 1;
|
||||
return `${this.item.packing}x${stems}`;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: {
|
||||
type: Number,
|
||||
required: true,
|
||||
description: 'The item id'
|
||||
},
|
||||
warehouseId: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
labelNumber: {
|
||||
type: Number
|
||||
},
|
||||
totalLabels: {
|
||||
type: Number
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1 +0,0 @@
|
|||
reportName: Etiqueta
|
|
@ -1,14 +0,0 @@
|
|||
SELECT
|
||||
i.id,
|
||||
i.name,
|
||||
i.stems,
|
||||
i.size,
|
||||
b.packing,
|
||||
p.name as 'producer'
|
||||
FROM vn.item i
|
||||
JOIN cache.last_buy clb ON clb.item_id = i.id
|
||||
JOIN vn.buy b ON b.id = clb.buy_id
|
||||
JOIN vn.entry e ON e.id = b.entryFk
|
||||
JOIN vn.producer p ON p.id = i.producerFk
|
||||
|
||||
WHERE i.id = ? AND clb.warehouse_id = ?
|
|
@ -1,4 +0,0 @@
|
|||
SELECT t.code, t.name, it.value
|
||||
FROM vn.itemTag it
|
||||
JOIN vn.tag t ON t.id = it.tagFk
|
||||
WHERE it.itemFk = ?
|
Loading…
Reference in New Issue