diff --git a/db/changes/224701/00-ACL.sql b/db/changes/224701/00-ACL.sql new file mode 100644 index 000000000..2cce197b2 --- /dev/null +++ b/db/changes/224701/00-ACL.sql @@ -0,0 +1,49 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('ClientConsumptionQueue', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'deliveryNotePdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'deliveryNoteEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'deliveryNoteCsvPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'deliveryNoteCsvEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'clientWelcomeHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'clientWelcomeEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'creditRequestPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'creditRequestHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'creditRequestEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'printerSetupHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'printerSetupEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'sepaCoreEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'letterDebtorPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'letterDebtorStHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'letterDebtorStEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'letterDebtorNdEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'clientDebtStatementPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'clientDebtStatementEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'incotermsAuthorizationPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'incotermsAuthorizationHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'incotermsAuthorizationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'consumptionSendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'), + ('InvoiceOut', 'invoiceEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('InvoiceOut', 'exportationPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('InvoiceOut', 'sendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'), + ('Ticket', 'invoiceCsvPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'invoiceCsvEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Supplier', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Supplier', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Travel', 'extraCommunityPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Travel', 'extraCommunityEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Entry', 'entryOrderPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('OsTicket', 'osTicketReportEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'), + ('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'), + ('Claim', 'claimPickupPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Claim', 'claimPickupEmail', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'), + ('Item', 'labelPdf', 'READ', 'ALLOW', 'ROLE', 'employee'); + +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Sector','*','READ','ALLOW','ROLE','employee'); +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Sector','*','WRITE','ALLOW','ROLE','employee'); diff --git a/db/changes/224701/00-acl_receiptPdf.sql b/db/changes/224701/00-acl_receiptPdf.sql new file mode 100644 index 000000000..42f84b87d --- /dev/null +++ b/db/changes/224701/00-acl_receiptPdf.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Receipt', 'receiptPdf', '*', 'ALLOW', 'ROLE', 'salesAssistant'); diff --git a/db/changes/224701/00-clientConsumptionQueue.sql b/db/changes/224701/00-clientConsumptionQueue.sql new file mode 100644 index 000000000..2734d32cc --- /dev/null +++ b/db/changes/224701/00-clientConsumptionQueue.sql @@ -0,0 +1,9 @@ +create table `vn`.`clientConsumptionQueue` +( + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + params json not null, + queued datetime default current_timestamp() not null, + printed datetime null, + status varchar(50) default '' null +) + comment 'Queue for client consumption PDF mailing'; diff --git a/db/changes/224701/00-invoiceOutQueue.sql b/db/changes/224701/00-invoiceOutQueue.sql new file mode 100644 index 000000000..52ed4a113 --- /dev/null +++ b/db/changes/224701/00-invoiceOutQueue.sql @@ -0,0 +1 @@ +rename table `vn`.`invoiceOut_queue` to `vn`.`invoiceOutQueue`; diff --git a/db/changes/224701/00-itemConfig.sql b/db/changes/224701/00-itemConfig.sql new file mode 100644 index 000000000..b148aa094 --- /dev/null +++ b/db/changes/224701/00-itemConfig.sql @@ -0,0 +1,5 @@ +ALTER TABLE `vn`.`itemConfig` + ADD id int null PRIMARY KEY first; + +ALTER TABLE `vn`.`itemConfig` + ADD wasteRecipients VARCHAR(50) NOT NULL comment 'Weekly waste report schedule recipients'; diff --git a/db/changes/224701/00-printConfig.sql b/db/changes/224701/00-printConfig.sql new file mode 100644 index 000000000..c5af09ac9 --- /dev/null +++ b/db/changes/224701/00-printConfig.sql @@ -0,0 +1,10 @@ +create table `salix`.`printConfig` +( + id int auto_increment, + itRecipient varchar(50) null comment 'IT recipients for report mailing', + incidencesEmail varchar(50) null comment 'CAU destinatary email', + constraint printConfig_pk + primary key (id) +) + comment 'Print service config'; + diff --git a/db/changes/224701/00-sale_afterUpdate.sql b/db/changes/224701/00-sale_afterUpdate.sql new file mode 100644 index 000000000..407fb52c9 --- /dev/null +++ b/db/changes/224701/00-sale_afterUpdate.sql @@ -0,0 +1,100 @@ +DROP TRIGGER IF EXISTS vn.sale_afterUpdate; +USE vn; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_afterUpdate` + AFTER UPDATE ON `sale` + FOR EACH ROW +BEGIN + DECLARE vIsToSendMail BOOL; + DECLARE vPickedLines INT; + DECLARE vCollectionFk INT; + DECLARE vUserRole VARCHAR(255); + + IF !(NEW.id <=> OLD.id) + OR !(NEW.ticketFk <=> OLD.ticketFk) + OR !(NEW.itemFk <=> OLD.itemFk) + OR !(NEW.quantity <=> OLD.quantity) + OR !(NEW.created <=> OLD.created) + OR !(NEW.isPicked <=> OLD.isPicked) THEN + CALL stock.log_add('sale', NEW.id, OLD.id); + END IF; + + IF !(NEW.price <=> OLD.price) + OR !(NEW.ticketFk <=> OLD.ticketFk) + OR !(NEW.itemFk <=> OLD.itemFk) + OR !(NEW.quantity <=> OLD.quantity) + OR !(NEW.discount <=> OLD.discount) THEN + CALL ticket_requestRecalc(NEW.ticketFk); + CALL ticket_requestRecalc(OLD.ticketFk); + END IF; + + IF !(OLD.ticketFk <=> NEW.ticketFk) THEN + UPDATE ticketRequest SET ticketFk = NEW.ticketFk + WHERE saleFk = NEW.id; + END IF; + + SELECT account.myUser_getName() INTO vUserRole; + SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole; + + IF !(OLD.quantity <=> NEW.quantity) THEN + SELECT COUNT(*) INTO vIsToSendMail + FROM vncontrol.inter i + JOIN vn.state s ON s.id = i.state_id + WHERE s.code='PACKED' + AND i.Id_Ticket = OLD.ticketFk + AND vUserRole IN ('salesPerson', 'salesTeamBoss') + LIMIT 1; + + IF vIsToSendMail THEN + CALL vn.mail_insert('jefesventas@verdnatura.es', + 'noreply@verdnatura.es', + CONCAT('Ticket ', OLD.ticketFk ,' modificada cantidad tras encajado'), + CONCAT('Ticket ', OLD.ticketFk ,'.
', + 'Modificada la catidad de ', OLD.quantity, ' a ' , NEW.quantity, + ' del artículo ', OLD.itemFk, ' tras estado encajado del ticket.
', + 'Este email se ha generado automáticamente' ) + ); + END IF; + IF (OLD.quantity > NEW.quantity) THEN + INSERT INTO saleComponent(saleFk, componentFk, value) + SELECT NEW.id, cm.id, sc.value + FROM saleComponent sc + JOIN component cd ON cd.id = sc.componentFk + JOIN component cm ON cm.code = 'mana' + WHERE saleFk = NEW.id AND cd.code = 'lastUnitsDiscount' + ON DUPLICATE KEY UPDATE value = sc.value + VALUES(value); + + DELETE sc.* + FROM vn.saleComponent sc + JOIN component c ON c.id = sc.componentFk + WHERE saleFk = NEW.id AND c.code = 'lastUnitsDiscount'; + END IF; + INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) + SELECT r.id + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.route r ON r.id = t.routeFk + WHERE r.isOk = FALSE + AND s.id = NEW.id + AND r.created >= CURDATE() + GROUP BY r.id; + END IF; + + IF !(ABS(NEW.isPicked) <=> ABS(OLD.isPicked)) AND NEW.quantity > 0 THEN + + UPDATE vn.collection c + JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk + SET c.salePickedCount = c.salePickedCount + IF(NEW.isPicked != 0, 1, -1); + + END IF; + + IF !(NEW.quantity <=> OLD.quantity) AND (NEW.quantity = 0 OR OLD.quantity = 0) THEN + + UPDATE vn.collection c + JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk + SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1); + END IF; +END$$ +DELIMITER ; diff --git a/db/changes/224701/00-sample.sql b/db/changes/224701/00-sample.sql new file mode 100644 index 000000000..f84cd723e --- /dev/null +++ b/db/changes/224701/00-sample.sql @@ -0,0 +1,6 @@ +alter table `vn`.`sample` + add model VARCHAR(25) null comment 'Model name in plural'; + +UPDATE vn.sample t + SET t.model = 'Clients' + WHERE t.id IN(12, 13, 14, 15, 16, 18, 19, 20); \ No newline at end of file diff --git a/db/changes/224701/00-user_hasGrant.sql b/db/changes/224701/00-user_hasGrant.sql new file mode 100644 index 000000000..60d1273d8 --- /dev/null +++ b/db/changes/224701/00-user_hasGrant.sql @@ -0,0 +1 @@ +ALTER TABLE `account`.`user` ADD hasGrant TINYINT(1) NOT NULL; diff --git a/db/changes/224702/00-ACL_workerDisableExcluded.sql b/db/changes/224702/00-ACL_workerDisableExcluded.sql new file mode 100644 index 000000000..2fd9e8b12 --- /dev/null +++ b/db/changes/224702/00-ACL_workerDisableExcluded.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalId) + VALUES ('WorkerDisableExcluded','*','*','ALLOW','hr'); \ No newline at end of file diff --git a/db/changes/224702/00-aclBusiness.sql b/db/changes/224702/00-aclBusiness.sql new file mode 100644 index 000000000..8ea2c6d83 --- /dev/null +++ b/db/changes/224702/00-aclBusiness.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Business', '*', '*', 'ALLOW', 'ROLE', 'hr'); \ No newline at end of file diff --git a/db/changes/224702/00-aclUsesMana.sql b/db/changes/224702/00-aclUsesMana.sql new file mode 100644 index 000000000..5bb7178dd --- /dev/null +++ b/db/changes/224702/00-aclUsesMana.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Sale', 'usesMana', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/224702/00-defaultPayDem_sameAs_production.sql b/db/changes/224702/00-defaultPayDem_sameAs_production.sql new file mode 100644 index 000000000..294247338 --- /dev/null +++ b/db/changes/224702/00-defaultPayDem_sameAs_production.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`payDem` (id,payDem) + VALUES (7,'0'); diff --git a/db/changes/224702/00-invoiceInPdf.sql b/db/changes/224702/00-invoiceInPdf.sql new file mode 100644 index 000000000..bce256c05 --- /dev/null +++ b/db/changes/224702/00-invoiceInPdf.sql @@ -0,0 +1,4 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('InvoiceIn', 'invoiceInPdf', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/224702/00-newSupplier_ACL.sql b/db/changes/224702/00-newSupplier_ACL.sql new file mode 100644 index 000000000..c88f3de3f --- /dev/null +++ b/db/changes/224702/00-newSupplier_ACL.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) + VALUES ('Supplier','newSupplier','WRITE','administrative'); diff --git a/db/changes/224702/00-notificationProc.sql b/db/changes/224702/00-notificationProc.sql new file mode 100644 index 000000000..475b2e389 --- /dev/null +++ b/db/changes/224702/00-notificationProc.sql @@ -0,0 +1,28 @@ +DROP FUNCTION IF EXISTS `util`.`notification_send`; +DELIMITER $$ +CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`notification_send`(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT) + RETURNS INT + MODIFIES SQL DATA +BEGIN +/** + * Sends a notification. + * + * @param vNotificationName The notification name + * @param vParams The notification parameters formatted as JSON + * @param vAuthorFk The notification author or %NULL if there is no author + * @return The notification id + */ + DECLARE vNotificationFk INT; + + SELECT id INTO vNotificationFk + FROM `notification` + WHERE `name` = vNotificationName; + + INSERT INTO notificationQueue + SET notificationFk = vNotificationFk, + params = vParams, + authorFk = vAuthorFk; + + RETURN LAST_INSERT_ID(); +END$$ +DELIMITER ; diff --git a/db/changes/224702/00-notificationTables.sql b/db/changes/224702/00-notificationTables.sql new file mode 100644 index 000000000..2db7d9874 --- /dev/null +++ b/db/changes/224702/00-notificationTables.sql @@ -0,0 +1,63 @@ +USE util; + +CREATE TABLE notification( + id INT PRIMARY KEY, + `name` VARCHAR(255) UNIQUE, + `description` VARCHAR(255) +); + +CREATE TABLE notificationAcl( + notificationFk INT, + roleFk INT(10) unsigned, + PRIMARY KEY(notificationFk, roleFk) +); + +ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`) + ON DELETE CASCADE + ON UPDATE CASCADE; + +ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_2` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role`(`id`) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +CREATE TABLE notificationSubscription( + notificationFk INT, + userFk INT(10) unsigned, + PRIMARY KEY(notificationFk, userFk) +); + +ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`) + ON DELETE CASCADE + ON UPDATE CASCADE; + +ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user`(`id`) + ON DELETE CASCADE + ON UPDATE CASCADE; + +CREATE TABLE notificationQueue( + id INT PRIMARY KEY AUTO_INCREMENT, + notificationFk VARCHAR(255), + params JSON, + authorFk INT(10) unsigned NULL, + `status` ENUM('pending', 'sent', 'error') NOT NULL DEFAULT 'pending', + created DATETIME DEFAULT CURRENT_TIMESTAMP, + INDEX(notificationFk), + INDEX(authorFk), + INDEX(status) +); + +ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `nnotificationQueue_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`name`) + ON DELETE CASCADE + ON UPDATE CASCADE; + +ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_ibfk_2` FOREIGN KEY (`authorFk`) REFERENCES `account`.`user`(`id`) + ON DELETE CASCADE + ON UPDATE CASCADE; + +CREATE TABLE notificationConfig( + id INT PRIMARY KEY AUTO_INCREMENT, + cleanDays MEDIUMINT +); + +INSERT INTO notificationConfig + SET cleanDays = 90; diff --git a/db/changes/224702/00-payMethodFk_Allow_Null.sql b/db/changes/224702/00-payMethodFk_Allow_Null.sql new file mode 100644 index 000000000..6d9931d3c --- /dev/null +++ b/db/changes/224702/00-payMethodFk_Allow_Null.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`supplier` MODIFY COLUMN payMethodFk tinyint(3) unsigned NULL; \ No newline at end of file diff --git a/db/changes/224702/00-supplierActivityFk_Allow_Null.sql b/db/changes/224702/00-supplierActivityFk_Allow_Null.sql new file mode 100644 index 000000000..62aac0556 --- /dev/null +++ b/db/changes/224702/00-supplierActivityFk_Allow_Null.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`supplier` MODIFY COLUMN supplierActivityFk varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; \ No newline at end of file diff --git a/db/changes/224702/00-ticket_closeByTicket.sql b/db/changes/224702/00-ticket_closeByTicket.sql new file mode 100644 index 000000000..f378b1146 --- /dev/null +++ b/db/changes/224702/00-ticket_closeByTicket.sql @@ -0,0 +1,35 @@ +drop procedure `vn`.`ticket_closeByTicket`; + +DELIMITER $$ +$$ +create + definer = `root`@`localhost` procedure `vn`.`ticket_closeByTicket`(IN vTicketFk int) +BEGIN + +/** + * Inserta el ticket en la tabla temporal + * para ser cerrado. + * + * @param vTicketFk Id del ticket + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close; + CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY ( + SELECT + t.id AS ticketFk + FROM ticket t + JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + JOIN alertLevel al ON al.id = ts.alertLevel + WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered') + AND t.id = vTicketFk + AND t.refFk IS NULL + GROUP BY t.id); + + CALL ticket_close(); + + DROP TEMPORARY TABLE tmp.ticket_close; +END$$ +DELIMITER ; + + diff --git a/db/changes/224702/00-zipConfig.sql b/db/changes/224702/00-zipConfig.sql new file mode 100644 index 000000000..134ce7770 --- /dev/null +++ b/db/changes/224702/00-zipConfig.sql @@ -0,0 +1,9 @@ +CREATE TABLE `vn`.`zipConfig` ( + `id` double(10,2) NOT NULL, + `maxSize` int(11) DEFAULT NULL COMMENT 'in MegaBytes', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ZipConfig', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10500-november/00-ACL.sql b/db/changes/224801/00-ACL.sql similarity index 100% rename from db/changes/10500-november/00-ACL.sql rename to db/changes/224801/00-ACL.sql diff --git a/db/changes/10500-november/00-claim.sql b/db/changes/224801/00-claim.sql similarity index 100% rename from db/changes/10500-november/00-claim.sql rename to db/changes/224801/00-claim.sql diff --git a/db/changes/10500-november/00-claimRma.sql b/db/changes/224801/00-claimRma.sql similarity index 100% rename from db/changes/10500-november/00-claimRma.sql rename to db/changes/224801/00-claimRma.sql diff --git a/db/changes/10501-november/00-aclNotification.sql b/db/changes/224901/00-aclNotification.sql similarity index 100% rename from db/changes/10501-november/00-aclNotification.sql rename to db/changes/224901/00-aclNotification.sql diff --git a/db/changes/10501-november/00-packingSiteConfig.sql b/db/changes/224901/00-packingSiteConfig.sql similarity index 100% rename from db/changes/10501-november/00-packingSiteConfig.sql rename to db/changes/224901/00-packingSiteConfig.sql diff --git a/db/changes/10501-november/00-packingSiteUpdate.sql b/db/changes/224901/00-packingSiteUpdate.sql similarity index 100% rename from db/changes/10501-november/00-packingSiteUpdate.sql rename to db/changes/224901/00-packingSiteUpdate.sql diff --git a/db/changes/10501-november/00-salix_url.sql b/db/changes/224901/00-salix_url.sql similarity index 100% rename from db/changes/10501-november/00-salix_url.sql rename to db/changes/224901/00-salix_url.sql diff --git a/db/changes/10502-november/00-aclUserPassword.sql b/db/changes/224902/00-aclUserPassword.sql similarity index 100% rename from db/changes/10502-november/00-aclUserPassword.sql rename to db/changes/224902/00-aclUserPassword.sql diff --git a/db/changes/10502-november/00-deletePickupContact.sql b/db/changes/224902/00-deletePickupContact.sql similarity index 100% rename from db/changes/10502-november/00-deletePickupContact.sql rename to db/changes/224902/00-deletePickupContact.sql diff --git a/db/changes/10502-november/00-itemShelvingACL.sql b/db/changes/224902/00-itemShelvingACL.sql similarity index 100% rename from db/changes/10502-november/00-itemShelvingACL.sql rename to db/changes/224902/00-itemShelvingACL.sql diff --git a/db/changes/10502-november/00-itemShelvingPlacementSupplyStockACL.sql b/db/changes/224902/00-itemShelvingPlacementSupplyStockACL.sql similarity index 100% rename from db/changes/10502-november/00-itemShelvingPlacementSupplyStockACL.sql rename to db/changes/224902/00-itemShelvingPlacementSupplyStockACL.sql diff --git a/db/changes/10502-november/00-workerTimeControlMail.sql b/db/changes/224902/00-workerTimeControlMail.sql similarity index 100% rename from db/changes/10502-november/00-workerTimeControlMail.sql rename to db/changes/224902/00-workerTimeControlMail.sql diff --git a/db/changes/10502-november/00-zone_getPostalCode.sql b/db/changes/224902/00-zone_getPostalCode.sql similarity index 100% rename from db/changes/10502-november/00-zone_getPostalCode.sql rename to db/changes/224902/00-zone_getPostalCode.sql diff --git a/db/changes/10503-november/00-ACL_notification_InvoiceE.sql b/db/changes/224903/00-ACL_notification_InvoiceE.sql similarity index 100% rename from db/changes/10503-november/00-ACL_notification_InvoiceE.sql rename to db/changes/224903/00-ACL_notification_InvoiceE.sql diff --git a/db/changes/10503-november/00-aclInvoiceOut.sql b/db/changes/224903/00-aclInvoiceOut.sql similarity index 100% rename from db/changes/10503-november/00-aclInvoiceOut.sql rename to db/changes/224903/00-aclInvoiceOut.sql diff --git a/db/changes/10503-november/00-alter_expedition_itemFk.sql b/db/changes/224903/00-alter_expedition_itemFk.sql similarity index 100% rename from db/changes/10503-november/00-alter_expedition_itemFk.sql rename to db/changes/224903/00-alter_expedition_itemFk.sql diff --git a/db/changes/10503-november/00-clientHasInvoiceElectronic.sql b/db/changes/224903/00-clientHasInvoiceElectronic.sql similarity index 100% rename from db/changes/10503-november/00-clientHasInvoiceElectronic.sql rename to db/changes/224903/00-clientHasInvoiceElectronic.sql diff --git a/db/changes/10503-november/00-collection_missingTrash.sql b/db/changes/224903/00-collection_missingTrash.sql similarity index 100% rename from db/changes/10503-november/00-collection_missingTrash.sql rename to db/changes/224903/00-collection_missingTrash.sql diff --git a/db/changes/10503-november/00-deleteInvoiceOutQueue.sql b/db/changes/224903/00-deleteInvoiceOutQueue.sql similarity index 100% rename from db/changes/10503-november/00-deleteInvoiceOutQueue.sql rename to db/changes/224903/00-deleteInvoiceOutQueue.sql diff --git a/db/changes/10503-november/00-editTrackedACL.sql b/db/changes/224903/00-editTrackedACL.sql similarity index 100% rename from db/changes/10503-november/00-editTrackedACL.sql rename to db/changes/224903/00-editTrackedACL.sql diff --git a/db/changes/10503-november/00-greuge.sql b/db/changes/224903/00-greuge.sql similarity index 100% rename from db/changes/10503-november/00-greuge.sql rename to db/changes/224903/00-greuge.sql diff --git a/db/changes/10503-november/00-insert_notification_invoiceE.sql b/db/changes/224903/00-insert_notification_invoiceE.sql similarity index 100% rename from db/changes/10503-november/00-insert_notification_invoiceE.sql rename to db/changes/224903/00-insert_notification_invoiceE.sql diff --git a/db/changes/10503-november/00-isCompensationACL.sql b/db/changes/224903/00-isCompensationACL.sql similarity index 100% rename from db/changes/10503-november/00-isCompensationACL.sql rename to db/changes/224903/00-isCompensationACL.sql diff --git a/db/changes/10503-november/00-osTicketConfig.sql b/db/changes/224903/00-osTicketConfig.sql similarity index 100% rename from db/changes/10503-november/00-osTicketConfig.sql rename to db/changes/224903/00-osTicketConfig.sql diff --git a/db/changes/10503-november/00-ticket_canMerge.sql b/db/changes/224903/00-ticket_canMerge.sql similarity index 100% rename from db/changes/10503-november/00-ticket_canMerge.sql rename to db/changes/224903/00-ticket_canMerge.sql diff --git a/db/changes/10503-november/00-ticket_canbePostponed.sql b/db/changes/224903/00-ticket_canbePostponed.sql similarity index 100% rename from db/changes/10503-november/00-ticket_canbePostponed.sql rename to db/changes/224903/00-ticket_canbePostponed.sql diff --git a/db/changes/10503-november/00-timeBusiness_calculate.sql b/db/changes/224903/00-timeBusiness_calculate.sql similarity index 100% rename from db/changes/10503-november/00-timeBusiness_calculate.sql rename to db/changes/224903/00-timeBusiness_calculate.sql diff --git a/db/changes/10503-november/01-updateClientHasInvoiceElectronic.sql b/db/changes/224903/01-updateClientHasInvoiceElectronic.sql similarity index 100% rename from db/changes/10503-november/01-updateClientHasInvoiceElectronic.sql rename to db/changes/224903/01-updateClientHasInvoiceElectronic.sql diff --git a/db/changes/225001/.gitkeep b/db/changes/225001/.gitkeep new file mode 100644 index 000000000..7a4187c02 --- /dev/null +++ b/db/changes/225001/.gitkeep @@ -0,0 +1 @@ +Delete this file diff --git a/db/changes/10510-december/00-businessCategory.sql b/db/changes/225001/00-businessCategory.sql similarity index 100% rename from db/changes/10510-december/00-businessCategory.sql rename to db/changes/225001/00-businessCategory.sql diff --git a/db/changes/10510-december/00-entryDeleteRef.sql b/db/changes/225001/00-entryDeleteRef.sql similarity index 100% rename from db/changes/10510-december/00-entryDeleteRef.sql rename to db/changes/225001/00-entryDeleteRef.sql diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index ec98eaea4..f86e935ab 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -22,8 +22,12 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; +<<<<<<< HEAD INSERT INTO `config` VALUES (1,'10502',0,'production',NULL); +======= +INSERT INTO `config` VALUES (1,'224602',0,'production',NULL); +>>>>>>> ac447d4981695aeceab34cdc30c48cfe26f559b0 /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/import-changes.sh b/db/import-changes.sh index 2b80654d3..5461f003b 100755 --- a/db/import-changes.sh +++ b/db/import-changes.sh @@ -81,9 +81,9 @@ N_CHANGES=0 for DIR_PATH in "$DIR/changes/"*; do DIR_NAME=$(basename $DIR_PATH) - DIR_VERSION=${DIR_NAME:0:5} + DIR_VERSION=${DIR_NAME:0:6} - if [[ ! "$DIR_NAME" =~ ^[0-9]{5}(-[a-zA-Z0-9]+)?$ ]]; then + if [[ ! "$DIR_NAME" =~ ^[0-9]{6}$ ]]; then echo "[WARN] Ignoring wrong directory name: $DIR_NAME" continue fi diff --git a/modules/client/back/methods/receipt/filter.js b/modules/client/back/methods/receipt/filter.js index 9549fb001..6df5e73f8 100644 --- a/modules/client/back/methods/receipt/filter.js +++ b/modules/client/back/methods/receipt/filter.js @@ -57,14 +57,16 @@ module.exports = Self => { r.clientFk, FALSE hasPdf, FALSE isInvoice, - CASE WHEN at2.code LIKE 'compensation' THEN True ELSE False END as isCompensation + at2.id IS NOT NULL as isCompensation FROM vn.receipt r LEFT JOIN vn.worker w ON w.id = r.workerFk LEFT JOIN account.user u ON u.id = w.userFk JOIN vn.company c ON c.id = r.companyFk - JOIN vn.accounting a ON a.id = r.bankFk - JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk - WHERE r.clientFk = ? AND r.companyFk = ? + LEFT JOIN vn.accounting a ON a.id = r.bankFk + LEFT JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk AND at2.code = 'compensation' + WHERE + r.clientFk = ? + AND r.companyFk = ? UNION ALL SELECT i.id, @@ -81,13 +83,10 @@ module.exports = Self => { i.clientFk, i.hasPdf, TRUE isInvoice, - CASE WHEN at2.code LIKE 'compensation' THEN True ELSE False END as isCompensation + NULL FROM vn.invoiceOut i JOIN vn.company c ON c.id = i.companyFk - JOIN vn.accounting a ON a.id = i.bankFk - JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk WHERE i.clientFk = ? AND i.companyFk = ? - ORDER BY payed DESC, created DESC ) t ORDER BY payed DESC, created DESC`, [ clientId, diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/createPdf.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/createPdf.spec.js index 803338ef3..ee3310368 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/createPdf.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/createPdf.spec.js @@ -11,6 +11,7 @@ describe('InvoiceOut createPdf()', () => { const ctx = {req: activeCtx}; it('should create a new PDF file and set true the hasPdf property', async() => { + pending('https://redmine.verdnatura.es/issues/4875'); const invoiceId = 1; spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js index 08f049783..536fa07a0 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/downloadZip.spec.js @@ -30,6 +30,7 @@ describe('InvoiceOut downloadZip()', () => { }); it('should return an error if the size of the files is too large', async() => { + pending('https://redmine.verdnatura.es/issues/4875'); const tx = await models.InvoiceOut.beginTransaction({}); let error; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js index 02f982011..7b5886236 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js @@ -51,6 +51,7 @@ describe('InvoiceOut filter()', () => { }); it('should return the invoice out matching hasPdf', async() => { + pending('https://redmine.verdnatura.es/issues/4875'); const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index baa6a0b41..e33428bf0 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -137,9 +137,11 @@ module.exports = Self => { const params = [args.id, args.shipped, args.warehouseFk]; const [salesMovable] = await Self.rawSql(query, params, myOptions); + const sales = await models.Sale.find({ticketFk: args.id}, myOptions); const salesNewTicket = salesMovable.filter(sale => (sale.movable ? sale.movable : 0) >= sale.quantity); - if (salesNewTicket.length) { + const salesNewTicketLength = salesNewTicket.length; + if (salesNewTicketLength && sales.length != salesNewTicketLength) { const newTicket = await models.Ticket.transferSales(ctx, args.id, null, salesNewTicket, myOptions); args.id = newTicket.id; } diff --git a/modules/ticket/front/basic-data/step-two/index.js b/modules/ticket/front/basic-data/step-two/index.js index 32d6b2cd6..4ac9f292e 100644 --- a/modules/ticket/front/basic-data/step-two/index.js +++ b/modules/ticket/front/basic-data/step-two/index.js @@ -67,6 +67,7 @@ class Controller extends Component { ticketHaveNegatives() { let haveNegatives = false; let haveNotNegatives = false; + this.ticket.withoutNegatives = false; const haveDifferences = this.ticket.sale.haveDifferences; this.ticket.sale.items.forEach(item => { @@ -76,8 +77,9 @@ class Controller extends Component { haveNotNegatives = true; }); - this.ticket.withoutNegatives = true; this.haveNegatives = (haveNegatives && haveNotNegatives && haveDifferences); + if (this.haveNegatives) + this.ticket.withoutNegatives = true; } onSubmit() { diff --git a/print/templates/reports/collection-label/assets/css/style.css b/print/templates/reports/collection-label/assets/css/style.css index 597921c92..f92d5bf1e 100644 --- a/print/templates/reports/collection-label/assets/css/style.css +++ b/print/templates/reports/collection-label/assets/css/style.css @@ -1,5 +1,5 @@ html { - font-family: "Roboto"; + font-family: Arial, Helvetica, sans-serif; margin-top: -6px; } * { @@ -9,12 +9,15 @@ html { } #vertical { writing-mode: vertical-rl; - height: 240px; + height: 230px; + font-size: 29px; margin-left: -13px; } .outline { border: 1px solid black; padding: 5px; + height: 37px; + width: 100px; } #nickname { font-size: 22px; @@ -22,17 +25,20 @@ html { } #agencyDescripton { font-size: 32px; + width: 375px; font-weight: bold; } #bold { font-weight: bold; } #barcode{ - width: 390px; + width: 370px; } #shipped { font-weight: bold; + width: 50px; + max-width: 100px; } -#ticketFk, #vertical { - font-size: 34px; +#ticketFk { + font-size: 32px; } \ No newline at end of file diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html index 6716d1fe5..b7f783a88 100644 --- a/print/templates/reports/collection-label/collection-label.html +++ b/print/templates/reports/collection-label/collection-label.html @@ -4,31 +4,29 @@ - + - + - + - + - + - - + + - - + +
- {{labelData.collectionFk ? `${labelData.collectionFk} ~ ${labelData.wagon}-${labelData.level}` : '-'.repeat(23)}} - {{getVertical(labelData)}} {{labelData.clientFk ? `${labelData.ticketFk} « ${labelData.clientFk}` : labelData.ticketFk}} {{labelData.shipped ? labelData.shipped : '---'}}{{labelData.shipped || '---'}}
{{labelData.workerCode ? labelData.workerCode : '---'}}{{labelData.workerCode || '---'}}
{{labelData.labelCount ? labelData.labelCount : 0}}{{labelData.labelCount || 0}}
{{labelData.code == 'plant' ? labelData.size + 'cm' : labelData.volume + 'm³'}}{{labelData.code == 'V' ? (labelData.size || 0) + 'cm' : (labelData.volume || 0) + 'm³'}}
{{labelData.agencyDescription}}
{{labelData.lineCount ? labelData.lineCount : 0}}
{{labelData.agencyDescription ? labelData.agencyDescription.toUpperCase() : '---'}}
{{labelData.lineCount || 0}}
{{labelData.nickName ? labelData.nickName : '---'}}{{labelData.shipped ? labelData.shippedHour : labelData.zoneHour}}{{labelData.nickName ? labelData.nickName.toUpperCase() : '---'}}{{labelData.shippedHour || labelData.zoneHour}}
diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js index d2d5f6417..fd412791b 100644 --- a/print/templates/reports/collection-label/collection-label.js +++ b/print/templates/reports/collection-label/collection-label.js @@ -25,7 +25,6 @@ module.exports = { ticketIds = [this.id]; this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]); - if (!this.labelsData.length) throw new UserError('Empty data source'); }, @@ -44,6 +43,19 @@ module.exports = { }); return xmlSerializer.serializeToString(svgNode); }, + getVertical(labelData) { + let value; + if (labelData.collectionFk) { + value = `${labelData.collectionFk} ~ `; + if (labelData.code == 'V') + value = value + `${labelData.wagon}-${labelData.level}`; + else + value = value + `${labelData.color.substring(0, 4)}`; + } else + value = '-'.repeat(19); + + return value; + }, }, components: { 'report-body': reportBody.build() diff --git a/print/templates/reports/collection-label/options.json b/print/templates/reports/collection-label/options.json index ae88e6c0c..a555c5723 100644 --- a/print/templates/reports/collection-label/options.json +++ b/print/templates/reports/collection-label/options.json @@ -1,6 +1,6 @@ { "width": "10.4cm", - "height": "4.8cm", + "height": "4.9cm", "margin": { "top": "0.3cm", "right": "0.6cm", diff --git a/print/templates/reports/collection-label/sql/labelsData.sql b/print/templates/reports/collection-label/sql/labelsData.sql index b799b289b..9afac79d0 100644 --- a/print/templates/reports/collection-label/sql/labelsData.sql +++ b/print/templates/reports/collection-label/sql/labelsData.sql @@ -1,13 +1,13 @@ -SELECT tc.collectionFk, +SELECT c.itemPackingTypeFk code, + tc.collectionFk, SUBSTRING('ABCDEFGH', tc.wagon, 1) wagon, tc.`level`, t.id ticketFk, COALESCE(et.description, zo.name, am.name) agencyDescription, - am.name, + cc.code color, t.clientFk, CAST(SUM(sv.volume) AS DECIMAL(5, 2)) volume, MAX(i.`size`) `size`, - ic.code, w.code workerCode, TIME_FORMAT(t.shipped, '%H:%i') shippedHour, TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour, @@ -16,8 +16,8 @@ SELECT tc.collectionFk, tt.labelCount, COUNT(*) lineCount FROM vn.ticket t - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - LEFT JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + JOIN vn.collection c ON c.id = tc.collectionFk LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level` AND cc.wagon = tc.wagon AND cc.trainFk = c.trainFk @@ -26,7 +26,7 @@ SELECT tc.collectionFk, JOIN vn.item i ON i.id = s.itemFk JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN vn.worker w ON w.id = c.workerFk + JOIN vn.worker w ON w.id = c.workerFk JOIN vn.agencyMode am ON am.id = t.agencyModeFk LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id