diff --git a/back/methods/collection/getSectors.js b/back/methods/collection/getSectors.js deleted file mode 100644 index 12ad0dc06..000000000 --- a/back/methods/collection/getSectors.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getSectors', { - description: 'Get all sectors', - accessType: 'READ', - returns: { - type: 'Object', - root: true - }, - http: { - path: `/getSectors`, - verb: 'GET' - } - }); - - Self.getSectors = async() => { - const query = `CALL vn.sector_get()`; - const [result] = await Self.rawSql(query); - return result; - }; -}; diff --git a/back/methods/collection/spec/getSectors.spec.js b/back/methods/collection/spec/getSectors.spec.js deleted file mode 100644 index d8fa60663..000000000 --- a/back/methods/collection/spec/getSectors.spec.js +++ /dev/null @@ -1,11 +0,0 @@ -const {models} = require('vn-loopback/server/server'); - -describe('getSectors()', () => { - it('return list of sectors', async() => { - let response = await models.Collection.getSectors(); - - expect(response.length).toBeGreaterThan(0); - expect(response[0].id).toEqual(1); - expect(response[0].description).toEqual('First sector'); - }); -}); diff --git a/back/models/collection.js b/back/models/collection.js index 1c10d49fa..52ef26e88 100644 --- a/back/models/collection.js +++ b/back/models/collection.js @@ -1,6 +1,5 @@ module.exports = Self => { require('../methods/collection/getCollection')(Self); - require('../methods/collection/getSectors')(Self); require('../methods/collection/setSaleQuantity')(Self); require('../methods/collection/previousLabel')(Self); require('../methods/collection/getTickets')(Self); diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 6e4d9947c..d7e99a4ee 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1815,8 +1815,6 @@ USE `vn`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios'); - INSERT INTO `alertLevel` VALUES ('FREE',0,1); INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',1,1); INSERT INTO `alertLevel` VALUES ('PACKED',2,0); diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 4c5f89d97..bda625a96 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -137,9 +137,6 @@ INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressF INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded) VALUES (1, 24, 'Ranged weapon longbow 2m', 1.00, NULL, 8.07, 0, 0.00, 0, 0, 0, '2022-07-06 00:00:00', 0); */ -INSERT INTO vn2008.zones (zone_id,name,printingOrder) - VALUES (1,'zone Test',1); - -- XXX: lab INSERT INTO `vn`.`businessReasonEnd` (`id`, `reason`) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 094b956af..cb9ee0fe6 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -352,12 +352,12 @@ INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) ('46600', 4, 7), ('EC170150', 5, 8); -INSERT INTO `vn`.`clientType`(`id`, `code`, `type`) +INSERT INTO `vn`.`clientType`(`code`, `type`) VALUES - (1, 'normal', 'Normal'), - (2, 'internalUse', 'Autoconsumo'), - (3, 'handMaking', 'Confección'), - (4, 'loses', 'Mermas'); + ('normal', 'Normal'), + ('internalUse', 'Autoconsumo'), + ('handMaking', 'Confección'), + ('loses', 'Mermas'); INSERT INTO `vn`.`cplusTerIdNif`(`id`, `description`) VALUES @@ -371,23 +371,23 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) (4, 'GCN Channel'), (5, 'The Newspaper'); -INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`) +INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`) VALUES - (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), - (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), - (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), - (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), - (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist','normal'), - (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'), - (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'), - (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'), - (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'), - (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'), - (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'), - (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'); + (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist','normal'), + (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'), + (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'), + (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'), + (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'), + (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'), + (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'), + (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'); INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) - SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 + SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 FROM `account`.`role` `r` WHERE `r`.`hasLogin` = 1; @@ -564,13 +564,13 @@ INSERT INTO `vn`.`supplierActivity`(`code`, `name`) 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'), - (2, 'FARMER KING', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'GOTHAM', 1, 46000, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), + (2, 'FARMER KING', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 46000, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), (69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), - (442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), + (442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 46000, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), (567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), (791, 'BROS SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE(), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), - (1381, 'ORNAMENTALES', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); + (1381, 'ORNAMENTALES', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 46000, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`) VALUES @@ -653,6 +653,7 @@ INSERT INTO `vn`.`expense`(`id`, `name`, `isWithheld`) (7001000000, 'Mercaderia', 0), (7050000000, 'Prestacion de servicios', 1); +INSERT INTO `vn`.`agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios'); INSERT INTO `vn`.`invoiceOutExpense`(`id`, `invoiceOutFk`, `amount`, `expenseFk`, `created`) VALUES @@ -728,7 +729,7 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`) VALUES (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1), - (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), + (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3), (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL), (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL), @@ -2408,7 +2409,8 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`) (17, 'cmr', 1, 1, 'cmr'), (18, 'dua', NULL, NULL, 'dua'), (19, 'inmovilizado', NULL, NULL, 'fixedAssets'), - (20, 'Reclamación', 1, 1, 'claim'); + (20, 'Reclamación', 1, 1, 'claim'), + (21, 'Entrada', 1, 1, 'entry'); INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`) VALUES @@ -2419,7 +2421,8 @@ INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `wa (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()), (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()), (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()), - (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()); + (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()), + (9, 21, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'ENTRADA ID 1', util.VN_CURDATE()); INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`) VALUES @@ -3063,7 +3066,14 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (13, 1101, 1, NULL), (14, 1101, 4, 27); +INSERT INTO `vn`.`entryDms`(`entryFk`, `dmsFk`, `editorFk`) + VALUES + (1, 9, 9); + INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentInstruccions,specialAgreements,companyFk,addressToFk,addressFromFk,supplierFk,packagesList,merchandiseDetail,state) VALUES (1,'123456A','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',442,1,2,1,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'), (2,'123456N','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',69,3,4,2,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'), (3,'123456B','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',567,5,6,69,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'); + +UPDATE vn.department + SET workerFk = null; diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 9988c8b29..12b2738f3 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`ventas_contables_add`(IN vYear INT, IN vMonth INT) BEGIN - + /** * Reemplaza las ventas contables del último año. * Es el origen de datos para el balance de Entradas @@ -13,8 +13,8 @@ BEGIN DECLARE TIPO_PATRIMONIAL INT DEFAULT 188; - DELETE FROM bs.ventas_contables - WHERE year = vYear + DELETE FROM bs.ventas_contables + WHERE year = vYear AND month = vMonth; DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; @@ -25,7 +25,7 @@ BEGIN FROM vn2008.Tickets t JOIN vn.invoiceOut io ON io.id = t.Factura WHERE year(io.issued) = vYear - AND month(io.issued) = vMonth; + AND month(io.issued) = vMonth; INSERT INTO bs.ventas_contables(year , month @@ -35,7 +35,7 @@ BEGIN , tipo_id , empresa_id , gasto) - + SELECT vYear , vMonth , round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) @@ -47,13 +47,13 @@ BEGIN , tp.reino_id , a.tipo_id , t.empresa_id - , 7000000000 + , a.expenseFk + IF(e.empresa_grupo = e2.empresa_grupo ,1 ,IF(e2.empresa_grupo,2,0) - ) * 1000000 - + tp.reino_id * 10000 as Gasto - FROM vn2008.Movimientos m + ) * 100000 + + tp.reino_id * 1000 as Gasto + FROM vn2008.Movimientos m JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente @@ -67,7 +67,7 @@ BEGIN AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; - + INSERT INTO bs.ventas_contables(year , month , venta @@ -86,17 +86,17 @@ BEGIN ) as grupo , NULL , NULL - , t.companyFk + , t.companyFk , 7050000000 - FROM vn.ticketService ts + FROM vn.ticketService ts JOIN vn.ticket t ON ts.ticketFk = t.id - JOIN vn.address a on a.id = t.addressFk - JOIN vn.client cl on cl.id = a.clientFk + JOIN vn.address a on a.id = t.addressFk + JOIN vn.client cl on cl.id = a.clientFk JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id - JOIN vn.company c on c.id = t.companyFk + JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id - GROUP BY grupo, t.companyFk ; - + GROUP BY grupo, t.companyFk ; + DROP TEMPORARY TABLE tmp.ticket_list; END$$ DELIMITER ; diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index ac6690129..0ab328b49 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -19,7 +19,7 @@ BEGIN itemFk, itemTypeFk, floor(sum(value)) as total, - floor(sum(IF(clientTypeFk = 'loses', value, 0))) as mermas + floor(sum(IF(typeFk = 'loses', value, 0))) as mermas FROM vn.saleValue where year = vYear and week = vWeek diff --git a/db/routines/util/functions/checkPrintableChars.sql b/db/routines/util/functions/checkPrintableChars.sql new file mode 100644 index 000000000..a4addce24 --- /dev/null +++ b/db/routines/util/functions/checkPrintableChars.sql @@ -0,0 +1,15 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`checkPrintableChars`( + vString VARCHAR(255) +) RETURNS tinyint(1) + DETERMINISTIC +BEGIN +/** + * Validates whether the input string contains only printable characters + * and Spanish special characters (such as ¡, ÿ, etc.). + * + * @vString string to check + */ + RETURN vString REGEXP '^[ -~¡-ÿ]*$'; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/functions/isPalletHomogeneus.sql b/db/routines/vn/functions/isPalletHomogeneus.sql deleted file mode 100644 index b38fdcc5e..000000000 --- a/db/routines/vn/functions/isPalletHomogeneus.sql +++ /dev/null @@ -1,27 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`isPalletHomogeneus`(vExpedition INT) - RETURNS tinyint(1) - NOT DETERMINISTIC - READS SQL DATA -BEGIN - DECLARE vScanId INT; - DECLARE vDistinctRoutesInThePallet INT; - - SELECT scan_id INTO vScanId - FROM vn2008.scan_line - WHERE code = vExpedition - LIMIT 1; - - SELECT COUNT(*) INTO vDistinctRoutesInThePallet - FROM ( - SELECT DISTINCT t.Id_Ruta - FROM vn2008.scan_line sl - JOIN expedition e ON e.id = sl.code - JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticketFk - WHERE sl.scan_id = vScanId - AND t.Id_Ruta - ) t1; - - RETURN vDistinctRoutesInThePallet = 1; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 92434a47b..e264b500d 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -39,11 +39,11 @@ BEGIN WHERE t.landed BETWEEN vStarted AND vEnded AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND b.price2 > 0 - AND b.quantity > 0 ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC LIMIT 10000000000000000000) sub GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) SELECT b.itemFk, diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 1b3c8b3a2..06f36afce 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -22,6 +22,7 @@ BEGIN SET v2Years = util.VN_CURDATE() - INTERVAL 2 YEAR; SET v5Years = util.VN_CURDATE() - INTERVAL 5 YEAR; + DELETE FROM workerActivity WHERE created < v2Years; DELETE FROM ticketParking WHERE created < vDateShort; DELETE FROM routesMonitor WHERE dated < vDateShort; DELETE FROM workerTimeControlLog WHERE created < vDateShort; diff --git a/db/routines/vn/procedures/comparative_add.sql b/db/routines/vn/procedures/comparative_add.sql index 756096e54..44f9686aa 100644 --- a/db/routines/vn/procedures/comparative_add.sql +++ b/db/routines/vn/procedures/comparative_add.sql @@ -47,12 +47,11 @@ BEGIN JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - JOIN clientType ct ON ct.id = c.clientTypeFk JOIN warehouse w ON w.id = t.warehouseFk JOIN address ad ON ad.id = t.addressFk LEFT JOIN province p ON p.id = ad.provinceFk WHERE tm.period BETWEEN vMaxPeriod AND vPeriod - AND ct.code <> 'loses' + AND c.typeFk <> 'loses' AND NOT w.code = 'inv' GROUP BY p.countryFk, s.itemFk, tm.period, t.warehouseFk; END IF; diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 77e989630..60ec34696 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -8,6 +8,7 @@ BEGIN */ DECLARE vTaxRowLimit INT; DECLARE vLines INT; + DECLARE vHasDistinctTransactions INT; SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; @@ -18,6 +19,18 @@ BEGIN IF vLines >= vTaxRowLimit THEN CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit)); - END IF; + END IF; + + SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions + FROM invoiceIn ii + JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id + JOIN invoiceInSerial iis ON iis.code = ii.serial + WHERE ii.id = vInvoiceInFk + AND iis.taxAreaFk = 'CEE' + AND transactionTypeSageFk; + + IF vHasDistinctTransactions > 1 THEN + CALL util.throw ('This invoice does not allow different types of transactions'); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemProposal_Add.sql b/db/routines/vn/procedures/itemProposal_Add.sql deleted file mode 100644 index ac4dfa5d5..000000000 --- a/db/routines/vn/procedures/itemProposal_Add.sql +++ /dev/null @@ -1,70 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemProposal_Add`(vSaleFk INT, vMateFk INT, vQuantity INT) -BEGIN -/** - * Añade un nuevo articulo para sustituir a otro, y actualiza la memoria de sustituciones. - * - * @param vSaleFk id de la tabla sale - * @param vMateFk articulo sustituto - * @ param vQuantity cantidad que se va a sustituir - */ - DECLARE vTicketFk INT; - DECLARE vItemFk INT; - DECLARE vWarehouseFk SMALLINT; - DECLARE vDate DATE; - DECLARE vGrouping INT; - DECLARE vBox INT; - DECLARE vPacking INT; - DECLARE vRoundQuantity INT DEFAULT 1; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - SELECT s.ticketFk, LEAST(s.quantity, vQuantity), s.itemFk,t.shipped,t.warehouseFk - INTO vTicketFk, vQuantity, vItemFk,vDate,vWarehouseFk - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE s.id = vSaleFk; - - CALL buyUltimate(vWarehouseFk, vDate); - - SELECT `grouping`, groupingMode, packing INTO vGrouping, vBox, vPacking - FROM buy b - JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk - WHERE tmp.itemFk = vMateFk AND tmp.WarehouseFk = vWarehouseFk; - - IF vBox = 2 AND vPacking > 0 THEN - SET vRoundQuantity = vPacking; - END IF; - IF vBox = 1 AND vGrouping > 0 THEN - SET vRoundQuantity = vGrouping; - END IF; - - START TRANSACTION; - - UPDATE sale - SET quantity = quantity - vQuantity - WHERE id = vSaleFk; - - INSERT INTO sale(ticketFk, itemFk, quantity, concept) - SELECT vTicketFk, - vMateFk, - CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, - CONCAT('+ ',i.longName) - FROM item i - WHERE id = vMateFk; - - SELECT LAST_INSERT_ID() INTO vSaleFk; - - CALL sale_calculateComponent(vSaleFk, NULL); - - INSERT INTO itemProposal(itemFk, mateFk, counter) - VALUES(vItemFk, vMateFk, 1) - ON DUPLICATE KEY UPDATE counter = counter + 1; - - COMMIT; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index 02762fa0b..2a4676b50 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -19,6 +19,10 @@ BEGIN DECLARE vItemFk INT; SELECT barcodeToItem(vBarcode) INTO vItemFk; + + SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1)); + + SET vQuantity = vQuantity * vPacking; IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN diff --git a/db/routines/vn/procedures/itemShelving_filterBuyer.sql b/db/routines/vn/procedures/itemShelving_filterBuyer.sql index a232139d3..7112aa48e 100644 --- a/db/routines/vn/procedures/itemShelving_filterBuyer.sql +++ b/db/routines/vn/procedures/itemShelving_filterBuyer.sql @@ -44,10 +44,9 @@ proc:BEGIN LEFT JOIN saleTracking st ON st.saleFk = s.id JOIN ticket t ON t.id = s.ticketFk JOIN client c on c.id = t.clientFk - JOIN clientType ct ON ct.id = c.clientTypeFk WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND st.saleFk IS NULL - AND ct.code IN ('normal', 'trust') + AND c.typeFk IN ('normal', 'trust') GROUP BY s.itemFk ) sub2 ON sub2.itemFk = sub.itemFk UNION ALL @@ -70,10 +69,9 @@ proc:BEGIN LEFT JOIN saleTracking st ON st.saleFk = s.id JOIN ticket t ON t.id = s.ticketFk JOIN client c on c.id = t.clientFk - JOIN clientType ct ON ct.id = c.clientTypeFk WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND st.saleFk IS NULL - AND ct.code IN ('normal', 'trust') + AND c.typeFk IN ('normal', 'trust') GROUP BY s.itemFk ) sub5 ON sub5.itemFk = v.item_id WHERE v.calc_id = vCalcVisibleFk diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 5fe57f2a4..95596d3bc 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -120,7 +120,7 @@ BEGIN TRUE, s.id, st.`order`, - ct.`code`, + c.typeFk, cb.claimFk, NULL FROM sale s @@ -128,7 +128,6 @@ BEGIN LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN state st ON st.`code` = ts.`code` JOIN client c ON c.id = t.clientFk - JOIN clientType ct ON ct.id = c.clientTypeFk JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), 'DELIVERED', IF (t.shipped > util.dayEnd(util.VN_CURDATE()), diff --git a/db/routines/vn/procedures/sale_getBoxPickingList.sql b/db/routines/vn/procedures/sale_getBoxPickingList.sql index 0f2b2bc71..0af23e945 100644 --- a/db/routines/vn/procedures/sale_getBoxPickingList.sql +++ b/db/routines/vn/procedures/sale_getBoxPickingList.sql @@ -17,7 +17,6 @@ BEGIN CALL productionControl(vWarehouseFk, 0); - -- Products with vn.item.isBoxPickingMode = TRUE, pay atention to vn.itemShelving.packing CREATE OR REPLACE TEMPORARY TABLE tmp.sale (saleFk INT PRIMARY KEY) SELECT @@ -29,7 +28,7 @@ BEGIN MAKETIME(pb.HH,pb.mm,0) etd, pb.routeFk, FLOOR(s.quantity / ish.packing) stickers, - ish.packing, + IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing, b.packagingFk FROM sale s JOIN item i ON i.id = s.itemFk @@ -52,8 +51,8 @@ BEGIN LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk LEFT JOIN buy b ON b.id = lb.buy_id - WHERE s.quantity BETWEEN ish.packing AND (ish.visible - IFNULL(tISS.reserve,0)) - AND i.isBoxPickingMode + WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut) + <= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0)) AND NOT pb.problem AND sgd.saleFk IS NULL AND p.sectorFk = vSectorFk @@ -64,47 +63,13 @@ BEGIN GROUP BY s.id ORDER BY etd; - -- Remaining products, vn.item.packingOut - INSERT IGNORE INTO tmp.sale - SELECT - s.ticketFk, - s.id saleFk, - s.itemFk, - s.concept, - s.quantity, - MAKETIME(pb.HH,pb.mm,0) etd, - pb.routeFk, - s.quantity / i.packingOut stickers, - i.packingOut, - pc.defaultBigPackageFk - FROM sale s - JOIN item i ON i.id = s.itemFk - JOIN itemShelving ish ON ish.itemFk = s.itemFk - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk - JOIN agencyMode am ON am.id = pb.agencyModeFk - JOIN packagingConfig pc - LEFT JOIN routesMonitor rm ON rm.routeFk = pb.routeFk - LEFT JOIN itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = p.sectorFk - LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id - LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk - WHERE s.quantity >= i.packingOut - AND NOT pb.problem - AND s.quantity > 0 - AND sgd.saleFk IS NULL - AND p.sectorFk = vSectorFk - AND ts.isPreviousPreparable - AND iss.visible >= s.quantity - AND ((rm.bufferFk AND rm.isPickingAllowed) - OR am.code = 'REC_ALG') - AND pb.shipped = vDated - GROUP BY s.id - ORDER BY etd; - - SELECT * FROM tmp.sale; + SELECT * + FROM tmp.sale + WHERE stickers; DROP TEMPORARY TABLE tmp.productionBuffer; DROP TEMPORARY TABLE tmp.sale; END$$ DELIMITER ; + +CALL `vn`.`sale_getBoxPickingList`(1, curdate()); \ No newline at end of file diff --git a/db/routines/vn/procedures/sectorCollectionSaleGroup_add.sql b/db/routines/vn/procedures/sectorCollectionSaleGroup_add.sql index 9e21defc5..5ffb30635 100644 --- a/db/routines/vn/procedures/sectorCollectionSaleGroup_add.sql +++ b/db/routines/vn/procedures/sectorCollectionSaleGroup_add.sql @@ -8,6 +8,25 @@ BEGIN * @param vSaleGroupFk Identificador de vn.saleGroup * @param vSectorCollectionFk Identificador de vn.sectorCollection */ + DECLARE vHasSaleGroup INT; + DECLARE vHasSectorCollection INT; + + SELECT COUNT(id) INTO vHasSaleGroup + FROM saleGroup + WHERE id = vSaleGroupFk; + + IF !vHasSaleGroup THEN + CALL util.throw ("invalid saleGroup"); + END IF; + + SELECT COUNT(id) INTO vHasSectorCollection + FROM sectorCollection + WHERE id = vSectorCollectionFk; + + IF !vHasSectorCollection THEN + CALL util.throw ("invalid sectorCollection"); + END IF; + REPLACE sectorCollectionSaleGroup SET sectorCollectionFk = vSectorCollectionFk, saleGroupFk = vSaleGroupFk; diff --git a/db/routines/vn/procedures/sector_get.sql b/db/routines/vn/procedures/sector_get.sql deleted file mode 100644 index fe978203a..000000000 --- a/db/routines/vn/procedures/sector_get.sql +++ /dev/null @@ -1,13 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sector_get`() -BEGIN - -/** - * Obtiene los sectores -*/ - - SELECT s.id,s.description,s.warehouseFk - FROM vn.sector s; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_getTax.sql b/db/routines/vn/procedures/ticket_getTax.sql index 7269a1caf..b9f5c14e3 100644 --- a/db/routines/vn/procedures/ticket_getTax.sql +++ b/db/routines/vn/procedures/ticket_getTax.sql @@ -9,6 +9,8 @@ BEGIN * @return tmp.ticketAmount (ticketFk, taxableBase, tax, code) * @return tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) Impuesto desglosado para cada ticket. */ + -- Mantengo el drop porque si no da error en los tests de back de salix + -- Table 'addressCompany' was locked with a READ lock and can't be updated' DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; CREATE TEMPORARY TABLE tmp.addressCompany (INDEX (addressFk, companyFk)) @@ -17,24 +19,24 @@ BEGIN FROM tmp.ticket tmpTicket JOIN ticket t ON t.id = tmpTicket.ticketFk; - CALL addressTaxArea (); + CALL addressTaxArea(); IF vTaxArea IS NOT NULL THEN UPDATE tmp.addressTaxArea SET areaFk = vTaxArea; END IF; - /* Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente - * No se debería cambiar el sistema por problemas con los decimales - */ - DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax; - CREATE TEMPORARY TABLE tmp.ticketTax + -- Solo se calcula la base imponible (taxableBase) y + -- el impuesto se calculará posteriormente + -- No se debería cambiar el sistema por problemas con los decimales + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax (PRIMARY KEY (ticketFk, code, rate)) ENGINE = MEMORY SELECT * FROM ( SELECT tmpTicket.ticketFk, bp.pgcFk, - SUM(s.quantity * s.price * (100 - s.discount)/100 ) taxableBase, + SUM(s.quantity * s.price * (100 - s.discount) / 100 ) taxableBase, pgc.rate, tc.code, bp.priority @@ -43,22 +45,21 @@ BEGIN JOIN item i ON i.id = s.itemFk JOIN ticket t ON t.id = tmpTicket.ticketFk JOIN supplier su ON su.id = t.companyFk - JOIN tmp.addressTaxArea ata - ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk - JOIN itemTaxCountry itc - ON itc.itemFk = i.id AND itc.countryFk = su.countryFk - JOIN bookingPlanner bp - ON bp.countryFk = su.countryFk - AND bp.taxAreaFk = ata.areaFk - AND bp.taxClassFk = itc.taxClassFk + JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk + AND ata.companyFk = t.companyFk + JOIN itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = su.countryFk + JOIN bookingPlanner bp ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = itc.taxClassFk JOIN pgc ON pgc.code = bp.pgcFk JOIN taxClass tc ON tc.id = bp.taxClassFk GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate - HAVING taxableBase <> 0) t3 + HAVING taxableBase + ) t3 ORDER BY priority; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax; - CREATE TEMPORARY TABLE tmp.ticketServiceTax + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax (PRIMARY KEY (ticketFk, code, rate)) ENGINE = MEMORY SELECT tt.ticketFk, @@ -70,24 +71,22 @@ BEGIN JOIN ticketService ts ON ts.ticketFk = tt.ticketFk JOIN ticket t ON t.id = tt.ticketFk JOIN supplier su ON su.id = t.companyFk - JOIN tmp.addressTaxArea ata - ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk - JOIN bookingPlanner bp - ON bp.countryFk = su.countryFk - AND bp.taxAreaFk = ata.areaFk - AND bp.taxClassFk = ts.taxClassFk + JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk + AND ata.companyFk = t.companyFk + JOIN bookingPlanner bp ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = ts.taxClassFk JOIN pgc ON pgc.code = bp.pgcFk JOIN taxClass tc ON tc.id = bp.taxClassFk GROUP BY tt.ticketFk, pgc.code - HAVING taxableBase <> 0; + HAVING taxableBase; INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code FROM tmp.ticketServiceTax ts ON DUPLICATE KEY UPDATE ticketTax.taxableBase = VALUES (taxableBase) + ticketTax.taxableBase ; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount; - CREATE TEMPORARY TABLE tmp.ticketAmount + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketAmount (INDEX (ticketFk)) ENGINE = MEMORY SELECT ticketFk, @@ -97,7 +96,8 @@ BEGIN FROM tmp.ticketTax GROUP BY ticketFk, code; - DROP TEMPORARY TABLE tmp.addressCompany; - DROP TEMPORARY TABLE tmp.addressTaxArea; + DROP TEMPORARY TABLE + tmp.addressCompany, + tmp.addressTaxArea; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/workerTimeControl_clockIn.sql b/db/routines/vn/procedures/workerTimeControl_clockIn.sql index 77a628d10..e58528487 100644 --- a/db/routines/vn/procedures/workerTimeControl_clockIn.sql +++ b/db/routines/vn/procedures/workerTimeControl_clockIn.sql @@ -75,7 +75,7 @@ BEGIN SET vDated = DATE(vTimed); - SELECT IF(pc.code = 'driveCE', + SELECT IF(pc.code = 'driverCE', wc.dayBreakDriver, wc.dayBreak), wc.shortWeekBreak, diff --git a/db/routines/vn/procedures/worker_updateBusiness.sql b/db/routines/vn/procedures/worker_updateBusiness.sql index 274bc3ec0..76c8c9cbb 100644 --- a/db/routines/vn/procedures/worker_updateBusiness.sql +++ b/db/routines/vn/procedures/worker_updateBusiness.sql @@ -23,6 +23,12 @@ BEGIN IF vOldBusinessFk IS NULL THEN CALL account.account_enable(vSelf); + + UPDATE client c + JOIN payMethod pm ON pm.code = 'bankDraft' + SET c.payMethodFk = pm.id + WHERE c.id = vSelf + AND c.iban; END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entryDms_afterDelete.sql b/db/routines/vn/triggers/entryDms_afterDelete.sql new file mode 100644 index 000000000..9ae8e7058 --- /dev/null +++ b/db/routines/vn/triggers/entryDms_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_afterDelete` + AFTER DELETE ON `entryDms` + FOR EACH ROW +BEGIN + INSERT INTO entryLog + SET `action` = 'delete', + `changedModel` = 'EntryDms', + `changedModelId` = OLD.entryFk, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/entryDms_beforeInsert.sql b/db/routines/vn/triggers/entryDms_beforeInsert.sql new file mode 100644 index 000000000..4f9550f48 --- /dev/null +++ b/db/routines/vn/triggers/entryDms_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_beforeInsert` + BEFORE INSERT ON `entryDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/entryDms_beforeUpdate.sql b/db/routines/vn/triggers/entryDms_beforeUpdate.sql new file mode 100644 index 000000000..ecc047029 --- /dev/null +++ b/db/routines/vn/triggers/entryDms_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_beforeUpdate` + BEFORE UPDATE ON `entryDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index 91d490b21..60b83002c 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -43,9 +43,9 @@ BEGIN SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) - OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN - SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); + IF NOT (NEW.travelFk <=> OLD.travelFk) + OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN + SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceIn_beforeInsert.sql b/db/routines/vn/triggers/invoiceIn_beforeInsert.sql index c09e71ba1..2b80f2534 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeInsert.sql @@ -9,6 +9,10 @@ BEGIN DECLARE vActive TINYINT; DECLARE vWithholdingSageFk INT; + IF NOT util.checkPrintableChars(NEW.supplierRef) THEN + CALL util.throw('The invoiceIn reference contains invalid characters'); + END IF; + SET NEW.editorFk = account.myUser_getId(); SELECT withholdingSageFk INTO vWithholdingSageFk diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql index ae69ad379..4503c7dbd 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql @@ -3,9 +3,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat BEFORE UPDATE ON `invoiceIn` FOR EACH ROW BEGIN - DECLARE vWithholdingSageFk INT; + IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN + CALL util.throw('The invoiceIn reference contains invalid characters'); + END IF; + SET NEW.editorFk = account.myUser_getId(); IF (SELECT COUNT(*) FROM vn.invoiceIn diff --git a/db/routines/vn/triggers/saleLabel_afterUpdate.sql b/db/routines/vn/triggers/saleLabel_afterUpdate.sql new file mode 100644 index 000000000..ff3787358 --- /dev/null +++ b/db/routines/vn/triggers/saleLabel_afterUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleLabel_afterUpdate` + AFTER UPDATE ON `vn`.`saleLabel` + FOR EACH ROW +IF NEW.stem >= (SELECT s.quantity FROM sale s WHERE s.id = NEW.saleFk) THEN + UPDATE sale s SET s.isPicked = TRUE WHERE s.id = NEW.saleFk; +END IF$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/supplierDms_afterDelete.sql b/db/routines/vn/triggers/supplierDms_afterDelete.sql new file mode 100644 index 000000000..482decbb6 --- /dev/null +++ b/db/routines/vn/triggers/supplierDms_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierDms_afterDelete` + AFTER DELETE ON `supplierDms` + FOR EACH ROW +BEGIN + INSERT INTO clientLog + SET `action` = 'delete', + `changedModel` = 'supplierDms', + `changedModelId` = OLD.dmsFk, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/supplierDms_beforeInsert.sql b/db/routines/vn/triggers/supplierDms_beforeInsert.sql new file mode 100644 index 000000000..130428d1e --- /dev/null +++ b/db/routines/vn/triggers/supplierDms_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierDms_beforeInsert` + BEFORE INSERT ON `supplierDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/supplierDms_beforeUpdate.sql b/db/routines/vn/triggers/supplierDms_beforeUpdate.sql new file mode 100644 index 000000000..54dcef049 --- /dev/null +++ b/db/routines/vn/triggers/supplierDms_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierDms_beforeUpdate` + BEFORE UPDATE ON `supplierDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/ticket_beforeUpdate.sql b/db/routines/vn/triggers/ticket_beforeUpdate.sql index 0836b2486..72831bc3d 100644 --- a/db/routines/vn/triggers/ticket_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticket_beforeUpdate.sql @@ -4,7 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_beforeUpdate` FOR EACH ROW BEGIN DECLARE vNewTime TIME; - DECLARE vHasTicketRefund BOOL; SET NEW.editorFk = account.myUser_getId(); @@ -64,14 +63,5 @@ BEGIN CALL vn.routeUpdateM3(NEW.routeFk); END IF; - - SELECT COUNT(*) INTO vHasTicketRefund - FROM ticketRefund - WHERE originalTicketFk = NEW.id - OR refundTicketFk = NEW.id; - - IF vHasTicketRefund AND NEW.clientFk <> OLD.clientFk THEN - CALL util.throw('The ticket has a refund associated'); - END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index 2079cd21e..7cc198e3c 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -3,9 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeUpdate` BEFORE UPDATE ON `travel` FOR EACH ROW BEGIN + DECLARE vHasAnyInvoiceBooked BOOL; + SET NEW.editorFk = account.myUser_getId(); - IF NOT (NEW.landed <=> OLD.landed) + IF NOT (NEW.landed <=> OLD.landed) OR NOT (NEW.shipped <=> OLD.shipped) THEN CALL travel_checkDates(NEW.shipped, NEW.landed); END IF; @@ -17,5 +19,18 @@ BEGIN IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); END IF; + + IF NOT (NEW.awbFk <=> OLD.awbFk)THEN + SELECT COUNT(*) INTO vHasAnyInvoiceBooked + FROM travel t + JOIN entry e ON e.travelFk = t.id + JOIN invoiceIn ii ON ii.id = e.invoiceInFk + WHERE t.id = NEW.id + AND ii.isBooked; + + IF vHasAnyInvoiceBooked THEN + CALL util.throw('The travel has entries with booked invoices'); + END IF; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/views/exchangeInsuranceInPrevious.sql b/db/routines/vn/views/exchangeInsuranceInPrevious.sql deleted file mode 100644 index 097728bc7..000000000 --- a/db/routines/vn/views/exchangeInsuranceInPrevious.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`exchangeInsuranceInPrevious` -AS SELECT `ei`.`finished` AS `dated`, - `ei`.`amount` AS `amount`, - `ei`.`rate` AS `rate` -FROM `vn`.`exchangeInsurance` `ei` -WHERE `ei`.`amount` <> 0 - AND `ei`.`financialProductTypefk` = 'SC' diff --git a/db/routines/vn/views/saleValue.sql b/db/routines/vn/views/saleValue.sql index 4394769d1..2dee4695e 100644 --- a/db/routines/vn/views/saleValue.sql +++ b/db/routines/vn/views/saleValue.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` VIEW `vn`.`saleValue` AS SELECT `wh`.`name` AS `warehouse`, `c`.`name` AS `client`, - `c`.`typeFk` AS `clientTypeFk`, + `c`.`typeFk` AS `typeFk`, `u`.`name` AS `buyer`, `it`.`id` AS `itemTypeFk`, `it`.`name` AS `family`, diff --git a/db/routines/vn/views/unaryScanLineBuy.sql b/db/routines/vn/views/unaryScanLineBuy.sql deleted file mode 100644 index 26f178a45..000000000 --- a/db/routines/vn/views/unaryScanLineBuy.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`unaryScanLineBuy` -AS SELECT `u`.`scan_line_id` AS `unaryScanLineFk`, - `u`.`Id_Article` AS `itemFk` -FROM `vn2008`.`unary_scan_line_buy` `u` diff --git a/db/routines/vn/views/unaryScanLineExpedition.sql b/db/routines/vn/views/unaryScanLineExpedition.sql deleted file mode 100644 index e71c2423e..000000000 --- a/db/routines/vn/views/unaryScanLineExpedition.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`unaryScanLineExpedition` -AS SELECT `u`.`scan_line_id` AS `unaryScanLineFk`, - `u`.`expedition_id` AS `expeditionFk` -FROM `vn2008`.`unary_scan_line_expedition` `u` diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index 631cec7b8..946157fa0 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -40,7 +40,6 @@ proc: BEGIN DELETE FROM cl_main WHERE Fecha < vDate18; DELETE FROM hedera.`order` WHERE date_send < vDate18; DELETE FROM vn.message WHERE sendDate < vDate; - DELETE FROM travel_reserve WHERE odbc_date < vDate; DELETE FROM cache.departure_limit WHERE Fecha < util.VN_CURDATE() - INTERVAL 1 MONTH; diff --git a/db/routines/vn2008/triggers/movement_label_afterUpdate.sql b/db/routines/vn2008/triggers/movement_label_afterUpdate.sql deleted file mode 100644 index 364568fb3..000000000 --- a/db/routines/vn2008/triggers/movement_label_afterUpdate.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`movement_label_afterUpdate` - AFTER UPDATE ON `movement_label` - FOR EACH ROW -IF NEW.stem >= (SELECT Cantidad FROM Movimientos WHERE Id_Movimiento = NEW.Id_Movimiento) THEN - UPDATE Movimientos SET OK = 1 WHERE Id_Movimiento = NEW.Id_Movimiento; -END IF$$ -DELIMITER ; diff --git a/db/routines/vn2008/views/Clientes.sql b/db/routines/vn2008/views/Clientes.sql index 12583915a..a696cb6e0 100644 --- a/db/routines/vn2008/views/Clientes.sql +++ b/db/routines/vn2008/views/Clientes.sql @@ -34,7 +34,6 @@ AS SELECT `c`.`id` AS `id_cliente`, `c`.`hasLcr` AS `hasLcr`, `c`.`defaultAddressFk` AS `default_address`, `c`.`riskCalculated` AS `risk_calculated`, - `c`.`clientTypeFk` AS `clientes_tipo_id`, `c`.`hasToInvoiceByAddress` AS `invoiceByAddress`, `c`.`isTaxDataChecked` AS `contabilizado`, `c`.`isFreezed` AS `congelado`, diff --git a/db/routines/vn2008/views/financialProductType.sql b/db/routines/vn2008/views/financialProductType.sql new file mode 100644 index 000000000..89a063856 --- /dev/null +++ b/db/routines/vn2008/views/financialProductType.sql @@ -0,0 +1,4 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER +VIEW `vn2008`.`financialProductType`AS + SELECT * FROM vn.financialProductType; \ No newline at end of file diff --git a/db/routines/vn2008/views/flight.sql b/db/routines/vn2008/views/flight.sql new file mode 100644 index 000000000..2df5362f7 --- /dev/null +++ b/db/routines/vn2008/views/flight.sql @@ -0,0 +1,13 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`flight` +AS SELECT + `f`.`id` AS `flight_id`, + `f`.`duration` AS `duration`, + `f`.`flightPath` AS `route`, + `f`.`days` AS `days`, + `f`.`airlineFk` AS `airline_id`, + `f`.`airportArrivalFk` AS `airport_out`, + `f`.`airportDepartureFk` AS `airport_in` +FROM + `vn`.`flight` `f`; \ No newline at end of file diff --git a/db/routines/vn2008/views/gastos_resumen.sql b/db/routines/vn2008/views/gastos_resumen.sql new file mode 100644 index 000000000..02231bcbf --- /dev/null +++ b/db/routines/vn2008/views/gastos_resumen.sql @@ -0,0 +1,11 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`gastos_resumen` +AS SELECT + `es`.`expenseFk` AS `Id_Gasto`, + `es`.`year` AS `year`, + `es`.`month` AS `month`, + `es`.`amount` AS `importe`, + `es`.`companyFk` AS `empresa_id` +FROM + `vn`.`expenseManual` `es`; \ No newline at end of file diff --git a/db/routines/vn2008/views/integra2.sql b/db/routines/vn2008/views/integra2.sql new file mode 100644 index 000000000..05840d6bb --- /dev/null +++ b/db/routines/vn2008/views/integra2.sql @@ -0,0 +1,9 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`integra2` +AS SELECT + `i2`.`postCode` AS `postal_code`, + `i2`.`frequency` AS `frequency`, + `i2`.`warehouseFk` AS `warehouse_id` +FROM + `vn`.`integra2` `i2`; \ No newline at end of file diff --git a/db/routines/vn2008/views/integra2_province.sql b/db/routines/vn2008/views/integra2_province.sql new file mode 100644 index 000000000..bc099adb3 --- /dev/null +++ b/db/routines/vn2008/views/integra2_province.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`integra2_province` +AS SELECT + `ip`.`provinceFk` AS `province_id`, + `ip`.`franchise` AS `franquicia` +FROM + `vn`.`integra2Province` `ip`; \ No newline at end of file diff --git a/db/routines/vn2008/views/pago_sdc.sql b/db/routines/vn2008/views/pago_sdc.sql new file mode 100644 index 000000000..29480e376 --- /dev/null +++ b/db/routines/vn2008/views/pago_sdc.sql @@ -0,0 +1,16 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`pago_sdc` +AS SELECT `ei`.`id` AS `pago_sdc_id`, + `ei`.`amount` AS `importe`, + `ei`.`dated` AS `fecha`, + `ei`.`dueDated` AS `vencimiento`, + `ei`.`entityFk` AS `entity_id`, + `ei`.`ref` AS `ref`, + `ei`.`rate` AS `rate`, + `ei`.`companyFk` AS `empresa_id`, + `ei`.`financialProductTypefk` AS `financialProductTypefk`, + `ei`.`upperBarrier` AS `upperBarrier`, + `ei`.`lowerBarrier` AS `lowerBarrier`, + `ei`.`strike` AS `strike` +FROM `vn`.`exchangeInsurance` `ei` \ No newline at end of file diff --git a/db/routines/vn2008/views/warehouse_pickup.sql b/db/routines/vn2008/views/warehouse_pickup.sql new file mode 100644 index 000000000..c3a7268a1 --- /dev/null +++ b/db/routines/vn2008/views/warehouse_pickup.sql @@ -0,0 +1,9 @@ + +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`warehouse_pickup` +AS SELECT + `wp`.`warehouseFk` AS `warehouse_id`, + `wp`.`agencyModeFk` AS `agency_id` +FROM + `vn`.`warehousePickup` `wp`; \ No newline at end of file diff --git a/db/versions/10835-brownCarnation/00-firstScript.sql b/db/versions/10835-brownCarnation/00-firstScript.sql index e66b84ee5..be53d866c 100644 --- a/db/versions/10835-brownCarnation/00-firstScript.sql +++ b/db/versions/10835-brownCarnation/00-firstScript.sql @@ -97,10 +97,6 @@ ALTER TABLE IF EXISTS vn2008.Tickets_stack__ COMMENT='refs #6371 deprecated 2024 ALTER TABLE IF EXISTS vn2008.Tipos_f11 RENAME vn2008.Tipos_f11__; ALTER TABLE IF EXISTS vn2008.Tipos_f11__ COMMENT='refs #6371 deprecated 2024-01-11'; --- Para la tabla Tramos -ALTER TABLE IF EXISTS vn2008.Tramos RENAME vn2008.Tramos__; -ALTER TABLE IF EXISTS vn2008.Tramos__ COMMENT='refs #6371 deprecated 2024-01-11'; - -- Para la tabla accion_dits ALTER TABLE IF EXISTS vn2008.accion_dits RENAME vn2008.accion_dits__; ALTER TABLE IF EXISTS vn2008.accion_dits__ COMMENT='refs #6371 deprecated 2024-01-11'; @@ -161,10 +157,6 @@ ALTER TABLE IF EXISTS vn2008.cyc__ COMMENT='refs #6371 deprecated 2024-01-11'; ALTER TABLE IF EXISTS vn2008.cyc_declaration RENAME vn2008.cyc_declaration__; ALTER TABLE IF EXISTS vn2008.cyc_declaration__ COMMENT='refs #6371 deprecated 2024-01-11'; --- Para la tabla dock -ALTER TABLE IF EXISTS vn2008.dock RENAME vn2008.dock__; -ALTER TABLE IF EXISTS vn2008.dock__ COMMENT='refs #6371 deprecated 2024-01-11'; - -- Para la tabla edi_testigos ALTER TABLE IF EXISTS vn2008.edi_testigos RENAME vn2008.edi_testigos__; ALTER TABLE IF EXISTS vn2008.edi_testigos__ COMMENT='refs #6371 deprecated 2024-01-11'; diff --git a/db/versions/10841-orangeGalax/00-entryDms.sql b/db/versions/10841-orangeGalax/00-entryDms.sql new file mode 100644 index 000000000..33ec1e3af --- /dev/null +++ b/db/versions/10841-orangeGalax/00-entryDms.sql @@ -0,0 +1,15 @@ +CREATE OR REPLACE TABLE `vn`.`entryDms` ( + `entryFk` int(11) NOT NULL, + `dmsFk` int(11) NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`entryFk`,`dmsFk`), + KEY `gestdoc_id` (`dmsFk`), + KEY `entryDms_editor` (`editorFk`), + CONSTRAINT `entryDms_dms` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `entryDms_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), + CONSTRAINT `entryDms_entry` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('EntryDms', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/versions/10841-orangeGalax/00-entryDmsType.vn.sql b/db/versions/10841-orangeGalax/00-entryDmsType.vn.sql new file mode 100644 index 000000000..d408ab827 --- /dev/null +++ b/db/versions/10841-orangeGalax/00-entryDmsType.vn.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`dmsType` (code, name, path__, writeRoleFk, readRoleFk, monthToDelete) + VALUES('entry', 'Entrada', '', 1, 1, NULL); diff --git a/db/versions/10862-navyHydrangea/00-alterAgencyTermConfig.sql b/db/versions/10862-navyHydrangea/00-alterAgencyTermConfig.sql new file mode 100644 index 000000000..3409b762e --- /dev/null +++ b/db/versions/10862-navyHydrangea/00-alterAgencyTermConfig.sql @@ -0,0 +1,3 @@ +USE vn; +ALTER TABLE vn.agencyTermConfig + ADD CONSTRAINT agencyTermConfig_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/00-alterGastosResumen.sql b/db/versions/10862-navyHydrangea/00-alterGastosResumen.sql new file mode 100644 index 000000000..307b8f205 --- /dev/null +++ b/db/versions/10862-navyHydrangea/00-alterGastosResumen.sql @@ -0,0 +1,11 @@ +USE vn; + +ALTER TABLE vn2008.gastos_resumen MODIFY COLUMN Id_Gasto varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; + +DELETE gr.* + FROM vn2008.gastos_resumen gr LEFT JOIN vn.expense e ON gr.Id_Gasto = e.id + WHERE e.id IS NULL; + +ALTER TABLE vn2008.gastos_resumen + ADD CONSTRAINT gastos_resumen_expense_FK + FOREIGN KEY (Id_Gasto) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/00-alterInvoiceOutTaxConfig.sql b/db/versions/10862-navyHydrangea/00-alterInvoiceOutTaxConfig.sql new file mode 100644 index 000000000..fc5025c18 --- /dev/null +++ b/db/versions/10862-navyHydrangea/00-alterInvoiceOutTaxConfig.sql @@ -0,0 +1,5 @@ +USE vn; +ALTER TABLE vn.invoiceOutTaxConfig MODIFY COLUMN expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; + +ALTER TABLE vn.invoiceOutTaxConfig + ADD CONSTRAINT invoiceOutTaxConfig_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/00-alterItemGroupToOffer.sql b/db/versions/10862-navyHydrangea/00-alterItemGroupToOffer.sql new file mode 100644 index 000000000..68611c13c --- /dev/null +++ b/db/versions/10862-navyHydrangea/00-alterItemGroupToOffer.sql @@ -0,0 +1,5 @@ +USE edi; +ALTER TABLE edi.item_groupToOffer MODIFY COLUMN expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '7001000000' NULL; + +ALTER TABLE edi.item_groupToOffer + ADD CONSTRAINT item_groupToOffer_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/01-ventasContablesPk.sql b/db/versions/10862-navyHydrangea/01-ventasContablesPk.sql new file mode 100644 index 000000000..3f8bf2c79 --- /dev/null +++ b/db/versions/10862-navyHydrangea/01-ventasContablesPk.sql @@ -0,0 +1,14 @@ +USE vn; +-- Eliminar la clave primaria actual +ALTER TABLE bs.ventas_contables DROP PRIMARY KEY; + +-- Agregar la nueva clave primaria incluyendo el campo `gasto` +ALTER TABLE bs.ventas_contables ADD PRIMARY KEY (`year`, `month`, `grupo`, `reino_id`, `tipo_id`, `empresa_id`, `gasto`); + +DELETE vc.* FROM bs.ventas_contables vc LEFT JOIN vn.expense e ON e.id = vc.gasto WHERE e.id IS NULL; + +ALTER TABLE bs.ventas_contables + MODIFY COLUMN gasto VARCHAR(10) + CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; + +ALTER TABLE bs.ventas_contables ADD CONSTRAINT ventas_contables_expense_FK FOREIGN KEY (gasto) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/02-updateExpenseRegularize.sql b/db/versions/10862-navyHydrangea/02-updateExpenseRegularize.sql new file mode 100644 index 000000000..90d865c1d --- /dev/null +++ b/db/versions/10862-navyHydrangea/02-updateExpenseRegularize.sql @@ -0,0 +1,8 @@ +DELETE FROM vn.expense + WHERE id ='' AND id IS NULL AND isWithheld = FALSE; +UPDATE vn.expense + SET id='7002090000' + WHERE id='7002009000'; +UPDATE vn.expense + SET id='7001090000' + WHERE id='7001009000'; diff --git a/db/versions/10862-navyHydrangea/03-updateExpense.sql b/db/versions/10862-navyHydrangea/03-updateExpense.sql new file mode 100644 index 000000000..a44c4c504 --- /dev/null +++ b/db/versions/10862-navyHydrangea/03-updateExpense.sql @@ -0,0 +1,44 @@ +UPDATE vn.expense +SET id = CASE id + WHEN 7000010000 THEN 7001001000 + WHEN 7000020000 THEN 7001002000 + WHEN 7000030000 THEN 7001003000 + WHEN 7000040000 THEN 7001004000 + WHEN 7000050000 THEN 7001005000 + WHEN 7000060000 THEN 7001006000 + WHEN 7000070000 THEN 7001007000 + WHEN 7002060000 THEN 7001206000 + WHEN 7002070000 THEN 7001207000 + WHEN 7002030000 THEN 7001203000 + WHEN 7002040000 THEN 7001204000 + WHEN 7002050000 THEN 7001205000 + WHEN 7002020000 THEN 7001202000 + WHEN 7002010000 THEN 7001201000 + WHEN 7001060000 THEN 7001106000 + WHEN 7001070000 THEN 7001107000 + WHEN 7001030000 THEN 7001103000 + WHEN 7001040000 THEN 7001104000 + WHEN 7001050000 THEN 7001105000 + WHEN 7001020000 THEN 7001102000 + WHEN 7001010000 THEN 7001101000 + WHEN 7000080000 THEN 7040008000 + WHEN 7001080000 THEN 7000108000 + WHEN 7002080000 THEN 7001208000 + WHEN 7000090000 THEN 7001009000 + WHEN 7002090000 THEN 7001209000 + WHEN 7002100000 THEN 7001210000 + WHEN 7001090000 THEN 7001109000 + WHEN 7001100000 THEN 7001110000 + WHEN 7000120000 THEN 7001012000 + WHEN 7002120000 THEN 7001212000 + WHEN 7000130000 THEN 7001013000 + WHEN 7000140000 THEN 7001014000 + ELSE id +END +WHERE id IN (7000010000, 7000020000, 7000030000, 7000040000, 7000050000, + 7000060000, 7000070000, 7002060000, 7002070000, 7002030000, + 7002040000, 7002050000, 7002020000, 7002010000, 7001060000, + 7001070000, 7001030000, 7001040000, 7001050000, 7001020000, + 7001010000, 7000080000, 7001080000, 7002080000, 7000090000, + 7002090000, 7002100000, 7001090000, 7001100000, + 7000120000, 7002120000, 7000130000, 7000140000); diff --git a/db/versions/10862-navyHydrangea/04-updateExpenseConflict.sql b/db/versions/10862-navyHydrangea/04-updateExpenseConflict.sql new file mode 100644 index 000000000..0e008081b --- /dev/null +++ b/db/versions/10862-navyHydrangea/04-updateExpenseConflict.sql @@ -0,0 +1,6 @@ +UPDATE vn.expense +SET id = CASE id + WHEN 7000100000 THEN 7001010000 + ELSE id +END +WHERE id IN (7000100000); diff --git a/db/versions/10885-wheatHydrangea/00-revokeUpdateClient.sql b/db/versions/10885-wheatHydrangea/00-revokeUpdateClient.sql new file mode 100644 index 000000000..b22e09615 --- /dev/null +++ b/db/versions/10885-wheatHydrangea/00-revokeUpdateClient.sql @@ -0,0 +1,37 @@ +REVOKE UPDATE ON vn.ticket FROM employee; + +GRANT UPDATE (id, + warehouseFk, + shipped, + nickname, + refFk, + addressFk, + workerFk, + observations, + isSigned, + isLabeled, + isPrinted, + packages, + location, + hour, + created, + isBlocked, + solution, + routeFk, + priority, + hasPriority, + companyFk, + agencyModeFk, + landed, + isBoxed, + isDeleted, + zoneFk, + zonePrice, + zoneBonus, + totalWithVat, + totalWithoutVat, + weight, + clonedFrom, + cmrFk, + editorFk) + ON vn.ticket TO employee; diff --git a/db/versions/10891-chocolateRuscus/00-firstScript.sql b/db/versions/10891-chocolateRuscus/00-firstScript.sql new file mode 100644 index 000000000..711850323 --- /dev/null +++ b/db/versions/10891-chocolateRuscus/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.client DROP FOREIGN KEY tipos_de_cliente; +ALTER TABLE vn.client CHANGE COLUMN clientTypeFk clientTypeFk__ INT NOT NULL DEFAULT 1 COMMENT '@deprecated 2024-02-20 refs #6784'; +ALTER TABLE vn.clientType CHANGE COLUMN id id__ INT NOT NULL COMMENT '@deprecated 2024-02-20 refs #6784'; +ALTER TABLE vn.clientType DROP PRIMARY KEY; +ALTER TABLE vn.clientType ADD PRIMARY KEY (code); + diff --git a/db/versions/10896-salmonOrchid/01-financialProductType.sql b/db/versions/10896-salmonOrchid/01-financialProductType.sql new file mode 100644 index 000000000..c5d51e015 --- /dev/null +++ b/db/versions/10896-salmonOrchid/01-financialProductType.sql @@ -0,0 +1 @@ +ALTER TABLE IF EXISTS `vn2008`.`financialProductType` RENAME `vn`.`financialProductType`; diff --git a/db/versions/10896-salmonOrchid/02-flight.sql b/db/versions/10896-salmonOrchid/02-flight.sql new file mode 100644 index 000000000..657fa2aa1 --- /dev/null +++ b/db/versions/10896-salmonOrchid/02-flight.sql @@ -0,0 +1,8 @@ +ALTER TABLE IF EXISTS `vn2008`.`flight` RENAME `vn`.`flight`; + +ALTER TABLE IF EXISTS `vn`.`flight` +CHANGE COLUMN IF EXISTS `flight_id` `id` varchar(10) NOT NULL, +CHANGE COLUMN IF EXISTS `airline_id` `airlineFk` smallint(2) unsigned DEFAULT NULL, +CHANGE COLUMN IF EXISTS `route` `flightPath` varchar(20) DEFAULT NULL, +CHANGE COLUMN IF EXISTS `airport_out` `airportArrivalFk` varchar(3) NOT NULL, +CHANGE COLUMN IF EXISTS `airport_in` `airportDepartureFk` varchar(3) NOT NULL; \ No newline at end of file diff --git a/db/versions/10896-salmonOrchid/03-gastos_resumen.sql b/db/versions/10896-salmonOrchid/03-gastos_resumen.sql new file mode 100644 index 000000000..1f5101df5 --- /dev/null +++ b/db/versions/10896-salmonOrchid/03-gastos_resumen.sql @@ -0,0 +1,32 @@ +DELETE FROM vn2008.gastos_resumen + WHERE Id_Gasto IN ( + SELECT DISTINCT g.Id_Gasto + FROM vn2008.gastos_resumen g + LEFT JOIN vn.expense e ON e.id = g.Id_Gasto COLLATE utf8mb3_general_ci + WHERE e.id IS NULL + ); + +ALTER TABLE `vn2008`.`gastos_resumen` DROP FOREIGN KEY gastos_resumen_expense_FK; +ALTER TABLE IF EXISTS `vn2008`.`gastos_resumen` RENAME `vn`.`expenseManual`; +ALTER TABLE `vn`.`expenseManual` +CHANGE COLUMN IF EXISTS `Id_Gasto` `expenseFk` varchar(10) NOT NULL, +CHANGE COLUMN IF EXISTS `importe` `amount` decimal(10,2) DEFAULT NULL, +CHANGE COLUMN IF EXISTS `empresa_id` `companyFk` int(11) NOT NULL; + +ALTER TABLE `vn`.`expenseManual` MODIFY COLUMN IF EXISTS expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; + +ALTER TABLE `vn`.`expenseManual` DROP PRIMARY KEY; + +ALTER TABLE `vn`.`expenseManual` MODIFY COLUMN companyFk int(10) unsigned NULL; + +ALTER TABLE `vn`.`expenseManual` ADD CONSTRAINT expenseManual_expense_FK FOREIGN KEY IF NOT EXISTS (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE; + +UPDATE `vn`.`expenseManual` + SET companyFK= NULL + WHERE companyFk= 0; + +ALTER TABLE `vn`.`expenseManual` ADD CONSTRAINT expenseManual_company_FK FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`expenseManual` ADD COLUMN id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY FIRST; + +ALTER TABLE `vn`.`expenseManual` ADD CONSTRAINT expenseManual_unique UNIQUE KEY IF NOT EXISTS (expenseFk,`year`,`month`,companyFk); \ No newline at end of file diff --git a/db/versions/10896-salmonOrchid/04-integra2.sql b/db/versions/10896-salmonOrchid/04-integra2.sql new file mode 100644 index 000000000..663b28d78 --- /dev/null +++ b/db/versions/10896-salmonOrchid/04-integra2.sql @@ -0,0 +1,10 @@ +ALTER TABLE IF EXISTS `vn2008`.`integra2` RENAME `vn`.`integra2`; + +ALTER TABLE IF EXISTS `vn`.`integra2` +CHANGE COLUMN IF EXISTS `postal_code` `postCode` varchar(10) NOT NULL, +CHANGE COLUMN IF EXISTS `frequency` `frequency` decimal(10,2) DEFAULT NULL, +CHANGE COLUMN IF EXISTS `warehouse_id` `warehouseFk` smallint(6) unsigned NOT NULL; + +ALTER TABLE IF EXISTS vn.integra2 ADD CONSTRAINT integra2_warehouse_FK +FOREIGN KEY (warehouseFk) REFERENCES vn.warehouse(id) ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/db/versions/10896-salmonOrchid/05-integra2_province.sql b/db/versions/10896-salmonOrchid/05-integra2_province.sql new file mode 100644 index 000000000..31f8f4156 --- /dev/null +++ b/db/versions/10896-salmonOrchid/05-integra2_province.sql @@ -0,0 +1,4 @@ +ALTER TABLE IF EXISTS `vn2008`.`integra2_province` RENAME `vn`.`integra2Province`; +ALTER TABLE IF EXISTS `vn`.`integra2Province` +CHANGE COLUMN IF EXISTS `franquicia` `franchise` varchar(65) NOT NULL, +CHANGE COLUMN IF EXISTS `province_id` `provinceFk` smallint(6) unsigned NOT NULL; diff --git a/db/versions/10896-salmonOrchid/06-intervalos__delete.sql b/db/versions/10896-salmonOrchid/06-intervalos__delete.sql new file mode 100644 index 000000000..18d4f57ca --- /dev/null +++ b/db/versions/10896-salmonOrchid/06-intervalos__delete.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS vn2008.intervalos__; \ No newline at end of file diff --git a/db/versions/10896-salmonOrchid/10-mail_templates__delete.sql b/db/versions/10896-salmonOrchid/10-mail_templates__delete.sql new file mode 100644 index 000000000..e30aae925 --- /dev/null +++ b/db/versions/10896-salmonOrchid/10-mail_templates__delete.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS vn2008.mail_templates__; diff --git a/db/versions/10896-salmonOrchid/12-ticket_location__delete.sql b/db/versions/10896-salmonOrchid/12-ticket_location__delete.sql new file mode 100644 index 000000000..a7dbbfb95 --- /dev/null +++ b/db/versions/10896-salmonOrchid/12-ticket_location__delete.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS vn2008.ticket_location__; \ No newline at end of file diff --git a/db/versions/10896-salmonOrchid/13-turn__delete.sql b/db/versions/10896-salmonOrchid/13-turn__delete.sql new file mode 100644 index 000000000..7aa69e57d --- /dev/null +++ b/db/versions/10896-salmonOrchid/13-turn__delete.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS vn2008.turn__; \ No newline at end of file diff --git a/db/versions/10896-salmonOrchid/14-movement_label.sql b/db/versions/10896-salmonOrchid/14-movement_label.sql new file mode 100644 index 000000000..194df6e1e --- /dev/null +++ b/db/versions/10896-salmonOrchid/14-movement_label.sql @@ -0,0 +1,12 @@ +DROP TRIGGER IF EXISTS `vn2008`.`movement_label_afterUpdate`; + +ALTER TABLE vn2008.movement_label DROP FOREIGN KEY movement_label_ibfk_1; + +DROP VIEW IF EXISTS `vn`.`saleLabel`; + +ALTER TABLE IF EXISTS `vn2008`.`movement_label` RENAME `vn`.`saleLabel`; + +ALTER TABLE IF EXISTS `vn`.`saleLabel` +CHANGE COLUMN IF EXISTS `Id_movimiento` `saleFk` int(11) NOT NULL; + +ALTER TABLE `vn`.`saleLabel` ADD CONSTRAINT saleLabel_sale_FK FOREIGN KEY (saleFk) REFERENCES vn.sale(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/10896-salmonOrchid/15-pago_sdc.sql b/db/versions/10896-salmonOrchid/15-pago_sdc.sql new file mode 100644 index 000000000..1b63b9c54 --- /dev/null +++ b/db/versions/10896-salmonOrchid/15-pago_sdc.sql @@ -0,0 +1,11 @@ +DROP VIEW IF EXISTS `vn`.`exchangeInsurance`; + +ALTER TABLE IF EXISTS `vn2008`.`pago_sdc` RENAME `vn`.`exchangeInsurance`; + +ALTER TABLE IF EXISTS `vn`.`exchangeInsurance` +CHANGE COLUMN IF EXISTS `pago_sdc_id` `id` int(11) NOT NULL AUTO_INCREMENT, +CHANGE COLUMN IF EXISTS `importe` `amount` decimal(10,2) NOT NULL, +CHANGE COLUMN IF EXISTS `fecha` `dated` date NOT NULL, +CHANGE COLUMN IF EXISTS `vencimiento` `dueDated` date NOT NULL, +CHANGE COLUMN IF EXISTS `entity_id` `entityFk` int(10) unsigned NOT NULL, +CHANGE COLUMN IF EXISTS `empresa_id` `companyFk`int(10) unsigned NOT NULL DEFAULT 442; diff --git a/db/versions/10896-salmonOrchid/25-warehouse_pickup.sql b/db/versions/10896-salmonOrchid/25-warehouse_pickup.sql new file mode 100644 index 000000000..d6f2ae18d --- /dev/null +++ b/db/versions/10896-salmonOrchid/25-warehouse_pickup.sql @@ -0,0 +1,7 @@ +ALTER TABLE IF EXISTS `vn2008`.`warehouse_pickup` RENAME `vn`.`warehousePickup`; + +ALTER TABLE IF EXISTS `vn`.`warehousePickup` +CHANGE COLUMN IF EXISTS `warehouse_id` `warehouseFk` smallint(5) unsigned NOT NULL, +CHANGE COLUMN IF EXISTS `agency_id` `agencyModeFk` int(11) DEFAULT NULL; + +ALTER TABLE `vn`.`warehousePickup` COMMENT='Agencia de recogida para cada almacén'; diff --git a/db/versions/10896-salmonOrchid/29-kk.sql b/db/versions/10896-salmonOrchid/29-kk.sql new file mode 100644 index 000000000..201a1c806 --- /dev/null +++ b/db/versions/10896-salmonOrchid/29-kk.sql @@ -0,0 +1,155 @@ +ALTER TABLE IF EXISTS vn2008.template_bionic_component RENAME vn2008.template_bionic_component__; +ALTER TABLE IF EXISTS vn2008.template_bionic_component__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.template_bionic_lot RENAME vn2008.template_bionic_lot__; +ALTER TABLE IF EXISTS vn2008.template_bionic_lot__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.template_bionic_price RENAME vn2008.template_bionic_price__; +ALTER TABLE IF EXISTS vn2008.template_bionic_price__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.tmpNEWTARIFAS RENAME vn2008.tmpNEWTARIFAS__; +ALTER TABLE IF EXISTS vn2008.tmpNEWTARIFAS__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.unaryScanFilter RENAME vn2008.unaryScanFilter__; +ALTER TABLE IF EXISTS vn2008.unaryScanFilter__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.unary_source RENAME vn2008.unary_source__; +ALTER TABLE IF EXISTS vn2008.unary_source__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.viaxpress RENAME vn2008.viaxpress__; +ALTER TABLE IF EXISTS vn2008.viaxpress__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.warehouse_filtro RENAME vn2008.warehouse_filtro__; +ALTER TABLE IF EXISTS vn2008.warehouse_filtro__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.warehouse_group RENAME vn2008.warehouse_group__; +ALTER TABLE IF EXISTS vn2008.warehouse_group__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.warehouse_joined RENAME vn2008.warehouse_joined__; +ALTER TABLE IF EXISTS vn2008.warehouse_joined__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.warehouse_lc RENAME vn2008.warehouse_lc__; +ALTER TABLE IF EXISTS vn2008.warehouse_lc__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.wh_selection RENAME vn2008.wh_selection__; +ALTER TABLE IF EXISTS vn2008.wh_selection__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.trolley RENAME vn2008.trolley__; +ALTER TABLE IF EXISTS vn2008.trolley__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.zones RENAME vn2008.zones__; +ALTER TABLE IF EXISTS vn2008.zones__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.tblIVA RENAME vn2008.tblIVA__; +ALTER TABLE IF EXISTS vn2008.tblIVA__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.filtros RENAME vn2008.filtros__; +ALTER TABLE IF EXISTS vn2008.filtros__ COMMENT='refs #6372 @deprecated 2023-11-21;'; + +ALTER TABLE IF EXISTS vn2008.form_query RENAME vn2008.form_query__; +ALTER TABLE IF EXISTS vn2008.form_query__ COMMENT='refs #6372 @deprecated 2023-11-21;'; + +ALTER TABLE IF EXISTS vn2008.guillen RENAME vn2008.guillen__; +ALTER TABLE IF EXISTS vn2008.guillen__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.guillen_carry RENAME vn2008.guillen_carry__; +ALTER TABLE IF EXISTS vn2008.guillen_carry__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.integra2_escala RENAME vn2008.integra2_escala__; +ALTER TABLE IF EXISTS vn2008.integra2_escala__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.invoice_observation RENAME vn2008.invoice_observation__; +ALTER TABLE IF EXISTS vn2008.invoice_observation__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.nichos RENAME vn2008.nichos__; +ALTER TABLE IF EXISTS vn2008.nichos__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.payroll_bonificaciones RENAME vn2008.payroll_bonificaciones__; +ALTER TABLE IF EXISTS vn2008.payroll_bonificaciones__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.payroll_datos RENAME vn2008.payroll_datos__; +ALTER TABLE IF EXISTS vn2008.payroll_datos__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.payroll_embargos RENAME vn2008.payroll_embargos__; +ALTER TABLE IF EXISTS vn2008.payroll_embargos__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.payroll_tipobasess RENAME vn2008.payroll_tipobasess__; +ALTER TABLE IF EXISTS vn2008.payroll_tipobasess__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.preparation_exception RENAME vn2008.preparation_exception__; +ALTER TABLE IF EXISTS vn2008.preparation_exception__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.payrroll_apEmpresarial RENAME vn2008.payrroll_apEmpresarial__; +ALTER TABLE IF EXISTS vn2008.payrroll_apEmpresarial__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.rec_translator RENAME vn2008.rec_translator__; +ALTER TABLE IF EXISTS vn2008.rec_translator__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.recibida_agricola RENAME vn2008.recibida_agricola__; +ALTER TABLE IF EXISTS vn2008.recibida_agricola__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.rounding RENAME vn2008.rounding__; +ALTER TABLE IF EXISTS vn2008.rounding__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.scanTree RENAME vn2008.scanTree__; +ALTER TABLE IF EXISTS vn2008.scanTree__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.sort_merge_results_ernesto RENAME vn2008.sort_merge_results_ernesto__; +ALTER TABLE IF EXISTS vn2008.sort_merge_results_ernesto__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.route RENAME vn2008.route__; +ALTER TABLE IF EXISTS vn2008.route__ COMMENT='refs #6372 @deprecated 2023-11-28;'; + +ALTER TABLE IF EXISTS vn2008.travel_reserve RENAME vn2008.travel_reserve__; +ALTER TABLE IF EXISTS vn2008.travel_reserve__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.wks RENAME vn2008.wks__; +ALTER TABLE IF EXISTS vn2008.wks__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.unary RENAME vn2008.unary__; +ALTER TABLE IF EXISTS vn2008.unary__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.unary_scan RENAME vn2008.unary_scan__; +ALTER TABLE IF EXISTS vn2008.unary_scan__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.unary_scan_line RENAME vn2008.unary_scan_line__; +ALTER TABLE IF EXISTS vn2008.unary_scan_line__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.unary_scan_line_buy RENAME vn2008.unary_scan_line_buy__; +ALTER TABLE IF EXISTS vn2008.unary_scan_line_buy__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.unary_scan_line_expedition RENAME vn2008.unary_scan_line_expedition__; +ALTER TABLE IF EXISTS vn2008.unary_scan_line_expedition__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.widget RENAME vn2008.widget__; +ALTER TABLE IF EXISTS vn2008.widget__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.scan RENAME vn2008.scan__; +ALTER TABLE IF EXISTS vn2008.scan__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.scan_line RENAME vn2008.scan_line__; +ALTER TABLE IF EXISTS vn2008.scan_line__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.tipsa RENAME vn2008.tipsa__; +ALTER TABLE IF EXISTS vn2008.tipsa__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.payroll_basess RENAME vn2008.payroll_basess__; +ALTER TABLE IF EXISTS vn2008.payroll_basess__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.pago_sdc RENAME vn2008.pago_sdc__; +ALTER TABLE IF EXISTS vn2008.pago_sdc__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.transport RENAME vn2008.transport__; +ALTER TABLE IF EXISTS vn2008.transport__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.travel_pattern RENAME vn2008.travel_pattern__; +ALTER TABLE IF EXISTS vn2008.travel_pattern__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.jerarquia RENAME vn2008.jerarquia__; +ALTER TABLE IF EXISTS vn2008.jerarquia__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.language RENAME vn2008.language__; +ALTER TABLE IF EXISTS vn2008.language__ COMMENT='refs #6372 @deprecated 2023-12-13;'; + +ALTER TABLE IF EXISTS vn2008.link RENAME vn2008.link__; +ALTER TABLE IF EXISTS vn2008.link__ COMMENT='refs #6372 @deprecated 2023-12-13;'; diff --git a/db/versions/10896-salmonOrchid/30-permissions.sql b/db/versions/10896-salmonOrchid/30-permissions.sql new file mode 100644 index 000000000..fd7c6c58e --- /dev/null +++ b/db/versions/10896-salmonOrchid/30-permissions.sql @@ -0,0 +1,32 @@ +-- flight +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER +VIEW `vn2008`.`flight` AS + SELECT 1; +GRANT SELECT, INSERT, UPDATE ON TABLE vn2008.flight TO `logistic`; +GRANT SELECT, INSERT, UPDATE ON TABLE vn.flight TO `logistic`; +-- integra2_province +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER +VIEW `vn2008`.`integra2_province` AS + SELECT 1; +GRANT SELECT ON TABLE vn2008.integra2_province TO `employee`; +GRANT SELECT ON TABLE vn.integra2Province TO `employee`; +-- link + +GRANT SELECT ON TABLE vn.company TO `administrative`; +GRANT SELECT ON TABLE vn.company TO `hr`; + +-- warehouse_pickup +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER +VIEW `vn2008`.`warehouse_pickup` AS + SELECT 1; +GRANT SELECT ON TABLE vn2008.warehouse_pickup TO `logistic`; +GRANT SELECT ON TABLE vn.warehousePickup TO `logistic`; +GRANT SELECT ON TABLE vn2008.warehouse_pickup TO `claimManager`; +GRANT SELECT ON TABLE vn.warehousePickup TO `claimManager`; +GRANT SELECT ON TABLE vn2008.warehouse_pickup TO `employee`; +GRANT SELECT ON TABLE vn.warehousePickup TO `employee`; +GRANT SELECT ON TABLE vn2008.warehouse_pickup TO `deliveryAssistant`; +GRANT SELECT ON TABLE vn.warehousePickup TO `deliveryAssistant`; diff --git a/db/versions/10898-workerActivity/00-table.sql b/db/versions/10898-workerActivity/00-table.sql new file mode 100644 index 000000000..ec517b929 --- /dev/null +++ b/db/versions/10898-workerActivity/00-table.sql @@ -0,0 +1,13 @@ +-- Place your SQL code here +CREATE TABLE vn.workerActivity ( +id INT PRIMARY KEY AUTO_INCREMENT, +created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, +model ENUM('COM', 'ENT', 'TPV', 'ENC', 'LAB', 'ETI') NOT NULL, +workerFk INT(10) UNSIGNED NOT NULL, +event ENUM('open', 'close', 'insert', 'delete', 'update', 'refresh') NOT NULL, +description VARCHAR(255) DEFAULT NULL, +CONSTRAINT fk_workerActivity_worker FOREIGN KEY (workerFk) + REFERENCES vn.worker (id) + ON DELETE CASCADE + ON UPDATE CASCADE +); \ No newline at end of file diff --git a/db/versions/10906-limeIvy/00-firstScript.sql b/db/versions/10906-limeIvy/00-firstScript.sql new file mode 100644 index 000000000..6ce187d20 --- /dev/null +++ b/db/versions/10906-limeIvy/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.professionalCategory DROP COLUMN IF EXISTS code; +ALTER TABLE IF EXISTS vn.professionalCategory ADD COLUMN code VARCHAR(25) UNIQUE DEFAULT NULL; + +UPDATE vn.professionalCategory + SET code = 'driverCE' + WHERE name = 'Conductor C + E'; \ No newline at end of file diff --git a/db/versions/10908-blueAsparagus/00-createSupplierDms.sql b/db/versions/10908-blueAsparagus/00-createSupplierDms.sql new file mode 100644 index 000000000..bc0a40f11 --- /dev/null +++ b/db/versions/10908-blueAsparagus/00-createSupplierDms.sql @@ -0,0 +1,25 @@ +DELETE FROM vn.supplierDms + WHERE dmsFk IN ( + SELECT sd.dmsFk + FROM vn.supplierDms sd + LEFT JOIN vn.dms d ON d.id = sd.dmsFk + WHERE d.id IS NULL + ); + +DELETE FROM vn.supplierDms + WHERE supplierFk IN ( + SELECT sd.supplierFk + FROM vn.supplierDms sd + LEFT JOIN vn.supplier s ON s.id = sd.supplierFk + WHERE s.id IS NULL + ); + +ALTER TABLE `vn`.`supplierDms` + MODIFY COLUMN supplierFk int(10) unsigned NOT NULL, + ADD editorFk INT UNSIGNED NULL, + ADD CONSTRAINT user_Fk FOREIGN KEY (editorFk) REFERENCES account.`user`(id), + ADD CONSTRAINT dms_Fk FOREIGN KEY (dmsFk) REFERENCES vn.dms(id) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT supplier_Fk FOREIGN KEY (supplierFk) REFERENCES vn.supplier(id) ON UPDATE CASCADE; + +ALTER TABLE `vn`.`supplierLog` + MODIFY COLUMN `changedModel` ENUM('Supplier','SupplierAddress','SupplierAccount','SupplierContact','SupplierDms') NOT NULL DEFAULT 'Supplier'; \ No newline at end of file diff --git a/db/versions/10912-brownCataractarum/00-firstScript.sql b/db/versions/10912-brownCataractarum/00-firstScript.sql new file mode 100644 index 000000000..51aea42a1 --- /dev/null +++ b/db/versions/10912-brownCataractarum/00-firstScript.sql @@ -0,0 +1,12 @@ +ALTER TABLE vn.country + MODIFY COLUMN code varchar(2) NOT NULL; + +ALTER TABLE vn.country + ADD CONSTRAINT country_unique UNIQUE KEY (code); + +ALTER TABLE vn.transitoryDuaUnified + ADD countryCodeFk varchar(2) DEFAULT 'EC' NOT NULL; + +ALTER TABLE vn.transitoryDuaUnified + ADD CONSTRAINT transitoryDuaUnified_country_FK FOREIGN KEY (countryCodeFk) + REFERENCES vn.country(code); diff --git a/front/core/components/watcher/locale/es.yml b/front/core/components/watcher/locale/es.yml index 5d25752b4..83553d20d 100644 --- a/front/core/components/watcher/locale/es.yml +++ b/front/core/components/watcher/locale/es.yml @@ -1,4 +1,4 @@ Are you sure exit without saving?: ¿Seguro que quieres salir sin guardar? Unsaved changes will be lost: Los cambios que no hayas guardado se perderán No changes to save: No hay cambios que guardar -Some fields are invalid: Algunos campos no son válidos \ No newline at end of file +Some fields are invalid: Algunos campos no son válidos diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 49283e633..4079fa1ca 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -333,9 +333,12 @@ "It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}", "This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada", "This user does not have an assigned tablet": "Este usuario no tiene tablet asignada", - "Incorrect pin": "Pin incorrecto", + "Field are invalid": "El campo '{{tag}}' no es válido", + "Incorrect pin": "Pin incorrecto.", "You already have the mailAlias": "Ya tienes este alias de correo", "The alias cant be modified": "Este alias de correo no puede ser modificado", + "No tickets to invoice": "No hay tickets para facturar", + "this warehouse has not dms": "El Almacén no acepta documentos", "This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado", "Name should be uppercase": "El nombre debe ir en mayúscula", "Bank entity must be specified": "La entidad bancaria es obligatoria", @@ -344,6 +347,5 @@ "CountryFK cannot be empty": "El país no puede estar vacío", "Cmr file does not exist": "El archivo del cmr no existe", "You are not allowed to modify the alias": "No estás autorizado a modificar el alias", - "No tickets to invoice": "No hay tickets para facturar", "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas" } diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index aadee048c..608479b4b 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -103,6 +103,20 @@ "video/mp4" ] }, + "entryStorage": { + "name": "entryStorage", + "connector": "loopback-component-storage", + "provider": "filesystem", + "root": "./storage/dms", + "maxFileSize": "31457280", + "allowedContentTypes": [ + "image/png", + "image/jpeg", + "image/jpg", + "image/webp", + "video/mp4" + ] + }, "accessStorage": { "name": "accessStorage", "connector": "loopback-component-storage", diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 5fd886c32..9a6255215 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -26,23 +26,23 @@ module.exports = Self => { }, { arg: 'street', - type: 'string' + type: 'any' }, { arg: 'postcode', - type: 'string' + type: 'any' }, { arg: 'city', - type: 'string' + type: 'any' }, { arg: 'countryFk', - type: 'number' + type: 'any' }, { arg: 'provinceFk', - type: 'number' + type: 'any' }, { arg: 'sageTaxTypeFk', @@ -94,7 +94,7 @@ module.exports = Self => { }, { arg: 'despiteOfClient', - type: 'number' + type: 'any' }, { arg: 'hasIncoterms', diff --git a/modules/client/back/models/client-type.json b/modules/client/back/models/client-type.json index eeae845eb..ecf0c065f 100644 --- a/modules/client/back/models/client-type.json +++ b/modules/client/back/models/client-type.json @@ -7,12 +7,9 @@ } }, "properties": { - "id": { - "type": "number", - "id": true - }, "code": { - "type": "string" + "type": "string", + "id": true }, "type": { "type": "string" diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index bfde05162..550ac380e 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -197,7 +197,7 @@ "type": { "type": "belongsTo", "model": "ClientType", - "foreignKey": "clientTypeFk" + "foreignKey": "typeFk" }, "businessType": { "type": "belongsTo", diff --git a/modules/entry/back/methods/entry-dms/downloadFile.js b/modules/entry/back/methods/entry-dms/downloadFile.js new file mode 100644 index 000000000..a4f10f9dc --- /dev/null +++ b/modules/entry/back/methods/entry-dms/downloadFile.js @@ -0,0 +1,59 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('downloadFile', { + description: 'Get the entry file', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'Number', + description: 'The document id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, + { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, + { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: `/:id/downloadFile`, + verb: 'GET' + } + }); + + Self.downloadFile = async function(ctx, id) { + const models = Self.app.models; + const EntryContainer = models.EntryContainer; + const dms = await models.Dms.findById(id); + const pathHash = EntryContainer.getHash(dms.id); + try { + await EntryContainer.getFile(pathHash, dms.file); + } catch (e) { + if (e.code != 'ENOENT') + throw e; + + const error = new UserError(`File doesn't exists`); + error.statusCode = 404; + + throw error; + } + + const stream = EntryContainer.downloadStream(pathHash, dms.file); + + return [stream, dms.contentType, `filename="${dms.file}"`]; + }; +}; diff --git a/modules/entry/back/methods/entry-dms/removeFile.js b/modules/entry/back/methods/entry-dms/removeFile.js new file mode 100644 index 000000000..89a87755c --- /dev/null +++ b/modules/entry/back/methods/entry-dms/removeFile.js @@ -0,0 +1,53 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('removeFile', { + description: 'Removes a entry document', + accessType: 'WRITE', + accepts: { + arg: 'id', + type: 'number', + description: 'The document id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/removeFile`, + verb: 'POST' + } + }); + + Self.removeFile = async(ctx, id, options) => { + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const targetEntryDms = await Self.findById(id, null, myOptions); + const targetDms = await Self.app.models.Dms.removeFile(ctx, targetEntryDms.dmsFk, myOptions); + + if (!targetDms) + throw new UserError('Try again'); + + const entryDmsDestroyed = await targetEntryDms.destroy(myOptions); + + if (tx) await tx.commit(); + + return entryDmsDestroyed; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; + diff --git a/modules/entry/back/methods/entry-dms/uploadFile.js b/modules/entry/back/methods/entry-dms/uploadFile.js new file mode 100644 index 000000000..54b56fed4 --- /dev/null +++ b/modules/entry/back/methods/entry-dms/uploadFile.js @@ -0,0 +1,86 @@ + +module.exports = Self => { + Self.remoteMethodCtx('uploadFile', { + description: 'Upload and attach a file', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + description: 'The entry id', + http: {source: 'path'} + }, + { + arg: 'warehouseId', + type: 'number', + description: 'The warehouse id', + required: true + }, + { + arg: 'companyId', + type: 'number', + description: 'The company id', + required: true + }, + { + arg: 'dmsTypeId', + type: 'number', + description: 'The dms type id', + required: true + }, + { + arg: 'reference', + type: 'string', + required: true + }, + { + arg: 'description', + type: 'string', + required: true + }, + { + arg: 'hasFile', + type: 'boolean', + description: 'True if has an attached file', + required: true + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/uploadFile`, + verb: 'POST' + } + }); + + Self.uploadFile = async(ctx, id, options) => { + const {Dms, EntryDms} = 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 uploadedFiles = await Dms.uploadFile(ctx, myOptions); + + const promises = uploadedFiles.map(dms => EntryDms.create({ + entryFk: id, + dmsFk: dms.id + }, myOptions)); + await Promise.all(promises); + + if (tx) await tx.commit(); + + return uploadedFiles; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index ca4472c8c..7b6e23685 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -2,6 +2,12 @@ "Entry": { "dataSource": "vn" }, + "EntryDms": { + "dataSource": "vn" + }, + "EntryContainer": { + "dataSource": "entryStorage" + }, "Buy": { "dataSource": "vn" }, diff --git a/modules/entry/back/models/entry-container.json b/modules/entry/back/models/entry-container.json new file mode 100644 index 000000000..a60c272fa --- /dev/null +++ b/modules/entry/back/models/entry-container.json @@ -0,0 +1,10 @@ +{ + "name": "EntryContainer", + "base": "Container", + "acls": [{ + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + }] +} diff --git a/modules/entry/back/models/entry-dms.js b/modules/entry/back/models/entry-dms.js new file mode 100644 index 000000000..219f4fcf5 --- /dev/null +++ b/modules/entry/back/models/entry-dms.js @@ -0,0 +1,13 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + require('../methods/entry-dms/removeFile')(Self); + require('../methods/entry-dms/downloadFile')(Self); + require('../methods/entry-dms/uploadFile')(Self); + + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError('This document already exists on this entry'); + return err; + }); +}; diff --git a/modules/entry/back/models/entry-dms.json b/modules/entry/back/models/entry-dms.json new file mode 100644 index 000000000..eb8300e83 --- /dev/null +++ b/modules/entry/back/models/entry-dms.json @@ -0,0 +1,36 @@ +{ + "name": "EntryDms", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "entryDms" + } + }, + "allowedContentTypes": [ + "image/png", + "image/jpeg", + "image/jpg" + ], + "properties": { + "dmsFk": { + "type": "number", + "id": true, + "required": true + } + }, + "relations": { + "entry": { + "type": "belongsTo", + "model": "Entry", + "foreignKey": "entryFk" + }, + "dms": { + "type": "belongsTo", + "model": "Dms", + "foreignKey": "dmsFk" + } + } +} diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js index dc9496b4a..66440616c 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js @@ -46,23 +46,19 @@ module.exports = Self => { const stmts = []; let stmt; - stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.ticket`); - stmts.push(new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.ticket + `CREATE OR REPLACE TEMPORARY TABLE tmp.ticket (KEY (ticketFk)) ENGINE = MEMORY SELECT id ticketFk FROM ticket t - WHERE shipped BETWEEN ? AND ? + WHERE shipped BETWEEN ? AND util.dayEnd(?) AND refFk IS NULL`, [args.from, args.to])); stmts.push(`CALL vn.ticket_getTax(NULL)`); - stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.filter`); stmts.push(new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.filter + `CREATE OR REPLACE TEMPORARY TABLE tmp.filter ENGINE = MEMORY - SELECT - co.code company, + SELECT co.code company, cou.country, c.id clientId, c.socialName clientSocialName, @@ -75,28 +71,26 @@ module.exports = Self => { c.isTaxDataChecked, w.id comercialId, CONCAT(w.firstName, ' ', w.lastName) comercialName - FROM vn.ticket t - JOIN vn.company co ON co.id = t.companyFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.country cou ON cou.id = c.countryFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - JOIN account.user u ON u.id = w.id - LEFT JOIN ( - SELECT ticketFk, taxableBase - FROM tmp.ticketAmount - GROUP BY ticketFk - HAVING taxableBase < 0 - ) negativeBase ON negativeBase.ticketFk = t.id - WHERE t.shipped BETWEEN ? AND ? - AND t.refFk IS NULL - AND c.typeFk IN ('normal','trust') - GROUP BY t.clientFk, negativeBase.taxableBase - HAVING amount < 0`, [args.from, args.to])); + FROM vn.ticket t + JOIN vn.company co ON co.id = t.companyFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.country cou ON cou.id = c.countryFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + JOIN account.user u ON u.id = w.id + LEFT JOIN ( + SELECT ticketFk, taxableBase + FROM tmp.ticketAmount + GROUP BY ticketFk + HAVING taxableBase < 0 + ) negativeBase ON negativeBase.ticketFk = t.id + WHERE t.shipped BETWEEN ? AND util.dayEnd(?) + AND t.refFk IS NULL + AND c.typeFk IN ('normal','trust') + GROUP BY t.clientFk, negativeBase.taxableBase + HAVING amount < 0`, [args.from, args.to])); - stmt = new ParameterizedSQL(` - SELECT f.* - FROM tmp.filter f`); + stmt = new ParameterizedSQL(`SELECT * FROM tmp.filter`); if (args.filter) { stmt.merge(conn.makeWhere(args.filter.where)); diff --git a/modules/item/back/methods/item-shelving/specs/addListByItem.spec.js b/modules/item/back/methods/item-shelving/specs/addListByItem.spec.js new file mode 100644 index 000000000..e31ff2e61 --- /dev/null +++ b/modules/item/back/methods/item-shelving/specs/addListByItem.spec.js @@ -0,0 +1,55 @@ +const {models} = require('vn-loopback/server/server'); +const LoopBackContext = require('loopback-context'); + +describe('ItemShelving upsertItem()', () => { + const warehouseFk = 1; + let ctx; + let options; + let tx; + + beforeEach(async() => { + ctx = { + req: { + accessToken: {userId: 9}, + headers: {origin: 'http://localhost'} + }, + args: {} + }; + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: ctx.req + }); + + options = {transaction: tx}; + tx = await models.ItemShelving.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should add two new records', async() => { + const shelvingFk = 'ZPP'; + const items = [1, 1, 1, 2]; + + await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options); + const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options); + + expect(itemShelvings.length).toEqual(2); + }); + + it('should update the visible items', async() => { + const shelvingFk = 'GVC'; + const items = [2, 2]; + const {visible: itemsBefore} = await models.ItemShelving.findOne({ + where: {shelvingFk, itemFk: items[0]} + }, options); + await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options); + const {visible: itemsAfter} = await models.ItemShelving.findOne({ + where: {shelvingFk, itemFk: items[0]} + }, options); + + expect(itemsAfter).toEqual(itemsBefore + 2); + }); +}); diff --git a/modules/item/back/methods/item-shelving/upsertItem.js b/modules/item/back/methods/item-shelving/upsertItem.js new file mode 100644 index 000000000..49c2f1b0d --- /dev/null +++ b/modules/item/back/methods/item-shelving/upsertItem.js @@ -0,0 +1,64 @@ +module.exports = Self => { + Self.remoteMethodCtx('upsertItem', { + description: 'Add a record or update it if it already exists.', + accessType: 'WRITE', + accepts: [{ + arg: 'shelvingFk', + type: 'string', + required: true, + }, + { + arg: 'items', + type: ['number'], + required: true, + description: 'array of item foreign keys' + }, + { + arg: 'warehouseFk', + type: 'number', + required: true + }], + + http: { + path: `/upsertItem`, + verb: 'POST' + } + }); + + Self.upsertItem = async(ctx, shelvingFk, items, warehouseFk, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + const discardItems = new Set(); + const itemCounts = items.reduce((acc, item) => { + acc[item] = (acc[item] || 0) + 1; + return acc; + }, {}); + + try { + for (let item of items) { + if (!discardItems.has(item)) { + let quantity = itemCounts[item]; + discardItems.add(item); + + await Self.rawSql('CALL vn.itemShelving_add(?, ?, ?, NULL, NULL, NULL, ?)', + [shelvingFk, item, quantity, warehouseFk], myOptions + ); + } + } + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index 98ff18931..c031d8271 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -1,4 +1,5 @@ module.exports = Self => { require('../methods/item-shelving/deleteItemShelvings')(Self); + require('../methods/item-shelving/upsertItem')(Self); require('../methods/item-shelving/getInventory')(Self); }; diff --git a/modules/order/back/methods/order/isEditable.js b/modules/order/back/methods/order/isEditable.js index 4ef76c11f..3fd2f993c 100644 --- a/modules/order/back/methods/order/isEditable.js +++ b/modules/order/back/methods/order/isEditable.js @@ -29,17 +29,11 @@ module.exports = Self => { where: {id: orderId}, fields: ['isConfirmed', 'clientFk'], include: [ - {relation: 'client', - scope: { - include: { - relation: 'type' - } - } - } + {relation: 'client'} ] }, myOptions); - if (exists && exists.client().type().code !== 'normal') + if (exists && exists.client().typeFk !== 'normal') return true; if (!exists || exists.isConfirmed === 1) diff --git a/modules/order/back/methods/order/new.js b/modules/order/back/methods/order/new.js index d65b18e12..2aad27c9a 100644 --- a/modules/order/back/methods/order/new.js +++ b/modules/order/back/methods/order/new.js @@ -49,17 +49,12 @@ module.exports = Self => { where: {id: addressId}, fields: ['clientFk'], include: [ - {relation: 'client', - scope: { - include: { - relation: 'type' - } - } + {relation: 'client' } ] }, myOptions); - if (address.client().type().code === 'normal') { + if (address.client().typeFk === 'normal') { if (!address.client().isActive) throw new UserError(`You can't create an order for an inactive client`); } diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index 0e7fa0e34..2b36de5e2 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -26,7 +26,8 @@ describe('Supplier newSupplier()', () => { const options = {transaction: tx}; ctx.args = { name: 'NEWSUPPLIER', - nif: '12345678Z' + nif: '12345678Z', + city: 'Gotham' }; const result = await models.Supplier.newSupplier(ctx, options); diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js index c0b860983..f2cdd63be 100644 --- a/modules/supplier/back/methods/supplier/updateFiscalData.js +++ b/modules/supplier/back/methods/supplier/updateFiscalData.js @@ -19,7 +19,7 @@ module.exports = Self => { type: 'any' }, { arg: 'phone', - type: 'string' + type: 'any' }, { arg: 'sageTaxTypeFk', type: 'any' @@ -46,10 +46,10 @@ module.exports = Self => { type: 'any' }, { arg: 'supplierActivityFk', - type: 'string' + type: 'any' }, { arg: 'healthRegister', - type: 'string' + type: 'any' }, { arg: 'isVies', type: 'boolean' diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 3f40ce58b..05d78240d 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -129,10 +129,13 @@ describe('loopback model Supplier', () => { const options = {transaction: tx}; try { - const newSupplier = await models.Supplier.create({name: 'ALFRED PENNYWORTH'}, options); - const fetchedSupplier = await models.Supplier.findById(newSupplier.id, null, options); + const newSupplier = { + name: 'ALFRED PENNYWORTH', nif: '87805752D', city: 'Gotham' + }; + const supplierCreated = await models.Supplier.create(newSupplier, options); + const fetchedSupplier = await models.Supplier.findById(supplierCreated.id, null, options); - expect(Number(fetchedSupplier.account)).toEqual(4100000000 + newSupplier.id); + expect(Number(fetchedSupplier.account)).toEqual(4100000000 + supplierCreated.id); await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 0ac389074..2d3ffef3e 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -17,17 +17,13 @@ module.exports = Self => { message: 'The social name cannot be empty' }); - if (this.city) { - Self.validatesPresenceOf('city', { - message: 'City cannot be empty' - }); - } + Self.validatesPresenceOf('city', { + message: 'City cannot be empty' + }); - if (this.nif) { - Self.validatesPresenceOf('nif', { - message: 'The nif cannot be empty' - }); - } + Self.validatesPresenceOf('nif', { + message: 'The nif cannot be empty' + }); Self.validatesUniquenessOf('nif', { message: 'TIN must be unique' diff --git a/modules/ticket/back/methods/ticket/isEditableOrThrow.js b/modules/ticket/back/methods/ticket/isEditableOrThrow.js index 41438be3a..16cff84f1 100644 --- a/modules/ticket/back/methods/ticket/isEditableOrThrow.js +++ b/modules/ticket/back/methods/ticket/isEditableOrThrow.js @@ -17,21 +17,16 @@ module.exports = Self => { const alertLevel = state ? state.alertLevel : null; const ticket = await models.Ticket.findById(id, { fields: ['clientFk'], - include: [{ - relation: 'client', - scope: { - include: { - relation: 'type' - } - } - }] + include: { + relation: 'client' + } }, myOptions); const isLocked = await models.Ticket.isLocked(id, myOptions); const isWeekly = await models.TicketWeekly.findOne({where: {ticketFk: id}}, myOptions); const alertLevelGreaterThanZero = (alertLevel && alertLevel > 0); - const isNormalClient = ticket && ticket.client().type().code == 'normal'; + const isNormalClient = ticket && ticket.client().typeFk == 'normal'; const isEditable = !(alertLevelGreaterThanZero && isNormalClient); if (!ticket) diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index 288d38d77..8c27101ef 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -77,12 +77,7 @@ module.exports = Self => { where: {id: args.addressId}, fields: ['id', 'clientFk'], include: { - relation: 'client', - scope: { - include: { - relation: 'type' - } - } + relation: 'client' } }, myOptions); @@ -93,7 +88,7 @@ module.exports = Self => { if (args.agencyModeId) agencyMode = await models.AgencyMode.findById(args.agencyModeId, null, myOptions); - if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) { + if (address.client().typeFk === 'normal' && (!agencyMode || agencyMode.code != 'refund')) { const canCreateTicket = await models.Client.canCreateTicket(args.clientId, myOptions); if (!canCreateTicket) throw new UserError(`You can't create a ticket for an inactive client`); diff --git a/modules/ticket/back/methods/ticket/specs/transferClient.spec.js b/modules/ticket/back/methods/ticket/specs/transferClient.spec.js index 5a9edd17e..5f1c09776 100644 --- a/modules/ticket/back/methods/ticket/specs/transferClient.spec.js +++ b/modules/ticket/back/methods/ticket/specs/transferClient.spec.js @@ -1,49 +1,60 @@ const models = require('vn-loopback/server/server').models; describe('Ticket transferClient()', () => { - const userId = 9; - const activeCtx = { - accessToken: {userId: userId}, - }; - const ctx = {req: activeCtx}; + const originalTicketId = 8; + const refundTicketId = 24; + const clientId = 1; + let ctx; + let options; + let tx; + beforeEach(async() => { + ctx = { + req: { + accessToken: {userId: 9}, + headers: {origin: 'http://localhost'} + }, + args: {} + }; + + options = {transaction: tx}; + tx = await models.Ticket.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); it('should throw an error as the ticket is not editable', async() => { - const tx = await models.Ticket.beginTransaction({}); - let error; - try { - const options = {transaction: tx}; const ticketId = 4; const clientId = 1; await models.Ticket.transferClient(ctx, ticketId, clientId, options); - - await tx.rollback(); } catch (e) { - await tx.rollback(); - error = e; + expect(e.message).toEqual(`This ticket is locked`); } - - expect(error.message).toEqual(`This ticket is locked`); }); - it('should be assigned a different clientFk', async() => { - const tx = await models.Ticket.beginTransaction({}); - let updatedTicket; - const ticketId = 10; - const clientId = 1; + it('should be assigned a different clientFk in the original ticket', async() => { + await models.Ticket.transferClient(ctx, 2, clientId, options); + const afterTransfer = await models.Ticket.findById(2, null, options); - try { - const options = {transaction: tx}; + expect(afterTransfer.clientFk).toEqual(clientId); + }); - await models.Ticket.transferClient(ctx, ticketId, clientId, options); - updatedTicket = await models.Ticket.findById(ticketId, {fields: ['clientFk']}, options); + it('should be assigned a different clientFk in the original and refund ticket and claim', async() => { + await models.Ticket.transferClient(ctx, originalTicketId, clientId, options); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + const [originalTicket, refundTicket] = await models.Ticket.find({ + where: {id: {inq: [originalTicketId, refundTicketId]}} + }, options); - expect(updatedTicket.clientFk).toEqual(clientId); + const claim = await models.Claim.findOne({ + where: {ticketFk: originalTicketId} + }, options); + + expect(originalTicket.clientFk).toEqual(clientId); + expect(refundTicket.clientFk).toEqual(clientId); + expect(claim.clientFk).toEqual(clientId); }); }); diff --git a/modules/ticket/back/methods/ticket/transferClient.js b/modules/ticket/back/methods/ticket/transferClient.js index 60e70d710..d38c0e8a7 100644 --- a/modules/ticket/back/methods/ticket/transferClient.js +++ b/modules/ticket/back/methods/ticket/transferClient.js @@ -2,20 +2,17 @@ module.exports = Self => { Self.remoteMethodCtx('transferClient', { description: 'Transfering ticket to another client', accessType: 'WRITE', - accepts: [ - { - arg: 'id', - type: 'number', - required: true, - description: 'the ticket id', - http: {source: 'path'} - }, - { - arg: 'clientFk', - type: 'number', - required: true, - }, - ], + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'the ticket id', + http: {source: 'path'} + }, { + arg: 'clientFk', + type: 'number', + required: true, + }], http: { path: `/:id/transferClient`, verb: 'PATCH' @@ -25,21 +22,51 @@ module.exports = Self => { Self.transferClient = async(ctx, id, clientFk, options) => { const models = Self.app.models; const myOptions = {}; + let tx; + if (typeof options == 'object') Object.assign(myOptions, options); - await Self.isEditableOrThrow(ctx, id, myOptions); + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } - const ticket = await models.Ticket.findById( - id, - {fields: ['id', 'shipped', 'clientFk', 'addressFk']}, - myOptions - ); - const client = await models.Client.findById(clientFk, {fields: ['id', 'defaultAddressFk']}, myOptions); + try { + await Self.isEditableOrThrow(ctx, id, myOptions); - await ticket.updateAttributes({ - clientFk, - addressFk: client.defaultAddressFk, - }); + const ticketRefund = await models.TicketRefund.findOne({ + where: {or: [{originalTicketFk: id}, {refundTicketFk: id}]}, + include: [{relation: 'refundTicket'}, {relation: 'originalTicket'}] + }, myOptions); + + const {defaultAddressFk: addressFk} = await models.Client.findById(clientFk, + {fields: ['id', 'defaultAddressFk']}, myOptions); + + const attributes = {clientFk, addressFk}; + + const tickets = []; + const ticketIds = []; + + if (ticketRefund) { + const {refundTicket, originalTicket} = ticketRefund; + tickets.push(refundTicket(), originalTicket()); + + for (const ticket of tickets) { + await ticket.updateAttributes(attributes, myOptions); + ticketIds.push(ticket.id); + } + } else { + await Self.updateAll({id}, attributes, myOptions); + ticketIds.push(id); + } + + await models.Claim.updateAll({ticketFk: {inq: ticketIds}}, {clientFk}, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } }; }; diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 30fb74b75..22ad40184 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -41,7 +41,7 @@ module.exports = Self => { include: { relation: 'client', scope: { - fields: ['id', 'clientTypeFk'], + fields: ['id', 'typeFk'], include: { relation: 'type', scope: { @@ -52,7 +52,7 @@ module.exports = Self => { } }, ctx.options); - if (ticket?.client()?.type()?.code === 'loses') return; + if (ticket?.client()?.typeFk === 'loses') return; const isRefund = await models.TicketRefund.findOne({ fields: ['id'], diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index d0830b00f..d3e9cb9d0 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -36,6 +36,7 @@ describe('Worker new', () => { payMethodFk: 1, roleFk: 1 }; + const req = {accessToken: {userId: 9}}; it('should return error if personal mail already exists', async() => { @@ -138,17 +139,29 @@ describe('Worker new', () => { }); it('should create a new worker', async() => { - const newWorker = await models.Worker.new({args: defaultWorker, req}); - - await models.Worker.destroyById(newWorker.id); - await models.Address.destroyAll({clientFk: newWorker.id}); - await models.Mandate.destroyAll({clientFk: newWorker.id}); - await models.Client.destroyById(newWorker.id); - await models.VnUser.destroyById(newWorker.id); + let newWorker; + try { + newWorker = await models.Worker.new({args: defaultWorker, req}); + } finally { + await removeWorker(newWorker.id); + } expect(newWorker.id).toBeDefined(); }); + it('should create a new client', async() => { + let newWorker; + let client; + try { + newWorker = await models.Worker.new({args: defaultWorker, req}); + client = await models.Client.findById(newWorker.id); + } finally { + await removeWorker(newWorker.id); + } + + expect(client).toBeDefined(); + }); + it('should create a new worker in client', async() => { const bruceWayneId = 1101; const client = await models.Client.findById(bruceWayneId, {fields: ['fi', 'email']}); @@ -163,10 +176,21 @@ describe('Worker new', () => { }), req }; - const newWorker = await models.Worker.new(newWorkerData); - - await models.Worker.destroyById(newWorker.id); + let newWorker; + try { + newWorker = await models.Worker.new(newWorkerData); + } finally { + await models.Worker.destroyById(newWorker.id); + } expect(newWorker.id).toEqual(bruceWayneId); }); }); + +async function removeWorker(id) { + await models.Worker.destroyById(id); + await models.Address.destroyAll({clientFk: id}); + await models.Mandate.destroyAll({clientFk: id}); + await models.Client.destroyById(id); + await models.VnUser.destroyById(id); +} diff --git a/myt.config.yml b/myt.config.yml index 2e37a0d97..0b1d62d25 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -44,7 +44,6 @@ fixtures: - module - defaultViewConfig vn: - - agencyTermConfig - alertLevel - bookingPlanner - businessType diff --git a/package.json b/package.json index d7dea767e..6956cabeb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.8.0", + "version": "24.10.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", @@ -42,7 +42,7 @@ "mysql": "2.18.1", "node-ssh": "^11.0.0", "object.pick": "^1.3.0", - "puppeteer": "^21.11.0", + "puppeteer": "21.11.0", "read-chunk": "^3.2.0", "require-yaml": "0.0.1", "smbhash": "0.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 36bff2fe1..b1f68378d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -93,7 +93,7 @@ dependencies: specifier: ^1.3.0 version: 1.3.0 puppeteer: - specifier: ^21.11.0 + specifier: 21.11.0 version: 21.11.0 read-chunk: specifier: ^3.2.0 @@ -3786,7 +3786,7 @@ packages: resolution: {integrity: sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==} dependencies: base64-js: 1.5.1 - ieee754: 1.1.13 + ieee754: 1.2.1 isarray: 1.0.0 dev: false @@ -7288,8 +7288,8 @@ packages: - supports-color dev: true - /http-proxy-agent@7.0.0: - resolution: {integrity: sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==} + /http-proxy-agent@7.0.2: + resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==} engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 @@ -7367,8 +7367,8 @@ packages: transitivePeerDependencies: - supports-color - /https-proxy-agent@7.0.2: - resolution: {integrity: sha512-NmLNjm6ucYwtcUmL7JQC1ZQ57LmHP4lT15FQ8D61nak1rO6DH+fz5qNK2Ap5UN4ZapYICE3/0KodcLYSPsPbaA==} + /https-proxy-agent@7.0.4: + resolution: {integrity: sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==} engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 @@ -9780,6 +9780,7 @@ packages: /mkdirp-classic@0.5.3: resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + requiresBuild: true dev: false /mkdirp@0.3.0: @@ -10692,8 +10693,8 @@ packages: agent-base: 7.1.0 debug: 4.3.4(supports-color@6.1.0) get-uri: 6.0.2 - http-proxy-agent: 7.0.0 - https-proxy-agent: 7.0.2 + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.4 pac-resolver: 7.0.0 socks-proxy-agent: 8.0.2 transitivePeerDependencies: @@ -11155,8 +11156,8 @@ packages: dependencies: agent-base: 7.1.0 debug: 4.3.4(supports-color@6.1.0) - http-proxy-agent: 7.0.0 - https-proxy-agent: 7.0.2 + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.4 lru-cache: 7.18.3 pac-proxy-agent: 7.0.1 proxy-from-env: 1.1.0 @@ -11288,6 +11289,7 @@ packages: /queue-tick@1.0.1: resolution: {integrity: sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==} + requiresBuild: true dev: false /quick-lru@4.0.1: diff --git a/print/package.json b/print/package.json index 2adb7f1e0..ea0e37f99 100755 --- a/print/package.json +++ b/print/package.json @@ -1,34 +1,34 @@ { - "name": "vn-print", - "version": "2.0.0", - "description": "Print service", - "scripts": { - "start": "node server/server.js", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "https://git.verdnatura.es/salix" - }, - "license": "GPL-3.0", - "packageManager": "pnpm@8.15.1", - "dependencies": { - "express": "4.14.0", - "fs-extra": "^7.0.1", - "intl": "^1.2.5", - "js-yaml": "^3.13.1", - "jsbarcode": "^3.11.5", - "juice": "^5.2.0", - "log4js": "^6.7.0", - "mysql2": "^1.7.0", - "nodemailer": "^4.7.0", - "puppeteer": "^22.4.0", - "puppeteer-cluster": "^0.23.0", - "qrcode": "^1.4.2", - "strftime": "^0.10.0", - "vue": "^2.6.10", - "vue-i18n": "^8.15.0", - "vue-server-renderer": "^2.6.10", - "xmldom": "^0.6.0" - } + "name": "vn-print", + "version": "2.0.0", + "description": "Print service", + "scripts": { + "start": "node server/server.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://git.verdnatura.es/salix" + }, + "license": "GPL-3.0", + "packageManager": "pnpm@8.15.1", + "dependencies": { + "express": "4.14.0", + "fs-extra": "^7.0.1", + "intl": "^1.2.5", + "js-yaml": "^3.13.1", + "jsbarcode": "^3.11.5", + "juice": "^5.2.0", + "log4js": "^6.7.0", + "mysql2": "^1.7.0", + "nodemailer": "^4.7.0", + "puppeteer": "21.11.0", + "puppeteer-cluster": "0.23.0", + "qrcode": "^1.4.2", + "strftime": "^0.10.0", + "vue": "^2.6.10", + "vue-i18n": "^8.15.0", + "vue-server-renderer": "^2.6.10", + "xmldom": "^0.6.0" + } } diff --git a/print/pnpm-lock.yaml b/print/pnpm-lock.yaml index 185dd89de..13b2fe827 100644 --- a/print/pnpm-lock.yaml +++ b/print/pnpm-lock.yaml @@ -33,11 +33,11 @@ dependencies: specifier: ^4.7.0 version: 4.7.0 puppeteer: - specifier: ^22.4.0 - version: 22.4.0 + specifier: 21.11.0 + version: 21.11.0 puppeteer-cluster: - specifier: ^0.23.0 - version: 0.23.0(puppeteer@22.4.0) + specifier: 0.23.0 + version: 0.23.0(puppeteer@21.11.0) qrcode: specifier: ^1.4.2 version: 1.5.3 @@ -103,17 +103,16 @@ packages: to-fast-properties: 2.0.0 dev: false - /@puppeteer/browsers@2.1.0: - resolution: {integrity: sha512-xloWvocjvryHdUjDam/ZuGMh7zn4Sn3ZAaV4Ah2e2EwEt90N3XphZlSsU3n0VDc1F7kggCjMuH0UuxfPQ5mD9w==} - engines: {node: '>=18'} + /@puppeteer/browsers@1.9.1: + resolution: {integrity: sha512-PuvK6xZzGhKPvlx3fpfdM2kYY3P/hB1URtK8wA7XUJ6prn6pp22zvJHu48th0SGcHL9SutbPHrFuQgfXTFobWA==} + engines: {node: '>=16.3.0'} hasBin: true dependencies: debug: 4.3.4 extract-zip: 2.0.1 progress: 2.0.3 - proxy-agent: 6.4.0 - semver: 7.6.0 - tar-fs: 3.0.5 + proxy-agent: 6.3.1 + tar-fs: 3.0.4 unbzip2-stream: 1.4.3 yargs: 17.7.2 transitivePeerDependencies: @@ -247,37 +246,6 @@ packages: resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==} dev: false - /bare-events@2.2.1: - resolution: {integrity: sha512-9GYPpsPFvrWBkelIhOhTWtkeZxVxZOdb3VnFTCzlOo3OjvmTvzLoZFUT8kNFACx0vJej6QPney1Cf9BvzCNE/A==} - requiresBuild: true - dev: false - optional: true - - /bare-fs@2.2.1: - resolution: {integrity: sha512-+CjmZANQDFZWy4PGbVdmALIwmt33aJg8qTkVjClU6X4WmZkTPBDxRHiBn7fpqEWEfF3AC2io++erpViAIQbSjg==} - requiresBuild: true - dependencies: - bare-events: 2.2.1 - bare-os: 2.2.0 - bare-path: 2.1.0 - streamx: 2.15.6 - dev: false - optional: true - - /bare-os@2.2.0: - resolution: {integrity: sha512-hD0rOPfYWOMpVirTACt4/nK8mC55La12K5fY1ij8HAdfQakD62M+H4o4tpfKzVGLgRDTuk3vjA4GqGXXCeFbag==} - requiresBuild: true - dev: false - optional: true - - /bare-path@2.1.0: - resolution: {integrity: sha512-DIIg7ts8bdRKwJRJrUMy/PICEaQZaPGZ26lsSx9MJSwIhSrcdHn7/C8W+XmnG/rKi6BaRcz+JO00CjZteybDtw==} - requiresBuild: true - dependencies: - bare-os: 2.2.0 - dev: false - optional: true - /base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} dev: false @@ -361,12 +329,12 @@ packages: lodash.some: 4.6.0 dev: false - /chromium-bidi@0.5.12(devtools-protocol@0.0.1249869): - resolution: {integrity: sha512-sZMgEBWKbupD0Q7lyFu8AWkrE+rs5ycE12jFkGwIgD/VS8lDPtelPlXM7LYaq4zrkZ/O2L3f4afHUHL0ICdKog==} + /chromium-bidi@0.5.8(devtools-protocol@0.0.1232444): + resolution: {integrity: sha512-blqh+1cEQbHBKmok3rVJkBlBxt9beKBgOsxbFgs7UJcoVbbeZ+K7+6liAsjgpc8l1Xd55cQUy14fXZdGSb4zIw==} peerDependencies: devtools-protocol: '*' dependencies: - devtools-protocol: 0.0.1249869 + devtools-protocol: 0.0.1232444 mitt: 3.0.1 urlpattern-polyfill: 10.0.0 dev: false @@ -580,8 +548,8 @@ packages: resolution: {integrity: sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==} dev: false - /devtools-protocol@0.0.1249869: - resolution: {integrity: sha512-Ctp4hInA0BEavlUoRy9mhGq0i+JSo/AwVyX2EFgZmV1kYB+Zq+EMBAn52QWu6FbRr10hRb6pBl420upbp4++vg==} + /devtools-protocol@0.0.1232444: + resolution: {integrity: sha512-pM27vqEfxSxRkTMnF+XCmxSEb6duO5R+t8A9DEEJgy4Wz2RVanje2mmj99B6A3zv2r/qGfYlOvYznUhuokizmg==} dev: false /dijkstrajs@1.0.3: @@ -1293,13 +1261,6 @@ packages: yallist: 3.1.1 dev: false - /lru-cache@6.0.0: - resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} - engines: {node: '>=10'} - dependencies: - yallist: 4.0.0 - dev: false - /lru-cache@7.18.3: resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==} engines: {node: '>=12'} @@ -1350,6 +1311,10 @@ packages: resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} dev: false + /mkdirp-classic@0.5.3: + resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + dev: false + /ms@0.7.1: resolution: {integrity: sha512-lRLiIR9fSNpnP6TC4v8+4OU7oStC01esuNowdQ34L+Gk8e5Puoc88IqJ+XAY/B3Mn2ZKis8l8HX90oU8ivzUHg==} dev: false @@ -1574,8 +1539,8 @@ packages: ipaddr.js: 1.4.0 dev: false - /proxy-agent@6.4.0: - resolution: {integrity: sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==} + /proxy-agent@6.3.1: + resolution: {integrity: sha512-Rb5RVBy1iyqOtNl15Cw/llpeLH8bsb37gM1FUfKQ+Wck6xHlbAhWGUFiTRHtkjqGTA5pSHz6+0hrPW/oECihPQ==} engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 @@ -1610,26 +1575,26 @@ packages: engines: {node: '>=6'} dev: false - /puppeteer-cluster@0.23.0(puppeteer@22.4.0): + /puppeteer-cluster@0.23.0(puppeteer@21.11.0): resolution: {integrity: sha512-108terIWDzPrQopmoYSPd5yDoy3FGJ2dNnoGMkGYPs6xtkdhgaECwpfZkzaRToMQPZibUOz0/dSSGgPEdXEhkQ==} peerDependencies: puppeteer: '>=1.5.0' dependencies: debug: 4.3.4 - puppeteer: 22.4.0 + puppeteer: 21.11.0 transitivePeerDependencies: - supports-color dev: false - /puppeteer-core@22.4.0: - resolution: {integrity: sha512-MZttAbttrxi6O/B//rY6zQihjFe/vXeCLb5YvKH2xG6yrcVESo0Hc5/Cv49omwZyZzAJ1BK8BnDeatDsj+3hMw==} - engines: {node: '>=18'} + /puppeteer-core@21.11.0: + resolution: {integrity: sha512-ArbnyA3U5SGHokEvkfWjW+O8hOxV1RSJxOgriX/3A4xZRqixt9ZFHD0yPgZQF05Qj0oAqi8H/7stDorjoHY90Q==} + engines: {node: '>=16.13.2'} dependencies: - '@puppeteer/browsers': 2.1.0 - chromium-bidi: 0.5.12(devtools-protocol@0.0.1249869) + '@puppeteer/browsers': 1.9.1 + chromium-bidi: 0.5.8(devtools-protocol@0.0.1232444) cross-fetch: 4.0.0 debug: 4.3.4 - devtools-protocol: 0.0.1249869 + devtools-protocol: 0.0.1232444 ws: 8.16.0 transitivePeerDependencies: - bufferutil @@ -1638,15 +1603,15 @@ packages: - utf-8-validate dev: false - /puppeteer@22.4.0: - resolution: {integrity: sha512-tR+JsDbA2qD1DqRX4F9k9SxQhk6UzcaCN+Qux7+WrDceS7wcR7tlFmMNB8+g8zE4Fmr/iRTOtf5wNnTW9cGUFQ==} - engines: {node: '>=18'} + /puppeteer@21.11.0: + resolution: {integrity: sha512-9jTHuYe22TD3sNxy0nEIzC7ZrlRnDgeX3xPkbS7PnbdwYjl2o/z/YuCrRBwezdKpbTDTJ4VqIggzNyeRcKq3cg==} + engines: {node: '>=16.13.2'} hasBin: true requiresBuild: true dependencies: - '@puppeteer/browsers': 2.1.0 + '@puppeteer/browsers': 1.9.1 cosmiconfig: 9.0.0 - puppeteer-core: 22.4.0 + puppeteer-core: 21.11.0 transitivePeerDependencies: - bufferutil - encoding @@ -1768,14 +1733,6 @@ packages: hasBin: true dev: false - /semver@7.6.0: - resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} - engines: {node: '>=10'} - hasBin: true - dependencies: - lru-cache: 6.0.0 - dev: false - /send@0.14.1: resolution: {integrity: sha512-1Ru269QpUVUgD32Y9jdyBXiX+pHYuYnTzR17w+DhyOWvGMPjJILrnLhl9c4LQjtIy2BSAa6Ykq0ZdGcAjaXlwQ==} engines: {node: '>= 0.8.0'} @@ -1997,14 +1954,12 @@ packages: engines: {node: '>= 0.4'} dev: false - /tar-fs@3.0.5: - resolution: {integrity: sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==} + /tar-fs@3.0.4: + resolution: {integrity: sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==} dependencies: + mkdirp-classic: 0.5.3 pump: 3.0.0 tar-stream: 3.1.7 - optionalDependencies: - bare-fs: 2.2.1 - bare-path: 2.1.0 dev: false /tar-stream@3.1.7: @@ -2249,10 +2204,6 @@ packages: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} dev: false - /yallist@4.0.0: - resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} - dev: false - /yargs-parser@18.1.3: resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==} engines: {node: '>=6'} diff --git a/print/templates/reports/invoice/sql/sales.sql b/print/templates/reports/invoice/sql/sales.sql index 3833a3700..8e5ad1102 100644 --- a/print/templates/reports/invoice/sql/sales.sql +++ b/print/templates/reports/invoice/sql/sales.sql @@ -7,7 +7,8 @@ SELECT s.discount, s.itemFk, s.concept, - tc.code vatType + tc.code vatType, + it.isPackaging FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.supplier su ON su.id = io.companyFk @@ -34,9 +35,10 @@ SELECT ts.quantity, ts.price, 0 discount, - '', - ts.description concept, - tc.code vatType + NULL, + ts.description, + tc.code, + NULL FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.ticketService ts ON ts.ticketFk = t.id @@ -46,3 +48,4 @@ SELECT JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk JOIN vn.taxClass tc ON tc.id = ts.taxClassFk WHERE t.refFk = ? +ORDER BY (isPackaging), concept, itemFk