Merge branch 'master' into 8119-itemCampaignQuantity
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
commit
9eaa5a7585
|
@ -403,7 +403,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
|
|||
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses');
|
||||
|
||||
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
|
||||
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1
|
||||
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), UPPER(CONCAT(name, 'Street')), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1
|
||||
FROM `account`.`role` `r`
|
||||
WHERE `r`.`hasLogin` = 1;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ proc: BEGIN
|
|||
DECLARE vUserFk INT;
|
||||
DECLARE vTotalReservedQuantity INT;
|
||||
DECLARE vSaleQuantity INT;
|
||||
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
|
||||
|
||||
DECLARE vItemShelvingAvailable CURSOR FOR
|
||||
SELECT ish.id itemShelvingFk,
|
||||
|
@ -44,11 +45,11 @@ proc: BEGIN
|
|||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
CALL util.tx_rollback(vIsRequiredTx);
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
START TRANSACTION;
|
||||
CALL util.tx_start(vIsRequiredTx);
|
||||
|
||||
SELECT id INTO vSaleFk
|
||||
FROM sale
|
||||
|
@ -65,7 +66,7 @@ proc: BEGIN
|
|||
WHERE s.id = vSaleFk;
|
||||
|
||||
IF vOutStanding <= 0 THEN
|
||||
COMMIT;
|
||||
CALL util.tx_commit(vIsRequiredTx);
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
|
@ -93,7 +94,7 @@ proc: BEGIN
|
|||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SELECT id INTO vItemShelvingFk
|
||||
SELECT id INTO vItemShelvingFk
|
||||
FROM itemShelving
|
||||
WHERE id = vItemShelvingFk
|
||||
FOR UPDATE;
|
||||
|
@ -102,19 +103,19 @@ proc: BEGIN
|
|||
SET vOutStanding = vOutStanding - vReservedQuantity;
|
||||
|
||||
IF vReservedQuantity > 0 THEN
|
||||
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
|
||||
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
|
||||
INSERT INTO itemShelvingSale(
|
||||
itemShelvingFk,
|
||||
saleFk,
|
||||
quantity,
|
||||
userFk,
|
||||
isPicked)
|
||||
SELECT vItemShelvingFk,
|
||||
vSaleFk,
|
||||
vReservedQuantity,
|
||||
vUserFk,
|
||||
FALSE;
|
||||
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
|
||||
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
|
||||
INSERT INTO itemShelvingSale(
|
||||
itemShelvingFk,
|
||||
saleFk,
|
||||
quantity,
|
||||
userFk,
|
||||
isPicked)
|
||||
SELECT vItemShelvingFk,
|
||||
vSaleFk,
|
||||
vReservedQuantity,
|
||||
vUserFk,
|
||||
FALSE;
|
||||
|
||||
UPDATE itemShelving
|
||||
SET available = available - vReservedQuantity
|
||||
|
@ -123,6 +124,6 @@ proc: BEGIN
|
|||
END IF;
|
||||
END LOOP;
|
||||
CLOSE vItemShelvingAvailable;
|
||||
COMMIT;
|
||||
CALL util.tx_commit(vIsRequiredTx);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -51,7 +51,8 @@ BEGIN
|
|||
origin.companyFk futureCompanyFk,
|
||||
IFNULL(dest.nickname, origin.nickname) nickname,
|
||||
dest.landed,
|
||||
dest.preparation
|
||||
dest.preparation,
|
||||
origin.departmentFk
|
||||
FROM (
|
||||
SELECT s.ticketFk,
|
||||
c.salesPersonFk workerFk,
|
||||
|
@ -71,9 +72,11 @@ BEGIN
|
|||
t.addressFk,
|
||||
t.warehouseFk,
|
||||
t.companyFk,
|
||||
t.agencyModeFk
|
||||
t.agencyModeFk,
|
||||
wd.departmentFk
|
||||
FROM ticket t
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
|
|
|
@ -50,6 +50,11 @@ module.exports = Self => {
|
|||
type: 'boolean',
|
||||
description: 'True when lines and stock of origin are equal'
|
||||
},
|
||||
{
|
||||
arg: 'departmentFk',
|
||||
type: 'number',
|
||||
description: 'Department identifier'
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
|
@ -96,6 +101,8 @@ module.exports = Self => {
|
|||
};
|
||||
case 'isFullMovable':
|
||||
return {'f.isFullMovable': value};
|
||||
case 'departmentFk':
|
||||
return {'f.departmentFk': value};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
today.setHours(0, 0, 0, 0);
|
||||
let tomorrow = Date.vnNew();
|
||||
tomorrow.setDate(today.getDate() + 1);
|
||||
const salesDeptId = 43;
|
||||
const spain1DeptId = 95;
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should return the tickets passing the required data', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
@ -129,4 +132,39 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the tickets matching the right department', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
ctx.args = {
|
||||
dateFuture: tomorrow,
|
||||
dateToAdvance: today,
|
||||
warehouseFk: 1,
|
||||
};
|
||||
|
||||
await models.Ticket.updateAll({id: {inq: [12, 31]}}, {clientFk: 1}, options);
|
||||
const client = await models.Client.findById(1, null, options);
|
||||
await client.updateAttribute('salesPersonFk', 1, options);
|
||||
const business = await models.Business.findById(1, null, options);
|
||||
await business.updateAttributes({departmentFk: spain1DeptId}, options);
|
||||
|
||||
const saleTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
const filteredSaleTickets = await models.Ticket.getTicketsAdvance(
|
||||
{args: {...ctx.args, departmentFk: spain1DeptId}},
|
||||
options);
|
||||
|
||||
expect(saleTickets.length).toBeGreaterThan(filteredSaleTickets.length);
|
||||
expect(saleTickets.some(ticket => ticket.departmentFk === salesDeptId)).toBeTrue();
|
||||
expect(saleTickets.some(ticket => ticket.departmentFk === spain1DeptId)).toBeTrue();
|
||||
|
||||
expect(filteredSaleTickets.some(ticket => ticket.departmentFk === salesDeptId)).toBeFalse();
|
||||
expect(filteredSaleTickets.some(ticket => ticket.departmentFk === spain1DeptId)).toBeTrue();
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,63 +1,66 @@
|
|||
{
|
||||
"name": "Expedition",
|
||||
"base": "VnModel",
|
||||
"mixins": {
|
||||
"Loggable": true
|
||||
"name": "Expedition",
|
||||
"base": "VnModel",
|
||||
"mixins": {
|
||||
"Loggable": true
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "expedition"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "expedition"
|
||||
}
|
||||
"freightItemFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"freightItemFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
},
|
||||
"counter": {
|
||||
"type": "number"
|
||||
},
|
||||
"externalId": {
|
||||
"type": "string"
|
||||
}
|
||||
"created": {
|
||||
"type": "date"
|
||||
},
|
||||
"relations": {
|
||||
"ticket": {
|
||||
"type": "belongsTo",
|
||||
"model": "Ticket",
|
||||
"foreignKey": "ticketFk"
|
||||
},
|
||||
"agencyMode": {
|
||||
"type": "belongsTo",
|
||||
"model": "AgencyMode",
|
||||
"foreignKey": "agencyModeFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"packages": {
|
||||
"type": "hasMany",
|
||||
"model": "TicketPackaging",
|
||||
"foreignKey": "ticketFk"
|
||||
},
|
||||
"freightItem": {
|
||||
"type": "belongsTo",
|
||||
"model": "Item",
|
||||
"foreignKey": "freightItemFk"
|
||||
},
|
||||
"packaging": {
|
||||
"type": "belongsTo",
|
||||
"model": "Package",
|
||||
"foreignKey": "packagingFk"
|
||||
}
|
||||
"counter": {
|
||||
"type": "number"
|
||||
},
|
||||
"externalId": {
|
||||
"type": "string"
|
||||
},
|
||||
"stateTypeFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"ticket": {
|
||||
"type": "belongsTo",
|
||||
"model": "Ticket",
|
||||
"foreignKey": "ticketFk"
|
||||
},
|
||||
"agencyMode": {
|
||||
"type": "belongsTo",
|
||||
"model": "AgencyMode",
|
||||
"foreignKey": "agencyModeFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"packages": {
|
||||
"type": "hasMany",
|
||||
"model": "TicketPackaging",
|
||||
"foreignKey": "ticketFk"
|
||||
},
|
||||
"freightItem": {
|
||||
"type": "belongsTo",
|
||||
"model": "Item",
|
||||
"foreignKey": "freightItemFk"
|
||||
},
|
||||
"packaging": {
|
||||
"type": "belongsTo",
|
||||
"model": "Package",
|
||||
"foreignKey": "packagingFk"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue