Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4523-item_fixed-price_rate2
This commit is contained in:
commit
b4b7b8e204
|
@ -43,6 +43,9 @@ module.exports = Self => {
|
||||||
if (!recipient)
|
if (!recipient)
|
||||||
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
|
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV == 'test')
|
||||||
|
message = `[Test:Environment to user ${userId}] ` + message;
|
||||||
|
|
||||||
await models.Chat.create({
|
await models.Chat.create({
|
||||||
senderFk: sender.id,
|
senderFk: sender.id,
|
||||||
recipient: `@${recipient.name}`,
|
recipient: `@${recipient.name}`,
|
||||||
|
|
|
@ -12,14 +12,9 @@ BEGIN
|
||||||
* @param vAuthorFk The notification author or %NULL if there is no author
|
* @param vAuthorFk The notification author or %NULL if there is no author
|
||||||
* @return The notification id
|
* @return The notification id
|
||||||
*/
|
*/
|
||||||
DECLARE vNotificationFk INT;
|
|
||||||
|
|
||||||
SELECT id INTO vNotificationFk
|
|
||||||
FROM `notification`
|
|
||||||
WHERE `name` = vNotificationName;
|
|
||||||
|
|
||||||
INSERT INTO notificationQueue
|
INSERT INTO notificationQueue
|
||||||
SET notificationFk = vNotificationFk,
|
SET notificationFk = vNotificationName,
|
||||||
params = vParams,
|
params = vParams,
|
||||||
authorFk = vAuthorFk;
|
authorFk = vAuthorFk;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
DROP TRIGGER IF EXISTS `vn`.`supplier_beforeUpdate`;
|
||||||
|
USE `vn`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate`
|
||||||
|
BEFORE UPDATE ON `supplier`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
DECLARE vHasChange BOOL;
|
||||||
|
DECLARE vPayMethodChanged BOOL;
|
||||||
|
DECLARE vPayMethodHasVerified BOOL;
|
||||||
|
DECLARE vParams JSON;
|
||||||
|
DECLARE vOldPayMethodName VARCHAR(20);
|
||||||
|
DECLARE vNewPayMethodName VARCHAR(20);
|
||||||
|
|
||||||
|
SELECT hasVerified INTO vPayMethodHasVerified
|
||||||
|
FROM payMethod
|
||||||
|
WHERE id = NEW.payMethodFk;
|
||||||
|
|
||||||
|
SET vPayMethodChanged = NOT(NEW.payMethodFk <=> OLD.payMethodFk);
|
||||||
|
|
||||||
|
IF vPayMethodChanged THEN
|
||||||
|
SELECT name INTO vOldPayMethodName
|
||||||
|
FROM payMethod
|
||||||
|
WHERE id = OLD.payMethodFk;
|
||||||
|
SELECT name INTO vNewPayMethodName
|
||||||
|
FROM payMethod
|
||||||
|
WHERE id = NEW.payMethodFk;
|
||||||
|
|
||||||
|
SET vParams = JSON_OBJECT(
|
||||||
|
'name', NEW.name,
|
||||||
|
'oldPayMethod', vOldPayMethodName,
|
||||||
|
'newPayMethod', vNewPayMethodName
|
||||||
|
);
|
||||||
|
SELECT util.notification_send('supplier-pay-method-update', vParams, NULL) INTO @id;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SET vHasChange = NOT(NEW.payDemFk <=> OLD.payDemFk AND NEW.payDay <=> OLD.payDay) OR vPayMethodChanged;
|
||||||
|
|
||||||
|
IF vHasChange AND vPayMethodHasVerified THEN
|
||||||
|
SET NEW.isPayMethodChecked = FALSE;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,104 @@
|
||||||
|
DROP PROCEDURE IF EXISTS `vn`.`ticket_canAdvance`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
|
||||||
|
*
|
||||||
|
* @param vDateFuture Fecha de los tickets que se quieren adelantar.
|
||||||
|
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||||
|
* @param vWarehouseFk Almacén
|
||||||
|
*/
|
||||||
|
|
||||||
|
DECLARE vDateInventory DATE;
|
||||||
|
|
||||||
|
SELECT inventoried INTO vDateInventory FROM vn.config;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.stock;
|
||||||
|
CREATE TEMPORARY TABLE tmp.stock
|
||||||
|
(itemFk INT PRIMARY KEY,
|
||||||
|
amount INT)
|
||||||
|
ENGINE = MEMORY;
|
||||||
|
|
||||||
|
INSERT INTO tmp.stock(itemFk, amount)
|
||||||
|
SELECT itemFk, SUM(quantity) amount FROM
|
||||||
|
(
|
||||||
|
SELECT itemFk, quantity
|
||||||
|
FROM vn.itemTicketOut
|
||||||
|
WHERE shipped >= vDateInventory
|
||||||
|
AND shipped < vDateFuture
|
||||||
|
AND warehouseFk = vWarehouseFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT itemFk, quantity
|
||||||
|
FROM vn.itemEntryIn
|
||||||
|
WHERE landed >= vDateInventory
|
||||||
|
AND landed < vDateFuture
|
||||||
|
AND isVirtualStock = FALSE
|
||||||
|
AND warehouseInFk = vWarehouseFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT itemFk, quantity
|
||||||
|
FROM vn.itemEntryOut
|
||||||
|
WHERE shipped >= vDateInventory
|
||||||
|
AND shipped < vDateFuture
|
||||||
|
AND warehouseOutFk = vWarehouseFk
|
||||||
|
) t
|
||||||
|
GROUP BY itemFk HAVING amount != 0;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||||
|
CREATE TEMPORARY TABLE tmp.filter
|
||||||
|
(INDEX (id))
|
||||||
|
SELECT s.ticketFk futureId,
|
||||||
|
t2.ticketFk id,
|
||||||
|
sum((s.quantity <= IFNULL(st.amount,0))) hasStock,
|
||||||
|
count(DISTINCT s.id) saleCount,
|
||||||
|
t2.state,
|
||||||
|
t2.stateCode,
|
||||||
|
st.name futureState,
|
||||||
|
st.code futureStateCode,
|
||||||
|
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||||
|
t2.ipt,
|
||||||
|
t.workerFk,
|
||||||
|
CAST(sum(litros) AS DECIMAL(10,0)) liters,
|
||||||
|
CAST(count(*) AS DECIMAL(10,0)) `lines`,
|
||||||
|
t2.shipped,
|
||||||
|
t.shipped futureShipped,
|
||||||
|
t2.totalWithVat,
|
||||||
|
t.totalWithVat futureTotalWithVat
|
||||||
|
FROM vn.ticket t
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
|
JOIN vn.state st ON st.id = ts.stateFk
|
||||||
|
JOIN vn.saleVolume sv ON t.id = sv.ticketFk
|
||||||
|
JOIN (SELECT
|
||||||
|
t2.id ticketFk,
|
||||||
|
t2.addressFk,
|
||||||
|
st.name state,
|
||||||
|
st.code stateCode,
|
||||||
|
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt,
|
||||||
|
t2.shipped,
|
||||||
|
t2.totalWithVat
|
||||||
|
FROM vn.ticket t2
|
||||||
|
JOIN vn.sale s ON s.ticketFk = t2.id
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t2.id
|
||||||
|
JOIN vn.state st ON st.id = ts.stateFk
|
||||||
|
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||||
|
WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
|
||||||
|
AND t2.warehouseFk = vWarehouseFk
|
||||||
|
GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk
|
||||||
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||||
|
LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk
|
||||||
|
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||||
|
AND t.warehouseFk = vWarehouseFk
|
||||||
|
GROUP BY t.id;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.stock;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES
|
||||||
|
('Ticket', 'getTicketsAdvance', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,73 @@
|
||||||
|
DROP PROCEDURE IF EXISTS `vn`.`ticket_canbePostponed`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
|
||||||
|
*
|
||||||
|
* @param vOriginDated Fecha en cuestión
|
||||||
|
* @param vFutureDated Fecha en el futuro a sondear
|
||||||
|
* @param vWarehouseFk Identificador de vn.warehouse
|
||||||
|
*/
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||||
|
CREATE TEMPORARY TABLE tmp.filter
|
||||||
|
(INDEX (id))
|
||||||
|
SELECT sv.ticketFk id,
|
||||||
|
sub2.id futureId,
|
||||||
|
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
|
||||||
|
CAST(sum(litros) AS DECIMAL(10,0)) liters,
|
||||||
|
CAST(count(*) AS DECIMAL(10,0)) `lines`,
|
||||||
|
st.name state,
|
||||||
|
sub2.iptd futureIpt,
|
||||||
|
sub2.state futureState,
|
||||||
|
t.clientFk,
|
||||||
|
t.warehouseFk,
|
||||||
|
ts.alertLevel,
|
||||||
|
t.shipped,
|
||||||
|
sub2.shipped futureShipped,
|
||||||
|
t.workerFk,
|
||||||
|
st.code stateCode,
|
||||||
|
sub2.code futureStateCode
|
||||||
|
FROM vn.saleVolume sv
|
||||||
|
JOIN vn.sale s ON s.id = sv.saleFk
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
JOIN vn.ticket t ON t.id = sv.ticketFk
|
||||||
|
JOIN vn.address a ON a.id = t.addressFk
|
||||||
|
JOIN vn.province p ON p.id = a.provinceFk
|
||||||
|
JOIN vn.country c ON c.id = p.countryFk
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
|
JOIN vn.state st ON st.id = ts.stateFk
|
||||||
|
JOIN vn.alertLevel al ON al.id = ts.alertLevel
|
||||||
|
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT *
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
t.addressFk,
|
||||||
|
t.id,
|
||||||
|
t.shipped,
|
||||||
|
st.name state,
|
||||||
|
st.code code,
|
||||||
|
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
|
||||||
|
FROM vn.ticket t
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
|
JOIN vn.state st ON st.id = ts.stateFk
|
||||||
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
WHERE t.shipped BETWEEN vFutureDated
|
||||||
|
AND util.dayend(vFutureDated)
|
||||||
|
AND t.warehouseFk = vWarehouseFk
|
||||||
|
GROUP BY t.id
|
||||||
|
) sub
|
||||||
|
GROUP BY sub.addressFk
|
||||||
|
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
|
||||||
|
WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated)
|
||||||
|
AND t.warehouseFk = vWarehouseFk
|
||||||
|
AND al.code = 'FREE'
|
||||||
|
AND tp.ticketFk IS NULL
|
||||||
|
GROUP BY sv.ticketFk
|
||||||
|
HAVING futureId;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,2 @@
|
||||||
|
DROP PROCEDURE IF EXISTS `ticket_split`;
|
||||||
|
DROP PROCEDURE IF EXISTS `ticket_merge`;
|
|
@ -690,7 +690,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
|
||||||
(27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
|
(27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
|
||||||
(28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
|
(28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
|
||||||
(29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
|
(29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
|
||||||
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE());
|
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
|
||||||
|
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -991,7 +992,8 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
|
||||||
(33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()),
|
(33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()),
|
||||||
(34, 4, 28, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
(34, 4, 28, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||||
(35, 4, 29, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
(35, 4, 29, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||||
(36, 4, 30, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE());
|
(36, 4, 30, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||||
|
(37, 4, 31, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
|
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2689,7 +2691,8 @@ INSERT INTO `util`.`notificationConfig`
|
||||||
|
|
||||||
INSERT INTO `util`.`notification` (`id`, `name`, `description`)
|
INSERT INTO `util`.`notification` (`id`, `name`, `description`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'print-email', 'notification fixture one');
|
(1, 'print-email', 'notification fixture one'),
|
||||||
|
(3, 'supplier-pay-method-update', 'A supplier pay method has been updated');
|
||||||
|
|
||||||
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2746,3 +2749,4 @@ INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||||
INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
|
INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1);
|
(1, 1);
|
||||||
|
|
||||||
|
|
|
@ -735,18 +735,16 @@ export default {
|
||||||
},
|
},
|
||||||
ticketFuture: {
|
ticketFuture: {
|
||||||
openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]',
|
openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]',
|
||||||
originDated: 'vn-date-picker[label="Origin ETD"]',
|
originDated: 'vn-date-picker[label="Origin date"]',
|
||||||
futureDated: 'vn-date-picker[label="Destination ETD"]',
|
futureDated: 'vn-date-picker[label="Destination date"]',
|
||||||
shipped: 'vn-date-picker[label="Origin date"]',
|
|
||||||
tfShipped: 'vn-date-picker[label="Destination date"]',
|
|
||||||
linesMax: 'vn-textfield[label="Max Lines"]',
|
linesMax: 'vn-textfield[label="Max Lines"]',
|
||||||
litersMax: 'vn-textfield[label="Max Liters"]',
|
litersMax: 'vn-textfield[label="Max Liters"]',
|
||||||
ipt: 'vn-autocomplete[label="Origin IPT"]',
|
ipt: 'vn-autocomplete[label="Origin IPT"]',
|
||||||
tfIpt: 'vn-autocomplete[label="Destination IPT"]',
|
futureIpt: 'vn-autocomplete[label="Destination IPT"]',
|
||||||
tableIpt: 'vn-autocomplete[name="ipt"]',
|
tableIpt: 'vn-autocomplete[name="ipt"]',
|
||||||
tableTfIpt: 'vn-autocomplete[name="tfIpt"]',
|
tableFutureIpt: 'vn-autocomplete[name="futureIpt"]',
|
||||||
state: 'vn-autocomplete[label="Origin Grouped State"]',
|
state: 'vn-autocomplete[label="Origin Grouped State"]',
|
||||||
tfState: 'vn-autocomplete[label="Destination Grouped State"]',
|
futureState: 'vn-autocomplete[label="Destination Grouped State"]',
|
||||||
warehouseFk: 'vn-autocomplete[label="Warehouse"]',
|
warehouseFk: 'vn-autocomplete[label="Warehouse"]',
|
||||||
problems: 'vn-check[label="With problems"]',
|
problems: 'vn-check[label="With problems"]',
|
||||||
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
||||||
|
@ -755,9 +753,34 @@ export default {
|
||||||
firstCheck: 'tbody > tr:nth-child(1) > td > vn-check',
|
firstCheck: 'tbody > tr:nth-child(1) > td > vn-check',
|
||||||
multiCheck: 'vn-multi-check',
|
multiCheck: 'vn-multi-check',
|
||||||
tableId: 'vn-textfield[name="id"]',
|
tableId: 'vn-textfield[name="id"]',
|
||||||
tableTfId: 'vn-textfield[name="ticketFuture"]',
|
tableFutureId: 'vn-textfield[name="futureId"]',
|
||||||
tableLiters: 'vn-textfield[name="litersMax"]',
|
tableLiters: 'vn-textfield[name="liters"]',
|
||||||
tableLines: 'vn-textfield[name="linesMax"]',
|
tableLines: 'vn-textfield[name="lines"]',
|
||||||
|
submit: 'vn-submit[label="Search"]',
|
||||||
|
table: 'tbody > tr:not(.empty-rows)'
|
||||||
|
},
|
||||||
|
ticketAdvance: {
|
||||||
|
openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]',
|
||||||
|
dateFuture: 'vn-date-picker[label="Origin date"]',
|
||||||
|
dateToAdvance: 'vn-date-picker[label="Destination date"]',
|
||||||
|
linesMax: 'vn-textfield[label="Max Lines"]',
|
||||||
|
litersMax: 'vn-textfield[label="Max Liters"]',
|
||||||
|
futureIpt: 'vn-autocomplete[label="Origin IPT"]',
|
||||||
|
ipt: 'vn-autocomplete[label="Destination IPT"]',
|
||||||
|
tableIpt: 'vn-autocomplete[name="ipt"]',
|
||||||
|
tableFutureIpt: 'vn-autocomplete[name="futureIpt"]',
|
||||||
|
futureState: 'vn-autocomplete[label="Origin Grouped State"]',
|
||||||
|
state: 'vn-autocomplete[label="Destination Grouped State"]',
|
||||||
|
warehouseFk: 'vn-autocomplete[label="Warehouse"]',
|
||||||
|
tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
|
||||||
|
moveButton: 'vn-button[vn-tooltip="Advance tickets"]',
|
||||||
|
acceptButton: '.vn-confirm.shown button[response="accept"]',
|
||||||
|
multiCheck: 'vn-multi-check',
|
||||||
|
tableId: 'vn-textfield[name="id"]',
|
||||||
|
tableFutureId: 'vn-textfield[name="futureId"]',
|
||||||
|
tableLiters: 'vn-textfield[name="liters"]',
|
||||||
|
tableLines: 'vn-textfield[name="lines"]',
|
||||||
|
tableStock: 'vn-textfield[name="hasStock"]',
|
||||||
submit: 'vn-submit[label="Search"]',
|
submit: 'vn-submit[label="Search"]',
|
||||||
table: 'tbody > tr:not(.empty-rows)'
|
table: 'tbody > tr:not(.empty-rows)'
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import selectors from '../../helpers/selectors';
|
import selectors from '../../helpers/selectors';
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
describe('Login path', async() => {
|
// https://redmine.verdnatura.es/issues/4995 fix login
|
||||||
|
xdescribe('RecoverPassword path', async() => {
|
||||||
let browser;
|
let browser;
|
||||||
let page;
|
let page;
|
||||||
|
|
||||||
|
|
|
@ -127,8 +127,8 @@ describe('Item regularize path', () => {
|
||||||
await page.waitForState('ticket.index');
|
await page.waitForState('ticket.index');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should search for the ticket with id 31 once again', async() => {
|
it('should search for the ticket missing once again', async() => {
|
||||||
await page.accessToSearchResult('31');
|
await page.accessToSearchResult('Missing');
|
||||||
await page.waitForState('ticket.card.summary');
|
await page.waitForState('ticket.card.summary');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,6 @@ describe('Ticket Future path', () => {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
const now = new Date();
|
|
||||||
const tomorrow = new Date(now.getDate() + 1);
|
|
||||||
|
|
||||||
it('should show errors snackbar because of the required data', async() => {
|
it('should show errors snackbar because of the required data', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
||||||
await page.clearInput(selectors.ticketFuture.warehouseFk);
|
await page.clearInput(selectors.ticketFuture.warehouseFk);
|
||||||
|
@ -27,20 +24,6 @@ describe('Ticket Future path', () => {
|
||||||
|
|
||||||
expect(message.text).toContain('warehouseFk is a required argument');
|
expect(message.text).toContain('warehouseFk is a required argument');
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
|
||||||
await page.clearInput(selectors.ticketFuture.litersMax);
|
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
|
||||||
message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('litersMax is a required argument');
|
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
|
||||||
await page.clearInput(selectors.ticketFuture.linesMax);
|
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
|
||||||
message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('linesMax is a required argument');
|
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
||||||
await page.clearInput(selectors.ticketFuture.futureDated);
|
await page.clearInput(selectors.ticketFuture.futureDated);
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
|
@ -62,44 +45,13 @@ describe('Ticket Future path', () => {
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 4);
|
await page.waitForNumberOfElements(selectors.ticketFuture.table, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should search with the origin shipped today', async() => {
|
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
|
||||||
await page.pickDate(selectors.ticketFuture.shipped, now);
|
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 4);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search with the origin shipped tomorrow', async() => {
|
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
|
||||||
await page.pickDate(selectors.ticketFuture.shipped, tomorrow);
|
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search with the destination shipped today', async() => {
|
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
|
||||||
await page.clearInput(selectors.ticketFuture.shipped);
|
|
||||||
await page.pickDate(selectors.ticketFuture.tfShipped, now);
|
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 4);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search with the destination shipped tomorrow', async() => {
|
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
|
||||||
await page.pickDate(selectors.ticketFuture.tfShipped, tomorrow);
|
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search with the origin IPT', async() => {
|
it('should search with the origin IPT', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
||||||
|
|
||||||
await page.clearInput(selectors.ticketFuture.shipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.tfShipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.ipt);
|
await page.clearInput(selectors.ticketFuture.ipt);
|
||||||
await page.clearInput(selectors.ticketFuture.tfIpt);
|
await page.clearInput(selectors.ticketFuture.futureIpt);
|
||||||
await page.clearInput(selectors.ticketFuture.state);
|
await page.clearInput(selectors.ticketFuture.state);
|
||||||
await page.clearInput(selectors.ticketFuture.tfState);
|
await page.clearInput(selectors.ticketFuture.futureState);
|
||||||
|
|
||||||
await page.autocompleteSearch(selectors.ticketFuture.ipt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketFuture.ipt, 'Horizontal');
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
|
@ -109,14 +61,12 @@ describe('Ticket Future path', () => {
|
||||||
it('should search with the destination IPT', async() => {
|
it('should search with the destination IPT', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
||||||
|
|
||||||
await page.clearInput(selectors.ticketFuture.shipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.tfShipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.ipt);
|
await page.clearInput(selectors.ticketFuture.ipt);
|
||||||
await page.clearInput(selectors.ticketFuture.tfIpt);
|
await page.clearInput(selectors.ticketFuture.futureIpt);
|
||||||
await page.clearInput(selectors.ticketFuture.state);
|
await page.clearInput(selectors.ticketFuture.state);
|
||||||
await page.clearInput(selectors.ticketFuture.tfState);
|
await page.clearInput(selectors.ticketFuture.futureState);
|
||||||
|
|
||||||
await page.autocompleteSearch(selectors.ticketFuture.tfIpt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'Horizontal');
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 0);
|
await page.waitForNumberOfElements(selectors.ticketFuture.table, 0);
|
||||||
});
|
});
|
||||||
|
@ -124,12 +74,10 @@ describe('Ticket Future path', () => {
|
||||||
it('should search with the origin grouped state', async() => {
|
it('should search with the origin grouped state', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
||||||
|
|
||||||
await page.clearInput(selectors.ticketFuture.shipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.tfShipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.ipt);
|
await page.clearInput(selectors.ticketFuture.ipt);
|
||||||
await page.clearInput(selectors.ticketFuture.tfIpt);
|
await page.clearInput(selectors.ticketFuture.futureIpt);
|
||||||
await page.clearInput(selectors.ticketFuture.state);
|
await page.clearInput(selectors.ticketFuture.state);
|
||||||
await page.clearInput(selectors.ticketFuture.tfState);
|
await page.clearInput(selectors.ticketFuture.futureState);
|
||||||
|
|
||||||
await page.autocompleteSearch(selectors.ticketFuture.state, 'Free');
|
await page.autocompleteSearch(selectors.ticketFuture.state, 'Free');
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
|
@ -139,24 +87,20 @@ describe('Ticket Future path', () => {
|
||||||
it('should search with the destination grouped state', async() => {
|
it('should search with the destination grouped state', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
||||||
|
|
||||||
await page.clearInput(selectors.ticketFuture.shipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.tfShipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.ipt);
|
await page.clearInput(selectors.ticketFuture.ipt);
|
||||||
await page.clearInput(selectors.ticketFuture.tfIpt);
|
await page.clearInput(selectors.ticketFuture.futureIpt);
|
||||||
await page.clearInput(selectors.ticketFuture.state);
|
await page.clearInput(selectors.ticketFuture.state);
|
||||||
await page.clearInput(selectors.ticketFuture.tfState);
|
await page.clearInput(selectors.ticketFuture.futureState);
|
||||||
|
|
||||||
await page.autocompleteSearch(selectors.ticketFuture.tfState, 'Free');
|
await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free');
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 0);
|
await page.waitForNumberOfElements(selectors.ticketFuture.table, 0);
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
||||||
await page.clearInput(selectors.ticketFuture.shipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.tfShipped);
|
|
||||||
await page.clearInput(selectors.ticketFuture.ipt);
|
await page.clearInput(selectors.ticketFuture.ipt);
|
||||||
await page.clearInput(selectors.ticketFuture.tfIpt);
|
await page.clearInput(selectors.ticketFuture.futureIpt);
|
||||||
await page.clearInput(selectors.ticketFuture.state);
|
await page.clearInput(selectors.ticketFuture.state);
|
||||||
await page.clearInput(selectors.ticketFuture.tfState);
|
await page.clearInput(selectors.ticketFuture.futureState);
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 4);
|
await page.waitForNumberOfElements(selectors.ticketFuture.table, 4);
|
||||||
|
@ -176,7 +120,7 @@ describe('Ticket Future path', () => {
|
||||||
|
|
||||||
it('should search in smart-table with an ID Destination', async() => {
|
it('should search in smart-table with an ID Destination', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
||||||
await page.write(selectors.ticketFuture.tableTfId, '12');
|
await page.write(selectors.ticketFuture.tableFutureId, '12');
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 5);
|
await page.waitForNumberOfElements(selectors.ticketFuture.table, 5);
|
||||||
|
|
||||||
|
@ -199,7 +143,7 @@ describe('Ticket Future path', () => {
|
||||||
|
|
||||||
it('should search in smart-table with an IPT Destination', async() => {
|
it('should search in smart-table with an IPT Destination', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
||||||
await page.autocompleteSearch(selectors.ticketFuture.tableTfIpt, 'Vertical');
|
await page.autocompleteSearch(selectors.ticketFuture.tableFutureIpt, 'Vertical');
|
||||||
await page.waitForNumberOfElements(selectors.ticketFuture.table, 1);
|
await page.waitForNumberOfElements(selectors.ticketFuture.table, 1);
|
||||||
|
|
||||||
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
|
@ -0,0 +1,162 @@
|
||||||
|
import selectors from '../../helpers/selectors.js';
|
||||||
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
|
describe('Ticket Advance path', () => {
|
||||||
|
let browser;
|
||||||
|
let page;
|
||||||
|
|
||||||
|
beforeAll(async() => {
|
||||||
|
browser = await getBrowser();
|
||||||
|
page = browser.page;
|
||||||
|
await page.loginAndModule('employee', 'ticket');
|
||||||
|
await page.accessToSection('ticket.advance');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async() => {
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show errors snackbar because of the required data', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.clearInput(selectors.ticketAdvance.warehouseFk);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
let message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('warehouseFk is a required argument');
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.clearInput(selectors.ticketAdvance.dateToAdvance);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('dateToAdvance is a required argument');
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.clearInput(selectors.ticketAdvance.dateFuture);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('dateFuture is a required argument');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search with the required data', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search with the origin IPT', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'Horizontal');
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.clearInput(selectors.ticketAdvance.ipt);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search with the destination IPT', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'Horizontal');
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.clearInput(selectors.ticketAdvance.futureIpt);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search with the origin grouped state', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.autocompleteSearch(selectors.ticketAdvance.futureState, 'Free');
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.clearInput(selectors.ticketAdvance.futureState);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search with the destination grouped state', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.autocompleteSearch(selectors.ticketAdvance.state, 'Free');
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.clearInput(selectors.ticketAdvance.state);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search in smart-table with an IPT Origin', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.autocompleteSearch(selectors.ticketAdvance.tableFutureIpt, 'Vertical');
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search in smart-table with an IPT Destination', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.autocompleteSearch(selectors.ticketAdvance.tableIpt, 'Vertical');
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search in smart-table with stock', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.write(selectors.ticketAdvance.tableStock, '5');
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 2);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search in smart-table with especified Lines', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.write(selectors.ticketAdvance.tableLines, '0');
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search in smart-table with especified Liters', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.write(selectors.ticketAdvance.tableLiters, '0');
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should check the three last tickets and move to the future', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.multiCheck);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.moveButton);
|
||||||
|
await page.waitToClick(selectors.ticketAdvance.acceptButton);
|
||||||
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('Tickets moved successfully!');
|
||||||
|
});
|
||||||
|
});
|
|
@ -147,7 +147,7 @@ export default class SmartTable extends Component {
|
||||||
for (const column of this.columns) {
|
for (const column of this.columns) {
|
||||||
if (viewConfig.configuration[column.field] == false) {
|
if (viewConfig.configuration[column.field] == false) {
|
||||||
const baseSelector = `smart-table[view-config-id="${this.viewConfigId}"] table`;
|
const baseSelector = `smart-table[view-config-id="${this.viewConfigId}"] table`;
|
||||||
selectors.push(`${baseSelector} thead > tr > th:nth-child(${column.index + 1})`);
|
selectors.push(`${baseSelector} thead > tr:not([second-header]) > th:nth-child(${column.index + 1})`);
|
||||||
selectors.push(`${baseSelector} tbody > tr > td:nth-child(${column.index + 1})`);
|
selectors.push(`${baseSelector} tbody > tr > td:nth-child(${column.index + 1})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ export default class SmartTable extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
registerColumns() {
|
registerColumns() {
|
||||||
const header = this.element.querySelector('thead > tr');
|
const header = this.element.querySelector('thead > tr:not([second-header])');
|
||||||
if (!header) return;
|
if (!header) return;
|
||||||
const columns = header.querySelectorAll('th');
|
const columns = header.querySelectorAll('th');
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ export default class SmartTable extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
emptyDataRows() {
|
emptyDataRows() {
|
||||||
const header = this.element.querySelector('thead > tr');
|
const header = this.element.querySelector('thead > tr:not([second-header])');
|
||||||
const columns = header.querySelectorAll('th');
|
const columns = header.querySelectorAll('th');
|
||||||
const tbody = this.element.querySelector('tbody');
|
const tbody = this.element.querySelector('tbody');
|
||||||
if (tbody) {
|
if (tbody) {
|
||||||
|
@ -333,7 +333,7 @@ export default class SmartTable extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
displaySearch() {
|
displaySearch() {
|
||||||
const header = this.element.querySelector('thead > tr');
|
const header = this.element.querySelector('thead > tr:not([second-header])');
|
||||||
if (!header) return;
|
if (!header) return;
|
||||||
|
|
||||||
const tbody = this.element.querySelector('tbody');
|
const tbody = this.element.querySelector('tbody');
|
||||||
|
|
|
@ -8,6 +8,16 @@ smart-table table {
|
||||||
& > thead {
|
& > thead {
|
||||||
border-bottom: $border;
|
border-bottom: $border;
|
||||||
|
|
||||||
|
& > tr[second-header] {
|
||||||
|
& > th
|
||||||
|
{
|
||||||
|
text-align: center;
|
||||||
|
border-bottom-style: groove;
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
& > * > th {
|
& > * > th {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +70,9 @@ smart-table table {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&[separator]{
|
||||||
|
border-left-style: groove;
|
||||||
|
}
|
||||||
vn-icon.bright, i.bright {
|
vn-icon.bright, i.bright {
|
||||||
color: #f7931e;
|
color: #f7931e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<vn-layout
|
<vn-layout
|
||||||
ng-if="$ctrl.showLayout">
|
ng-if="$ctrl.showLayout">
|
||||||
</vn-layout>
|
</vn-layout>
|
||||||
<vn-out-layout
|
<ui-view
|
||||||
|
name="login"
|
||||||
ng-if="!$ctrl.showLayout">
|
ng-if="!$ctrl.showLayout">
|
||||||
</vn-out-layout>
|
</ui-view>
|
||||||
<vn-snackbar vn-id="snackbar"></vn-snackbar>
|
<vn-snackbar vn-id="snackbar"></vn-snackbar>
|
||||||
<vn-debug-info></vn-debug-info>
|
<vn-debug-info></vn-debug-info>
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default class App extends Component {
|
||||||
|
|
||||||
get showLayout() {
|
get showLayout() {
|
||||||
const state = this.$state.current.name || this.$location.$$path.substring(1).replace('/', '.');
|
const state = this.$state.current.name || this.$location.$$path.substring(1).replace('/', '.');
|
||||||
const outLayout = ['login', 'recoverPassword', 'resetPassword'];
|
const outLayout = ['login', 'recoverPassword', 'resetPassword', 'reset-password'];
|
||||||
return state && !outLayout.some(ol => ol == state);
|
return state && !outLayout.some(ol => ol == state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,3 +19,4 @@ import './user-popover';
|
||||||
import './upload-photo';
|
import './upload-photo';
|
||||||
import './bank-entity';
|
import './bank-entity';
|
||||||
import './log';
|
import './log';
|
||||||
|
import './sendSms';
|
||||||
|
|
|
@ -1,27 +1,32 @@
|
||||||
<vn-textfield
|
<div class="box">
|
||||||
|
<img src="./logo.svg"/>
|
||||||
|
<form name="form" ng-submit="$ctrl.submit()">
|
||||||
|
<vn-textfield
|
||||||
label="User"
|
label="User"
|
||||||
ng-model="$ctrl.user"
|
ng-model="$ctrl.user"
|
||||||
vn-id="userField"
|
vn-id="userField"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Password"
|
label="Password"
|
||||||
ng-model="$ctrl.password"
|
ng-model="$ctrl.password"
|
||||||
type="password">
|
type="password">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-check
|
<vn-check
|
||||||
label="Do not close session"
|
label="Do not close session"
|
||||||
ng-model="$ctrl.remember"
|
ng-model="$ctrl.remember"
|
||||||
name="remember">
|
name="remember">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<vn-submit label="Enter" ng-click="$ctrl.submit()"></vn-submit>
|
<vn-submit label="Enter" ng-click="$ctrl.submit()"></vn-submit>
|
||||||
<div class="spinner-wrapper">
|
<div class="spinner-wrapper">
|
||||||
<vn-spinner enable="$ctrl.loading"></vn-spinner>
|
<vn-spinner enable="$ctrl.loading"></vn-spinner>
|
||||||
</div>
|
</div>
|
||||||
<div class="vn-pt-lg">
|
<!--<div class="vn-pt-lg">
|
||||||
<a ui-sref="recoverPassword" translate>
|
<a ui-sref="recoverPassword" translate>
|
||||||
I do not remember my password
|
I do not remember my password
|
||||||
</a>
|
</a>
|
||||||
|
</div>-->
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,7 +25,7 @@ vn-recover-password{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-out-layout{
|
vn-login{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../../module';
|
||||||
import Component from 'core/lib/component';
|
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
import Dialog from '../../../core/components/dialog';
|
||||||
|
|
||||||
|
export default class sendSmsDialog extends Dialog {
|
||||||
|
constructor($element, $scope, $http, $translate, vnApp) {
|
||||||
|
super($element, $scope, $http, $translate, vnApp);
|
||||||
|
|
||||||
|
new CustomEvent('openSmsDialog', {
|
||||||
|
detail: {
|
||||||
|
this: this
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
class Controller extends Component {
|
|
||||||
open() {
|
open() {
|
||||||
this.$.SMSDialog.show();
|
this.$.SMSDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
charactersRemaining() {
|
charactersRemaining() {
|
||||||
const element = this.$.message;
|
const element = this.sms.message;
|
||||||
const value = element.input.value;
|
|
||||||
|
|
||||||
const maxLength = 160;
|
const maxLength = 160;
|
||||||
const textAreaLength = new Blob([value]).size;
|
return maxLength - element.length;
|
||||||
return maxLength - textAreaLength;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onResponse() {
|
onResponse() {
|
||||||
|
@ -25,23 +32,19 @@ class Controller extends Component {
|
||||||
if (this.charactersRemaining() < 0)
|
if (this.charactersRemaining() < 0)
|
||||||
throw new Error(`The message it's too long`);
|
throw new Error(`The message it's too long`);
|
||||||
|
|
||||||
this.$http.post(`Tickets/${this.sms.ticketId}/sendSms`, this.sms).then(res => {
|
return this.onSend({$sms: this.sms});
|
||||||
this.vnApp.showMessage(this.$t('SMS sent!'));
|
|
||||||
|
|
||||||
if (res.data) this.emit('send', {response: res.data});
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.vnApp.showError(this.$t(e.message));
|
this.vnApp.showError(this.$t(e.message));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnTicketSms', {
|
ngModule.vnComponent('vnSmsDialog', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
controller: Controller,
|
controller: sendSmsDialog,
|
||||||
bindings: {
|
bindings: {
|
||||||
sms: '<',
|
sms: '<',
|
||||||
|
onSend: '&',
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -9,7 +9,9 @@ function config($stateProvider, $urlRouterProvider) {
|
||||||
.state('login', {
|
.state('login', {
|
||||||
url: '/login?continue',
|
url: '/login?continue',
|
||||||
description: 'Login',
|
description: 'Login',
|
||||||
template: '<vn-login></vn-login>'
|
views: {
|
||||||
|
'login': {template: '<vn-login></vn-login>'},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.state('recoverPassword', {
|
.state('recoverPassword', {
|
||||||
url: '/recover-password',
|
url: '/recover-password',
|
||||||
|
|
|
@ -140,8 +140,9 @@
|
||||||
"You don't have grant privilege": "You don't have grant privilege",
|
"You don't have grant privilege": "You don't have grant privilege",
|
||||||
"You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user",
|
"You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user",
|
||||||
"Email verify": "Email verify",
|
"Email verify": "Email verify",
|
||||||
"Ticket merged": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) merged with [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})",
|
"Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})",
|
||||||
"Sale(s) blocked, please contact production": "Sale(s) blocked, please contact production",
|
"Sale(s) blocked, please contact production": "Sale(s) blocked, please contact production",
|
||||||
|
"The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified",
|
||||||
"Receipt's bank was not found": "Receipt's bank was not found",
|
"Receipt's bank was not found": "Receipt's bank was not found",
|
||||||
"This receipt was not compensated": "This receipt was not compensated",
|
"This receipt was not compensated": "This receipt was not compensated",
|
||||||
"Client's email was not found": "Client's email was not found"
|
"Client's email was not found": "Client's email was not found"
|
||||||
|
|
|
@ -241,7 +241,7 @@
|
||||||
"Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*",
|
"Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*",
|
||||||
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
|
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
|
||||||
"You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario",
|
"You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario",
|
||||||
"Ticket merged": "Ticket [{{id}}]({{{fullPath}}}) ({{{originDated}}}) fusionado con [{{tfId}}]({{{fullPathFuture}}}) ({{{futureDated}}})",
|
"Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})",
|
||||||
"Already has this status": "Ya tiene este estado",
|
"Already has this status": "Ya tiene este estado",
|
||||||
"There aren't records for this week": "No existen registros para esta semana",
|
"There aren't records for this week": "No existen registros para esta semana",
|
||||||
"Empty data source": "Origen de datos vacio",
|
"Empty data source": "Origen de datos vacio",
|
||||||
|
|
|
@ -113,10 +113,11 @@
|
||||||
</div>
|
</div>
|
||||||
</slot-body>
|
</slot-body>
|
||||||
</vn-descriptor-content>
|
</vn-descriptor-content>
|
||||||
<vn-client-sms
|
<vn-sms-dialog
|
||||||
vn-id="sms"
|
vn-id="sms"
|
||||||
|
on-send="$ctrl.onSmsSend($sms)"
|
||||||
sms="$ctrl.newSMS">
|
sms="$ctrl.newSMS">
|
||||||
</vn-client-sms>
|
</vn-sms-dialog>
|
||||||
<vn-worker-descriptor-popover
|
<vn-worker-descriptor-popover
|
||||||
vn-id="workerDescriptor">
|
vn-id="workerDescriptor">
|
||||||
</vn-worker-descriptor-popover>
|
</vn-worker-descriptor-popover>
|
||||||
|
|
|
@ -39,6 +39,11 @@ class Controller extends Descriptor {
|
||||||
};
|
};
|
||||||
this.$.sms.open();
|
this.$.sms.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSmsSend(sms) {
|
||||||
|
return this.$http.post(`Clients/${this.id}/sendSms`, sms)
|
||||||
|
.then(() => this.vnApp.showSuccess(this.$t('SMS sent')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnClientDescriptor', {
|
ngModule.vnComponent('vnClientDescriptor', {
|
||||||
|
|
|
@ -35,7 +35,6 @@ import './sample/index';
|
||||||
import './sample/create';
|
import './sample/create';
|
||||||
import './web-payment';
|
import './web-payment';
|
||||||
import './log';
|
import './log';
|
||||||
import './sms';
|
|
||||||
import './postcode';
|
import './postcode';
|
||||||
import './postcode/province';
|
import './postcode/province';
|
||||||
import './postcode/city';
|
import './postcode/city';
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
import ngModule from '../module';
|
|
||||||
import Section from 'salix/components/section';
|
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
class Controller extends Section {
|
|
||||||
open() {
|
|
||||||
this.$.SMSDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
charactersRemaining() {
|
|
||||||
const element = this.$.message;
|
|
||||||
const value = element.input.value;
|
|
||||||
|
|
||||||
const maxLength = 160;
|
|
||||||
const textAreaLength = new Blob([value]).size;
|
|
||||||
return maxLength - textAreaLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
onResponse() {
|
|
||||||
try {
|
|
||||||
if (!this.sms.destination)
|
|
||||||
throw new Error(`The destination can't be empty`);
|
|
||||||
if (!this.sms.message)
|
|
||||||
throw new Error(`The message can't be empty`);
|
|
||||||
if (this.charactersRemaining() < 0)
|
|
||||||
throw new Error(`The message it's too long`);
|
|
||||||
|
|
||||||
this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => {
|
|
||||||
this.vnApp.showMessage(this.$t('SMS sent!'));
|
|
||||||
|
|
||||||
if (res.data) this.emit('send', {response: res.data});
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
this.vnApp.showError(this.$t(e.message));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp'];
|
|
||||||
|
|
||||||
ngModule.vnComponent('vnClientSms', {
|
|
||||||
template: require('./index.html'),
|
|
||||||
controller: Controller,
|
|
||||||
bindings: {
|
|
||||||
sms: '<',
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,74 +0,0 @@
|
||||||
import './index';
|
|
||||||
|
|
||||||
describe('Client', () => {
|
|
||||||
describe('Component vnClientSms', () => {
|
|
||||||
let controller;
|
|
||||||
let $httpBackend;
|
|
||||||
let $element;
|
|
||||||
|
|
||||||
beforeEach(ngModule('client'));
|
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
|
||||||
$httpBackend = _$httpBackend_;
|
|
||||||
let $scope = $rootScope.$new();
|
|
||||||
$element = angular.element('<vn-dialog></vn-dialog>');
|
|
||||||
controller = $componentController('vnClientSms', {$element, $scope});
|
|
||||||
controller.client = {id: 1101};
|
|
||||||
controller.$params = {id: 1101};
|
|
||||||
controller.$.message = {
|
|
||||||
input: {
|
|
||||||
value: 'My SMS'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('onResponse()', () => {
|
|
||||||
it('should perform a POST query and show a success snackbar', () => {
|
|
||||||
let params = {destinationFk: 1101, destination: 111111111, message: 'My SMS'};
|
|
||||||
controller.sms = {destinationFk: 1101, destination: 111111111, message: 'My SMS'};
|
|
||||||
|
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
|
||||||
$httpBackend.expect('POST', `Clients/1101/sendSms`, params).respond(200, params);
|
|
||||||
|
|
||||||
controller.onResponse();
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call onResponse without the destination and show an error snackbar', () => {
|
|
||||||
controller.sms = {destinationFk: 1101, message: 'My SMS'};
|
|
||||||
|
|
||||||
jest.spyOn(controller.vnApp, 'showError');
|
|
||||||
|
|
||||||
controller.onResponse('accept');
|
|
||||||
|
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call onResponse without the message and show an error snackbar', () => {
|
|
||||||
controller.sms = {destinationFk: 1101, destination: 222222222};
|
|
||||||
|
|
||||||
jest.spyOn(controller.vnApp, 'showError');
|
|
||||||
|
|
||||||
controller.onResponse('accept');
|
|
||||||
|
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('charactersRemaining()', () => {
|
|
||||||
it('should return the characters remaining in a element', () => {
|
|
||||||
controller.$.message = {
|
|
||||||
input: {
|
|
||||||
value: 'My message 0€'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = controller.charactersRemaining();
|
|
||||||
|
|
||||||
expect(result).toEqual(145);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -9,31 +9,43 @@ module.exports = Self => {
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
arg: 'ids',
|
arg: 'ids',
|
||||||
type: ['number'],
|
type: 'string',
|
||||||
description: 'The invoice ids'
|
description: 'The invoices ids',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: [
|
||||||
arg: 'base64',
|
{
|
||||||
type: 'string',
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
root: true
|
root: true
|
||||||
},
|
}, {
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'string',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'string',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
http: {
|
http: {
|
||||||
path: '/downloadZip',
|
path: '/downloadZip',
|
||||||
verb: 'POST'
|
verb: 'GET'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.downloadZip = async function(ctx, ids, options) {
|
Self.downloadZip = async function(ctx, ids, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
const zip = new JSZip();
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const zip = new JSZip();
|
|
||||||
let totalSize = 0;
|
|
||||||
const zipConfig = await models.ZipConfig.findOne(null, myOptions);
|
const zipConfig = await models.ZipConfig.findOne(null, myOptions);
|
||||||
|
let totalSize = 0;
|
||||||
|
ids = ids.split(',');
|
||||||
|
|
||||||
for (let id of ids) {
|
for (let id of ids) {
|
||||||
if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large');
|
if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large');
|
||||||
const invoiceOutPdf = await models.InvoiceOut.download(ctx, id, myOptions);
|
const invoiceOutPdf = await models.InvoiceOut.download(ctx, id, myOptions);
|
||||||
|
@ -44,8 +56,10 @@ module.exports = Self => {
|
||||||
totalSize += sizeInMegabytes;
|
totalSize += sizeInMegabytes;
|
||||||
zip.file(fileName, body);
|
zip.file(fileName, body);
|
||||||
}
|
}
|
||||||
const base64 = await zip.generateAsync({type: 'base64'});
|
|
||||||
return base64;
|
const stream = zip.generateNodeStream({streamFiles: true});
|
||||||
|
|
||||||
|
return [stream, 'application/zip', `filename="download.zip"`];
|
||||||
};
|
};
|
||||||
|
|
||||||
function extractFileName(str) {
|
function extractFileName(str) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
describe('InvoiceOut downloadZip()', () => {
|
describe('InvoiceOut downloadZip()', () => {
|
||||||
const userId = 9;
|
const userId = 9;
|
||||||
const invoiceIds = [1, 2];
|
const invoiceIds = '1,2';
|
||||||
const ctx = {
|
const ctx = {
|
||||||
req: {
|
req: {
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,13 @@ export default class Controller extends Section {
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
} else {
|
} else {
|
||||||
const invoiceOutIds = this.checked;
|
const invoiceOutIds = this.checked;
|
||||||
const params = {
|
const invoicesIds = invoiceOutIds.join(',');
|
||||||
ids: invoiceOutIds
|
const serializedParams = this.$httpParamSerializer({
|
||||||
};
|
access_token: this.vnToken.token,
|
||||||
this.$http.post(`InvoiceOuts/downloadZip`, params)
|
ids: invoicesIds
|
||||||
.then(res => {
|
|
||||||
location.href = 'data:application/zip;base64,' + res.data;
|
|
||||||
});
|
});
|
||||||
|
const url = `api/InvoiceOuts/downloadZip?${serializedParams}`;
|
||||||
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ describe('loopback model Supplier', () => {
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
supplierOne = await models.Supplier.findById(1);
|
supplierOne = await models.Supplier.findById(1);
|
||||||
supplierTwo = await models.Supplier.findById(442);
|
supplierTwo = await models.Supplier.findById(442);
|
||||||
|
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: 9},
|
accessToken: {userId: 9},
|
||||||
http: {
|
http: {
|
||||||
|
@ -23,18 +22,16 @@ describe('loopback model Supplier', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await supplierOne.updateAttribute('payMethodFk', supplierOne.payMethodFk);
|
|
||||||
await supplierTwo.updateAttribute('payMethodFk', supplierTwo.payMethodFk);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('payMethodFk', () => {
|
describe('payMethodFk', () => {
|
||||||
it('should throw an error when attempting to set an invalid payMethod id in the supplier', async() => {
|
it('should throw an error when attempting to set an invalid payMethod id in the supplier', async() => {
|
||||||
|
const tx = await models.Supplier.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
let error;
|
let error;
|
||||||
const expectedError = 'You can not select this payment method without a registered bankery account';
|
const expectedError = 'You can not select this payment method without a registered bankery account';
|
||||||
const supplier = await models.Supplier.findById(1);
|
|
||||||
|
|
||||||
await supplier.updateAttribute('payMethodFk', 8)
|
await supplierOne.updateAttribute('payMethodFk', 8, options)
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
error = e;
|
error = e;
|
||||||
|
|
||||||
|
@ -42,52 +39,89 @@ describe('loopback model Supplier', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not throw if the payMethod id is valid', async() => {
|
it('should not throw if the payMethod id is valid', async() => {
|
||||||
|
const tx = await models.Supplier.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
let error;
|
let error;
|
||||||
const supplier = await models.Supplier.findById(442);
|
await supplierTwo.updateAttribute('payMethodFk', 4, options)
|
||||||
await supplier.updateAttribute('payMethodFk', 4)
|
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
error = e;
|
error = e;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(error).not.toBeDefined();
|
expect(error).not.toBeDefined();
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have checked isPayMethodChecked for payMethod hasVerfified is false', async() => {
|
it('should have checked isPayMethodChecked for payMethod hasVerfified is false', async() => {
|
||||||
const supplier = await models.Supplier.findById(442);
|
const tx = await models.Supplier.beginTransaction({});
|
||||||
await supplier.updateAttribute('isPayMethodChecked', true);
|
const options = {transaction: tx};
|
||||||
await supplier.updateAttribute('payMethodFk', 5);
|
|
||||||
|
|
||||||
const result = await models.Supplier.findById(442);
|
try {
|
||||||
|
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
|
||||||
|
await supplierTwo.updateAttribute('payMethodFk', 5, options);
|
||||||
|
|
||||||
|
const result = await models.Supplier.findById(442, null, options);
|
||||||
|
|
||||||
expect(result.isPayMethodChecked).toEqual(true);
|
expect(result.isPayMethodChecked).toEqual(true);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have unchecked isPayMethodChecked for payMethod hasVerfified is true', async() => {
|
it('should have unchecked isPayMethodChecked for payMethod hasVerfified is true', async() => {
|
||||||
const supplier = await models.Supplier.findById(442);
|
const tx = await models.Supplier.beginTransaction({});
|
||||||
await supplier.updateAttribute('isPayMethodChecked', true);
|
const options = {transaction: tx};
|
||||||
await supplier.updateAttribute('payMethodFk', 2);
|
|
||||||
|
|
||||||
const result = await models.Supplier.findById(442);
|
try {
|
||||||
|
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
|
||||||
|
await supplierTwo.updateAttribute('payMethodFk', 2, options);
|
||||||
|
|
||||||
|
const result = await models.Supplier.findById(442, null, options);
|
||||||
|
|
||||||
expect(result.isPayMethodChecked).toEqual(false);
|
expect(result.isPayMethodChecked).toEqual(false);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have unchecked isPayMethodChecked for payDay and peyDemFk', async() => {
|
it('should have unchecked isPayMethodChecked for payDay and peyDemFk', async() => {
|
||||||
const supplier = await models.Supplier.findById(442);
|
const tx = await models.Supplier.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
await supplier.updateAttribute('isPayMethodChecked', true);
|
try {
|
||||||
await supplier.updateAttribute('payDay', 5);
|
await supplierTwo.updateAttribute('payMethodFk', 2, options);
|
||||||
const firstResult = await models.Supplier.findById(442);
|
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
|
||||||
|
await supplierTwo.updateAttribute('payDay', 5, options);
|
||||||
|
const firstResult = await models.Supplier.findById(442, null, options);
|
||||||
|
|
||||||
await supplier.updateAttribute('isPayMethodChecked', true);
|
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
|
||||||
await supplier.updateAttribute('payDemFk', 1);
|
await supplierTwo.updateAttribute('payDemFk', 1, options);
|
||||||
const secondResult = await models.Supplier.findById(442);
|
const secondResult = await models.Supplier.findById(442, null, options);
|
||||||
|
|
||||||
expect(firstResult.isPayMethodChecked).toEqual(false);
|
expect(firstResult.isPayMethodChecked).toEqual(false);
|
||||||
expect(secondResult.isPayMethodChecked).toEqual(false);
|
expect(secondResult.isPayMethodChecked).toEqual(false);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,3 +20,4 @@ routeFk: route
|
||||||
companyFk: company
|
companyFk: company
|
||||||
agencyModeFk: agency
|
agencyModeFk: agency
|
||||||
ticketFk: ticket
|
ticketFk: ticket
|
||||||
|
mergedTicket: merged ticket
|
||||||
|
|
|
@ -20,3 +20,4 @@ routeFk: ruta
|
||||||
companyFk: empresa
|
companyFk: empresa
|
||||||
agencyModeFk: agencia
|
agencyModeFk: agencia
|
||||||
ticketFk: ticket
|
ticketFk: ticket
|
||||||
|
mergedTicket: ticket fusionado
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||||
|
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||||
|
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('getTicketsAdvance', {
|
||||||
|
description: 'Find all tickets that can be moved to the present',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'warehouseFk',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Warehouse identifier',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'dateFuture',
|
||||||
|
type: 'date',
|
||||||
|
description: 'Date of the tickets that you want to advance',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'dateToAdvance',
|
||||||
|
type: 'date',
|
||||||
|
description: 'Date to when you want to advance',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'ipt',
|
||||||
|
type: 'string',
|
||||||
|
description: 'Origin Item Packaging Type',
|
||||||
|
required: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'futureIpt',
|
||||||
|
type: 'string',
|
||||||
|
description: 'Destination Item Packaging Type',
|
||||||
|
required: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Origin id',
|
||||||
|
required: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'futureId',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Destination id',
|
||||||
|
required: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'state',
|
||||||
|
type: 'string',
|
||||||
|
description: 'Origin state',
|
||||||
|
required: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'futureState',
|
||||||
|
type: 'string',
|
||||||
|
description: 'Destination state',
|
||||||
|
required: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'object',
|
||||||
|
description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string`
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/getTicketsAdvance`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getTicketsAdvance = async(ctx, options) => {
|
||||||
|
const args = ctx.args;
|
||||||
|
const conn = Self.dataSource.connector;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const where = buildFilter(ctx.args, (param, value) => {
|
||||||
|
switch (param) {
|
||||||
|
case 'id':
|
||||||
|
return {'f.id': value};
|
||||||
|
case 'futureId':
|
||||||
|
return {'f.futureId': value};
|
||||||
|
case 'ipt':
|
||||||
|
return {'f.ipt': value};
|
||||||
|
case 'futureIpt':
|
||||||
|
return {'f.futureIpt': value};
|
||||||
|
case 'state':
|
||||||
|
return {'f.stateCode': {like: `%${value}%`}};
|
||||||
|
case 'futureState':
|
||||||
|
return {'f.futureStateCode': {like: `%${value}%`}};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let filter = mergeFilters(ctx.args.filter, {where});
|
||||||
|
const stmts = [];
|
||||||
|
let stmt;
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(
|
||||||
|
`CALL vn.ticket_canAdvance(?,?,?)`,
|
||||||
|
[args.dateFuture, args.dateToAdvance, args.warehouseFk]);
|
||||||
|
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(`
|
||||||
|
SELECT f.*
|
||||||
|
FROM tmp.filter f`);
|
||||||
|
|
||||||
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
|
|
||||||
|
stmt.merge(conn.makeOrderBy(filter.order));
|
||||||
|
stmt.merge(conn.makeLimit(filter));
|
||||||
|
const ticketsIndex = stmts.push(stmt) - 1;
|
||||||
|
|
||||||
|
stmts.push(
|
||||||
|
`DROP TEMPORARY TABLE
|
||||||
|
tmp.filter`);
|
||||||
|
|
||||||
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
const result = await conn.executeStmt(sql, myOptions);
|
||||||
|
|
||||||
|
return result[ticketsIndex];
|
||||||
|
};
|
||||||
|
};
|
|
@ -20,18 +20,6 @@ module.exports = Self => {
|
||||||
description: 'The date to probe',
|
description: 'The date to probe',
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
arg: 'litersMax',
|
|
||||||
type: 'number',
|
|
||||||
description: 'Maximum volume of tickets to catapult',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'linesMax',
|
|
||||||
type: 'number',
|
|
||||||
description: 'Maximum number of lines of tickets to catapult',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
arg: 'warehouseFk',
|
arg: 'warehouseFk',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
|
@ -39,15 +27,15 @@ module.exports = Self => {
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'shipped',
|
arg: 'litersMax',
|
||||||
type: 'date',
|
type: 'number',
|
||||||
description: 'Origin shipped',
|
description: 'Maximum volume of tickets to catapult',
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'tfShipped',
|
arg: 'linesMax',
|
||||||
type: 'date',
|
type: 'number',
|
||||||
description: 'Destination shipped',
|
description: 'Maximum number of lines of tickets to catapult',
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -57,7 +45,7 @@ module.exports = Self => {
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'tfIpt',
|
arg: 'futureIpt',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Destination Item Packaging Type',
|
description: 'Destination Item Packaging Type',
|
||||||
required: false
|
required: false
|
||||||
|
@ -69,7 +57,7 @@ module.exports = Self => {
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'tfId',
|
arg: 'futureId',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'Destination id',
|
description: 'Destination id',
|
||||||
required: false
|
required: false
|
||||||
|
@ -81,7 +69,7 @@ module.exports = Self => {
|
||||||
required: false
|
required: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'tfState',
|
arg: 'futureState',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Destination state',
|
description: 'Destination state',
|
||||||
required: false
|
required: false
|
||||||
|
@ -108,7 +96,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getTicketsFuture = async (ctx, options) => {
|
Self.getTicketsFuture = async(ctx, options) => {
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
@ -119,31 +107,31 @@ module.exports = Self => {
|
||||||
const where = buildFilter(ctx.args, (param, value) => {
|
const where = buildFilter(ctx.args, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'id':
|
case 'id':
|
||||||
return { 'f.id': value };
|
return {'f.id': value};
|
||||||
case 'tfId':
|
case 'lines':
|
||||||
return { 'f.ticketFuture': value };
|
return {'f.lines': {lte: value}};
|
||||||
case 'shipped':
|
case 'liters':
|
||||||
return { 'f.shipped': value };
|
return {'f.liters': {lte: value}};
|
||||||
case 'tfShipped':
|
case 'futureId':
|
||||||
return { 'f.tfShipped': value };
|
return {'f.futureId': value};
|
||||||
case 'ipt':
|
case 'ipt':
|
||||||
return { 'f.ipt': value };
|
return {'f.ipt': value};
|
||||||
case 'tfIpt':
|
case 'futureIpt':
|
||||||
return { 'f.tfIpt': value };
|
return {'f.futureIpt': value};
|
||||||
case 'state':
|
case 'state':
|
||||||
return { 'f.code': { like: `%${value}%` } };
|
return {'f.stateCode': {like: `%${value}%`}};
|
||||||
case 'tfState':
|
case 'futureState':
|
||||||
return { 'f.tfCode': { like: `%${value}%` } };
|
return {'f.futureStateCode': {like: `%${value}%`}};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let filter = mergeFilters(ctx.args.filter, { where });
|
let filter = mergeFilters(ctx.args.filter, {where});
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(
|
stmt = new ParameterizedSQL(
|
||||||
`CALL vn.ticket_canbePostponed(?,?,?,?,?)`,
|
`CALL vn.ticket_canbePostponed(?,?,?)`,
|
||||||
[args.originDated, args.futureDated, args.litersMax, args.linesMax, args.warehouseFk]);
|
[args.originDated, args.futureDated, args.warehouseFk]);
|
||||||
|
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
@ -153,7 +141,7 @@ module.exports = Self => {
|
||||||
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
||||||
(INDEX (ticketFk))
|
(INDEX (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
|
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters
|
||||||
FROM tmp.filter f
|
FROM tmp.filter f
|
||||||
LEFT JOIN alertLevel al ON al.id = f.alertLevel
|
LEFT JOIN alertLevel al ON al.id = f.alertLevel
|
||||||
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)`);
|
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)`);
|
||||||
|
@ -177,7 +165,7 @@ module.exports = Self => {
|
||||||
case true:
|
case true:
|
||||||
condition = `or`;
|
condition = `or`;
|
||||||
hasProblem = true;
|
hasProblem = true;
|
||||||
range = { neq: null };
|
range = {neq: null};
|
||||||
hasWhere = true;
|
hasWhere = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -191,18 +179,17 @@ module.exports = Self => {
|
||||||
|
|
||||||
const problems = {
|
const problems = {
|
||||||
[condition]: [
|
[condition]: [
|
||||||
{ 'tp.isFreezed': hasProblem },
|
{'tp.isFreezed': hasProblem},
|
||||||
{ 'tp.risk': hasProblem },
|
{'tp.risk': hasProblem},
|
||||||
{ 'tp.hasTicketRequest': hasProblem },
|
{'tp.hasTicketRequest': hasProblem},
|
||||||
{ 'tp.itemShortage': range },
|
{'tp.itemShortage': range},
|
||||||
{ 'tp.hasComponentLack': hasProblem },
|
{'tp.hasComponentLack': hasProblem},
|
||||||
{ 'tp.isTooLittle': hasProblem }
|
{'tp.isTooLittle': hasProblem}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (hasWhere) {
|
if (hasWhere)
|
||||||
filter = mergeFilters(filter, { where: problems });
|
filter = mergeFilters(filter, {where: problems});
|
||||||
}
|
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
stmt.merge(conn.makeOrderBy(filter.order));
|
stmt.merge(conn.makeOrderBy(filter.order));
|
|
@ -40,19 +40,32 @@ module.exports = Self => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (let ticket of tickets) {
|
for (let ticket of tickets) {
|
||||||
const fullPath = `${origin}/#!/ticket/${ticket.id}/summary`;
|
const originFullPath = `${origin}/#!/ticket/${ticket.originId}/summary`;
|
||||||
const fullPathFuture = `${origin}/#!/ticket/${ticket.ticketFuture}/summary`;
|
const destinationFullPath = `${origin}/#!/ticket/${ticket.destinationId}/summary`;
|
||||||
const message = $t('Ticket merged', {
|
const message = $t('Ticket merged', {
|
||||||
originDated: dateUtil.toString(new Date(ticket.originETD)),
|
originDated: dateUtil.toString(new Date(ticket.originShipped)),
|
||||||
futureDated: dateUtil.toString(new Date(ticket.destETD)),
|
destinationDated: dateUtil.toString(new Date(ticket.destinationShipped)),
|
||||||
id: ticket.id,
|
originId: ticket.originId,
|
||||||
tfId: ticket.ticketFuture,
|
destinationId: ticket.destinationId,
|
||||||
fullPath,
|
originFullPath,
|
||||||
fullPathFuture
|
destinationFullPath
|
||||||
});
|
});
|
||||||
if (!ticket.id || !ticket.ticketFuture) continue;
|
if (!ticket.originId || !ticket.destinationId) continue;
|
||||||
await models.Sale.updateAll({ticketFk: ticket.id}, {ticketFk: ticket.ticketFuture}, myOptions);
|
|
||||||
await models.Ticket.setDeleted(ctx, ticket.id, myOptions);
|
const ticketDestinationLogRecord = {
|
||||||
|
originFk: ticket.destinationId,
|
||||||
|
userFk: ctx.req.accessToken.userId,
|
||||||
|
action: 'update',
|
||||||
|
changedModel: 'Ticket',
|
||||||
|
changedModelId: ticket.destinationId,
|
||||||
|
changedModelValue: ticket.destinationId,
|
||||||
|
oldInstance: {},
|
||||||
|
newInstance: {mergedTicket: ticket.originId}
|
||||||
|
};
|
||||||
|
|
||||||
|
await models.TicketLog.create(ticketDestinationLogRecord, myOptions);
|
||||||
|
await models.Sale.updateAll({ticketFk: ticket.originId}, {ticketFk: ticket.destinationId}, myOptions);
|
||||||
|
await models.Ticket.setDeleted(ctx, ticket.originId, myOptions);
|
||||||
await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message);
|
await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message);
|
||||||
}
|
}
|
||||||
if (tx)
|
if (tx)
|
||||||
|
|
|
@ -107,8 +107,8 @@ describe('ticket filter()', () => {
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
const firstRow = result[0];
|
const firstRow = result[0];
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
expect(firstRow.id).toEqual(11);
|
expect(firstRow.id).toBeGreaterThan(10);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -153,7 +153,7 @@ describe('ticket filter()', () => {
|
||||||
const secondRow = result[1];
|
const secondRow = result[1];
|
||||||
const thirdRow = result[2];
|
const thirdRow = result[2];
|
||||||
|
|
||||||
expect(result.length).toEqual(17);
|
expect(result.length).toBeGreaterThan(15);
|
||||||
expect(firstRow.state).toEqual('Entregado');
|
expect(firstRow.state).toEqual('Entregado');
|
||||||
expect(secondRow.state).toEqual('Entregado');
|
expect(secondRow.state).toEqual('Entregado');
|
||||||
expect(thirdRow.state).toEqual('Entregado');
|
expect(thirdRow.state).toEqual('Entregado');
|
||||||
|
@ -175,7 +175,7 @@ describe('ticket filter()', () => {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(26);
|
expect(result.length).toBeGreaterThan(25);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -194,7 +194,7 @@ describe('ticket filter()', () => {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -213,7 +213,7 @@ describe('ticket filter()', () => {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(3);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -251,7 +251,7 @@ describe('ticket filter()', () => {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(5);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -289,7 +289,7 @@ describe('ticket filter()', () => {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(6);
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('TicketFuture getTicketsAdvance()', () => {
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
let tomorrow = new Date();
|
||||||
|
tomorrow.setDate(today.getDate() + 1);
|
||||||
|
|
||||||
|
it('should return the tickets passing the required data', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
dateFuture: tomorrow,
|
||||||
|
dateToAdvance: today,
|
||||||
|
warehouseFk: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the tickets matching the origin grouped state', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
dateFuture: tomorrow,
|
||||||
|
dateToAdvance: today,
|
||||||
|
warehouseFk: 1,
|
||||||
|
state: 'OK'
|
||||||
|
};
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the tickets matching the destination grouped state', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
dateFuture: tomorrow,
|
||||||
|
dateToAdvance: today,
|
||||||
|
warehouseFk: 1,
|
||||||
|
futureState: 'FREE'
|
||||||
|
};
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
|
expect(result.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the tickets matching the origin IPT', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
dateFuture: tomorrow,
|
||||||
|
dateToAdvance: today,
|
||||||
|
warehouseFk: 1,
|
||||||
|
ipt: 'Vertical'
|
||||||
|
};
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
|
expect(result.length).toBeLessThan(5);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the tickets matching the destination IPT', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
dateFuture: tomorrow,
|
||||||
|
dateToAdvance: today,
|
||||||
|
warehouseFk: 1,
|
||||||
|
tfIpt: 'Vertical'
|
||||||
|
};
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
|
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||||
|
|
||||||
|
expect(result.length).toBeLessThan(5);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,25 +1,22 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('TicketFuture getTicketsFuture()', () => {
|
describe('ticket getTicketsFuture()', () => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
today.setHours(0, 0, 0, 0);
|
today.setHours(0, 0, 0, 0);
|
||||||
const tomorrow = new Date(today.getDate() + 1);
|
|
||||||
|
|
||||||
it('should return the tickets passing the required data', async () => {
|
it('should return the tickets passing the required data', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toEqual(4);
|
||||||
|
@ -30,22 +27,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the problems on true', async () => {
|
it('should return the tickets matching the problems on true', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
problems: true
|
problems: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toEqual(4);
|
||||||
|
@ -57,22 +52,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the problems on false', async () => {
|
it('should return the tickets matching the problems on false', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
problems: false
|
problems: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(0);
|
||||||
|
@ -84,22 +77,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the problems on null', async () => {
|
it('should return the tickets matching the problems on null', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
problems: null
|
problems: null
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toEqual(4);
|
||||||
|
@ -111,130 +102,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the correct origin shipped', async () => {
|
it('should return the tickets matching the OK State in origin date', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
shipped: today
|
state: 'OK'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the tickets matching the an incorrect origin shipped', async () => {
|
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = { transaction: tx };
|
|
||||||
|
|
||||||
const args = {
|
|
||||||
originDated: today,
|
|
||||||
futureDated: today,
|
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
|
||||||
shipped: tomorrow
|
|
||||||
};
|
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the tickets matching the correct destination shipped', async () => {
|
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = { transaction: tx };
|
|
||||||
|
|
||||||
const args = {
|
|
||||||
originDated: today,
|
|
||||||
futureDated: today,
|
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
|
||||||
tfShipped: today
|
|
||||||
};
|
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the tickets matching the an incorrect destination shipped', async () => {
|
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = { transaction: tx };
|
|
||||||
|
|
||||||
const args = {
|
|
||||||
originDated: today,
|
|
||||||
futureDated: today,
|
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
|
||||||
tfShipped: tomorrow
|
|
||||||
};
|
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the tickets matching the OK State in origin date', async () => {
|
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = { transaction: tx };
|
|
||||||
|
|
||||||
const args = {
|
|
||||||
originDated: today,
|
|
||||||
futureDated: today,
|
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
|
||||||
state: "OK"
|
|
||||||
};
|
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
|
@ -246,22 +127,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the OK State in destination date', async () => {
|
it('should return the tickets matching the OK State in destination date', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
tfState: "OK"
|
futureState: 'OK'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toEqual(4);
|
||||||
|
@ -273,22 +152,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the correct IPT in origin date', async () => {
|
it('should return the tickets matching the correct IPT in origin date', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
ipt: null
|
ipt: null
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toEqual(4);
|
||||||
|
@ -300,22 +177,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the incorrect IPT in origin date', async () => {
|
it('should return the tickets matching the incorrect IPT in origin date', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
ipt: 0
|
ipt: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(0);
|
||||||
|
@ -327,22 +202,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the correct IPT in destination date', async () => {
|
it('should return the tickets matching the correct IPT in destination date', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
tfIpt: null
|
futureIpt: null
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toEqual(4);
|
||||||
|
@ -354,22 +227,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the incorrect IPT in destination date', async () => {
|
it('should return the tickets matching the incorrect IPT in destination date', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
tfIpt: 0
|
futureIpt: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(0);
|
||||||
|
@ -381,22 +252,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the ID in origin date', async () => {
|
it('should return the tickets matching the ID in origin date', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
id: 13
|
id: 13
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
|
@ -408,22 +277,20 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the tickets matching the ID in destination date', async () => {
|
it('should return the tickets matching the ID in destination date', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
litersMax: 9999,
|
|
||||||
linesMax: 9999,
|
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
tfId: 12
|
futureId: 12
|
||||||
};
|
};
|
||||||
|
|
||||||
const ctx = { req: { accessToken: { userId: 9 } }, args };
|
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(4);
|
expect(result.length).toEqual(4);
|
||||||
|
@ -434,5 +301,4 @@ describe('TicketFuture getTicketsFuture()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -3,15 +3,15 @@ const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('ticket merge()', () => {
|
describe('ticket merge()', () => {
|
||||||
const tickets = [{
|
const tickets = [{
|
||||||
id: 13,
|
originId: 13,
|
||||||
ticketFuture: 12,
|
destinationId: 12,
|
||||||
workerFk: 1,
|
originShipped: new Date(),
|
||||||
originETD: new Date(),
|
destinationShipped: new Date(),
|
||||||
destETD: new Date()
|
workerFk: 1
|
||||||
}];
|
}];
|
||||||
|
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: { userId: 9 },
|
accessToken: {userId: 9},
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -22,26 +22,26 @@ describe('ticket merge()', () => {
|
||||||
|
|
||||||
const ctx = {
|
const ctx = {
|
||||||
req: {
|
req: {
|
||||||
accessToken: { userId: 9 },
|
accessToken: {userId: 9},
|
||||||
headers: { origin: 'http://localhost:5000' },
|
headers: {origin: 'http://localhost:5000'},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ctx.req.__ = value => {
|
ctx.req.__ = value => {
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should merge two tickets', async () => {
|
it('should merge two tickets', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = { transaction: tx };
|
const options = {transaction: tx};
|
||||||
const chatNotificationBeforeMerge = await models.Chat.find();
|
const chatNotificationBeforeMerge = await models.Chat.find();
|
||||||
|
|
||||||
await models.Ticket.merge(ctx, tickets, options);
|
await models.Ticket.merge(ctx, tickets, options);
|
||||||
|
|
||||||
const createdTicketLog = await models.TicketLog.find({ where: { originFk: tickets[0].id } }, options);
|
const createdTicketLog = await models.TicketLog.find({where: {originFk: tickets[0].originId}}, options);
|
||||||
const deletedTicket = await models.Ticket.findOne({ where: { id: tickets[0].id } }, options);
|
const deletedTicket = await models.Ticket.findOne({where: {id: tickets[0].originId}}, options);
|
||||||
const salesTicketFuture = await models.Sale.find({ where: { ticketFk: tickets[0].ticketFuture } }, options);
|
const salesTicketFuture = await models.Sale.find({where: {ticketFk: tickets[0].destinationId}}, options);
|
||||||
const chatNotificationAfterMerge = await models.Chat.find();
|
const chatNotificationAfterMerge = await models.Chat.find();
|
||||||
|
|
||||||
expect(createdTicketLog.length).toEqual(1);
|
expect(createdTicketLog.length).toEqual(1);
|
||||||
|
|
|
@ -87,7 +87,7 @@ describe('sale priceDifference()', () => {
|
||||||
const secondtItem = result.items[1];
|
const secondtItem = result.items[1];
|
||||||
|
|
||||||
expect(firstItem.movable).toEqual(410);
|
expect(firstItem.movable).toEqual(410);
|
||||||
expect(secondtItem.movable).toEqual(1810);
|
expect(secondtItem.movable).toEqual(1790);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
"SaleTracking": {
|
"SaleTracking": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"State":{
|
"State": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Ticket": {
|
"Ticket": {
|
||||||
|
@ -71,16 +71,16 @@
|
||||||
"TicketRequest": {
|
"TicketRequest": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"TicketState":{
|
"TicketState": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"TicketLastState":{
|
"TicketLastState": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"TicketService":{
|
"TicketService": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"TicketServiceType":{
|
"TicketServiceType": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"TicketTracking": {
|
"TicketTracking": {
|
||||||
|
@ -94,8 +94,5 @@
|
||||||
},
|
},
|
||||||
"TicketConfig": {
|
"TicketConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
|
||||||
"TicketFuture": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"name": "TicketFuture",
|
|
||||||
"base": "PersistedModel",
|
|
||||||
"acls": [
|
|
||||||
{
|
|
||||||
"accessType": "READ",
|
|
||||||
"principalType": "ROLE",
|
|
||||||
"principalId": "employee",
|
|
||||||
"permission": "ALLOW"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -33,8 +33,9 @@ module.exports = function(Self) {
|
||||||
require('../methods/ticket/closeByTicket')(Self);
|
require('../methods/ticket/closeByTicket')(Self);
|
||||||
require('../methods/ticket/closeByAgency')(Self);
|
require('../methods/ticket/closeByAgency')(Self);
|
||||||
require('../methods/ticket/closeByRoute')(Self);
|
require('../methods/ticket/closeByRoute')(Self);
|
||||||
require('../methods/ticket-future/getTicketsFuture')(Self);
|
require('../methods/ticket/getTicketsFuture')(Self);
|
||||||
require('../methods/ticket/merge')(Self);
|
require('../methods/ticket/merge')(Self);
|
||||||
|
require('../methods/ticket/getTicketsAdvance')(Self);
|
||||||
require('../methods/ticket/isRoleAdvanced')(Self);
|
require('../methods/ticket/isRoleAdvanced')(Self);
|
||||||
require('../methods/ticket/collectionLabel')(Self);
|
require('../methods/ticket/collectionLabel')(Self);
|
||||||
require('../methods/ticket/expeditionPalletLabel')(Self);
|
require('../methods/ticket/expeditionPalletLabel')(Self);
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
<div class="search-panel">
|
||||||
|
<form id="manifold-form" ng-submit="$ctrl.onSearch()">
|
||||||
|
<vn-horizontal class="vn-px-lg vn-pt-lg">
|
||||||
|
<vn-date-picker
|
||||||
|
vn-one
|
||||||
|
label="Origin date"
|
||||||
|
ng-model="filter.dateFuture"
|
||||||
|
required="true">
|
||||||
|
</vn-date-picker>
|
||||||
|
<vn-date-picker
|
||||||
|
vn-one
|
||||||
|
label="Destination date"
|
||||||
|
ng-model="filter.dateToAdvance"
|
||||||
|
required="true">
|
||||||
|
</vn-date-picker>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal class="vn-px-lg">
|
||||||
|
<vn-autocomplete vn-one
|
||||||
|
data="$ctrl.itemPackingTypes"
|
||||||
|
label="Origin IPT"
|
||||||
|
value-field="code"
|
||||||
|
show-field="description"
|
||||||
|
ng-model="filter.futureIpt"
|
||||||
|
info="IPT">
|
||||||
|
<tpl-item>
|
||||||
|
{{description}}
|
||||||
|
</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete vn-one
|
||||||
|
data="$ctrl.itemPackingTypes"
|
||||||
|
label="Destination IPT"
|
||||||
|
value-field="code"
|
||||||
|
show-field="description"
|
||||||
|
ng-model="filter.ipt"
|
||||||
|
info="IPT">
|
||||||
|
<tpl-item>
|
||||||
|
{{description}}
|
||||||
|
</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal class="vn-px-lg">
|
||||||
|
<vn-autocomplete vn-one
|
||||||
|
data="$ctrl.groupedStates"
|
||||||
|
label="Origin Grouped State"
|
||||||
|
value-field="code"
|
||||||
|
show-field="name"
|
||||||
|
ng-model="filter.futureState">
|
||||||
|
<tpl-item>
|
||||||
|
{{name}}
|
||||||
|
</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete vn-one
|
||||||
|
data="$ctrl.groupedStates"
|
||||||
|
label="Destination Grouped State"
|
||||||
|
value-field="code"
|
||||||
|
show-field="name"
|
||||||
|
ng-model="filter.state">
|
||||||
|
<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"
|
||||||
|
url="Warehouses"
|
||||||
|
required="true">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal class="vn-px-lg vn-pb-lg vn-mt-lg">
|
||||||
|
<vn-submit label="Search"></vn-submit>
|
||||||
|
</vn-horizontal>
|
||||||
|
</form>
|
||||||
|
</div>
|
|
@ -0,0 +1,43 @@
|
||||||
|
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();
|
||||||
|
this.getItemPackingTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getItemPackingTypes() {
|
||||||
|
let itemPackingTypes = [];
|
||||||
|
this.$http.get('ItemPackingTypes').then(res => {
|
||||||
|
for (let ipt of res.data) {
|
||||||
|
itemPackingTypes.push({
|
||||||
|
code: ipt.code,
|
||||||
|
description: this.$t(ipt.description)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.itemPackingTypes = itemPackingTypes;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnAdvanceTicketSearchPanel', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
|
@ -0,0 +1 @@
|
||||||
|
Advance tickets: Advance tickets
|
|
@ -0,0 +1 @@
|
||||||
|
Advance tickets: Adelantar tickets
|
|
@ -0,0 +1,160 @@
|
||||||
|
<vn-crud-model
|
||||||
|
vn-id="model"
|
||||||
|
url="Tickets/getTicketsAdvance"
|
||||||
|
auto-load="false">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-portal slot="topbar">
|
||||||
|
<vn-searchbar
|
||||||
|
vn-focus
|
||||||
|
panel="vn-advance-ticket-search-panel"
|
||||||
|
placeholder="Search tickets"
|
||||||
|
info="Search advance tickets by date"
|
||||||
|
suggested-filter="$ctrl.filterParams"
|
||||||
|
auto-state="false"
|
||||||
|
model="model">
|
||||||
|
</vn-searchbar>
|
||||||
|
</vn-portal>
|
||||||
|
<vn-card>
|
||||||
|
<smart-table
|
||||||
|
model="model"
|
||||||
|
options="$ctrl.smartTableOptions"
|
||||||
|
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||||
|
>
|
||||||
|
<slot-actions>
|
||||||
|
<vn-button disabled="$ctrl.checked.length === 0"
|
||||||
|
icon="keyboard_double_arrow_left"
|
||||||
|
ng-click="moveTicketsAdvance.show($event)"
|
||||||
|
vn-tooltip="Advance tickets">
|
||||||
|
</vn-button>
|
||||||
|
</slot-actions>
|
||||||
|
<slot-table>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr second-header>
|
||||||
|
<td></td>
|
||||||
|
<th colspan="5" translate>Origin</th>
|
||||||
|
<th colspan="8" translate>Destination</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th shrink>
|
||||||
|
<vn-multi-check
|
||||||
|
model="model"
|
||||||
|
checked="$ctrl.checkAll"
|
||||||
|
check-field="checked">
|
||||||
|
</vn-multi-check>
|
||||||
|
</th>
|
||||||
|
<th field="futureId">
|
||||||
|
<span translate>ID</span>
|
||||||
|
</th>
|
||||||
|
<th field="futureShipped">
|
||||||
|
<span translate>Date</span>
|
||||||
|
</th>
|
||||||
|
<th field="futureIpt" title="Item Packing Type">
|
||||||
|
<span>IPT</span>
|
||||||
|
</th>
|
||||||
|
<th field="futureState">
|
||||||
|
<span translate>State</span>
|
||||||
|
</th>
|
||||||
|
<th field="totalWithVat">
|
||||||
|
<span translate>Import</span>
|
||||||
|
</th>
|
||||||
|
<th separator field="id">
|
||||||
|
<span translate>ID</span>
|
||||||
|
</th>
|
||||||
|
<th field="shipped">
|
||||||
|
<span translate>Date</span>
|
||||||
|
</th>
|
||||||
|
<th field="ipt" title="Item Packing Type">
|
||||||
|
<span>IPT</span>
|
||||||
|
</th>
|
||||||
|
<th field="state">
|
||||||
|
<span translate>State</span>
|
||||||
|
</th>
|
||||||
|
<th field="liters">
|
||||||
|
<span translate>Liters</span>
|
||||||
|
</th>
|
||||||
|
<th field="hasStock">
|
||||||
|
<span>Stock</span>
|
||||||
|
</th>
|
||||||
|
<th field="lines">
|
||||||
|
<span translate>Lines</span>
|
||||||
|
</th>
|
||||||
|
<th field="futureTotalWithVat">
|
||||||
|
<span translate>Import</span>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="ticket in model.data">
|
||||||
|
<td>
|
||||||
|
<vn-check
|
||||||
|
ng-model="ticket.checked"
|
||||||
|
vn-click-stop>
|
||||||
|
</vn-check>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span
|
||||||
|
ng-click="ticketDescriptor.show($event, ticket.futureId)"
|
||||||
|
class="link">
|
||||||
|
{{::ticket.futureId | dashIfEmpty}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td shrink-date>
|
||||||
|
<span class="chip {{$ctrl.compareDate(ticket.futureShipped)}}">
|
||||||
|
{{::ticket.futureShipped | date: 'dd/MM/yyyy'}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>{{::ticket.futureIpt | dashIfEmpty}}</td>
|
||||||
|
<td>
|
||||||
|
<span
|
||||||
|
class="chip {{$ctrl.stateColor(ticket.futureState)}}">
|
||||||
|
{{::ticket.futureState | dashIfEmpty}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="chip {{$ctrl.totalPriceColor(ticket.futureTotalWithVat)}}">
|
||||||
|
{{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span
|
||||||
|
ng-click="ticketDescriptor.show($event, ticket.id)"
|
||||||
|
class="link">
|
||||||
|
{{::ticket.id | dashIfEmpty}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td shrink-date>
|
||||||
|
<span class="chip {{$ctrl.compareDate(ticket.shipped)}}">
|
||||||
|
{{::ticket.shipped | date: 'dd/MM/yyyy'}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>{{::ticket.ipt | dashIfEmpty}}</td>
|
||||||
|
<td>
|
||||||
|
<span
|
||||||
|
class="chip {{$ctrl.stateColor(ticket.state)}}">
|
||||||
|
{{::ticket.state | dashIfEmpty}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>{{::ticket.liters | dashIfEmpty}}</td>
|
||||||
|
<td>{{::ticket.hasStock | dashIfEmpty}}</td>
|
||||||
|
<td>{{::ticket.lines | dashIfEmpty}}</td>
|
||||||
|
<td>
|
||||||
|
<span class="chip {{$ctrl.totalPriceColor(ticket.totalWithVat)}}">
|
||||||
|
{{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</slot-table>
|
||||||
|
</smart-table>
|
||||||
|
</vn-card>
|
||||||
|
<vn-confirm
|
||||||
|
vn-id="moveTicketsAdvance"
|
||||||
|
on-accept="$ctrl.moveTicketsAdvance()"
|
||||||
|
question="{{$ctrl.confirmationMessage}}"
|
||||||
|
message="Advance tickets">
|
||||||
|
</vn-confirm>
|
||||||
|
<vn-ticket-descriptor-popover
|
||||||
|
vn-id="ticketDescriptor">
|
||||||
|
</vn-ticket-descriptor-popover>
|
|
@ -0,0 +1,177 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
export default class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
this.$checkAll = false;
|
||||||
|
|
||||||
|
this.smartTableOptions = {
|
||||||
|
activeButtons: {
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'state',
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'futureState',
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalWithVat',
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'futureTotalWithVat',
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'shipped',
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'futureShipped',
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'ipt',
|
||||||
|
autocomplete: {
|
||||||
|
url: 'ItemPackingTypes',
|
||||||
|
showField: 'description',
|
||||||
|
valueField: 'code'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'futureIpt',
|
||||||
|
autocomplete: {
|
||||||
|
url: 'ItemPackingTypes',
|
||||||
|
showField: 'description',
|
||||||
|
valueField: 'code'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$postLink() {
|
||||||
|
this.setDefaultFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
setDefaultFilter() {
|
||||||
|
let today = new Date();
|
||||||
|
const tomorrow = new Date(today);
|
||||||
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||||
|
this.filterParams = {
|
||||||
|
dateFuture: tomorrow,
|
||||||
|
dateToAdvance: today,
|
||||||
|
warehouseFk: this.vnConfig.warehouseFk
|
||||||
|
};
|
||||||
|
this.$.model.applyFilter(null, this.filterParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
compareDate(date) {
|
||||||
|
let today = new Date();
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
|
||||||
|
get checked() {
|
||||||
|
const tickets = this.$.model.data || [];
|
||||||
|
const checkedLines = [];
|
||||||
|
for (let ticket of tickets) {
|
||||||
|
if (ticket.checked)
|
||||||
|
checkedLines.push(ticket);
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkedLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
stateColor(state) {
|
||||||
|
if (state === 'OK')
|
||||||
|
return 'success';
|
||||||
|
else if (state === 'Libre')
|
||||||
|
return 'notice';
|
||||||
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
|
totalPriceColor(totalWithVat) {
|
||||||
|
const total = parseInt(totalWithVat);
|
||||||
|
if (total > 0 && total < 50)
|
||||||
|
return 'warning';
|
||||||
|
}
|
||||||
|
|
||||||
|
get confirmationMessage() {
|
||||||
|
if (!this.$.model) return 0;
|
||||||
|
|
||||||
|
return this.$t(`Advance confirmation`, {
|
||||||
|
checked: this.checked.length
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
moveTicketsAdvance() {
|
||||||
|
let ticketsToMove = [];
|
||||||
|
this.checked.forEach(ticket => {
|
||||||
|
ticketsToMove.push({
|
||||||
|
originId: ticket.futureId,
|
||||||
|
destinationId: ticket.id,
|
||||||
|
originShipped: ticket.futureShipped,
|
||||||
|
destinationShipped: ticket.shipped,
|
||||||
|
workerFk: ticket.workerFk
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const params = {tickets: ticketsToMove};
|
||||||
|
return this.$http.post('Tickets/merge', params)
|
||||||
|
.then(() => {
|
||||||
|
this.$.model.refresh();
|
||||||
|
this.vnApp.showSuccess(this.$t('Success'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
exprBuilder(param, value) {
|
||||||
|
switch (param) {
|
||||||
|
case 'id':
|
||||||
|
return {'id': value};
|
||||||
|
case 'futureId':
|
||||||
|
return {'futureId': value};
|
||||||
|
case 'liters':
|
||||||
|
return {'liters': value};
|
||||||
|
case 'lines':
|
||||||
|
return {'lines': value};
|
||||||
|
case 'ipt':
|
||||||
|
return {'ipt': value};
|
||||||
|
case 'futureIpt':
|
||||||
|
return {'futureIpt': value};
|
||||||
|
case 'totalWithVat':
|
||||||
|
return {'totalWithVat': value};
|
||||||
|
case 'futureTotalWithVat':
|
||||||
|
return {'futureTotalWithVat': value};
|
||||||
|
case 'hasStock':
|
||||||
|
return {'hasStock': value};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.$inject = ['$element', '$scope'];
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnTicketAdvance', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
|
@ -0,0 +1,113 @@
|
||||||
|
import './index.js';
|
||||||
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
|
describe('Component vnTicketAdvance', () => {
|
||||||
|
let controller;
|
||||||
|
let $httpBackend;
|
||||||
|
|
||||||
|
beforeEach(ngModule('ticket')
|
||||||
|
);
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
const $element = angular.element('<vn-ticket-advance></vn-ticket-advance>');
|
||||||
|
controller = $componentController('vnTicketAdvance', {$element});
|
||||||
|
controller.$.model = crudModel;
|
||||||
|
controller.$.model.data = [{
|
||||||
|
id: 1,
|
||||||
|
checked: true,
|
||||||
|
state: 'OK'
|
||||||
|
}, {
|
||||||
|
id: 2,
|
||||||
|
checked: true,
|
||||||
|
state: 'Libre'
|
||||||
|
}];
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('compareDate()', () => {
|
||||||
|
it('should return warning when the date is the present', () => {
|
||||||
|
let today = new Date();
|
||||||
|
let result = controller.compareDate(today);
|
||||||
|
|
||||||
|
expect(result).toEqual('warning');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return sucess when the date is in the future', () => {
|
||||||
|
let futureDate = new Date();
|
||||||
|
futureDate = futureDate.setDate(futureDate.getDate() + 10);
|
||||||
|
let result = controller.compareDate(futureDate);
|
||||||
|
|
||||||
|
expect(result).toEqual('success');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return undefined when the date is in the past', () => {
|
||||||
|
let pastDate = new Date();
|
||||||
|
pastDate = pastDate.setDate(pastDate.getDate() - 10);
|
||||||
|
let result = controller.compareDate(pastDate);
|
||||||
|
|
||||||
|
expect(result).toEqual(undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('checked()', () => {
|
||||||
|
it('should return an array of checked tickets', () => {
|
||||||
|
const result = controller.checked;
|
||||||
|
const firstRow = result[0];
|
||||||
|
const secondRow = result[1];
|
||||||
|
|
||||||
|
expect(result.length).toEqual(2);
|
||||||
|
expect(firstRow.id).toEqual(1);
|
||||||
|
expect(secondRow.id).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('stateColor()', () => {
|
||||||
|
it('should return success to the OK tickets', () => {
|
||||||
|
const ok = controller.stateColor(controller.$.model.data[0].state);
|
||||||
|
const notOk = controller.stateColor(controller.$.model.data[1].state);
|
||||||
|
|
||||||
|
expect(ok).toEqual('success');
|
||||||
|
expect(notOk).not.toEqual('success');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return success to the FREE tickets', () => {
|
||||||
|
const notFree = controller.stateColor(controller.$.model.data[0].state);
|
||||||
|
const free = controller.stateColor(controller.$.model.data[1].state);
|
||||||
|
|
||||||
|
expect(free).toEqual('notice');
|
||||||
|
expect(notFree).not.toEqual('notice');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('dateRange()', () => {
|
||||||
|
it('should return two dates with the hours at the start and end of the given date', () => {
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
const today = now.getDate();
|
||||||
|
|
||||||
|
const dateRange = controller.dateRange(now);
|
||||||
|
const start = dateRange[0].toString();
|
||||||
|
const end = dateRange[1].toString();
|
||||||
|
|
||||||
|
expect(start).toContain(today);
|
||||||
|
expect(start).toContain('00:00:00');
|
||||||
|
|
||||||
|
expect(end).toContain(today);
|
||||||
|
expect(end).toContain('23:59:59');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('moveTicketsAdvance()', () => {
|
||||||
|
it('should make an HTTP Post query', () => {
|
||||||
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
|
$httpBackend.expectPOST(`Tickets/merge`).respond();
|
||||||
|
controller.moveTicketsAdvance();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
||||||
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,2 @@
|
||||||
|
Advance tickets: Advance tickets
|
||||||
|
Success: Tickets moved successfully!
|
|
@ -0,0 +1,6 @@
|
||||||
|
Advance tickets: Adelantar tickets
|
||||||
|
Search advance tickets by date: Busca tickets para adelantar por fecha
|
||||||
|
Advance confirmation: ¿Desea adelantar {{checked}} tickets?
|
||||||
|
Success: Tickets movidos correctamente
|
||||||
|
Lines: Líneas
|
||||||
|
Liters: Litros
|
|
@ -280,10 +280,11 @@
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
|
|
||||||
<!-- Send SMS popup -->
|
<!-- Send SMS popup -->
|
||||||
<vn-ticket-sms
|
<vn-sms-dialog
|
||||||
vn-id="sms"
|
vn-id="sms"
|
||||||
|
on-send="$ctrl.onSmsSend($sms)"
|
||||||
sms="$ctrl.newSMS">
|
sms="$ctrl.newSMS">
|
||||||
</vn-ticket-sms>
|
</vn-sms-dialog>
|
||||||
|
|
||||||
<!-- Make invoice confirmation dialog -->
|
<!-- Make invoice confirmation dialog -->
|
||||||
<vn-confirm
|
<vn-confirm
|
||||||
|
|
|
@ -239,6 +239,7 @@ class Controller extends Section {
|
||||||
destinationFk: this.ticket.clientFk,
|
destinationFk: this.ticket.clientFk,
|
||||||
destination: phone
|
destination: phone
|
||||||
}, params);
|
}, params);
|
||||||
|
|
||||||
this.$.sms.open();
|
this.$.sms.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,6 +295,11 @@ class Controller extends Section {
|
||||||
this.$state.go('ticket.card.sale', {id: refundTicket.id});
|
this.$state.go('ticket.card.sale', {id: refundTicket.id});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSmsSend(sms) {
|
||||||
|
return this.$http.post(`Tickets/${this.id}/sendSms`, sms)
|
||||||
|
.then(() => this.vnApp.showSuccess(this.$t('SMS sent')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
|
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
|
||||||
|
|
|
@ -261,11 +261,8 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
||||||
describe('showSMSDialog()', () => {
|
describe('showSMSDialog()', () => {
|
||||||
it('should set the destionationFk and destination properties and then call the sms open() method', () => {
|
it('should set the destionationFk and destination properties and then call the sms open() method', () => {
|
||||||
controller.$.sms = {open: () => {}};
|
controller.$.sms = {open: () => {}};
|
||||||
jest.spyOn(controller.$.sms, 'open');
|
|
||||||
|
|
||||||
controller.showSMSDialog();
|
controller.showSMSDialog();
|
||||||
|
|
||||||
expect(controller.$.sms.open).toHaveBeenCalledWith();
|
|
||||||
expect(controller.newSMS).toEqual({
|
expect(controller.newSMS).toEqual({
|
||||||
destinationFk: ticket.clientFk,
|
destinationFk: ticket.clientFk,
|
||||||
destination: ticket.address.mobile,
|
destination: ticket.address.mobile,
|
||||||
|
|
|
@ -4,43 +4,26 @@
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
vn-one
|
vn-one
|
||||||
label="Origin date"
|
label="Origin date"
|
||||||
ng-model="filter.shipped"
|
ng-model="filter.originDated"
|
||||||
on-change="$ctrl.from = value">
|
required="true">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
vn-one
|
vn-one
|
||||||
label="Destination date"
|
label="Destination date"
|
||||||
ng-model="filter.tfShipped">
|
|
||||||
</vn-date-picker>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal class="vn-px-lg">
|
|
||||||
<vn-date-picker
|
|
||||||
vn-one
|
|
||||||
label="Origin ETD"
|
|
||||||
ng-model="filter.originDated"
|
|
||||||
required="true"
|
|
||||||
info="ETD">
|
|
||||||
</vn-date-picker>
|
|
||||||
<vn-date-picker
|
|
||||||
vn-one
|
|
||||||
label="Destination ETD"
|
|
||||||
ng-model="filter.futureDated"
|
ng-model="filter.futureDated"
|
||||||
required="true"
|
required="true">
|
||||||
info="ETD">
|
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="vn-px-lg">
|
<vn-horizontal class="vn-px-lg">
|
||||||
<vn-textfield
|
|
||||||
vn-one
|
|
||||||
label="Max Lines"
|
|
||||||
ng-model="filter.linesMax"
|
|
||||||
required="true">
|
|
||||||
</vn-textfield>
|
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
vn-one
|
vn-one
|
||||||
label="Max Liters"
|
label="Max Liters"
|
||||||
ng-model="filter.litersMax"
|
ng-model="filter.litersMax">
|
||||||
required="true">
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Max Lines"
|
||||||
|
ng-model="filter.linesMax">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="vn-px-lg">
|
<vn-horizontal class="vn-px-lg">
|
||||||
|
@ -48,22 +31,22 @@
|
||||||
data="$ctrl.itemPackingTypes"
|
data="$ctrl.itemPackingTypes"
|
||||||
label="Origin IPT"
|
label="Origin IPT"
|
||||||
value-field="code"
|
value-field="code"
|
||||||
show-field="name"
|
show-field="description"
|
||||||
ng-model="filter.ipt"
|
ng-model="filter.ipt"
|
||||||
info="IPT">
|
info="IPT">
|
||||||
<tpl-item>
|
<tpl-item>
|
||||||
{{name}}
|
{{description}}
|
||||||
</tpl-item>
|
</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
data="$ctrl.itemPackingTypes"
|
data="$ctrl.itemPackingTypes"
|
||||||
label="Destination IPT"
|
label="Destination IPT"
|
||||||
value-field="code"
|
value-field="code"
|
||||||
show-field="name"
|
show-field="description"
|
||||||
ng-model="filter.tfIpt"
|
ng-model="filter.futureIpt"
|
||||||
info="IPT">
|
info="IPT">
|
||||||
<tpl-item>
|
<tpl-item>
|
||||||
{{name}}
|
{{description}}
|
||||||
</tpl-item>
|
</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
@ -83,7 +66,7 @@
|
||||||
label="Destination Grouped State"
|
label="Destination Grouped State"
|
||||||
value-field="code"
|
value-field="code"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
ng-model="filter.tfState">
|
ng-model="filter.futureState">
|
||||||
<tpl-item>
|
<tpl-item>
|
||||||
{{name}}
|
{{name}}
|
||||||
</tpl-item>
|
</tpl-item>
|
||||||
|
|
|
@ -28,9 +28,8 @@ class Controller extends SearchPanel {
|
||||||
this.$http.get('ItemPackingTypes').then(res => {
|
this.$http.get('ItemPackingTypes').then(res => {
|
||||||
for (let ipt of res.data) {
|
for (let ipt of res.data) {
|
||||||
itemPackingTypes.push({
|
itemPackingTypes.push({
|
||||||
id: ipt.id,
|
description: this.$t(ipt.description),
|
||||||
code: ipt.code,
|
code: ipt.code,
|
||||||
name: this.$t(ipt.code)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.itemPackingTypes = itemPackingTypes;
|
this.itemPackingTypes = itemPackingTypes;
|
||||||
|
|
|
@ -1,9 +1 @@
|
||||||
Future tickets: Tickets a futuro
|
Future tickets: Tickets a futuro
|
||||||
FREE: Free
|
|
||||||
DELIVERED: Delivered
|
|
||||||
ON_PREPARATION: On preparation
|
|
||||||
PACKED: Packed
|
|
||||||
F: Fruits and vegetables
|
|
||||||
V: Vertical
|
|
||||||
H: Horizontal
|
|
||||||
P: Feed
|
|
||||||
|
|
|
@ -11,13 +11,4 @@ With problems: Con problemas
|
||||||
Warehouse: Almacén
|
Warehouse: Almacén
|
||||||
Origin Grouped State: Estado agrupado origen
|
Origin Grouped State: Estado agrupado origen
|
||||||
Destination Grouped State: Estado agrupado destino
|
Destination Grouped State: Estado agrupado destino
|
||||||
FREE: Libre
|
|
||||||
DELIVERED: Servido
|
|
||||||
ON_PREPARATION: En preparacion
|
|
||||||
PACKED: Encajado
|
|
||||||
F: Frutas y verduras
|
|
||||||
V: Vertical
|
|
||||||
H: Horizontal
|
|
||||||
P: Pienso
|
|
||||||
ETD: Tiempo estimado de entrega
|
|
||||||
IPT: Encajado
|
IPT: Encajado
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="Tickets/getTicketsFuture"
|
url="Tickets/getTicketsFuture"
|
||||||
limit="20">
|
auto-load="false">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-portal slot="topbar">
|
<vn-portal slot="topbar">
|
||||||
<vn-searchbar
|
<vn-searchbar
|
||||||
|
@ -30,6 +30,11 @@
|
||||||
<slot-table>
|
<slot-table>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
<tr second-header>
|
||||||
|
<td></td>
|
||||||
|
<th colspan="7" translate>Origin</th>
|
||||||
|
<th colspan="4" translate>Destination</th>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th shrink>
|
<th shrink>
|
||||||
<vn-multi-check
|
<vn-multi-check
|
||||||
|
@ -38,39 +43,39 @@
|
||||||
check-field="checked">
|
check-field="checked">
|
||||||
</vn-multi-check>
|
</vn-multi-check>
|
||||||
</th>
|
</th>
|
||||||
<th field="problems">
|
<th field="totalProblems">
|
||||||
<span translate>Problems</span>
|
<span translate>Problems</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="id">
|
<th field="id">
|
||||||
<span translate>Origin ID</span>
|
<span translate>ID</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="originETD">
|
<th field="shipped">
|
||||||
<span translate>Origin ETD</span>
|
<span translate>Date</span>
|
||||||
|
</th>
|
||||||
|
<th field="ipt" title="Item Packing Type">
|
||||||
|
<span>IPT</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="state">
|
<th field="state">
|
||||||
<span translate>Origin State</span>
|
<span translate>State</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="ipt">
|
<th field="liters">
|
||||||
<span>IPT</span>
|
|
||||||
</th>
|
|
||||||
<th field="litersMax">
|
|
||||||
<span translate>Liters</span>
|
<span translate>Liters</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="linesMax">
|
<th shrink field="lines">
|
||||||
<span translate>Available Lines</span>
|
<span translate>Available Lines</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="ticketFuture">
|
<th field="futureId" separator>
|
||||||
<span translate>Destination ID</span>
|
<span translate>ID</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="destETD">
|
<th field="futureShipped">
|
||||||
<span translate>Destination ETD</span>
|
<span translate>Date</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="tfState">
|
<th field="futureIpt" title="Item Packing Type">
|
||||||
<span translate>Destination State</span>
|
|
||||||
</th>
|
|
||||||
<th field="tfIpt">
|
|
||||||
<span>IPT</span>
|
<span>IPT</span>
|
||||||
</th>
|
</th>
|
||||||
|
<th shrink field="futureState">
|
||||||
|
<span translate>State</span>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -125,38 +130,38 @@
|
||||||
{{::ticket.id}}
|
{{::ticket.id}}
|
||||||
</span></td>
|
</span></td>
|
||||||
<td shrink-date>
|
<td shrink-date>
|
||||||
<span class="chip {{$ctrl.compareDate(ticket.originETD)}}">
|
<span class="chip {{$ctrl.compareDate(ticket.shipped)}}">
|
||||||
{{::ticket.originETD | date: 'dd/MM/yyyy'}}
|
{{::ticket.shipped | date: 'dd/MM/yyyy'}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>{{::ticket.ipt}}</td>
|
||||||
<td>
|
<td>
|
||||||
<span
|
<span
|
||||||
class="chip {{$ctrl.stateColor(ticket.state)}}">
|
class="chip {{$ctrl.stateColor(ticket.state)}}">
|
||||||
{{::ticket.state}}
|
{{::ticket.state}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{::ticket.ipt}}</td>
|
|
||||||
<td>{{::ticket.liters}}</td>
|
<td>{{::ticket.liters}}</td>
|
||||||
<td>{{::ticket.lines}}</td>
|
<td>{{::ticket.lines}}</td>
|
||||||
<td>
|
<td>
|
||||||
<span
|
<span
|
||||||
ng-click="ticketDescriptor.show($event, ticket.ticketFuture)"
|
ng-click="ticketDescriptor.show($event, ticket.futureId)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::ticket.ticketFuture}}
|
{{::ticket.futureId}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td shrink-date>
|
<td shrink-date>
|
||||||
<span class="chip {{$ctrl.compareDate(ticket.destETD)}}">
|
<span class="chip {{$ctrl.compareDate(ticket.futureShipped)}}">
|
||||||
{{::ticket.destETD | date: 'dd/MM/yyyy'}}
|
{{::ticket.futureShipped | date: 'dd/MM/yyyy'}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>{{::ticket.futureIpt}}</td>
|
||||||
<td>
|
<td>
|
||||||
<span
|
<span
|
||||||
class="chip {{$ctrl.stateColor(ticket.tfState)}}">
|
class="chip {{$ctrl.stateColor(ticket.futureState)}}">
|
||||||
{{::ticket.tfState}}
|
{{::ticket.futureState}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{::ticket.tfIpt}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -11,15 +11,15 @@ export default class Controller extends Section {
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
columns: [{
|
columns: [{
|
||||||
field: 'problems',
|
field: 'totalProblems',
|
||||||
|
searchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'shipped',
|
||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'originETD',
|
field: 'futureShipped',
|
||||||
searchable: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'destETD',
|
|
||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ export default class Controller extends Section {
|
||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'tfState',
|
field: 'futureState',
|
||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'tfIpt',
|
field: 'futureIpt',
|
||||||
autocomplete: {
|
autocomplete: {
|
||||||
url: 'ItemPackingTypes',
|
url: 'ItemPackingTypes',
|
||||||
showField: 'description',
|
showField: 'description',
|
||||||
|
@ -48,6 +48,9 @@ export default class Controller extends Section {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$postLink() {
|
||||||
this.setDefaultFilter();
|
this.setDefaultFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +60,9 @@ export default class Controller extends Section {
|
||||||
this.filterParams = {
|
this.filterParams = {
|
||||||
originDated: today,
|
originDated: today,
|
||||||
futureDated: today,
|
futureDated: today,
|
||||||
linesMax: '9999',
|
warehouseFk: this.vnConfig.warehouseFk
|
||||||
litersMax: '9999',
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
};
|
||||||
|
this.$.model.applyFilter(null, this.filterParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
compareDate(date) {
|
compareDate(date) {
|
||||||
|
@ -113,7 +115,17 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
moveTicketsFuture() {
|
moveTicketsFuture() {
|
||||||
let params = { tickets: this.checked };
|
let ticketsToMove = [];
|
||||||
|
this.checked.forEach(ticket => {
|
||||||
|
ticketsToMove.push({
|
||||||
|
originId: ticket.id,
|
||||||
|
destinationId: ticket.futureId,
|
||||||
|
originShipped: ticket.shipped,
|
||||||
|
destinationShipped: ticket.futureShipped,
|
||||||
|
workerFk: ticket.workerFk
|
||||||
|
});
|
||||||
|
});
|
||||||
|
let params = {tickets: ticketsToMove};
|
||||||
return this.$http.post('Tickets/merge', params)
|
return this.$http.post('Tickets/merge', params)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$.model.refresh();
|
this.$.model.refresh();
|
||||||
|
@ -124,17 +136,17 @@ export default class Controller extends Section {
|
||||||
exprBuilder(param, value) {
|
exprBuilder(param, value) {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'id':
|
case 'id':
|
||||||
return { 'id': value };
|
return {'id': value};
|
||||||
case 'ticketFuture':
|
case 'futureId':
|
||||||
return { 'ticketFuture': value };
|
return {'futureId': value};
|
||||||
case 'litersMax':
|
case 'liters':
|
||||||
return { 'liters': value };
|
return {'liters': value};
|
||||||
case 'linesMax':
|
case 'lines':
|
||||||
return { 'lines': value };
|
return {'lines': value};
|
||||||
case 'ipt':
|
case 'ipt':
|
||||||
return { 'ipt': value };
|
return {'ipt': value};
|
||||||
case 'tfIpt':
|
case 'futureIpt':
|
||||||
return { 'tfIpt': value };
|
return {'futureIpt': value};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,33 +2,30 @@ import './index.js';
|
||||||
import crudModel from 'core/mocks/crud-model';
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
describe('Component vnTicketFuture', () => {
|
describe('Component vnTicketFuture', () => {
|
||||||
|
const today = new Date();
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
let $window;
|
|
||||||
|
|
||||||
beforeEach(ngModule('ticket')
|
beforeEach(ngModule('ticket'));
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(inject(($componentController, _$window_, _$httpBackend_) => {
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$window = _$window_;
|
|
||||||
const $element = angular.element('<vn-ticket-future></vn-ticket-future>');
|
const $element = angular.element('<vn-ticket-future></vn-ticket-future>');
|
||||||
controller = $componentController('vnTicketFuture', { $element });
|
controller = $componentController('vnTicketFuture', {$element});
|
||||||
controller.$.model = crudModel;
|
controller.$.model = crudModel;
|
||||||
controller.$.model.data = [{
|
controller.$.model.data = [{
|
||||||
id: 1,
|
id: 1,
|
||||||
checked: true,
|
checked: true,
|
||||||
state: "OK"
|
state: 'OK'
|
||||||
}, {
|
}, {
|
||||||
id: 2,
|
id: 2,
|
||||||
checked: true,
|
checked: true,
|
||||||
state: "Libre"
|
state: 'Libre'
|
||||||
}];
|
}];
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('compareDate()', () => {
|
describe('compareDate()', () => {
|
||||||
it('should return warning when the date is the present', () => {
|
it('should return warning when the date is the present', () => {
|
||||||
let today = new Date();
|
|
||||||
let result = controller.compareDate(today);
|
let result = controller.compareDate(today);
|
||||||
|
|
||||||
expect(result).toEqual('warning');
|
expect(result).toEqual('warning');
|
||||||
|
@ -67,6 +64,7 @@ describe('Component vnTicketFuture', () => {
|
||||||
it('should return success to the OK tickets', () => {
|
it('should return success to the OK tickets', () => {
|
||||||
const ok = controller.stateColor(controller.$.model.data[0].state);
|
const ok = controller.stateColor(controller.$.model.data[0].state);
|
||||||
const notOk = controller.stateColor(controller.$.model.data[1].state);
|
const notOk = controller.stateColor(controller.$.model.data[1].state);
|
||||||
|
|
||||||
expect(ok).toEqual('success');
|
expect(ok).toEqual('success');
|
||||||
expect(notOk).not.toEqual('success');
|
expect(notOk).not.toEqual('success');
|
||||||
});
|
});
|
||||||
|
@ -74,6 +72,7 @@ describe('Component vnTicketFuture', () => {
|
||||||
it('should return success to the FREE tickets', () => {
|
it('should return success to the FREE tickets', () => {
|
||||||
const notFree = controller.stateColor(controller.$.model.data[0].state);
|
const notFree = controller.stateColor(controller.$.model.data[0].state);
|
||||||
const free = controller.stateColor(controller.$.model.data[1].state);
|
const free = controller.stateColor(controller.$.model.data[1].state);
|
||||||
|
|
||||||
expect(free).toEqual('notice');
|
expect(free).toEqual('notice');
|
||||||
expect(notFree).not.toEqual('notice');
|
expect(notFree).not.toEqual('notice');
|
||||||
});
|
});
|
||||||
|
@ -81,18 +80,14 @@ describe('Component vnTicketFuture', () => {
|
||||||
|
|
||||||
describe('dateRange()', () => {
|
describe('dateRange()', () => {
|
||||||
it('should return two dates with the hours at the start and end of the given date', () => {
|
it('should return two dates with the hours at the start and end of the given date', () => {
|
||||||
const now = new Date();
|
const dateRange = controller.dateRange(today);
|
||||||
|
|
||||||
const today = now.getDate();
|
|
||||||
|
|
||||||
const dateRange = controller.dateRange(now);
|
|
||||||
const start = dateRange[0].toString();
|
const start = dateRange[0].toString();
|
||||||
const end = dateRange[1].toString();
|
const end = dateRange[1].toString();
|
||||||
|
|
||||||
expect(start).toContain(today);
|
expect(start).toContain(today.getDate());
|
||||||
expect(start).toContain('00:00:00');
|
expect(start).toContain('00:00:00');
|
||||||
|
|
||||||
expect(end).toContain(today);
|
expect(end).toContain(today.getDate());
|
||||||
expect(end).toContain('23:59:59');
|
expect(end).toContain('23:59:59');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,2 @@
|
||||||
Move confirmation: Do you want to move {{checked}} tickets to the future?
|
Move confirmation: Do you want to move {{checked}} tickets to the future?
|
||||||
FREE: Free
|
|
||||||
DELIVERED: Delivered
|
|
||||||
ON_PREPARATION: On preparation
|
|
||||||
PACKED: Packed
|
|
||||||
Success: Tickets moved successfully!
|
Success: Tickets moved successfully!
|
||||||
|
|
|
@ -3,20 +3,14 @@ Search tickets: Buscar tickets
|
||||||
Search future tickets by date: Buscar tickets por fecha
|
Search future tickets by date: Buscar tickets por fecha
|
||||||
Problems: Problemas
|
Problems: Problemas
|
||||||
Origin ID: ID origen
|
Origin ID: ID origen
|
||||||
Closing: Cierre
|
|
||||||
Origin State: Estado origen
|
Origin State: Estado origen
|
||||||
Destination State: Estado destino
|
Destination State: Estado destino
|
||||||
Liters: Litros
|
Liters: Litros
|
||||||
Available Lines: Líneas disponibles
|
Available Lines: Líneas disponibles
|
||||||
Destination ID: ID destino
|
Destination ID: ID destino
|
||||||
Destination ETD: ETD Destino
|
|
||||||
Origin ETD: ETD Origen
|
|
||||||
Move tickets: Mover tickets
|
Move tickets: Mover tickets
|
||||||
Move confirmation: ¿Desea mover {{checked}} tickets hacia el futuro?
|
Move confirmation: ¿Desea mover {{checked}} tickets hacia el futuro?
|
||||||
Success: Tickets movidos correctamente
|
Success: Tickets movidos correctamente
|
||||||
ETD: Tiempo estimado de entrega
|
|
||||||
IPT: Encajado
|
IPT: Encajado
|
||||||
FREE: Libre
|
Origin Date: Fecha origen
|
||||||
DELIVERED: Servido
|
Destination Date: Fecha destino
|
||||||
ON_PREPARATION: En preparacion
|
|
||||||
PACKED: Encajado
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ import './weekly';
|
||||||
import './dms/index';
|
import './dms/index';
|
||||||
import './dms/create';
|
import './dms/create';
|
||||||
import './dms/edit';
|
import './dms/edit';
|
||||||
import './sms';
|
|
||||||
import './boxing';
|
import './boxing';
|
||||||
import './future';
|
import './future';
|
||||||
import './future-search-panel';
|
import './future-search-panel';
|
||||||
|
import './advance';
|
||||||
|
import './advance-search-panel';
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
"main": [
|
"main": [
|
||||||
{"state": "ticket.index", "icon": "icon-ticket"},
|
{"state": "ticket.index", "icon": "icon-ticket"},
|
||||||
{"state": "ticket.weekly.index", "icon": "schedule"},
|
{"state": "ticket.weekly.index", "icon": "schedule"},
|
||||||
{"state": "ticket.future", "icon": "keyboard_double_arrow_right"}
|
{"state": "ticket.future", "icon": "keyboard_double_arrow_right"},
|
||||||
|
{"state": "ticket.advance", "icon": "keyboard_double_arrow_left"}
|
||||||
],
|
],
|
||||||
"card": [
|
"card": [
|
||||||
{"state": "ticket.card.basicData.stepOne", "icon": "settings"},
|
{"state": "ticket.card.basicData.stepOne", "icon": "settings"},
|
||||||
|
@ -290,6 +291,12 @@
|
||||||
"state": "ticket.future",
|
"state": "ticket.future",
|
||||||
"component": "vn-ticket-future",
|
"component": "vn-ticket-future",
|
||||||
"description": "Future tickets"
|
"description": "Future tickets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/advance",
|
||||||
|
"state": "ticket.advance",
|
||||||
|
"component": "vn-ticket-advance",
|
||||||
|
"description": "Advance tickets"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
<vn-dialog
|
|
||||||
vn-id="SMSDialog"
|
|
||||||
on-accept="$ctrl.onResponse()"
|
|
||||||
message="Send SMS">
|
|
||||||
<tpl-body>
|
|
||||||
<section class="SMSDialog">
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-textfield
|
|
||||||
vn-one
|
|
||||||
label="Destination"
|
|
||||||
ng-model="$ctrl.sms.destination"
|
|
||||||
required="true"
|
|
||||||
rule>
|
|
||||||
</vn-textfield>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal >
|
|
||||||
<vn-textarea vn-one
|
|
||||||
vn-id="message"
|
|
||||||
label="Message"
|
|
||||||
ng-model="$ctrl.sms.message"
|
|
||||||
info="Special characters like accents counts as a multiple"
|
|
||||||
rows="5"
|
|
||||||
required="true"
|
|
||||||
rule>
|
|
||||||
</vn-textarea>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<span>
|
|
||||||
{{'Characters remaining' | translate}}:
|
|
||||||
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{
|
|
||||||
'colored': $ctrl.charactersRemaining() > 25,
|
|
||||||
'warning': $ctrl.charactersRemaining() <= 25,
|
|
||||||
'alert': $ctrl.charactersRemaining() < 0,
|
|
||||||
}">
|
|
||||||
{{$ctrl.charactersRemaining()}}
|
|
||||||
</vn-chip>
|
|
||||||
</span>
|
|
||||||
</vn-horizontal>
|
|
||||||
</section>
|
|
||||||
</tpl-body>
|
|
||||||
<tpl-buttons>
|
|
||||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
|
||||||
<button response="accept" translate>Send</button>
|
|
||||||
</tpl-buttons>
|
|
||||||
</vn-dialog>
|
|
|
@ -1,71 +0,0 @@
|
||||||
import './index';
|
|
||||||
|
|
||||||
describe('Ticket', () => {
|
|
||||||
describe('Component vnTicketSms', () => {
|
|
||||||
let controller;
|
|
||||||
let $httpBackend;
|
|
||||||
|
|
||||||
beforeEach(ngModule('ticket'));
|
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
|
||||||
$httpBackend = _$httpBackend_;
|
|
||||||
let $scope = $rootScope.$new();
|
|
||||||
const $element = angular.element('<vn-dialog></vn-dialog>');
|
|
||||||
controller = $componentController('vnTicketSms', {$element, $scope});
|
|
||||||
controller.$.message = {
|
|
||||||
input: {
|
|
||||||
value: 'My SMS'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('onResponse()', () => {
|
|
||||||
it('should perform a POST query and show a success snackbar', () => {
|
|
||||||
let params = {ticketId: 11, destinationFk: 1101, destination: 111111111, message: 'My SMS'};
|
|
||||||
controller.sms = {ticketId: 11, destinationFk: 1101, destination: 111111111, message: 'My SMS'};
|
|
||||||
|
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
|
||||||
$httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params);
|
|
||||||
|
|
||||||
controller.onResponse();
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call onResponse without the destination and show an error snackbar', () => {
|
|
||||||
controller.sms = {destinationFk: 1101, message: 'My SMS'};
|
|
||||||
|
|
||||||
jest.spyOn(controller.vnApp, 'showError');
|
|
||||||
|
|
||||||
controller.onResponse();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call onResponse without the message and show an error snackbar', () => {
|
|
||||||
controller.sms = {destinationFk: 1101, destination: 222222222};
|
|
||||||
|
|
||||||
jest.spyOn(controller.vnApp, 'showError');
|
|
||||||
|
|
||||||
controller.onResponse();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('charactersRemaining()', () => {
|
|
||||||
it('should return the characters remaining in a element', () => {
|
|
||||||
controller.$.message = {
|
|
||||||
input: {
|
|
||||||
value: 'My message 0€'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = controller.charactersRemaining();
|
|
||||||
|
|
||||||
expect(result).toEqual(145);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,9 +0,0 @@
|
||||||
Send SMS: Enviar SMS
|
|
||||||
Destination: Destinatario
|
|
||||||
Message: Mensaje
|
|
||||||
SMS sent!: ¡SMS enviado!
|
|
||||||
Characters remaining: Carácteres restantes
|
|
||||||
The destination can't be empty: El destinatario no puede estar vacio
|
|
||||||
The message can't be empty: El mensaje no puede estar vacio
|
|
||||||
The message it's too long: El mensaje es demasiado largo
|
|
||||||
Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios
|
|
|
@ -1,5 +0,0 @@
|
||||||
@import "variables";
|
|
||||||
|
|
||||||
.SMSDialog {
|
|
||||||
min-width: 400px
|
|
||||||
}
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const vnPrintPath = path.resolve('print');
|
||||||
|
|
||||||
|
module.exports = new Stylesheet([
|
||||||
|
`${vnPrintPath}/common/css/spacing.css`,
|
||||||
|
`${vnPrintPath}/common/css/misc.css`,
|
||||||
|
`${vnPrintPath}/common/css/layout.css`,
|
||||||
|
`${vnPrintPath}/common/css/email.css`])
|
||||||
|
.mergeStyles();
|
|
@ -0,0 +1,3 @@
|
||||||
|
subject: Pay method updated
|
||||||
|
title: Pay method updated
|
||||||
|
description: The pay method of the supplier {0} has been updated from {1} to {2}
|
|
@ -0,0 +1,3 @@
|
||||||
|
subject: Método de pago actualizado
|
||||||
|
title: Método de pago actualizado
|
||||||
|
description: Se ha actualizado el método de pago del proveedor {0} de {1} a {2}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<email-body v-bind="$props">
|
||||||
|
<div class="grid-row">
|
||||||
|
<div class="grid-block vn-pa-ml">
|
||||||
|
<h1>{{ $t('title') }}</h1>
|
||||||
|
<p v-html="$t('description', [name, oldPayMethod, newPayMethod])"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</email-body>
|
|
@ -0,0 +1,23 @@
|
||||||
|
const Component = require(`vn-print/core/component`);
|
||||||
|
const emailBody = new Component('email-body');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'supplier-pay-method-update',
|
||||||
|
components: {
|
||||||
|
'email-body': emailBody.build(),
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
oldPayMethod: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
newPayMethod: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue