Compare commits
8 Commits
dev
...
8002-refac
Author | SHA1 | Date |
---|---|---|
Jorge Penadés | 1ed8c01712 | |
Jorge Penadés | ca641e555f | |
Jorge Penadés | dbf5953d69 | |
Jorge Penadés | 285fe67ca5 | |
Jorge Penadés | 021fd901b7 | |
Jorge Penadés | 873b91f113 | |
Jorge Penadés | b75b369716 | |
Jorge Penadés | 1c49c073ee |
|
@ -36,7 +36,3 @@ rules:
|
|||
jasmine/no-focused-tests: 0
|
||||
jasmine/prefer-toHaveBeenCalledWith: 0
|
||||
arrow-spacing: ["error", { "before": true, "after": true }]
|
||||
no-restricted-syntax:
|
||||
- "error"
|
||||
- selector: "NewExpression[callee.name='Date']"
|
||||
message: "Use Date.vnNew() instead of new Date()."
|
||||
|
|
|
@ -29,8 +29,10 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.getSales = async(ctx, collectionOrTicketFk, print, source, options) => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {userId};
|
||||
const $t = ctx.req.__;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
@ -57,6 +59,22 @@ module.exports = Self => {
|
|||
|
||||
if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions);
|
||||
|
||||
for (let ticket of tickets) {
|
||||
if (ticket.observaciones) {
|
||||
let observations = ticket.observaciones.split(' ');
|
||||
|
||||
for (let observation of observations) {
|
||||
const salesPerson = ticket.salesPersonFk;
|
||||
if (observation.startsWith('#') || observation.startsWith('@')) {
|
||||
await models.Chat.send(ctx,
|
||||
observation,
|
||||
$t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getCollection(id, tickets, sales, placements, myOptions);
|
||||
};
|
||||
|
||||
|
|
|
@ -57,10 +57,10 @@ module.exports = Self => {
|
|||
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving,
|
||||
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving,
|
||||
sh.code,
|
||||
p2.code parkingCodePrevia,
|
||||
p2.pickingOrder pickingOrderPrevia,
|
||||
p.code parkingCode,
|
||||
p.pickingOrder pickingOrder,
|
||||
p2.code parkingCode,
|
||||
p2.pickingOrder pickingOrder,
|
||||
p.code parkingCodePrevia,
|
||||
p.pickingOrder pickingOrderPrevia,
|
||||
iss.id itemShelvingSaleFk,
|
||||
iss.isPicked,
|
||||
iss.itemShelvingFk
|
||||
|
@ -73,7 +73,7 @@ module.exports = Self => {
|
|||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
LEFT JOIN parking p ON p.id = sh.parkingFk
|
||||
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
|
||||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
|
@ -114,7 +114,7 @@ module.exports = Self => {
|
|||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
LEFT JOIN parking p ON p.id = sh.parkingFk
|
||||
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
|
||||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
|
|
|
@ -28,10 +28,9 @@ describe('ticket assign()', () => {
|
|||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should throw an error when there are no picking tickets', async() => {
|
||||
it('should throw an error when there is not picking tickets', async() => {
|
||||
try {
|
||||
await models.Collection.assign(ctx, options);
|
||||
fail('Expected an error to be thrown, but none was thrown.');
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual('There are not picking tickets');
|
||||
}
|
||||
|
|
|
@ -29,35 +29,34 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.sendToSupport = async(ctx, reason, additionalData) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const emailUser =
|
||||
await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']});
|
||||
await Self.app.models.EmailUser.findById(userId, {fields: ['email']});
|
||||
|
||||
let html = `<strong>Motivo</strong>:<br/>${reason}<br/>`;
|
||||
html += `<strong>Usuario</strong>:<br/>${ctx.req.accessToken.userId} ${emailUser.email}<br/>`;
|
||||
let html = `<h2>Motivo: ${reason}</h2>`;
|
||||
html += `<h3>Usuario: ${userId} ${emailUser.email}</h3>`;
|
||||
html += `<h3>Additional Data:</h3>`;
|
||||
html += '<ul>';
|
||||
for (const [key, val] of Object.entries(additionalData)) {
|
||||
if (key !== 'config') html += `<li>${key}: ${parse(val)}</li>`;
|
||||
else {
|
||||
html += `<li>${key}:</li><ul style="list-style-type: square;">`;
|
||||
for (const [confKey, confVal] of Object.entries(val))
|
||||
html += `<li>${confKey}: ${parse(confVal)}</li>`;
|
||||
html += '</ul>';
|
||||
}
|
||||
}
|
||||
html += '</ul>';
|
||||
|
||||
delete additionalData.backError.config.headers.Authorization;
|
||||
const httpRequest = JSON.parse(additionalData?.httpRequest);
|
||||
|
||||
if (httpRequest)
|
||||
delete httpRequest.config.headers.Authorization;
|
||||
additionalData.httpRequest = httpRequest;
|
||||
|
||||
for (const data in additionalData)
|
||||
html += `<strong>${data}</strong>:<br/>${tryParse(additionalData[data])}<br/>`;
|
||||
|
||||
const subjectReason = httpRequest?.data?.error;
|
||||
const {message, path, name} = additionalData;
|
||||
await smtp.send({
|
||||
to: `${config.app.reportEmail}, ${emailUser.email}`,
|
||||
subject:
|
||||
'[Support-Salix] ' +
|
||||
additionalData?.frontPath + ' ' +
|
||||
subjectReason?.name + ':' +
|
||||
subjectReason?.message,
|
||||
subject: `[Support-Salix] ${path} ${name}: ${message}`,
|
||||
html
|
||||
});
|
||||
};
|
||||
|
||||
function tryParse(value) {
|
||||
function parse(value) {
|
||||
try {
|
||||
try {
|
||||
value = JSON.parse(value);
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports = Self => {
|
|||
return await Self.rawSql(`
|
||||
INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model)
|
||||
SELECT ?, ?, ?
|
||||
FROM workerTimeControlConfig wtcc
|
||||
FROM workerTimeControlParams wtcp
|
||||
LEFT JOIN (
|
||||
SELECT wa.workerFk,
|
||||
wa.created,
|
||||
|
@ -44,7 +44,7 @@ module.exports = Self => {
|
|||
) sub ON TRUE
|
||||
WHERE sub.workerFk IS NULL
|
||||
OR sub.code <> ?
|
||||
OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcc.dayBreak;`
|
||||
OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;`
|
||||
, [userId, code, model, userId, code], myOptions);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -79,9 +79,6 @@
|
|||
"ImageCollectionSize": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ImageConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ImageContainer": {
|
||||
"dataSource": "imageStorage"
|
||||
},
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
},
|
||||
"itemFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"isChecked": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"name": "ImageConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "hedera.imageConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -13,9 +13,6 @@
|
|||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultChannel": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
|
|
@ -2084,7 +2084,7 @@ INSERT INTO `ACL` VALUES (756,'Route','findOne','READ','ALLOW','ROLE','employee'
|
|||
INSERT INTO `ACL` VALUES (757,'Route','getRoutesByWorker','READ','ALLOW','ROLE','employee',NULL);
|
||||
INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryAssistant',NULL);
|
||||
INSERT INTO `ACL` VALUES (759,'Route','cmr','READ','ALLOW','ROLE','employee',NULL);
|
||||
INSERT INTO `ACL` VALUES (760,'Cmr','downloadZip','READ','ALLOW','ROLE','employee',NULL);
|
||||
INSERT INTO `ACL` VALUES (760,'Route','downloadCmrsZip','READ','ALLOW','ROLE','employee',NULL);
|
||||
INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','employee',NULL);
|
||||
INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee',NULL);
|
||||
INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee',NULL);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1254,9 +1254,9 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
|||
|
||||
INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`)
|
||||
VALUES
|
||||
(2, 11, 1, 1, 1, 2,1106),
|
||||
(4, 12, 1, 1, 1, NULL,1106),
|
||||
(1, 13, 2, 12, 12, NULL,1106);
|
||||
(2, 'GVC', 1, 1, 1, 2,1106),
|
||||
(4, 'HEJ', 1, 1, 1, NULL,1106),
|
||||
(1, 'UXN', 2, 12, 12, NULL,1106);
|
||||
|
||||
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
|
||||
VALUES
|
||||
|
@ -1505,32 +1505,32 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk
|
|||
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
|
||||
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
|
||||
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `isRaid`, `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, FALSE, 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, FALSE, NULL),
|
||||
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, FALSE, 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, FALSE, 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, FALSE, 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, FALSE,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, TRUE, 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, FALSE, 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, TRUE, 2),
|
||||
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
|
||||
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL);
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `daysInForward`)
|
||||
VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, NULL),
|
||||
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, NULL),
|
||||
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, NULL),
|
||||
(4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, NULL),
|
||||
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, NULL),
|
||||
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, NULL),
|
||||
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, 2),
|
||||
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, NULL),
|
||||
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, 2),
|
||||
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL),
|
||||
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL);
|
||||
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`)
|
||||
VALUES
|
||||
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, '', 'packaging'),
|
||||
(2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 'observation two', 'product'),
|
||||
(3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 'observation three', 'product'),
|
||||
(4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 'observation four', 'product'),
|
||||
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 'observation five', 'product'),
|
||||
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 'observation six', 'product'),
|
||||
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven', 'product'),
|
||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, '', 'product'),
|
||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, '', 'product'),
|
||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, '', 'product'),
|
||||
(99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99', 0, '', 'product');
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`)
|
||||
VALUES
|
||||
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, ''),
|
||||
(2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 'observation two'),
|
||||
(3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 'observation three'),
|
||||
(4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 'observation four'),
|
||||
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 'observation five'),
|
||||
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 'observation six'),
|
||||
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven'),
|
||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1,''),
|
||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, ''),
|
||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, ''),
|
||||
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, '');
|
||||
|
||||
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
||||
VALUES (2, 4, 1);
|
||||
|
@ -2521,6 +2521,10 @@ INSERT INTO `vn`.`queuePriority`(`id`, `priority`, `code`)
|
|||
(2, 'Normal', 'normal'),
|
||||
(3, 'Baja', 'low');
|
||||
|
||||
INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`)
|
||||
VALUES
|
||||
(1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000);
|
||||
|
||||
INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');
|
||||
|
||||
INSERT INTO `vn`.`thermograph`(`id`, `model`)
|
||||
|
@ -3421,7 +3425,7 @@ INSERT INTO vn.buy
|
|||
INSERT INTO vn.itemShelving
|
||||
SET id = 9931,
|
||||
itemFk = 999993,
|
||||
shelvingFk = 16,
|
||||
shelvingFk = 'NCC',
|
||||
visible = 10,
|
||||
`grouping` = 5,
|
||||
packing = 10;
|
||||
|
@ -3748,7 +3752,7 @@ INSERT vn.sale
|
|||
|
||||
USE vn;
|
||||
DELETE ish.* FROM vn.itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector s ON s.id = p.sectorFk
|
||||
JOIN vn.warehouse w ON w.id = s.warehouseFk
|
||||
|
@ -3757,22 +3761,22 @@ DELETE ish.* FROM vn.itemShelving ish
|
|||
INSERT INTO vn.itemShelving
|
||||
(itemFk, shelvingFk, visible, created, `grouping`, packing, packagingFk, userFk, isChecked)
|
||||
VALUES
|
||||
(999991, 14, 8, '2023-09-20', 1, 20, NULL, 103, NULL),
|
||||
(999998, 14, 80, '2023-09-20', 10, 30, NULL, 103, NULL),
|
||||
(1000001, 14, 6, '2023-09-20', 3, 50, NULL, 103, NULL),
|
||||
(1000000, 15, 50, '2023-09-18', 25, 500, NULL, 103, NULL),
|
||||
(999993, 15, 25, '2023-09-18', NULL, 10, NULL, 103, NULL),
|
||||
(999999, 15, 30, '2023-09-18', 10, 500, NULL, 103, NULL),
|
||||
(999993, 16, 25, '2023-09-20', 5, 10, NULL, 103, NULL),
|
||||
(999997, 16, 10, '2023-09-20', NULL, 100, NULL, 103, NULL),
|
||||
(999999, 16, 40, '2023-09-20', 10, 500, NULL, 103, NULL),
|
||||
(999995, 17, 10, '2023-09-19', NULL, 20, NULL, 103, NULL),
|
||||
(999994, 17, 48, '2023-09-19', 4, 20, NULL, 103, NULL),
|
||||
(1000001, 18, 6, '2023-09-21', 3, 50, NULL, 103, NULL),
|
||||
(999992, 18, 50, '2023-09-21', NULL, 1, NULL, 103, NULL),
|
||||
(1000000, 18, 25, '2023-09-21', 25, 500, NULL, 103, NULL),
|
||||
(999996, 19, 5, '2023-09-27', 1, 5, NULL, 103, NULL),
|
||||
(999997, 21, 10, '2023-09-27', 5, 100, NULL, 103, NULL);
|
||||
(999991, 'NAA', 8, '2023-09-20', 1, 20, NULL, 103, NULL),
|
||||
(999998, 'NAA', 80, '2023-09-20', 10, 30, NULL, 103, NULL),
|
||||
(1000001, 'NAA', 6, '2023-09-20', 3, 50, NULL, 103, NULL),
|
||||
(1000000, 'NBB', 50, '2023-09-18', 25, 500, NULL, 103, NULL),
|
||||
(999993, 'NBB', 25, '2023-09-18', NULL, 10, NULL, 103, NULL),
|
||||
(999999, 'NBB', 30, '2023-09-18', 10, 500, NULL, 103, NULL),
|
||||
(999993, 'NCC', 25, '2023-09-20', 5, 10, NULL, 103, NULL),
|
||||
(999997, 'NCC', 10, '2023-09-20', NULL, 100, NULL, 103, NULL),
|
||||
(999999, 'NCC', 40, '2023-09-20', 10, 500, NULL, 103, NULL),
|
||||
(999995, 'NDD', 10, '2023-09-19', NULL, 20, NULL, 103, NULL),
|
||||
(999994, 'NDD', 48, '2023-09-19', 4, 20, NULL, 103, NULL),
|
||||
(1000001, 'NEE', 6, '2023-09-21', 3, 50, NULL, 103, NULL),
|
||||
(999992, 'NEE', 50, '2023-09-21', NULL, 1, NULL, 103, NULL),
|
||||
(1000000, 'NEE', 25, '2023-09-21', 25, 500, NULL, 103, NULL),
|
||||
(999996, 'PAA', 5, '2023-09-27', 1, 5, NULL, 103, NULL),
|
||||
(999997, 'PCC', 10, '2023-09-27', 5, 100, NULL, 103, NULL);
|
||||
|
||||
-- Previous for Bolas de madera
|
||||
INSERT IGNORE INTO vn.sectorCollection
|
||||
|
@ -4004,17 +4008,10 @@ INSERT IGNORE INTO pbx.queueMember
|
|||
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
|
||||
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
|
||||
|
||||
INSERT INTO vn.workerRelatives (workerFk, isDescendant, disabilityGradeFk, birthed, adoptionYear, isDependend, isJointCustody, updated)
|
||||
VALUES
|
||||
(1106, 1, NULL, 0, NULL, 0, 0, '2024-10-29 08:42:44.000');
|
||||
INSERT INTO vn.routeAction (id, name, price, isMainlineDelivered) VALUES(1, 'Pintar traje', 50.00, 0);
|
||||
INSERT INTO vn.routeComplement (id, dated, workerFk, price, routeActionFk) VALUES(1, util.VN_CURDATE(), 9, 50.00, 1);
|
||||
|
||||
|
||||
INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk)
|
||||
INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk)
|
||||
VALUES (0, 0, 0, 0, NULL, 3, 1, 0, 'ENT', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
|
||||
(1, 0, 9900, 0, NULL, 1, 0, 0, 'NOK', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
|
||||
(2, 0, 0, 450, 13000, 1, 0, 1, '01A', 1, 1, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
|
||||
(2, 0, 0, 450, 13000, 1, 0, 1, '01A', 1, 1, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
|
||||
(3, 1400, 0, 450, 13000, 1, 0, 1, '01B', 1, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
|
||||
(4, 0, 500, 500, 13000, 1, 4, 1, '02A', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL),
|
||||
(5, 1400, 500, 500, 13000, 1, 4, 1, '02B', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL),
|
||||
|
@ -4024,12 +4021,11 @@ INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, c
|
|||
(9, 1400, 1500, 500, 13000, 1, 1, 1, '04B', 4, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
|
||||
(10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL);
|
||||
|
||||
INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
|
||||
VALUES (19, '1169'),
|
||||
(8, '1183');
|
||||
|
||||
INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
|
||||
VALUES ('saysimle-url-mock', 1320);
|
||||
INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
|
||||
VALUES (19, 1169),
|
||||
(8, 1183),
|
||||
(NULL, 1320);
|
||||
|
||||
INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate)
|
||||
VALUES (1106,'26493101E','2019-09-20');
|
||||
INSERT IGNORE INTO vn.saySimpleConfig (url)
|
||||
VALUES ('saysimle-url-mock');
|
|
@ -32,7 +32,7 @@ BEGIN
|
|||
CREATE OR REPLACE TEMPORARY TABLE tVisible
|
||||
SELECT itemFk, SUM(visible) totalVisible
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector sc ON sc.id = p.sectorFk
|
||||
WHERE sc.warehouseFk = vWarehouseFk
|
||||
|
|
|
@ -53,7 +53,7 @@ proc: BEGIN
|
|||
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
|
||||
AND t.warehouseInFk = vWarehouse
|
||||
AND s.name != 'INVENTARIO'
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
GROUP BY b.itemFk
|
||||
) c
|
||||
JOIN vn.item i ON i.id = c.itemFk
|
||||
|
|
|
@ -14,7 +14,7 @@ BEGIN
|
|||
b.stickers = NEW.NumberOfUnits
|
||||
WHERE i.supplyResponseFk = NEW.ID
|
||||
AND am.name = 'LOGIFLORA'
|
||||
AND tr.isRaid
|
||||
AND tr.daysInForward
|
||||
AND tr.landed >= util.VN_CURDATE();
|
||||
|
||||
END$$
|
||||
|
|
|
@ -59,7 +59,7 @@ BEGIN
|
|||
JOIN vn.travel t ON t.id = e.travelFk
|
||||
WHERE t.landed BETWEEN vDateInv AND vDate
|
||||
AND t.warehouseInFk = vWarehouse
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
UNION ALL
|
||||
SELECT b.itemFk, -b.quantity
|
||||
FROM vn.buy b
|
||||
|
@ -67,7 +67,7 @@ BEGIN
|
|||
JOIN vn.travel t ON t.id = e.travelFk
|
||||
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
|
||||
AND t.warehouseOutFk = vWarehouse
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
AND t.isDelivered
|
||||
UNION ALL
|
||||
SELECT m.itemFk, -m.quantity
|
||||
|
|
|
@ -26,7 +26,7 @@ BEGIN
|
|||
|
||||
DECLARE vCursor CURSOR FOR
|
||||
SELECT it.taxableBase,
|
||||
CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)),
|
||||
CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
|
||||
t.PorcentajeIva,
|
||||
it.transactionTypeSageFk,
|
||||
it.taxTypeSageFk,
|
||||
|
@ -39,8 +39,7 @@ BEGIN
|
|||
JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
|
||||
LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
|
||||
WHERE i.id = vInvoiceInFk
|
||||
AND d.id IS NULL
|
||||
GROUP BY it.taxTypeSageFk;
|
||||
AND d.id IS NULL;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@ BEGIN
|
|||
DROP TEMPORARY TABLE IF EXISTS tValues;
|
||||
CREATE TEMPORARY TABLE tValues
|
||||
ENGINE = MEMORY
|
||||
SELECT b.id buyFk,
|
||||
SELECT
|
||||
b.id buyFk,
|
||||
e.id entryFk,
|
||||
t.id travelFk,
|
||||
b.itemFk,
|
||||
t.isRaid,
|
||||
t.daysInForward,
|
||||
ADDTIME(t.shipped,
|
||||
IFNULL(t.shipmentHour, '00:00:00')) shipped,
|
||||
t.warehouseOutFk,
|
||||
|
@ -49,7 +50,7 @@ BEGIN
|
|||
itemFk,
|
||||
TIMESTAMPADD(DAY, life, @dated),
|
||||
quantity,
|
||||
IF(isIn, isReceived, isDelivered) AND NOT isRaid
|
||||
IF(isIn, isReceived, isDelivered) AND NOT daysInForward
|
||||
FROM tValues
|
||||
WHERE isIn OR !lessThanInventory;
|
||||
|
||||
|
@ -64,7 +65,7 @@ BEGIN
|
|||
itemFk,
|
||||
created,
|
||||
quantity,
|
||||
IF(isIn, isDelivered, isReceived) AND NOT isRaid
|
||||
IF(isIn, isDelivered, isReceived) AND NOT daysInForward
|
||||
FROM tValues
|
||||
WHERE !isIn OR !lessThanInventory;
|
||||
|
||||
|
|
|
@ -14,12 +14,9 @@ BEGIN
|
|||
SELECT p.geoFk INTO vGeoFk
|
||||
FROM address a
|
||||
JOIN town t ON t.provinceFk = a.provinceFk
|
||||
JOIN postCode p ON p.townFk = t.id
|
||||
AND (p.code = a.postalCode OR a.postalCode IS NULL)
|
||||
JOIN zoneGeo zg ON zg.id = p.geoFk
|
||||
JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode
|
||||
WHERE a.id = vSelf
|
||||
ORDER BY (a.city SOUNDS LIKE t.name) DESC,
|
||||
(p.code = a.postalCode) DESC
|
||||
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC
|
||||
LIMIT 1;
|
||||
|
||||
RETURN vGeoFk;
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getGeo`(vSelf INT)
|
||||
RETURNS int(11)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Returns the geo for the passed client.
|
||||
*
|
||||
* @param vSelf The address id
|
||||
* @return The geo id
|
||||
*/
|
||||
DECLARE vGeoFk INT;
|
||||
|
||||
SELECT p.geoFk INTO vGeoFk
|
||||
FROM client c
|
||||
JOIN town t ON t.provinceFk = c.provinceFk
|
||||
JOIN postCode p ON p.townFk = t.id
|
||||
AND (p.code = c.postcode OR c.postcode IS NULL)
|
||||
JOIN zoneGeo zg ON zg.id = p.geoFk
|
||||
WHERE c.id = vSelf
|
||||
ORDER BY (c.city SOUNDS LIKE t.name) DESC,
|
||||
(p.code = c.postcode) DESC
|
||||
LIMIT 1;
|
||||
|
||||
RETURN vGeoFk;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,51 +1,58 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(vTravelFk INT,
|
||||
vCurrencyFk INT,
|
||||
vSupplierFk INT
|
||||
vCurrencyFk INT,
|
||||
vSupplierFk INT
|
||||
)
|
||||
RETURNS int(11)
|
||||
NOT DETERMINISTIC
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
DECLARE vCommission INT;
|
||||
DECLARE vCurrentCommission INT;
|
||||
DECLARE vIsNotEUR INT;
|
||||
DECLARE vLastEntryFk INT;
|
||||
DECLARE vCommission INT;
|
||||
DECLARE vCurrentCommission INT;
|
||||
DECLARE vIsCurrencyUsd INT;
|
||||
DECLARE vLastEntryFk INT;
|
||||
|
||||
SELECT count(*) INTO vIsCurrencyUsd
|
||||
FROM currency c
|
||||
WHERE c.code = 'USD' AND id = vCurrencyFk;
|
||||
|
||||
IF NOT vIsCurrencyUsd THEN
|
||||
|
||||
SELECT e.id INTO vLastEntryFk
|
||||
FROM vn.entry e
|
||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||
WHERE e.supplierFk = vSupplierFk
|
||||
ORDER BY tr.landed DESC
|
||||
LIMIT 1;
|
||||
|
||||
IF vLastEntryFk THEN
|
||||
|
||||
SELECT commission INTO vCurrentCommission
|
||||
FROM vn.entry
|
||||
WHERE id = vLastEntryFk;
|
||||
|
||||
ELSE
|
||||
|
||||
SELECT commission INTO vCurrentCommission
|
||||
FROM supplier s
|
||||
WHERE s.id = vSupplierFk;
|
||||
|
||||
END IF;
|
||||
|
||||
RETURN vCurrentCommission;
|
||||
|
||||
ELSE
|
||||
|
||||
SELECT count(*) INTO vIsNotEUR
|
||||
FROM currency c
|
||||
WHERE c.code <> 'EUR' AND id = vCurrencyFk;
|
||||
|
||||
IF vIsNotEUR THEN
|
||||
SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission
|
||||
FROM travel t
|
||||
LEFT JOIN referenceCurrent r ON r.currencyFk = vCurrencyFk AND r.`dated` <= t.shipped
|
||||
WHERE t.id = vTravelFk
|
||||
ORDER BY r.`dated` DESC
|
||||
LIMIT 1;
|
||||
|
||||
|
||||
RETURN IFNULL(vCommission, 0);
|
||||
ELSE
|
||||
SELECT e.id INTO vLastEntryFk
|
||||
FROM `entry` e
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
WHERE e.supplierFk = vSupplierFk
|
||||
ORDER BY tr.landed DESC
|
||||
LIMIT 1;
|
||||
|
||||
IF vLastEntryFk THEN
|
||||
SELECT commission INTO vCurrentCommission
|
||||
FROM `entry`
|
||||
WHERE id = vLastEntryFk;
|
||||
|
||||
ELSE
|
||||
SELECT commission INTO vCurrentCommission
|
||||
FROM supplier s
|
||||
WHERE s.id = vSupplierFk;
|
||||
|
||||
END IF;
|
||||
|
||||
RETURN vCurrentCommission;
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -9,7 +9,7 @@ BEGIN
|
|||
SELECT count(*) INTO vItemCount
|
||||
FROM vn.sale s
|
||||
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
WHERE s.ticketFk = vTicketFk
|
||||
AND p.sectorFk = vSectorFk;
|
||||
|
|
|
@ -10,7 +10,7 @@ BEGIN
|
|||
SELECT count(*) INTO vItemCount
|
||||
FROM vn.sale s
|
||||
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
WHERE s.ticketFk = vTicketFk
|
||||
AND p.sectorFk = vSectorFk;
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`supplier_getGeo`(vSelf INT)
|
||||
RETURNS int(11)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Returns the geo for the passed supplier.
|
||||
*
|
||||
* @param vSelf The address id
|
||||
* @return The geo id
|
||||
*/
|
||||
DECLARE vGeoFk INT;
|
||||
|
||||
SELECT p.geoFk INTO vGeoFk
|
||||
FROM supplier s
|
||||
JOIN town t ON t.provinceFk = s.provinceFk
|
||||
JOIN postCode p ON p.townFk = t.id
|
||||
AND (p.code = s.postCode OR s.postCode IS NULL)
|
||||
LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
|
||||
JOIN zoneGeo zg ON zg.id = p.geoFk
|
||||
WHERE s.id = vSelf
|
||||
ORDER BY (s.city SOUNDS LIKE t.name) DESC,
|
||||
(p.code = s.postCode) DESC,
|
||||
(p.code = sad.postalCode) DESC
|
||||
LIMIT 1;
|
||||
|
||||
RETURN vGeoFk;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,65 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME)
|
||||
RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
|
||||
NOT DETERMINISTIC
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Verifica la dirección de la fichada
|
||||
* @param vUserFk Identificador del trabajador
|
||||
* @param vTimed Hora de la fichada
|
||||
* @return Retorna sentido de la fichada 'in, out, middle'
|
||||
*/
|
||||
|
||||
DECLARE vPrevious DATETIME ;
|
||||
DECLARE vNext DATETIME ;
|
||||
DECLARE vPreviousDirection VARCHAR(3) ;
|
||||
DECLARE vNextDirection VARCHAR(3) ;
|
||||
DECLARE vDayStayMax INT;
|
||||
DECLARE vTimedSeconds INT;
|
||||
DECLARE vLastTimeIn INT;
|
||||
|
||||
SELECT UNIX_TIMESTAMP(vTimed) INTO vTimedSeconds;
|
||||
|
||||
SELECT dayStayMax INTO vDayStayMax
|
||||
FROM vn.workerTimeControlParams;
|
||||
|
||||
SELECT timed, direction INTO vNext,vNextDirection
|
||||
FROM vn.workerTimeControl
|
||||
WHERE userFk = vUserFk
|
||||
AND direction IN ('in','out')
|
||||
AND timed > vTimed
|
||||
ORDER BY timed ASC
|
||||
LIMIT 1;
|
||||
|
||||
SELECT timed, direction INTO vPrevious, vPreviousDirection
|
||||
FROM vn.workerTimeControl
|
||||
WHERE userFk = vUserFk
|
||||
AND direction IN ('in','out')
|
||||
AND timed < vTimed
|
||||
ORDER BY timed DESC
|
||||
LIMIT 1;
|
||||
|
||||
IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN
|
||||
RETURN 'middle';
|
||||
END IF;
|
||||
|
||||
|
||||
IF (vTimedSeconds> UNIX_TIMESTAMP(vPrevious)) THEN
|
||||
IF vPreviousDirection = 'in' THEN
|
||||
RETURN 'out';
|
||||
ELSE
|
||||
SELECT UNIX_TIMESTAMP(MAX(timed)) INTO vLastTimeIn
|
||||
FROM vn.workerTimeControl
|
||||
WHERE userFk = vUserFk
|
||||
AND direction ='in'
|
||||
AND timed < vPrevious;
|
||||
IF vTimedSeconds - vLastTimeIn <= vDayStayMax THEN
|
||||
RETURN 'out';
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
RETURN 'in';
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -39,7 +39,7 @@ BEGIN
|
|||
AND vWarehouseFk IN (tr.warehouseInFk, 0)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
UNION ALL
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
|
@ -58,7 +58,7 @@ BEGIN
|
|||
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
UNION ALL
|
||||
SELECT t.shipped,
|
||||
NULL,
|
||||
|
|
|
@ -42,7 +42,7 @@ proc: BEGIN
|
|||
WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom
|
||||
AND t.warehouseInFk = vWarehouseLanding
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
GROUP BY c.itemFk;
|
||||
|
||||
-- Tabla con el ultimo dia de last_buy para cada producto
|
||||
|
@ -57,7 +57,7 @@ proc: BEGIN
|
|||
JOIN travel tr ON tr.id = e.travelFk
|
||||
LEFT JOIN tItemRange i ON t.itemFk = i.itemFk
|
||||
WHERE t.warehouseFk = vWarehouseShipment
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated,
|
||||
tr.landed);
|
||||
|
||||
|
@ -94,7 +94,7 @@ proc: BEGIN
|
|||
JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk
|
||||
WHERE NOT e.isExcludedFromAvailable
|
||||
AND b.quantity <> 0
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
AND t.warehouseInFk = vWarehouseLanding
|
||||
AND t.landed >= vDatedFrom
|
||||
AND (ir.dated IS NULL OR t.landed <= ir.dated)
|
||||
|
|
|
@ -83,7 +83,7 @@ BEGIN
|
|||
AND s.semaphore = 1
|
||||
GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk
|
||||
JOIN itemShelving ish ON ish.itemFk = ts.itemFk
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector sc ON sc.id = p.sectorFk
|
||||
JOIN sectorType st ON st.id = sc.typeFk
|
||||
|
|
|
@ -166,7 +166,7 @@ BEGIN
|
|||
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
|
||||
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
|
||||
WHERE ic.display
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
AND (ti.visible OR ti.available)
|
||||
ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name;
|
||||
|
||||
|
|
|
@ -9,18 +9,16 @@ BEGIN
|
|||
*
|
||||
* @param vSelf Id de entrada
|
||||
*/
|
||||
DECLARE vIsNotEditable BOOL DEFAULT FALSE;
|
||||
DECLARE vIsEditable BOOL;
|
||||
|
||||
SELECT TRUE INTO vIsNotEditable
|
||||
SELECT e.isBooked INTO vIsEditable
|
||||
FROM `entry` e
|
||||
LEFT JOIN entryType et ON et.code = e.typeFk
|
||||
WHERE e.id = vSelf
|
||||
AND e.isBooked
|
||||
AND (e.typeFk IS NULL OR NOT et.isInformal);
|
||||
JOIN entryType et ON et.code = e.typeFk
|
||||
WHERE NOT et.isInformal
|
||||
AND e.id = vSelf;
|
||||
|
||||
IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
|
||||
IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
|
||||
CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable'));
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(
|
||||
vShelvingCode VARCHAR(10),
|
||||
vFromEntryFk INT,
|
||||
vToEntryFk INT
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Divide las compras entre dos entradas de
|
||||
* acuerdo con lo ubicado en una matricula.
|
||||
* Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr<EFBFBD>cula
|
||||
*
|
||||
* @param vShelvingCode Código de vn.shelving
|
||||
* @param vShelvingFk Identificador de vn.shelving
|
||||
* @param vFromEntryFk Entrada origen
|
||||
* @param vToEntryFk Entrada destino
|
||||
*/
|
||||
|
@ -19,7 +14,7 @@ BEGIN
|
|||
DECLARE vDone BOOLEAN DEFAULT FALSE;
|
||||
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT bb.id buyFk,
|
||||
SELECT bb.id buyFk,
|
||||
LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers,
|
||||
bb.stickers buyStickers
|
||||
FROM itemShelving ish
|
||||
|
@ -28,7 +23,7 @@ BEGIN
|
|||
WHERE b.entryFk = vFromEntryFk
|
||||
ORDER BY b.stickers DESC
|
||||
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
|
||||
WHERE ish.shelvingFk = vShelvingCode COLLATE utf8_general_ci
|
||||
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
|
||||
AND NOT ish.isSplit
|
||||
GROUP BY ish.id;
|
||||
|
||||
|
@ -112,10 +107,9 @@ BEGIN
|
|||
UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID();
|
||||
END IF;
|
||||
|
||||
UPDATE itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
SET ish.isSplit = TRUE
|
||||
WHERE sh.code = vShelvingCode COLLATE utf8_general_ci;
|
||||
UPDATE itemShelving
|
||||
SET isSplit = TRUE
|
||||
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci;
|
||||
END LOOP;
|
||||
CLOSE cur;
|
||||
END$$
|
||||
|
|
|
@ -22,7 +22,7 @@ BEGIN
|
|||
FROM vn.entry e
|
||||
JOIN vn.travel t ON t.id = e.travelFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||
WHERE t.landed >= util.VN_CURDATE()
|
||||
WHERE t.shipped >= util.VN_CURDATE()
|
||||
AND e.currencyFk = vCurrency
|
||||
AND NOT e.isBooked;
|
||||
|
||||
|
@ -33,7 +33,7 @@ BEGIN
|
|||
SET e.commission = vComission;
|
||||
|
||||
SELECT `name` INTO vCurrencyName
|
||||
FROM currency
|
||||
FROM currency
|
||||
WHERE id = vCurrency;
|
||||
|
||||
CALL entry_recalc();
|
||||
|
|
|
@ -4,12 +4,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(
|
|||
vExpeditionFk INT
|
||||
)
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT id FROM expeditionPallet WHERE id = vPalletFk) THEN
|
||||
CALL util.throw('Pallet not exists');
|
||||
IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN
|
||||
CALL util.throw('Expedition not exists');
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT id FROM expedition WHERE id = vExpeditionFk) THEN
|
||||
CALL util.throw('Expedition not exists');
|
||||
IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN
|
||||
CALL util.throw('Pallet not exists');
|
||||
END IF;
|
||||
|
||||
REPLACE expeditionScan(expeditionFk, palletFk)
|
||||
|
|
|
@ -137,7 +137,7 @@ BEGIN
|
|||
JOIN travel tr ON tr.id = e.travelFk
|
||||
WHERE tr.warehouseInFk = vWarehouseFk
|
||||
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
GROUP BY b.itemFk;
|
||||
|
||||
-- Transfers
|
||||
|
@ -150,7 +150,7 @@ BEGIN
|
|||
JOIN travel tr ON tr.id = e.travelFk
|
||||
WHERE tr.warehouseOutFk = vWarehouseFk
|
||||
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
GROUP BY b.itemFk
|
||||
) sub
|
||||
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
|
||||
|
|
|
@ -219,7 +219,7 @@ BEGIN
|
|||
) eWithheld ON TRUE
|
||||
WHERE tii.taxTypeSageFk IS NOT NULL
|
||||
AND (tii.taxCode IS NULL OR tii.taxCode NOT IN ('import10', 'import21'))
|
||||
GROUP BY tii.CuentaIvaRepercutido;
|
||||
GROUP BY tii.PorcentajeIva, tii.expenseFk;
|
||||
|
||||
-- Línea iva inversor sujeto pasivo
|
||||
INSERT INTO XDiario(
|
||||
|
@ -284,7 +284,7 @@ BEGIN
|
|||
AND NOT(tii.isVies
|
||||
AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk
|
||||
AND tii.taxCode = 'nonTaxable')
|
||||
GROUP BY tii.CuentaIvaRepercutido;
|
||||
GROUP BY tii.PorcentajeIva, tii.expenseFk;
|
||||
|
||||
-- Actualización del registro original
|
||||
UPDATE invoiceIn ii
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(
|
||||
vShelvingCode VARCHAR(10),
|
||||
vQuantity INT,
|
||||
vItemFk INT
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT)
|
||||
BEGIN
|
||||
|
||||
SELECT ish.itemFk,
|
||||
|
@ -13,21 +9,21 @@ BEGIN
|
|||
ish.itemShelvingFk,
|
||||
ish.shelving,
|
||||
ish.stock,
|
||||
LEAST(ish.stock,vQuantity) total,
|
||||
LEAST(ish.stock,quantity) as total,
|
||||
CONCAT(
|
||||
CAST(FLOOR(LEAST(ish.stock, vQuantity) / ish.packing) AS DECIMAL(10,0)),
|
||||
CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)),
|
||||
' x ',
|
||||
ish.packing,
|
||||
IF (
|
||||
LEAST(ish.stock, vQuantity) MOD ish.packing,
|
||||
CONCAT(' + ',CAST(LEAST(ish.stock, vQuantity) MOD ish.packing AS DECIMAL(10,0))),
|
||||
LEAST(ish.stock,quantity) MOD ish.packing,
|
||||
CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))),
|
||||
''
|
||||
),
|
||||
' = ',
|
||||
LEAST(ish.stock, vQuantity)
|
||||
) proposal
|
||||
FROM itemShelvingPlacementSupplyStock ish
|
||||
WHERE ish.shelving = vShelvingCode COLLATE utf8_general_ci
|
||||
LEAST(ish.stock,quantity)
|
||||
) as proposal
|
||||
FROM vn.itemShelvingPlacementSupplyStock ish
|
||||
WHERE ish.shelving = vShelvingFk COLLATE utf8_general_ci
|
||||
AND ish.itemFk = vItemFk;
|
||||
|
||||
END$$
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(
|
||||
vSectorFk INT
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(vSector INT )
|
||||
BEGIN
|
||||
|
||||
DECLARE vId INT;
|
||||
|
@ -9,35 +7,31 @@ BEGIN
|
|||
DECLARE vNextParkingFk INT;
|
||||
|
||||
SELECT sh.parkingFk INTO vLastParkingFk
|
||||
FROM itemShelvingPlacementSupply isps
|
||||
JOIN itemShelving ish ON ish.id = isps.itemShelvingFk
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
FROM vn.itemShelvingPlacementSupply isps
|
||||
JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
WHERE isps.userFk = getUser()
|
||||
ORDER BY isps.created DESC
|
||||
LIMIT 1;
|
||||
|
||||
SET vNextParkingFk = itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
|
||||
SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
|
||||
|
||||
SELECT ipsl.id INTO vId
|
||||
FROM itemPlacementSupplyList ipsl
|
||||
JOIN itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
|
||||
FROM vn.itemPlacementSupplyList ipsl
|
||||
JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
|
||||
WHERE ipsl.saldo > 0
|
||||
AND (ipsl.repoUserFk is NULL OR ipsl.repoUserFk = getUser())
|
||||
AND ipsl.sectorFk = vSectorFk
|
||||
ORDER BY ipsl.repoUserFk DESC,
|
||||
ipsl.priority DESC,
|
||||
(ispss.parkingFk = vNextParkingFk) DESC,
|
||||
ispss.parking DESC,
|
||||
ipsl.created
|
||||
AND ipsl.sectorFk = vSector
|
||||
ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created
|
||||
LIMIT 1;
|
||||
|
||||
UPDATE itemPlacementSupply
|
||||
UPDATE vn.itemPlacementSupply
|
||||
SET repoUserFk = getUser()
|
||||
WHERE id = vId;
|
||||
|
||||
SELECT * FROM itemPlacementSupplyList
|
||||
SELECT * FROM vn.itemPlacementSupplyList
|
||||
WHERE id = vId
|
||||
AND sectorFk = vSectorFk;
|
||||
AND sectorFk = vSector;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(
|
||||
vItemFk INT,
|
||||
vSectorFk INT
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa.
|
||||
|
@ -16,11 +13,11 @@ BEGIN
|
|||
SUM(ish.visible) stockTotal,
|
||||
ish.created,
|
||||
p.pickingOrder
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector sc ON sc.id = p.sectorFk
|
||||
JOIN warehouse w ON w.id = sc.warehouseFk
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector sc ON sc.id = p.sectorFk
|
||||
JOIN vn.warehouse w ON w.id = sc.warehouseFk
|
||||
WHERE ish.visible > 0
|
||||
AND ish.itemFk = vItemFk
|
||||
GROUP BY ish.id
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(
|
||||
vShelvingCode VARCHAR(10)
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(vShelvingFk VARCHAR(10) )
|
||||
BEGIN
|
||||
|
||||
/**
|
||||
* Devuelve el log de los item en cada carro
|
||||
*
|
||||
* @param vShelvingCode Matrícula del carro
|
||||
* @param vShelvingFk Matrícula del carro
|
||||
*
|
||||
*/
|
||||
|
||||
SELECT isl.itemShelvingFk,
|
||||
isl.created,
|
||||
isl.accion,
|
||||
|
@ -28,9 +28,8 @@ BEGIN
|
|||
FROM item
|
||||
JOIN itemShelvingLog isl ON item.id = isl.itemFk
|
||||
JOIN worker ON isl.workerFk = worker.id
|
||||
JOIN shelving sh ON sh.id = isl.shelvingFk
|
||||
WHERE sh.code = vShelvingCode COLLATE utf8mb3_unicode_ci
|
||||
OR isl.itemFk = vShelvingCode -- ?? Respeto porque ya estaba
|
||||
ORDER BY isl.created DESC;
|
||||
WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk
|
||||
ORDER BY isl.created DESC;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -20,7 +20,7 @@ BEGIN
|
|||
LEFT JOIN (
|
||||
SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
LEFT JOIN parking pk ON pk.id = sh.parkingFk
|
||||
WHERE ish.created BETWEEN vFromTimed AND vToTimed
|
||||
GROUP BY itemFk
|
||||
|
|
|
@ -27,7 +27,7 @@ proc: BEGIN
|
|||
ish.available
|
||||
FROM sale s
|
||||
JOIN itemShelving ish ON ish.itemFk = s.itemFk
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector sc ON sc.id = p.sectorFk
|
||||
JOIN productionConfig pc
|
||||
|
@ -61,7 +61,7 @@ proc: BEGIN
|
|||
FROM sale s
|
||||
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
LEFT JOIN parking p ON p.id = sh.parkingFk
|
||||
WHERE s.id = vSaleFk;
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQ
|
|||
vItemShelvingSaleFk INT(10),
|
||||
vQuantity DECIMAL(10,0),
|
||||
vIsItemShelvingSaleEmpty BOOLEAN,
|
||||
vSectorFk INT,
|
||||
vShelvingFk VARCHAR(10)
|
||||
vSectorFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
|
@ -25,7 +24,6 @@ BEGIN
|
|||
DECLARE vItemFk INT;
|
||||
DECLARE vTotalQuantity INT;
|
||||
DECLARE vStateCode VARCHAR(45);
|
||||
DECLARE vCurrentShelvingFk VARCHAR(10);
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
|
@ -47,26 +45,18 @@ BEGIN
|
|||
iss.saleFk,
|
||||
iss.itemShelvingFk,
|
||||
SUM(IFNULL(iss.quantity,0)),
|
||||
IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED'),
|
||||
sh.code
|
||||
IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED')
|
||||
INTO vItemFk,
|
||||
vSaleFk,
|
||||
vItemShelvingFk,
|
||||
vReservedQuantity,
|
||||
vStateCode,
|
||||
vCurrentShelvingFk
|
||||
vStateCode
|
||||
FROM itemShelvingSale iss
|
||||
JOIN sale s ON s.id = iss.saleFk
|
||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
|
||||
LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
|
||||
WHERE iss.id = vItemShelvingSaleFk
|
||||
AND NOT iss.isPicked;
|
||||
|
||||
IF NOT (vCurrentShelvingFk <=> vShelvingFk) THEN
|
||||
CALL util.throw('The shelving can not be different from the shelving reserved');
|
||||
END IF;
|
||||
|
||||
IF vQuantity > vReservedQuantity
|
||||
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
|
||||
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_add`(
|
||||
vShelvingCode VARCHAR(10),
|
||||
vShelvingFk VARCHAR(8),
|
||||
vBarcode VARCHAR(22),
|
||||
vQuantity INT,
|
||||
vPackagingFk VARCHAR(10),
|
||||
|
@ -12,7 +12,7 @@ BEGIN
|
|||
/**
|
||||
* Añade registro o lo actualiza si ya existe.
|
||||
*
|
||||
* @param vShelvingCode matrícula del carro
|
||||
* @param vShelvingFk matrícula del carro
|
||||
* @param vBarcode el id del registro
|
||||
* @param vQuantity indica la cantidad del producto
|
||||
* @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra
|
||||
|
@ -23,15 +23,10 @@ BEGIN
|
|||
**/
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vBuyFk INT;
|
||||
DECLARE vShelvingFk INT;
|
||||
|
||||
SELECT id INTO vBuyFk
|
||||
FROM buy WHERE id = vBarcode;
|
||||
|
||||
SELECT id INTO vShelvingFk
|
||||
FROM shelving
|
||||
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
|
||||
|
||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
||||
|
||||
IF vBuyFk IS NULL THEN
|
||||
|
@ -45,7 +40,7 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
IF (SELECT COUNT(*) FROM itemShelving
|
||||
WHERE shelvingFk = vShelvingFk
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||
AND itemFk = vItemFk
|
||||
AND packing = vPacking
|
||||
AND buyFk = vBuyFk) THEN
|
||||
|
@ -53,9 +48,7 @@ BEGIN
|
|||
UPDATE itemShelving
|
||||
SET visible = visible + vQuantity,
|
||||
available = available + vQuantity
|
||||
WHERE shelvingFk = vShelvingFk
|
||||
AND itemFk = vItemFk
|
||||
AND packing = vPacking;
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
|
||||
|
||||
ELSE
|
||||
|
||||
|
|
|
@ -1,38 +1,29 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(
|
||||
vClaimFk INT,
|
||||
vShelvingCode VARCHAR(10)
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3))
|
||||
BEGIN
|
||||
/**
|
||||
* Insert items of claim into itemShelving.
|
||||
*
|
||||
* @param vClaimFk The claim
|
||||
* @param vShelvingCode The shelving code
|
||||
* @param vShelvingFk The shelving
|
||||
* @table tmp.buyUltimate
|
||||
*/
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vShelvingFk INT;
|
||||
|
||||
SELECT t.warehouseFk INTO vWarehouseFk
|
||||
FROM claim c
|
||||
JOIN ticket t ON t.id = c.ticketFk
|
||||
WHERE c.id = vClaimFk;
|
||||
|
||||
SELECT id INTO vShelvingFk
|
||||
FROM shelving
|
||||
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
|
||||
|
||||
CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE());
|
||||
|
||||
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
|
||||
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity visible
|
||||
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
|
||||
FROM claim c
|
||||
JOIN claimBeginning cb ON c.id = cb.claimFk
|
||||
JOIN sale s ON s.id = cb.saleFk
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
AND bu.warehouseFk = t.warehouseFk
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE c.id = vClaimFk;
|
||||
END$$
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(
|
||||
vShelvingCode VARCHAR(10),
|
||||
vShelvingFk VARCHAR(3),
|
||||
vList TEXT,
|
||||
vIsChecking BOOL,
|
||||
vWarehouseFk INT
|
||||
|
@ -13,7 +13,7 @@ BEGIN
|
|||
* Cuando es TRUE sólo inserta los elementos de la colección que no están ya en
|
||||
* ese shelving, actualizando los valores del campo itemShelving.isChecked
|
||||
*
|
||||
* @param vShelvingCode Código de shelving
|
||||
* @param vShelvingFk Identificador de shelving
|
||||
* @param vList JSON array con esta estructura: '[value1, value2, ...]'
|
||||
* @param vIsChecking Define si hay que añadir o comprobar los items
|
||||
* @param vWarehouseFk Identificador de warehouse
|
||||
|
@ -24,11 +24,6 @@ BEGIN
|
|||
DECLARE vPath VARCHAR(6);
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vIsChecked BOOL;
|
||||
DECLARE vShelvingFk INT;
|
||||
|
||||
SELECT id INTO vShelvingFk
|
||||
FROM shelving
|
||||
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
|
||||
|
||||
WHILE vCounter < vListLength DO
|
||||
SET vPath = CONCAT('$[', vCounter, ']');
|
||||
|
@ -39,17 +34,17 @@ BEGIN
|
|||
|
||||
SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked
|
||||
FROM itemShelving
|
||||
WHERE shelvingFk = vShelvingFk
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||
AND itemFk = vItemFk;
|
||||
END IF;
|
||||
|
||||
IF NOT vIsChecking OR NOT vIsChecked THEN
|
||||
CALL itemShelving_add(vShelvingCode, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
|
||||
CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
|
||||
END IF;
|
||||
|
||||
UPDATE itemShelving
|
||||
SET isChecked = vIsChecked
|
||||
WHERE shelvingFk = vShelvingFk
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||
AND itemFk = vItemFk
|
||||
AND isChecked IS NULL;
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(
|
||||
vShelvingCode VARCHAR(10)
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8))
|
||||
BEGIN
|
||||
/**
|
||||
* Lista artículos de itemShelving.
|
||||
* Lista artículos de itemshelving
|
||||
*
|
||||
* @param vShelvingCode Matrícula del carro
|
||||
* @param vSelf matrícula del carro
|
||||
**/
|
||||
SELECT ish.itemFk item,
|
||||
i.name,
|
||||
|
@ -21,13 +19,12 @@ BEGIN
|
|||
ish.isChecked,
|
||||
ic.url,
|
||||
ish.available,
|
||||
ish.buyFk,
|
||||
ish.shelvingFk
|
||||
ish.buyFk
|
||||
FROM itemShelving ish
|
||||
JOIN item i ON i.id = ish.itemFk
|
||||
JOIN shelving s ON s.id = ish.shelvingFk
|
||||
LEFT JOIN parking p ON p.id = s.parkingFk
|
||||
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
|
||||
LEFT JOIN parking p ON s.parkingFk = p.id
|
||||
JOIN hedera.imageConfig ic
|
||||
WHERE s.code COLLATE utf8_unicode_ci = vShelvingCode;
|
||||
WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,31 +1,21 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(
|
||||
vShelvingCode VARCHAR(10)
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(vShelvingFk VARCHAR(10))
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve un listado de posibles ubicaciones alternativas a ubicar
|
||||
* los item de la matricula del carro que se le ha pasado.
|
||||
* Devuelve un listado de posibles ubicaciones alternativas a ubicar los item de la matricula
|
||||
* del carro que se le ha pasado.
|
||||
*
|
||||
* @param vShelvingCode Matricula del carro
|
||||
* @param vShelvingFk matricula del carro
|
||||
*/
|
||||
DECLARE vShelvingFk INT;
|
||||
|
||||
SELECT id INTO vShelvingFk
|
||||
FROM shelving
|
||||
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
|
||||
|
||||
SELECT is2.id,is2.shelvingFk, p.code, is2.itemFk , is2.visible, p.pickingOrder
|
||||
SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder
|
||||
FROM itemShelving is2
|
||||
JOIN shelving sh ON sh.id = is2.shelvingFk
|
||||
JOIN shelving sh ON sh.code = is2.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector s ON s.id = p.sectorFk
|
||||
LEFT JOIN operator o ON o.sectorFk = s.id
|
||||
AND o.workerFk = account.myUser_getId()
|
||||
LEFT JOIN operator o ON o.sectorFk = s.id AND o.workerFk = account.myUser_getId()
|
||||
JOIN warehouse wh ON wh.id = s.warehouseFk
|
||||
JOIN itemShelving is3 ON is3.itemFk = is2.itemFk
|
||||
AND is3.shelvingFk = vShelvingFk
|
||||
WHERE is2.shelvingFk <> vShelvingFk
|
||||
JOIN itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
|
||||
WHERE is2.shelvingFk <> vShelvingFk COLLATE utf8_unicode_ci
|
||||
GROUP BY is2.id
|
||||
ORDER BY p.pickingOrder DESC;
|
||||
END$$
|
||||
|
|
|
@ -16,7 +16,7 @@ BEGIN
|
|||
ish.itemFk itemFk,
|
||||
sh.priority
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.`code` = ish.shelvingFk
|
||||
JOIN vn.parking pk ON pk.id = sh.parkingFk
|
||||
WHERE ish.itemFk = vItemFk
|
||||
ORDER BY sh.priority DESC, created ASC;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(
|
||||
vBarcodeItem INT,
|
||||
vShelvingCode VARCHAR(10)
|
||||
vShelvingFK VARCHAR(10)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Obtiene el precio y visible de un item
|
||||
*
|
||||
* @param vBarcodeItem barcode de artículo
|
||||
* @param vShelvingCode Ubicación actual del artículo
|
||||
* @param vShelvingFK Ubicación actual del artículo
|
||||
*/
|
||||
DECLARE vIsItem BOOL;
|
||||
DECLARE vBuyFk INT;
|
||||
|
@ -38,19 +38,18 @@ BEGIN
|
|||
WITH visible AS(
|
||||
SELECT itemFk,
|
||||
IFNULL(buyingValue, 0) +
|
||||
IFNULL(freightValue, 0) +
|
||||
IFNULL(comissionValue, 0) +
|
||||
IFNULL(packageValue, 0) itemCost
|
||||
FROM vn.buy b
|
||||
IFNULL(freightValue, 0) +
|
||||
IFNULL(comissionValue, 0) +
|
||||
IFNULL(packageValue, 0) itemCost
|
||||
FROM vn.buy b
|
||||
WHERE b.id = vBuyFk
|
||||
) SELECT v.itemFk,
|
||||
vShelvingCode,
|
||||
vShelvingFK,
|
||||
v.itemCost,
|
||||
SUM(ish.visible) visible
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFK
|
||||
JOIN visible v
|
||||
WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci
|
||||
AND ish.itemFk = v.itemFk;
|
||||
WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci
|
||||
AND ish.itemFk = v.itemFk;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,20 +1,14 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(
|
||||
vShelvingCode VARCHAR(10)
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(vShelvingFk VARCHAR(3))
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
|
||||
*
|
||||
* @param vShelvingCode Matrícula del carro o pallet
|
||||
*/
|
||||
|
||||
/* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
|
||||
*
|
||||
* @param vShelvingFk Matrícula del carro o pallet
|
||||
*/
|
||||
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vStockScopeDays INT;
|
||||
DECLARE vShelvingFk INT;
|
||||
|
||||
SELECT id INTO vShelvingFk
|
||||
FROM shelving
|
||||
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
|
||||
|
||||
SELECT s.warehouseFk, stockScopeDays
|
||||
INTO vWarehouseFk, vStockScopeDays
|
||||
|
@ -36,7 +30,7 @@ BEGIN
|
|||
ENGINE = MEMORY
|
||||
SELECT itemFk, SUM(visible) visible
|
||||
FROM itemShelving
|
||||
WHERE shelvingFk = vShelvingFk
|
||||
WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
|
||||
GROUP BY itemFk;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay
|
||||
|
@ -58,7 +52,7 @@ BEGIN
|
|||
SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE()
|
||||
FROM itemShelving ish
|
||||
JOIN tmp.tItems i ON i.itemFk = ish.itemFk
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON sh.parkingFk = p.id
|
||||
JOIN sector s ON s.id = p.sectorFk
|
||||
WHERE s.isReserve
|
||||
|
@ -116,7 +110,7 @@ BEGIN
|
|||
UPDATE tmp.tStockByDay sbd
|
||||
JOIN (SELECT ish.itemFK, SUM(ish.visible) amount
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector s ON s.id = p.sectorFk
|
||||
WHERE s.warehouseFk = vWarehouseFk
|
||||
|
@ -156,10 +150,10 @@ BEGIN
|
|||
p.sectorFk,
|
||||
ish.shelvingFk
|
||||
FROM itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
LEFT JOIN parking p ON p.id = parkingFk
|
||||
LEFT JOIN vn.sector s ON s.id = p.sectorFk
|
||||
WHERE ish.shelvingFk = vShelvingFk
|
||||
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
|
||||
) sub4 ON sub4.itemFk = ts.itemFk
|
||||
LEFT JOIN sector s ON s.id = sub4.sectorFk
|
||||
LEFT JOIN item i ON i.id = ts.itemFk
|
||||
|
|
|
@ -42,7 +42,7 @@ BEGIN
|
|||
JOIN item i ON i.id = ish.itemFk
|
||||
JOIN itemType it ON it.id = i.typeFk
|
||||
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
LEFT JOIN (
|
||||
SELECT s.itemFk, sum(s.quantity) notPrepared
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`(
|
||||
vShelvingCode VARCHAR(10) COLLATE utf8_general_ci,
|
||||
vShelvingFk VARCHAR(10) COLLATE utf8_general_ci,
|
||||
vItemFk INT,
|
||||
vQuantity INT
|
||||
)
|
||||
|
@ -9,9 +9,9 @@ BEGIN
|
|||
* Leave the indicated amount on the shelve
|
||||
* and create a ticket with the difference.
|
||||
*
|
||||
* @param vShelvingCode Code of the shelve where the item is located
|
||||
* @param vItemFk Item of which the self-consumption ticket is to be created
|
||||
* @param vQuantity Amount that will stay on the shelve
|
||||
* @param vShelvingFk id of the shelve where the item is located.
|
||||
* @param vItemFk article of which the self-consumption ticket is to be created.
|
||||
* @param vQuantity amount that will stay on the shelve
|
||||
*/
|
||||
DECLARE vVisible INT;
|
||||
DECLARE vClientFk INT;
|
||||
|
@ -21,11 +21,6 @@ BEGIN
|
|||
DECLARE vAgencyModeFk INT;
|
||||
DECLARE vItemShelvingFk INT;
|
||||
DECLARE vAddressFk INT;
|
||||
DECLARE vShelvingFk INT;
|
||||
|
||||
SELECT id INTO vShelvingFk
|
||||
FROM shelving
|
||||
WHERE code = vShelvingCode;
|
||||
|
||||
SELECT c.id,
|
||||
pc.clientSelfConsumptionFk,
|
||||
|
@ -42,7 +37,7 @@ BEGIN
|
|||
JOIN parking p ON p.sectorFk = s.id
|
||||
JOIN shelving s2 ON s2.parkingFk = p.id
|
||||
JOIN productionConfig pc
|
||||
WHERE s2.id = vShelvingFk;
|
||||
WHERE s2.code = vShelvingFk;
|
||||
|
||||
IF vClientFk IS NULL THEN
|
||||
CALL util.throw('The company does not have a customer assigned');
|
||||
|
@ -52,7 +47,7 @@ BEGIN
|
|||
CALL util.throw('The shelf cannot have NULL or negative quantities');
|
||||
END IF;
|
||||
|
||||
IF vShelvingCode IS NULL THEN
|
||||
IF vShelvingFk IS NULL THEN
|
||||
CALL util.throw('The shelf is necessary');
|
||||
END IF;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`(
|
||||
vItemShelvingFk INT,
|
||||
vShelvingCode VARCHAR(10)
|
||||
vShelvingFk VARCHAR(10)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
|
@ -9,14 +9,9 @@ BEGIN
|
|||
* fusionando si coincide el packing y la fecha.
|
||||
*
|
||||
* @param vItemShelvingFk Identificador de itemShelving
|
||||
* @param vShelvingCode Código de shelving
|
||||
* @param vShelvingFk Identificador de shelving
|
||||
*/
|
||||
DECLARE vNewItemShelvingFk INT;
|
||||
DECLARE vShelvingFk INT;
|
||||
|
||||
SELECT id INTO vShelvingFk
|
||||
FROM shelving
|
||||
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
|
||||
|
||||
SELECT MAX(ish.id) INTO vNewItemShelvingFk
|
||||
FROM itemShelving ish
|
||||
|
@ -31,7 +26,7 @@ BEGIN
|
|||
AND ish2.packing = ish.packing
|
||||
AND DATE(ish2.created) = DATE(ish.created)
|
||||
AND ish2.buyFk = ish.buyFk
|
||||
WHERE ish.shelvingFk = vShelvingFk;
|
||||
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
|
||||
|
||||
IF vNewItemShelvingFk THEN
|
||||
UPDATE itemShelving ish
|
||||
|
@ -43,7 +38,9 @@ BEGIN
|
|||
DELETE FROM itemShelving
|
||||
WHERE id = vItemShelvingFk;
|
||||
ELSE
|
||||
IF (SELECT EXISTS(SELECT id FROM shelving WHERE id = vShelvingFk)) THEN
|
||||
IF (SELECT EXISTS(SELECT id FROM shelving
|
||||
WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN
|
||||
|
||||
UPDATE itemShelving
|
||||
SET shelvingFk = vShelvingFk
|
||||
WHERE id = vItemShelvingFk;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_devalueA2`(
|
||||
vSelf INT,
|
||||
vShelvingCode VARCHAR(10) COLLATE utf8mb3_general_ci,
|
||||
vShelvingFK VARCHAR(10),
|
||||
vBuyingValue DECIMAL(10,4),
|
||||
vQuantity INT
|
||||
)
|
||||
|
@ -12,7 +12,7 @@ BEGIN
|
|||
* de almacén y shelvings correspondientes
|
||||
*
|
||||
* @param vSelf Id de artículo a devaluar
|
||||
* @param vShelvingCode Código de shelving / ubicación
|
||||
* @param vShelvingFK Ubicación actual del artículo
|
||||
* @param vBuyingValue Nuevo precio de coste
|
||||
* @param vQuantity Cantidad del ítem a pasar a A2
|
||||
*/
|
||||
|
@ -109,11 +109,10 @@ BEGIN
|
|||
CALL util.throw ('The item has not a buy');
|
||||
END IF;
|
||||
|
||||
SELECT ish.id, ish.visible INTO vTargetItemShelvingFk, vCurrentVisible
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
WHERE sh.code = vShelvingCode
|
||||
AND ish.itemFk = vSelf
|
||||
SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible
|
||||
FROM itemShelving
|
||||
WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
|
||||
AND itemFk = vSelf
|
||||
LIMIT 1;
|
||||
|
||||
IF vCurrentVisible IS NULL THEN
|
||||
|
@ -389,17 +388,16 @@ BEGIN
|
|||
userFk,
|
||||
isChecked)
|
||||
SELECT vItemA2Fk,
|
||||
ish.shelvingFk,
|
||||
shelvingFk,
|
||||
vQuantity ,
|
||||
ish.`grouping`,
|
||||
ish.packing,
|
||||
ish.packagingFk,
|
||||
`grouping`,
|
||||
packing,
|
||||
packagingFk,
|
||||
account.myUser_getId(),
|
||||
ish.isChecked
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
WHERE ish.itemFK = vSelf
|
||||
AND sh.code = vShelvingCode
|
||||
isChecked
|
||||
FROM itemShelving
|
||||
WHERE itemFK = vSelf
|
||||
AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
|
||||
ON DUPLICATE KEY UPDATE
|
||||
visible = vQuantity + VALUES(visible);
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ BEGIN
|
|||
AND (s.id <> vSupplierInventoryFk OR vDated IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
),
|
||||
entriesOut AS (
|
||||
SELECT 'entry',
|
||||
|
@ -95,7 +95,7 @@ BEGIN
|
|||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT w.isFeedStock
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
),
|
||||
sales AS (
|
||||
WITH itemSales AS (
|
||||
|
|
|
@ -63,7 +63,7 @@ BEGIN
|
|||
AND NOT e.isExcludedFromAvailable
|
||||
AND b.quantity <> 0
|
||||
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
UNION ALL
|
||||
SELECT r.itemFk,
|
||||
r.shipment,
|
||||
|
|
|
@ -30,7 +30,7 @@ BEGIN
|
|||
AND NOT s.name = 'INVENTARIO'
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND w.isComparative
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
GROUP BY i.id;
|
||||
|
||||
UPDATE tmp.itemInventory y
|
||||
|
|
|
@ -109,7 +109,7 @@ BEGIN
|
|||
JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||
WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd
|
||||
AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE)
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
AND w.valuatedInventory
|
||||
AND t.isInventory
|
||||
AND e.supplierFk <> vInventorySupplierFk
|
||||
|
@ -131,7 +131,7 @@ BEGIN
|
|||
JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
||||
WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
AND w.valuatedInventory
|
||||
AND t.isInventory
|
||||
AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL)
|
||||
|
@ -196,7 +196,7 @@ BEGIN
|
|||
JOIN warehouse wIn ON wIn.id = tr.warehouseInFk
|
||||
JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk
|
||||
WHERE vDated >= tr.shipped AND vDated < tr.landed
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
AND wIn.valuatedInventory
|
||||
AND t.isInventory
|
||||
AND e.isConfirmed
|
||||
|
|
|
@ -60,7 +60,7 @@ proc: BEGIN
|
|||
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
||||
AND w.isComparative
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
UNION ALL
|
||||
SELECT b.itemFk, - b.quantity
|
||||
FROM buy b
|
||||
|
@ -71,7 +71,7 @@ proc: BEGIN
|
|||
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
||||
AND w.isComparative
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
) sub
|
||||
GROUP BY itemFk;
|
||||
|
||||
|
@ -121,7 +121,7 @@ proc: BEGIN
|
|||
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
|
||||
AND w.isComparative
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
UNION ALL
|
||||
SELECT b.itemFk, t.shipped, - b.quantity
|
||||
FROM buy b
|
||||
|
@ -132,7 +132,7 @@ proc: BEGIN
|
|||
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
|
||||
AND w.isComparative
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT t.isRaid
|
||||
AND NOT t.daysInForward
|
||||
) sub
|
||||
GROUP BY sub.itemFk, sub.dated;
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ proc: BEGIN
|
|||
st.code = 'previousPrepared' isPreviousPrepared,
|
||||
sc.itemPackingTypeFk
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector sc ON sc.id = p.sectorFk
|
||||
JOIN sectorType st ON st.id = sc.typeFk
|
||||
|
|
|
@ -11,8 +11,6 @@ BEGIN
|
|||
*/
|
||||
DECLARE vIsUpdatable, vIsFreelance BOOL DEFAULT 0;
|
||||
DECLARE vAgencyModePricePercentage DOUBLE;
|
||||
DECLARE vIsKmTruckRate BOOL;
|
||||
DECLARE vCountryFk INT;
|
||||
|
||||
SELECT r.created >= rc.cutoffDated INTO vIsUpdatable
|
||||
FROM route r
|
||||
|
@ -23,16 +21,10 @@ BEGIN
|
|||
DELETE FROM routeCommission
|
||||
WHERE routeFk = vSelf;
|
||||
|
||||
SELECT w.isFreelance, v.isKmTruckRate, c.countryFk INTO vIsFreelance, vIsKmTruckRate, vCountryFk
|
||||
SELECT w.isFreelance INTO vIsFreelance
|
||||
FROM route r
|
||||
JOIN worker w ON w.id = r.workerFk
|
||||
JOIN vehicle v ON v.id = r.vehicleFk
|
||||
LEFT JOIN ticket t ON t.routeFk = r.id
|
||||
LEFT JOIN client c ON c.id = t.clientFk
|
||||
WHERE r.id = vSelf
|
||||
GROUP BY c.countryFk
|
||||
ORDER BY COUNT(*) DESC
|
||||
LIMIT 1;
|
||||
WHERE r.id = vSelf;
|
||||
|
||||
SELECT ampp.percentage INTO vAgencyModePricePercentage
|
||||
FROM route r
|
||||
|
@ -47,9 +39,7 @@ BEGIN
|
|||
workCenterFk,
|
||||
freelanceYearlyM3,
|
||||
cat4m3,
|
||||
cat5m3,
|
||||
isKmTruckRate,
|
||||
countryFk
|
||||
cat5m3
|
||||
)
|
||||
SELECT vSelf,
|
||||
r.commissionWorkCenterFk,
|
||||
|
@ -61,14 +51,11 @@ BEGIN
|
|||
IFNULL(r.m3, 0),
|
||||
0
|
||||
),
|
||||
IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),
|
||||
IFNULL(wc.distributionCat5M3, rc.distributionCat5M3) * IFNULL(r.m3, 0),
|
||||
vIsKmTruckRate,
|
||||
vCountryFk
|
||||
rc.distributionCat4M3 * IFNULL(r.m3, 0),
|
||||
rc.distributionCat5M3 * IFNULL(r.m3, 0)
|
||||
FROM route r
|
||||
JOIN vehicle v ON v.id = r.vehicleFk
|
||||
JOIN routeConfig rc
|
||||
LEFT JOIN workCenterCommission wc ON wc.workCenter = r.workCenterFk
|
||||
WHERE r.id = vSelf
|
||||
AND r.workerFk
|
||||
AND r.commissionWorkCenterFk;
|
||||
|
@ -81,9 +68,7 @@ BEGIN
|
|||
yearlyKm,
|
||||
yearlyM3,
|
||||
cat4m3,
|
||||
cat5m3,
|
||||
isKmTruckRate,
|
||||
countryFk
|
||||
cat5m3
|
||||
)
|
||||
SELECT vSelf,
|
||||
r.commissionWorkCenterFk,
|
||||
|
@ -93,14 +78,11 @@ BEGIN
|
|||
IF(v.isKmTruckRate, rc.deliveryM3Cat5, rc.deliveryM3Cat4),
|
||||
(r.kmEnd - r.kmStart) * rc.kmYearly,
|
||||
IFNULL(r.m3, 0) * rc.m3Yearly,
|
||||
IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),
|
||||
IFNULL(wc.distributionCat5M3, rc.distributionCat5M3) * IFNULL(r.m3, 0),
|
||||
vIsKmTruckRate,
|
||||
vCountryFk
|
||||
rc.distributionCat4M3 * IFNULL(r.m3, 0),
|
||||
rc.distributionCat5M3 * IFNULL(r.m3, 0)
|
||||
FROM route r
|
||||
JOIN vehicle v ON v.id = r.vehicleFk
|
||||
JOIN routeConfig rc
|
||||
LEFT JOIN workCenterCommission wc ON wc.workCenter = r.workCenterFk
|
||||
WHERE r.id = vSelf
|
||||
AND r.kmStart
|
||||
AND r.kmEnd
|
||||
|
|
|
@ -27,7 +27,7 @@ BEGIN
|
|||
DECLARE vQuantity INT;
|
||||
DECLARE vRemainder INT DEFAULT 0;
|
||||
DECLARE vRemainderSaleFk INT;
|
||||
DECLARE vShelvingFk VARCHAR(10);
|
||||
DECLARE vShelving VARCHAR(10);
|
||||
DECLARE vTicketFk INT;
|
||||
|
||||
SELECT s.quantity,
|
||||
|
@ -74,7 +74,7 @@ w1: WHILE vQuantity >= vPacking DO
|
|||
p.pickingOrder,
|
||||
ish.created
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
LEFT JOIN itemShelvingSale iss
|
||||
ON iss.itemShelvingFk = ish.id
|
||||
|
@ -262,9 +262,9 @@ w1: WHILE vQuantity >= vPacking DO
|
|||
CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE);
|
||||
|
||||
SELECT shelvingFk, p.code
|
||||
INTO vShelvingFk, vParkingCode
|
||||
INTO vShelving, vParkingCode
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
WHERE ish.id = vItemShelvingFk;
|
||||
|
||||
|
@ -273,7 +273,7 @@ w1: WHILE vQuantity >= vPacking DO
|
|||
itemFk = vItemFk,
|
||||
quantity = vPacking,
|
||||
longName = vConcept,
|
||||
shelvingFk = vShelvingFk,
|
||||
shelvingFk = vShelving,
|
||||
parkingCode = vParkingCode,
|
||||
phone = RIGHT(phone,vMaxPhoneLength),
|
||||
street = RIGHT(street, vMAxStreetLength)
|
||||
|
|
|
@ -41,7 +41,7 @@ BEGIN
|
|||
AND iss.created >= vDated
|
||||
GROUP BY iss.itemShelvingFk, s.itemFk) tISS
|
||||
ON tISS.itemFk = ish.itemFk AND tISS.itemShelvingFk = ish.id
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
|
||||
JOIN agencyMode am ON am.id = pb.agencyModeFk
|
||||
|
|
|
@ -87,7 +87,7 @@ BEGIN
|
|||
SUM(ish.visible) visible,
|
||||
s.warehouseFk warehouseFk
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector s ON s.id = p.sectorFk
|
||||
GROUP BY ish.itemFk, s.warehouseFk;
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(
|
||||
`vShelvingO` VARCHAR(10),
|
||||
`vShelvingD` VARCHAR(10)
|
||||
)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8))
|
||||
BEGIN
|
||||
UPDATE itemShelving ish
|
||||
JOIN shelving sh1 ON sh1.code = vShelvingD COLLATE utf8_unicode_ci
|
||||
JOIN shelving sh2 ON sh2.code = vShelvingO COLLATE utf8_unicode_ci
|
||||
SET ish.shelvingFk = sh1.id
|
||||
WHERE ish.shelvingFk = sh2.id;
|
||||
|
||||
UPDATE vn.itemShelving
|
||||
SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci
|
||||
WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci;
|
||||
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(
|
||||
vShelvingCode VARCHAR(10),
|
||||
vWarehouseFk INT,
|
||||
vDayRange INT
|
||||
)
|
||||
BEGIN
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT)
|
||||
BEGIN
|
||||
|
||||
|
||||
SELECT s.itemFk,
|
||||
s.concept,
|
||||
CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir,
|
||||
|
@ -12,15 +10,14 @@ SELECT s.itemFk,
|
|||
FROM vn.sale s
|
||||
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk
|
||||
AND ist.warehouseFk = vWarehouseFk
|
||||
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
AND sh.code = vShelvingCode COLLATE utf8_general_ci
|
||||
LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk
|
||||
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
|
||||
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE()))
|
||||
AND iss.saleFk IS NULL
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY s.itemFk
|
||||
HAVING sinServir > aparcado;
|
||||
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -12,12 +12,12 @@ BEGIN
|
|||
|
||||
DELETE ish.*
|
||||
FROM itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
WHERE sh.parkingFk IS NULL
|
||||
AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
|
||||
|
||||
UPDATE shelving sh
|
||||
LEFT JOIN itemShelving its ON its.shelvingFk = sh.id
|
||||
LEFT JOIN itemShelving its ON its.shelvingFk = sh.`code`
|
||||
SET isPrinted = 0,
|
||||
parkingFk = NULL
|
||||
WHERE its.id IS NULL
|
||||
|
@ -27,11 +27,11 @@ UPDATE shelving sh
|
|||
OR
|
||||
sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK
|
||||
)
|
||||
|
||||
AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN (
|
||||
SELECT DISTINCT LEFT(sh.code, 2)
|
||||
SELECT DISTINCT LEFT(its.shelvingFk, 2)
|
||||
FROM itemShelving its
|
||||
JOIN shelving sh ON sh.id = its.shelvingFk
|
||||
WHERE sh.code REGEXP '^[A-Za-z]{2}[0-9]'
|
||||
WHERE its.shelvingFk REGEXP '^[A-Za-z]{2}[0-9]'
|
||||
), TRUE);
|
||||
|
||||
END$$
|
||||
|
|
|
@ -25,7 +25,7 @@ BEGIN
|
|||
LEFT JOIN (
|
||||
SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector s ON s.id = p.sectorFk
|
||||
WHERE s.code = 'FUENTES_PICASSE'
|
||||
|
@ -68,7 +68,7 @@ BEGIN
|
|||
sh.isSpam
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.item i ON i.id = ish.itemFk
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector s ON s.id = p.sectorFk
|
||||
JOIN vn.warehouse w ON w.id = s.warehouseFk
|
||||
|
|
|
@ -80,7 +80,7 @@ proc: BEGIN
|
|||
|
||||
UPDATE stockBought s
|
||||
JOIN tStockSold ts ON ts.workerFk = s.workerFk
|
||||
SET s.bought = IF(s.bought < ABS(ts.sold), 0, ROUND(s.bought - ABS(ts.sold), 1))
|
||||
SET s.bought = IF(s.bought < ts.sold, ROUND(s.bought - ts.sold, 1), 0)
|
||||
WHERE s.dated = vDated;
|
||||
|
||||
DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold;
|
||||
|
|
|
@ -9,7 +9,7 @@ BEGIN
|
|||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
|
||||
JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
WHERE p.sectorFk = vSectorFk
|
||||
) sub ON sub.id = td.ticketFk
|
||||
|
|
|
@ -27,7 +27,7 @@ BEGIN
|
|||
SUM(ish.visible) visible,
|
||||
s.warehouseFk warehouseFk
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector s ON s.id = p.sectorFk
|
||||
GROUP BY ish.itemFk,
|
||||
|
|
|
@ -28,7 +28,7 @@ BEGIN
|
|||
SUM(ish.visible) visible,
|
||||
s.warehouseFk warehouseFk
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.id = ish.shelvingFk
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector s ON s.id = p.sectorFk
|
||||
GROUP BY ish.itemFk,
|
||||
|
|
|
@ -5,122 +5,122 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki
|
|||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Separa en diferentes tickets según el tipo de empaquetado
|
||||
* El ticket original conserva las líneas del tipo de empaquetado especificado
|
||||
* Las líneas sin tipo de empaquetado se asignan al ticket del tipo por defecto.
|
||||
* Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado.
|
||||
* Respeta el id inicial para el tipo propuesto.
|
||||
*
|
||||
* @param vSelf Id del ticket original
|
||||
* @param vOriginalItemPackingTypeFk Tipo de empaquetado a mantener en el ticket original
|
||||
* @param vSelf Id ticket
|
||||
* @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original
|
||||
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
*/
|
||||
DECLARE vIsDone BOOLEAN DEFAULT FALSE;
|
||||
DECLARE vCurrentPackingType VARCHAR(1);
|
||||
DECLARE vDefaultPackingType VARCHAR(1);
|
||||
DECLARE vHasOriginalPackingType BOOLEAN;
|
||||
DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H';
|
||||
DECLARE vNewTicketFk INT;
|
||||
DECLARE vTicketFk INT;
|
||||
DECLARE vPackingTypesToSplit INT;
|
||||
DECLARE vDone INT DEFAULT FALSE;
|
||||
|
||||
DECLARE vItemPackingTypes CURSOR FOR
|
||||
SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove;
|
||||
DECLARE vSaleGroup CURSOR FOR
|
||||
SELECT itemPackingTypeFk
|
||||
FROM tSaleGroup
|
||||
WHERE itemPackingTypeFk IS NOT NULL
|
||||
ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tSalesToMove (
|
||||
ticketFk INT,
|
||||
saleFk INT,
|
||||
itemPackingTypeFk VARCHAR(1)
|
||||
) ENGINE=MEMORY;
|
||||
|
||||
SELECT COALESCE(MAX(ic.defaultPackingTypeFk), MAX(i.itemPackingTypeFk)) INTO vDefaultPackingType
|
||||
FROM vn.sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN itemConfig ic ON ic.defaultPackingTypeFk = i.itemPackingTypeFk
|
||||
WHERE s.ticketFk = vSelf
|
||||
GROUP BY s.ticketFk;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT TRUE
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE s.ticketFk = vSelf
|
||||
AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk
|
||||
) INTO vHasOriginalPackingType;
|
||||
|
||||
IF vOriginalItemPackingTypeFk IS NULL OR NOT vHasOriginalPackingType THEN
|
||||
SET vOriginalItemPackingTypeFk = vDefaultPackingType;
|
||||
END IF;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT t.id INTO vTicketFk
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.id = t.id
|
||||
WHERE t.id = vSelf
|
||||
SELECT id
|
||||
FROM sale
|
||||
WHERE ticketFk = vSelf
|
||||
AND NOT quantity
|
||||
FOR UPDATE;
|
||||
|
||||
INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk)
|
||||
SELECT s.id, i.itemPackingTypeFk
|
||||
DELETE FROM sale
|
||||
WHERE NOT quantity
|
||||
AND ticketFk = vSelf;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tSale
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE s.ticketFk = vSelf
|
||||
AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk;
|
||||
LEFT JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
WHERE s.ticketFk = vSelf;
|
||||
|
||||
OPEN vItemPackingTypes;
|
||||
l: LOOP
|
||||
SET vIsDone = FALSE;
|
||||
FETCH vItemPackingTypes INTO vCurrentPackingType;
|
||||
CREATE OR REPLACE TEMPORARY TABLE tSaleGroup
|
||||
ENGINE = MEMORY
|
||||
SELECT itemPackingTypeFk, SUM(litros) totalLitros
|
||||
FROM tSale
|
||||
GROUP BY itemPackingTypeFk;
|
||||
|
||||
IF vIsDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
SELECT COUNT(*) INTO vPackingTypesToSplit
|
||||
FROM tSaleGroup
|
||||
WHERE itemPackingTypeFk IS NOT NULL;
|
||||
|
||||
CALL ticket_Clone(vSelf, vNewTicketFk);
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
|
||||
ticketFk INT,
|
||||
itemPackingTypeFk VARCHAR(1)
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
SELECT id INTO vTicketFk
|
||||
FROM ticket t
|
||||
WHERE t.id = vNewTicketFk
|
||||
FOR UPDATE;
|
||||
CASE vPackingTypesToSplit
|
||||
WHEN 0 THEN
|
||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
VALUES(vSelf, vItemPackingTypeFk);
|
||||
WHEN 1 THEN
|
||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
SELECT vSelf, itemPackingTypeFk
|
||||
FROM tSaleGroup
|
||||
WHERE itemPackingTypeFk IS NOT NULL;
|
||||
ELSE
|
||||
OPEN vSaleGroup;
|
||||
FETCH vSaleGroup INTO vItemPackingTypeFk;
|
||||
|
||||
UPDATE tSalesToMove
|
||||
SET ticketFk = vNewTicketFk
|
||||
WHERE itemPackingTypeFk = vCurrentPackingType;
|
||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
VALUES(vSelf, vItemPackingTypeFk);
|
||||
|
||||
IF vCurrentPackingType = vDefaultPackingType THEN
|
||||
INSERT INTO tSalesToMove (ticketFk, saleFk, itemPackingTypeFk)
|
||||
SELECT vNewTicketFk, s.id, i.itemPackingTypeFk
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE s.ticketFk = vSelf
|
||||
AND i.itemPackingTypeFk IS NULL;
|
||||
END IF;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vSaleGroup INTO vItemPackingTypeFk;
|
||||
|
||||
END LOOP;
|
||||
CLOSE vItemPackingTypes;
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
UPDATE sale s
|
||||
JOIN tSalesToMove t ON t.saleFk = s.id
|
||||
SET s.ticketFk = t.ticketFk;
|
||||
CALL ticket_Clone(vSelf, vNewTicketFk);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT
|
||||
ENGINE=MEMORY
|
||||
SELECT s.ticketFk, MAX(i.itemPackingTypeFk) itemPackingTypeFk
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE s.ticketFk = vSelf
|
||||
GROUP BY s.ticketFk
|
||||
UNION
|
||||
SELECT ticketFk, MAX(itemPackingTypeFk)
|
||||
FROM tSalesToMove
|
||||
GROUP BY ticketFk;
|
||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
VALUES(vNewTicketFk, vItemPackingTypeFk);
|
||||
END LOOP;
|
||||
|
||||
CLOSE vSaleGroup;
|
||||
|
||||
SELECT s.id
|
||||
FROM sale s
|
||||
JOIN tSale ts ON ts.id = s.id
|
||||
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
|
||||
FOR UPDATE;
|
||||
|
||||
UPDATE sale s
|
||||
JOIN tSale ts ON ts.id = s.id
|
||||
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
|
||||
SET s.ticketFk = t.ticketFk;
|
||||
|
||||
SELECT itemPackingTypeFk INTO vItemPackingTypeFk
|
||||
FROM tSaleGroup sg
|
||||
WHERE sg.itemPackingTypeFk IS NOT NULL
|
||||
ORDER BY sg.itemPackingTypeFk
|
||||
LIMIT 1;
|
||||
|
||||
UPDATE sale s
|
||||
JOIN tSale ts ON ts.id = s.id
|
||||
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk
|
||||
SET s.ticketFk = t.ticketFk
|
||||
WHERE ts.itemPackingTypeFk IS NULL;
|
||||
END CASE;
|
||||
|
||||
COMMIT;
|
||||
|
||||
DROP TEMPORARY TABLE tSalesToMove;
|
||||
DROP TEMPORARY TABLE
|
||||
tSale,
|
||||
tSaleGroup;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -10,7 +10,7 @@ BEGIN
|
|||
JOIN vn.entry e ON e.travelFk = tr.id
|
||||
JOIN vn.buy b ON b.entryFk = e.id
|
||||
WHERE tr.landed BETWEEN vFromDated AND vToDated
|
||||
AND NOT tr.isRaid
|
||||
AND NOT tr.daysInForward
|
||||
AND tr.warehouseInFk = vWarehouseFk
|
||||
GROUP BY tr.landed , a.name ;
|
||||
END$$
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkRaid`(
|
||||
vIsRaid BOOL,
|
||||
vDaysInForward INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Check if the values of isRaid and daysInforward are correct
|
||||
*
|
||||
* @param vIsRaid idRaid value
|
||||
* @param vDaysInForward daysInForward value
|
||||
*/
|
||||
IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN
|
||||
CALL util.throw('The raid information is not correct');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`()
|
|||
BEGIN
|
||||
/**
|
||||
* Desplaza los travels en el futuro y avisa a los compradores
|
||||
*
|
||||
*
|
||||
*/
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vBuyerEmail VARCHAR(40);
|
||||
|
@ -11,21 +11,21 @@ BEGIN
|
|||
DECLARE vMailBody TEXT DEFAULT '';
|
||||
|
||||
DECLARE vCur CURSOR FOR
|
||||
SELECT GROUP_CONCAT(DISTINCT
|
||||
CONCAT('https://salix.verdnatura.es/#!/travel/',
|
||||
ttm.travelFk,
|
||||
SELECT GROUP_CONCAT(DISTINCT
|
||||
CONCAT('https://salix.verdnatura.es/#!/travel/',
|
||||
ttm.travelFk,
|
||||
'/summary ')
|
||||
ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink,
|
||||
CONCAT(u.name, '@verdnatura.es') buyerEmail
|
||||
FROM tTravelToMove ttm
|
||||
JOIN entry e ON e.travelFk = ttm.travelFk
|
||||
JOIN entry e ON e.travelFk = ttm.travelFk
|
||||
JOIN buy b ON b.entryFk = e.id
|
||||
JOIN item i ON i.id = b.itemFk
|
||||
JOIN itemType it ON it.id = i.typeFk
|
||||
JOIN account.user u ON u.id = it.workerFk
|
||||
GROUP BY u.name;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
|
@ -34,11 +34,10 @@ BEGIN
|
|||
END;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
|
||||
SELECT id travelFk,
|
||||
SELECT id travelFk,
|
||||
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
|
||||
FROM travel
|
||||
WHERE isRaid
|
||||
AND daysInForward;
|
||||
WHERE daysInForward;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100))
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd
|
||||
*
|
||||
* @param vUserFk Identificador del trabajador
|
||||
* @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ;
|
||||
* En caso de tener algun problema retorna el primero que encuentra
|
||||
*/
|
||||
DECLARE vLastIn DATETIME ;
|
||||
DECLARE vLastOut DATETIME ;
|
||||
DECLARE vDayWorkMax INT;
|
||||
DECLARE vDayBreak INT;
|
||||
DECLARE vWeekBreak INT ;
|
||||
DECLARE vWeekScope INT;
|
||||
DECLARE vDayStayMax INT;
|
||||
DECLARE vProblem VARCHAR(20) DEFAULT NULL;
|
||||
DECLARE vTimedWorked INT;
|
||||
DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL;
|
||||
DECLARE vDepartmentFk INT;
|
||||
DECLARE vTo VARCHAR(50) DEFAULT NULL;
|
||||
DECLARE vUserName VARCHAR(50) DEFAULT NULL;
|
||||
DECLARE vBody VARCHAR(255) DEFAULT NULL;
|
||||
|
||||
SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax
|
||||
INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax
|
||||
FROM workerTimeControlParams;
|
||||
|
||||
SELECT MAX(timed) INTO vLastIn
|
||||
FROM workerTimeControl
|
||||
WHERE userFk = vUserFk
|
||||
AND direction = 'in';
|
||||
|
||||
SELECT MAX(timed) INTO vLastOut
|
||||
FROM workerTimeControl
|
||||
WHERE userFk = vUserFk
|
||||
AND direction = 'out';
|
||||
|
||||
SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo
|
||||
FROM account.user u
|
||||
WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk);
|
||||
|
||||
SELECT CONCAT(firstName,' ',lastName) INTO vUserName
|
||||
FROM worker w
|
||||
WHERE w.id = vUserFk;
|
||||
|
||||
|
||||
IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA
|
||||
|
||||
-- VERIFICAR DESCANSO DIARIO
|
||||
IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN
|
||||
SELECT "Descansos 12 h" AS problem;
|
||||
-- ENVIAMOS CORREO AL BOSSFK
|
||||
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody;
|
||||
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
-- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ
|
||||
IF (SELECT MOD(COUNT(*),2) -- <>0
|
||||
FROM workerTimeControl
|
||||
WHERE userFk = vUserFk
|
||||
AND timed >= vLastIn
|
||||
) THEN
|
||||
SELECT "Dias con fichadas impares" AS problem;
|
||||
-- ENVIAMOS CORREO AL BOSSFK
|
||||
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody;
|
||||
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
-- VERIFICAR VACACIONES
|
||||
SELECT at2.name INTO vCalendarStateType
|
||||
FROM calendar c
|
||||
JOIN business b ON b.id = c.businessFk
|
||||
JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
|
||||
WHERE c.dated = util.VN_CURDATE()
|
||||
AND at2.isAllowedToWork = FALSE
|
||||
AND b.workerFk = vUserFk
|
||||
LIMIT 1;
|
||||
|
||||
IF(LENGTH(vCalendarStateType)) THEN
|
||||
SELECT vCalendarStateType AS problem;
|
||||
-- ENVIAMOS CORREO AL BOSSFK
|
||||
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody;
|
||||
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
|
||||
LEAVE proc;
|
||||
|
||||
END IF;
|
||||
|
||||
-- VERIFICAR CONTRATO EN VIGOR
|
||||
IF (SELECT COUNT(*)
|
||||
FROM business b
|
||||
WHERE b.workerFk = vUserFk
|
||||
AND b.started <= vDated
|
||||
AND IFNULL(b.ended, vDated) >= vDated
|
||||
) = 0 THEN
|
||||
SELECT "No hay un contrato en vigor" AS problem;
|
||||
-- ENVIAMOS CORREO AL BOSSFK
|
||||
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody;
|
||||
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
|
||||
LEAVE proc;
|
||||
|
||||
END IF;
|
||||
|
||||
-- VERIFICAR DESCANSO SEMANAL
|
||||
SET @vHasBreakWeek:= FALSE;
|
||||
SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND));
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.trash;
|
||||
CREATE TEMPORARY TABLE tmp.trash
|
||||
SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias,
|
||||
@vLastTimed:= UNIX_TIMESTAMP(timed)
|
||||
FROM workerTimeControl
|
||||
WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND)
|
||||
AND userFk= vUserFk
|
||||
AND direction IN ('in','out')
|
||||
ORDER BY timed ASC;
|
||||
|
||||
IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA
|
||||
SELECT "Descansos 36 h" AS problem;
|
||||
-- ENVIAMOS CORREO AL BOSSFK
|
||||
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody;
|
||||
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.trash;
|
||||
|
||||
ELSE -- DIA ACTUAL
|
||||
|
||||
-- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO
|
||||
SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked
|
||||
FROM workerTimeControl wtc
|
||||
WHERE userFk = vUserFk
|
||||
AND timed >= vLastIn
|
||||
ORDER BY timed;
|
||||
|
||||
IF vTimedWorked > vDayWorkMax THEN
|
||||
SELECT "Jornadas" AS problem;
|
||||
-- ENVIAMOS CORREO AL BOSSFK
|
||||
SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody;
|
||||
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
-- VERIFICAR DEPARTAMENTO
|
||||
/* IF vTabletFk IS NOT NULL THEN
|
||||
SELECT wtcu.departmentFk INTO vDepartmentFk
|
||||
FROM workerTimeControlUserInfo wtcu
|
||||
WHERE wtcu.userFk = vUserFk;
|
||||
IF (SELECT COUNT(td.tabletFk)
|
||||
FROM tabletDepartment td
|
||||
WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk
|
||||
) = 0 THEN
|
||||
SELECT "No perteneces a este departamento." AS problem;
|
||||
-- ENVIAMOS CORREO AL BOSSFK
|
||||
SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody;
|
||||
CALL mail_insert(vTo,vTo,'error al fichar',vBody);
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
END IF;*/
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -6,7 +6,6 @@ BEGIN
|
|||
DECLARE vIsEqualizated BOOL;
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
SET NEW.geoFk = address_getGeo(NEW.id);
|
||||
|
||||
IF (NEW.phone <> '') THEN
|
||||
CALL pbx.phone_isValid(NEW.phone);
|
||||
|
|
|
@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_beforeUpdate`
|
|||
BEFORE UPDATE ON `address`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN
|
||||
|
@ -13,10 +14,5 @@ BEGIN
|
|||
CALL pbx.phone_isValid(NEW.mobile);
|
||||
END IF;
|
||||
|
||||
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
|
||||
OR (NEW.postalCode <=> OLD.postalCode) THEN
|
||||
|
||||
SET NEW.geoFk = address_getGeo(NEW.id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,10 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_beforeInsert`
|
|||
BEFORE INSERT ON `client`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
SET NEW.accountingAccount = 4300000000 + NEW.id;
|
||||
SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
|
||||
SET NEW.geoFk = client_getGeo(NEW.id);
|
||||
|
||||
IF (NEW.phone <> '') THEN
|
||||
CALL pbx.phone_isValid(NEW.phone);
|
||||
|
@ -15,5 +13,9 @@ BEGIN
|
|||
IF (NEW.mobile <> '') THEN
|
||||
CALL pbx.phone_isValid(NEW.mobile);
|
||||
END IF;
|
||||
|
||||
SET NEW.accountingAccount = 4300000000 + NEW.id;
|
||||
|
||||
SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -72,11 +72,5 @@ BEGIN
|
|||
IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
|
||||
SET NEW.isTaxDataChecked = 0;
|
||||
END IF;
|
||||
|
||||
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
|
||||
OR (NEW.postcode <=> OLD.postcode) THEN
|
||||
|
||||
SET NEW.geoFk = client_getGeo(NEW.id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate`
|
|||
BEFORE UPDATE ON `entry`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vIsRaid BOOL;
|
||||
DECLARE vDaysInForward INT;
|
||||
DECLARE vPrintedCount INT;
|
||||
DECLARE vHasDistinctWarehouses BOOL;
|
||||
DECLARE vTotalBuy INT;
|
||||
|
@ -38,10 +38,10 @@ BEGIN
|
|||
CALL travel_throwAwb(NEW.travelFk);
|
||||
END IF;
|
||||
|
||||
SELECT t.isRaid INTO vIsRaid
|
||||
SELECT daysInForward INTO vDaysInForward
|
||||
FROM travel t
|
||||
JOIN entry e ON e.travelFk = t.id
|
||||
WHERE e.id = NEW.id;
|
||||
WHERE entryFk = NEW.id;
|
||||
|
||||
SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
|
||||
OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
|
||||
|
@ -50,7 +50,7 @@ BEGIN
|
|||
WHERE o.id = OLD.travelFk
|
||||
AND n.id = NEW.travelFk;
|
||||
|
||||
IF vIsRaid AND vHasDistinctWarehouses THEN
|
||||
IF vDaysInForward AND vHasDistinctWarehouses THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses';
|
||||
END IF;
|
||||
|
|
|
@ -2,18 +2,18 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_afterUpdate`
|
||||
AFTER UPDATE ON `route`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
BEGIN
|
||||
IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN
|
||||
-- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets
|
||||
|
||||
|
||||
-- Inserta el gestdoc en todos los tickets de la ruta
|
||||
INSERT INTO ticketDms(ticketFk,dmsFk)
|
||||
SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id
|
||||
ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk;
|
||||
|
||||
-- Update del firmado
|
||||
UPDATE ticket t
|
||||
JOIN ticketDms tg ON t.id = tg.ticketFk
|
||||
-- Update del firmado
|
||||
UPDATE ticket t
|
||||
JOIN ticketDms tg ON t.id = tg.ticketFk
|
||||
SET isSigned = 1 WHERE t.routeFk = NEW.id;
|
||||
END IF;
|
||||
|
||||
|
@ -21,8 +21,7 @@ BEGIN
|
|||
OR !(NEW.kmEnd <=> OLD.kmEnd)
|
||||
OR !(NEW.workerFk <=> OLD.workerFk)
|
||||
OR !(NEW.m3 <=> OLD.m3)
|
||||
OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)
|
||||
OR !(NEW.vehicleFk <=> OLD.vehicleFk)THEN
|
||||
OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)THEN
|
||||
CALL route_calcCommission(NEW.id);
|
||||
END IF;
|
||||
|
||||
|
|
|
@ -4,6 +4,5 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_beforeInsert`
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
SET NEW.geoFk = supplier_getGeo(NEW.id);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -40,10 +40,5 @@ BEGIN
|
|||
SET NEW.isPayMethodChecked = FALSE;
|
||||
END IF;
|
||||
|
||||
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
|
||||
OR (NEW.postCode <=> OLD.postCode) THEN
|
||||
|
||||
SET NEW.geoFk = supplier_getGeo(NEW.id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`town_beforeUpdate`
|
||||
BEFORE UPDATE ON `town`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
-- IF !(OLD.geoFk <=> NEW.geoFk) THEN
|
||||
-- CALL zoneGeo_throwNotEditable;
|
||||
-- END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -8,11 +8,7 @@ BEGIN
|
|||
CALL travel_checkDates(NEW.shipped, NEW.landed);
|
||||
|
||||
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
||||
|
||||
IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN
|
||||
CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
|
||||
END IF;
|
||||
|
||||
|
||||
IF NEW.awbFk IS NOT NULL THEN
|
||||
CALL travel_throwAwb(NEW.id);
|
||||
END IF;
|
||||
|
|
|
@ -7,7 +7,7 @@ BEGIN
|
|||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
IF NOT (NEW.landed <=> OLD.landed)
|
||||
IF NOT (NEW.landed <=> OLD.landed)
|
||||
OR NOT (NEW.shipped <=> OLD.shipped) THEN
|
||||
CALL travel_checkDates(NEW.shipped, NEW.landed);
|
||||
END IF;
|
||||
|
@ -20,23 +20,19 @@ BEGIN
|
|||
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
||||
END IF;
|
||||
|
||||
IF NOT (NEW.isRaid <=> OLD.isRaid) OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN
|
||||
CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
|
||||
END IF;
|
||||
|
||||
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
|
||||
SELECT COUNT(*) INTO vHasAnyInvoiceBooked
|
||||
SELECT COUNT(*) INTO vHasAnyInvoiceBooked
|
||||
FROM travel t
|
||||
JOIN entry e ON e.travelFk = t.id
|
||||
JOIN invoiceIn ii ON ii.id = e.invoiceInFk
|
||||
JOIN entry e ON e.travelFk = t.id
|
||||
JOIN invoiceIn ii ON ii.id = e.invoiceInFk
|
||||
WHERE t.id = NEW.id
|
||||
AND ii.isBooked;
|
||||
|
||||
AND ii.isBooked;
|
||||
|
||||
IF vHasAnyInvoiceBooked THEN
|
||||
CALL util.throw('The travel has entries with booked invoices');
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN
|
||||
CALL travel_throwAwb(NEW.id);
|
||||
END IF;
|
||||
|
|
|
@ -6,7 +6,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`,
|
|||
`b`.`itemFk` AS `itemFk`,
|
||||
`b`.`quantity` AS `quantity`,
|
||||
`t`.`isReceived` AS `isReceived`,
|
||||
`t`.`isRaid` AS `isVirtualStock`,
|
||||
`t`.`daysInForward` AS `isVirtualStock`,
|
||||
`e`.`id` AS `entryFk`
|
||||
FROM (
|
||||
(
|
||||
|
|
|
@ -15,5 +15,5 @@ FROM (
|
|||
JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`)
|
||||
)
|
||||
WHERE `e`.`isExcludedFromAvailable` = 0
|
||||
AND NOT `t`.`isRaid`
|
||||
AND NOT `t`.`daysInForward`
|
||||
AND `b`.`quantity` <> 0
|
||||
|
|
|
@ -15,7 +15,7 @@ FROM (
|
|||
(
|
||||
(
|
||||
`vn`.`itemShelving` `ish`
|
||||
JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
|
||||
JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
|
||||
)
|
||||
JOIN `vn`.`item` `i` ON(`i`.`id` = `ish`.`itemFk`)
|
||||
)
|
||||
|
|
|
@ -18,7 +18,7 @@ FROM (
|
|||
(
|
||||
(
|
||||
`vn`.`itemShelving` `ish`
|
||||
JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
|
||||
JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
|
||||
)
|
||||
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
|
||||
)
|
||||
|
|
|
@ -13,7 +13,7 @@ FROM (
|
|||
`vn`.`itemShelvingSale` `iss`
|
||||
JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `iss`.`itemShelvingFk`)
|
||||
)
|
||||
JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
|
||||
JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
|
||||
)
|
||||
JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
|
||||
)
|
||||
|
|
|
@ -21,7 +21,7 @@ FROM (
|
|||
(
|
||||
(
|
||||
`vn`.`itemShelving` `ish`
|
||||
LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
|
||||
LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
|
||||
)
|
||||
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
|
||||
)
|
||||
|
|
|
@ -19,7 +19,7 @@ FROM (
|
|||
(
|
||||
(
|
||||
`vn`.`itemShelving` `ish`
|
||||
JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
|
||||
JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
|
||||
)
|
||||
JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
|
||||
)
|
||||
|
|
|
@ -31,5 +31,5 @@ FROM (
|
|||
LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`)
|
||||
)
|
||||
WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`()
|
||||
AND NOT `tr`.`isRaid`
|
||||
AND NOT `tr`.`daysInForward`
|
||||
AND `b`.`stickers` > 0
|
||||
|
|
|
@ -8,7 +8,6 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`,
|
|||
`e`.`isExcludedFromAvailable` AS `Inventario`,
|
||||
`e`.`isConfirmed` AS `Confirmada`,
|
||||
`e`.`isOrdered` AS `Pedida`,
|
||||
`tr`.`isRaid` AS `isRaid`,
|
||||
`tr`.`daysInForward` AS `daysInForward`,
|
||||
`e`.`evaNotes` AS `notas`,
|
||||
`e`.`supplierFk` AS `Id_Proveedor`,
|
||||
|
|
|
@ -18,6 +18,5 @@ AS SELECT `t`.`id` AS `id`,
|
|||
`t`.`totalEntries` AS `totalEntries`,
|
||||
`t`.`appointment` AS `appointment`,
|
||||
`t`.`awbFk` AS `awbFk`,
|
||||
`t`.`isRaid` AS `isRaid`,
|
||||
`t`.`daysInForward` AS `daysInForward`
|
||||
FROM `vn`.`travel` `t`
|
||||
|
|
|
@ -86,4 +86,4 @@ FROM (
|
|||
)
|
||||
WHERE NOT `W_IN`.`isFeedStock`
|
||||
AND NOT `E`.`Inventario`
|
||||
AND NOT `TR`.`isRaid`
|
||||
AND NOT `TR`.`daysInForward`
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue