From 3fd34e08618fe9ea1b260f8103bddb9b6d9421fd Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 25 Jul 2022 14:49:39 +0200 Subject: [PATCH 01/36] feat(claim_pickup_order): modify email --- db/dump/fixtures.sql | 256 +++++++++--------- modules/claim/front/basic-data/index.html | 4 +- modules/claim/front/basic-data/locale/es.yml | 4 +- modules/claim/front/descriptor/index.js | 5 +- modules/claim/front/summary/index.html | 47 ++-- .../claim-pickup-order.html | 9 +- .../claim-pickup-order/claim-pickup-order.js | 12 + .../email/claim-pickup-order/locale/es.yml | 13 +- .../claim-pickup-order.html | 9 +- .../claim-pickup-order/claim-pickup-order.js | 4 - .../reports/claim-pickup-order/locale/es.yml | 4 - .../claim-pickup-order/sql/claimConfig.sql | 2 - 12 files changed, 192 insertions(+), 177 deletions(-) delete mode 100644 print/templates/reports/claim-pickup-order/sql/claimConfig.sql diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0609a6a6ab..746e77ffd7 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1,7 +1,7 @@ CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `tmp`; -UPDATE `util`.`config` +UPDATE `util`.`config` SET `environment`= 'test'; ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; @@ -9,11 +9,11 @@ ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; -INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) - VALUES +INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) + VALUES ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); -INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) +INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); @@ -22,11 +22,11 @@ INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVo (1.30, 167.00, 138000, 71); INSERT INTO `vn`.`chatConfig` (`host`, `api`) - VALUES + VALUES ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); -INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) - VALUES +INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) + VALUES ('1', '11'); INSERT INTO `vn`.`packagingConfig`(`upperGap`) @@ -52,11 +52,11 @@ INSERT INTO `account`.`account`(`id`) INSERT INTO `vn`.`educationLevel` (`id`, `name`) VALUES (1, 'ESTUDIOS PRIMARIOS COMPLETOS'), - (2, 'ENSEÑANZAS DE BACHILLERATO'); + (2, 'ENSEÑANZAS DE BACHILLERATO'); INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 - FROM `vn`.`user`; + FROM `vn`.`user`; UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9; @@ -69,7 +69,7 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` (1, 978, 1, 0, 2000, 9, 0); INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) - VALUES + VALUES (1101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), (1102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), (1103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), @@ -113,7 +113,7 @@ INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossF (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, 1), (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2), - (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); + (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) VALUES @@ -123,7 +123,7 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) (4, 'JPY', 'Yen Japones', 1); INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `politicalCountryFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`) - VALUES + VALUES (1, 'España', 1, 'ES', 1, 1, 24, 4, 0, 1), (2, 'Italia', 1, 'IT', 1, 2, 27, 4, 0, 1), (3, 'Alemania', 1, 'DE', 1, 3, 22, 4, 0, 1), @@ -153,19 +153,19 @@ INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPrepare (1, 'First sector', 1, 1, 'FIRST'), (2, 'Second sector', 2, 0, 'SECOND'); -INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES +INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) + VALUES ('1', '700', '01', '1', '700-01', '70001'), ('2', '700', '02', '2', '700-02', '70002'); -INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`) - VALUES +INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`) + VALUES ('GVC', 1, 0, 1, 0, 1106), ('HEJ', 2, 0, 1, 0, 1106), ('UXN', 1, 0, 1, 0, 1106); INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) - VALUES + VALUES (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1), (2, 'Cash', 'Cash', 'cash', 1000, 0), (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0), @@ -180,8 +180,8 @@ INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`) (128, 1, 'The Best Bank', 'BBKKESMMMMMM'), (2100, 1, 'Caixa Bank', 'CAIXESBB'); -INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) - VALUES +INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) + VALUES (1, 'Pay on receipt', '5720000001', 3, 128, 1, 1), (2, 'Cash', '5700000001', 2, 128, 1, 1), (3, 'Compensation', '4000000000', 8, 128, 1, 1), @@ -235,7 +235,7 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com' UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`) - VALUES + VALUES (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0), (2, NULL, 'PayMethod two', 10, 001, 0, 0, 1), (3, 'compensation', 'PayMethod three', 0, 001, 0, 0, 0), @@ -244,7 +244,7 @@ INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1, 0); INSERT INTO `vn`.`payDem`(`id`, `payDem`) - VALUES + VALUES (1, 10), (2, 20); @@ -273,7 +273,7 @@ INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) (5, 'Quito', 5); INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) - VALUES + VALUES ('46000', 1, 6), ('46460', 2, 6), ('46680', 3, 6), @@ -481,7 +481,7 @@ INSERT INTO `vn`.`supplierActivity`(`code`, `name`) ('complements', 'Other complements'), ('flowerPlants', 'Wholesale of flowers and plants'), ('vegetablesFruits', 'Fruit and vegetable trade'); - + INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`) VALUES (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), @@ -498,7 +498,7 @@ INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport'), (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport'), (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL), - (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport'); + (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport'); INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) VALUES @@ -519,7 +519,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES (1, 'T', 1014.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), - (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0); @@ -531,7 +531,7 @@ UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4; UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5; INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`) - VALUES + VALUES (1, 895.76, 89.58, 4722000010), (1, 33.80, 7.10, 4722000021), (2, 110.33, 11.03, 4770000010), @@ -552,7 +552,7 @@ INSERT INTO `vn`.`expence`(`id`, `taxTypeFk`, `name`, `isWithheld`) (7001000000, 1, 'Mercaderia', 0), (7050000000, 1, 'Prestacion de servicios', 1); - + INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`) VALUES (1, 1, 813.06, 2000000000, util.VN_CURDATE()), @@ -564,7 +564,7 @@ INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk` (7, 5, 8.07, 2000000000, util.VN_CURDATE()); INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`) - VALUES + VALUES (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), (3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), @@ -580,7 +580,7 @@ INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100); INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) - VALUES + VALUES (1, 1, 1), (2, 2, 2), (3, 3, 1), @@ -596,7 +596,7 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) (13, 13, 5); INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) - VALUES + VALUES (1, util.VN_CURDATE(), '23:59'), (2, util.VN_CURDATE(), '23:59'), (3, util.VN_CURDATE(), '23:59'), @@ -668,7 +668,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des (11, 24, 4, 'Reclama ticket: 7'), (12, 11, 3, 'Delivery after 10am'); --- FIX for state hours on local, inter_afterInsert +-- FIX for state hours on local, inter_afterInsert UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND); INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) @@ -764,7 +764,7 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code` INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) VALUES ('warm', 'Warm', 'Warm'), - ('cool', 'Cool', 'Cool'); + ('cool', 'Cool', 'Cool'); INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`) VALUES @@ -818,7 +818,7 @@ INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`) (1, util.VN_CURDATE(), 1), (1, util.VN_CURDATE(), 21), (2, util.VN_CURDATE(), 2); - + INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) VALUES (05080000, 'Coral y materiales similares', 2, 2), @@ -830,7 +830,7 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('SER', 'Services'), ('VT', 'Sales'); -INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, +INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`) VALUES (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15), @@ -966,7 +966,7 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (3, 39, 0.994), (4, 28, 1.25), (4, 29, 0.42), - (4, 39, 0.017), + (4, 39, 0.017), (5, 17, 9.94), (5, 28, 50), (5, 29, 49.4), @@ -988,8 +988,8 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (9, 15, 3.0949), (9, 21, 0.001), (9, 28, 53), - (9, 29, 46.4), - (9, 39, 0.994), + (9, 29, 46.4), + (9, 39, 0.994), (10, 15, 0.0199), (10, 28, 7), (10, 29, 0), @@ -1088,14 +1088,14 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (32, 36, -92.324), (32, 39, 0.994); -INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`) - VALUES +INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`) + VALUES (2, 'GVC', 'A', 1, 1, 1, 1106), (4, 'HEJ', 'A', 1, 1, 1, 1106), (1, 'UXN', 'A', 2, 12, 12, 1106); -INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) - VALUES +INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) + VALUES ('1', '1', '1', '', '1106'), ('2', '2', '5', '', '1106'), ('1', '7', '1', '', '1106'), @@ -1137,8 +1137,8 @@ INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`) (3, 2, NULL), (23, 1, NULL); -INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES +INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) + VALUES ('100', '01', 1, '100-01', 1); INSERT INTO `vn`.`genus`(`id`, `name`) @@ -1292,7 +1292,7 @@ INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) CALL `vn`.`itemRefreshTags`(NULL); INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`) - VALUES + VALUES ('1', '1', '1', 'insert', 'We made a change!'); INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`) @@ -1484,8 +1484,8 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) (4, 21, -0.001), (4, 28, 20.72), (4, 29, -19.72), - (4, 37, 2), - (4, 39, 0.01), + (4, 37, 2), + (4, 39, 0.01), (5, 15, 0.58), (5, 23, 6.5), (5, 28, 20.72), @@ -1704,7 +1704,7 @@ INSERT INTO `vn`.`workerManaExcluded`(`workerFk`) La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets */ -call vn.manaSpellersRequery(19); +call vn.manaSpellersRequery(19); call vn.manaSpellersRequery(18); INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`) @@ -1772,8 +1772,8 @@ INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, ` (1, 'Arkham Bank', 442, 1, 'h12387193H10238'), (2, 'NewYork Bank', 442, 1, '7981ugsgd1hsdad'); -INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) - VALUES +INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) + VALUES (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE()), (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE()), (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE()), @@ -1787,32 +1787,32 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) (2, 2), (3, 3), (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9), - (10, 10), - (11, 11), - (12, 12), - (13, 13), - (14, 14), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11), + (12, 12), + (13, 13), + (14, 14), (15, 15), (16, 16), (17, 17), (18, 18), (19, 19), - (20, 20), - (21, 21), + (20, 20), + (21, 21), (22, 22); -INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) +INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES (1, 1, 69), - (5, 1, 442), + (5, 1, 442), (9, 1, 442), (18, 3, 567); - + INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) VALUES (1, 'Cobro web', 100.50, util.VN_CURDATE(), 9, 1, 1101, util.VN_CURDATE(), 442, 1), @@ -1895,14 +1895,14 @@ INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_ VALUES (1111, NULL, 23, 1, 0.0, 1, 1, 1, 1); -UPDATE `postgresql`.`business_labour` bl +UPDATE `postgresql`.`business_labour` bl JOIN `postgresql`.`business` b ON b.business_id = bl.business_id JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id JOIN `postgresql`.`person` p ON p.person_id = pr.person_id SET bl.`professional_category_id` = 31 WHERE p.`Id_trabajador` = 1110; -UPDATE `postgresql`.`business_labour` bl +UPDATE `postgresql`.`business_labour` bl SET bl.`department_id` = 43 WHERE business_id IN(18, 19); @@ -1917,18 +1917,18 @@ INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `medi (2, 1107, 2); INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`) - VALUES + VALUES ('1', '27.5', YEAR(util.VN_CURDATE())), ('5', '22', YEAR(util.VN_CURDATE())), - ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), + ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))); -INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) - VALUES +INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) + VALUES (1, 'Holidays', '#FF4444', 'holiday', 0, 0), (2, 'Leave of absence', '#C71585', 'absence', 0, 1), (6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5), - (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), + (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), (20, 'Furlough', '#97B92F', 'furlough', 1, 1), (21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1); @@ -1945,10 +1945,10 @@ INSERT INTO `postgresql`.`business_labour_payroll` (`business_id`, `cod_tarifa`, (1, 7, 12, 100, 900.50), (1106, 7, 12, 100, 1263.03), (1107, 7, 12, 100, 2000), - (1108, 7, 12, 100, 1500); + (1108, 7, 12, 100, 1500); -INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) - VALUES +INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) + VALUES (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))), @@ -1966,8 +1966,8 @@ INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id` (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))), (1107, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL - 16 DAY)); -INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) - VALUES +INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) + VALUES ('1', 'https://api.gateway360.com/api/3.0/sms/send', 'Verdnatura', '5715476da95b46d686a5a255e6459523'); INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`) @@ -1983,37 +1983,37 @@ CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) VALUES - (1, 3, 0), - (1, 4, 0), - (1, 5, 0), + (1, 3, 0), + (1, 4, 0), + (1, 5, 0), (1, 1, 1), - (2, 3, 0), - (2, 4, 0), - (2, 5, 0), + (2, 3, 0), + (2, 4, 0), + (2, 5, 0), (2, 1, 1), - (3, 3, 0), - (3, 4, 0), - (3, 5, 0), + (3, 3, 0), + (3, 4, 0), + (3, 5, 0), (3, 1, 1), - (4, 3, 0), - (4, 4, 0), - (4, 5, 0), + (4, 3, 0), + (4, 4, 0), + (4, 5, 0), (4, 1, 1), - (5, 3, 1), - (5, 4, 0), - (5, 5, 1), + (5, 3, 1), + (5, 4, 0), + (5, 5, 1), (5, 1, 1), - (6, 3, 1), - (6, 4, 0), - (6, 5, 1), + (6, 3, 1), + (6, 4, 0), + (6, 5, 1), (6, 1, 1), - (7, 3, 0), - (7, 4, 0), - (7, 5, 0), + (7, 3, 0), + (7, 4, 0), + (7, 5, 0), (7, 1, 1), - (8, 3, 0), - (8, 4, 0), - (8, 5, 0), + (8, 3, 0), + (8, 4, 0), + (8, 5, 0), (8, 1, 1), (10, 14, 1); @@ -2226,12 +2226,12 @@ INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`) - VALUES + VALUES (8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'), (10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`) - VALUES + VALUES (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)); INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`) @@ -2294,8 +2294,8 @@ INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker (1, 1106, 4, TRUE), (2, 1107, 3, FALSE); -INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) - VALUES +INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) + VALUES ('aaa', 'android', '9'); INSERT INTO `vn`.`queuePriority`(`id`, `priority`) @@ -2309,7 +2309,7 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); - + INSERT INTO `vn`.`thermograph`(`id`, `model`) VALUES ('TMM190901395', 'TEMPMATE'), @@ -2327,21 +2327,21 @@ INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL); -REPLACE INTO `vn`.`incoterms`(`code`, `name`) - VALUES +REPLACE INTO `vn`.`incoterms`(`code`, `name`) + VALUES ('FAS', 'Free Alongside Ship'); -REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) - VALUES +REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) + VALUES (1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'), (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); -INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) - VALUES +INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) + VALUES ('1', 'TEST', 'ON THE FIXTURES', '0'), ('2', 'DEV', 'OTHER TABLET', '0'); -INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) +INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) VALUES (1, 23), (2, 1); @@ -2374,8 +2374,8 @@ INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25), (util.VN_CURDATE(), 1, 12, 17, 22, 27); -INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) - VALUES +INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) + VALUES (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1), (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1), (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1), @@ -2387,8 +2387,8 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1), (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); -INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) - VALUES +INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) + VALUES (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442), (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442), (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442), @@ -2435,8 +2435,8 @@ INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`) (4, 4, 4), (5, 5, 5), (6, 6, 6), - (7, 7, 7), - (8, 8, 8), + (7, 7, 7), + (8, 8, 8), (9, 9, 9), (10, 10, 10); @@ -2446,7 +2446,7 @@ INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `for (2, 999.99, '2000000000', null, null, null), (3, 1000.50, '2000000000', null, null, null), (4, 0.50, '2000000000', null, null, null), - (5, 150.50, '2000000000', null, null, null), + (5, 150.50, '2000000000', null, null, null), (1, 252.25, '4751000000', NULL, 7, 61), (2, 223.17, '6210000567', NULL, 8, 20), (3, 95.60, '7001000000', NULL, 8, 35), @@ -2461,9 +2461,9 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (1, 10, 6021010, 20.00, 205, 5), (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); - + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) - SELECT `id` + SELECT `id` FROM `vn`.`ticket` t LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id WHERE tr.ticketFk IS NULL; @@ -2478,7 +2478,7 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) (4, 7, 1); INSERT INTO `vn`.`expeditionTruck` (`id`, `ETD`, `description`) - VALUES + VALUES (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet'); INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`) @@ -2486,7 +2486,7 @@ INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPr (1, 1, util.VN_CURDATE(), 1, 1); INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`) - VALUES + VALUES (1, 1, util.VN_CURDATE(), 1), (2, 2, util.VN_CURDATE(), 1), (3, 3, util.VN_CURDATE(), 1), @@ -2521,7 +2521,7 @@ UPDATE `vn`.`route` INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`, `portfolioWeight`) VALUES (18, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 807.23), - (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); + (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) VALUES @@ -2550,14 +2550,14 @@ INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`) INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`) VALUES (1, 1, CONCAT(YEAR(util.VN_CURDATE()), '-12-09'), 1, 1); - + INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`) VALUES (1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23), (2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33), (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0), (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0), - (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); + (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`) VALUES @@ -2607,7 +2607,7 @@ INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`) INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`) VALUES (1, 1); - + INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`) VALUES - (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); \ No newline at end of file + (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 7a91e180a4..16e134c60a 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -19,7 +19,7 @@ readonly="true"> @@ -56,7 +56,7 @@ label="Pick up" ng-model="$ctrl.claim.hasToPickUp" vn-acl="claimManager" - info="When checked will notify to the salesPerson"> + title="{{'When checked will notify to the salesPerson' | translate}}"> diff --git a/modules/claim/front/basic-data/locale/es.yml b/modules/claim/front/basic-data/locale/es.yml index c51afee3fb..5250d266c6 100644 --- a/modules/claim/front/basic-data/locale/es.yml +++ b/modules/claim/front/basic-data/locale/es.yml @@ -5,5 +5,5 @@ Responsability: Responsabilidad Company: Empresa Sales/Client: Comercial/Cliente Pick up: Recoger -When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial -Packages received: Bultos recibidos \ No newline at end of file +When checked will notify to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial +Packages received: Bultos recibidos diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index 674ac91e19..bb406ff795 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -19,9 +19,10 @@ class Controller extends Descriptor { sendPickupOrder() { return this.vnEmail.send('claim-pickup-order', { - recipient: this.claim.client.email, + recipient: 'alexm@verdnatura.es', recipientId: this.claim.clientFk, - claimId: this.claim.id + claimId: this.claim.id, + ticketId: this.claim.ticketFk }); } diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html index 0c12aa2e64..fc1813467a 100644 --- a/modules/claim/front/summary/index.html +++ b/modules/claim/front/summary/index.html @@ -34,6 +34,15 @@ label="State" value="{{$ctrl.summary.claim.claimState.description}}"> + + + + @@ -45,13 +54,13 @@

- Observations

-

Observations @@ -70,13 +79,13 @@

- Detail

-

Detail @@ -98,7 +107,7 @@ - {{::saleClaimed.sale.itemFk | zeroFill:6}} @@ -111,7 +120,7 @@ {{::saleClaimed.sale.price | currency: 'EUR':2}} {{::saleClaimed.sale.discount}} % - {{saleClaimed.sale.quantity * saleClaimed.sale.price * + {{saleClaimed.sale.quantity * saleClaimed.sale.price * ((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}} @@ -123,7 +132,7 @@

Photos

-
@@ -137,13 +146,13 @@

- Development

-

Development @@ -165,8 +174,8 @@ {{::development.claimResult.description}} {{::development.claimResponsible.description}} - {{::development.worker.user.nickname}} @@ -179,21 +188,21 @@

- Action

Action

- {{::action.sale.itemFk | zeroFill:6}} - {{::action.sale.ticket.id}} @@ -258,9 +267,9 @@ vn-id="item-descriptor" warehouse-fk="$ctrl.vnConfig.warehouseFk"> - - - \ No newline at end of file + diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.html b/print/templates/email/claim-pickup-order/claim-pickup-order.html index f674dcee8b..e6e74ed939 100644 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.html @@ -23,9 +23,10 @@
-

{{ $t('title') }}

-

{{$t('description.dear')}},

-

{{$t('description.instructions')}}

+

{{ $t('title', [claimId]) }}

+

{{ $t('description.dear') }},

+

+

{{ $t('description.conclusion') }}

@@ -43,4 +44,4 @@ - \ No newline at end of file + diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index cf4ba7d123..220a72dc33 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -8,10 +8,22 @@ module.exports = { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build() }, + created() { + this.instructions = this.$t('description.instructions', [this.claimId, this.ticketId]); + }, + data() { + return { + instructions: String + }; + }, props: { claimId: { type: [Number, String], required: true + }, + ticketId: { + type: [Number, String], + required: true } } }; diff --git a/print/templates/email/claim-pickup-order/locale/es.yml b/print/templates/email/claim-pickup-order/locale/es.yml index fe08fb0a8a..9ff30158e2 100644 --- a/print/templates/email/claim-pickup-order/locale/es.yml +++ b/print/templates/email/claim-pickup-order/locale/es.yml @@ -1,5 +1,10 @@ -subject: Orden de recogida -title: Orden de recogida +subject: Reclamación Verdnatura +title: Reclamación Verdnatura {0} description: - dear: Estimado cliente - instructions: Aqui tienes tu orden de recogida. \ No newline at end of file + dear: Estimado cliente + instructions: 'Le informamos que se ha aceptado su solicitud de reclamación nº {0} correspondiente al pedido {1}. + Para tramitar la recogida, rellene el SIGUIENTE FORMULARIO en un plazo máximo de 24h. +

Cuando recibamos el género en nuestras instalaciones emitiremos el abono correspondiente. + Debe imprimir el archivo adjunto e incluirlo en la caja. En el caso de no poder imprimirlo, identifique la caja con el número de reclamación CLARAMENTE LEGIBLE.' + conclusion: Un saludo diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html index 1f6db49666..49ec00cfd4 100644 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -52,7 +52,7 @@ - + @@ -71,16 +71,13 @@
- +
{{$t('clientSignature')}}

{{client.name}}

- -

-

{{claimConfig.pickupContact}}

@@ -94,4 +91,4 @@ - \ No newline at end of file + diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.js b/print/templates/reports/claim-pickup-order/claim-pickup-order.js index bf975e9f2c..fa21240573 100755 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js @@ -7,7 +7,6 @@ module.exports = { async serverPrefetch() { this.client = await this.fetchClient(this.claimId); this.sales = await this.fetchSales(this.claimId); - this.claimConfig = await this.fetchClaimConfig(); if (!this.client) throw new Error('Something went wrong'); @@ -26,9 +25,6 @@ module.exports = { fetchSales(claimId) { return this.rawSqlFromDef('sales', [claimId]); }, - fetchClaimConfig() { - return this.findOneFromDef('claimConfig'); - }, }, components: { 'report-header': reportHeader.build(), diff --git a/print/templates/reports/claim-pickup-order/locale/es.yml b/print/templates/reports/claim-pickup-order/locale/es.yml index 388c1f1a69..5ee5ecda76 100644 --- a/print/templates/reports/claim-pickup-order/locale/es.yml +++ b/print/templates/reports/claim-pickup-order/locale/es.yml @@ -11,7 +11,3 @@ concept: Concepto clientSignature: Firma del cliente claim: Reclamación {0} phone: Teléfono -sections: - agency: - description: 'Para agilizar su recogida, por favor, póngase en contacto con la oficina - de Logista Parcel.' diff --git a/print/templates/reports/claim-pickup-order/sql/claimConfig.sql b/print/templates/reports/claim-pickup-order/sql/claimConfig.sql deleted file mode 100644 index 9d744ca6d6..0000000000 --- a/print/templates/reports/claim-pickup-order/sql/claimConfig.sql +++ /dev/null @@ -1,2 +0,0 @@ -SELECT pickupContact - FROM claimConfig; \ No newline at end of file From 2a64fde57c74836804c639e7cd21cc2b2f43064f Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 22 Sep 2022 14:58:38 +0200 Subject: [PATCH 02/36] feat: add option "move expedition" --- modules/ticket/front/expedition/index.html | 119 ++++++++++++--------- modules/ticket/front/expedition/index.js | 11 ++ 2 files changed, 82 insertions(+), 48 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index a41d368f6b..37e64fad59 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -8,54 +8,77 @@ auto-load="true"> - - - - - - Expedition - Item - Name - Package type - Counter - externalId - Created - State - - - - - - - - - - {{expedition.id | zeroFill:6}} - - - {{expedition.packagingFk}} - - - {{::expedition.packageItemName}} - {{::expedition.freightItemName}} - {{::expedition.counter}} - {{::expedition.externalId}} - {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} - {{::expedition.state}} - - - - - - - + + + + + + + + + +

Subtotal {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

+

VAT {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

+

Total {{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}

+
+
+ + + + + + + + Expedition + Item + Name + Package type + Counter + externalId + Created + State + + + + + + + + + + {{expedition.id | zeroFill:6}} + + + {{expedition.packagingFk}} + + + {{::expedition.packageItemName}} + {{::expedition.freightItemName}} + {{::expedition.counter}} + {{::expedition.externalId}} + {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} + {{::expedition.state}} + + + + + + +
Date: Fri, 23 Sep 2022 08:50:11 +0200 Subject: [PATCH 03/36] feat: add totalChecked --- modules/ticket/front/expedition/index.html | 20 ++++++++++++++++---- modules/ticket/front/expedition/index.js | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 37e64fad59..3a5d5f8a6d 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -12,12 +12,11 @@ + ng-show="$ctrl.totalChecked"> @@ -134,4 +133,17 @@ - \ No newline at end of file + + + + + New ticket without route + + + New ticket with route + + \ No newline at end of file diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index adbbc53d4e..38d02f5484 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -22,6 +22,10 @@ class Controller extends Section { return checkedRows; } + + get totalChecked() { + return this.checked.length; + } } ngModule.vnComponent('vnTicketExpedition', { From 11484edd105c0c57210b523c89f246a55bb1f17d Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 3 Oct 2022 15:18:07 +0200 Subject: [PATCH 04/36] feat: create new ticket --- modules/ticket/front/expedition/index.html | 22 +++++++++++++++++++--- modules/ticket/front/expedition/index.js | 17 +++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 3a5d5f8a6d..694b3eb33c 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -138,12 +138,28 @@ + ng-click="$ctrl.createTicket()"> New ticket without route + ng-click="selectRoute.show()"> New ticket with route - \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 38d02f5484..d80c8e812b 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -26,6 +26,23 @@ class Controller extends Section { get totalChecked() { return this.checked.length; } + + createTicket(routeFk) { + const tomorrow = new Date(); + const params = { + clientId: this.ticket.clientFk, + landed: tomorrow.getDay() + 1, + addressId: this.ticket.addressFk, + agencyModeId: this.ticket.agencyModeFk, + warehouseId: this.ticket.warehouseFk + }; + const query = `Tickets/new`; + this.$http.post(query, params).then(res => { + if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); + this.vnApp.showSuccess(this.$t('Data saved!')); + this.$state.go('ticket.card.summary', {id: res.data.id}); + }); + } } ngModule.vnComponent('vnTicketExpedition', { From a3a432c753c19d263d642c379aa1d7c4977b3a6e Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 6 Oct 2022 10:18:19 +0200 Subject: [PATCH 05/36] fix: delete one or more expeditions --- modules/ticket/front/expedition/index.html | 11 ++++++----- modules/ticket/front/expedition/index.js | 14 ++++++++++++++ modules/ticket/front/expedition/locale/es.yml | 3 ++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 694b3eb33c..caef67f59e 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -17,8 +17,9 @@ ng-show="$ctrl.totalChecked"> @@ -88,11 +89,11 @@ - + on-accept="$ctrl.onRemove()"> diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index d80c8e812b..1525f97b5d 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -27,6 +27,20 @@ class Controller extends Section { return this.checked.length; } + async onRemove() { + const params = []; + for (let expedition of this.checked) + params.push(expedition.id); + + for (let id of params) { + await this.$http.delete(`Expeditions/${id}`) + .then(() => { + this.vnApp.showSuccess(this.$t('Expedition removed')); + this.$state.reload(); + }); + } + } + createTicket(routeFk) { const tomorrow = new Date(); const params = { diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index d23cf25af3..9c7872fd70 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -1 +1,2 @@ -Status log: Hitorial de estados \ No newline at end of file +Status log: Hitorial de estados +Expedition removed: Expedición eliminada \ No newline at end of file From 37601934f579e55668e5b2eae07e9b68e95a3e81 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 6 Oct 2022 11:40:46 +0200 Subject: [PATCH 06/36] feat: first option to delete and update --- modules/ticket/front/expedition/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 1525f97b5d..4f7b34e7cb 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -42,17 +42,25 @@ class Controller extends Section { } createTicket(routeFk) { - const tomorrow = new Date(); - const params = { + const date = new Date(); // esta fecha hay que preguntarla a Fran Monsalvez + const ticketParams = { clientId: this.ticket.clientFk, - landed: tomorrow.getDay() + 1, + landed: date, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, warehouseId: this.ticket.warehouseFk }; const query = `Tickets/new`; - this.$http.post(query, params).then(res => { + this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); + + const params = []; + for (let expedition of this.checked) + params.push(expedition.id); + const expeditionParams = {ticketFk: res.data.id}; + for (let id of params) + this.$http.patch(`Expeditions/${id}`, expeditionParams); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); From deb8a00dfb2edbd5d3a2a2e84caec89679cce5ad Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 7 Oct 2022 10:47:54 +0200 Subject: [PATCH 07/36] feat: add backRoutes --- .../methods/expedition/deleteExpeditions.js | 48 +++++++++++++++ .../methods/expedition/moveExpeditions.js | 59 +++++++++++++++++++ modules/ticket/back/models/expedition.js | 2 + modules/ticket/front/expedition/index.html | 4 +- modules/ticket/front/expedition/index.js | 35 +++++------ modules/ticket/front/expedition/locale/es.yml | 5 +- 6 files changed, 130 insertions(+), 23 deletions(-) create mode 100644 modules/ticket/back/methods/expedition/deleteExpeditions.js create mode 100644 modules/ticket/back/methods/expedition/moveExpeditions.js diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js new file mode 100644 index 0000000000..b902b9f0c5 --- /dev/null +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -0,0 +1,48 @@ + +module.exports = Self => { + Self.remoteMethod('deleteExpeditions', { + description: 'Delete the selected expeditions', + accessType: 'WRITE', + accepts: [{ + arg: 'expeditionsIds', + type: ['number'], + required: true, + description: 'The expeditions ids to delete' + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/deleteExpeditions`, + verb: 'POST' + } + }); + + Self.deleteExpeditions = async(expeditionsIds, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const deletedExpeditions = await models.Expedition.destroyAll({ + id: {inq: expeditionsIds} + }, myOptions); + + if (tx) await tx.commit(); + + return deletedExpeditions; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js new file mode 100644 index 0000000000..2c521dda7c --- /dev/null +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -0,0 +1,59 @@ + +module.exports = Self => { + Self.remoteMethod('moveExpeditions', { + description: 'Move the selected expeditions to another ticket', + accessType: 'WRITE', + accepts: [{ + arg: 'expeditionsIds', + type: ['number'], + required: true, + description: 'The expeditions ids to nove' + }, + { + arg: 'ticketId', + type: 'number', + required: true, + description: 'the ticket id to which the expeditions are added' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/moveExpeditions`, + verb: 'POST' + } + }); + + Self.moveExpeditions = async(expeditionsIds, ticketId, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const promises = []; + for (let expeditionsId of expeditionsIds) { + const expeditionToUpdate = await models.Expedition.findById(expeditionsId); + const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); + promises.push(expeditionUpdated); + } + + const updated = await Promise.all(promises); + + if (tx) await tx.commit(); + + return updated; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/models/expedition.js b/modules/ticket/back/models/expedition.js index 9d65643737..46cde68902 100644 --- a/modules/ticket/back/models/expedition.js +++ b/modules/ticket/back/models/expedition.js @@ -1,3 +1,5 @@ module.exports = function(Self) { require('../methods/expedition/filter')(Self); + require('../methods/expedition/deleteExpeditions')(Self); + require('../methods/expedition/moveExpeditions')(Self); }; diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index caef67f59e..35f56872c2 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -14,10 +14,10 @@ + disabled="!$ctrl.totalChecked"> diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 4f7b34e7cb..a81439d644 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -17,7 +17,7 @@ class Controller extends Section { const checkedRows = []; for (let row of rows) { if (row.checked) - checkedRows.push(row); + checkedRows.push(row.id); } return checkedRows; @@ -27,18 +27,14 @@ class Controller extends Section { return this.checked.length; } - async onRemove() { - const params = []; - for (let expedition of this.checked) - params.push(expedition.id); - - for (let id of params) { - await this.$http.delete(`Expeditions/${id}`) - .then(() => { - this.vnApp.showSuccess(this.$t('Expedition removed')); - this.$state.reload(); - }); - } + onRemove() { + const params = {expeditionsIds: this.checked}; + const query = `Expeditions/deleteExpeditions`; + this.$http.post(query, params) + .then(() => { + this.vnApp.showSuccess(this.$t('Expedition removed')); + this.$state.reload(); + }); } createTicket(routeFk) { @@ -54,13 +50,12 @@ class Controller extends Section { this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); - const params = []; - for (let expedition of this.checked) - params.push(expedition.id); - const expeditionParams = {ticketFk: res.data.id}; - for (let id of params) - this.$http.patch(`Expeditions/${id}`, expeditionParams); - + const params = { + expeditionsIds: this.checked, + ticketId: res.data.id + }; + const query = `Expeditions/moveExpeditions`; + this.$http.post(query, params); this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index 9c7872fd70..bc3ec33455 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -1,2 +1,5 @@ Status log: Hitorial de estados -Expedition removed: Expedición eliminada \ No newline at end of file +Expedition removed: Expedición eliminada +Move: Mover +New ticket without route: Nuevo ticket sin ruta +New ticket with route: Nuevo ticket con ruta \ No newline at end of file From bb26fa6502232335c784f9fb101a381bf4f1be39 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 7 Oct 2022 13:49:42 +0200 Subject: [PATCH 08/36] feat: add tFront --- modules/ticket/front/expedition/index.js | 23 ++++---- modules/ticket/front/expedition/index.spec.js | 58 +++++++++++++++++++ 2 files changed, 69 insertions(+), 12 deletions(-) diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index a81439d644..f7674716b1 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -2,16 +2,6 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { - onDialogAccept(id) { - return this.$http.delete(`Expeditions/${id}`) - .then(() => this.$.model.refresh()); - } - - showLog(expedition) { - this.expedition = expedition; - this.$.statusLog.show(); - } - get checked() { const rows = this.$.model.data || []; const checkedRows = []; @@ -27,13 +17,23 @@ class Controller extends Section { return this.checked.length; } + onDialogAccept(id) { + return this.$http.delete(`Expeditions/${id}`) + .then(() => this.$.model.refresh()); + } + + showLog(expedition) { + this.expedition = expedition; + this.$.statusLog.show(); + } + onRemove() { const params = {expeditionsIds: this.checked}; const query = `Expeditions/deleteExpeditions`; this.$http.post(query, params) .then(() => { this.vnApp.showSuccess(this.$t('Expedition removed')); - this.$state.reload(); + this.$.model.refresh(); }); } @@ -49,7 +49,6 @@ class Controller extends Section { const query = `Tickets/new`; this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); - const params = { expeditionsIds: this.checked, ticketId: res.data.id diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index 586ef21096..fe23046ce2 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -17,6 +17,14 @@ describe('Ticket', () => { refresh: () => {} }; controller = $componentController('vnTicketExpedition', {$element: null, $scope}); + controller.$.model.data = [ + {id: 1}, + {id: 2}, + {id: 3} + ]; + const modelData = controller.$.model.data; + modelData[0].checked = true; + modelData[1].checked = true; })); describe('onDialogAccept()', () => { @@ -50,5 +58,55 @@ describe('Ticket', () => { expect(controller.$.statusLog.show).toHaveBeenCalledWith(); }); }); + + describe('onRemove()', () => { + it('should make a query and then call to the model refresh() method', () => { + jest.spyOn($scope.model, 'refresh'); + + const expectedParams = {expeditionsIds: [1, 2]}; + $httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200); + controller.onRemove(); + $httpBackend.flush(); + + expect($scope.model.refresh).toHaveBeenCalledWith(); + }); + }); + + describe('createTicket()', () => { + it('should make a query and then call to the $state go() method', () => { + jest.spyOn(controller.$state, 'go').mockReturnThis(); + + const ticket = { + clientFk: 1101, + landed: new Date(), + addressFk: 121, + agencyModeFk: 1, + warehouseFk: 1 + }; + controller.ticket = ticket; + + const expectedTicket = { + clientId: 1101, + landed: new Date(), + addressId: 121, + agencyModeId: 1, + warehouseId: 1 + }; + + const ticketIdToTransfer = 28; + const expectedResponse = {id: ticketIdToTransfer}; + + const expectedParams = { + expeditionsIds: [1, 2], + ticketId: 28 + }; + $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); + $httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(200); + controller.createTicket(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketIdToTransfer}); + }); + }); }); }); From 843f67919c9992e7e622f01b8dcfca7697fd81b3 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 10 Oct 2022 12:56:03 +0200 Subject: [PATCH 09/36] feat: add backTest --- .../specs/deleteExpeditions.spec.js | 22 ++++++++++++++++++ .../expedition/specs/moveExpeditions.spec.js | 23 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js create mode 100644 modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js new file mode 100644 index 0000000000..0a47c78da1 --- /dev/null +++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js @@ -0,0 +1,22 @@ +const models = require('vn-loopback/server/server').models; + +describe('ticket deleteExpeditions()', () => { + it('should delete the selected expeditions', async() => { + const tx = await models.Expedition.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const expeditionIds = [12, 13]; + const result = await models.Expedition.deleteExpeditions(expeditionIds, options); + + expect(result.count).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); + diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js new file mode 100644 index 0000000000..0bb402a558 --- /dev/null +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -0,0 +1,23 @@ +const models = require('vn-loopback/server/server').models; + +describe('ticket moveExpeditions()', () => { + it('should delete the selected expeditions', async() => { + const tx = await models.Expedition.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const expeditionIds = [12, 13]; + const ticketId = 1; + const result = await models.Expedition.moveExpeditions(expeditionIds, ticketId, options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); + From ea1714240e63f97bd91a9de75d3ca8463c88de17 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 10 Oct 2022 13:45:34 +0200 Subject: [PATCH 10/36] fix: test e2e --- e2e/helpers/selectors.js | 3 ++- e2e/paths/05-ticket/02_expeditions_and_log.spec.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index fedcaf5f95..97a58ba9c1 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -596,7 +596,8 @@ export default { submitNotesButton: 'button[type=submit]' }, ticketExpedition: { - thirdExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(3) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]', + thirdSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(3) vn-check[ng-model="expedition.checked"]', + deleteExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="delete"]', expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr' }, ticketPackages: { diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js index dd2525f439..f970247e51 100644 --- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js +++ b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js @@ -18,7 +18,8 @@ describe('Ticket expeditions and log path', () => { }); it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async() => { - await page.waitToClick(selectors.ticketExpedition.thirdExpeditionRemoveButton); + await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox); + await page.waitToClick(selectors.ticketExpedition.deleteExpeditionButton); await page.waitToClick(selectors.globalItems.acceptButton); await page.reloadSection('ticket.card.expedition'); From 2455a11c26744ac45f81b869b618af686d868157 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Oct 2022 14:29:21 +0200 Subject: [PATCH 11/36] feat: changeMultipleDiscount uses the same popover than changeDiscount --- modules/ticket/front/sale/index.html | 30 ++---------------------- modules/ticket/front/sale/index.js | 34 ++++++++++++---------------- 2 files changed, 17 insertions(+), 47 deletions(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 42eb10cb06..112476c301 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -300,7 +300,7 @@ ng-model="$ctrl.manaCode"> -
+

New price

{{$ctrl.getNewPrice() | currency: 'EUR': 2}} @@ -321,32 +321,6 @@

- - - - - -
-
- - -
-
- Mana: {{::$ctrl.edit.mana | currency: 'EUR': 0}} -
-
-
-
-
@@ -490,7 +464,7 @@ + ng-click="$ctrl.showEditDiscountPopover($event, sale)"> Update discount Date: Fri, 14 Oct 2022 14:30:37 +0200 Subject: [PATCH 12/36] fix: only can exists 'mana' or 'manaClaim' discount. Never both --- .../back/methods/ticket/updateDiscount.js | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index b1291a45bf..99daac5127 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -115,10 +115,43 @@ module.exports = Self => { for (let sale of sales) { const oldDiscount = sale.discount; const value = ((-sale.price * newDiscount) / 100); - const newComponent = models.SaleComponent.upsert({ - saleFk: sale.id, - value: value, - componentFk: componentId}, myOptions); + + const manaComponent = await models.Component.findOne({ + where: {code: 'mana'} + }, myOptions); + + const manaClaimComponent = await models.Component.findOne({ + where: {code: 'manaClaim'} + }, myOptions); + + const oldComponent = await models.SaleComponent.find({ + where: { + and: [ + {saleFk: sale.id}, + {componentFk: {inq: [manaComponent.id, manaClaimComponent.id]}} + ] + } + }, myOptions); + + let newComponent; + if (oldComponent) { + const filter = { + saleFk: sale.id, + componentFk: oldComponent.componentFk + }; + await models.SaleComponent.destroyAll(filter, myOptions); + + newComponent = models.SaleComponent.create({ + saleFk: sale.id, + value: value, + componentFk: componentId + }, myOptions); + } else { + newComponent = models.SaleComponent.create({ + saleFk: sale.id, + value: value, + componentFk: componentId}, myOptions); + } const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions); From 40075e7e21633569a5c7eb29d5f60fbedbb4a9c1 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Oct 2022 14:38:47 +0200 Subject: [PATCH 13/36] fix: testFront --- modules/ticket/front/sale/index.js | 1 - modules/ticket/front/sale/index.spec.js | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 714baa126c..0d1d28b0e5 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -273,7 +273,6 @@ class Controller extends Section { const hasChanges = sales.some(sale => { return sale.discount != newDiscount; }); - if (newDiscount != null && hasChanges) this.updateDiscount(sales); diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 28d8749328..a59eb3865c 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -393,7 +393,7 @@ describe('Ticket', () => { secondSelectedSale.checked = true; const expectedSales = [firstSelectedSale, secondSelectedSale]; - controller.$.editDiscountDialog = {hide: jest.fn()}; + controller.$.editDiscount = {hide: jest.fn()}; controller.edit = { discount: 10, sales: expectedSales @@ -402,7 +402,7 @@ describe('Ticket', () => { controller.changeMultipleDiscount(); expect(controller.updateDiscount).toHaveBeenCalledWith(expectedSales); - expect(controller.$.editDiscountDialog.hide).toHaveBeenCalledWith(); + expect(controller.$.editDiscount.hide).toHaveBeenCalledWith(); }); it('should not call to the updateDiscount() method and then to the editDiscountDialog hide() method', () => { @@ -417,7 +417,7 @@ describe('Ticket', () => { secondSelectedSale.discount = 10; const expectedSales = [firstSelectedSale, secondSelectedSale]; - controller.$.editDiscountDialog = {hide: jest.fn()}; + controller.$.editDiscount = {hide: jest.fn()}; controller.edit = { discount: 10, sales: expectedSales @@ -426,7 +426,7 @@ describe('Ticket', () => { controller.changeMultipleDiscount(); expect(controller.updateDiscount).not.toHaveBeenCalledWith(expectedSales); - expect(controller.$.editDiscountDialog.hide).toHaveBeenCalledWith(); + expect(controller.$.editDiscount.hide).toHaveBeenCalledWith(); }); }); From 991893837c285ebd9f340959375038dce77f757c Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 17 Oct 2022 07:34:22 +0200 Subject: [PATCH 14/36] correct fixutures from dev --- db/dump/fixtures.sql | 109 +++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 55 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 912c43bc20..2e00389e5b 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -866,7 +866,7 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('VT', 'Sales'); INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, - `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`) + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`) VALUES (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15,3), (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10,2), @@ -1175,10 +1175,6 @@ INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`) (3, 2, NULL), (23, 1, NULL); -INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES - ('100', '01', 1, '100-01', 1); - INSERT INTO `vn`.`genus`(`id`, `name`) VALUES (1, 'Abelia'), @@ -1936,16 +1932,19 @@ INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent` (100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1), (109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1); -UPDATE `postgresql`.`business_labour` bl - JOIN `postgresql`.`business` b ON b.business_id = bl.business_id - JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id - JOIN `postgresql`.`person` p ON p.person_id = pr.person_id - SET bl.`professional_category_id` = 31 - WHERE p.`Id_trabajador` = 1110; +UPDATE `vn`.`business` b + SET `rate` = 7, + `workerBusinessCategoryFk` = 12, + `workerBusinessTypeFk` = 100, + `amount` = 900.50 + WHERE b.id = 1; -UPDATE `postgresql`.`business_labour` bl - SET bl.`department_id` = 43 -WHERE business_id IN(18, 19); +UPDATE `vn`.`business` b + SET `rate` = 7, + `workerBusinessCategoryFk` = 12, + `workerBusinessTypeFk` = 100, + `amount` = 1263.03 + WHERE b.id = 1106; UPDATE `vn`.`business` b SET `rate` = 7, @@ -1954,17 +1953,12 @@ UPDATE `vn`.`business` b `amount` = 2000 WHERE b.id = 1107; -INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `media_id`) - VALUES - (1, 1106, 1), - (2, 1107, 2); - -INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`) - VALUES - ('1', '27.5', YEAR(util.VN_CURDATE())), - ('5', '22', YEAR(util.VN_CURDATE())), - ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), - ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))); +UPDATE `vn`.`business` b + SET `rate` = 7, + `workerBusinessCategoryFk` = 12, + `workerBusinessTypeFk` = 100, + `amount` = 1500 + WHERE b.id = 1108; INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) VALUES @@ -1975,22 +1969,7 @@ INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlement (20, 'Furlough', '#97B92F', 'furlough', 1, 1), (21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1); -ALTER TABLE `postgresql`.`business_labour_payroll` DROP FOREIGN KEY `business_labour_payroll_cod_categoria`; - -INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent`, `hasHolidayEntitlement`) - VALUES - (1, 'CONTRATO HOLANDA', 1, 0, 1), - (100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1), - (109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1); - -INSERT INTO `postgresql`.`business_labour_payroll` (`business_id`, `cod_tarifa`, `cod_categoria`, `cod_contrato`, `importepactado`) - VALUES - (1, 7, 12, 100, 900.50), - (1106, 7, 12, 100, 1263.03), - (1107, 7, 12, 100, 2000), - (1108, 7, 12, 100, 1500); - -INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) +INSERT INTO `postgresql`.`calendar_employee` (`businessFk`, `calendar_state_id`, `date`) VALUES (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), @@ -2485,18 +2464,18 @@ INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`) INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `foreignValue`, `taxTypeSageFk`, `transactionTypeSageFk`) VALUES - (1, 99.99, '2000000000', null, null, null), - (2, 999.99, '2000000000', null, null, null), - (3, 1000.50, '2000000000', null, null, null), - (4, 0.50, '2000000000', null, null, null), - (5, 150.50, '2000000000', null, null, null), - (1, 252.25, '4751000000', NULL, 7, 61), - (2, 223.17, '6210000567', NULL, 8, 20), - (3, 95.60, '7001000000', NULL, 8, 35), - (4, 446.63, '7001000000', NULL, 6, 61), - (5, 64.23, '6210000567', NULL, 8, 20), - (6, 29.95, '7001000000', NULL, 7, 20), - (7, 58.64, '6210000567', NULL, 8, 20); + (1, 99.99, '2000000000', NULL, NULL, NULL), + (2, 999.99, '2000000000', NULL, NULL, NULL), + (3, 1000.50, '2000000000', NULL, NULL, NULL), + (4, 0.50, '2000000000', NULL, NULL, NULL), + (5, 150.50, '2000000000', NULL, NULL, NULL), + (1, 252.25, '4751000000', NULL, 7, 61), + (2, 223.17, '6210000567', NULL, 8, 20), + (3, 95.60, '7001000000', NULL, 8, 35), + (4, 446.63, '7001000000', NULL, 6, 61), + (5, 64.23, '6210000567', NULL, 8, 20), + (6, 29.95, '7001000000', NULL, 7, 20), + (7, 58.64, '6210000567', NULL, 8, 20); INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk`) VALUES @@ -2506,8 +2485,8 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (2, 16.10, 6021010, 25.00, 80, 5); INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) - SELECT `id` - FROM `vn`.`ticket` t + SELECT t.id + FROM vn.ticket t LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id WHERE tr.ticketFk IS NULL; @@ -2668,3 +2647,23 @@ INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`) VALUES (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); + +INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) + VALUES + (1, 9); + +INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`) + VALUES + (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6); + +INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`) + VALUES + (3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL); + +INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`) + VALUES + (9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL); + +UPDATE `account`.`user` + SET `hasGrant` = 1 + WHERE `id` = 66; From a11ef73dfbb70a780dc503767cab76c3e7476112 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 17 Oct 2022 08:01:55 +0200 Subject: [PATCH 15/36] refactor: code repetead --- .../back/methods/ticket/updateDiscount.js | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 99daac5127..d452b03fef 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -141,17 +141,9 @@ module.exports = Self => { }; await models.SaleComponent.destroyAll(filter, myOptions); - newComponent = models.SaleComponent.create({ - saleFk: sale.id, - value: value, - componentFk: componentId - }, myOptions); - } else { - newComponent = models.SaleComponent.create({ - saleFk: sale.id, - value: value, - componentFk: componentId}, myOptions); - } + await createSaleComponent(sale.id, value, componentId, myOptions); + } else + await createSaleComponent(sale.id, value, componentId, myOptions); const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions); @@ -198,4 +190,14 @@ module.exports = Self => { throw e; } }; + + async function createSaleComponent(saleId, value, componentId, myOptions) { + const models = Self.app.models; + + newComponent = models.SaleComponent.create({ + saleFk: saleId, + value: value, + componentFk: componentId + }, myOptions); + } }; From 06ecceb478373820cfd0d0c9968ae200462c034c Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 17 Oct 2022 08:02:19 +0200 Subject: [PATCH 16/36] refactor: lines to long --- .../back/methods/ticket/specs/componentUpdate.spec.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index 2aa2a07c4c..a8a4d5048a 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -18,13 +18,17 @@ describe('ticket componentUpdate()', () => { beforeAll(async() => { const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}}); deliveryComponentId = deliveryComponenet.id; - componentOfSaleSeven = `SELECT value FROM vn.saleComponent WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`; - componentOfSaleEight = `SELECT value FROM vn.saleComponent WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`; - + componentOfSaleSeven = `SELECT value + FROM vn.saleComponent + WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`; + componentOfSaleEight = `SELECT value + FROM vn.saleComponent + WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`; [componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven); firstvalueBeforeChange = componentValue.value; [componentValue] = await models.SaleComponent.rawSql(componentOfSaleEight); + secondvalueBeforeChange = componentValue.value; }); From cdce628038a2bea5aefd5589a4e68d13a900d69c Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 17 Oct 2022 08:11:50 +0200 Subject: [PATCH 17/36] refactor: delete line break --- modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index a8a4d5048a..b3291c25a4 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -28,7 +28,6 @@ describe('ticket componentUpdate()', () => { firstvalueBeforeChange = componentValue.value; [componentValue] = await models.SaleComponent.rawSql(componentOfSaleEight); - secondvalueBeforeChange = componentValue.value; }); From 787d10aac6c08fb7e69643b622505d9d1d3a47d4 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 17 Oct 2022 08:29:09 +0200 Subject: [PATCH 18/36] fix: select one result only --- modules/ticket/back/methods/ticket/updateDiscount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index d452b03fef..bfa3cdbf64 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -124,7 +124,7 @@ module.exports = Self => { where: {code: 'manaClaim'} }, myOptions); - const oldComponent = await models.SaleComponent.find({ + const [oldComponent] = await models.SaleComponent.find({ where: { and: [ {saleFk: sale.id}, From 79b970286c1b382a8b90a8969e55a1a5a11445d8 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 17 Oct 2022 11:22:27 +0200 Subject: [PATCH 19/36] refactor(claim_claimPickupEmail): use text template and external form --- e2e/paths/06-claim/05_summary.spec.js | 2 +- loopback/locale/en.json | 5 ++- loopback/locale/es.json | 5 ++- .../back/methods/claim/claimPickupEmail.js | 40 +++++++++++++++++++ modules/claim/front/descriptor/index.js | 5 ++- modules/claim/front/descriptor/index.spec.js | 12 +++++- .../claim-pickup-order.html | 2 +- .../claim-pickup-order/claim-pickup-order.js | 2 +- .../claim-pickup-order/claim-pickup-order.js | 3 +- 9 files changed, 64 insertions(+), 12 deletions(-) diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index 00b021f88f..05d18a2c31 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -2,7 +2,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Claim summary path', () => { +fdescribe('Claim summary path', () => { let browser; let page; const claimId = '4'; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index e5a0fae322..e9311800ec 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -133,5 +133,6 @@ "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", "Password does not meet requirements": "Password does not meet requirements", "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", - "Not enough privileges to edit a client": "Not enough privileges to edit a client" -} \ No newline at end of file + "Not enough privileges to edit a client": "Not enough privileges to edit a client", + "Claim pickup order sent": "Claim pickup order sent [({{claimId}})]({{{claimUrl}}}) to client *{{clientName}}*" +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 67370b3438..8caf76836c 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -235,5 +235,6 @@ "Dirección incorrecta": "Dirección incorrecta", "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente" -} \ No newline at end of file + "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", + "Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*" +} diff --git a/modules/claim/back/methods/claim/claimPickupEmail.js b/modules/claim/back/methods/claim/claimPickupEmail.js index 4d64cc66ea..4c9b865025 100644 --- a/modules/claim/back/methods/claim/claimPickupEmail.js +++ b/modules/claim/back/methods/claim/claimPickupEmail.js @@ -29,6 +29,24 @@ module.exports = Self => { type: 'number', description: 'The recipient id to send to the recipient preferred language', required: false + }, + { + arg: 'ticketId', + type: 'number', + description: 'The ticket id', + required: true + }, + { + arg: 'salesPersonId', + type: 'number', + description: 'The salesPerson id', + required: false + }, + { + arg: 'clientName', + type: 'string', + description: 'The client name', + required: true } ], returns: { @@ -42,6 +60,11 @@ module.exports = Self => { }); Self.claimPickupEmail = async ctx => { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const $t = ctx.req.__; // $translate + const origin = ctx.req.headers.origin; + const args = Object.assign({}, ctx.args); const params = { recipient: args.recipient, @@ -52,6 +75,23 @@ module.exports = Self => { for (const param in args) params[param] = args[param]; + const message = $t('Claim pickup order sent', { + claimId: args.id, + clientName: args.clientName, + claimUrl: `${origin}/#!/claim/${args.id}/summary`, + }); + + if (args.salesPersonId) + await models.Chat.sendCheckingPresence(ctx, args.salesPersonId, message); + + await models.ClaimLog.create({ + originFk: args.id, + userFk: userId, + action: 'insert', + description: 'Claim-pickup-order sent', + changedModel: 'Mail' + }); + const email = new Email('claim-pickup-order', params); return email.send(); diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index 0dddadbe14..b36fae3211 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -19,7 +19,10 @@ class Controller extends Descriptor { sendPickupOrder() { return this.vnEmail.send(`Claims/${this.claim.id}/claim-pickup-email`, { recipient: this.claim.client.email, - recipientId: this.claim.clientFk + recipientId: this.claim.clientFk, + clientName: this.claim.client.name, + ticketId: this.claim.ticket.id, + salesPersonId: this.claim.client.salesPersonFk }); } diff --git a/modules/claim/front/descriptor/index.spec.js b/modules/claim/front/descriptor/index.spec.js index e6785d3d8a..18ccdaff5e 100644 --- a/modules/claim/front/descriptor/index.spec.js +++ b/modules/claim/front/descriptor/index.spec.js @@ -7,7 +7,12 @@ describe('Item Component vnClaimDescriptor', () => { const claim = { id: 2, clientFk: 1101, - client: {email: 'client@email'} + client: { + email: 'client@email', + name: 'clientName', + salesPersonFk: 18 + }, + ticket: {id: 2} }; beforeEach(ngModule('claim')); @@ -40,7 +45,10 @@ describe('Item Component vnClaimDescriptor', () => { const params = { recipient: claim.client.email, - recipientId: claim.clientFk + recipientId: claim.clientFk, + clientName: claim.client.name, + ticketId: claim.ticket.id, + salesPersonId: claim.client.salesPersonFk }; controller.sendPickupOrder(); diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.html b/print/templates/email/claim-pickup-order/claim-pickup-order.html index e6e74ed939..32606bd7b4 100644 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.html @@ -23,7 +23,7 @@
-

{{ $t('title', [claimId]) }}

+

{{ $t('title', [id]) }}

{{ $t('description.dear') }},

{{ $t('description.conclusion') }}

diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index 74ee9408d6..51db21cb52 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -9,7 +9,7 @@ module.exports = { 'email-footer': emailFooter.build() }, created() { - this.instructions = this.$t('description.instructions', [this.claimId, this.ticketId]); + this.instructions = this.$t('description.instructions', [this.id, this.ticketId]); }, data() { return { diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.js b/print/templates/reports/claim-pickup-order/claim-pickup-order.js index 0220428454..c2c11cb88c 100755 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js @@ -7,7 +7,6 @@ module.exports = { async serverPrefetch() { this.client = await this.fetchClient(this.id); this.sales = await this.fetchSales(this.id); - this.claimConfig = await this.fetchClaimConfig(); if (!this.client) throw new Error('Something went wrong'); @@ -25,7 +24,7 @@ module.exports = { }, fetchSales(id) { return this.rawSqlFromDef('sales', [id]); - }, + } }, components: { 'report-header': reportHeader.build(), From 57b2ae770da0c34798e01593dad9eed8f9f7b33a Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 17 Oct 2022 11:44:29 +0200 Subject: [PATCH 20/36] fix(e2e) --- e2e/paths/06-claim/05_summary.spec.js | 2 +- modules/claim/front/summary/index.html | 39 +++++++++++++++----------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index 05d18a2c31..00b021f88f 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -2,7 +2,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Claim summary path', () => { +describe('Claim summary path', () => { let browser; let page; const claimId = '4'; diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html index fc1813467a..6adbfd6840 100644 --- a/modules/claim/front/summary/index.html +++ b/modules/claim/front/summary/index.html @@ -25,14 +25,29 @@

- - + +

+ + Basic data + +

+ + + + + + label="Attended by" + value="{{$ctrl.summary.claim.worker.user.nickname}}"> -
- - - - - - +

Date: Mon, 17 Oct 2022 14:01:21 +0200 Subject: [PATCH 21/36] refactor: delete code repeated --- modules/ticket/back/methods/ticket/updateDiscount.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index bfa3cdbf64..7e7c4e06d0 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -140,10 +140,9 @@ module.exports = Self => { componentFk: oldComponent.componentFk }; await models.SaleComponent.destroyAll(filter, myOptions); + } - await createSaleComponent(sale.id, value, componentId, myOptions); - } else - await createSaleComponent(sale.id, value, componentId, myOptions); + await createSaleComponent(sale.id, value, componentId, myOptions); const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions); From 423454d19ea755b1ebc1667c1ebbb6830a7bfb80 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 11:47:22 +0200 Subject: [PATCH 22/36] feat: add date-picker --- modules/ticket/front/expedition/index.html | 20 ++++++++++++-------- modules/ticket/front/expedition/index.js | 15 ++++++++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 35f56872c2..f4b2615339 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -138,25 +138,29 @@ + name="withoutRoute" + ng-click="selectLanded.show('withoutRoute')"> New ticket without route + name="withRoute" + ng-click="selectLanded.show('withRoute')"> New ticket with route + vn-id="selectLanded" + on-accept="$ctrl.createTicket($ctrl.landed, $ctrl.newRoute)"> + + + ng-model="$ctrl.newRoute"> diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index f7674716b1..49ba3280d7 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -2,6 +2,12 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { + constructor($element, $scope) { + super($element, $scope); + this.landed = new Date(); + this.newRoute = null; + } + get checked() { const rows = this.$.model.data || []; const checkedRows = []; @@ -28,7 +34,7 @@ class Controller extends Section { } onRemove() { - const params = {expeditionsIds: this.checked}; + const params = {expeditionIds: this.checked}; const query = `Expeditions/deleteExpeditions`; this.$http.post(query, params) .then(() => { @@ -37,11 +43,10 @@ class Controller extends Section { }); } - createTicket(routeFk) { - const date = new Date(); // esta fecha hay que preguntarla a Fran Monsalvez + createTicket(landed, routeFk) { const ticketParams = { clientId: this.ticket.clientFk, - landed: date, + landed: landed, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, warehouseId: this.ticket.warehouseFk @@ -50,7 +55,7 @@ class Controller extends Section { this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); const params = { - expeditionsIds: this.checked, + expeditionIds: this.checked, ticketId: res.data.id }; const query = `Expeditions/moveExpeditions`; From 5fce93abd5bd36720eec2ffa6d7df0f0ec3cbcd4 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 11:47:37 +0200 Subject: [PATCH 23/36] refactor: change variables name --- modules/ticket/back/methods/expedition/deleteExpeditions.js | 6 +++--- modules/ticket/back/methods/expedition/moveExpeditions.js | 6 +++--- modules/ticket/front/expedition/index.spec.js | 4 ++-- modules/ticket/front/expedition/locale/es.yml | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index b902b9f0c5..5b9d0daaa3 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -4,7 +4,7 @@ module.exports = Self => { description: 'Delete the selected expeditions', accessType: 'WRITE', accepts: [{ - arg: 'expeditionsIds', + arg: 'expeditionIds', type: ['number'], required: true, description: 'The expeditions ids to delete' @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.deleteExpeditions = async(expeditionsIds, options) => { + Self.deleteExpeditions = async(expeditionIds, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -34,7 +34,7 @@ module.exports = Self => { try { const deletedExpeditions = await models.Expedition.destroyAll({ - id: {inq: expeditionsIds} + id: {inq: expeditionIds} }, myOptions); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 2c521dda7c..338568fdb4 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -4,7 +4,7 @@ module.exports = Self => { description: 'Move the selected expeditions to another ticket', accessType: 'WRITE', accepts: [{ - arg: 'expeditionsIds', + arg: 'expeditionIds', type: ['number'], required: true, description: 'The expeditions ids to nove' @@ -25,7 +25,7 @@ module.exports = Self => { } }); - Self.moveExpeditions = async(expeditionsIds, ticketId, options) => { + Self.moveExpeditions = async(expeditionIds, ticketId, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -40,7 +40,7 @@ module.exports = Self => { try { const promises = []; - for (let expeditionsId of expeditionsIds) { + for (let expeditionsId of expeditionIds) { const expeditionToUpdate = await models.Expedition.findById(expeditionsId); const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); promises.push(expeditionUpdated); diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index fe23046ce2..ad5dafbd7b 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -63,7 +63,7 @@ describe('Ticket', () => { it('should make a query and then call to the model refresh() method', () => { jest.spyOn($scope.model, 'refresh'); - const expectedParams = {expeditionsIds: [1, 2]}; + const expectedParams = {expeditionIds: [1, 2]}; $httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200); controller.onRemove(); $httpBackend.flush(); @@ -97,7 +97,7 @@ describe('Ticket', () => { const expectedResponse = {id: ticketIdToTransfer}; const expectedParams = { - expeditionsIds: [1, 2], + expeditionIds: [1, 2], ticketId: 28 }; $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index bc3ec33455..68812f9850 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -2,4 +2,5 @@ Status log: Hitorial de estados Expedition removed: Expedición eliminada Move: Mover New ticket without route: Nuevo ticket sin ruta -New ticket with route: Nuevo ticket con ruta \ No newline at end of file +New ticket with route: Nuevo ticket con ruta +Id route: Id ruta \ No newline at end of file From ae3e3c3c49c4dc474d96fbd510febaa03fb28f7c Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 12:37:06 +0200 Subject: [PATCH 24/36] fix: id model duplicated --- modules/ticket/front/expedition/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index f4b2615339..0ebe388c12 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -98,16 +98,16 @@ - + - + State From 9ea427dbfece8d68a6350e1f9861f2222c31f631 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 13:45:46 +0200 Subject: [PATCH 25/36] refactor: move front to back funcionality --- loopback/locale/es.json | 3 +- .../methods/expedition/moveExpeditions.js | 60 +++++++++++++++---- modules/ticket/front/expedition/index.js | 17 ++---- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 67370b3438..bd9de41c29 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -235,5 +235,6 @@ "Dirección incorrecta": "Dirección incorrecta", "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente" + "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", + "This route not exists": "Esta ruta no existe" } \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 338568fdb4..d0f8aa8939 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -1,19 +1,47 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('moveExpeditions', { + Self.remoteMethodCtx('moveExpeditions', { description: 'Move the selected expeditions to another ticket', accessType: 'WRITE', accepts: [{ + arg: 'clientId', + type: 'number', + description: `The client id`, + required: true + }, + { + arg: 'landed', + type: 'date', + description: `The landing date` + }, + { + arg: 'warehouseId', + type: 'number', + description: `The warehouse id`, + required: true + }, + { + arg: 'addressId', + type: 'number', + description: `The address id`, + required: true + }, + { + arg: 'agencyModeId', + type: 'any', + description: `The agencyMode id` + }, + { + arg: 'routeId', + type: 'any', + description: `The route id` + }, + { arg: 'expeditionIds', type: ['number'], required: true, - description: 'The expeditions ids to nove' - }, - { - arg: 'ticketId', - type: 'number', - required: true, - description: 'the ticket id to which the expeditions are added' + description: 'The expeditions ids to move' }], returns: { type: 'object', @@ -25,8 +53,9 @@ module.exports = Self => { } }); - Self.moveExpeditions = async(expeditionIds, ticketId, options) => { + Self.moveExpeditions = async(ctx, options) => { const models = Self.app.models; + const args = ctx.args; const myOptions = {}; let tx; @@ -39,18 +68,23 @@ module.exports = Self => { } try { + if (args.routeId) { + const route = await models.Route.findById(args.routeId, null, myOptions); + if (!route) throw new UserError('This route not exists'); + } + const ticket = await models.Ticket.new(ctx, myOptions); const promises = []; - for (let expeditionsId of expeditionIds) { + for (let expeditionsId of args.expeditionIds) { const expeditionToUpdate = await models.Expedition.findById(expeditionsId); - const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); + const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } - const updated = await Promise.all(promises); + await Promise.all(promises); if (tx) await tx.commit(); - return updated; + return ticket; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 49ba3280d7..7ffe2fe5e6 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -44,22 +44,17 @@ class Controller extends Section { } createTicket(landed, routeFk) { - const ticketParams = { + const params = { clientId: this.ticket.clientFk, landed: landed, + warehouseId: this.ticket.warehouseFk, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, - warehouseId: this.ticket.warehouseFk + routeId: routeFk, + expeditionIds: this.checked }; - const query = `Tickets/new`; - this.$http.post(query, ticketParams).then(res => { - if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); - const params = { - expeditionIds: this.checked, - ticketId: res.data.id - }; - const query = `Expeditions/moveExpeditions`; - this.$http.post(query, params); + const query = `Expeditions/moveExpeditions`; + this.$http.post(query, params).then(res => { this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); From 6f7ec12cb2119ce6584811d7d4228bdd8df499fb Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 19 Oct 2022 10:35:41 +0200 Subject: [PATCH 26/36] feat: response as 'reply' and not as 'internNote' --- back/methods/osticket/closeTicket.js | 48 ++++++++++++++----- back/models/osticket-config.json | 12 +++-- db/changes/10481-june/00-osTicketConfig.sql | 6 +-- db/changes/10491-august/00-osTicketConfig.sql | 8 ++++ db/dump/fixtures.sql | 4 ++ package.json | 1 + 6 files changed, 58 insertions(+), 21 deletions(-) create mode 100644 db/changes/10491-august/00-osTicketConfig.sql diff --git a/back/methods/osticket/closeTicket.js b/back/methods/osticket/closeTicket.js index 87d54d3b86..33fe5958b0 100644 --- a/back/methods/osticket/closeTicket.js +++ b/back/methods/osticket/closeTicket.js @@ -1,12 +1,13 @@ const jsdom = require('jsdom'); const mysql = require('mysql'); +const FormData = require('form-data'); module.exports = Self => { Self.remoteMethodCtx('closeTicket', { description: 'Close tickets without response from the user', accessType: 'READ', returns: { - type: 'Object', + type: 'object', root: true }, http: { @@ -54,9 +55,9 @@ module.exports = Self => { }); }); - await requestToken(); + await getRequestToken(); - async function requestToken() { + async function getRequestToken() { const response = await fetch(ostUri); const result = response.headers.get('set-cookie'); @@ -93,24 +94,45 @@ module.exports = Self => { await close(token, secondCookie); } + async function getLockCode(token, secondCookie, ticketId) { + const ostUri = `${config.host}/ajax.php/lock/ticket/${ticketId}`; + const params = { + method: 'POST', + headers: { + 'X-CSRFToken': token, + 'Cookie': secondCookie + } + }; + const response = await fetch(ostUri, params); + const body = await response.text(); + const json = JSON.parse(body); + + return json.code; + } + async function close(token, secondCookie) { for (const ticketId of ticketsId) { - const ostUri = `${config.host}/ajax.php/tickets/${ticketId}/status`; - const data = { - status_id: config.newStatusId, - comments: config.comment, - undefined: config.action - }; + const lockCode = await getLockCode(token, secondCookie, ticketId); + let form = new FormData(); + form.append('__CSRFToken__', token); + form.append('id', ticketId); + form.append('a', config.responseType); + form.append('lockCode', lockCode); + form.append('from_email_id', config.fromEmailId); + form.append('reply-to', config.replyTo); + form.append('cannedResp', 0); + form.append('response', config.comment); + form.append('signature', 'none'); + form.append('reply_status_id', config.newStatusId); + + const ostUri = `${config.host}/tickets.php?id=${ticketId}`; const params = { method: 'POST', - body: new URLSearchParams(data), + body: form, headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', - 'X-CSRFToken': token, 'Cookie': secondCookie } }; - return fetch(ostUri, params); } } diff --git a/back/models/osticket-config.json b/back/models/osticket-config.json index d42632c6a5..5a863e7bc7 100644 --- a/back/models/osticket-config.json +++ b/back/models/osticket-config.json @@ -27,9 +27,6 @@ "newStatusId": { "type": "number" }, - "action": { - "type": "string" - }, "day": { "type": "number" }, @@ -47,6 +44,15 @@ }, "portDb": { "type": "number" + }, + "responseType": { + "type": "string" + }, + "fromEmailId": { + "type": "number" + }, + "replyTo": { + "type": "string" } } } \ No newline at end of file diff --git a/db/changes/10481-june/00-osTicketConfig.sql b/db/changes/10481-june/00-osTicketConfig.sql index ad66627153..8727c816dd 100644 --- a/db/changes/10481-june/00-osTicketConfig.sql +++ b/db/changes/10481-june/00-osTicketConfig.sql @@ -13,8 +13,4 @@ CREATE TABLE `vn`.`osTicketConfig` ( `passwordDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `portDb` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; - -INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`) - VALUES - (0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL); \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file diff --git a/db/changes/10491-august/00-osTicketConfig.sql b/db/changes/10491-august/00-osTicketConfig.sql new file mode 100644 index 0000000000..10a58b6c82 --- /dev/null +++ b/db/changes/10491-august/00-osTicketConfig.sql @@ -0,0 +1,8 @@ +ALTER TABLE `vn`.`osTicketConfig` DROP COLUMN `action`; +ALTER TABLE `vn`.`osTicketConfig` ADD responseType varchar(100) NULL; +ALTER TABLE `vn`.`osTicketConfig` ADD fromEmailId INT NULL; +ALTER TABLE `vn`.`osTicketConfig` ADD replyTo varchar(100) NULL; + +UPDATE `vn`.`osTicketConfig` + SET responseType='reply', fromEmailId=5, replyTo='all' +WHERE id=0; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 7e59c1a54a..b3f2d9c262 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2667,3 +2667,7 @@ INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `lev UPDATE `account`.`user` SET `hasGrant` = 1 WHERE `id` = 66; + +INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) + VALUES + (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); \ No newline at end of file diff --git a/package.json b/package.json index 26c164832a..5ab329875a 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "bcrypt": "^5.0.1", "bmp-js": "^0.1.0", "compression": "^1.7.3", + "form-data": "^4.0.0", "fs-extra": "^5.0.0", "ftps": "^1.2.0", "got": "^10.7.0", From 51cad752984fb2d13f804772aa8bec233430e4f7 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 08:17:15 +0200 Subject: [PATCH 27/36] fix: testFront --- modules/ticket/front/expedition/index.spec.js | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index ad5dafbd7b..b95d64fa34 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -83,29 +83,25 @@ describe('Ticket', () => { agencyModeFk: 1, warehouseFk: 1 }; + const routeId = null; controller.ticket = ticket; - const expectedTicket = { - clientId: 1101, - landed: new Date(), - addressId: 121, - agencyModeId: 1, - warehouseId: 1 - }; - - const ticketIdToTransfer = 28; - const expectedResponse = {id: ticketIdToTransfer}; + const ticketToTransfer = {id: 28}; const expectedParams = { - expeditionIds: [1, 2], - ticketId: 28 + clientId: 1101, + landed: new Date(), + warehouseId: 1, + addressId: 121, + agencyModeId: 1, + routeId: null, + expeditionIds: [1, 2] }; - $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); - $httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(200); - controller.createTicket(); + $httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(ticketToTransfer); + controller.createTicket(ticket.landed, routeId); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketIdToTransfer}); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketToTransfer.id}); }); }); }); From bcc9acac0ac997d9c54df4e12efc830dc50c1331 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 08:41:00 +0200 Subject: [PATCH 28/36] fix: tBack --- .../expedition/specs/moveExpeditions.spec.js | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index 0bb402a558..67919e76c0 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -1,17 +1,33 @@ const models = require('vn-loopback/server/server').models; describe('ticket moveExpeditions()', () => { - it('should delete the selected expeditions', async() => { + it('should move the selected expeditions to new ticket', async() => { const tx = await models.Expedition.beginTransaction({}); + const ctx = { + req: {accessToken: {userId: 9}}, + args: {}, + params: {} + }; + const myCtx = Object.assign({}, ctx); try { const options = {transaction: tx}; + myCtx.args = { + clientId: 1101, + landed: new Date(), + warehouseId: 1, + addressId: 121, + agencyModeId: 1, + routeId: null, + expeditionIds: [1, 2] - const expeditionIds = [12, 13]; - const ticketId = 1; - const result = await models.Expedition.moveExpeditions(expeditionIds, ticketId, options); + }; - expect(result.length).toEqual(2); + const ticket = await models.Expedition.moveExpeditions(myCtx, options); + + const newestTicketIdInFixtures = 27; + + expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures); await tx.rollback(); } catch (e) { From 2da34d0850de92ee8684fb9d339b59a4ff2cc852 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 09:40:11 +0200 Subject: [PATCH 29/36] feat: add e2e --- e2e/helpers/selectors.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 74dabc31ad..dabb4c0cdc 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -596,8 +596,14 @@ export default { submitNotesButton: 'button[type=submit]' }, ticketExpedition: { + firstSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(1) vn-check[ng-model="expedition.checked"]', thirdSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(3) vn-check[ng-model="expedition.checked"]', deleteExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="delete"]', + moveExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="keyboard_arrow_down"]', + moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]', + moreMenuWithRoute: 'vn-item[name="withRoute"]', + newRouteId: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newRoute"]', + saveButton: '.vn-dialog.shown [response="accept"]', expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr' }, ticketPackages: { From 5824fee213055de7401a1ebd3e63f7879199315a Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 09:40:23 +0200 Subject: [PATCH 30/36] feat: add e2e --- e2e/paths/05-ticket/20_moveExpedition.spec.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e/paths/05-ticket/20_moveExpedition.spec.js diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js new file mode 100644 index 0000000000..9673c70717 --- /dev/null +++ b/e2e/paths/05-ticket/20_moveExpedition.spec.js @@ -0,0 +1,50 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +fdescribe('Ticket expeditions', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('production', 'ticket'); + await page.accessToSearchResult('1'); + await page.accessToSection('ticket.card.expedition'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should move one expedition to new ticket withoute route`, async() => { + await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox); + await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton); + await page.waitToClick(selectors.ticketExpedition.moreMenuWithoutRoute); + await page.waitToClick(selectors.ticketExpedition.saveButton); + await page.waitForState('ticket.card.summary'); + await page.accessToSection('ticket.card.expedition'); + + await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); + const result = await page + .countElement(selectors.ticketExpedition.expeditionRow); + + expect(result).toEqual(1); + }); + + it(`should move one expedition to new ticket with route`, async() => { + await page.waitToClick(selectors.ticketExpedition.firstSaleCheckbox); + await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton); + await page.waitToClick(selectors.ticketExpedition.moreMenuWithRoute); + await page.write(selectors.ticketExpedition.newRouteId, '1'); + await page.waitToClick(selectors.ticketExpedition.saveButton); + await page.waitForState('ticket.card.summary'); + await page.accessToSection('ticket.card.expedition'); + + await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); + const result = await page + .countElement(selectors.ticketExpedition.expeditionRow); + + expect(result).toEqual(1); + }); +}); From dd15d06f5edfb7c439482764551175e7fe225b70 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 10:21:44 +0200 Subject: [PATCH 31/36] delete focus test --- e2e/paths/05-ticket/20_moveExpedition.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js index 9673c70717..cf1c5ded32 100644 --- a/e2e/paths/05-ticket/20_moveExpedition.spec.js +++ b/e2e/paths/05-ticket/20_moveExpedition.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Ticket expeditions', () => { +describe('Ticket expeditions', () => { let browser; let page; From 925565d3d24037bb53d209823db0b5cef12bc83c Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 08:23:36 +0200 Subject: [PATCH 32/36] =?UTF-8?q?refator:=20borrada=20variable=20global=20?= =?UTF-8?q?y=20a=C3=B1adida=20Promesa=20al=20array?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/ticket/back/methods/ticket/updateDiscount.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 7e7c4e06d0..a60d732b14 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -133,20 +133,20 @@ module.exports = Self => { } }, myOptions); - let newComponent; + let deletedComponent; if (oldComponent) { const filter = { saleFk: sale.id, componentFk: oldComponent.componentFk }; - await models.SaleComponent.destroyAll(filter, myOptions); + deletedComponent = await models.SaleComponent.destroyAll(filter, myOptions); } - await createSaleComponent(sale.id, value, componentId, myOptions); + const newComponent = await createSaleComponent(sale.id, value, componentId, myOptions); const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions); - promises.push(newComponent, updatedSale); + promises.push(newComponent, updatedSale, deletedComponent); const change = `${oldDiscount}% ➔ *${newDiscount}%*`; changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${change}`; @@ -193,7 +193,7 @@ module.exports = Self => { async function createSaleComponent(saleId, value, componentId, myOptions) { const models = Self.app.models; - newComponent = models.SaleComponent.create({ + return models.SaleComponent.create({ saleFk: saleId, value: value, componentFk: componentId From d4e278363009abaa45090212dc3e50a2f0430086 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 08:39:07 +0200 Subject: [PATCH 33/36] =?UTF-8?q?refactor:=20corregidas=20traducciones,=20?= =?UTF-8?q?eliminado=20destroyAll=20y=20a=C3=B1adida=20transacci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/locale/es.json | 2 +- .../back/methods/expedition/deleteExpeditions.js | 10 +++++++--- .../ticket/back/methods/expedition/moveExpeditions.js | 4 ++-- .../methods/expedition/specs/deleteExpeditions.spec.js | 2 +- modules/ticket/front/expedition/index.html | 2 +- modules/ticket/front/expedition/locale/es.yml | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index bd9de41c29..2d9bae1d83 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -236,5 +236,5 @@ "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", - "This route not exists": "Esta ruta no existe" + "This route does not exists": "Esta ruta no existe" } \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 5b9d0daaa3..2419d3a5e8 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -33,9 +33,13 @@ module.exports = Self => { } try { - const deletedExpeditions = await models.Expedition.destroyAll({ - id: {inq: expeditionIds} - }, myOptions); + const promises = []; + for (let expeditionId of expeditionIds) { + const deletedExpedition = models.Expedition.destroyById(expeditionId, myOptions); + promises.push(deletedExpedition); + } + + const deletedExpeditions = await Promise.all(promises); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index d0f8aa8939..cef35ab867 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -70,12 +70,12 @@ module.exports = Self => { try { if (args.routeId) { const route = await models.Route.findById(args.routeId, null, myOptions); - if (!route) throw new UserError('This route not exists'); + if (!route) throw new UserError('This route does not exists'); } const ticket = await models.Ticket.new(ctx, myOptions); const promises = []; for (let expeditionsId of args.expeditionIds) { - const expeditionToUpdate = await models.Expedition.findById(expeditionsId); + const expeditionToUpdate = await models.Expedition.findById(expeditionsId, null, myOptions); const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js index 0a47c78da1..14bdf7aea6 100644 --- a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js @@ -10,7 +10,7 @@ describe('ticket deleteExpeditions()', () => { const expeditionIds = [12, 13]; const result = await models.Expedition.deleteExpeditions(expeditionIds, options); - expect(result.count).toEqual(2); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 0ebe388c12..ec6dc7ee2b 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -159,7 +159,7 @@ diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index 68812f9850..278dcc8f2a 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -3,4 +3,4 @@ Expedition removed: Expedición eliminada Move: Mover New ticket without route: Nuevo ticket sin ruta New ticket with route: Nuevo ticket con ruta -Id route: Id ruta \ No newline at end of file +Route id: Id ruta \ No newline at end of file From 9225e8f176c192464bae875f4324ca393ab8734e Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 27 Oct 2022 15:11:57 +0200 Subject: [PATCH 34/36] fix tests --- back/methods/chat/sendCheckingPresence.js | 4 ++ .../10500-november/00-deletePickupContact.sql | 1 + db/dump/fixtures.sql | 8 ++-- .../back/methods/claim/claimPickupEmail.js | 41 +++++++++---------- modules/claim/front/descriptor/index.js | 5 +-- modules/claim/front/descriptor/index.spec.js | 12 +----- package.json | 2 +- .../claim-pickup-order/claim-pickup-order.js | 21 +++++----- .../email/claim-pickup-order/sql/ticket.sql | 4 ++ 9 files changed, 47 insertions(+), 51 deletions(-) create mode 100644 db/changes/10500-november/00-deletePickupContact.sql create mode 100644 print/templates/email/claim-pickup-order/sql/ticket.sql diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3bc022429c..556a16260e 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -25,6 +25,7 @@ module.exports = Self => { }); Self.sendCheckingPresence = async(ctx, recipientId, message, options) => { + console.log(ctx, recipientId, message, options); if (!recipientId) return false; const myOptions = {}; @@ -38,7 +39,10 @@ module.exports = Self => { const recipient = await models.Account.findById(recipientId, null, myOptions); // Prevent sending messages to yourself + console.log('llega'); + console.log(recipientId, userId); if (recipientId == userId) return false; + console.log('llega2'); if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); diff --git a/db/changes/10500-november/00-deletePickupContact.sql b/db/changes/10500-november/00-deletePickupContact.sql new file mode 100644 index 0000000000..6bfa662c5e --- /dev/null +++ b/db/changes/10500-november/00-deletePickupContact.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`claimConfig` DROP COLUMN `pickupContact`; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 9a0a1fff6e..34e592b9a0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1778,10 +1778,10 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina (1, 31, 4, 21, 2), (2, 32, 3, 21, 3); -INSERT INTO `vn`.`claimConfig`(`id`, `pickupContact`, `maxResponsibility`) +INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`) VALUES - (1, 'Contact description', 50), - (2, 'Contact description', 30); + (1, 50), + (2, 30); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES @@ -1791,7 +1791,7 @@ INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRa (1104, 2500, 150.00, 0.02, 0.10, 1.00); INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`) -VALUES + VALUES (1, '02676A049183', DEFAULT, 1106), (2, '02676A049183', DEFAULT, 1106), (3, '02676A049183', DEFAULT, 1107), diff --git a/modules/claim/back/methods/claim/claimPickupEmail.js b/modules/claim/back/methods/claim/claimPickupEmail.js index 4c9b865025..23f0e31ef7 100644 --- a/modules/claim/back/methods/claim/claimPickupEmail.js +++ b/modules/claim/back/methods/claim/claimPickupEmail.js @@ -9,7 +9,7 @@ module.exports = Self => { arg: 'id', type: 'number', required: true, - description: 'The client id', + description: 'The claim id', http: {source: 'path'} }, { @@ -29,24 +29,6 @@ module.exports = Self => { type: 'number', description: 'The recipient id to send to the recipient preferred language', required: false - }, - { - arg: 'ticketId', - type: 'number', - description: 'The ticket id', - required: true - }, - { - arg: 'salesPersonId', - type: 'number', - description: 'The salesPerson id', - required: false - }, - { - arg: 'clientName', - type: 'string', - description: 'The client name', - required: true } ], returns: { @@ -75,14 +57,29 @@ module.exports = Self => { for (const param in args) params[param] = args[param]; + const claim = await models.Claim.findById(args.id, { + fields: ['id', 'clientFk'], + include: { + relation: 'client', + scope: { + fields: ['name', 'salesPersonFk'] + } + } + }); + console.log(claim); + const message = $t('Claim pickup order sent', { claimId: args.id, - clientName: args.clientName, + clientName: claim.client.name, claimUrl: `${origin}/#!/claim/${args.id}/summary`, }); - if (args.salesPersonId) - await models.Chat.sendCheckingPresence(ctx, args.salesPersonId, message); + console.log(claim.client()); + const salesPersonId = claim.client().salesPersonFk; + if (claim.client().salesPersonFk) + console.log(await models.Chat.sendCheckingPresence(ctx, 25, message)); + + console.log(claim.client().salesPersonFk); await models.ClaimLog.create({ originFk: args.id, diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index b36fae3211..0dddadbe14 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -19,10 +19,7 @@ class Controller extends Descriptor { sendPickupOrder() { return this.vnEmail.send(`Claims/${this.claim.id}/claim-pickup-email`, { recipient: this.claim.client.email, - recipientId: this.claim.clientFk, - clientName: this.claim.client.name, - ticketId: this.claim.ticket.id, - salesPersonId: this.claim.client.salesPersonFk + recipientId: this.claim.clientFk }); } diff --git a/modules/claim/front/descriptor/index.spec.js b/modules/claim/front/descriptor/index.spec.js index 18ccdaff5e..e6785d3d8a 100644 --- a/modules/claim/front/descriptor/index.spec.js +++ b/modules/claim/front/descriptor/index.spec.js @@ -7,12 +7,7 @@ describe('Item Component vnClaimDescriptor', () => { const claim = { id: 2, clientFk: 1101, - client: { - email: 'client@email', - name: 'clientName', - salesPersonFk: 18 - }, - ticket: {id: 2} + client: {email: 'client@email'} }; beforeEach(ngModule('claim')); @@ -45,10 +40,7 @@ describe('Item Component vnClaimDescriptor', () => { const params = { recipient: claim.client.email, - recipientId: claim.clientFk, - clientName: claim.client.name, - ticketId: claim.ticket.id, - salesPersonId: claim.client.salesPersonFk + recipientId: claim.clientFk }; controller.sendPickupOrder(); diff --git a/package.json b/package.json index 26c164832a..be6db46a82 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "node-ssh": "^11.0.0", "object-diff": "0.0.4", "object.pick": "^1.3.0", - "puppeteer": "^18.0.5", + "puppeteer": "^19.2.0", "read-chunk": "^3.2.0", "require-yaml": "0.0.1", "sharp": "^0.31.0", diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index 51db21cb52..b8804c6040 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -8,22 +8,23 @@ module.exports = { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build() }, - created() { - this.instructions = this.$t('description.instructions', [this.id, this.ticketId]); + async serverPrefetch() { + this.ticket = await this.fetchTicket(this.id); + + if (!this.ticket) + throw new Error('Something went wrong'); + console.log(); + this.instructions = this.$t('description.instructions', [this.id, this.ticket.id]); }, - data() { - return { - instructions: String - }; + methods: { + fetchTicket(id) { + return this.findOneFromDef('ticket', [id]); + } }, props: { id: { type: [Number, String], required: true - }, - ticketId: { - type: [Number, String], - required: true } } }; diff --git a/print/templates/email/claim-pickup-order/sql/ticket.sql b/print/templates/email/claim-pickup-order/sql/ticket.sql new file mode 100644 index 0000000000..28b78c9875 --- /dev/null +++ b/print/templates/email/claim-pickup-order/sql/ticket.sql @@ -0,0 +1,4 @@ +SELECT + c.ticketFk as id +FROM claim c +WHERE c.id = ? From 9170c22d6f80515a3251ba003ac8494fc0c5b262 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 28 Oct 2022 09:21:28 +0200 Subject: [PATCH 35/36] fix send email --- back/methods/chat/sendCheckingPresence.js | 4 ---- modules/claim/back/methods/claim/claimPickupEmail.js | 10 +++------- .../email/claim-pickup-order/claim-pickup-order.js | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 556a16260e..3bc022429c 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -25,7 +25,6 @@ module.exports = Self => { }); Self.sendCheckingPresence = async(ctx, recipientId, message, options) => { - console.log(ctx, recipientId, message, options); if (!recipientId) return false; const myOptions = {}; @@ -39,10 +38,7 @@ module.exports = Self => { const recipient = await models.Account.findById(recipientId, null, myOptions); // Prevent sending messages to yourself - console.log('llega'); - console.log(recipientId, userId); if (recipientId == userId) return false; - console.log('llega2'); if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); diff --git a/modules/claim/back/methods/claim/claimPickupEmail.js b/modules/claim/back/methods/claim/claimPickupEmail.js index 23f0e31ef7..c688d6ded2 100644 --- a/modules/claim/back/methods/claim/claimPickupEmail.js +++ b/modules/claim/back/methods/claim/claimPickupEmail.js @@ -66,20 +66,16 @@ module.exports = Self => { } } }); - console.log(claim); const message = $t('Claim pickup order sent', { claimId: args.id, - clientName: claim.client.name, + clientName: claim.client().name, claimUrl: `${origin}/#!/claim/${args.id}/summary`, }); - console.log(claim.client()); const salesPersonId = claim.client().salesPersonFk; - if (claim.client().salesPersonFk) - console.log(await models.Chat.sendCheckingPresence(ctx, 25, message)); - - console.log(claim.client().salesPersonFk); + if (salesPersonId) + await models.Chat.sendCheckingPresence(ctx, salesPersonId, message); await models.ClaimLog.create({ originFk: args.id, diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index b8804c6040..29f295b1ee 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -13,7 +13,7 @@ module.exports = { if (!this.ticket) throw new Error('Something went wrong'); - console.log(); + this.instructions = this.$t('description.instructions', [this.id, this.ticket.id]); }, methods: { From a7b1ee85fec2bcd7eab29fed84c642de265224f7 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 2 Nov 2022 07:27:57 +0100 Subject: [PATCH 36/36] fix changes folder --- .../{10490-goldenSummer => 10500-november}/00-aclNotification.sql | 0 .../{10490-august => 10500-november}/00-packingSiteConfig.sql | 0 .../{10490-august => 10500-november}/00-packingSiteUpdate.sql | 0 db/changes/{10490-august => 10500-november}/00-salix_url.sql | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename db/changes/{10490-goldenSummer => 10500-november}/00-aclNotification.sql (100%) rename db/changes/{10490-august => 10500-november}/00-packingSiteConfig.sql (100%) rename db/changes/{10490-august => 10500-november}/00-packingSiteUpdate.sql (100%) rename db/changes/{10490-august => 10500-november}/00-salix_url.sql (100%) diff --git a/db/changes/10490-goldenSummer/00-aclNotification.sql b/db/changes/10500-november/00-aclNotification.sql similarity index 100% rename from db/changes/10490-goldenSummer/00-aclNotification.sql rename to db/changes/10500-november/00-aclNotification.sql diff --git a/db/changes/10490-august/00-packingSiteConfig.sql b/db/changes/10500-november/00-packingSiteConfig.sql similarity index 100% rename from db/changes/10490-august/00-packingSiteConfig.sql rename to db/changes/10500-november/00-packingSiteConfig.sql diff --git a/db/changes/10490-august/00-packingSiteUpdate.sql b/db/changes/10500-november/00-packingSiteUpdate.sql similarity index 100% rename from db/changes/10490-august/00-packingSiteUpdate.sql rename to db/changes/10500-november/00-packingSiteUpdate.sql diff --git a/db/changes/10490-august/00-salix_url.sql b/db/changes/10500-november/00-salix_url.sql similarity index 100% rename from db/changes/10490-august/00-salix_url.sql rename to db/changes/10500-november/00-salix_url.sql