Merge pull request '8093-devToTest_2442_3' (!3100) from 8093-devToTest_2442_3 into test
Reviewed-on: #3100 Reviewed-by: Carlos Satorres <carlossa@verdnatura.es>
This commit is contained in:
commit
f61c2fa083
|
@ -38,7 +38,7 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'hasFile',
|
||||
type: 'Boolean',
|
||||
description: 'True if has an attached file'
|
||||
description: 'True if has the original in paper'
|
||||
},
|
||||
{
|
||||
arg: 'hasFileAttached',
|
||||
|
|
|
@ -72,9 +72,9 @@ describe('Renew Token', () => {
|
|||
}
|
||||
|
||||
expect(error).toBeDefined();
|
||||
const query = 'SELECT * FROM util.debug';
|
||||
|
||||
const debugLog = await models.Application.rawSql(query, null);
|
||||
const query = 'SELECT * FROM util.debug WHERE variable = "renewToken"';
|
||||
const debugLog = await models.Application.rawSql(query);
|
||||
|
||||
expect(debugLog.length).toEqual(1);
|
||||
});
|
||||
|
|
|
@ -175,6 +175,9 @@
|
|||
"PrintConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"QueueMember": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ViaexpressConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "QueueMember",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "pbx.queueMember"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"queue": {
|
||||
"type": "string"
|
||||
},
|
||||
"extension": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"queueRelation": {
|
||||
"type": "belongsTo",
|
||||
"model": "Queue",
|
||||
"foreignKey": "queue",
|
||||
"primaryKey": "name"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"property": "*",
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "employee",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -185,6 +185,7 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory
|
|||
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0),
|
||||
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1),
|
||||
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
|
||||
(6, 'Warehouse six', 'vnh', 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
|
||||
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0),
|
||||
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0);
|
||||
|
||||
|
@ -545,7 +546,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
|
|||
(6, 'Weight', 'weight'),
|
||||
(7, 'InvoiceOut', 'invoiceOut'),
|
||||
(8, 'DropOff', 'dropOff'),
|
||||
(9, 'Sustitución', 'substitution');
|
||||
(9, 'Sustitución', 'substitution'),
|
||||
(10, 'Finance', 'finance');
|
||||
|
||||
INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`)
|
||||
VALUES
|
||||
|
@ -1497,16 +1499,17 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk
|
|||
(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`)
|
||||
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),
|
||||
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2, 2),
|
||||
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),
|
||||
(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),
|
||||
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10);
|
||||
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10),
|
||||
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4),
|
||||
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4);
|
||||
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
|
||||
VALUES
|
||||
|
@ -1519,7 +1522,8 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
|
|||
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'),
|
||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''),
|
||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
|
||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '');
|
||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, ''),
|
||||
(99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, '');
|
||||
|
||||
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
||||
VALUES (2, 4, 1);
|
||||
|
@ -1542,7 +1546,7 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal
|
|||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'),
|
||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20');
|
||||
|
||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
||||
INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,freightValue,packageValue,comissionValue,packing,grouping,groupingMode,location,price1,price2,price3,printedStickers,isChecked,isIgnored,weight,created)
|
||||
VALUES
|
||||
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
|
||||
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
|
||||
|
@ -1558,7 +1562,8 @@ INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagi
|
|||
(12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||
(13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||
(14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE());
|
||||
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||
(16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000');
|
||||
|
||||
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
|
||||
VALUES
|
||||
|
@ -2439,7 +2444,8 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `
|
|||
(1107, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 1),
|
||||
(1107, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 1);
|
||||
|
||||
INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||
INSERT INTO `vn`.`dmsType`
|
||||
(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||
VALUES
|
||||
(1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'),
|
||||
(2, 'Doc oficial', NULL, NULL, 'officialDoc'),
|
||||
|
@ -2462,7 +2468,8 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
|||
(19, 'inmovilizado', NULL, NULL, 'fixedAssets'),
|
||||
(20, 'Reclamación', 1, 1, 'claim'),
|
||||
(21, 'Entrada', 1, 1, 'entry'),
|
||||
(22, 'Proveedor', 1, 1, 'supplier');
|
||||
(22, 'Proveedor', 1, 1, 'supplier'),
|
||||
(23, 'Termografos', 35, 35, 'thermograph');
|
||||
|
||||
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
|
||||
VALUES
|
||||
|
@ -2470,7 +2477,7 @@ INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `wa
|
|||
(2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE()),
|
||||
(3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE()),
|
||||
(4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE()),
|
||||
(5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()),
|
||||
(5, 23, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()),
|
||||
(6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()),
|
||||
(7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
||||
(8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
||||
|
@ -2520,14 +2527,15 @@ INSERT INTO `vn`.`thermograph`(`id`, `model`)
|
|||
('138350-0', 'DISPOSABLE');
|
||||
|
||||
|
||||
INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk`)
|
||||
INSERT INTO `vn`.`travelThermograph`
|
||||
(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `minTemperature`, `maxTemperature`, `result`, `dmsFk`)
|
||||
VALUES
|
||||
('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
|
||||
('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
|
||||
('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL),
|
||||
('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5),
|
||||
('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5),
|
||||
('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL);
|
||||
('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', NULL, NULL, 'Ok', NULL),
|
||||
('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', NULL, NULL, 'Ok', NULL),
|
||||
('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', NULL, NULL, 'can not read the temperature', NULL),
|
||||
('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', NULL, NULL, 'Temperature in range', 5),
|
||||
('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', 2, 12, NULL, 5),
|
||||
('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL, NULL, NULL);
|
||||
|
||||
REPLACE INTO `vn`.`incoterms`(`code`, `name`)
|
||||
VALUES
|
||||
|
@ -3935,6 +3943,11 @@ INSERT INTO vn.medicalReview
|
|||
(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark)
|
||||
VALUES(3, 9, 2, '2000-01-01', '8:00', 1, 150.0, NULL, NULL);
|
||||
|
||||
INSERT INTO vn.stockBought (workerFk, bought, reserve, dated)
|
||||
VALUES(35, 1.00, 1.00, '2001-01-01');
|
||||
INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk)
|
||||
VALUES (1,0.6,6);
|
||||
|
||||
INSERT INTO vn.payrollComponent
|
||||
(id, name, isSalaryAgreed, isVariable, isException)
|
||||
VALUES
|
||||
|
@ -3976,3 +3989,25 @@ VALUES
|
|||
INSERT IGNORE INTO ormConfig
|
||||
SET id =1,
|
||||
selectLimit = 1000;
|
||||
|
||||
INSERT INTO pbx.queueMultiConfig
|
||||
SET id = 'ring',
|
||||
strategy = 20,
|
||||
timeout = 2,
|
||||
retry = 0,
|
||||
weight = 0,
|
||||
maxLen = 0,
|
||||
ringInUse = 0;
|
||||
|
||||
INSERT INTO pbx.queue (description, name, config)
|
||||
VALUES ('X-men', '1000', 1),
|
||||
('Avengers', '2000', 1);
|
||||
|
||||
INSERT IGNORE INTO pbx.queueMember
|
||||
SET queue = '1000',
|
||||
extension = '1010';
|
||||
|
||||
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
|
||||
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ BEGIN
|
|||
* @param vUser The user identifier
|
||||
*/
|
||||
DECLARE vHasRows BOOL;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vHas0Amount BOOL;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vShipment DATE;
|
||||
DECLARE vShipmentDayEnd DATETIME;
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getVolumeByAgency`(vDated DATE, vAgencyFk INT)
|
||||
BEGIN
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.buy;
|
||||
CREATE TEMPORARY TABLE tmp.buy (buyFk INT NOT NULL, PRIMARY KEY (buyFk)) ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp.buy
|
||||
SELECT b.id
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed = vDated
|
||||
AND t.agencyModeFk IN (0, vAgencyFk);
|
||||
|
||||
CALL buy_getVolume();
|
||||
DROP TEMPORARY TABLE tmp.buy;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -23,6 +23,13 @@ BEGIN
|
|||
DELETE FROM messageInbox WHERE sendDate < v2Months;
|
||||
DELETE FROM messageInbox WHERE sendDate < v2Months;
|
||||
DELETE FROM workerTimeControl WHERE timed < v4Years;
|
||||
DELETE FROM itemShelvingSale
|
||||
WHERE itemShelvingFk IN (
|
||||
SELECT id
|
||||
FROM itemShelving
|
||||
WHERE created < util.VN_CURDATE()
|
||||
AND visible = 0
|
||||
);
|
||||
DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0;
|
||||
DELETE FROM ticketDown WHERE created < util.yesterday();
|
||||
DELETE IGNORE FROM expedition WHERE created < v26Months;
|
||||
|
@ -50,16 +57,10 @@ BEGIN
|
|||
DELETE FROM claim WHERE ticketCreated < v4Years;
|
||||
-- Robert ubicacion anterior de travelLog comentario para debug
|
||||
DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Months;
|
||||
DELETE bm
|
||||
FROM buyMark bm
|
||||
JOIN buy b ON b.id = bm.id
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed <= v2Months;
|
||||
DELETE b FROM buy b
|
||||
JOIN entryConfig e ON e.defaultEntry = b.entryFk
|
||||
WHERE b.created < v2Months;
|
||||
DELETE FROM stockBuyed WHERE creationDate < v2Months;
|
||||
DELETE FROM stockBought WHERE dated < v2Months;
|
||||
DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months;
|
||||
-- Equipos duplicados
|
||||
DELETE w.*
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_new`(vUserFk INT, OUT vCollectionFk INT)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_new`(
|
||||
vUserFk INT,
|
||||
OUT vCollectionFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Genera colecciones de tickets sin asignar trabajador.
|
||||
|
@ -12,30 +15,29 @@ BEGIN
|
|||
DECLARE vLinesLimit INT;
|
||||
DECLARE vTicketLines INT;
|
||||
DECLARE vVolumeLimit DECIMAL;
|
||||
DECLARE vTicketVolume DECIMAL;
|
||||
DECLARE vSizeLimit INT;
|
||||
DECLARE vTicketVolume DECIMAL;
|
||||
DECLARE vMaxTickets INT;
|
||||
DECLARE vStateFk VARCHAR(45);
|
||||
DECLARE vStateCode VARCHAR(45);
|
||||
DECLARE vFirstTicketFk INT;
|
||||
DECLARE vHour INT;
|
||||
DECLARE vMinute INT;
|
||||
DECLARE vWorkerCode VARCHAR(3);
|
||||
DECLARE vWagonCounter INT DEFAULT 0;
|
||||
DECLARE vWagonCounter INT DEFAULT 1;
|
||||
DECLARE vTicketFk INT;
|
||||
DECLARE vItemPackingTypeFk VARCHAR(1);
|
||||
DECLARE vHasAssignedTickets BOOLEAN;
|
||||
DECLARE vHasAssignedTickets BOOL;
|
||||
DECLARE vHasUniqueCollectionTime BOOL;
|
||||
DECLARE vDone INT DEFAULT FALSE;
|
||||
DECLARE vLockName VARCHAR(215);
|
||||
DECLARE vLockTime INT DEFAULT 30;
|
||||
DECLARE vHeight INT;
|
||||
DECLARE vVolume INT;
|
||||
DECLARE vLiters INT;
|
||||
DECLARE vLines INT;
|
||||
DECLARE vTotalLines INT DEFAULT 0;
|
||||
DECLARE vTotalVolume INT DEFAULT 0;
|
||||
DECLARE vFreeWagonFk INT;
|
||||
DECLARE vErrorNumber INT;
|
||||
DECLARE vErrorMsg TEXT;
|
||||
DECLARE vDone INT DEFAULT FALSE;
|
||||
|
||||
DECLARE c1 CURSOR FOR
|
||||
DECLARE vTickets CURSOR FOR
|
||||
SELECT ticketFk, `lines`, m3
|
||||
FROM tmp.productionBuffer
|
||||
WHERE ticketFk <> vFirstTicketFk
|
||||
ORDER BY HH,
|
||||
mm,
|
||||
productionOrder DESC,
|
||||
|
@ -48,26 +50,6 @@ BEGIN
|
|||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
GET DIAGNOSTICS CONDITION 1
|
||||
vErrorNumber = MYSQL_ERRNO,
|
||||
vErrorMsg = MESSAGE_TEXT;
|
||||
|
||||
CALL util.debugAdd('collection_new', JSON_OBJECT(
|
||||
'errorNumber', vErrorNumber,
|
||||
'errorMsg', vErrorMsg,
|
||||
'lockName', vLockName,
|
||||
'userFk', vUserFk,
|
||||
'ticketFk', vTicketFk
|
||||
)); -- Tmp
|
||||
|
||||
IF vLockName IS NOT NULL THEN
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
END IF;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
SELECT pc.ticketTrolleyMax * o.numberOfWagons,
|
||||
pc.hasUniqueCollectionTime,
|
||||
w.code,
|
||||
|
@ -78,36 +60,26 @@ BEGIN
|
|||
o.trainFk,
|
||||
o.linesLimit,
|
||||
o.volumeLimit,
|
||||
o.sizeLimit,
|
||||
pc.collection_new_lockname
|
||||
o.sizeLimit
|
||||
INTO vMaxTickets,
|
||||
vHasUniqueCollectionTime,
|
||||
vWorkerCode,
|
||||
vWarehouseFk,
|
||||
vItemPackingTypeFk,
|
||||
vStateFk,
|
||||
vStateCode,
|
||||
vWagons,
|
||||
vTrainFk,
|
||||
vLinesLimit,
|
||||
vVolumeLimit,
|
||||
vSizeLimit,
|
||||
vLockName
|
||||
FROM productionConfig pc
|
||||
JOIN worker w ON w.id = vUserFk
|
||||
vSizeLimit
|
||||
FROM worker w
|
||||
JOIN operator o ON o.workerFk = w.id
|
||||
JOIN state st ON st.`code` = 'ON_PREPARATION'
|
||||
JOIN operator o ON o.workerFk = vUserFk;
|
||||
|
||||
SET vLockName = CONCAT_WS('/',
|
||||
vLockName,
|
||||
vWarehouseFk,
|
||||
vItemPackingTypeFk
|
||||
);
|
||||
|
||||
IF NOT GET_LOCK(vLockName, vLockTime) THEN
|
||||
CALL util.throw(CONCAT('Cannot get lock: ', vLockName));
|
||||
END IF;
|
||||
JOIN productionConfig pc
|
||||
WHERE w.id = vUserFk;
|
||||
|
||||
-- Se prepara el tren, con tantos vagones como sea necesario.
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tTrain
|
||||
(wagon INT,
|
||||
shelve INT,
|
||||
|
@ -118,59 +90,60 @@ BEGIN
|
|||
PRIMARY KEY(wagon, shelve))
|
||||
ENGINE = MEMORY;
|
||||
|
||||
WHILE vWagons > vWagonCounter DO
|
||||
SET vWagonCounter = vWagonCounter + 1;
|
||||
|
||||
INSERT INTO tTrain(wagon, shelve, liters, `lines`, height)
|
||||
SELECT vWagonCounter, cv.`level` , cv.liters , cv.`lines` , cv.height
|
||||
FROM collectionVolumetry cv
|
||||
WHERE cv.trainFk = vTrainFk
|
||||
INSERT INTO tTrain (wagon, shelve, liters, `lines`, height)
|
||||
WITH RECURSIVE wagonSequence AS (
|
||||
SELECT vWagonCounter wagon
|
||||
UNION ALL
|
||||
SELECT wagon + 1 wagon
|
||||
FROM wagonSequence
|
||||
WHERE wagon < vWagonCounter + vWagons -1
|
||||
)
|
||||
SELECT ws.wagon, cv.`level`, cv.liters, cv.`lines`, cv.height
|
||||
FROM wagonSequence ws
|
||||
JOIN vn.collectionVolumetry cv ON cv.trainFk = vTrainFk
|
||||
AND cv.itemPackingTypeFk = vItemPackingTypeFk;
|
||||
END WHILE;
|
||||
|
||||
-- Esto desaparecerá cuando tengamos la table cache.ticket
|
||||
|
||||
CALL productionControl(vWarehouseFk, 0);
|
||||
|
||||
ALTER TABLE tmp.productionBuffer
|
||||
ADD COLUMN liters INT,
|
||||
ADD COLUMN height INT;
|
||||
|
||||
-- Se obtiene nº de colección.
|
||||
INSERT INTO collection
|
||||
SET itemPackingTypeFk = vItemPackingTypeFk,
|
||||
trainFk = vTrainFk,
|
||||
wagons = vWagons,
|
||||
warehouseFk = vWarehouseFk;
|
||||
|
||||
SELECT LAST_INSERT_ID() INTO vCollectionFk;
|
||||
|
||||
-- Los tickets de recogida en Algemesí sólo se sacan si están asignados.
|
||||
-- Los pedidos con riesgo no se sacan aunque se asignen.
|
||||
DELETE pb.*
|
||||
|
||||
DELETE pb
|
||||
FROM tmp.productionBuffer pb
|
||||
JOIN state s ON s.id = pb.state
|
||||
WHERE (pb.agency = 'REC_ALGEMESI'
|
||||
AND s.code <> 'PICKER_DESIGNED')
|
||||
OR pb.problem LIKE '%RIESGO%';
|
||||
|
||||
-- Comprobamos si hay tickets asignados. En ese caso, nos centramos
|
||||
-- exclusivamente en esos tickets y los sacamos independientemente
|
||||
-- de problemas o tamaños
|
||||
SELECT COUNT(*) INTO vHasAssignedTickets
|
||||
-- Si hay tickets asignados, nos centramos exclusivamente en esos tickets
|
||||
-- y los sacamos independientemente de problemas o tamaños
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT TRUE
|
||||
FROM tmp.productionBuffer pb
|
||||
JOIN state s ON s.id = pb.state
|
||||
WHERE s.code = 'PICKER_DESIGNED'
|
||||
AND pb.workerCode = vWorkerCode;
|
||||
WHERE (s.code = 'PICKER_DESIGNED'
|
||||
AND pb.workerCode = vWorkerCode)
|
||||
OR s.code = 'LAST_CALL'
|
||||
) INTO vHasAssignedTickets;
|
||||
|
||||
-- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados
|
||||
|
||||
IF vHasAssignedTickets THEN
|
||||
DELETE pb.*
|
||||
DELETE pb
|
||||
FROM tmp.productionBuffer pb
|
||||
JOIN state s ON s.id = pb.state
|
||||
WHERE s.code <> 'PICKER_DESIGNED'
|
||||
OR pb.workerCode <> vWorkerCode;
|
||||
WHERE (s.code <> 'PICKER_DESIGNED'
|
||||
OR pb.workerCode <> vWorkerCode)
|
||||
AND s.code <> 'LAST_CALL';
|
||||
ELSE
|
||||
DELETE pb.*
|
||||
DELETE pb
|
||||
FROM tmp.productionBuffer pb
|
||||
JOIN state s ON s.id = pb.state
|
||||
JOIN agencyMode am ON am.id = pb.agencyModeFk
|
||||
|
@ -193,24 +166,23 @@ BEGIN
|
|||
OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H')
|
||||
OR (NOT pb.V AND vItemPackingTypeFk = 'V')
|
||||
OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking)
|
||||
OR LENGTH(pb.problem) > 0
|
||||
OR LENGTH(pb.problem)
|
||||
OR pb.lines > vLinesLimit
|
||||
OR pb.m3 > vVolumeLimit
|
||||
OR sub.maxSize > vSizeLimit
|
||||
OR pb.hasPlantTray;
|
||||
END IF;
|
||||
|
||||
-- Es importante que el primer ticket se coja en todos los casos
|
||||
SELECT ticketFk,
|
||||
HH,
|
||||
mm,
|
||||
`lines`,
|
||||
m3
|
||||
INTO vFirstTicketFk,
|
||||
vHour,
|
||||
vMinute,
|
||||
vTicketLines,
|
||||
vTicketVolume
|
||||
-- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede
|
||||
|
||||
IF vHasUniqueCollectionTime THEN
|
||||
DELETE pb
|
||||
FROM tmp.productionBuffer pb
|
||||
JOIN tmp.productionBuffer pb2 ON pb2.ticketFk = vFirstTicketFk
|
||||
AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm);
|
||||
END IF;
|
||||
|
||||
SELECT ticketFk INTO vFirstTicketFk
|
||||
FROM tmp.productionBuffer
|
||||
ORDER BY HH,
|
||||
mm,
|
||||
|
@ -222,44 +194,37 @@ BEGIN
|
|||
ticketFk
|
||||
LIMIT 1;
|
||||
|
||||
-- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede
|
||||
IF vHasUniqueCollectionTime THEN
|
||||
DELETE FROM tmp.productionBuffer
|
||||
WHERE HH <> vHour
|
||||
OR mm <> vMinute;
|
||||
OPEN vTickets;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vTickets INTO vTicketFk, vTicketLines, vTicketVolume;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vTicketFk = vFirstTicketFk;
|
||||
SET @lines = 0;
|
||||
SET @volume = 0;
|
||||
|
||||
OPEN c1;
|
||||
read_loop: LOOP
|
||||
SET vDone = FALSE;
|
||||
|
||||
-- Buscamos un ticket que cumpla con los requisitos en el listado
|
||||
IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL)
|
||||
AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN
|
||||
|
||||
IF (vLinesLimit IS NULL OR (vTotalLines + vTicketLines) <= vLinesLimit)
|
||||
AND (vVolumeLimit IS NULL OR (vTotalVolume + vTicketVolume) <= vVolumeLimit) THEN
|
||||
|
||||
CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk);
|
||||
DROP TEMPORARY TABLE tmp.ticketIPT;
|
||||
|
||||
UPDATE tmp.productionBuffer pb
|
||||
JOIN (
|
||||
SELECT SUM(litros) liters,
|
||||
@lines:= COUNT(*) + @lines,
|
||||
COUNT(*) `lines`,
|
||||
MAX(i.`size`) height,
|
||||
@volume := SUM(sv.volume) + @volume,
|
||||
SUM(sv.volume) volume
|
||||
SELECT COUNT(*), SUM(litros), MAX(i.`size`), SUM(sv.volume)
|
||||
INTO vLines, vLiters, vHeight, vVolume
|
||||
FROM saleVolume sv
|
||||
JOIN sale s ON s.id = sv.saleFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE sv.ticketFk = vTicketFk
|
||||
) sub
|
||||
SET pb.liters = sub.liters,
|
||||
pb.`lines` = sub.`lines`,
|
||||
pb.height = sub.height
|
||||
WHERE sv.ticketFk = vTicketFk;
|
||||
|
||||
SET vTotalVolume = vTotalVolume + vVolume,
|
||||
vTotalLines = vTotalLines + vLines;
|
||||
|
||||
UPDATE tmp.productionBuffer pb
|
||||
SET pb.liters = vLiters,
|
||||
pb.`lines` = vLines,
|
||||
pb.height = vHeight
|
||||
WHERE pb.ticketFk = vTicketFk;
|
||||
|
||||
UPDATE tTrain tt
|
||||
|
@ -276,17 +241,13 @@ BEGIN
|
|||
tt.height
|
||||
LIMIT 1;
|
||||
|
||||
-- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre
|
||||
-- Si no le encuentra una balda, intentamos darle un carro entero libre
|
||||
|
||||
IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
|
||||
SELECT tt.wagon
|
||||
INTO vFreeWagonFk
|
||||
FROM tTrain tt
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT wagon
|
||||
SELECT wagon INTO vFreeWagonFk
|
||||
FROM tTrain
|
||||
WHERE ticketFk IS NOT NULL
|
||||
) nn ON nn.wagon = tt.wagon
|
||||
WHERE nn.wagon IS NULL
|
||||
GROUP BY wagon
|
||||
HAVING COUNT(ticketFk) = 0
|
||||
ORDER BY wagon
|
||||
LIMIT 1;
|
||||
|
||||
|
@ -295,38 +256,35 @@ BEGIN
|
|||
SET ticketFk = vFirstTicketFk
|
||||
WHERE wagon = vFreeWagonFk;
|
||||
|
||||
-- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
|
||||
DELETE tt.*
|
||||
FROM tTrain tt
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT wagon
|
||||
FROM tTrain
|
||||
WHERE ticketFk IS NOT NULL
|
||||
) nn ON nn.wagon = tt.wagon
|
||||
WHERE nn.wagon IS NULL;
|
||||
END IF;
|
||||
END IF;
|
||||
-- Se anulan el resto de carros libres,
|
||||
-- máximo un carro con pedido excesivo
|
||||
|
||||
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
|
||||
IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN
|
||||
LEAVE read_loop;
|
||||
DELETE tt
|
||||
FROM tTrain tt
|
||||
JOIN (SELECT wagon
|
||||
FROM tTrain
|
||||
GROUP BY wagon
|
||||
HAVING COUNT(ticketFk) = 0
|
||||
) sub ON sub.wagon = tt.wagon;
|
||||
END IF;
|
||||
ELSE
|
||||
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
|
||||
IF vDone THEN
|
||||
LEAVE read_loop;
|
||||
END IF;
|
||||
END IF;
|
||||
END LOOP;
|
||||
CLOSE c1;
|
||||
CLOSE vTickets;
|
||||
|
||||
IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
|
||||
UPDATE collection c
|
||||
JOIN state st ON st.code = 'ON_PREPARATION'
|
||||
SET c.stateFk = st.id
|
||||
WHERE c.id = vCollectionFk;
|
||||
-- Se obtiene nº de colección
|
||||
|
||||
INSERT INTO collection
|
||||
SET itemPackingTypeFk = vItemPackingTypeFk,
|
||||
trainFk = vTrainFk,
|
||||
wagons = vWagons,
|
||||
warehouseFk = vWarehouseFk;
|
||||
|
||||
SELECT LAST_INSERT_ID() INTO vCollectionFk;
|
||||
|
||||
-- Asigna las bandejas
|
||||
|
||||
INSERT IGNORE INTO ticketCollection(ticketFk, collectionFk, `level`, wagon, liters)
|
||||
SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters
|
||||
FROM tTrain tt
|
||||
|
@ -334,37 +292,34 @@ BEGIN
|
|||
ORDER BY tt.wagon, tt.shelve;
|
||||
|
||||
-- Actualiza el estado de los tickets
|
||||
CALL collection_setState(vCollectionFk, vStateFk);
|
||||
|
||||
CALL collection_setState(vCollectionFk, vStateCode);
|
||||
|
||||
-- Aviso para la preparacion previa
|
||||
|
||||
INSERT INTO ticketDown(ticketFk, collectionFk)
|
||||
SELECT tc.ticketFk, tc.collectionFk
|
||||
FROM ticketCollection tc
|
||||
WHERE tc.collectionFk = vCollectionFk;
|
||||
|
||||
CALL sales_mergeByCollection(vCollectionFk);
|
||||
CALL collection_mergeSales(vCollectionFk);
|
||||
|
||||
UPDATE `collection` c
|
||||
JOIN (
|
||||
JOIN(
|
||||
SELECT COUNT(*) saleTotalCount,
|
||||
SUM(s.isPicked <> 0) salePickedCount
|
||||
FROM ticketCollection tc
|
||||
JOIN sale s ON s.ticketFk = tc.ticketFk
|
||||
WHERE tc.collectionFk = vCollectionFk
|
||||
AND s.quantity > 0
|
||||
) sub
|
||||
)sub
|
||||
SET c.saleTotalCount = sub.saleTotalCount,
|
||||
c.salePickedCount = sub.salePickedCount
|
||||
WHERE c.id = vCollectionFk;
|
||||
|
||||
ELSE
|
||||
DELETE FROM `collection`
|
||||
WHERE id = vCollectionFk;
|
||||
SET vCollectionFk = NULL;
|
||||
END IF;
|
||||
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tTrain,
|
||||
tmp.productionBuffer;
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOut_newFromAddress`(
|
||||
IN vAddressFk INT,
|
||||
IN vSerial CHAR(2),
|
||||
IN vMaxShipped DATE,
|
||||
IN vCompanyFk INT,
|
||||
IN vTaxArea VARCHAR(25),
|
||||
IN vRef VARCHAR(25),
|
||||
OUT vInvoiceId INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Factura los tickets de un consignatario hasta una fecha dada
|
||||
* @param vAddressFk Id del consignatario a facturar
|
||||
* @param vSerial Serie de factura
|
||||
* @param vMaxShipped Fecha hasta la cual cogerá tickets para facturar
|
||||
* @param vCompanyFk Id de la empresa desde la que se factura
|
||||
* @param vTaxArea Tipo de iva en relacion a la empresa y al cliente, NULL por defecto
|
||||
* @param vRef Referencia de la factura en caso que se quiera forzar, NULL por defecto
|
||||
* @return vInvoiceId factura
|
||||
*/
|
||||
DECLARE vIsRefEditable BOOLEAN;
|
||||
|
||||
IF vRef IS NOT NULL AND vSerial IS NOT NULL THEN
|
||||
SELECT isRefEditable INTO vIsRefEditable
|
||||
FROM invoiceOutSerial
|
||||
WHERE code = vSerial;
|
||||
|
||||
IF NOT vIsRefEditable THEN
|
||||
CALL util.throw('serial non editable');
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`;
|
||||
CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice`
|
||||
(PRIMARY KEY (`id`))
|
||||
ENGINE = MEMORY
|
||||
SELECT id FROM ticket t
|
||||
WHERE t.addressFk = vAddressFk
|
||||
AND t.refFk IS NULL
|
||||
AND t.companyFk = vCompanyFk
|
||||
AND t.shipped BETWEEN
|
||||
util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR)
|
||||
AND util.dayend(vMaxShipped);
|
||||
|
||||
CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId);
|
||||
|
||||
UPDATE invoiceOut
|
||||
SET `ref` = vRef
|
||||
WHERE id = vInvoiceId
|
||||
AND vRef IS NOT NULL;
|
||||
|
||||
IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN
|
||||
CALL invoiceOutBooking(vInvoiceId);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,16 +1,22 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(vShelvingFk VARCHAR(3), vList TEXT, vIsChecking BOOL, vWarehouseFk INT)
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(
|
||||
vShelvingFk VARCHAR(3),
|
||||
vList TEXT,
|
||||
vIsChecking BOOL,
|
||||
vWarehouseFk INT
|
||||
)
|
||||
BEGIN
|
||||
/* Recorre cada elemento en la colección vList.
|
||||
/**
|
||||
* Recorre cada elemento en la colección vList.
|
||||
* Si el parámetro isChecking = FALSE, llama a itemShelving_add.
|
||||
*
|
||||
* 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 vn.itemShelving.isChecked
|
||||
* ese shelving, actualizando los valores del campo itemShelving.isChecked
|
||||
*
|
||||
* param vShelvingFk Identificador de vn.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 vn.warehouse
|
||||
* @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
|
||||
*/
|
||||
DECLARE vListLength INT DEFAULT JSON_LENGTH(vList);
|
||||
DECLARE vCounter INT DEFAULT 0;
|
||||
|
@ -20,26 +26,27 @@ BEGIN
|
|||
DECLARE vIsChecked BOOL;
|
||||
|
||||
WHILE vCounter < vListLength DO
|
||||
SET vPath = CONCAT('$[',vCounter,']');
|
||||
SET vBarcode = JSON_EXTRACT(vList,vPath);
|
||||
SET vPath = CONCAT('$[', vCounter, ']');
|
||||
SET vBarcode = JSON_EXTRACT(vList, vPath);
|
||||
SET vIsChecked = NULL;
|
||||
IF vIsChecking THEN
|
||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
||||
|
||||
SELECT COUNT(*) INTO vIsChecked
|
||||
FROM vn.itemShelving
|
||||
SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked
|
||||
FROM itemShelving
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||
AND itemFk = vItemFk;
|
||||
END IF;
|
||||
|
||||
IF NOT (vIsChecking AND vIsChecked) THEN
|
||||
CALL vn.itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
|
||||
IF NOT vIsChecking OR NOT vIsChecked THEN
|
||||
CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
|
||||
END IF;
|
||||
|
||||
UPDATE vn.itemShelving
|
||||
UPDATE itemShelving
|
||||
SET isChecked = vIsChecked
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||
AND itemFk = vItemFk AND isChecked IS NULL;
|
||||
AND itemFk = vItemFk
|
||||
AND isChecked IS NULL;
|
||||
|
||||
SET vCounter = vCounter + 1;
|
||||
END WHILE;
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockTraslation`(
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_calculateStock`(
|
||||
vDated DATE
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula el stock del almacén de subasta desde FechaInventario hasta vDated
|
||||
* sin tener en cuenta las salidas del mismo dia vDated
|
||||
* para ver el transporte a reservar
|
||||
* Calculate the stock of the auction warehouse from the inventory date to vDated
|
||||
*
|
||||
* @param vDated Fecha hasta la cual calcula el stock
|
||||
* @return tmp.item
|
||||
* @param vDated Date to calculate the stock.
|
||||
* @return tmp.item, tmp.buyUltimate
|
||||
*/
|
||||
DECLARE vAuctionWarehouseFk INT;
|
||||
|
|
@ -15,13 +15,11 @@ proc: BEGIN
|
|||
DECLARE vEndingDate DATETIME;
|
||||
DECLARE vIsTodayRelative BOOLEAN;
|
||||
|
||||
SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
|
||||
INTO vEndingDate
|
||||
FROM productionConfig;
|
||||
|
||||
SELECT isTodayRelative INTO vIsTodayRelative
|
||||
FROM worker
|
||||
WHERE id = getUser(); -- Cambiar por account.myUser_getId(), falta dar permisos
|
||||
SELECT w.isTodayRelative, util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, pc.maxProductionScopeDays) DAY
|
||||
INTO vIsTodayRelative,vEndingDate
|
||||
FROM worker w
|
||||
JOIN productionConfig pc
|
||||
WHERE w.id = account.myUser_getId();
|
||||
|
||||
CALL prepareTicketList(util.yesterday(), vEndingDate);
|
||||
|
||||
|
@ -272,7 +270,6 @@ proc: BEGIN
|
|||
AND lb.item_id = s.itemFk
|
||||
JOIN buy b ON b.id = lb.buy_id
|
||||
JOIN packaging p ON p.id = b.packagingFk
|
||||
JOIN productionConfig pc
|
||||
SET pb.hasPlantTray = TRUE
|
||||
WHERE p.isPlantTray
|
||||
AND s.quantity >= b.packing
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
DELIMITER $$
|
||||
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
|
||||
vBusinessFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
|
||||
*
|
||||
* @param vBusinessFk ID del negocio
|
||||
*/
|
||||
DECLARE vNewQueue VARCHAR(10);
|
||||
DECLARE vExtension VARCHAR(10);
|
||||
DECLARE exit handler FOR SQLEXCEPTION
|
||||
|
||||
SELECT d.pbxQueue, s.extension
|
||||
INTO vNewQueue, vExtension
|
||||
FROM business b
|
||||
JOIN department d ON d.id = b.departmentFk
|
||||
JOIN pbx.sip s ON s.user_id = b.workerFk
|
||||
WHERE b.id = vBusinessFk;
|
||||
|
||||
DELETE FROM pbx.queueMember
|
||||
WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||
|
||||
INSERT IGNORE INTO pbx.queueMember (queue, extension)
|
||||
VALUES (vNewQueue, vExtension);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,74 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBuyedByWorker`(
|
||||
vDated DATE,
|
||||
vWorker INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Inserta el volumen de compra de un comprador
|
||||
* en stockBuyed de acuerdo con la fecha.
|
||||
*
|
||||
* @param vDated Fecha de compra
|
||||
* @param vWorker Id de trabajador
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tStockBuyed
|
||||
(INDEX (userFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT requested, reserved, userFk
|
||||
FROM stockBuyed
|
||||
WHERE dated = vDated
|
||||
AND userFk = vWorker;
|
||||
|
||||
DELETE FROM stockBuyed
|
||||
WHERE dated = vDated
|
||||
AND userFk = vWorker;
|
||||
|
||||
CALL stockTraslation(vDated);
|
||||
|
||||
INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description)
|
||||
SELECT it.workerFk,
|
||||
SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000,
|
||||
vDated,
|
||||
sb.reserved,
|
||||
sb.requested,
|
||||
u.name
|
||||
FROM itemType it
|
||||
JOIN item i ON i.typeFk = it.id
|
||||
LEFT JOIN tmp.item ti ON ti.itemFk = i.id
|
||||
JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||
JOIN warehouse wh ON wh.code = 'VNH'
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
|
||||
AND bu.warehouseFk = wh.id
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
JOIN volumeConfig vc
|
||||
JOIN account.`user` u ON u.id = it.workerFk
|
||||
LEFT JOIN tStockBuyed sb ON sb.userFk = it.workerFk
|
||||
WHERE ic.display
|
||||
AND it.workerFk = vWorker;
|
||||
|
||||
SELECT b.entryFk Id_Entrada,
|
||||
i.id Id_Article,
|
||||
i.name Article,
|
||||
ti.quantity Cantidad,
|
||||
(ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id))
|
||||
/ (vc.trolleyM3 * 1000000) buyed,
|
||||
b.packagingFk id_cubo,
|
||||
b.packing
|
||||
FROM tmp.item ti
|
||||
JOIN item i ON i.id = ti.itemFk
|
||||
JOIN itemType it ON i.typeFk = it.id
|
||||
JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||
JOIN worker w ON w.id = it.workerFk
|
||||
JOIN auctionConfig ac
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
|
||||
AND bu.warehouseFk = ac.warehouseFk
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
JOIN volumeConfig vc
|
||||
WHERE ic.display
|
||||
AND w.id = vWorker;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate,
|
||||
tmp.item,
|
||||
tStockBuyed;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,70 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBuyed_add`(
|
||||
vDated DATE
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Inserta el volumen de compra por comprador
|
||||
* en stockBuyed de acuerdo con la fecha.
|
||||
*
|
||||
* @param vDated Fecha de compra
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tStockBuyed
|
||||
(INDEX (userFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT requested, reserved, userFk
|
||||
FROM stockBuyed
|
||||
WHERE dated = vDated;
|
||||
|
||||
DELETE FROM stockBuyed WHERE dated = vDated;
|
||||
|
||||
CALL stockTraslation(vDated);
|
||||
|
||||
INSERT INTO stockBuyed(userFk, buyed, `dated`, description)
|
||||
SELECT it.workerFk,
|
||||
SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000,
|
||||
vDated,
|
||||
u.name
|
||||
FROM itemType it
|
||||
JOIN item i ON i.typeFk = it.id
|
||||
LEFT JOIN tmp.item ti ON ti.itemFk = i.id
|
||||
JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||
JOIN warehouse wh ON wh.code = 'VNH'
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
JOIN volumeConfig vc
|
||||
JOIN account.`user` u ON u.id = it.workerFk
|
||||
JOIN workerDepartment wd ON wd.workerFk = u.id
|
||||
JOIN department d ON d.id = wd.departmentFk
|
||||
WHERE ic.display
|
||||
AND d.code IN ('shopping', 'logistic', 'franceTeam')
|
||||
GROUP BY it.workerFk;
|
||||
|
||||
INSERT INTO stockBuyed(buyed, dated, description)
|
||||
SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000),
|
||||
vDated,
|
||||
IF(c.code = 'ES', p.name, c.name) destiny
|
||||
FROM itemTicketOut ito
|
||||
JOIN ticket t ON t.id = ito.ticketFk
|
||||
JOIN `address` a ON a.id = t.addressFk
|
||||
JOIN province p ON p.id = a.provinceFk
|
||||
JOIN country c ON c.id = p.countryFk
|
||||
JOIN warehouse wh ON wh.id = t.warehouseFk
|
||||
JOIN itemCost ic ON ic.itemFk = ito.itemFk
|
||||
AND ic.warehouseFk = t.warehouseFk
|
||||
JOIN volumeConfig vc
|
||||
WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated)
|
||||
AND wh.code = 'VNH'
|
||||
GROUP BY destiny;
|
||||
|
||||
UPDATE stockBuyed s
|
||||
JOIN tStockBuyed ts ON ts.userFk = s.userFk
|
||||
SET s.requested = ts.requested,
|
||||
s.reserved = ts.reserved
|
||||
WHERE s.dated = vDated;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate,
|
||||
tmp.item,
|
||||
tStockBuyed;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,25 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketRefund_upsert`(
|
||||
vRefundTicketFk INT,
|
||||
vOriginalTicketFk INT
|
||||
)
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Common code for ticketRefund triggers
|
||||
*
|
||||
* @param vRefundTicketFk
|
||||
* @param vOriginalTicketFk
|
||||
*/
|
||||
DECLARE vIsDeleted BOOL;
|
||||
|
||||
SELECT COUNT(*) INTO vIsDeleted
|
||||
FROM ticket
|
||||
WHERE id IN (vRefundTicketFk, vOriginalTicketFk)
|
||||
AND isDeleted;
|
||||
|
||||
IF vIsDeleted THEN
|
||||
CALL util.throw('The refund ticket cannot be deleted tickets');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -3,12 +3,25 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_mergeSales`(
|
|||
vSelf INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Para un ticket se agrupa las diferentes líneas de venta de un mismo artículo en una sola
|
||||
* siempre y cuando tengan el mismo precio y dto.
|
||||
*
|
||||
* @param vSelf Id de ticket
|
||||
*/
|
||||
DECLARE vHasSalesToMerge BOOL;
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT id INTO vSelf
|
||||
FROM ticket
|
||||
WHERE id = vSelf FOR UPDATE;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
|
@ -18,26 +31,24 @@ BEGIN
|
|||
JOIN itemType it ON it.id = i.typeFk
|
||||
WHERE s.ticketFk = vSelf
|
||||
AND it.isMergeable
|
||||
GROUP BY s.itemFk, s.price, s.discount;
|
||||
GROUP BY s.itemFk, s.price, s.discount
|
||||
HAVING COUNT(*) > 1;
|
||||
|
||||
START TRANSACTION;
|
||||
SELECT COUNT(*) INTO vHasSalesToMerge FROM tSalesToPreserve;
|
||||
|
||||
IF vHasSalesToMerge THEN
|
||||
UPDATE sale s
|
||||
JOIN tSalesToPreserve stp ON stp.id = s.id
|
||||
SET s.quantity = newQuantity
|
||||
WHERE s.ticketFk = vSelf;
|
||||
SET s.quantity = newQuantity;
|
||||
|
||||
DELETE s.*
|
||||
DELETE s
|
||||
FROM sale s
|
||||
LEFT JOIN tSalesToPreserve stp ON stp.id = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemType it ON it.id = i.typeFk
|
||||
JOIN tSalesToPreserve stp ON stp.itemFk = s.itemFk
|
||||
WHERE s.ticketFk = vSelf
|
||||
AND stp.id IS NULL
|
||||
AND it.isMergeable;
|
||||
AND s.id <> stp.id;
|
||||
END IF;
|
||||
|
||||
COMMIT;
|
||||
|
||||
DROP TEMPORARY TABLE tSalesToPreserve;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,83 +3,62 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki
|
|||
vSelf INT,
|
||||
vOriginalItemPackingTypeFk VARCHAR(1)
|
||||
)
|
||||
BEGIN
|
||||
proc:BEGIN
|
||||
/**
|
||||
* Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado.
|
||||
* Respeta el id inicial para el tipo propuesto.
|
||||
* Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado.
|
||||
* Respeta el id de ticket original para el tipo de empaquetado propuesto.
|
||||
*
|
||||
* @param vSelf Id ticket
|
||||
* @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original
|
||||
* @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original
|
||||
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
*/
|
||||
DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H';
|
||||
DECLARE vNewTicketFk INT;
|
||||
DECLARE vPackingTypesToSplit INT;
|
||||
DECLARE vDone INT DEFAULT FALSE;
|
||||
DECLARE vHasItemPackingType BOOL;
|
||||
DECLARE vItemPackingTypeFk INT;
|
||||
DECLARE vNewTicketFk INT;
|
||||
|
||||
DECLARE vSaleGroup CURSOR FOR
|
||||
SELECT itemPackingTypeFk
|
||||
FROM tSaleGroup
|
||||
WHERE itemPackingTypeFk IS NOT NULL
|
||||
ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC;
|
||||
DECLARE vItemPackingTypes CURSOR FOR
|
||||
SELECT DISTINCT itemPackingTypeFk
|
||||
FROM tSalesToMove;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT id
|
||||
FROM sale
|
||||
WHERE ticketFk = vSelf
|
||||
AND NOT quantity
|
||||
FOR UPDATE;
|
||||
|
||||
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
|
||||
SELECT COUNT(*) INTO vHasItemPackingType
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
WHERE s.ticketFk = vSelf;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tSaleGroup
|
||||
ENGINE = MEMORY
|
||||
SELECT itemPackingTypeFk, SUM(litros) totalLitros
|
||||
FROM tSale
|
||||
GROUP BY itemPackingTypeFk;
|
||||
|
||||
SELECT COUNT(*) INTO vPackingTypesToSplit
|
||||
FROM tSaleGroup
|
||||
WHERE itemPackingTypeFk IS NOT NULL;
|
||||
WHERE t.id = vSelf
|
||||
AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
|
||||
ticketFk INT,
|
||||
itemPackingTypeFk VARCHAR(1)
|
||||
) ENGINE = MEMORY;
|
||||
) ENGINE=MEMORY
|
||||
SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk;
|
||||
|
||||
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;
|
||||
IF NOT vHasItemPackingType THEN
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
VALUES(vSelf, vItemPackingTypeFk);
|
||||
CREATE OR REPLACE TEMPORARY TABLE tSalesToMove (
|
||||
ticketFk INT,
|
||||
saleFk INT,
|
||||
itemPackingTypeFk INT
|
||||
) ENGINE=MEMORY;
|
||||
|
||||
INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk)
|
||||
SELECT s.id, i.itemPackingTypeFk
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
WHERE t.id = vSelf
|
||||
AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk;
|
||||
|
||||
OPEN vItemPackingTypes;
|
||||
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vSaleGroup INTO vItemPackingTypeFk;
|
||||
FETCH vItemPackingTypes INTO vItemPackingTypeFk;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
|
@ -87,40 +66,24 @@ BEGIN
|
|||
|
||||
CALL ticket_Clone(vSelf, vNewTicketFk);
|
||||
|
||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||
VALUES(vNewTicketFk, vItemPackingTypeFk);
|
||||
UPDATE tSalesToMove
|
||||
SET ticketFk = vNewTicketFk
|
||||
WHERE itemPackingTypeFk = 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;
|
||||
CLOSE vItemPackingTypes;
|
||||
|
||||
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;
|
||||
JOIN tSalesToMove stm ON stm.saleFk = s.id
|
||||
SET s.ticketFk = stm.ticketFk
|
||||
WHERE stm.ticketFk;
|
||||
|
||||
SELECT itemPackingTypeFk INTO vItemPackingTypeFk
|
||||
FROM tSaleGroup sg
|
||||
WHERE sg.itemPackingTypeFk IS NOT NULL
|
||||
ORDER BY sg.itemPackingTypeFk
|
||||
LIMIT 1;
|
||||
INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk)
|
||||
SELECT ticketFk, itemPackingTypeFk
|
||||
FROM tSalesToMove
|
||||
GROUP BY ticketFk;
|
||||
|
||||
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
|
||||
tSale,
|
||||
tSaleGroup;
|
||||
DROP TEMPORARY TABLE tSalesToMove;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -21,6 +21,8 @@ BEGIN
|
|||
SET businessFk = vNewBusinessFk
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL queueMember_updateQueue(vNewBusinessFk);
|
||||
|
||||
IF vOldBusinessFk IS NULL THEN
|
||||
CALL account.account_enable(vSelf);
|
||||
|
||||
|
|
|
@ -3,10 +3,20 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate`
|
|||
AFTER UPDATE ON `business`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vIsActive BOOL;
|
||||
DECLARE vExtension VARCHAR(10);
|
||||
|
||||
CALL worker_updateBusiness(NEW.workerFk);
|
||||
|
||||
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
|
||||
CALL worker_updateBusiness(OLD.workerFk);
|
||||
END IF;
|
||||
|
||||
IF NOT (OLD.departmentFk <=> NEW.departmentFk) THEN
|
||||
SELECT COUNT(*) INTO vIsActive FROM worker WHERE businessFk = NEW.id;
|
||||
IF vIsActive THEN
|
||||
CALL queueMember_updateQueue(NEW.id);
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInse
|
|||
BEFORE INSERT ON `ticketRefund`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk);
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpda
|
|||
BEFORE UPDATE ON `ticketRefund`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk);
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -4,5 +4,14 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travelThermograph_befor
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
IF NEW.travelFk IS NULL AND
|
||||
(SELECT COUNT(*) FROM travelThermograph
|
||||
WHERE thermographFk = NEW.thermographFk
|
||||
AND travelFk IS NULL
|
||||
AND id <> NEW.id) > 0
|
||||
THEN
|
||||
CALL util.throw('Duplicate thermographFk without travelFk not allowed.');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -4,5 +4,14 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travelThermograph_befor
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
IF NEW.travelFk IS NULL AND
|
||||
(SELECT COUNT(*) FROM travelThermograph
|
||||
WHERE thermographFk = NEW.thermographFk
|
||||
AND travelFk IS NULL
|
||||
AND id <> NEW.id) > 0
|
||||
THEN
|
||||
CALL util.throw('Duplicate thermographFk without travelFk not allowed.');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -13,6 +13,5 @@ AS SELECT `am`.`id` AS `Id_Agencia`,
|
|||
`am`.`reportMail` AS `send_mail`,
|
||||
`am`.`isActive` AS `tpv`,
|
||||
`am`.`code` AS `code`,
|
||||
`am`.`showAgencyName` AS `show_AgencyName`,
|
||||
`am`.`isRiskFree` AS `isRiskFree`
|
||||
FROM `vn`.`agencyMode` `am`
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`Compres_mark`
|
||||
AS SELECT `bm`.`id` AS `Id_Compra`,
|
||||
`bm`.`comment` AS `comment`,
|
||||
`bm`.`mark` AS `mark`,
|
||||
`bm`.`odbcDate` AS `odbc_date`
|
||||
FROM `vn`.`buyMark` `bm`
|
|
@ -0,0 +1,7 @@
|
|||
UPDATE vn.itemShelving
|
||||
SET isChecked = TRUE
|
||||
WHERE isChecked;
|
||||
|
||||
UPDATE vn.itemShelving
|
||||
SET isChecked = FALSE
|
||||
WHERE NOT isChecked;
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE vn.clientObservation
|
||||
ADD COLUMN IF NOT EXISTS observationTypeFk TINYINT(3) UNSIGNED NOT NULL,
|
||||
ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id);
|
|
@ -0,0 +1,3 @@
|
|||
INSERT IGNORE INTO vn.observationType
|
||||
SET description = 'Finance',
|
||||
code = 'finance';
|
|
@ -0,0 +1,3 @@
|
|||
DELETE FROM salix.ACL
|
||||
WHERE model = 'WorkerLog'
|
||||
AND property = '*';
|
|
@ -0,0 +1,5 @@
|
|||
/*
|
||||
UPDATE vn.sale
|
||||
SET originalQuantity = quantity
|
||||
WHERE originalQuantity IS NULL
|
||||
*/
|
|
@ -0,0 +1 @@
|
|||
-- ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity';
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE `vn`.`travelThermograph`
|
||||
ADD COLUMN `maxTemperature` DECIMAL(5,2) NULL AFTER `temperatureFk`,
|
||||
ADD COLUMN `minTemperature` DECIMAL(5,2) NULL AFTER `maxTemperature`;
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE `vn`.`travelThermograph` DROP FOREIGN KEY travelThermographDmsFgn;
|
||||
ALTER TABLE `vn`.`travelThermograph` ADD CONSTRAINT travelThermographDmsFgn FOREIGN KEY (dmsFk) REFERENCES vn.dms(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -0,0 +1,31 @@
|
|||
-- vn.priceDelta definition
|
||||
|
||||
CREATE OR REPLACE TABLE vn.priceDelta (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`itemTypeFk` smallint(5) unsigned NOT NULL,
|
||||
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
|
||||
`maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size',
|
||||
`inkFk` varchar(3) DEFAULT NULL,
|
||||
`originFk` tinyint(2) unsigned DEFAULT NULL,
|
||||
`producerFk` mediumint(3) unsigned DEFAULT NULL,
|
||||
`fromDated` date DEFAULT NULL,
|
||||
`toDated` date DEFAULT NULL,
|
||||
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
|
||||
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price',
|
||||
`warehouseFk` smallint(6) unsigned NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
`editorFk` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
|
||||
KEY `priceDelta_ink_FK` (`inkFk`),
|
||||
KEY `priceDelta_producer_FK` (`producerFk`),
|
||||
KEY `priceDelta_warehouse_FK` (`warehouseFk`),
|
||||
KEY `priceDelta_worker_FK` (`editorFk`),
|
||||
CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';
|
||||
|
||||
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer;
|
|
@ -0,0 +1,32 @@
|
|||
-- Place your SQL code here
|
||||
-- vn.priceDelta definition
|
||||
|
||||
CREATE OR REPLACE TABLE vn.priceDelta (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`itemTypeFk` smallint(5) unsigned NOT NULL,
|
||||
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
|
||||
`maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size',
|
||||
`inkFk` varchar(3) DEFAULT NULL,
|
||||
`originFk` tinyint(2) unsigned DEFAULT NULL,
|
||||
`producerFk` mediumint(3) unsigned DEFAULT NULL,
|
||||
`fromDated` date DEFAULT NULL,
|
||||
`toDated` date DEFAULT NULL,
|
||||
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
|
||||
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price',
|
||||
`warehouseFk` smallint(6) unsigned NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
`editorFk` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
|
||||
KEY `priceDelta_ink_FK` (`inkFk`),
|
||||
KEY `priceDelta_producer_FK` (`producerFk`),
|
||||
KEY `priceDelta_warehouse_FK` (`warehouseFk`),
|
||||
KEY `priceDelta_worker_FK` (`editorFk`),
|
||||
CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';
|
||||
|
||||
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer;
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE vn.agencyMode
|
||||
CHANGE IF EXISTS showAgencyName showAgencyName__ tinyint(1) DEFAULT 1 COMMENT '@deprecated 2024-09-24';
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE dipole.expedition_PrintOut DROP COLUMN IF EXISTS isChecked;
|
|
@ -0,0 +1,3 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL COMMENT 'Application area for the bonus component';
|
||||
ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,4 @@
|
|||
-- Place your SQL code here
|
||||
RENAME TABLE vn.stockBuyed TO vn.stockBuyed__;
|
||||
ALTER TABLE vn.stockBuyed__
|
||||
COMMENT='@deprecated 2024-10-01 rename and refactor to stockBought';
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.address MODIFY COLUMN isEqualizated tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.autonomy MODIFY COLUMN isUeeMember tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.chat MODIFY COLUMN checkUserStatus tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE vn.warehouse
|
||||
MODIFY COLUMN isOrigin tinyint(1) DEFAULT FALSE NOT NULL,
|
||||
MODIFY COLUMN isDestiny tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.zoneIncluded MODIFY COLUMN isIncluded tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE bs.defaulter MODIFY COLUMN hasChanged tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE account.user MODIFY COLUMN emailVerified tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -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 @@
|
|||
DROP TABLE IF EXISTS vn.buyMark;
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2;
|
||||
ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelving_fk2
|
||||
FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(code) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,2 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.itemShelving ADD IF NOT EXISTS isMoving BOOL DEFAULT FALSE NOT NULL COMMENT 'Indica que se ha marcado este registro para transferirlo a otro sector';
|
|
@ -0,0 +1,3 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving;
|
||||
ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL;
|
|
@ -1,68 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('SmartTable SearchBar integration', () => {
|
||||
let browser;
|
||||
let page;
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('salesPerson', 'item');
|
||||
await page.waitToClick(selectors.globalItems.searchButton);
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should search by type in searchBar, reload page and have same results', async() => {
|
||||
await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton);
|
||||
await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium');
|
||||
await page.waitToClick(selectors.itemsIndex.advancedSearchButton);
|
||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
|
||||
|
||||
await page.reload({
|
||||
waitUntil: 'networkidle2'
|
||||
});
|
||||
|
||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
|
||||
|
||||
await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
|
||||
|
||||
await page.reload({
|
||||
waitUntil: 'networkidle2'
|
||||
});
|
||||
|
||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
|
||||
});
|
||||
|
||||
it('should filter in section without smart-table and search in searchBar go to zone section', async() => {
|
||||
await page.loginAndModule('salesPerson', 'zone');
|
||||
await page.waitToClick(selectors.globalItems.searchButton);
|
||||
|
||||
await page.doSearch('A');
|
||||
const firstCount = await page.countElement(selectors.zoneIndex.searchResult);
|
||||
|
||||
await page.doSearch('A');
|
||||
const secondCount = await page.countElement(selectors.zoneIndex.searchResult);
|
||||
|
||||
expect(firstCount).toEqual(7);
|
||||
expect(secondCount).toEqual(7);
|
||||
});
|
||||
|
||||
it('should order orders by first id and order by last id, reload page and have same order', async() => {
|
||||
await page.loginAndModule('developer', 'item');
|
||||
await page.accessToSection('item.fixedPrice');
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '1');
|
||||
|
||||
await page.waitToClick(selectors.itemFixedPrice.orderColumnId);
|
||||
await page.reload({
|
||||
waitUntil: 'networkidle2'
|
||||
});
|
||||
await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '3');
|
||||
});
|
||||
});
|
|
@ -1,42 +0,0 @@
|
|||
import selectors from '../../helpers/selectors';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Client Add notes path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'client');
|
||||
await page.accessToSearchResult('Bruce Banner');
|
||||
await page.accessToSection('client.card.note.index');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it(`should reach the notes index`, async() => {
|
||||
await page.waitForState('client.card.note.index');
|
||||
});
|
||||
|
||||
it(`should click on the add note button`, async() => {
|
||||
await page.waitToClick(selectors.clientNotes.addNoteFloatButton);
|
||||
await page.waitForState('client.card.note.create');
|
||||
});
|
||||
|
||||
it(`should create a note`, async() => {
|
||||
await page.waitForSelector(selectors.clientNotes.note);
|
||||
await page.type(`${selectors.clientNotes.note} textarea`, 'Meeting with Black Widow 21st 9am');
|
||||
await page.waitToClick(selectors.clientNotes.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should confirm the note was created', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.clientNotes.firstNoteText, 'innerText');
|
||||
|
||||
expect(result).toEqual('Meeting with Black Widow 21st 9am');
|
||||
});
|
||||
});
|
|
@ -28,12 +28,12 @@ describe('Client defaulter path', () => {
|
|||
const salesPersonName =
|
||||
await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText');
|
||||
|
||||
expect(clientName).toEqual('Bruce Banner');
|
||||
expect(salesPersonName).toEqual('developer');
|
||||
expect(clientName).toEqual('Ororo Munroe');
|
||||
expect(salesPersonName).toEqual('salesperson');
|
||||
});
|
||||
|
||||
it('should first observation not changed', async() => {
|
||||
const expectedObservation = 'Meeting with Black Widow 21st 9am';
|
||||
const expectedObservation = 'Madness, as you know, is like gravity, all it takes is a little push';
|
||||
const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value');
|
||||
|
||||
expect(result).toContain(expectedObservation);
|
||||
|
@ -62,13 +62,4 @@ describe('Client defaulter path', () => {
|
|||
await page.write(selectors.clientDefaulter.observation, 'My new observation');
|
||||
await page.waitToClick(selectors.clientDefaulter.saveButton);
|
||||
});
|
||||
|
||||
it('should first observation changed', async() => {
|
||||
const message = await page.waitForSnackbar();
|
||||
await page.waitForSelector(selectors.clientDefaulter.firstObservation);
|
||||
const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value');
|
||||
|
||||
expect(message.text).toContain('Observation saved!');
|
||||
expect(result).toContain('My new observation');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
const $ = {
|
||||
id: 'vn-order-summary vn-one:nth-child(1) > vn-label-value:nth-child(1) span',
|
||||
alias: 'vn-order-summary vn-one:nth-child(1) > vn-label-value:nth-child(2) span',
|
||||
consignee: 'vn-order-summary vn-one:nth-child(2) > vn-label-value:nth-child(6) span',
|
||||
subtotal: 'vn-order-summary vn-one.taxes > p:nth-child(1)',
|
||||
vat: 'vn-order-summary vn-one.taxes > p:nth-child(2)',
|
||||
total: 'vn-order-summary vn-one.taxes > p:nth-child(3)',
|
||||
sale: 'vn-order-summary vn-tbody > vn-tr',
|
||||
};
|
||||
|
||||
describe('Order summary path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'order');
|
||||
await page.accessToSearchResult('16');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should reach the order summary section and check data', async() => {
|
||||
await page.waitForState('order.card.summary');
|
||||
|
||||
const id = await page.innerText($.id);
|
||||
const alias = await page.innerText($.alias);
|
||||
const consignee = await page.innerText($.consignee);
|
||||
const subtotal = await page.innerText($.subtotal);
|
||||
const vat = await page.innerText($.vat);
|
||||
const total = await page.innerText($.total);
|
||||
const sale = await page.countElement($.sale);
|
||||
|
||||
expect(id).toEqual('16');
|
||||
expect(alias).toEqual('Many places');
|
||||
expect(consignee).toEqual('address 26 - Gotham (Province one)');
|
||||
expect(subtotal.length).toBeGreaterThan(1);
|
||||
expect(vat.length).toBeGreaterThan(1);
|
||||
expect(total.length).toBeGreaterThan(1);
|
||||
expect(sale).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
|
@ -1,69 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
const $ = {
|
||||
form: 'vn-order-basic-data form',
|
||||
observation: 'vn-order-basic-data form [vn-name="note"]',
|
||||
saveButton: `vn-order-basic-data form button[type=submit]`,
|
||||
acceptButton: '.vn-confirm.shown button[response="accept"]'
|
||||
};
|
||||
|
||||
describe('Order edit basic data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
|
||||
await page.loginAndModule('employee', 'order');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('order.card.basicData');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
describe('when confirmed order', () => {
|
||||
it('should not be able to change the client', async() => {
|
||||
const message = await page.sendForm($.form, {
|
||||
client: 'Tony Stark',
|
||||
address: 'Tony Stark',
|
||||
});
|
||||
|
||||
expect(message.text).toContain(`You can't make changes on the basic data`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when new order', () => {
|
||||
it('should create an order and edit its basic data', async() => {
|
||||
await page.waitToClick(selectors.globalItems.returnToModuleIndexButton);
|
||||
await page.waitToClick($.acceptButton);
|
||||
await page.waitForContentLoaded();
|
||||
await page.waitToClick(selectors.ordersIndex.createOrderButton);
|
||||
await page.waitForState('order.create');
|
||||
|
||||
await page.autocompleteSearch(selectors.createOrderView.client, 'Jessica Jones');
|
||||
await page.pickDate(selectors.createOrderView.landedDatePicker);
|
||||
await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency');
|
||||
await page.waitToClick(selectors.createOrderView.createButton);
|
||||
await page.waitForState('order.card.catalog');
|
||||
|
||||
await page.accessToSection('order.card.basicData');
|
||||
|
||||
const values = {
|
||||
client: 'Tony Stark',
|
||||
address: 'Tony Stark',
|
||||
agencyMode: 'Other agency'
|
||||
};
|
||||
|
||||
const message = await page.sendForm($.form, values);
|
||||
await page.reloadSection('order.card.basicData');
|
||||
const formValues = await page.fetchForm($.form, Object.keys(values));
|
||||
|
||||
expect(message.isSuccess).toBeTrue();
|
||||
expect(formValues).toEqual(values);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,48 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Order lines', () => {
|
||||
let browser;
|
||||
let page;
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'order');
|
||||
await page.accessToSearchResult('8');
|
||||
await page.accessToSection('order.card.line');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should check the order subtotal', async() => {
|
||||
const result = await page
|
||||
.waitToGetProperty(selectors.orderLine.orderSubtotal, 'innerText');
|
||||
|
||||
expect(result).toContain('112.30');
|
||||
});
|
||||
|
||||
it('should delete the first line in the order', async() => {
|
||||
await page.waitToClick(selectors.orderLine.firstLineDeleteButton);
|
||||
await page.waitToClick(selectors.orderLine.confirmButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should confirm the order subtotal has changed', async() => {
|
||||
await page.waitForTextInElement(selectors.orderLine.orderSubtotal, '92.80');
|
||||
const result = await page
|
||||
.waitToGetProperty(selectors.orderLine.orderSubtotal, 'innerText');
|
||||
|
||||
expect(result).toContain('92.80');
|
||||
});
|
||||
|
||||
it('should confirm the whole order and redirect to ticket index filtered by clientFk', async() => {
|
||||
await page.waitToClick(selectors.orderLine.confirmOrder);
|
||||
|
||||
await page.expectURL('ticket/index');
|
||||
await page.expectURL('clientFk');
|
||||
});
|
||||
});
|
|
@ -1,97 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Order catalog', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'order');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should open the create new order form', async() => {
|
||||
await page.waitToClick(selectors.ordersIndex.createOrderButton);
|
||||
await page.waitForState('order.create');
|
||||
});
|
||||
|
||||
it('should create a new order', async() => {
|
||||
await page.autocompleteSearch(selectors.createOrderView.client, 'Tony Stark');
|
||||
await page.pickDate(selectors.createOrderView.landedDatePicker);
|
||||
await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency');
|
||||
await page.waitToClick(selectors.createOrderView.createButton);
|
||||
await page.waitForState('order.card.catalog');
|
||||
});
|
||||
|
||||
it('should add the realm and type filters and obtain results', async() => {
|
||||
await page.waitToClick(selectors.orderCatalog.plantRealmButton);
|
||||
await page.autocompleteSearch(selectors.orderCatalog.type, 'Anthurium');
|
||||
await page.waitForNumberOfElements('section.product', 4);
|
||||
const result = await page.countElement('section.product');
|
||||
|
||||
expect(result).toEqual(4);
|
||||
});
|
||||
|
||||
it('should perfom an "OR" search for the item tag colors silver and brown', async() => {
|
||||
await page.waitToClick(selectors.orderCatalog.openTagSearch);
|
||||
await page.autocompleteSearch(selectors.orderCatalog.tag, 'Color');
|
||||
await page.autocompleteSearch(selectors.orderCatalog.firstTagAutocomplete, 'silver');
|
||||
await page.waitToClick(selectors.orderCatalog.addTagButton);
|
||||
await page.autocompleteSearch(selectors.orderCatalog.secondTagAutocomplete, 'brown');
|
||||
await page.waitToClick(selectors.orderCatalog.searchTagButton);
|
||||
await page.waitForNumberOfElements('section.product', 4);
|
||||
});
|
||||
|
||||
it('should perfom an "OR" search for the item tag tallos 2 and 9', async() => {
|
||||
await page.waitToClick(selectors.orderCatalog.openTagSearch);
|
||||
await page.autocompleteSearch(selectors.orderCatalog.tag, 'Tallos');
|
||||
await page.write(selectors.orderCatalog.firstTagValue, '2');
|
||||
await page.waitToClick(selectors.orderCatalog.addTagButton);
|
||||
await page.write(selectors.orderCatalog.secondTagValue, '9');
|
||||
await page.waitToClick(selectors.orderCatalog.searchTagButton);
|
||||
await page.waitForNumberOfElements('section.product', 2);
|
||||
});
|
||||
|
||||
it('should perform a general search for category', async() => {
|
||||
await page.write(selectors.orderCatalog.itemTagValue, 'concussion');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.waitForNumberOfElements('section.product', 2);
|
||||
});
|
||||
|
||||
it('should perfom an "AND" search for the item tag tallos 2', async() => {
|
||||
await page.waitToClick(selectors.orderCatalog.openTagSearch);
|
||||
await page.autocompleteSearch(selectors.orderCatalog.tag, 'Tallos');
|
||||
await page.write(selectors.orderCatalog.firstTagValue, '2');
|
||||
await page.waitToClick(selectors.orderCatalog.searchTagButton);
|
||||
await page.waitForNumberOfElements('section.product', 1);
|
||||
});
|
||||
|
||||
it('should remove the tag filters and have 4 results', async() => {
|
||||
await page.waitForContentLoaded();
|
||||
await page.waitToClick(selectors.orderCatalog.sixthFilterRemoveButton);
|
||||
await page.waitForContentLoaded();
|
||||
await page.waitToClick(selectors.orderCatalog.fifthFilterRemoveButton);
|
||||
await page.waitForContentLoaded();
|
||||
await page.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton);
|
||||
await page.waitForContentLoaded();
|
||||
await page.waitToClick(selectors.orderCatalog.thirdFilterRemoveButton);
|
||||
|
||||
await page.waitForNumberOfElements('.product', 4);
|
||||
const result = await page.countElement('section.product');
|
||||
|
||||
expect(result).toEqual(4);
|
||||
});
|
||||
|
||||
it('should search for an item by id', async() => {
|
||||
await page.accessToSearchResult('2');
|
||||
await page.waitForNumberOfElements('section.product', 1);
|
||||
const result = await page.countElement('section.product');
|
||||
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
});
|
|
@ -1,34 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Order Index', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'order');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it(`should check the second search result doesn't contain a total of 0€`, async() => {
|
||||
await page.waitToClick(selectors.globalItems.searchButton);
|
||||
const result = await page.waitToGetProperty(selectors.ordersIndex.secondSearchResultTotal, 'innerText');
|
||||
|
||||
expect(result).not.toContain('0.00');
|
||||
});
|
||||
|
||||
it('should search including empty orders', async() => {
|
||||
await page.waitToClick(selectors.ordersIndex.openAdvancedSearch);
|
||||
await page.waitToClick(selectors.ordersIndex.advancedSearchShowEmptyCheckbox);
|
||||
await page.waitToClick(selectors.ordersIndex.advancedSearchButton);
|
||||
await page.waitForTextInElement(selectors.ordersIndex.secondSearchResultTotal, '0.00');
|
||||
const result = await page.waitToGetProperty(selectors.ordersIndex.secondSearchResultTotal, 'innerText');
|
||||
|
||||
expect(result).toContain('0.00');
|
||||
});
|
||||
});
|
|
@ -1,42 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Travel create path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('buyer', 'travel');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should create a new travel and check it was created with the correct data', async() => {
|
||||
const date = Date.vnNew();
|
||||
date.setDate(15);
|
||||
date.setUTCHours(0, 0, 0, 0);
|
||||
|
||||
await page.waitToClick(selectors.travelIndex.newTravelButton);
|
||||
await page.waitForState('travel.create');
|
||||
|
||||
const values = {
|
||||
reference: 'Testing reference',
|
||||
agencyMode: 'inhouse pickup',
|
||||
shipped: date,
|
||||
landed: date,
|
||||
warehouseOut: 'Warehouse One',
|
||||
warehouseIn: 'Warehouse Five'
|
||||
};
|
||||
|
||||
const message = await page.sendForm('vn-travel-create form', values);
|
||||
await page.waitForState('travel.card.basicData');
|
||||
const formValues = await page.fetchForm('vn-travel-basic-data form', Object.keys(values));
|
||||
|
||||
expect(message.isSuccess).toBeTrue();
|
||||
expect(formValues).toEqual(values);
|
||||
});
|
||||
});
|
|
@ -1,97 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Travel basic data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('buyer', 'travel');
|
||||
await page.write(selectors.travelIndex.generalSearchFilter, '3');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.accessToSection('travel.card.basicData');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should reach the thermograph section', async() => {
|
||||
await page.waitForState('travel.card.basicData');
|
||||
});
|
||||
|
||||
it('should set a wrong delivery date then receive an error on submit', async() => {
|
||||
await page.loginAndModule('buyer', 'travel');
|
||||
await page.write(selectors.travelIndex.generalSearchFilter, '4');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.accessToSection('travel.card.basicData');
|
||||
await page.waitForState('travel.card.basicData');
|
||||
|
||||
const lastMonth = Date.vnNew();
|
||||
lastMonth.setMonth(lastMonth.getMonth() - 2);
|
||||
|
||||
await page.pickDate(selectors.travelBasicData.deliveryDate, lastMonth);
|
||||
await page.waitToClick(selectors.travelBasicData.save);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Landing cannot be lesser than shipment');
|
||||
});
|
||||
|
||||
it('should undo the changes', async() => {
|
||||
await page.clearInput(selectors.travelBasicData.reference);
|
||||
await page.write(selectors.travelBasicData.reference, 'totally pointless ref');
|
||||
await page.waitToClick(selectors.travelBasicData.undoChanges);
|
||||
const result = await page.waitToGetProperty(selectors.travelBasicData.reference, 'value');
|
||||
|
||||
expect(result).toEqual('fourth travel');
|
||||
});
|
||||
|
||||
it('should now edit the whole form then save', async() => {
|
||||
await page.clearInput(selectors.travelBasicData.reference);
|
||||
await page.write(selectors.travelBasicData.reference, 'new reference!');
|
||||
await page.autocompleteSearch(selectors.travelBasicData.agency, 'Entanglement');
|
||||
await page.autocompleteSearch(selectors.travelBasicData.outputWarehouse, 'Warehouse Three');
|
||||
await page.autocompleteSearch(selectors.travelBasicData.inputWarehouse, 'Warehouse Four');
|
||||
await page.waitToClick(selectors.travelBasicData.delivered);
|
||||
await page.waitToClick(selectors.travelBasicData.received);
|
||||
await page.waitToClick(selectors.travelBasicData.save);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reload the section and check the reference was saved', async() => {
|
||||
await page.reloadSection('travel.card.basicData');
|
||||
const result = await page.waitToGetProperty(selectors.travelBasicData.reference, 'value');
|
||||
|
||||
expect(result).toEqual('new reference!');
|
||||
});
|
||||
|
||||
it('should check the agency was saved', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.travelBasicData.agency, 'value');
|
||||
|
||||
expect(result).toEqual('Entanglement');
|
||||
});
|
||||
|
||||
it('should check the output warehouse date was saved', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.travelBasicData.outputWarehouse, 'value');
|
||||
|
||||
expect(result).toEqual('Warehouse Three');
|
||||
});
|
||||
|
||||
it('should check the input warehouse date was saved', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.travelBasicData.inputWarehouse, 'value');
|
||||
|
||||
expect(result).toEqual('Warehouse Four');
|
||||
});
|
||||
|
||||
it(`should check the delivered checkbox was saved even tho it doesn't make sense`, async() => {
|
||||
await page.waitForClassPresent(selectors.travelBasicData.delivered, 'checked');
|
||||
});
|
||||
|
||||
it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => {
|
||||
await page.waitForClassPresent(selectors.travelBasicData.received, 'checked');
|
||||
});
|
||||
});
|
|
@ -1,36 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Travel descriptor path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('buyer', 'travel');
|
||||
await page.write(selectors.travelIndex.generalSearchFilter, '3');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.waitForState('travel.card.summary');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should click the descriptor button to navigate to the travel index showing all travels with current agency', async() => {
|
||||
await page.waitToClick(selectors.travelDescriptor.filterByAgencyButton);
|
||||
await page.waitForState('travel.index');
|
||||
const result = await page.countElement(selectors.travelIndex.anySearchResult);
|
||||
|
||||
expect(result).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should navigate to the first search result', async() => {
|
||||
await page.waitToClick(selectors.travelIndex.firstSearchResult);
|
||||
await page.waitForState('travel.card.summary');
|
||||
const state = await page.getState();
|
||||
|
||||
expect(state).toBe('travel.card.summary');
|
||||
});
|
||||
});
|
|
@ -1,42 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Travel extra community path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('buyer', 'travel');
|
||||
await page.accessToSection('travel.extraCommunity');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should edit the travel reference and the locked kilograms', async() => {
|
||||
await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter);
|
||||
await page.waitForSpinnerLoad();
|
||||
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
||||
await page.waitForSpinnerLoad();
|
||||
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelLockedKg, '1500');
|
||||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reload the index and confirm the reference and locked kg were edited', async() => {
|
||||
await page.accessToSection('travel.index');
|
||||
await page.accessToSection('travel.extraCommunity');
|
||||
await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter);
|
||||
await page.waitForTextInElement(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
||||
const reference = await page.getProperty(selectors.travelExtraCommunity.firstTravelReference, 'innerText');
|
||||
const lockedKg = await page.getProperty(selectors.travelExtraCommunity.firstTravelLockedKg, 'innerText');
|
||||
|
||||
expect(reference).toContain('edited reference');
|
||||
expect(lockedKg).toContain(1500);
|
||||
});
|
||||
});
|
|
@ -1,64 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Travel thermograph path', () => {
|
||||
const thermographName = '7H3-37H3RN4L-FL4M3';
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('buyer', 'travel');
|
||||
await page.write(selectors.travelIndex.generalSearchFilter, '3');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.accessToSection('travel.card.thermograph.index');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should reach the thermograph section', async() => {
|
||||
await page.waitForState('travel.card.thermograph.index');
|
||||
});
|
||||
|
||||
it('should click the add thermograph floating button', async() => {
|
||||
await page.waitToClick(selectors.travelThermograph.add);
|
||||
await page.waitForState('travel.card.thermograph.create');
|
||||
});
|
||||
|
||||
it('should click on the add thermograph icon of the thermograph autocomplete', async() => {
|
||||
await page.waitToClick(selectors.travelThermograph.addThermographIcon);
|
||||
await page.write(selectors.travelThermograph.newThermographId, thermographName);
|
||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographModel, 'TEMPMATE');
|
||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographWarehouse, 'Warehouse Two');
|
||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographTemperature, 'Warm');
|
||||
await page.waitToClick(selectors.travelThermograph.createThermographButton);
|
||||
});
|
||||
|
||||
it('should select the file to upload', async() => {
|
||||
let currentDir = process.cwd();
|
||||
let filePath = `${currentDir}/e2e/assets/thermograph.jpeg`;
|
||||
|
||||
const [fileChooser] = await Promise.all([
|
||||
page.waitForFileChooser(),
|
||||
page.waitToClick(selectors.travelThermograph.uploadIcon)
|
||||
]);
|
||||
await fileChooser.accept([filePath]);
|
||||
|
||||
await page.waitToClick(selectors.travelThermograph.upload);
|
||||
|
||||
const message = await page.waitForSnackbar();
|
||||
const state = await page.getState();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
expect(state).toBe('travel.card.thermograph.index');
|
||||
});
|
||||
|
||||
it('should check everything was saved correctly', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.travelThermograph.createdThermograph, 'innerText');
|
||||
|
||||
expect(result).toContain(thermographName);
|
||||
});
|
||||
});
|
|
@ -1,62 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Travel search panel path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
let httpRequest;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('buyer', 'travel');
|
||||
page.on('request', req => {
|
||||
if (req.url().includes(`Travels/filter`))
|
||||
httpRequest = req.url();
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should filter using all the fields', async() => {
|
||||
await page.click(selectors.travelIndex.chip);
|
||||
await page.write(selectors.travelIndex.generalSearchFilter, 'travel');
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
expect(httpRequest).toContain('search=travel');
|
||||
|
||||
await page.click(selectors.travelIndex.chip);
|
||||
await page.autocompleteSearch(selectors.travelIndex.agencyFilter, 'Entanglement');
|
||||
|
||||
expect(httpRequest).toContain('agencyModeFk');
|
||||
|
||||
await page.click(selectors.travelIndex.chip);
|
||||
await page.autocompleteSearch(selectors.travelIndex.warehouseOutFilter, 'Warehouse One');
|
||||
|
||||
expect(httpRequest).toContain('warehouseOutFk');
|
||||
|
||||
await page.click(selectors.travelIndex.chip);
|
||||
await page.autocompleteSearch(selectors.travelIndex.warehouseInFilter, 'Warehouse Two');
|
||||
|
||||
expect(httpRequest).toContain('warehouseInFk');
|
||||
|
||||
await page.click(selectors.travelIndex.chip);
|
||||
await page.overwrite(selectors.travelIndex.scopeDaysFilter, '15');
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
expect(httpRequest).toContain('scopeDays=15');
|
||||
|
||||
await page.click(selectors.travelIndex.chip);
|
||||
await page.autocompleteSearch(selectors.travelIndex.continentFilter, 'Asia');
|
||||
|
||||
expect(httpRequest).toContain('continent');
|
||||
|
||||
await page.click(selectors.travelIndex.chip);
|
||||
await page.write(selectors.travelIndex.totalEntriesFilter, '1');
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
expect(httpRequest).toContain('totalEntries=1');
|
||||
});
|
||||
});
|
|
@ -1,104 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Zone basic data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
|
||||
await page.loginAndModule('deliveryAssistant',
|
||||
'zone'); // turns up the zone module name and route aint the same lol
|
||||
await page.accessToSearchResult('10');
|
||||
await page.accessToSection('zone.card.basicData');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should reach the basic data section', async() => {
|
||||
await page.waitForState('zone.card.basicData');
|
||||
});
|
||||
|
||||
it('should edit de form and then save', async() => {
|
||||
await page.clearInput(selectors.zoneBasicData.name);
|
||||
await page.write(selectors.zoneBasicData.name, 'Brimstone teleportation');
|
||||
await page.autocompleteSearch(selectors.zoneBasicData.agency, 'Quantum break device');
|
||||
await page.clearInput(selectors.zoneBasicData.maxVolume);
|
||||
await page.write(selectors.zoneBasicData.maxVolume, '10');
|
||||
await page.clearInput(selectors.zoneBasicData.travelingDays);
|
||||
await page.write(selectors.zoneBasicData.travelingDays, '1');
|
||||
await page.clearInput(selectors.zoneBasicData.closing);
|
||||
await page.pickTime(selectors.zoneBasicData.closing, '21:00');
|
||||
await page.clearInput(selectors.zoneBasicData.price);
|
||||
await page.write(selectors.zoneBasicData.price, '999');
|
||||
await page.clearInput(selectors.zoneBasicData.bonus);
|
||||
await page.write(selectors.zoneBasicData.bonus, '100');
|
||||
await page.clearInput(selectors.zoneBasicData.inflation);
|
||||
await page.write(selectors.zoneBasicData.inflation, '200');
|
||||
await page.waitToClick(selectors.zoneBasicData.volumetric);
|
||||
await page.waitToClick(selectors.zoneBasicData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should now reload the section', async() => {
|
||||
await page.reloadSection('zone.card.basicData');
|
||||
});
|
||||
|
||||
it('should confirm the name was updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.name, 'value');
|
||||
|
||||
expect(result).toEqual('Brimstone teleportation');
|
||||
});
|
||||
|
||||
it('should confirm the agency was updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.agency, 'value');
|
||||
|
||||
expect(result).toEqual('Quantum break device');
|
||||
});
|
||||
|
||||
it('should confirm the max volume was updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.maxVolume, 'value');
|
||||
|
||||
expect(result).toEqual('10');
|
||||
});
|
||||
|
||||
it('should confirm the traveling days were updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.travelingDays, 'value');
|
||||
|
||||
expect(result).toEqual('1');
|
||||
});
|
||||
|
||||
it('should confirm the closing hour was updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.closing, 'value');
|
||||
|
||||
expect(result).toEqual('21:00');
|
||||
});
|
||||
|
||||
it('should confirm the price was updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.price, 'value');
|
||||
|
||||
expect(result).toEqual('999');
|
||||
});
|
||||
|
||||
it('should confirm the bonus was updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.bonus, 'value');
|
||||
|
||||
expect(result).toEqual('100');
|
||||
});
|
||||
|
||||
it('should confirm the inflation was updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.inflation, 'value');
|
||||
|
||||
expect(result).toEqual('200');
|
||||
});
|
||||
|
||||
it('should confirm the volumetric checkbox was checked', async() => {
|
||||
await page.waitForClassPresent(selectors.zoneBasicData.volumetric, 'checked');
|
||||
});
|
||||
});
|
|
@ -1,32 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Zone descriptor path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('deliveryAssistant', 'zone');
|
||||
await page.accessToSearchResult('13');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should eliminate the zone using the descriptor option', async() => {
|
||||
await page.waitToClick(selectors.zoneDescriptor.menu);
|
||||
await page.waitToClick(selectors.zoneDescriptor.deleteZone);
|
||||
await page.respondToDialog('accept');
|
||||
await page.waitForState('zone.index');
|
||||
});
|
||||
|
||||
it('should search for the deleted zone to find no results', async() => {
|
||||
await page.doSearch('13');
|
||||
const count = await page.countElement(selectors.zoneIndex.searchResult);
|
||||
|
||||
expect(count).toEqual(0);
|
||||
});
|
||||
});
|
|
@ -378,5 +378,9 @@
|
|||
"There is already a tray with the same height": "Ya existe una bandeja con la misma altura",
|
||||
"The height must be greater than 50cm": "La altura debe ser superior a 50cm",
|
||||
"The maximum height of the wagon is 200cm": "La altura máxima es 200cm",
|
||||
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea"
|
||||
"The entry does not have stickers": "La entrada no tiene etiquetas",
|
||||
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
|
||||
"No valid travel thermograph found": "No se encontró un termógrafo válido",
|
||||
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
|
||||
"type cannot be blank": "Se debe rellenar el tipo"
|
||||
}
|
|
@ -25,7 +25,12 @@
|
|||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "user_id"
|
||||
},
|
||||
"queueMember": {
|
||||
"type": "belongsTo",
|
||||
"model": "QueueMember",
|
||||
"foreignKey": "extension",
|
||||
"primaryKey": "extension"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
module.exports = function(Self) {
|
||||
Self.validate('text', isEnabled, {message: 'Description cannot be blank'});
|
||||
function isEnabled(err) {
|
||||
Self.validate('text', function(err) {
|
||||
if (!this.text) err();
|
||||
}
|
||||
}, {message: 'Description cannot be blank'});
|
||||
|
||||
Self.validate('observationTypeFk', function(err) {
|
||||
if (!this.observationTypeFk) err();
|
||||
}, {message: 'type cannot be blank'});
|
||||
|
||||
Self.observe('before save', function(ctx, next) {
|
||||
ctx.instance.created = Date();
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
"created": {
|
||||
"type": "date",
|
||||
"description": "Creation date and time"
|
||||
},
|
||||
"observationTypeFk": {
|
||||
"type": "number",
|
||||
"description": "Type of observation"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -44,11 +48,15 @@
|
|||
"include": {
|
||||
"relation": "worker",
|
||||
"scope": {
|
||||
"fields": ["id"],
|
||||
"fields": [
|
||||
"id"
|
||||
],
|
||||
"include": {
|
||||
"relation": "user",
|
||||
"scope": {
|
||||
"fields": ["nickname"]
|
||||
"fields": [
|
||||
"nickname"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="clientObservations"
|
||||
filter="$ctrl.filter"
|
||||
link="{clientFk: $ctrl.$params.id}"
|
||||
data="notes"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-w-md">
|
||||
<vn-card class="vn-pa-md">
|
||||
<div
|
||||
ng-repeat="note in notes"
|
||||
class="note vn-pa-sm border-solid border-radius vn-mb-md">
|
||||
<vn-horizontal class="vn-mb-sm" style="color: #666">
|
||||
<vn-one>{{::note.worker.user.nickname}}</vn-one>
|
||||
<vn-auto>{{::note.created | date:'dd/MM/yyyy HH:mm'}}</vn-auto>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="text">
|
||||
{{::note.text}}
|
||||
</vn-horizontal>
|
||||
</div>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<a vn-tooltip="New note"
|
||||
ui-sref="client.card.note.create({id: $ctrl.$params.id})"
|
||||
vn-bind="+"
|
||||
fixed-bottom-right>
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
|
@ -5,9 +5,10 @@ import './style.scss';
|
|||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.filter = {
|
||||
order: 'created DESC',
|
||||
};
|
||||
}
|
||||
async $onInit() {
|
||||
this.$state.go('home');
|
||||
window.location.href = await this.vnApp.getUrl(`customer/${this.$params.id}/notes`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,10 +106,15 @@ module.exports = Self => {
|
|||
description: `The to shipped date filter`
|
||||
},
|
||||
{
|
||||
arg: 'days',
|
||||
arg: 'daysOnward',
|
||||
type: 'number',
|
||||
description: `N days interval`
|
||||
},
|
||||
{
|
||||
arg: 'daysAgo',
|
||||
type: 'number',
|
||||
description: `N days ago interval`
|
||||
},
|
||||
{
|
||||
arg: 'invoiceAmount',
|
||||
type: 'number',
|
||||
|
@ -216,16 +221,29 @@ module.exports = Self => {
|
|||
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
||||
);
|
||||
|
||||
if (ctx.args.days) {
|
||||
stmt.merge({
|
||||
sql: `
|
||||
AND t.shipped <= util.VN_CURDATE() + INTERVAL ? DAY
|
||||
AND t.shipped >= util.VN_CURDATE()
|
||||
`,
|
||||
params: [ctx.args.days]
|
||||
});
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
|
||||
const {daysAgo, daysOnward} = ctx.args;
|
||||
if (daysOnward || daysAgo) {
|
||||
const params = [];
|
||||
let today = 'util.VN_CURDATE()';
|
||||
let from = today;
|
||||
let to = today;
|
||||
|
||||
if (daysAgo) {
|
||||
from += ' - INTERVAL ? DAY';
|
||||
params.push(daysAgo);
|
||||
}
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
if (daysOnward) {
|
||||
to += ' + INTERVAL ? DAY';
|
||||
params.push(daysOnward);
|
||||
}
|
||||
|
||||
const whereDays = (filter.where ? 'AND' : 'WHERE') + ` t.shipped BETWEEN ${from} AND ${to}`;
|
||||
stmt.merge({sql: whereDays, params});
|
||||
}
|
||||
|
||||
stmt.merge(conn.makePagination(filter));
|
||||
const itemsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
|
|
|
@ -39,7 +39,7 @@ describe('Entry filter()', () => {
|
|||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(11);
|
||||
expect(result.length).toEqual(12);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -49,13 +49,13 @@ describe('Entry filter()', () => {
|
|||
});
|
||||
|
||||
describe('should return the entry matching the supplier', () => {
|
||||
it('when userId is supplier ', async() => {
|
||||
it('when userId is supplier and searching days onward', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {days: 6},
|
||||
args: {daysOnward: 6},
|
||||
req: {accessToken: {userId: 1102}}
|
||||
};
|
||||
|
||||
|
@ -70,6 +70,27 @@ describe('Entry filter()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('when userId is supplier and searching days ago', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {daysAgo: 31},
|
||||
req: {accessToken: {userId: 1102}}
|
||||
};
|
||||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(6);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('when userId is supplier fetching other supplier', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
@ -131,7 +152,7 @@ describe('Entry filter()', () => {
|
|||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(10);
|
||||
expect(result.length).toEqual(11);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -45,8 +45,8 @@ module.exports = Self => {
|
|||
i.id itemFk,
|
||||
i.name itemName,
|
||||
ti.quantity,
|
||||
(ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id))
|
||||
/ (vc.trolleyM3 * 1000000) volume,
|
||||
ROUND((ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id))
|
||||
/ (vc.trolleyM3 * 1000000),1) volume,
|
||||
b.packagingFk packagingFk,
|
||||
b.packing
|
||||
FROM tmp.item ti
|
||||
|
|
|
@ -10,6 +10,11 @@ module.exports = Self => {
|
|||
type: 'any',
|
||||
description: 'The invoiceable client id'
|
||||
},
|
||||
{
|
||||
arg: 'addressFk',
|
||||
type: 'any',
|
||||
description: 'The address id'
|
||||
},
|
||||
{
|
||||
arg: 'ticketFk',
|
||||
type: 'any',
|
||||
|
@ -23,7 +28,8 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'serial',
|
||||
type: 'string',
|
||||
description: 'The invoice serial'
|
||||
description: 'The invoice serial',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'taxArea',
|
||||
|
@ -46,7 +52,8 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.createManualInvoice = async(ctx, clientFk, ticketFk, maxShipped, serial, taxArea, reference, options) => {
|
||||
Self.createManualInvoice =
|
||||
async(ctx, clientFk, addressFk, ticketFk, maxShipped, serial, taxArea, reference, options) => {
|
||||
if (!clientFk && !ticketFk) throw new UserError(`Select ticket or client`);
|
||||
const models = Self.app.models;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
@ -60,34 +67,43 @@ module.exports = Self => {
|
|||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
let companyId;
|
||||
let companyFk;
|
||||
let newInvoice;
|
||||
let query;
|
||||
try {
|
||||
if (ticketFk) {
|
||||
const ticket = await models.Ticket.findById(ticketFk, null, myOptions);
|
||||
const company = await models.Company.findById(ticket.companyFk, null, myOptions);
|
||||
const ticket = await models.Ticket.findById(ticketFk, {
|
||||
fields: ['clientFk', 'companyFk', 'shipped', 'refFk', 'totalWithVat']
|
||||
}, myOptions);
|
||||
const company = await models.Company.findById(ticket.companyFk, {
|
||||
fields: ['code']
|
||||
}, myOptions);
|
||||
|
||||
clientFk = ticket.clientFk;
|
||||
maxShipped = ticket.shipped;
|
||||
companyId = ticket.companyFk;
|
||||
companyFk = ticket.companyFk;
|
||||
|
||||
// Validates invoiced ticket
|
||||
if (ticket.refFk)
|
||||
throw new UserError('This ticket is already invoiced');
|
||||
|
||||
// Validates ticket amount
|
||||
if (ticket.totalWithVat == 0)
|
||||
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
||||
|
||||
// Validates ticket nagative base
|
||||
const hasNegativeBase = await getNegativeBase(maxShipped, clientFk, companyId, myOptions);
|
||||
const hasNegativeBase = await getNegativeBase(maxShipped, clientFk, companyFk, myOptions);
|
||||
if (hasNegativeBase && company.code == 'VNL')
|
||||
throw new UserError(`A ticket with a negative base can't be invoiced`);
|
||||
} else {
|
||||
if (!maxShipped)
|
||||
throw new UserError(`Max shipped required`);
|
||||
|
||||
if (addressFk) {
|
||||
const address = await models.Address.findById(addressFk, {
|
||||
fields: ['clientFk']
|
||||
}, myOptions);
|
||||
|
||||
if (clientFk && clientFk !== address.clientFk)
|
||||
throw new UserError('The provided clientFk does not match');
|
||||
}
|
||||
const company = await models.Ticket.findOne({
|
||||
fields: ['companyFk'],
|
||||
where: {
|
||||
|
@ -95,22 +111,20 @@ module.exports = Self => {
|
|||
shipped: {lte: maxShipped}
|
||||
}
|
||||
}, myOptions);
|
||||
companyId = company.companyFk;
|
||||
companyFk = company.companyFk;
|
||||
}
|
||||
|
||||
// Validate invoiceable client
|
||||
const isClientInvoiceable = await isInvoiceable(clientFk, myOptions);
|
||||
if (!isClientInvoiceable)
|
||||
throw new UserError(`This client is not invoiceable`);
|
||||
|
||||
// Can't invoice tickets into future
|
||||
const tomorrow = Date.vnNew();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
|
||||
if (maxShipped >= tomorrow)
|
||||
throw new UserError(`Can't invoice to future`);
|
||||
|
||||
const maxInvoiceDate = await getMaxIssued(serial, companyId, myOptions);
|
||||
const maxInvoiceDate = await getMaxIssued(serial, companyFk, myOptions);
|
||||
if (Date.vnNew() < maxInvoiceDate)
|
||||
throw new UserError(`Can't invoice to past`);
|
||||
|
||||
|
@ -122,13 +136,23 @@ module.exports = Self => {
|
|||
taxArea,
|
||||
reference
|
||||
], myOptions);
|
||||
} else if (addressFk) {
|
||||
query = `CALL invoiceOut_newFromAddress(?, ?, ?, ?, ?, ?, @newInvoiceId)`;
|
||||
await Self.rawSql(query, [
|
||||
addressFk,
|
||||
serial,
|
||||
maxShipped,
|
||||
companyFk,
|
||||
taxArea,
|
||||
reference
|
||||
], myOptions);
|
||||
} else {
|
||||
query = `CALL invoiceOut_newFromClient(?, ?, ?, ?, ?, ?, @newInvoiceId)`;
|
||||
await Self.rawSql(query, [
|
||||
clientFk,
|
||||
serial,
|
||||
maxShipped,
|
||||
companyId,
|
||||
companyFk,
|
||||
taxArea,
|
||||
reference
|
||||
], myOptions);
|
||||
|
@ -159,10 +183,10 @@ module.exports = Self => {
|
|||
return result.invoiceable;
|
||||
}
|
||||
|
||||
async function getNegativeBase(maxShipped, clientFk, companyId, options) {
|
||||
async function getNegativeBase(maxShipped, clientFk, companyFk, options) {
|
||||
const models = Self.app.models;
|
||||
await models.InvoiceOut.rawSql('CALL invoiceOut_exportationFromClient(?,?,?)',
|
||||
[maxShipped, clientFk, companyId], options
|
||||
[maxShipped, clientFk, companyFk], options
|
||||
);
|
||||
const query = 'SELECT vn.hasAnyNegativeBase() AS base';
|
||||
const [result] = await models.InvoiceOut.rawSql(query, [], options);
|
||||
|
@ -170,14 +194,14 @@ module.exports = Self => {
|
|||
return result.base;
|
||||
}
|
||||
|
||||
async function getMaxIssued(serial, companyId, options) {
|
||||
async function getMaxIssued(serial, companyFk, options) {
|
||||
const models = Self.app.models;
|
||||
const query = `SELECT MAX(issued) AS issued
|
||||
FROM invoiceOut
|
||||
WHERE serial = ? AND companyFk = ?`;
|
||||
const [maxIssued] = await models.InvoiceOut.rawSql(query,
|
||||
[serial, companyId], options);
|
||||
const maxInvoiceDate = maxIssued && maxIssued.issued || Date.vnNew();
|
||||
[serial, companyFk], options);
|
||||
const maxInvoiceDate = maxIssued?.issued || Date.vnNew();
|
||||
|
||||
return maxInvoiceDate;
|
||||
}
|
||||
|
|
|
@ -6,110 +6,90 @@ describe('InvoiceOut createManualInvoice()', () => {
|
|||
const clientId = 1106;
|
||||
const activeCtx = {accessToken: {userId: 1}};
|
||||
const ctx = {req: activeCtx};
|
||||
let tx; let options;
|
||||
|
||||
beforeEach(async() => {
|
||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(Promise.resolve(true));
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
|
||||
tx = await models.InvoiceOut.beginTransaction({});
|
||||
options = {transaction: tx};
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should throw an error trying to invoice again', async() => {
|
||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
let error;
|
||||
try {
|
||||
await createInvoice(ctx, options, undefined, ticketId);
|
||||
await createInvoice(ctx, options, undefined, ticketId);
|
||||
|
||||
await tx.rollback();
|
||||
await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||
await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain('This ticket is already invoiced');
|
||||
});
|
||||
|
||||
it('should throw an error for a ticket with an amount of zero', async() => {
|
||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
let error;
|
||||
try {
|
||||
const ticket = await models.Ticket.findById(ticketId, null, options);
|
||||
await ticket.updateAttributes({totalWithVat: 0}, options);
|
||||
|
||||
await createInvoice(ctx, options, undefined, ticketId);
|
||||
await tx.rollback();
|
||||
await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`A ticket with an amount of zero can't be invoiced`);
|
||||
});
|
||||
|
||||
it('should throw an error when the clientFk property is set without the max shipped date', async() => {
|
||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
let error;
|
||||
try {
|
||||
await createInvoice(ctx, options, clientId);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`Max shipped required`);
|
||||
});
|
||||
|
||||
it('should throw an error for a non-invoiceable client', async() => {
|
||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
let error;
|
||||
try {
|
||||
const client = await models.Client.findById(clientId, null, options);
|
||||
await client.updateAttributes({isTaxDataChecked: false}, options);
|
||||
|
||||
await createInvoice(ctx, options, undefined, ticketId);
|
||||
|
||||
await tx.rollback();
|
||||
await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`This client is not invoiceable`);
|
||||
});
|
||||
|
||||
it('should create a manual invoice', async() => {
|
||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const result = await createInvoice(ctx, options, undefined, ticketId);
|
||||
it('should create a manual invoice with ticket', async() => {
|
||||
const result = await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||
|
||||
expect(result.id).toEqual(jasmine.any(Number));
|
||||
});
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
it('should create a manual invoice with client', async() => {
|
||||
const result = await createInvoice(ctx, options, clientId, undefined, undefined, Date.vnNew());
|
||||
|
||||
expect(result.id).toEqual(jasmine.any(Number));
|
||||
});
|
||||
|
||||
it('should create a manual invoice with address', async() => {
|
||||
const addressFk = 126;
|
||||
const result = await createInvoice(ctx, options, clientId, addressFk, undefined, Date.vnNew());
|
||||
|
||||
expect(result.id).toEqual(jasmine.any(Number));
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -117,6 +97,7 @@ function createInvoice(
|
|||
ctx,
|
||||
options,
|
||||
clientFk = undefined,
|
||||
addressFk = undefined,
|
||||
ticketFk = undefined,
|
||||
maxShipped = undefined,
|
||||
serial = 'T',
|
||||
|
@ -124,6 +105,6 @@ function createInvoice(
|
|||
reference = undefined
|
||||
) {
|
||||
return models.InvoiceOut.createManualInvoice(
|
||||
ctx, clientFk, ticketFk, maxShipped, serial, taxArea, reference, options
|
||||
ctx, clientFk, addressFk, ticketFk, maxShipped, serial, taxArea, reference, options
|
||||
);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,11 @@ module.exports = Self => {
|
|||
try {
|
||||
const promises = [];
|
||||
for (let itemShelvingId of itemShelvingIds) {
|
||||
const itemShelvingSaleToDelete = models.ItemShelvingSale.destroyAll({
|
||||
itemShelvingFk: itemShelvingId
|
||||
}, myOptions);
|
||||
promises.push(itemShelvingSaleToDelete);
|
||||
|
||||
const itemShelvingToDelete = models.ItemShelving.destroyById(itemShelvingId, myOptions);
|
||||
promises.push(itemShelvingToDelete);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('ItemShelving deleteItemShelvings()', () => {
|
|||
const itemShelvingIds = [1, 2];
|
||||
const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
expect(result.length).toEqual(4);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
describe('item lastEntriesFilter()', () => {
|
||||
it('should return one entry for the given item', async() => {
|
||||
it('should return two entry for the given item', async() => {
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
const maxDate = Date.vnNew();
|
||||
|
@ -13,7 +13,7 @@ describe('item lastEntriesFilter()', () => {
|
|||
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
||||
const result = await models.Item.lastEntriesFilter(filter, options);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(result.length).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -22,7 +22,7 @@ describe('item lastEntriesFilter()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should return five entries for the given item', async() => {
|
||||
it('should return six entries for the given item', async() => {
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
minDate.setMonth(minDate.getMonth() - 2, 1);
|
||||
|
@ -37,7 +37,7 @@ describe('item lastEntriesFilter()', () => {
|
|||
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
||||
const result = await models.Item.lastEntriesFilter(filter, options);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
expect(result.length).toEqual(6);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
export * from './module';
|
||||
|
||||
import './main';
|
||||
import './index/';
|
||||
import './index/tickets';
|
||||
import './index/clients';
|
||||
import './index/orders';
|
||||
import './index/search-panel';
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="SalesMonitors/clientsFilter"
|
||||
limit="6"
|
||||
filter="$ctrl.filter"
|
||||
order="dated DESC, hour DESC"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-horizontal class="header">
|
||||
<vn-one translate>
|
||||
Clients on website
|
||||
</vn-one>
|
||||
<vn-none>
|
||||
<vn-icon class="arrow"
|
||||
icon="keyboard_arrow_up"
|
||||
vn-tooltip="Minimize/Maximize"
|
||||
ng-click="$ctrl.main.toggle()">
|
||||
</vn-icon>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-card vn-id="card">
|
||||
<smart-table
|
||||
model="model"
|
||||
options="$ctrl.smartTableOptions"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||
disabled-table-filter="true"
|
||||
disabled-table-order="true"
|
||||
class="scrollable sm">
|
||||
<slot-actions>
|
||||
<vn-horizontal>
|
||||
<vn-date-picker
|
||||
class="vn-pa-xs"
|
||||
label="From"
|
||||
ng-model="$ctrl.dateFrom"
|
||||
on-change="$ctrl.addFilterDate()">
|
||||
</vn-date-picker>
|
||||
<vn-date-picker
|
||||
class="vn-pa-xs"
|
||||
label="To"
|
||||
ng-model="$ctrl.dateTo"
|
||||
on-change="$ctrl.addFilterDate()">
|
||||
</vn-date-picker>
|
||||
</vn-horizontal>
|
||||
</slot-actions>
|
||||
<slot-table>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th field="dated">
|
||||
<span translate>Date</span>
|
||||
</th>
|
||||
<th field="hour">
|
||||
<span translate>Hour</span>
|
||||
</th>
|
||||
<th field="salesPersonFk" class="expendable">
|
||||
<span translate>Salesperson</span>
|
||||
</th>
|
||||
<th field="clientFk">
|
||||
<span translate>Client</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="visit in model.data track by visit.id">
|
||||
<td shrink-date>
|
||||
<span class="chip">
|
||||
{{::visit.dated | date:'dd/MM/yy'}}
|
||||
</span>
|
||||
</td>
|
||||
<td shrink-date>
|
||||
<span class="chip">
|
||||
{{::visit.hour | date: 'HH:mm'}}
|
||||
</span>
|
||||
</td>
|
||||
<td class="shrink expendable">
|
||||
<span
|
||||
title="{{::visit.salesPerson}}"
|
||||
vn-click-stop="workerDescriptor.show($event, visit.salesPersonFk)"
|
||||
class="link">
|
||||
{{::visit.salesPerson | dashIfEmpty}}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
title="{{::visit.clientName}}"
|
||||
vn-click-stop="clientDescriptor.show($event, visit.clientFk)"
|
||||
class="link">
|
||||
{{::visit.clientName}}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</slot-table>
|
||||
<slot-pagination>
|
||||
<vn-pagination
|
||||
model="model"
|
||||
class="vn-pt-xs"
|
||||
scroll-selector="vn-monitor-sales-clients smart-table"
|
||||
scroll-offset="100">
|
||||
</vn-pagination>
|
||||
</slot-pagination>
|
||||
</smart-table>
|
||||
</vn-card>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
|
@ -1,96 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
const date = Date.vnNew();
|
||||
this.dateFrom = date;
|
||||
this.dateTo = date;
|
||||
this.filter = {
|
||||
where: {
|
||||
'v.stamp': {
|
||||
between: this.dateRange()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.smartTableOptions = {
|
||||
activeButtons: {
|
||||
search: true
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'clientFk',
|
||||
autocomplete: {
|
||||
url: 'Clients',
|
||||
showField: 'name',
|
||||
valueField: 'id'
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'salesPersonFk',
|
||||
autocomplete: {
|
||||
url: 'Workers/activeWithInheritedRole',
|
||||
where: `{role: 'salesPerson'}`,
|
||||
searchFunction: '{firstName: $search}',
|
||||
showField: 'nickname',
|
||||
valueField: 'id',
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'dated',
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
field: 'hour',
|
||||
searchable: false
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'clientFk':
|
||||
return {[`c.id`]: value};
|
||||
case 'salesPersonFk':
|
||||
return {[`c.${param}`]: value};
|
||||
}
|
||||
}
|
||||
|
||||
dateRange() {
|
||||
let from = this.dateFrom;
|
||||
let to = this.dateTo;
|
||||
if (!from)
|
||||
from = Date.vnNew();
|
||||
if (!to)
|
||||
to = Date.vnNew();
|
||||
const minHour = new Date(from);
|
||||
minHour.setHours(0, 0, 0, 0);
|
||||
const maxHour = new Date(to);
|
||||
maxHour.setHours(23, 59, 59, 59);
|
||||
|
||||
return [minHour, maxHour];
|
||||
}
|
||||
|
||||
addFilterDate() {
|
||||
this.$.model.filter = {
|
||||
where: {
|
||||
'v.stamp': {
|
||||
between: this.dateRange()
|
||||
}
|
||||
}
|
||||
};
|
||||
this.$.model.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnMonitorSalesClients', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
require: {
|
||||
main: '^vnMonitorIndex'
|
||||
}
|
||||
});
|
|
@ -1,5 +0,0 @@
|
|||
<vn-horizontal ng-class="{'hidden': $ctrl.isTopPanelHidden}">
|
||||
<vn-monitor-sales-clients class="vn-mb-sm"></vn-monitor-sales-clients>
|
||||
<vn-monitor-sales-orders></vn-monitor-sales-orders>
|
||||
</vn-horizontal>
|
||||
<vn-monitor-sales-tickets></vn-monitor-sales-tickets>
|
|
@ -1,34 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden');
|
||||
if (isTopPanelHidden === 'true')
|
||||
this.isTopPanelHidden = true;
|
||||
}
|
||||
|
||||
toggle() {
|
||||
const monitor = this.element.querySelector('vn-horizontal');
|
||||
const isHidden = monitor.classList.contains('hidden');
|
||||
|
||||
if (!isHidden) {
|
||||
monitor.classList.add('hidden');
|
||||
localStorage.setItem('ticketTopPanelHidden', true);
|
||||
} else {
|
||||
monitor.classList.remove('hidden');
|
||||
localStorage.setItem('ticketTopPanelHidden', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnMonitorIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
require: {
|
||||
main: '^vnMonitorIndex'
|
||||
}
|
||||
});
|
|
@ -1,38 +0,0 @@
|
|||
import './index.js';
|
||||
describe('Component vnMonitorIndex', () => {
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(ngModule('monitor'));
|
||||
|
||||
beforeEach(inject(($compile, $rootScope) => {
|
||||
$element = $compile('<vn-monitor-index></vn-monitor-index>')($rootScope);
|
||||
controller = $element.controller('vnMonitorIndex');
|
||||
}));
|
||||
|
||||
describe('toggle()', () => {
|
||||
it('should add the hidden class to the horizontal contaning the panel to hide', () => {
|
||||
controller.toggle();
|
||||
|
||||
const targetElement = $element[0].querySelector('vn-horizontal');
|
||||
const firstClass = targetElement.classList[0];
|
||||
|
||||
const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden');
|
||||
|
||||
expect(firstClass).toEqual('hidden');
|
||||
expect(isTopPanelHidden).toEqual('true');
|
||||
});
|
||||
|
||||
it('should remove the hidden class to the horizontal contaning the panel to hide', () => {
|
||||
const targetElement = $element[0].querySelector('vn-horizontal');
|
||||
targetElement.classList.add('hidden');
|
||||
controller.toggle();
|
||||
const firstClass = targetElement.classList[0];
|
||||
|
||||
const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden');
|
||||
|
||||
expect(firstClass).toBeUndefined();
|
||||
expect(isTopPanelHidden).toEqual('false');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,16 +0,0 @@
|
|||
Tickets monitor: Monitor de tickets
|
||||
Clients on website: Clientes activos en la web
|
||||
Recent order actions: Acciones recientes en pedidos
|
||||
Search tickets: Buscar tickets
|
||||
Delete selected elements: Eliminar los elementos seleccionados
|
||||
All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar?
|
||||
Component lack: Faltan componentes
|
||||
Ticket too little: Ticket demasiado pequeño
|
||||
Minimize/Maximize: Minimizar/Maximizar
|
||||
Problems: Problemas
|
||||
Theoretical: Teórica
|
||||
Practical: Práctica
|
||||
Preparation: Preparación
|
||||
Auto-refresh: Auto-refresco
|
||||
Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos
|
||||
Is fragile: Es frágil
|
|
@ -1,141 +0,0 @@
|
|||
<vn-crud-model auto-load="true"
|
||||
vn-id="model"
|
||||
url="SalesMonitors/ordersFilter"
|
||||
limit="6"
|
||||
order="date_make DESC">
|
||||
</vn-crud-model>
|
||||
<vn-horizontal class="header">
|
||||
<vn-one translate>
|
||||
Recent order actions
|
||||
</vn-one>
|
||||
<vn-none>
|
||||
<vn-icon
|
||||
icon="delete"
|
||||
vn-tooltip="Delete"
|
||||
ng-if="$ctrl.totalChecked > 0"
|
||||
ng-click="delete.show()">
|
||||
</vn-icon>
|
||||
<vn-icon class="arrow"
|
||||
icon="keyboard_arrow_up"
|
||||
vn-tooltip="Minimize/Maximize"
|
||||
ng-click="$ctrl.main.toggle()">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
icon="refresh"
|
||||
vn-tooltip="Refresh"
|
||||
ng-click="model.refresh()">
|
||||
</vn-icon>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-card>
|
||||
<vn-table model="model" class="scrollable">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th shrink>
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</vn-th>
|
||||
<vn-th field="date_send" shrink-datetime>Date</vn-th>
|
||||
<vn-th field="clientFk">Client</vn-th>
|
||||
<vn-th field="salesPersonFk" shrink>SalesPerson</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<a ng-repeat="order in model.data track by order.id"
|
||||
class="clickable vn-tbody"
|
||||
ui-sref="order.card.summary({id: {{::order.id}}})" target="_blank">
|
||||
<vn-tr>
|
||||
<vn-td>
|
||||
<vn-check
|
||||
ng-model="order.checked"
|
||||
vn-click-stop>
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
<span class="chip {{::$ctrl.chipColor(order.date_send)}}">
|
||||
{{::order.date_send | date: 'dd/MM/yyyy'}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
<span
|
||||
title="{{::order.clientName}}"
|
||||
vn-click-stop="clientDescriptor.show($event, order.clientFk)"
|
||||
class="link">
|
||||
{{::order.clientName}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
<span
|
||||
title="{{::order.salesPerson}}"
|
||||
vn-click-stop="workerDescriptor.show($event, order.salesPersonFk)"
|
||||
class="link">
|
||||
{{::order.salesPerson | dashIfEmpty}}
|
||||
</span>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
<vn-tr>
|
||||
<vn-td></vn-td>
|
||||
<vn-td>
|
||||
<span>
|
||||
{{::order.date_make | date: 'dd/MM/yyyy HH:mm'}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
<span title="{{::order.agencyName}}">
|
||||
{{::order.agencyName | dashIfEmpty}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
{{::order.import | currency: 'EUR':2}}
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</a>
|
||||
</vn-table>
|
||||
<vn-pagination
|
||||
model="model"
|
||||
class="vn-pt-xs"
|
||||
scroll-selector="vn-monitor-sales-orders vn-table"
|
||||
scroll-offset="100">
|
||||
</vn-pagination>
|
||||
</vn-card>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
||||
<vn-contextmenu vn-id="contextmenu" targets="['vn-monitor-sales-orders vn-table']" model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-menu>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.filterBySelection()">
|
||||
Filter by selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.excludeSelection()">
|
||||
Exclude selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.removeFilter()">
|
||||
Remove filter
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="contextmenu.removeAllFilters()">
|
||||
Remove all filters
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isActionAllowed()"
|
||||
ng-click="contextmenu.copyValue()">
|
||||
Copy value
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
</vn-contextmenu>
|
||||
<vn-confirm
|
||||
vn-id="delete"
|
||||
on-accept="$ctrl.onDelete()"
|
||||
question="All the selected elements will be deleted. Are you sure you want to continue?"
|
||||
message="Delete selected elements">
|
||||
</vn-confirm>
|
|
@ -1,74 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
export default class Controller extends Section {
|
||||
get checked() {
|
||||
const rows = this.$.model.data || [];
|
||||
const checkedRows = [];
|
||||
for (let row of rows) {
|
||||
if (row.checked)
|
||||
checkedRows.push(row.id);
|
||||
}
|
||||
|
||||
return checkedRows;
|
||||
}
|
||||
|
||||
get totalChecked() {
|
||||
return this.checked.length;
|
||||
}
|
||||
|
||||
onDelete() {
|
||||
const params = {deletes: this.checked};
|
||||
const query = `SalesMonitors/deleteOrders`;
|
||||
this.$http.post(query, params).then(
|
||||
() => this.$.model.refresh());
|
||||
}
|
||||
|
||||
chipColor(date) {
|
||||
const today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
const orderLanded = new Date(date);
|
||||
orderLanded.setHours(0, 0, 0, 0);
|
||||
|
||||
const difference = today - orderLanded;
|
||||
|
||||
if (difference == 0)
|
||||
return 'warning';
|
||||
if (difference < 0)
|
||||
return 'success';
|
||||
if (difference > 0)
|
||||
return 'alert';
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'date_send':
|
||||
return {[`o.date_send`]: {
|
||||
between: this.dateRange(value)}
|
||||
};
|
||||
case 'clientFk':
|
||||
return {[`c.id`]: value};
|
||||
case 'salesPersonFk':
|
||||
return {[`c.${param}`]: value};
|
||||
}
|
||||
}
|
||||
|
||||
dateRange(value) {
|
||||
const minHour = new Date(value);
|
||||
minHour.setHours(0, 0, 0, 0);
|
||||
const maxHour = new Date(value);
|
||||
maxHour.setHours(23, 59, 59, 59);
|
||||
|
||||
return [minHour, maxHour];
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnMonitorSalesOrders', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
require: {
|
||||
main: '^vnMonitorIndex'
|
||||
}
|
||||
});
|
|
@ -1,50 +0,0 @@
|
|||
import './index.js';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('Component vnMonitorSalesOrders', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(ngModule('monitor'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
const $element = angular.element('<vn-monitor-sales-orders></vn-monitor-sales-orders>');
|
||||
controller = $componentController('vnMonitorSalesOrders', {$element});
|
||||
controller.$.model = crudModel;
|
||||
controller.$.model.data = [
|
||||
{id: 1, name: 'My item 1'},
|
||||
{id: 2, name: 'My item 2'},
|
||||
{id: 3, name: 'My item 3'}
|
||||
];
|
||||
}));
|
||||
|
||||
describe('checked() getter', () => {
|
||||
it('should return a the selected rows', () => {
|
||||
const modelData = controller.$.model.data;
|
||||
modelData[0].checked = true;
|
||||
modelData[1].checked = true;
|
||||
|
||||
const result = controller.checked;
|
||||
|
||||
expect(result).toEqual(expect.arrayContaining([1, 2]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('onDelete()', () => {
|
||||
it('should make a query and then call to the model refresh() method', () => {
|
||||
jest.spyOn(controller.$.model, 'refresh');
|
||||
|
||||
const modelData = controller.$.model.data;
|
||||
modelData[0].checked = true;
|
||||
modelData[1].checked = true;
|
||||
|
||||
const expectedParams = {deletes: [1, 2]};
|
||||
$httpBackend.expect('POST', 'SalesMonitors/deleteOrders', expectedParams).respond(200);
|
||||
controller.onDelete();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
@import "variables";
|
||||
|
||||
vn-monitor-sales-orders {
|
||||
vn-table.scrollable {
|
||||
max-height: 350px;
|
||||
overflow-x: hidden
|
||||
}
|
||||
|
||||
vn-table a.vn-tbody {
|
||||
& > vn-tr:nth-child(2) {
|
||||
color: gray;
|
||||
|
||||
& > vn-td {
|
||||
border-bottom: $border;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<div class="search-panel">
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Warehouses"
|
||||
data="warehouses">
|
||||
</vn-crud-model>
|
||||
<form id="manifold-form" ng-submit="$ctrl.onSearch()">
|
||||
<vn-horizontal class="vn-px-lg vn-pt-lg">
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="General search"
|
||||
ng-model="filter.search"
|
||||
info="Search ticket by id or alias"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Client id"
|
||||
ng-model="filter.clientFk">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Order id"
|
||||
ng-model="filter.orderFk">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-input-number
|
||||
vn-one
|
||||
min="0"
|
||||
step="1"
|
||||
label="Days onward"
|
||||
ng-model="filter.scopeDays"
|
||||
on-change="$ctrl.scopeDays = value"
|
||||
display-controls="true">
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Nickname"
|
||||
ng-model="filter.nickname">
|
||||
</vn-textfield>
|
||||
<vn-worker-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.salesPersonFk"
|
||||
departments="['VT']"
|
||||
label="Sales person">
|
||||
</vn-worker-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Invoice"
|
||||
ng-model="filter.refFk">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Agency"
|
||||
ng-model="filter.agencyModeFk"
|
||||
url="AgencyModes/isActive">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="State"
|
||||
ng-model="filter.stateFk"
|
||||
url="States">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
data="$ctrl.groupedStates"
|
||||
label="Grouped States"
|
||||
value-field="id"
|
||||
show-field="name"
|
||||
ng-model="filter.alertLevel">
|
||||
<tpl-item>
|
||||
{{name}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Warehouse"
|
||||
ng-model="filter.warehouseFk"
|
||||
data="warehouses">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Province"
|
||||
ng-model="filter.provinceFk"
|
||||
url="Provinces">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-check
|
||||
vn-one
|
||||
label="My team"
|
||||
ng-model="filter.myTeam"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="With problems"
|
||||
ng-model="filter.problems"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Pending"
|
||||
ng-model="filter.pending"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg vn-pb-lg vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
</vn-horizontal>
|
||||
</form>
|
||||
</div>
|
|
@ -1,59 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import SearchPanel from 'core/components/searchbar/search-panel';
|
||||
|
||||
class Controller extends SearchPanel {
|
||||
constructor($, $element) {
|
||||
super($, $element);
|
||||
this.filter = this.$.filter;
|
||||
|
||||
this.getGroupedStates();
|
||||
}
|
||||
|
||||
getGroupedStates() {
|
||||
let groupedStates = [];
|
||||
this.$http.get('AlertLevels').then(res => {
|
||||
for (let state of res.data) {
|
||||
groupedStates.push({
|
||||
id: state.id,
|
||||
code: state.code,
|
||||
name: this.$t(state.code)
|
||||
});
|
||||
}
|
||||
this.groupedStates = groupedStates;
|
||||
});
|
||||
}
|
||||
|
||||
get from() {
|
||||
return this._from;
|
||||
}
|
||||
|
||||
set from(value) {
|
||||
this._from = value;
|
||||
this.filter.scopeDays = null;
|
||||
}
|
||||
|
||||
get to() {
|
||||
return this._to;
|
||||
}
|
||||
|
||||
set to(value) {
|
||||
this._to = value;
|
||||
this.filter.scopeDays = null;
|
||||
}
|
||||
|
||||
get scopeDays() {
|
||||
return this._scopeDays;
|
||||
}
|
||||
|
||||
set scopeDays(value) {
|
||||
this._scopeDays = value;
|
||||
|
||||
this.filter.from = null;
|
||||
this.filter.to = null;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnMonitorSalesSearchPanel', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -1,71 +0,0 @@
|
|||
import './index';
|
||||
|
||||
describe('Monitor Component vnMonitorSalesSearchPanel', () => {
|
||||
let $httpBackend;
|
||||
let controller;
|
||||
|
||||
beforeEach(ngModule('monitor'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
controller = $componentController('vnMonitorSalesSearchPanel', {$element: null});
|
||||
controller.$t = () => {};
|
||||
controller.filter = {};
|
||||
}));
|
||||
|
||||
describe('getGroupedStates()', () => {
|
||||
it('should set an array of groupedStates with the adition of a name translation', () => {
|
||||
jest.spyOn(controller, '$t').mockReturnValue('miCodigo');
|
||||
const data = [
|
||||
{
|
||||
id: 9999,
|
||||
code: 'myCode'
|
||||
}
|
||||
];
|
||||
$httpBackend.whenGET('AlertLevels').respond(data);
|
||||
controller.getGroupedStates();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.groupedStates).toEqual([{
|
||||
id: 9999,
|
||||
code: 'myCode',
|
||||
name: 'miCodigo'
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('from() setter', () => {
|
||||
it('should clear the scope days when setting the from property', () => {
|
||||
controller.filter.scopeDays = 1;
|
||||
|
||||
controller.from = Date.vnNew();
|
||||
|
||||
expect(controller.filter.scopeDays).toBeNull();
|
||||
expect(controller.from).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('to() setter', () => {
|
||||
it('should clear the scope days when setting the to property', () => {
|
||||
controller.filter.scopeDays = 1;
|
||||
|
||||
controller.to = Date.vnNew();
|
||||
|
||||
expect(controller.filter.scopeDays).toBeNull();
|
||||
expect(controller.to).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('scopeDays() setter', () => {
|
||||
it('should clear the date range when setting the scopeDays property', () => {
|
||||
controller.filter.from = Date.vnNew();
|
||||
controller.filter.to = Date.vnNew();
|
||||
|
||||
controller.scopeDays = 1;
|
||||
|
||||
expect(controller.filter.from).toBeNull();
|
||||
expect(controller.filter.to).toBeNull();
|
||||
expect(controller.scopeDays).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,85 +0,0 @@
|
|||
@import "variables";
|
||||
@import "effects";
|
||||
|
||||
vn-monitor-index {
|
||||
.header {
|
||||
padding: 12px 0 5px 0;
|
||||
color: gray;
|
||||
font-size: 1.2rem;
|
||||
border-bottom: $border;
|
||||
margin-bottom: 10px;
|
||||
|
||||
& > vn-none > vn-icon {
|
||||
@extend %clickable-light;
|
||||
color: $color-button;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
vn-none > .arrow {
|
||||
transition: transform 200ms;
|
||||
}
|
||||
}
|
||||
|
||||
vn-monitor-sales-clients {
|
||||
vn-card {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding-right: 15px;
|
||||
|
||||
& > vn-none > .arrow {
|
||||
display: none
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vn-table.scrollable {
|
||||
height: 300px
|
||||
}
|
||||
|
||||
vn-horizontal {
|
||||
flex-wrap: wrap
|
||||
}
|
||||
|
||||
.hidden {
|
||||
vn-card {
|
||||
display: none
|
||||
}
|
||||
|
||||
.header > vn-none > .arrow {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width:1150px) {
|
||||
vn-monitor-index {
|
||||
& > vn-horizontal {
|
||||
flex-direction: column;
|
||||
|
||||
vn-monitor-sales-clients,
|
||||
vn-monitor-sales-orders {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
vn-monitor-sales-clients {
|
||||
margin-bottom: 15px
|
||||
}
|
||||
}
|
||||
|
||||
vn-monitor-sales-clients {
|
||||
vn-card {
|
||||
margin-right: 0
|
||||
}
|
||||
|
||||
.header {
|
||||
padding-right: 0;
|
||||
|
||||
& > vn-none > .arrow {
|
||||
display: inline-block
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,270 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="SalesMonitors/salesFilter"
|
||||
auto-load="false"
|
||||
limit="20">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
vn-focus
|
||||
panel="vn-monitor-sales-search-panel"
|
||||
placeholder="Search tickets"
|
||||
info="Search ticket by id or alias"
|
||||
model="model"
|
||||
fetch-params="$ctrl.fetchParams($params)"
|
||||
suggested-filter="$ctrl.filterParams"
|
||||
auto-state="false">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-horizontal class="header">
|
||||
<vn-one translate>
|
||||
Tickets monitor
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-card>
|
||||
<smart-table
|
||||
model="model"
|
||||
view-config-id="ticketsMonitor"
|
||||
options="$ctrl.smartTableOptions"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-actions>
|
||||
<vn-check
|
||||
label="Auto-refresh"
|
||||
vn-tooltip="Toggle auto-refresh every 2 minutes"
|
||||
on-change="$ctrl.autoRefresh(value)">
|
||||
</vn-check>
|
||||
</slot-actions>
|
||||
<slot-table>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th field="totalProblems" menu-enabled="false">
|
||||
<span translate>Problems</span>
|
||||
</th>
|
||||
<th field="id">
|
||||
<span translate>Identifier</span>
|
||||
</th>
|
||||
<th field="nickname">
|
||||
<span translate>Client</span>
|
||||
</th>
|
||||
<th field="salesPersonFk">
|
||||
<span translate>Salesperson</span>
|
||||
</th>
|
||||
<th field="shippedDate" shrink-date filter-enabled="false">
|
||||
<span translate>Date</span>
|
||||
</th>
|
||||
<th field="theoreticalHour" filter-enabled="false">
|
||||
<span translate>Theoretical</span>
|
||||
</th>
|
||||
<th field="practicalHour" filter-enabled="false">
|
||||
<span translate>Practical</span>
|
||||
</th>
|
||||
<th field="preparationHour" filter-enabled="false">
|
||||
<span translate>Preparation</span>
|
||||
</th>
|
||||
<th field="provinceFk">
|
||||
<span translate>Province</span>
|
||||
</th>
|
||||
<th field="stateFk">
|
||||
<span translate>State</span>
|
||||
</th>
|
||||
<th field="isFragile" number>
|
||||
<span translate>Fragile</span>
|
||||
</th>
|
||||
<th field="zoneFk">
|
||||
<span translate>Zone</span>
|
||||
</th>
|
||||
<th field="totalWithVat" shrink>
|
||||
<span translate>Total</span>
|
||||
</th>
|
||||
<th shrink></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="ticket in model.data track by ticket.id"
|
||||
vn-anchor="{
|
||||
state: 'ticket.card.summary',
|
||||
params: {id: ticket.id},
|
||||
target: '_blank'
|
||||
}">
|
||||
<td>
|
||||
<vn-icon
|
||||
ng-show="ticket.isTaxDataChecked === 0"
|
||||
translate-attr="{title: 'No verified data'}"
|
||||
class="bright"
|
||||
icon="icon-no036">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
ng-show="ticket.hasTicketRequest"
|
||||
translate-attr="{title: 'Purchase request'}"
|
||||
class="bright"
|
||||
icon="icon-buyrequest">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
ng-show="ticket.itemShortage"
|
||||
translate-attr="{title: 'Not visible'}"
|
||||
class="bright"
|
||||
icon="icon-unavailable">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
ng-show="ticket.isFreezed"
|
||||
translate-attr="{title: 'Client frozen'}"
|
||||
class="bright"
|
||||
icon="icon-frozen">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
ng-show="ticket.risk"
|
||||
ng-class="{'highRisk': ticket.hasHighRisk}"
|
||||
title="{{$ctrl.$t('Risk')}}: {{ticket.risk}}"
|
||||
class="bright"
|
||||
icon="icon-risk">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
ng-show="ticket.hasComponentLack"
|
||||
translate-attr="{title: 'Component lack'}"
|
||||
class="bright"
|
||||
icon="icon-components">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
ng-show="ticket.isTooLittle"
|
||||
translate-attr="{title: 'Ticket too little'}"
|
||||
class="bright"
|
||||
icon="icon-isTooLittle">
|
||||
</vn-icon>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
vn-click-stop="ticketDescriptor.show($event, ticket.id)"
|
||||
class="link">
|
||||
{{ticket.id}}
|
||||
</span>
|
||||
</td>
|
||||
<td name="nickname">
|
||||
<span
|
||||
title="{{ticket.nickname}}"
|
||||
vn-click-stop="clientDescriptor.show($event, ticket.clientFk)"
|
||||
class="link">
|
||||
{{ticket.nickname}}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
title="{{ticket.userName}}"
|
||||
vn-click-stop="workerDescriptor.show($event, ticket.salesPersonFk)"
|
||||
class="link">
|
||||
{{ticket.userName | dashIfEmpty}}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="chip {{$ctrl.compareDate(ticket.shippedDate)}}">
|
||||
{{ticket.shippedDate | date: 'dd/MM/yyyy'}}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ticket.zoneLanding | date: 'HH:mm'}}</td>
|
||||
<td>{{ticket.practicalHour | date: 'HH:mm'}}</td>
|
||||
<td>{{ticket.shipped | date: 'HH:mm'}}</td>
|
||||
<td>{{ticket.province}}</td>
|
||||
<td>
|
||||
<span
|
||||
ng-show="ticket.refFk"
|
||||
title="{{ticket.refFk}}"
|
||||
vn-click-stop="invoiceOutDescriptor.show($event, ticket.invoiceOutId)"
|
||||
class="link">
|
||||
{{ticket.refFk}}
|
||||
</span>
|
||||
<span
|
||||
ng-show="!ticket.refFk"
|
||||
class="chip {{ticket.classColor}}">
|
||||
{{ticket.state}}
|
||||
</span>
|
||||
</td>
|
||||
<td number>
|
||||
<vn-icon
|
||||
ng-show="ticket.isFragile"
|
||||
translate-attr="{title: 'Is fragile'}"
|
||||
class="bright"
|
||||
icon="local_bar">
|
||||
</vn-icon>
|
||||
</td>
|
||||
<td name="zone">
|
||||
<span
|
||||
title="{{ticket.zoneName}}"
|
||||
vn-click-stop="zoneDescriptor.show($event, ticket.zoneFk)"
|
||||
class="link">
|
||||
{{ticket.zoneName | dashIfEmpty}}
|
||||
</span>
|
||||
</td>
|
||||
<td number>
|
||||
<span class="chip {{$ctrl.totalPriceColor(ticket)}}">
|
||||
{{(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
|
||||
</span>
|
||||
</td>
|
||||
<td actions>
|
||||
<vn-icon-button
|
||||
vn-anchor="{
|
||||
state: 'ticket.card.sale',
|
||||
params: {id: ticket.id},
|
||||
target: '_blank'
|
||||
}"
|
||||
vn-tooltip="Go to lines"
|
||||
icon="icon-lines">
|
||||
</vn-icon-button>
|
||||
<vn-icon-button
|
||||
vn-click-stop="$ctrl.preview(ticket)"
|
||||
vn-tooltip="Preview"
|
||||
icon="preview">
|
||||
</vn-icon-button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</slot-table>
|
||||
</smart-table>
|
||||
</vn-card>
|
||||
<vn-ticket-descriptor-popover
|
||||
vn-id="ticketDescriptor">
|
||||
</vn-ticket-descriptor-popover>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
||||
<vn-zone-descriptor-popover
|
||||
vn-id="zoneDescriptor">
|
||||
</vn-zone-descriptor-popover>
|
||||
<vn-popup vn-id="summary">
|
||||
<vn-ticket-summary
|
||||
ticket="$ctrl.selectedTicket"
|
||||
model="model">
|
||||
</vn-ticket-summary>
|
||||
</vn-popup>
|
||||
<vn-contextmenu vn-id="contextmenu" targets="['vn-monitor-sales-tickets smart-table']" model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-menu>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.filterBySelection()">
|
||||
Filter by selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.excludeSelection()">
|
||||
Exclude selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.removeFilter()">
|
||||
Remove filter
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="contextmenu.removeAllFilters()">
|
||||
Remove all filters
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isActionAllowed()"
|
||||
ng-click="contextmenu.copyValue()">
|
||||
Copy value
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
</vn-contextmenu>
|
|
@ -1,178 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
this.filterParams = this.fetchParams();
|
||||
this.smartTableOptions = {
|
||||
activeButtons: {
|
||||
search: true,
|
||||
shownColumns: true,
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'totalProblems',
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
field: 'salesPersonFk',
|
||||
autocomplete: {
|
||||
url: 'Workers/activeWithInheritedRole',
|
||||
where: `{role: 'salesPerson'}`,
|
||||
searchFunction: '{firstName: $search}',
|
||||
showField: 'nickname',
|
||||
valueField: 'id',
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'provinceFk',
|
||||
autocomplete: {
|
||||
url: 'Provinces',
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'stateFk',
|
||||
autocomplete: {
|
||||
url: 'States',
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'zoneFk',
|
||||
autocomplete: {
|
||||
url: 'Zones',
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'warehouseFk',
|
||||
autocomplete: {
|
||||
url: 'Warehouses',
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'shippedDate',
|
||||
datepicker: true
|
||||
},
|
||||
{
|
||||
field: 'theoreticalHour',
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
field: 'preparationHour',
|
||||
searchable: false
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
if (!this.$params.q) {
|
||||
this.$.$applyAsync(
|
||||
() => this.$.model.applyFilter(null, this.filterParams));
|
||||
}
|
||||
}
|
||||
|
||||
fetchParams($params = {}) {
|
||||
const excludedParams = [
|
||||
'search',
|
||||
'clientFk',
|
||||
'orderFk',
|
||||
'refFk',
|
||||
'scopeDays'
|
||||
];
|
||||
|
||||
const hasExcludedParams = excludedParams.some(param => {
|
||||
return $params && $params[param] != undefined;
|
||||
});
|
||||
const hasParams = Object.entries($params).length;
|
||||
if (!hasParams || !hasExcludedParams)
|
||||
$params.scopeDays = 1;
|
||||
|
||||
if (typeof $params.scopeDays === 'number') {
|
||||
const from = Date.vnNew();
|
||||
from.setHours(0, 0, 0, 0);
|
||||
|
||||
const to = new Date(from.getTime());
|
||||
to.setDate(to.getDate() + $params.scopeDays);
|
||||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
Object.assign($params, {from, to});
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
compareDate(date) {
|
||||
let today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
let timeTicket = new Date(date);
|
||||
timeTicket.setHours(0, 0, 0, 0);
|
||||
|
||||
let comparation = today - timeTicket;
|
||||
|
||||
if (comparation == 0)
|
||||
return 'warning';
|
||||
if (comparation < 0)
|
||||
return 'success';
|
||||
}
|
||||
|
||||
totalPriceColor(ticket) {
|
||||
const total = parseInt(ticket.totalWithVat);
|
||||
if (total > 0 && total < 50)
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'stateFk':
|
||||
return {'ts.stateFk': value};
|
||||
case 'salesPersonFk':
|
||||
return {'c.salesPersonFk': value};
|
||||
case 'provinceFk':
|
||||
return {'a.provinceFk': value};
|
||||
case 'theoreticalHour':
|
||||
return {'z.hour': value};
|
||||
case 'practicalHour':
|
||||
return {'zed.etc': value};
|
||||
case 'shippedDate':
|
||||
return {'t.shipped': {
|
||||
between: this.dateRange(value)}
|
||||
};
|
||||
case 'nickname':
|
||||
return {[`t.nickname`]: {like: `%${value}%`}};
|
||||
case 'zoneFk':
|
||||
case 'totalWithVat':
|
||||
return {[`t.${param}`]: value};
|
||||
}
|
||||
}
|
||||
|
||||
dateRange(value) {
|
||||
const minHour = new Date(value);
|
||||
minHour.setHours(0, 0, 0, 0);
|
||||
const maxHour = new Date(value);
|
||||
maxHour.setHours(23, 59, 59, 59);
|
||||
|
||||
return [minHour, maxHour];
|
||||
}
|
||||
|
||||
preview(ticket) {
|
||||
this.selectedTicket = ticket;
|
||||
this.$.summary.show();
|
||||
}
|
||||
|
||||
autoRefresh(value) {
|
||||
if (value)
|
||||
this.refreshTimer = setInterval(() => this.$.model.refresh(), 120000);
|
||||
else {
|
||||
clearInterval(this.refreshTimer);
|
||||
this.refreshTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnMonitorSalesTickets', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue