Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
5cdb0b7eb6
|
@ -14,6 +14,7 @@ BEGIN
|
|||
DECLARE vHasRows BOOL;
|
||||
DECLARE vHas0Amount BOOL;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vHas0Amount BOOL;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vShipment DATE;
|
||||
DECLARE vShipmentDayEnd DATETIME;
|
||||
|
|
|
@ -45,7 +45,7 @@ BEGIN
|
|||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||
WHERE t.id = vParamFk
|
||||
AND t.shipped >= vYesterday
|
||||
UNION ALL
|
||||
UNION
|
||||
SELECT t.id ticketFk,
|
||||
IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
||||
am.name agencyName,
|
||||
|
@ -66,7 +66,7 @@ BEGIN
|
|||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||
WHERE tc.collectionFk = vParamFk
|
||||
UNION ALL
|
||||
UNION
|
||||
SELECT sg.ticketFk,
|
||||
NULL `level`,
|
||||
am.name agencyName,
|
||||
|
@ -83,6 +83,7 @@ BEGIN
|
|||
LEFT JOIN observation ob ON ob.ticketFk = t.id
|
||||
LEFT JOIN vn.client c ON c.id = t.clientFk
|
||||
WHERE sc.id = vParamFk
|
||||
AND t.shipped >= vYesterday;
|
||||
AND t.shipped >= vYesterday
|
||||
GROUP BY ticketFk;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_deleteAdded`(
|
||||
vSelf INT(11)
|
||||
)
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Borra una reservea devolviendo la cantidad al itemShelving
|
||||
*
|
||||
* @param vSelf Identificador del itemShelvingSale
|
||||
*/
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vHasSalesPicked BOOL;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT iss.saleFk INTO vSaleFk
|
||||
FROM itemShelvingSale iss
|
||||
JOIN sale s ON s.id = iss.saleFk
|
||||
WHERE iss.id = vSelf AND s.isAdded
|
||||
FOR UPDATE;
|
||||
|
||||
IF vSaleFk IS NULL THEN
|
||||
CALL util.throw('The sale can not be deleted');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vHasSalesPicked
|
||||
FROM itemShelvingSale
|
||||
WHERE saleFk = vSaleFk AND isPicked;
|
||||
|
||||
IF vHasSalesPicked THEN
|
||||
CALL util.throw('A sale with picked sales cannot be deleted');
|
||||
END IF;
|
||||
|
||||
UPDATE itemShelvingSale iss
|
||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
SET ish.available = ish.available + iss.quantity
|
||||
WHERE iss.saleFk = vSaleFk;
|
||||
|
||||
DELETE FROM sale WHERE id = vSaleFk;
|
||||
|
||||
COMMIT;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,3 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE hedera.`order` ADD IF NOT EXISTS rowUpdated DATETIME NULL
|
||||
COMMENT 'Timestamp for last updated record in orderRow table';
|
|
@ -0,0 +1,45 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getWithPackaging', {
|
||||
description: 'Returns the list of suppliers with an entry of type packaging',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getWithPackaging`,
|
||||
verb: 'GET'
|
||||
},
|
||||
nolimit: true
|
||||
});
|
||||
Self.getWithPackaging = async options => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const oneYearAgo = new Date();
|
||||
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1);
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const entries = await models.Entry.find({
|
||||
where: {
|
||||
typeFk: 'packaging',
|
||||
created: {gte: oneYearAgo}
|
||||
},
|
||||
include: {
|
||||
relation: 'supplier',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
fields: {supplierFk: true}
|
||||
}, myOptions);
|
||||
|
||||
const result = entries.map(item => ({
|
||||
id: item.supplier().id,
|
||||
name: item.supplier().name
|
||||
}));
|
||||
return Array.from(new Map(result.map(entry => [entry.id, entry])).values());
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('Supplier getWithPackaging()', () => {
|
||||
it('should return a list of suppliers with an entry of type packaging', async() => {
|
||||
const typeFk = 'packaging';
|
||||
|
||||
const tx = await models.Supplier.beginTransaction({});
|
||||
const myOptions = {transaction: tx};
|
||||
|
||||
try {
|
||||
const entry = await models.Entry.findOne(
|
||||
{
|
||||
where: {
|
||||
id: 1
|
||||
},
|
||||
myOptions
|
||||
});
|
||||
|
||||
await entry.updateAttributes({
|
||||
typeFk: typeFk,
|
||||
created: new Date()
|
||||
});
|
||||
|
||||
const result = await models.Supplier.getWithPackaging(myOptions);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -12,6 +12,7 @@ module.exports = Self => {
|
|||
require('../methods/supplier/campaignMetricsEmail')(Self);
|
||||
require('../methods/supplier/newSupplier')(Self);
|
||||
require('../methods/supplier/getItemsPackaging')(Self);
|
||||
require('../methods/supplier/getWithPackaging')(Self);
|
||||
|
||||
Self.validatesPresenceOf('name', {
|
||||
message: 'The social name cannot be empty'
|
||||
|
|
Loading…
Reference in New Issue