test excepto fallo e2e
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
db06626675
commit
039eec7d26
|
@ -1,5 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('WorkerDms', 'filter', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('WorkerDms', 'downloadFile', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
DELETE FROM `salix`.`ACL` WHERE (`id` = '205');
|
|
@ -1,119 +0,0 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `zone_getEvents`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getEvents`(
|
||||
vGeoFk INT,
|
||||
vAgencyModeFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Returns available events for the passed province/postcode and agency.
|
||||
*
|
||||
* @param vGeoFk The geo id
|
||||
* @param vAgencyModeFk The agency mode id
|
||||
*/
|
||||
DECLARE vDeliveryMethodFk VARCHAR(255);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tZone;
|
||||
CREATE TEMPORARY TABLE tZone
|
||||
(id INT PRIMARY KEY)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
SELECT dm.`code` INTO vDeliveryMethodFk
|
||||
FROM agencyMode am
|
||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
WHERE am.id = vAgencyModeFk;
|
||||
|
||||
IF vDeliveryMethodFk = 'PICKUP' THEN
|
||||
INSERT INTO tZone
|
||||
SELECT id
|
||||
FROM zone
|
||||
WHERE agencyModeFk = vAgencyModeFk;
|
||||
ELSE
|
||||
CALL zone_getFromGeo(vGeoFk);
|
||||
|
||||
IF vAgencyModeFk IS NOT NULL THEN
|
||||
INSERT INTO tZone
|
||||
SELECT t.id
|
||||
FROM tmp.zone t
|
||||
JOIN zone z ON z.id = t.id
|
||||
WHERE z.agencyModeFk = vAgencyModeFk;
|
||||
ELSE
|
||||
INSERT INTO tZone
|
||||
SELECT t.id
|
||||
FROM tmp.zone t
|
||||
JOIN zone z ON z.id = t.id
|
||||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
WHERE dm.`code` IN ('AGENCY', 'DELIVERY');
|
||||
END IF;
|
||||
DROP TEMPORARY TABLE tmp.zone;
|
||||
END IF;
|
||||
|
||||
SELECT e.zoneFk, e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays
|
||||
FROM tZone t
|
||||
JOIN zoneEvent e ON e.zoneFk = t.id;
|
||||
|
||||
SELECT e.zoneFk, e.dated
|
||||
FROM tZone t
|
||||
JOIN zoneExclusion e ON e.zoneFk = t.id;
|
||||
|
||||
DROP TEMPORARY TABLE tZone;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
USE `vn`;
|
||||
DROP procedure IF EXISTS `zone_getEvents__`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getEvents__`(
|
||||
vProvinceFk INT,
|
||||
vPostCode VARCHAR(255),
|
||||
vAgencyModeFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Returns available events for the passed province/postcode and agency.
|
||||
*
|
||||
* @param vAgencyModeFk The agency mode id
|
||||
* @param vProvinceFk The province id
|
||||
* @param vPostCode The postcode or %NULL to use the province
|
||||
*/
|
||||
|
||||
DECLARE vGeoFk INT;
|
||||
|
||||
IF vPostCode IS NOT NULL THEN
|
||||
SELECT p.geoFk INTO vGeoFk
|
||||
FROM postCode p
|
||||
JOIN town t ON t.id = p.townFk
|
||||
WHERE p.`code` = vPostCode
|
||||
AND t.provinceFk = vProvinceFk;
|
||||
ELSE
|
||||
SELECT geoFk INTO vGeoFk
|
||||
FROM province
|
||||
WHERE id = vProvinceFk;
|
||||
END IF;
|
||||
|
||||
CALL zone_getFromGeo(vGeoFk);
|
||||
|
||||
IF vAgencyModeFk IS NOT NULL THEN
|
||||
DELETE t FROM tmp.zone t
|
||||
JOIN zone z ON z.id = t.id
|
||||
WHERE z.agencyModeFk != vAgencyModeFk;
|
||||
END IF;
|
||||
|
||||
SELECT e.zoneFk, e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays
|
||||
FROM tmp.zone t
|
||||
JOIN zoneEvent e ON e.zoneFk = t.id;
|
||||
|
||||
SELECT e.zoneFk, e.dated
|
||||
FROM tmp.zone t
|
||||
JOIN zoneExclusion e ON e.zoneFk = t.id;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.zone;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `zone_getWarehouse`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve el listado de agencias disponibles para la fecha,
|
||||
* dirección y almacén pasados.
|
||||
*
|
||||
* @param vAddress
|
||||
* @param vWarehouse warehouse
|
||||
* @param vLanded Fecha de recogida
|
||||
* @select Listado de agencias disponibles
|
||||
*/
|
||||
|
||||
CALL zone_getFromGeo(address_getGeo(vAddress));
|
||||
CALL zone_getOptionsForLanding(vLanded, FALSE);
|
||||
|
||||
SELECT am.id agencyModeFk,
|
||||
am.name agencyMode,
|
||||
am.description,
|
||||
am.deliveryMethodFk,
|
||||
TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped,
|
||||
zw.warehouseFk,
|
||||
z.id zoneFk
|
||||
FROM tmp.zoneOption zo
|
||||
JOIN zone z ON z.id = zo.zoneFk
|
||||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
||||
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
|
||||
WHERE zw.warehouseFk = vWarehouse
|
||||
GROUP BY z.agencyModeFk
|
||||
ORDER BY agencyMode;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.zone,
|
||||
tmp.zoneOption;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
USE `vn`;
|
||||
DROP procedure IF EXISTS `zone_getWarehouse__`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse__`(vAddress INT, vLanded DATE, vWarehouse INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve el listado de agencias disponibles para la fecha,
|
||||
* dirección y almacén pasados.
|
||||
*
|
||||
* @param vAddress
|
||||
* @param vWarehouse warehouse
|
||||
* @param vLanded Fecha de recogida
|
||||
* @select Listado de agencias disponibles
|
||||
*/
|
||||
|
||||
CALL zone_getFromGeo(address_getGeo(vAddress));
|
||||
CALL zone_getOptionsForLanding(vLanded, FALSE);
|
||||
|
||||
SELECT am.id agencyModeFk,
|
||||
am.name agencyMode,
|
||||
am.description,
|
||||
am.deliveryMethodFk,
|
||||
TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped,
|
||||
zw.warehouseFk,
|
||||
z.id zoneFk
|
||||
FROM tmp.zoneOption zo
|
||||
JOIN zone z ON z.id = zo.zoneFk
|
||||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
||||
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
|
||||
WHERE zw.warehouseFk
|
||||
GROUP BY z.agencyModeFk
|
||||
ORDER BY agencyMode;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.zone,
|
||||
tmp.zoneOption;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `manaSpellersRequery`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER)
|
||||
BEGIN
|
||||
DECLARE vWorkerHasMana BOOLEAN;
|
||||
DECLARE vFromDated DATE;
|
||||
DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE());
|
||||
DECLARE vMana INT;
|
||||
DECLARE vAutoMana INT;
|
||||
DECLARE vManaBank INT;
|
||||
DECLARE vManaGreugeType INT;
|
||||
|
||||
SELECT id INTO vMana
|
||||
FROM `component` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vAutoMana
|
||||
FROM `component` WHERE code = 'autoMana';
|
||||
|
||||
SELECT id INTO vManaBank
|
||||
FROM `bank` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaGreugeType
|
||||
FROM `greugeType` WHERE code = 'mana';
|
||||
|
||||
SELECT COUNT(*) INTO vWorkerHasMana
|
||||
FROM vn.workerMana wm
|
||||
LEFT JOIN vn.workerManaExcluded wme ON wm.workerFk = wme.workerFk
|
||||
WHERE wm.workerFk = vWorkerFk AND wme.workerFk IS NULL;
|
||||
|
||||
IF vWorkerHasMana THEN
|
||||
|
||||
SELECT max(dated) INTO vFromDated
|
||||
FROM clientManaCache;
|
||||
|
||||
REPLACE workerMana (workerFk, amount)
|
||||
SELECT vWorkerFk, sum(mana) FROM
|
||||
(
|
||||
SELECT s.quantity * sc.value as mana
|
||||
FROM ticket t
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN client c ON c.id = a.clientFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana)
|
||||
AND t.shipped > vFromDated AND t.shipped < vToDated
|
||||
UNION ALL
|
||||
SELECT - r.amountPaid
|
||||
FROM receipt r
|
||||
JOIN client c ON c.id = r.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank
|
||||
AND payed > vFromDated
|
||||
UNION ALL
|
||||
SELECT g.amount
|
||||
FROM greuge g
|
||||
JOIN client c ON c.id = g.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType
|
||||
AND g.shipped > vFromDated and g.shipped < CURDATE()
|
||||
UNION ALL
|
||||
SELECT cc.mana
|
||||
FROM clientManaCache cc
|
||||
JOIN client c ON c.id = cc.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated
|
||||
) sub;
|
||||
END IF;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1455,6 +1455,9 @@ INSERT INTO `vn`.`clientContact`(`id`, `clientFk`, `name`, `phone`)
|
|||
(3, 101, 'contact 3', 222333444),
|
||||
(4, 102, 'contact 1', 876543219);
|
||||
|
||||
INSERT INTO `vn`.`workerManaExcluded`(`workerFk`)
|
||||
VALUES
|
||||
(9);
|
||||
/*
|
||||
el mana de los trabajadores lo podemos poner a mano en la tabla si lo calculamos antes,
|
||||
pero si hazemos alguna modificacion en alguna tabla que utiliza para calcularlo ya no seria correcto
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Ticket create path', () => {
|
||||
fdescribe('Ticket create path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
let nextMonth = new Date();
|
||||
|
|
|
@ -67,5 +67,6 @@
|
|||
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
|
||||
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",
|
||||
"Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}",
|
||||
"Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment"
|
||||
"Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment",
|
||||
"NOT_ZONE_WITH_THIS_PARAMETERS": "NOT_ZONE_WITH_THIS_PARAMETERS"
|
||||
}
|
|
@ -66,11 +66,6 @@ describe('sale updatePrice()', () => {
|
|||
let saleUpdated = await app.models.Sale.findById(saleId);
|
||||
createdSaleComponent = await app.models.SaleComponent.findOne({where: {saleFk: saleId, componentFk: manaComponentId}});
|
||||
|
||||
console.log(manaComponentId);
|
||||
console.log(saleId);
|
||||
console.log(saleUpdated);
|
||||
console.log(createdSaleComponent);
|
||||
|
||||
expect(saleUpdated.price).toBe(price);
|
||||
expect(createdSaleComponent.value).toEqual(-2.04);
|
||||
});
|
||||
|
|
|
@ -56,7 +56,9 @@ module.exports = Self => {
|
|||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
let usesMana = await models.WorkerMana.findOne({where: {workerFk: userId}, fields: 'amount'}, options);
|
||||
|
||||
let componentCode = usesMana ? 'mana' : 'buyerDiscount';
|
||||
|
||||
let discount = await models.Component.findOne({where: {code: componentCode}}, options);
|
||||
|
@ -80,7 +82,6 @@ module.exports = Self => {
|
|||
value: componentValue
|
||||
}, options);
|
||||
}
|
||||
|
||||
await sale.updateAttributes({price: newPrice}, options);
|
||||
|
||||
query = `CALL vn.manaSpellersRequery(?)`;
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('sale updateDiscount()', () => {
|
|||
|
||||
beforeAll(async done => {
|
||||
originalSale = await app.models.Sale.findById(originalSaleId);
|
||||
let manaDiscount = await app.models.Component.findOne({where: {code: 'mana'}});
|
||||
let manaDiscount = await app.models.Component.findOne({where: {code: 'buyerDiscount'}});
|
||||
componentId = manaDiscount.id;
|
||||
|
||||
let ticket = await app.models.Ticket.findById(originalSale.ticketFk);
|
||||
|
@ -26,7 +26,6 @@ describe('sale updateDiscount()', () => {
|
|||
done();
|
||||
});
|
||||
|
||||
|
||||
it('should throw an error if no sales were selected', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
let error;
|
||||
|
@ -76,6 +75,28 @@ describe('sale updateDiscount()', () => {
|
|||
});
|
||||
|
||||
it('should update the discount if the salesPerson has mana', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 18}}};
|
||||
const ticketId = 11;
|
||||
const sales = [originalSaleId];
|
||||
const newDiscount = 100;
|
||||
let manaDiscount = await app.models.Component.findOne({where: {code: 'mana'}});
|
||||
componentId = manaDiscount.id;
|
||||
|
||||
await app.models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount);
|
||||
|
||||
let updatedSale = await app.models.Sale.findById(originalSaleId);
|
||||
let createdSaleComponent = await app.models.SaleComponent.findOne({
|
||||
where: {
|
||||
componentFk: componentId,
|
||||
saleFk: originalSaleId
|
||||
}
|
||||
});
|
||||
|
||||
expect(createdSaleComponent.componentFk).toEqual(componentId);
|
||||
expect(updatedSale.discount).toEqual(100);
|
||||
});
|
||||
|
||||
it('should update the discount and add company discount component if the worker does not have mana', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
const ticketId = 11;
|
||||
const sales = [originalSaleId];
|
||||
|
|
|
@ -90,7 +90,6 @@ module.exports = Self => {
|
|||
where: {code: componentCode}}, options);
|
||||
|
||||
const componentId = discountComponent.id;
|
||||
|
||||
let promises = [];
|
||||
for (let sale of sales) {
|
||||
const value = ((-sale.price * newDiscount) / 100);
|
||||
|
|
|
@ -16,14 +16,11 @@ module.exports = Self => {
|
|||
Self.getCurrentWorkerMana = async ctx => {
|
||||
let userId = ctx.req.accessToken.userId;
|
||||
|
||||
console.log(userId);
|
||||
let workerMana = await Self.app.models.WorkerMana.findOne({
|
||||
where: {workerFk: userId},
|
||||
fields: 'amount'
|
||||
});
|
||||
let workerMana1 = await Self.app.models.WorkerMana.find();
|
||||
console.log(workerMana);
|
||||
console.log(workerMana1);
|
||||
|
||||
return workerMana ? workerMana.amount : 0;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue