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
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
commit
0437756256
|
@ -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": {
|
"Machine": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"MachineWorker": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"MachineWorkerConfig": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"MobileAppVersionControl": {
|
"MobileAppVersionControl": {
|
||||||
"dataSource": "vn"
|
"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 (379,'Item','buyerWasteEmail','WRITE','ALLOW','ROLE','system',NULL);
|
||||||
INSERT INTO `ACL` VALUES (380,'Claim','claimPickupPdf','READ','ALLOW','ROLE','employee',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 (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 (383,'Sector','*','READ','ALLOW','ROLE','employee',NULL);
|
||||||
INSERT INTO `ACL` VALUES (384,'Sector','*','WRITE','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);
|
INSERT INTO `ACL` VALUES (385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee',NULL);
|
||||||
|
|
|
@ -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');
|
(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`)
|
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`
|
FROM `account`.`role` `r`
|
||||||
WHERE `r`.`hasLogin` = 1;
|
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),
|
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
|
||||||
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 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`)
|
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),
|
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),
|
(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),
|
(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),
|
(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),
|
(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),
|
(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),
|
(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),
|
(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),
|
(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),
|
(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);
|
(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
|
VALUES
|
||||||
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 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, 0, 'observation two'),
|
(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, 0, 'observation three'),
|
(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, 0, 'observation four'),
|
(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, 0, 'observation five'),
|
(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, 0, 'observation six'),
|
(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, 0, 'observation seven'),
|
(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, 1, ''),
|
(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, 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, 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, 0, '');
|
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, '');
|
||||||
|
|
||||||
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
||||||
VALUES (2, 4, 1);
|
VALUES (2, 4, 1);
|
||||||
|
@ -2454,7 +2454,7 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `
|
||||||
INSERT INTO `vn`.`dmsType`
|
INSERT INTO `vn`.`dmsType`
|
||||||
(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'),
|
(1, 'Facturas Recibidas', 1, 1, 'invoiceIn'),
|
||||||
(2, 'Doc oficial', NULL, NULL, 'officialDoc'),
|
(2, 'Doc oficial', NULL, NULL, 'officialDoc'),
|
||||||
(3, 'Laboral', 37, 37, 'hhrrData'),
|
(3, 'Laboral', 37, 37, 'hhrrData'),
|
||||||
(4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote'),
|
(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-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);
|
('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`)
|
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -3831,8 +3825,6 @@ UPDATE vn.collection
|
||||||
UPDATE vn.sale
|
UPDATE vn.sale
|
||||||
SET isPicked =FALSE;
|
SET isPicked =FALSE;
|
||||||
|
|
||||||
INSERT INTO vn.machineWorkerConfig(id, maxHours)
|
|
||||||
VALUES(1, 12);
|
|
||||||
|
|
||||||
INSERT INTO vn.workerAppTester(workerFk) VALUES(66);
|
INSERT INTO vn.workerAppTester(workerFk) VALUES(66);
|
||||||
|
|
||||||
|
@ -3840,9 +3832,6 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen
|
||||||
VALUES
|
VALUES
|
||||||
('RE-003', 'IRON', 'JPH-24', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442);
|
('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.buy SET itemOriginalFk = 1 WHERE id = 1;
|
||||||
|
|
||||||
UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5;
|
UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5;
|
||||||
|
|
|
@ -53,7 +53,7 @@ proc: BEGIN
|
||||||
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
|
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
|
||||||
AND t.warehouseInFk = vWarehouse
|
AND t.warehouseInFk = vWarehouse
|
||||||
AND s.name != 'INVENTARIO'
|
AND s.name != 'INVENTARIO'
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
GROUP BY b.itemFk
|
GROUP BY b.itemFk
|
||||||
) c
|
) c
|
||||||
JOIN vn.item i ON i.id = c.itemFk
|
JOIN vn.item i ON i.id = c.itemFk
|
||||||
|
|
|
@ -6,16 +6,16 @@ BEGIN
|
||||||
|
|
||||||
UPDATE vn.buy b
|
UPDATE vn.buy b
|
||||||
JOIN vn.entry e ON e.id = b.entryFk
|
JOIN vn.entry e ON e.id = b.entryFk
|
||||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||||
JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
|
JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
|
||||||
JOIN vn.item i ON i.id = b.itemFk
|
JOIN vn.item i ON i.id = b.itemFk
|
||||||
JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
|
JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
|
||||||
SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits,
|
SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits,
|
||||||
b.stickers = NEW.NumberOfUnits
|
b.stickers = NEW.NumberOfUnits
|
||||||
WHERE i.supplyResponseFk = NEW.ID
|
WHERE i.supplyResponseFk = NEW.ID
|
||||||
AND am.name = 'LOGIFLORA'
|
AND am.name = 'LOGIFLORA'
|
||||||
AND e.isRaid
|
AND tr.daysInForward
|
||||||
AND tr.landed >= util.VN_CURDATE();
|
AND tr.landed >= util.VN_CURDATE();
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -59,7 +59,7 @@ BEGIN
|
||||||
JOIN vn.travel t ON t.id = e.travelFk
|
JOIN vn.travel t ON t.id = e.travelFk
|
||||||
WHERE t.landed BETWEEN vDateInv AND vDate
|
WHERE t.landed BETWEEN vDateInv AND vDate
|
||||||
AND t.warehouseInFk = vWarehouse
|
AND t.warehouseInFk = vWarehouse
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, -b.quantity
|
SELECT b.itemFk, -b.quantity
|
||||||
FROM vn.buy b
|
FROM vn.buy b
|
||||||
|
@ -67,7 +67,7 @@ BEGIN
|
||||||
JOIN vn.travel t ON t.id = e.travelFk
|
JOIN vn.travel t ON t.id = e.travelFk
|
||||||
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
|
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
|
||||||
AND t.warehouseOutFk = vWarehouse
|
AND t.warehouseOutFk = vWarehouse
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
AND t.isDelivered
|
AND t.isDelivered
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT m.itemFk, -m.quantity
|
SELECT m.itemFk, -m.quantity
|
||||||
|
|
|
@ -4,5 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeInsert`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
IF NEW.`property` = '*' THEN
|
||||||
|
CALL util.throw('The property field cannot be *');
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
||||||
e.id entryFk,
|
e.id entryFk,
|
||||||
t.id travelFk,
|
t.id travelFk,
|
||||||
b.itemFk,
|
b.itemFk,
|
||||||
e.isRaid,
|
t.daysInForward,
|
||||||
ADDTIME(t.shipped,
|
ADDTIME(t.shipped,
|
||||||
IFNULL(t.shipmentHour, '00:00:00')) shipped,
|
IFNULL(t.shipmentHour, '00:00:00')) shipped,
|
||||||
t.warehouseOutFk,
|
t.warehouseOutFk,
|
||||||
|
@ -50,7 +50,7 @@ BEGIN
|
||||||
itemFk,
|
itemFk,
|
||||||
TIMESTAMPADD(DAY, life, @dated),
|
TIMESTAMPADD(DAY, life, @dated),
|
||||||
quantity,
|
quantity,
|
||||||
IF(isIn, isReceived, isDelivered) AND !isRaid
|
IF(isIn, isReceived, isDelivered) AND NOT daysInForward
|
||||||
FROM tValues
|
FROM tValues
|
||||||
WHERE isIn OR !lessThanInventory;
|
WHERE isIn OR !lessThanInventory;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ BEGIN
|
||||||
itemFk,
|
itemFk,
|
||||||
created,
|
created,
|
||||||
quantity,
|
quantity,
|
||||||
IF(isIn, isDelivered, isReceived) AND !isRaid
|
IF(isIn, isDelivered, isReceived) AND NOT daysInForward
|
||||||
FROM tValues
|
FROM tValues
|
||||||
WHERE !isIn OR !lessThanInventory;
|
WHERE !isIn OR !lessThanInventory;
|
||||||
|
|
||||||
|
|
|
@ -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 ;
|
|
@ -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 ;
|
|
|
@ -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 ;
|
|
|
@ -39,7 +39,7 @@ BEGIN
|
||||||
AND vWarehouseFk IN (tr.warehouseInFk, 0)
|
AND vWarehouseFk IN (tr.warehouseInFk, 0)
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT tr.shipped,
|
SELECT tr.shipped,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -58,7 +58,7 @@ BEGIN
|
||||||
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT t.shipped,
|
SELECT t.shipped,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -81,7 +81,7 @@ BEGIN
|
||||||
FROM tHistoricalPast
|
FROM tHistoricalPast
|
||||||
WHERE `date` < vDate;
|
WHERE `date` < vDate;
|
||||||
|
|
||||||
SELECT p1.*, NULL v_virtual
|
SELECT p1.*, NULL v_virtual
|
||||||
FROM (
|
FROM (
|
||||||
SELECT vDate `date`,
|
SELECT vDate `date`,
|
||||||
vCalculatedInventory input,
|
vCalculatedInventory input,
|
||||||
|
@ -96,7 +96,7 @@ BEGIN
|
||||||
FROM tHistoricalPast
|
FROM tHistoricalPast
|
||||||
WHERE `date` >= vDate
|
WHERE `date` >= vDate
|
||||||
) p1;
|
) p1;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tHistoricalPast;
|
DROP TEMPORARY TABLE tHistoricalPast;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`available_traslate`(
|
||||||
vWarehouseShipment INT)
|
vWarehouseShipment INT)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcular la disponibilidad dependiendo del almacen
|
* Calcular la disponibilidad dependiendo del almacen
|
||||||
* de origen y destino según la fecha.
|
* de origen y destino según la fecha.
|
||||||
*
|
*
|
||||||
* @param vWarehouseLanding Almacén de llegada
|
* @param vWarehouseLanding Almacén de llegada
|
||||||
|
@ -42,10 +42,10 @@ proc: BEGIN
|
||||||
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
|
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
|
||||||
AND t.warehouseInFk = vWarehouseLanding
|
AND t.warehouseInFk = vWarehouseLanding
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
GROUP BY c.itemFk;
|
GROUP BY c.itemFk;
|
||||||
|
|
||||||
-- Tabla con el ultimo dia de last_buy para cada producto
|
-- Tabla con el ultimo dia de last_buy para cada producto
|
||||||
-- que hace un replace de la anterior.
|
-- que hace un replace de la anterior.
|
||||||
CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE());
|
CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE());
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ proc: BEGIN
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
|
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
|
||||||
WHERE t.warehouseFk = vWarehouseShipment
|
WHERE t.warehouseFk = vWarehouseShipment
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
|
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
|
||||||
tr.landed);
|
tr.landed);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ proc: BEGIN
|
||||||
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
|
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
|
||||||
WHERE NOT e.isExcludedFromAvailable
|
WHERE NOT e.isExcludedFromAvailable
|
||||||
AND b.quantity <> 0
|
AND b.quantity <> 0
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
AND t.warehouseInFk = vWarehouseLanding
|
AND t.warehouseInFk = vWarehouseLanding
|
||||||
AND t.landed >= vDatedFrom
|
AND t.landed >= vDatedFrom
|
||||||
AND (ir.dated IS NULL OR t.landed <= ir.dated)
|
AND (ir.dated IS NULL OR t.landed <= ir.dated)
|
||||||
|
@ -135,4 +135,4 @@ proc: BEGIN
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.itemList, tItemRange, tItemRangeLive;
|
DROP TEMPORARY TABLE tmp.itemList, tItemRange, tItemRangeLive;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
|
||||||
vItemFk INT,
|
vItemFk INT,
|
||||||
vWarehouseFk SMALLINT,
|
vWarehouseFk INT,
|
||||||
vDated DATE
|
vDated DATE
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -28,7 +28,7 @@ BEGIN
|
||||||
JOIN agencyMode am ON am.id = tr.agencyModeFk
|
JOIN agencyMode am ON am.id = tr.agencyModeFk
|
||||||
WHERE NOT b.quantity
|
WHERE NOT b.quantity
|
||||||
AND am.code = 'logiflora'
|
AND am.code = 'logiflora'
|
||||||
AND e.isRaid;
|
AND tr.daysInForward;
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
|
|
|
@ -37,23 +37,23 @@ BEGIN
|
||||||
WHERE t.id = vTicketFk;
|
WHERE t.id = vTicketFk;
|
||||||
|
|
||||||
CALL cache.available_refresh(
|
CALL cache.available_refresh(
|
||||||
vCacheAvailableFk,
|
vCacheAvailableFk,
|
||||||
FALSE,
|
FALSE,
|
||||||
vWarehouseFk,
|
vWarehouseFk,
|
||||||
util.VN_CURDATE());
|
util.VN_CURDATE());
|
||||||
|
|
||||||
SELECT available INTO vAvailable
|
SELECT available INTO vAvailable
|
||||||
FROM cache.available
|
FROM cache.available
|
||||||
WHERE calc_id = vCacheAvailableFk
|
WHERE calc_id = vCacheAvailableFk
|
||||||
AND item_id = vItemFk;
|
AND item_id = vItemFk;
|
||||||
|
|
||||||
IF vAvailable < vQuantity THEN
|
IF vAvailable < vQuantity THEN
|
||||||
SET vHasThrow = TRUE;
|
SET vHasThrow = TRUE;
|
||||||
ELSE
|
ELSE
|
||||||
SELECT `name`,
|
SELECT `name`,
|
||||||
CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
|
CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
|
||||||
INTO vItemName, vConcept
|
INTO vItemName, vConcept
|
||||||
FROM item
|
FROM item
|
||||||
WHERE id = vItemFk;
|
WHERE id = vItemFk;
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
@ -69,7 +69,7 @@ BEGIN
|
||||||
|
|
||||||
CALL sale_calculateComponent(vSaleFk, NULL);
|
CALL sale_calculateComponent(vSaleFk, NULL);
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
||||||
|
|
||||||
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
||||||
SET vHasThrow = TRUE;
|
SET vHasThrow = TRUE;
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -78,13 +78,13 @@ BEGIN
|
||||||
IF vHasThrow THEN
|
IF vHasThrow THEN
|
||||||
CALL util.throw("There is no available for the selected item");
|
CALL util.throw("There is no available for the selected item");
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF vSaleGroupFk THEN
|
IF vSaleGroupFk THEN
|
||||||
INSERT INTO saleGroupDetail
|
INSERT INTO saleGroupDetail
|
||||||
SET saleFk = vSaleFk,
|
SET saleFk = vSaleFk,
|
||||||
saleGroupFk = vSaleGroupFk;
|
saleGroupFk = vSaleGroupFk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -30,7 +30,9 @@ BEGIN
|
||||||
t.warehouseFk,
|
t.warehouseFk,
|
||||||
w.id salesPersonFk,
|
w.id salesPersonFk,
|
||||||
IFNULL(ob.description,'') observaciones,
|
IFNULL(ob.description,'') observaciones,
|
||||||
cc.rgb
|
cc.rgb,
|
||||||
|
p.code parkingCode,
|
||||||
|
IF (ps.ticketFk, TRUE, FALSE) isAdvanced
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
|
LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
|
||||||
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
|
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
|
||||||
|
@ -42,7 +44,10 @@ BEGIN
|
||||||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
LEFT JOIN vn.client c ON c.id = t.clientFk
|
||||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
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
|
WHERE t.id = vParamFk
|
||||||
AND t.shipped >= vYesterday
|
AND t.shipped >= vYesterday
|
||||||
UNION
|
UNION
|
||||||
|
@ -52,7 +57,9 @@ BEGIN
|
||||||
t.warehouseFk,
|
t.warehouseFk,
|
||||||
w.id salesPersonFk,
|
w.id salesPersonFk,
|
||||||
ob.description,
|
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
|
FROM vn.ticket t
|
||||||
JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
|
JOIN vn.ticketCollection tc ON t.id = tc.ticketFk
|
||||||
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
|
LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk
|
||||||
|
@ -64,7 +71,10 @@ BEGIN
|
||||||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
LEFT JOIN vn.client c ON c.id = t.clientFk
|
||||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
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
|
WHERE tc.collectionFk = vParamFk
|
||||||
UNION
|
UNION
|
||||||
SELECT sg.ticketFk,
|
SELECT sg.ticketFk,
|
||||||
|
@ -73,7 +83,9 @@ BEGIN
|
||||||
t.warehouseFk,
|
t.warehouseFk,
|
||||||
c.salesPersonFk,
|
c.salesPersonFk,
|
||||||
ob.description,
|
ob.description,
|
||||||
NULL `rgb`
|
NULL `rgb`,
|
||||||
|
p.code parkingCode,
|
||||||
|
IF (ps.ticketFk, TRUE, FALSE) isAdvanced
|
||||||
FROM vn.sectorCollection sc
|
FROM vn.sectorCollection sc
|
||||||
JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
|
JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
|
||||||
JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk
|
JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk
|
||||||
|
@ -81,7 +93,10 @@ BEGIN
|
||||||
LEFT JOIN vn.zone z ON z.id = t.zoneFk
|
LEFT JOIN vn.zone z ON z.id = t.zoneFk
|
||||||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
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
|
WHERE sc.id = vParamFk
|
||||||
AND t.shipped >= vYesterday
|
AND t.shipped >= vYesterday
|
||||||
GROUP BY ticketFk;
|
GROUP BY ticketFk;
|
||||||
|
|
|
@ -17,7 +17,6 @@ BEGIN
|
||||||
supplierFk,
|
supplierFk,
|
||||||
dated,
|
dated,
|
||||||
isExcludedFromAvailable,
|
isExcludedFromAvailable,
|
||||||
isRaid,
|
|
||||||
commission,
|
commission,
|
||||||
currencyFk,
|
currencyFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
|
@ -28,7 +27,6 @@ BEGIN
|
||||||
supplierFk,
|
supplierFk,
|
||||||
dated,
|
dated,
|
||||||
isExcludedFromAvailable,
|
isExcludedFromAvailable,
|
||||||
isRaid,
|
|
||||||
commission,
|
commission,
|
||||||
currencyFk,
|
currencyFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
|
|
|
@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_getTransfer`(
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Retorna los artículos trasladables a partir de una entrada.
|
* Retorna los artículos trasladables a partir de una entrada.
|
||||||
*
|
*
|
||||||
* @param vSelf Id de entrada
|
* @param vSelf Id de entrada
|
||||||
*/
|
*/
|
||||||
DECLARE vDateShipped DATE;
|
DECLARE vDateShipped DATE;
|
||||||
|
@ -166,7 +166,7 @@ BEGIN
|
||||||
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
|
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
|
||||||
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
|
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
|
||||||
WHERE ic.display
|
WHERE ic.display
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
AND (ti.visible OR ti.available)
|
AND (ti.visible OR ti.available)
|
||||||
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;
|
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ BEGIN
|
||||||
a.nickname,
|
a.nickname,
|
||||||
sub2.itemPackingTypeConcat,
|
sub2.itemPackingTypeConcat,
|
||||||
est.code,
|
est.code,
|
||||||
es.isScanned
|
es2.isScanned,
|
||||||
|
es2.scanOrder
|
||||||
FROM expedition e
|
FROM expedition e
|
||||||
JOIN ticket t ON t.id = e.ticketFk
|
JOIN ticket t ON t.id = e.ticketFk
|
||||||
JOIN ticketState ts ON ts.ticketFk = e.ticketFk
|
JOIN ticketState ts ON ts.ticketFk = e.ticketFk
|
||||||
|
@ -38,6 +39,7 @@ BEGIN
|
||||||
SELECT MAX(id)
|
SELECT MAX(id)
|
||||||
FROM expeditionState es
|
FROM expeditionState es
|
||||||
WHERE expeditionFk = e.id)
|
WHERE expeditionFk = e.id)
|
||||||
|
LEFT JOIN expeditionState es2 ON es2.id = es.id
|
||||||
WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE
|
WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE
|
||||||
ORDER BY r.created, t.priority DESC;
|
ORDER BY r.created, t.priority DESC;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -137,7 +137,7 @@ BEGIN
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
WHERE tr.warehouseInFk = vWarehouseFk
|
WHERE tr.warehouseInFk = vWarehouseFk
|
||||||
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
|
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
|
||||||
AND NOT isRaid
|
AND NOT tr.daysInForward
|
||||||
GROUP BY b.itemFk;
|
GROUP BY b.itemFk;
|
||||||
|
|
||||||
-- Transfers
|
-- Transfers
|
||||||
|
@ -150,7 +150,7 @@ BEGIN
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
WHERE tr.warehouseOutFk = vWarehouseFk
|
WHERE tr.warehouseOutFk = vWarehouseFk
|
||||||
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
|
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
|
||||||
AND NOT isRaid
|
AND NOT tr.daysInForward
|
||||||
GROUP BY b.itemFk
|
GROUP BY b.itemFk
|
||||||
) sub
|
) sub
|
||||||
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
|
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
|
||||||
|
|
|
@ -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 ;
|
|
@ -18,8 +18,9 @@ proc: BEGIN
|
||||||
DECLARE vReservedQuantity INT;
|
DECLARE vReservedQuantity INT;
|
||||||
DECLARE vOutStanding INT;
|
DECLARE vOutStanding INT;
|
||||||
DECLARE vUserFk INT;
|
DECLARE vUserFk INT;
|
||||||
DECLARE vTotalReservedQuantity INT;
|
DECLARE vTotalReservedQuantity INT;
|
||||||
DECLARE vSaleQuantity INT;
|
DECLARE vSaleQuantity INT;
|
||||||
|
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
|
||||||
|
|
||||||
DECLARE vItemShelvingAvailable CURSOR FOR
|
DECLARE vItemShelvingAvailable CURSOR FOR
|
||||||
SELECT ish.id itemShelvingFk,
|
SELECT ish.id itemShelvingFk,
|
||||||
|
@ -29,7 +30,7 @@ proc: BEGIN
|
||||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||||
JOIN parking p ON p.id = sh.parkingFk
|
JOIN parking p ON p.id = sh.parkingFk
|
||||||
JOIN sector sc ON sc.id = p.sectorFk
|
JOIN sector sc ON sc.id = p.sectorFk
|
||||||
JOIN productionConfig pc
|
JOIN productionConfig pc
|
||||||
WHERE s.id = vSaleFk
|
WHERE s.id = vSaleFk
|
||||||
AND NOT sc.isHideForPickers
|
AND NOT sc.isHideForPickers
|
||||||
AND (sc.id = vSectorFk OR vSectorFk IS NULL)
|
AND (sc.id = vSectorFk OR vSectorFk IS NULL)
|
||||||
|
@ -44,15 +45,15 @@ proc: BEGIN
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
CALL util.tx_rollback(vIsRequiredTx);
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
START TRANSACTION;
|
CALL util.tx_start(vIsRequiredTx);
|
||||||
|
|
||||||
SELECT id INTO vSaleFk
|
SELECT id INTO vSaleFk
|
||||||
FROM sale
|
FROM sale
|
||||||
WHERE id = vSaleFk
|
WHERE id = vSaleFk
|
||||||
FOR UPDATE;
|
FOR UPDATE;
|
||||||
|
|
||||||
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
|
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
|
||||||
|
@ -65,7 +66,7 @@ proc: BEGIN
|
||||||
WHERE s.id = vSaleFk;
|
WHERE s.id = vSaleFk;
|
||||||
|
|
||||||
IF vOutStanding <= 0 THEN
|
IF vOutStanding <= 0 THEN
|
||||||
COMMIT;
|
CALL util.tx_commit(vIsRequiredTx);
|
||||||
LEAVE proc;
|
LEAVE proc;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ proc: BEGIN
|
||||||
IF vTotalReservedQuantity <> vSaleQuantity THEN
|
IF vTotalReservedQuantity <> vSaleQuantity THEN
|
||||||
CALL util.debugAdd('itemShelvingSale_addBySale',
|
CALL util.debugAdd('itemShelvingSale_addBySale',
|
||||||
CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId()));
|
CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId()));
|
||||||
|
|
||||||
UPDATE sale
|
UPDATE sale
|
||||||
SET quantity = vTotalReservedQuantity
|
SET quantity = vTotalReservedQuantity
|
||||||
WHERE id = vSaleFk;
|
WHERE id = vSaleFk;
|
||||||
|
@ -93,7 +94,7 @@ proc: BEGIN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT id INTO vItemShelvingFk
|
SELECT id INTO vItemShelvingFk
|
||||||
FROM itemShelving
|
FROM itemShelving
|
||||||
WHERE id = vItemShelvingFk
|
WHERE id = vItemShelvingFk
|
||||||
FOR UPDATE;
|
FOR UPDATE;
|
||||||
|
@ -102,19 +103,19 @@ proc: BEGIN
|
||||||
SET vOutStanding = vOutStanding - vReservedQuantity;
|
SET vOutStanding = vOutStanding - vReservedQuantity;
|
||||||
|
|
||||||
IF vReservedQuantity > 0 THEN
|
IF vReservedQuantity > 0 THEN
|
||||||
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
|
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
|
||||||
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
|
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
|
||||||
INSERT INTO itemShelvingSale(
|
INSERT INTO itemShelvingSale(
|
||||||
itemShelvingFk,
|
itemShelvingFk,
|
||||||
saleFk,
|
saleFk,
|
||||||
quantity,
|
quantity,
|
||||||
userFk,
|
userFk,
|
||||||
isPicked)
|
isPicked)
|
||||||
SELECT vItemShelvingFk,
|
SELECT vItemShelvingFk,
|
||||||
vSaleFk,
|
vSaleFk,
|
||||||
vReservedQuantity,
|
vReservedQuantity,
|
||||||
vUserFk,
|
vUserFk,
|
||||||
FALSE;
|
FALSE;
|
||||||
|
|
||||||
UPDATE itemShelving
|
UPDATE itemShelving
|
||||||
SET available = available - vReservedQuantity
|
SET available = available - vReservedQuantity
|
||||||
|
@ -123,6 +124,6 @@ proc: BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vItemShelvingAvailable;
|
CLOSE vItemShelvingAvailable;
|
||||||
COMMIT;
|
CALL util.tx_commit(vIsRequiredTx);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -7,9 +7,10 @@ BEGIN
|
||||||
* @param vSelf matrícula del carro
|
* @param vSelf matrícula del carro
|
||||||
**/
|
**/
|
||||||
SELECT ish.itemFk item,
|
SELECT ish.itemFk item,
|
||||||
IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) description,
|
i.name,
|
||||||
|
i.longName,
|
||||||
|
i.size,
|
||||||
ish.visible,
|
ish.visible,
|
||||||
CEIL(ish.visible/ish.packing) stickers,
|
|
||||||
ish.packing,
|
ish.packing,
|
||||||
ish.grouping,
|
ish.grouping,
|
||||||
p.code,
|
p.code,
|
||||||
|
@ -17,7 +18,8 @@ BEGIN
|
||||||
s.priority,
|
s.priority,
|
||||||
ish.isChecked,
|
ish.isChecked,
|
||||||
ic.url,
|
ic.url,
|
||||||
ish.available
|
ish.available,
|
||||||
|
ish.buyFk
|
||||||
FROM itemShelving ish
|
FROM itemShelving ish
|
||||||
JOIN item i ON i.id = ish.itemFk
|
JOIN item i ON i.id = ish.itemFk
|
||||||
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
|
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
|
||||||
|
|
|
@ -50,16 +50,16 @@ BEGIN
|
||||||
JOIN vn.entry e ON e.id = b.entryFk
|
JOIN vn.entry e ON e.id = b.entryFk
|
||||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||||
JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE()
|
JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE()
|
||||||
OR (util.VN_CURDATE() AND tr.isReceived),
|
OR (util.VN_CURDATE() AND tr.isReceived),
|
||||||
'DELIVERED',
|
'DELIVERED',
|
||||||
'FREE')
|
'FREE')
|
||||||
WHERE tr.landed >= vDateInventory
|
WHERE tr.landed >= vDateInventory
|
||||||
AND tr.warehouseInFk = vWarehouseFk
|
AND tr.warehouseInFk = vWarehouseFk
|
||||||
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
|
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
),
|
),
|
||||||
entriesOut AS (
|
entriesOut AS (
|
||||||
SELECT 'entry',
|
SELECT 'entry',
|
||||||
|
@ -95,7 +95,7 @@ BEGIN
|
||||||
AND b.itemFk = vItemFk
|
AND b.itemFk = vItemFk
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT w.isFeedStock
|
AND NOT w.isFeedStock
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
),
|
),
|
||||||
sales AS (
|
sales AS (
|
||||||
WITH itemSales AS (
|
WITH itemSales AS (
|
||||||
|
@ -147,10 +147,10 @@ BEGIN
|
||||||
NULL
|
NULL
|
||||||
FROM itemSales s
|
FROM itemSales s
|
||||||
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
|
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
|
||||||
LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
|
LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
|
||||||
AND stk.stateFk = stPrep.id
|
AND stk.stateFk = stPrep.id
|
||||||
GROUP BY s.saleFk
|
GROUP BY s.saleFk
|
||||||
),
|
),
|
||||||
orders AS (
|
orders AS (
|
||||||
SELECT 'order' originType,
|
SELECT 'order' originType,
|
||||||
o.id originId,
|
o.id originId,
|
||||||
|
@ -215,9 +215,9 @@ BEGIN
|
||||||
t.`in` invalue,
|
t.`in` invalue,
|
||||||
t.`out`,
|
t.`out`,
|
||||||
@a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance,
|
@a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance,
|
||||||
@currentLineFk := IF (@shipped < util.VN_CURDATE()
|
@currentLineFk := IF (@shipped < util.VN_CURDATE()
|
||||||
OR (@shipped = util.VN_CURDATE() AND (t.isPicked OR a.`code` >= 'ON_PREPARATION')),
|
OR (@shipped = util.VN_CURDATE() AND (t.isPicked OR a.`code` >= 'ON_PREPARATION')),
|
||||||
t.lineFk,
|
t.lineFk,
|
||||||
@currentLineFk) lastPreparedLineFk,
|
@currentLineFk) lastPreparedLineFk,
|
||||||
t.isTicket,
|
t.isTicket,
|
||||||
t.lineFk,
|
t.lineFk,
|
||||||
|
@ -254,21 +254,21 @@ BEGIN
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT originType,
|
SELECT originType,
|
||||||
originId,
|
originId,
|
||||||
shipped,
|
shipped,
|
||||||
alertlevel,
|
alertlevel,
|
||||||
stateName,
|
stateName,
|
||||||
reference,
|
reference,
|
||||||
entityType,
|
entityType,
|
||||||
entityId,
|
entityId,
|
||||||
entityName,
|
entityName,
|
||||||
`in`,
|
`in`,
|
||||||
`out`,
|
`out`,
|
||||||
@a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0),
|
@a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0),
|
||||||
0,
|
0,
|
||||||
isTicket,
|
isTicket,
|
||||||
lineFk,
|
lineFk,
|
||||||
isPicked,
|
isPicked,
|
||||||
clientType,
|
clientType,
|
||||||
claimFk,
|
claimFk,
|
||||||
`order`
|
`order`
|
||||||
FROM tItemDiary
|
FROM tItemDiary
|
||||||
|
|
|
@ -63,7 +63,7 @@ BEGIN
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND b.quantity <> 0
|
AND b.quantity <> 0
|
||||||
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT r.itemFk,
|
SELECT r.itemFk,
|
||||||
r.shipment,
|
r.shipment,
|
||||||
|
|
|
@ -17,22 +17,22 @@ BEGIN
|
||||||
|
|
||||||
ALTER TABLE tmp.itemInventory
|
ALTER TABLE tmp.itemInventory
|
||||||
ADD `buy_date` datetime NOT NULL;
|
ADD `buy_date` datetime NOT NULL;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE lastBuyScope
|
CREATE OR REPLACE TEMPORARY TABLE lastBuyScope
|
||||||
SELECT i.id, MAX(t.landed) lastLanded
|
SELECT i.id, MAX(t.landed) lastLanded
|
||||||
FROM item i
|
FROM item i
|
||||||
JOIN buy b ON b.itemFk = i.id
|
JOIN buy b ON b.itemFk = i.id
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN supplier s ON s.id = e.supplierFk
|
JOIN supplier s ON s.id = e.supplierFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||||
WHERE t.landed BETWEEN (vDated + INTERVAL - vLastBuyScope DAY) AND vDated
|
WHERE t.landed BETWEEN (vDated + INTERVAL - vLastBuyScope DAY) AND vDated
|
||||||
AND NOT s.name = 'INVENTARIO'
|
AND NOT s.name = 'INVENTARIO'
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
GROUP BY i.id;
|
GROUP BY i.id;
|
||||||
|
|
||||||
UPDATE tmp.itemInventory y
|
UPDATE tmp.itemInventory y
|
||||||
JOIN lastBuyScope lbs ON lbs.id = y.id
|
JOIN lastBuyScope lbs ON lbs.id = y.id
|
||||||
SET y.buy_date = lbs.lastLanded;
|
SET y.buy_date = lbs.lastLanded;
|
||||||
|
|
|
@ -25,7 +25,7 @@ BEGIN
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
SET vHasNotInventory = (vInventoried IS NULL);
|
SET vHasNotInventory = (vInventoried IS NULL);
|
||||||
|
|
||||||
IF vHasNotInventory THEN
|
IF vHasNotInventory THEN
|
||||||
SELECT landed INTO vInventoryClone
|
SELECT landed INTO vInventoryClone
|
||||||
FROM travel tr
|
FROM travel tr
|
||||||
|
@ -50,7 +50,7 @@ BEGIN
|
||||||
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
|
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
|
||||||
)
|
)
|
||||||
ENGINE = MEMORY;
|
ENGINE = MEMORY;
|
||||||
|
|
||||||
-- Inventario inicial
|
-- Inventario inicial
|
||||||
IF vHasNotInventory THEN
|
IF vHasNotInventory THEN
|
||||||
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
||||||
|
@ -109,7 +109,7 @@ BEGIN
|
||||||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||||
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
|
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
|
||||||
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
|
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
AND e.supplierFk <> vInventorySupplierFk
|
AND e.supplierFk <> vInventorySupplierFk
|
||||||
|
@ -131,7 +131,7 @@ BEGIN
|
||||||
JOIN itemCategory ic ON ic.id = t.categoryFk
|
JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||||
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
||||||
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
|
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
|
||||||
AND NOT e.isRaid
|
AND NOT tr.daysInForward
|
||||||
AND w.valuatedInventory
|
AND w.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
|
@ -159,7 +159,7 @@ BEGIN
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1);
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1);
|
||||||
|
|
||||||
-- Volver a poner lo que esta aun en las estanterias
|
-- Volver a poner lo que esta aun en las estanterias
|
||||||
IF vDated = util.VN_CURDATE() THEN
|
IF vDated = util.VN_CURDATE() THEN
|
||||||
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory)
|
||||||
SELECT w.id,
|
SELECT w.id,
|
||||||
s.itemFk,
|
s.itemFk,
|
||||||
|
@ -196,14 +196,14 @@ BEGIN
|
||||||
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
|
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
|
||||||
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
|
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
|
||||||
WHERE vDated >= tr.shipped AND vDated < tr.landed
|
WHERE vDated >= tr.shipped AND vDated < tr.landed
|
||||||
AND NOT isRaid
|
AND NOT tr.daysInForward
|
||||||
AND wIn.valuatedInventory
|
AND wIn.valuatedInventory
|
||||||
AND t.isInventory
|
AND t.isInventory
|
||||||
AND e.isConfirmed
|
AND e.isConfirmed
|
||||||
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||||
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL)
|
||||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
|
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
|
||||||
|
|
||||||
CALL buy_getUltimate (NULL, NULL, vDateDayEnd);
|
CALL buy_getUltimate (NULL, NULL, vDateDayEnd);
|
||||||
|
|
||||||
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
|
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
|
||||||
|
@ -233,7 +233,7 @@ BEGIN
|
||||||
JOIN warehouse w ON w.id = warehouseFk
|
JOIN warehouse w ON w.id = warehouseFk
|
||||||
JOIN item i ON i.id = ti.itemFk
|
JOIN item i ON i.id = ti.itemFk
|
||||||
JOIN itemType tp ON tp.id = i.typeFk
|
JOIN itemType tp ON tp.id = i.typeFk
|
||||||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||||
WHERE w.valuatedInventory
|
WHERE w.valuatedInventory
|
||||||
AND ti.total > 0;
|
AND ti.total > 0;
|
||||||
|
|
||||||
|
|
|
@ -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 ;
|
|
|
@ -1,173 +1,173 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`multipleInventory`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`multipleInventory`(
|
||||||
vDate DATE,
|
vDate DATE,
|
||||||
vWarehouseFk TINYINT,
|
vWarehouseFk TINYINT,
|
||||||
vMaxDays TINYINT
|
vMaxDays TINYINT
|
||||||
)
|
)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY;
|
DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY;
|
||||||
DECLARE vDateFrom DATE DEFAULT vDate;
|
DECLARE vDateFrom DATE DEFAULT vDate;
|
||||||
DECLARE vDateTo DATETIME;
|
DECLARE vDateTo DATETIME;
|
||||||
DECLARE vDateToTomorrow DATETIME;
|
DECLARE vDateToTomorrow DATETIME;
|
||||||
DECLARE vDefaultDayRange INT;
|
DECLARE vDefaultDayRange INT;
|
||||||
DECLARE vCalcFk INT;
|
DECLARE vCalcFk INT;
|
||||||
|
|
||||||
IF vDate < util.VN_CURDATE() THEN
|
IF vDate < util.VN_CURDATE() THEN
|
||||||
LEAVE proc;
|
LEAVE proc;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF vDate = util.VN_CURDATE() THEN
|
IF vDate = util.VN_CURDATE() THEN
|
||||||
SELECT inventoried INTO vDateFrom
|
SELECT inventoried INTO vDateFrom
|
||||||
FROM config;
|
FROM config;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT defaultDayRange INTO vDefaultDayRange
|
SELECT defaultDayRange INTO vDefaultDayRange
|
||||||
FROM comparativeConfig;
|
FROM comparativeConfig;
|
||||||
|
|
||||||
SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY;
|
SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY;
|
||||||
SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY;
|
SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY;
|
||||||
|
|
||||||
ALTER TABLE tmp.itemInventory
|
ALTER TABLE tmp.itemInventory
|
||||||
ADD `avalaible` INT NOT NULL,
|
ADD `avalaible` INT NOT NULL,
|
||||||
ADD `sd` INT NOT NULL,
|
ADD `sd` INT NOT NULL,
|
||||||
ADD `rest` INT NOT NULL,
|
ADD `rest` INT NOT NULL,
|
||||||
ADD `expected` INT NOT NULL,
|
ADD `expected` INT NOT NULL,
|
||||||
ADD `inventory` INT NOT NULL,
|
ADD `inventory` INT NOT NULL,
|
||||||
ADD `visible` INT NOT NULL,
|
ADD `visible` INT NOT NULL,
|
||||||
ADD `life` TINYINT NOT NULL DEFAULT '0';
|
ADD `life` TINYINT NOT NULL DEFAULT '0';
|
||||||
|
|
||||||
-- Calculo del inventario
|
-- Calculo del inventario
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc
|
CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc
|
||||||
(PRIMARY KEY (itemFk))
|
(PRIMARY KEY (itemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT itemFk,
|
SELECT itemFk,
|
||||||
SUM(quantity) quantity
|
SUM(quantity) quantity
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.itemFk, - s.quantity quantity
|
SELECT s.itemFk, - s.quantity quantity
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseFk
|
JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
|
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
|
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, b.quantity
|
SELECT b.itemFk, b.quantity
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||||
WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate)
|
WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate)
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, - b.quantity
|
SELECT b.itemFk, - b.quantity
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseOutFk
|
JOIN warehouse w ON w.id = t.warehouseOutFk
|
||||||
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
|
WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate)
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
) sub
|
) sub
|
||||||
GROUP BY itemFk;
|
GROUP BY itemFk;
|
||||||
|
|
||||||
-- Cálculo del visible
|
-- Cálculo del visible
|
||||||
CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk);
|
CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
|
CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
|
||||||
(PRIMARY KEY (item_id))
|
(PRIMARY KEY (item_id))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT item_id, visible
|
SELECT item_id, visible
|
||||||
FROM cache.visible
|
FROM cache.visible
|
||||||
WHERE calc_id = vCalcFk;
|
WHERE calc_id = vCalcFk;
|
||||||
|
|
||||||
UPDATE tmp.itemInventory it
|
UPDATE tmp.itemInventory it
|
||||||
LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id
|
LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id
|
||||||
LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id
|
LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id
|
||||||
SET it.inventory = iic.quantity,
|
SET it.inventory = iic.quantity,
|
||||||
it.visible = ivc.visible,
|
it.visible = ivc.visible,
|
||||||
it.avalaible = iic.quantity,
|
it.avalaible = iic.quantity,
|
||||||
it.sd = iic.quantity;
|
it.sd = iic.quantity;
|
||||||
|
|
||||||
-- Calculo del disponible
|
-- Calculo del disponible
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
|
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
|
||||||
(INDEX (itemFk, warehouseFk))
|
(INDEX (itemFk, warehouseFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT sub.itemFk,
|
SELECT sub.itemFk,
|
||||||
vWarehouseFk warehouseFk,
|
vWarehouseFk warehouseFk,
|
||||||
sub.dated,
|
sub.dated,
|
||||||
SUM(sub.quantity) quantity
|
SUM(sub.quantity) quantity
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.itemFk,
|
SELECT s.itemFk,
|
||||||
DATE(t.shipped) dated,
|
DATE(t.shipped) dated,
|
||||||
- s.quantity quantity
|
- s.quantity quantity
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseFk
|
JOIN warehouse w ON w.id = t.warehouseFk
|
||||||
WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
|
WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
|
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, t.landed, b.quantity
|
SELECT b.itemFk, t.landed, b.quantity
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||||
WHERE t.landed BETWEEN vDateTomorrow AND vDateTo
|
WHERE t.landed BETWEEN vDateTomorrow AND vDateTo
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT b.itemFk, t.shipped, - b.quantity
|
SELECT b.itemFk, t.shipped, - b.quantity
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
JOIN warehouse w ON w.id = t.warehouseOutFk
|
JOIN warehouse w ON w.id = t.warehouseOutFk
|
||||||
WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
|
WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo
|
||||||
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND NOT e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND NOT e.isRaid
|
AND NOT t.daysInForward
|
||||||
) sub
|
) sub
|
||||||
GROUP BY sub.itemFk, sub.dated;
|
GROUP BY sub.itemFk, sub.dated;
|
||||||
|
|
||||||
CALL item_getAtp(vDate);
|
CALL item_getAtp(vDate);
|
||||||
CALL travel_upcomingArrivals(vWarehouseFk, vDate);
|
CALL travel_upcomingArrivals(vWarehouseFk, vDate);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
|
CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
|
||||||
(PRIMARY KEY (itemFk))
|
(PRIMARY KEY (itemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT it.itemFk,
|
SELECT it.itemFk,
|
||||||
SUM(it.quantity) quantity,
|
SUM(it.quantity) quantity,
|
||||||
im.quantity minQuantity
|
im.quantity minQuantity
|
||||||
FROM tmp.itemCalc it
|
FROM tmp.itemCalc it
|
||||||
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
|
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
|
||||||
JOIN item i ON i.id = it.itemFk
|
JOIN item i ON i.id = it.itemFk
|
||||||
LEFT JOIN origin o ON o.id = i.originFk
|
LEFT JOIN origin o ON o.id = i.originFk
|
||||||
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
|
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
|
||||||
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
|
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
|
||||||
t.landing,
|
t.landing,
|
||||||
vDateToTomorrow)
|
vDateToTomorrow)
|
||||||
GROUP BY it.itemFk;
|
GROUP BY it.itemFk;
|
||||||
|
|
||||||
UPDATE tmp.itemInventory it
|
UPDATE tmp.itemInventory it
|
||||||
JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
|
JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
|
||||||
SET it.avalaible = IF(iac.minQuantity > 0,
|
SET it.avalaible = IF(iac.minQuantity > 0,
|
||||||
it.avalaible,
|
it.avalaible,
|
||||||
it.avalaible + iac.minQuantity),
|
it.avalaible + iac.minQuantity),
|
||||||
it.sd = it.inventory + iac.quantity;
|
it.sd = it.inventory + iac.quantity;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tmp.itemTravel,
|
tmp.itemTravel,
|
||||||
tmp.itemCalc,
|
tmp.itemCalc,
|
||||||
tmp.itemAtp,
|
tmp.itemAtp,
|
||||||
tItemInventoryCalc,
|
tItemInventoryCalc,
|
||||||
tItemVisibleCalc,
|
tItemVisibleCalc,
|
||||||
tItemAvailableCalc;
|
tItemAvailableCalc;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -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 ;
|
|
|
@ -51,7 +51,8 @@ BEGIN
|
||||||
origin.companyFk futureCompanyFk,
|
origin.companyFk futureCompanyFk,
|
||||||
IFNULL(dest.nickname, origin.nickname) nickname,
|
IFNULL(dest.nickname, origin.nickname) nickname,
|
||||||
dest.landed,
|
dest.landed,
|
||||||
dest.preparation
|
dest.preparation,
|
||||||
|
origin.departmentFk
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.ticketFk,
|
SELECT s.ticketFk,
|
||||||
c.salesPersonFk workerFk,
|
c.salesPersonFk workerFk,
|
||||||
|
@ -71,9 +72,11 @@ BEGIN
|
||||||
t.addressFk,
|
t.addressFk,
|
||||||
t.warehouseFk,
|
t.warehouseFk,
|
||||||
t.companyFk,
|
t.companyFk,
|
||||||
t.agencyModeFk
|
t.agencyModeFk,
|
||||||
|
wd.departmentFk
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
JOIN client c ON c.id = t.clientFk
|
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 sale s ON s.ticketFk = t.id
|
||||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
|
|
@ -10,7 +10,7 @@ BEGIN
|
||||||
JOIN vn.entry e ON e.travelFk = tr.id
|
JOIN vn.entry e ON e.travelFk = tr.id
|
||||||
JOIN vn.buy b ON b.entryFk = e.id
|
JOIN vn.buy b ON b.entryFk = e.id
|
||||||
WHERE tr.landed BETWEEN vFromDated AND vToDated
|
WHERE tr.landed BETWEEN vFromDated AND vToDated
|
||||||
AND e.isRaid = FALSE
|
AND NOT tr.daysInForward
|
||||||
AND tr.warehouseInFk = vWarehouseFk
|
AND tr.warehouseInFk = vWarehouseFk
|
||||||
GROUP BY tr.landed , a.name ;
|
GROUP BY tr.landed , a.name ;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -62,7 +62,7 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL entry_cloneHeader(vAuxEntryFk, vNewEntryFk, vNewTravelFk);
|
CALL entry_cloneHeader(vAuxEntryFk, vNewEntryFk, vNewTravelFk);
|
||||||
CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
|
CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
|
||||||
|
|
||||||
SELECT evaNotes INTO vEvaNotes
|
SELECT evaNotes INTO vEvaNotes
|
||||||
FROM entry
|
FROM entry
|
||||||
|
@ -71,6 +71,8 @@ BEGIN
|
||||||
UPDATE entry
|
UPDATE entry
|
||||||
SET evaNotes = vEvaNotes
|
SET evaNotes = vEvaNotes
|
||||||
WHERE id = vNewEntryFk;
|
WHERE id = vNewEntryFk;
|
||||||
|
|
||||||
|
CALL buy_recalcPricesByEntry(vNewEntryFk);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
SET @isModeInventory = FALSE;
|
SET @isModeInventory = FALSE;
|
||||||
|
|
|
@ -1,72 +1,68 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`()
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`()
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
/*
|
* Desplaza los travels en el futuro y avisa a los compradores
|
||||||
* Desplaza al dia siguiente los travels que contengan redadas y avisa a los compradores
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DECLARE vDone BOOL DEFAULT FALSE;
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
DECLARE vWorkerName VARCHAR(50);
|
DECLARE vBuyerEmail VARCHAR(40);
|
||||||
DECLARE vRaid TEXT;
|
DECLARE vTravelLink TEXT;
|
||||||
DECLARE vWorker VARCHAR(50) DEFAULT '';
|
|
||||||
DECLARE vMailBody TEXT DEFAULT '';
|
DECLARE vMailBody TEXT DEFAULT '';
|
||||||
|
|
||||||
DECLARE vCur CURSOR FOR
|
DECLARE vCur CURSOR FOR
|
||||||
SELECT GROUP_CONCAT( DISTINCT CONCAT('https://salix.verdnatura.es/#!/travel/', ttr.id, '/summary ') ORDER BY ttr.id SEPARATOR '\n\r'),
|
SELECT GROUP_CONCAT(DISTINCT
|
||||||
u.name
|
CONCAT('https://salix.verdnatura.es/#!/travel/',
|
||||||
FROM tmp.travel ttr
|
ttm.travelFk,
|
||||||
JOIN entry e ON e.travelFk = ttr.id
|
'/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 buy b ON b.entryFk = e.id
|
||||||
JOIN item i ON i.id = b.itemFk
|
JOIN item i ON i.id = b.itemFk
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
JOIN account.user u ON u.id = it.workerFk
|
JOIN account.user u ON u.id = it.workerFk
|
||||||
GROUP BY u.name;
|
GROUP BY u.name;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
SET vDone = TRUE;
|
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.travel;
|
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
|
||||||
CREATE TEMPORARY TABLE tmp.travel
|
SELECT id travelFk,
|
||||||
SELECT tr.id,tr.landed
|
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
|
||||||
FROM travel tr
|
FROM travel
|
||||||
JOIN entry e ON e.travelFk = tr.id
|
WHERE daysInForward;
|
||||||
WHERE tr.landed = util.tomorrow()
|
|
||||||
AND e.isRaid
|
|
||||||
GROUP BY tr.id;
|
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
UPDATE travel tr
|
UPDATE travel tr
|
||||||
JOIN tmp.travel ttr ON ttr.id = tr.id
|
JOIN tTravelToMove ttm ON ttm.travelFk = tr.id
|
||||||
SET tr.landed = TIMESTAMPADD(DAY, 1, tr.landed);
|
SET tr.landed = ttm.newLanded;
|
||||||
|
|
||||||
OPEN vCur;
|
OPEN vCur;
|
||||||
|
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vCur INTO vRaid, vWorkerName;
|
FETCH vCur INTO vTravelLink, vBuyerEmail;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL `vn`.`mail_insert`(CONCAT(vWorkerName, '@verdnatura.es'),
|
CALL `vn`.`mail_insert`(
|
||||||
'noreply@verdnatura.es',
|
vBuyerEmail,
|
||||||
'Cambio de fecha en Redadas',
|
'noreply@verdnatura.es',
|
||||||
CONCAT('Se ha movido las siguientes redadas: \n\r ', vRaid)
|
'Cambio de fecha en Redadas',
|
||||||
);
|
CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink));
|
||||||
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vCur;
|
CLOSE vCur;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
DROP TEMPORARY TABLE tmp.travel;
|
DROP TEMPORARY TABLE tTravelToMove;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate`
|
||||||
BEFORE UPDATE ON `entry`
|
BEFORE UPDATE ON `entry`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vIsVirtual BOOL;
|
DECLARE vDaysInForward INT;
|
||||||
DECLARE vPrintedCount INT;
|
DECLARE vPrintedCount INT;
|
||||||
DECLARE vHasDistinctWarehouses BOOL;
|
DECLARE vHasDistinctWarehouses BOOL;
|
||||||
DECLARE vTotalBuy INT;
|
DECLARE vTotalBuy INT;
|
||||||
|
@ -37,18 +37,20 @@ BEGIN
|
||||||
IF NEW.travelFk IS NOT NULL THEN
|
IF NEW.travelFk IS NOT NULL THEN
|
||||||
CALL travel_throwAwb(NEW.travelFk);
|
CALL travel_throwAwb(NEW.travelFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) > 0 INTO vIsVirtual
|
SELECT daysInForward INTO vDaysInForward
|
||||||
FROM entryVirtual WHERE entryFk = NEW.id;
|
FROM travel t
|
||||||
|
JOIN entry e ON e.travelFk = t.id
|
||||||
|
WHERE entryFk = NEW.id;
|
||||||
|
|
||||||
SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
|
SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
|
||||||
OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
|
OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
|
||||||
INTO vHasDistinctWarehouses
|
INTO vHasDistinctWarehouses
|
||||||
FROM travel o, travel n
|
FROM travel o, travel n
|
||||||
WHERE o.id = OLD.travelFk
|
WHERE o.id = OLD.travelFk
|
||||||
AND n.id = NEW.travelFk;
|
AND n.id = NEW.travelFk;
|
||||||
|
|
||||||
IF vIsVirtual AND vHasDistinctWarehouses THEN
|
IF vDaysInForward AND vHasDistinctWarehouses THEN
|
||||||
SIGNAL SQLSTATE '45000'
|
SIGNAL SQLSTATE '45000'
|
||||||
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
|
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -71,7 +73,7 @@ BEGIN
|
||||||
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT (NEW.travelFk <=> OLD.travelFk)
|
IF NOT (NEW.travelFk <=> OLD.travelFk)
|
||||||
OR NOT (NEW.currencyFk <=> OLD.currencyFk)
|
OR NOT (NEW.currencyFk <=> OLD.currencyFk)
|
||||||
OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN
|
OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN
|
||||||
|
|
||||||
|
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeUpdate`
|
||||||
BEFORE UPDATE ON `itemType`
|
BEFORE UPDATE ON `itemType`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
IF NEW.itemPackingTypeFk = '' THEN
|
IF NEW.itemPackingTypeFk = '' THEN
|
||||||
|
|
||||||
SET NEW.itemPackingTypeFk = NULL;
|
SET NEW.itemPackingTypeFk = NULL;
|
||||||
|
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`productionConfig_afterD
|
||||||
AFTER DELETE ON `productionConfig`
|
AFTER DELETE ON `productionConfig`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO productionConfig
|
INSERT INTO productionConfigLog
|
||||||
SET `action` = 'delete',
|
SET `action` = 'delete',
|
||||||
`changedModel` = 'ProductionConfig',
|
`changedModel` = 'ProductionConfig',
|
||||||
`changedModelId` = OLD.id,
|
`changedModelId` = OLD.id,
|
||||||
|
|
|
@ -6,7 +6,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`,
|
||||||
`b`.`itemFk` AS `itemFk`,
|
`b`.`itemFk` AS `itemFk`,
|
||||||
`b`.`quantity` AS `quantity`,
|
`b`.`quantity` AS `quantity`,
|
||||||
`t`.`isReceived` AS `isReceived`,
|
`t`.`isReceived` AS `isReceived`,
|
||||||
`e`.`isRaid` AS `isVirtualStock`,
|
`t`.`daysInForward` AS `isVirtualStock`,
|
||||||
`e`.`id` AS `entryFk`
|
`e`.`id` AS `entryFk`
|
||||||
FROM (
|
FROM (
|
||||||
(
|
(
|
||||||
|
|
|
@ -15,5 +15,5 @@ FROM (
|
||||||
JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`)
|
JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`)
|
||||||
)
|
)
|
||||||
WHERE `e`.`isExcludedFromAvailable` = 0
|
WHERE `e`.`isExcludedFromAvailable` = 0
|
||||||
AND `e`.`isRaid` = 0
|
AND NOT `t`.`daysInForward`
|
||||||
AND `b`.`quantity` <> 0
|
AND `b`.`quantity` <> 0
|
||||||
|
|
|
@ -31,5 +31,5 @@ FROM (
|
||||||
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
|
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
|
||||||
)
|
)
|
||||||
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
|
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
|
||||||
AND `e`.`isRaid` = 0
|
AND NOT `tr`.`daysInForward`
|
||||||
AND `b`.`stickers` > 0
|
AND `b`.`stickers` > 0
|
||||||
|
|
|
@ -10,11 +10,10 @@ FROM (
|
||||||
`vn`.`collection` `c`
|
`vn`.`collection` `c`
|
||||||
JOIN `vn`.`client` `cl` ON(`cl`.`id` = `c`.`workerFk`)
|
JOIN `vn`.`client` `cl` ON(`cl`.`id` = `c`.`workerFk`)
|
||||||
)
|
)
|
||||||
LEFT JOIN `vn`.`machineWorker` `mw` ON(
|
JOIN `vn`.`operator` `o` ON(
|
||||||
`mw`.`workerFk` = `c`.`workerFk`
|
`o`.`workerFk` = `c`.`workerFk`
|
||||||
AND `mw`.`inTimed` > `util`.`VN_CURDATE`()
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
WHERE `c`.`created` > `util`.`VN_CURDATE`()
|
WHERE `c`.`created` > `util`.`VN_CURDATE`()
|
||||||
AND `mw`.`workerFk` IS NULL
|
AND `o`.`machineFk` IS NULL
|
||||||
GROUP BY `c`.`workerFk`
|
GROUP BY `c`.`workerFk`
|
||||||
|
|
|
@ -8,7 +8,6 @@ AS SELECT `e`.`id` AS `Id_Entrada`,
|
||||||
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
||||||
`e`.`isConfirmed` AS `Confirmada`,
|
`e`.`isConfirmed` AS `Confirmada`,
|
||||||
`e`.`isOrdered` AS `Pedida`,
|
`e`.`isOrdered` AS `Pedida`,
|
||||||
`e`.`isRaid` AS `Redada`,
|
|
||||||
`e`.`commission` AS `comision`,
|
`e`.`commission` AS `comision`,
|
||||||
`e`.`created` AS `odbc_date`,
|
`e`.`created` AS `odbc_date`,
|
||||||
`e`.`evaNotes` AS `Notas_Eva`,
|
`e`.`evaNotes` AS `Notas_Eva`,
|
||||||
|
|
|
@ -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`
|
|
|
@ -8,7 +8,7 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`,
|
||||||
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
||||||
`e`.`isConfirmed` AS `Confirmada`,
|
`e`.`isConfirmed` AS `Confirmada`,
|
||||||
`e`.`isOrdered` AS `Pedida`,
|
`e`.`isOrdered` AS `Pedida`,
|
||||||
`e`.`isRaid` AS `Redada`,
|
`tr`.`daysInForward` AS `daysInForward`,
|
||||||
`e`.`evaNotes` AS `notas`,
|
`e`.`evaNotes` AS `notas`,
|
||||||
`e`.`supplierFk` AS `Id_Proveedor`,
|
`e`.`supplierFk` AS `Id_Proveedor`,
|
||||||
`tr`.`shipped` AS `shipment`,
|
`tr`.`shipped` AS `shipment`,
|
||||||
|
|
|
@ -17,5 +17,6 @@ AS SELECT `t`.`id` AS `id`,
|
||||||
`t`.`cargoSupplierFk` AS `cargoSupplierFk`,
|
`t`.`cargoSupplierFk` AS `cargoSupplierFk`,
|
||||||
`t`.`totalEntries` AS `totalEntries`,
|
`t`.`totalEntries` AS `totalEntries`,
|
||||||
`t`.`appointment` AS `appointment`,
|
`t`.`appointment` AS `appointment`,
|
||||||
`t`.`awbFk` AS `awbFk`
|
`t`.`awbFk` AS `awbFk`,
|
||||||
|
`t`.`daysInForward` AS `daysInForward`
|
||||||
FROM `vn`.`travel` `t`
|
FROM `vn`.`travel` `t`
|
||||||
|
|
|
@ -28,7 +28,6 @@ AS SELECT `TP`.`Id_Tipo` AS `Familia`,
|
||||||
`E`.`Id_Proveedor` AS `Id_Proveedor`,
|
`E`.`Id_Proveedor` AS `Id_Proveedor`,
|
||||||
`E`.`Fecha` AS `Fecha`,
|
`E`.`Fecha` AS `Fecha`,
|
||||||
`E`.`Confirmada` AS `Confirmada`,
|
`E`.`Confirmada` AS `Confirmada`,
|
||||||
`E`.`Redada` AS `Redada`,
|
|
||||||
`E`.`empresa_id` AS `empresa_id`,
|
`E`.`empresa_id` AS `empresa_id`,
|
||||||
`E`.`travel_id` AS `travel_id`,
|
`E`.`travel_id` AS `travel_id`,
|
||||||
`E`.`Pedida` AS `Pedida`,
|
`E`.`Pedida` AS `Pedida`,
|
||||||
|
@ -85,6 +84,6 @@ FROM (
|
||||||
)
|
)
|
||||||
JOIN `vn2008`.`Cubos` `cb` ON(`cb`.`Id_Cubo` = `C`.`Id_Cubo`)
|
JOIN `vn2008`.`Cubos` `cb` ON(`cb`.`Id_Cubo` = `C`.`Id_Cubo`)
|
||||||
)
|
)
|
||||||
WHERE `W_IN`.`isFeedStock` = 0
|
WHERE NOT `W_IN`.`isFeedStock`
|
||||||
AND `E`.`Inventario` = 0
|
AND NOT `E`.`Inventario`
|
||||||
AND `E`.`Redada` = 0
|
AND NOT `TR`.`daysInForward`
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
ALTER TABLE vn.autonomy MODIFY COLUMN isUeeMember tinyint(1) DEFAULT FALSE NOT NULL;
|
|
|
@ -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');
|
|
@ -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;
|
|
@ -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 `model` = 'Worker'
|
||||||
|
AND `property` IN ('find', 'findById', 'findOne');
|
|
@ -0,0 +1,3 @@
|
||||||
|
DELETE FROM salix.ACL
|
||||||
|
WHERE property = 'labelPdf'
|
||||||
|
AND model = 'Item';
|
|
@ -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';
|
|
@ -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 @@
|
||||||
|
USE vn;
|
||||||
|
|
||||||
|
ALTER TABLE vn.expeditionState ADD scanOrder int(11) DEFAULT NULL NULL COMMENT 'Indica la posición al cargar la furgoneta';
|
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO vn.report (name, `method`)
|
||||||
|
VALUES ('LabelItemBarcode','Items/{id}/label-barcode-pdf'),
|
||||||
|
('LabelItemQr','Items/{id}/label-qr-pdf');
|
|
@ -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');
|
|
@ -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';
|
|
@ -240,6 +240,10 @@
|
||||||
"There is already a tray with the same height": "There is already a tray with the same height",
|
"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 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 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",
|
"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"
|
"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"
|
||||||
|
}
|
|
@ -384,5 +384,8 @@
|
||||||
"No valid travel thermograph found": "No se encontró un termógrafo válido",
|
"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",
|
"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",
|
"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"
|
||||||
|
}
|
|
@ -123,8 +123,8 @@
|
||||||
"Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
|
"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}}}",
|
"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}}}",
|
"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 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 quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}",
|
"Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}",
|
||||||
"State": "État",
|
"State": "État",
|
||||||
"regular": "normal",
|
"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é",
|
"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é",
|
"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",
|
"Cannot send mail": "Impossible d'envoyer le mail",
|
||||||
"Original invoice not found": "Facture originale introuvable",
|
"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"
|
"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à"
|
||||||
|
}
|
|
@ -124,7 +124,7 @@
|
||||||
"Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Created claim": "Reclamação criada [{{claimId}}]({{{claimUrl}}}) 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 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}}* ",
|
"Changes in sales": " [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* ",
|
||||||
"State": "Estado",
|
"State": "Estado",
|
||||||
"regular": "normal",
|
"regular": "normal",
|
||||||
|
@ -361,7 +361,9 @@
|
||||||
"It was not able to create the invoice": "Não foi possível criar a fatura",
|
"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",
|
"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",
|
"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",
|
"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."
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint max-len: ["error", { "code": 150 }]*/
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
|
@ -98,6 +99,8 @@ module.exports = function(Self) {
|
||||||
return client;
|
return client;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
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;
|
throw e;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,6 @@ columns:
|
||||||
notes: notes
|
notes: notes
|
||||||
isConfirmed: confirmed
|
isConfirmed: confirmed
|
||||||
isVirtual: virtual
|
isVirtual: virtual
|
||||||
isRaid: raid
|
|
||||||
commission: commission
|
commission: commission
|
||||||
isOrdered: price3
|
isOrdered: price3
|
||||||
created: created
|
created: created
|
||||||
|
|
|
@ -9,7 +9,6 @@ columns:
|
||||||
notes: notas
|
notes: notas
|
||||||
isConfirmed: confirmado
|
isConfirmed: confirmado
|
||||||
isVirtual: virtual
|
isVirtual: virtual
|
||||||
isRaid: redada
|
|
||||||
commission: comisión
|
commission: comisión
|
||||||
isOrdered: pedida
|
isOrdered: pedida
|
||||||
created: creado
|
created: creado
|
||||||
|
|
|
@ -1,14 +1,28 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('buyLabel', {
|
Self.remoteMethodCtx('buyLabel', {
|
||||||
description: 'Returns the entry buy labels',
|
description: 'Returns the buy label',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
arg: 'id',
|
arg: 'id',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The entry id',
|
description: 'The buy id',
|
||||||
http: {source: 'path'}
|
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: [
|
returns: [
|
||||||
|
@ -27,11 +41,16 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
http: {
|
http: {
|
||||||
path: '/:id/buy-label',
|
path: '/:id/:labelType/buy-label',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
accessScopes: ['DEFAULT', 'read:multimedia']
|
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');
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -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');
|
||||||
|
};
|
|
@ -194,7 +194,7 @@ module.exports = Self => {
|
||||||
e.evaNotes observation,
|
e.evaNotes observation,
|
||||||
e.isConfirmed,
|
e.isConfirmed,
|
||||||
e.isOrdered,
|
e.isOrdered,
|
||||||
e.isRaid,
|
t.daysInForward,
|
||||||
e.commission,
|
e.commission,
|
||||||
e.created,
|
e.created,
|
||||||
e.travelFk,
|
e.travelFk,
|
||||||
|
|
|
@ -48,7 +48,9 @@ module.exports = Self => {
|
||||||
'warehouseInFk',
|
'warehouseInFk',
|
||||||
'isReceived',
|
'isReceived',
|
||||||
'isDelivered',
|
'isDelivered',
|
||||||
'ref'],
|
'ref',
|
||||||
|
'daysInForward',
|
||||||
|
],
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
relation: 'agency',
|
relation: 'agency',
|
||||||
|
@ -85,7 +87,6 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
return models.Entry.findOne(filter, myOptions);
|
return models.Entry.findOne(filter, myOptions);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,4 +2,5 @@ module.exports = Self => {
|
||||||
require('../methods/entry/editLatestBuys')(Self);
|
require('../methods/entry/editLatestBuys')(Self);
|
||||||
require('../methods/entry/latestBuysFilter')(Self);
|
require('../methods/entry/latestBuysFilter')(Self);
|
||||||
require('../methods/entry/deleteBuys')(Self);
|
require('../methods/entry/deleteBuys')(Self);
|
||||||
|
require('../methods/entry/buyLabel')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,15 +33,6 @@
|
||||||
"isConfirmed": {
|
"isConfirmed": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"isVirtual": {
|
|
||||||
"type": "boolean",
|
|
||||||
"mysql": {
|
|
||||||
"columnName": "isRaid"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isRaid": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"commission": {
|
"commission": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
@ -88,7 +79,8 @@
|
||||||
"travel": {
|
"travel": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Travel",
|
"model": "Travel",
|
||||||
"foreignKey": "travelFk"
|
"foreignKey": "travelFk",
|
||||||
|
"daysInForward": "daysInForward"
|
||||||
},
|
},
|
||||||
"company": {
|
"company": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
|
|
|
@ -1,65 +1,65 @@
|
||||||
<vn-descriptor-content
|
<vn-descriptor-content
|
||||||
module="entry"
|
module="entry"
|
||||||
description="$ctrl.entry.supplier.nickname"
|
description="$ctrl.entry.supplier.nickname"
|
||||||
summary="$ctrl.$.summary">
|
summary="$ctrl.$.summary">
|
||||||
<slot-menu>
|
<slot-menu>
|
||||||
<vn-item
|
<vn-item
|
||||||
ng-click="$ctrl.showEntryReport()"
|
ng-click="$ctrl.showEntryReport()"
|
||||||
translate>
|
translate>
|
||||||
Show entry report
|
Show entry report
|
||||||
</vn-item>
|
</vn-item>
|
||||||
</slot-menu>
|
</slot-menu>
|
||||||
<slot-body>
|
<slot-body>
|
||||||
<div class="attributes">
|
<div class="attributes">
|
||||||
<vn-label-value label="Agency "
|
<vn-label-value label="Agency "
|
||||||
value="{{$ctrl.entry.travel.agency.name}}">
|
value="{{$ctrl.entry.travel.agency.name}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value label="Landed"
|
<vn-label-value label="Landed"
|
||||||
value="{{$ctrl.entry.travel.landed | date: 'dd/MM/yyyy'}}">
|
value="{{$ctrl.entry.travel.landed | date: 'dd/MM/yyyy'}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value label="Warehouse Out"
|
<vn-label-value label="Warehouse Out"
|
||||||
value="{{$ctrl.entry.travel.warehouseOut.name}}">
|
value="{{$ctrl.entry.travel.warehouseOut.name}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</div>
|
</div>
|
||||||
<div class="icons">
|
<div class="icons">
|
||||||
<vn-icon
|
<vn-icon
|
||||||
vn-tooltip="Is inventory entry"
|
vn-tooltip="It is a raid {{$ctrl.entryData.travel.daysInForward}} days forward"
|
||||||
icon="icon-inventory"
|
icon="icon-inventory"
|
||||||
ng-if="$ctrl.entry.isExcludedFromAvailable">
|
ng-if="$ctrl.entry.isExcludedFromAvailable">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
vn-tooltip="Is virtual entry"
|
vn-tooltip="Is virtual entry"
|
||||||
icon="icon-net"
|
icon="icon-net"
|
||||||
ng-if="$ctrl.entry.isRaid">
|
ng-if="$ctrl.entryData.travel.daysInForward">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="quicklinks">
|
<div class="quicklinks">
|
||||||
<div ng-transclude="btnOne">
|
<div ng-transclude="btnOne">
|
||||||
<vn-quick-link
|
<vn-quick-link
|
||||||
tooltip="Supplier card"
|
tooltip="Supplier card"
|
||||||
state="['supplier.index', {q: $ctrl.entry.supplier.id }]"
|
state="['supplier.index', {q: $ctrl.entry.supplier.id }]"
|
||||||
icon="icon-supplier">
|
icon="icon-supplier">
|
||||||
</vn-quick-link>
|
</vn-quick-link>
|
||||||
</div>
|
</div>
|
||||||
<div ng-transclude="btnTwo">
|
<div ng-transclude="btnTwo">
|
||||||
<vn-quick-link
|
<vn-quick-link
|
||||||
tooltip="All travels with current agency"
|
tooltip="All travels with current agency"
|
||||||
state="['travel.index', {q: $ctrl.travelFilter}]"
|
state="['travel.index', {q: $ctrl.travelFilter}]"
|
||||||
icon="local_airport">
|
icon="local_airport">
|
||||||
</vn-quick-link>
|
</vn-quick-link>
|
||||||
</div>
|
</div>
|
||||||
<div ng-transclude="btnThree">
|
<div ng-transclude="btnThree">
|
||||||
<vn-quick-link
|
<vn-quick-link
|
||||||
tooltip="All entries with current supplier"
|
tooltip="All entries with current supplier"
|
||||||
state="['entry.index', {q: $ctrl.entryFilter}]"
|
state="['entry.index', {q: $ctrl.entryFilter}]"
|
||||||
icon="icon-entry">
|
icon="icon-entry">
|
||||||
</vn-quick-link>
|
</vn-quick-link>
|
||||||
</div>
|
</div>
|
||||||
<div ng-transclude="btnThree">
|
<div ng-transclude="btnThree">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</slot-body>
|
</slot-body>
|
||||||
</vn-descriptor-content>
|
</vn-descriptor-content>
|
||||||
<vn-popup vn-id="summary">
|
<vn-popup vn-id="summary">
|
||||||
<vn-entry-summary entry="$ctrl.entry"></vn-entry-summary>
|
<vn-entry-summary entry="$ctrl.entry"></vn-entry-summary>
|
||||||
</vn-popup>
|
</vn-popup>
|
||||||
|
|
|
@ -86,7 +86,7 @@ auto-load="true">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
<vn-check
|
<vn-check
|
||||||
label="Raid"
|
label="Raid"
|
||||||
ng-model="$ctrl.entryData.isRaid"
|
ng-model="$ctrl.entryData.travel.daysInForward"
|
||||||
disabled="true">
|
disabled="true">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
<vn-check
|
<vn-check
|
||||||
|
|
|
@ -38,13 +38,23 @@ module.exports = Self => {
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
description: 'Type id',
|
description: 'Type id',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'producerFk',
|
||||||
|
type: 'integer',
|
||||||
|
description: 'Producer id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'instrastatFk',
|
||||||
|
type: 'string',
|
||||||
|
description: 'intrastat id',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'isActive',
|
arg: 'isActive',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Whether the item is or not active',
|
description: 'Whether the item is or not active',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'buyerFk',
|
arg: 'workerFk',
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
description: 'The buyer of the item',
|
description: 'The buyer of the item',
|
||||||
},
|
},
|
||||||
|
@ -126,14 +136,16 @@ module.exports = Self => {
|
||||||
return {'i.stemMultiplier': value};
|
return {'i.stemMultiplier': value};
|
||||||
case 'categoryFk':
|
case 'categoryFk':
|
||||||
return {'ic.id': value};
|
return {'ic.id': value};
|
||||||
case 'buyerFk':
|
case 'workerFk':
|
||||||
return {'it.workerFk': value};
|
return {'it.workerFk': value};
|
||||||
|
case 'producerFk':
|
||||||
|
return {'pr.id': value};
|
||||||
case 'supplierFk':
|
case 'supplierFk':
|
||||||
return {'s.id': value};
|
return {'s.id': value};
|
||||||
case 'origin':
|
case 'origin':
|
||||||
return {'ori.code': value};
|
return {'ori.code': value};
|
||||||
case 'intrastat':
|
case 'intrastatFk':
|
||||||
return {'intr.description': value};
|
return {'i.intrastatFk': value};
|
||||||
case 'landed':
|
case 'landed':
|
||||||
return {'lb.landed': value};
|
return {'lb.landed': value};
|
||||||
}
|
}
|
||||||
|
@ -172,6 +184,7 @@ module.exports = Self => {
|
||||||
u.name AS userName,
|
u.name AS userName,
|
||||||
ori.code AS origin,
|
ori.code AS origin,
|
||||||
ic.name AS category,
|
ic.name AS category,
|
||||||
|
i.intrastatFk,
|
||||||
intr.description AS intrastat,
|
intr.description AS intrastat,
|
||||||
b.grouping,
|
b.grouping,
|
||||||
b.packing,
|
b.packing,
|
||||||
|
|
|
@ -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');
|
|
||||||
};
|
|
|
@ -86,7 +86,7 @@ describe('item filter()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filter = {};
|
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);
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(2);
|
||||||
|
|
|
@ -47,6 +47,9 @@
|
||||||
"ItemType": {
|
"ItemType": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"ItemTypeLog": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"ItemTypeTag": {
|
"ItemTypeTag": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "ItemTypeLog",
|
||||||
|
"base": "Log",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "itemTypeLog"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,12 @@
|
||||||
},
|
},
|
||||||
"isLaid": {
|
"isLaid": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"maxRefs": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"isFragile": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -15,7 +15,6 @@ module.exports = Self => {
|
||||||
require('../methods/item/getWasteByItem')(Self);
|
require('../methods/item/getWasteByItem')(Self);
|
||||||
require('../methods/item/createIntrastat')(Self);
|
require('../methods/item/createIntrastat')(Self);
|
||||||
require('../methods/item/buyerWasteEmail')(Self);
|
require('../methods/item/buyerWasteEmail')(Self);
|
||||||
require('../methods/item/labelPdf')(Self);
|
|
||||||
require('../methods/item/setVisibleDiscard')(Self);
|
require('../methods/item/setVisibleDiscard')(Self);
|
||||||
require('../methods/item/get')(Self);
|
require('../methods/item/get')(Self);
|
||||||
|
|
||||||
|
|
|
@ -11,26 +11,26 @@
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Code"
|
label="Code"
|
||||||
ng-model="$ctrl.itemType.code"
|
ng-model="$ctrl.itemType.code"
|
||||||
rule
|
rule
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Name"
|
label="Name"
|
||||||
ng-model="$ctrl.itemType.name"
|
ng-model="$ctrl.itemType.name"
|
||||||
rule>
|
rule>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Worker"
|
label="Worker"
|
||||||
ng-model="$ctrl.itemType.workerFk"
|
ng-model="$ctrl.itemType.workerFk"
|
||||||
url="Workers"
|
url="Workers/search"
|
||||||
show-field="firstName"
|
show-field="nickname"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
rule>
|
rule>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Category"
|
label="Category"
|
||||||
ng-model="$ctrl.itemType.categoryFk"
|
ng-model="$ctrl.itemType.categoryFk"
|
||||||
url="ItemCategories"
|
url="ItemCategories"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
rule>
|
rule>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Temperature"
|
label="Temperature"
|
||||||
ng-model="$ctrl.itemType.temperatureFk"
|
ng-model="$ctrl.itemType.temperatureFk"
|
||||||
url="Temperatures"
|
url="Temperatures"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
@ -59,4 +59,4 @@
|
||||||
ng-click="watcher.loadOriginalData()">
|
ng-click="watcher.loadOriginalData()">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
</vn-button-bar>
|
</vn-button-bar>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -12,26 +12,26 @@
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Code"
|
label="Code"
|
||||||
ng-model="$ctrl.itemType.code"
|
ng-model="$ctrl.itemType.code"
|
||||||
rule
|
rule
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Name"
|
label="Name"
|
||||||
ng-model="$ctrl.itemType.name"
|
ng-model="$ctrl.itemType.name"
|
||||||
rule>
|
rule>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Worker"
|
label="Worker"
|
||||||
ng-model="$ctrl.itemType.workerFk"
|
ng-model="$ctrl.itemType.workerFk"
|
||||||
url="Workers"
|
url="Workers/search"
|
||||||
show-field="firstName"
|
show-field="nickname"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
rule>
|
rule>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Category"
|
label="Category"
|
||||||
ng-model="$ctrl.itemType.categoryFk"
|
ng-model="$ctrl.itemType.categoryFk"
|
||||||
url="ItemCategories"
|
url="ItemCategories"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
rule>
|
rule>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Temperature"
|
label="Temperature"
|
||||||
ng-model="$ctrl.itemType.temperatureFk"
|
ng-model="$ctrl.itemType.temperatureFk"
|
||||||
url="Temperatures"
|
url="Temperatures"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
|
|
@ -38,5 +38,13 @@
|
||||||
"model": "Sector",
|
"model": "Sector",
|
||||||
"foreignKey": "sectorFk"
|
"foreignKey": "sectorFk"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"scope": {
|
||||||
|
"include": {
|
||||||
|
"relation": "sector",
|
||||||
|
"scope": {
|
||||||
|
"fields": ["id", "description"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue