From 91f5ee3b93b755a581b1b46674cca2cc507b059a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 20 Jan 2024 12:29:41 +0100 Subject: [PATCH 01/88] refs #6321 feat: new remoteMethod --- db/dump/fixtures.sql | 3 + .../ticket/back/methods/ticket/itemLack.js | 781 ++++++++++++++++++ modules/ticket/back/models/ticket-methods.js | 1 + 3 files changed, 785 insertions(+) create mode 100644 modules/ticket/back/methods/ticket/itemLack.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index b243692bb2..ba513ee15a 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -3043,3 +3043,6 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (4, 1103, 4, 32), (13, 1101, 1, NULL), (14, 1101, 4, 27); +-- Auto-generated SQL script #202401191358 +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'); diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js new file mode 100644 index 0000000000..35f299e6c1 --- /dev/null +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -0,0 +1,781 @@ +module.exports = Self => { + Self.remoteMethod('itemLack', { + description: 'Download a ticket delivery note document', + accessType: 'READ', + accepts: [ + { + arg: 'filter', + type: 'object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'} + }, + ], + returns: [ + { + arg: 'body', + type: ['object'], + root: true + } + ], + http: { + path: `/itemLack`, + verb: 'GET' + } + }); + + Self.itemLack = async(ctx, filter, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + // let query = 'CALL vn.item_getLack(?, ?)'; + + // const result = await Self.rawSql(query, [true, 2]); + + // if (tx) await tx.commit(); + + return [ + { + 'itemFk': 7176, + 'longName': 'Anthurium Olivius x20', + 'warehouseFk': 60, + 'producer': null, + 'size': null, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -40, + 'inkFk': 'VRD', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 14613, + 'longName': 'Crisantemo Uniflora Anastasia Topsin', + 'warehouseFk': 60, + 'producer': null, + 'size': 70, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -10, + 'inkFk': 'BLN', + 'timed': '2024-01-19T15:20:00.000Z', + 'minTimed': '16:20' + }, + { + 'itemFk': 28619, + 'longName': 'Clavel Mix Fancy', + 'warehouseFk': 60, + 'producer': 'Benchmark', + 'size': 60, + 'category': 'Fan', + 'warehouse': 'Algemesi', + 'lack': -700, + 'inkFk': 'MIX', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 29422, + 'longName': 'Lisianthus Doble Green', + 'warehouseFk': 60, + 'producer': 'L.I.S.', + 'size': 65, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -10, + 'inkFk': 'VRC', + 'timed': '2024-01-19T16:00:00.000Z', + 'minTimed': '17:00' + }, + { + 'itemFk': 29590, + 'longName': 'Schlumbergera (3 Colors)', + 'warehouseFk': 60, + 'producer': 'Gartneriet Thoruplund', + 'size': 18, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -18, + 'inkFk': 'MIX', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 33636, + 'longName': 'Antirrinum Lavander', + 'warehouseFk': 60, + 'producer': null, + 'size': 80, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -10, + 'inkFk': 'LAV', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 36864, + 'longName': 'Kattegrass (Comida para gatos)', + 'warehouseFk': 60, + 'producer': 'Willem Jongenotter Kw.', + 'size': 10, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -10, + 'inkFk': 'VRD', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 38631, + 'longName': 'Triple Accion Listo Uso', + 'warehouseFk': 60, + 'producer': 'Flower', + 'size': null, + 'category': 'ml', + 'warehouse': 'Algemesi', + 'lack': -24, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 53233, + 'longName': 'Clavel Cheerio Fancy', + 'warehouseFk': 60, + 'producer': 'Benchmark', + 'size': 60, + 'category': 'Fan', + 'warehouse': 'Algemesi', + 'lack': -50, + 'inkFk': 'R\/B', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 60525, + 'longName': 'Rosa Explorer Extra', + 'warehouseFk': 60, + 'producer': 'Floraroma', + 'size': 60, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -500, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 68998, + 'longName': 'Clavel Hot Pink Select', + 'warehouseFk': 60, + 'producer': 'Funza', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -25, + 'inkFk': 'FUC', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 77807, + 'longName': 'Hydrangea Mix 4Flo', + 'warehouseFk': 60, + 'producer': 'Schroll-Flowers', + 'size': 35, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -6, + 'inkFk': 'MIX', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 84883, + 'longName': 'Rosa Freedom Standard', + 'warehouseFk': 60, + 'producer': 'El Milagro', + 'size': 40, + 'category': 'Sta', + 'warehouse': 'Algemesi', + 'lack': -600, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 92466, + 'longName': 'Clavel Kino Select', + 'warehouseFk': 60, + 'producer': 'Funza', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -25, + 'inkFk': 'P\/B', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 93355, + 'longName': 'Clavel Caramel Fancy', + 'warehouseFk': 60, + 'producer': 'Funza', + 'size': 60, + 'category': 'Fan', + 'warehouse': 'Algemesi', + 'lack': -50, + 'inkFk': 'TRR', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 95068, + 'longName': 'Alstroemeria Fifi Plus', + 'warehouseFk': 60, + 'producer': 'Funza', + 'size': 80, + 'category': 'Plu', + 'warehouse': 'Algemesi', + 'lack': -30, + 'inkFk': 'SWE', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 107891, + 'longName': 'Rosa Freedom Select', + 'warehouseFk': 60, + 'producer': 'Excellence', + 'size': 40, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -1000, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 113163, + 'longName': 'Lilium Oriental Roselily Aisha 2', + 'warehouseFk': 60, + 'producer': 'Moerman Lilium BV', + 'size': 65, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -10, + 'inkFk': 'BLN', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 117832, + 'longName': 'Rosa Freedom Standard', + 'warehouseFk': 60, + 'producer': 'Multiflora', + 'size': 50, + 'category': 'Sta', + 'warehouse': 'Algemesi', + 'lack': -200, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 123005, + 'longName': 'Rosa Orange Crush Extra', + 'warehouseFk': 60, + 'producer': 'Trebol', + 'size': 50, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -125, + 'inkFk': 'NAR', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 123380, + 'longName': 'Clavel Hypnosis Standard', + 'warehouseFk': 60, + 'producer': 'GEOFLORA', + 'size': 50, + 'category': 'Sta', + 'warehouse': 'Algemesi', + 'lack': -25, + 'inkFk': 'LAV', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 124948, + 'longName': 'Cymbidium Mon Amour', + 'warehouseFk': 60, + 'producer': 'New Orchids', + 'size': 60, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -1, + 'inkFk': 'BLN', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 125062, + 'longName': 'Hoya Kerri Cerámica', + 'warehouseFk': 60, + 'producer': 'Gartneriet Lundager', + 'size': 15, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -18, + 'inkFk': 'VRD', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 125593, + 'longName': 'Hoya Kerri Cerámica Roja', + 'warehouseFk': 60, + 'producer': 'v.d. Arend Tropical', + 'size': 12, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -1, + 'inkFk': 'VRD', + 'timed': '2024-01-19T15:20:00.000Z', + 'minTimed': '16:20' + }, + { + 'itemFk': 126428, + 'longName': 'Rosa Freedom Extra', + 'warehouseFk': 60, + 'producer': 'Matina', + 'size': 50, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -25, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 128417, + 'longName': 'Rosa Brighton Select', + 'warehouseFk': 60, + 'producer': 'Excellence', + 'size': 50, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -75, + 'inkFk': 'AMA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 132651, + 'longName': 'Rosa Freedom Select', + 'warehouseFk': 60, + 'producer': 'Excellence', + 'size': 60, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -1250, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 135194, + 'longName': 'Eucalipto Torreliana Small', + 'warehouseFk': 60, + 'producer': null, + 'size': 40, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -20, + 'inkFk': 'M\/V', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 135516, + 'longName': 'Hydrangea Curaçao Petite', + 'warehouseFk': 60, + 'producer': 'Flores del Este', + 'size': 60, + 'category': 'Pet', + 'warehouse': 'Algemesi', + 'lack': -15, + 'inkFk': 'AZL', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 136169, + 'longName': 'Hydrangea Turquesa Jumbo', + 'warehouseFk': 60, + 'producer': null, + 'size': 0, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -1, + 'inkFk': 'TUR', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 136518, + 'longName': 'Rosa Freedom Select', + 'warehouseFk': 60, + 'producer': 'Excellence', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -200, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 136733, + 'longName': 'Rosa LightHouse Premium', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 50, + 'category': 'Pre', + 'warehouse': 'Algemesi', + 'lack': -100, + 'inkFk': 'AMA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 137200, + 'longName': 'Rosa Luciano Extra', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 50, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -250, + 'inkFk': 'RSA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 137203, + 'longName': 'Rosa Satina Extra', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 40, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -600, + 'inkFk': 'RSA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 137204, + 'longName': 'Rosa Satina Extra', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 50, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -125, + 'inkFk': 'RSA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 137207, + 'longName': 'Rosa Mix Extra', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 40, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -875, + 'inkFk': 'MIX', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 137213, + 'longName': 'Rosa Vendela Extra', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 40, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -1800, + 'inkFk': 'BLN', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 137233, + 'longName': 'Rosa Freedom Extra', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 40, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -1200, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 137234, + 'longName': 'Rosa Freedom Extra', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 50, + 'category': 'Ext', + 'warehouse': 'Algemesi', + 'lack': -600, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 137748, + 'longName': 'Clavel Mini Hot Pink Select', + 'warehouseFk': 60, + 'producer': null, + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -20, + 'inkFk': 'FUC', + 'timed': '2024-01-19T12:45:00.000Z', + 'minTimed': '13:45' + }, + { + 'itemFk': 137814, + 'longName': 'Rosa Freedom Premium', + 'warehouseFk': 60, + 'producer': 'Santa Dorotea', + 'size': 80, + 'category': 'Pre', + 'warehouse': 'Algemesi', + 'lack': -1200, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 139016, + 'longName': 'Cesta Cassius', + 'warehouseFk': 60, + 'producer': 'Mega Ceramics', + 'size': 29, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -2, + 'inkFk': 'NAT', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 142330, + 'longName': 'Rosa Glam Dome Rosa', + 'warehouseFk': 60, + 'producer': null, + 'size': 0, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -3, + 'inkFk': 'RSA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 142331, + 'longName': 'Rosa Glam Dome Rojo', + 'warehouseFk': 60, + 'producer': null, + 'size': 0, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -6, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143511, + 'longName': 'Clavel White Florafil Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -200, + 'inkFk': 'BLN', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143512, + 'longName': 'Clavel Red Florafil Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -200, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143513, + 'longName': 'Clavel Lege Pink Florafil Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -200, + 'inkFk': 'RSA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143556, + 'longName': 'Clavel Mini White Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -400, + 'inkFk': 'BLN', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143557, + 'longName': 'Clavel Mini Red Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -400, + 'inkFk': 'ROJ', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143575, + 'longName': 'Clavel Mini Bicolor Mix Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -2000, + 'inkFk': 'MIX', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143697, + 'longName': 'Syngonium Rosa Colgante', + 'warehouseFk': 60, + 'producer': 'Quakelplant BV', + 'size': 35, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -3, + 'inkFk': 'RSA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143833, + 'longName': 'Cymbidium Magic', + 'warehouseFk': 60, + 'producer': 'HVS Orchids', + 'size': 50, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -3, + 'inkFk': 'BLN', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143918, + 'longName': 'Ranunculus Sprinkles Mix', + 'warehouseFk': 60, + 'producer': 'Firma P.A.M. van Os', + 'size': 27, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -12, + 'inkFk': 'MIX', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 143923, + 'longName': 'Dieff se Tropic Snow 2 Plantas', + 'warehouseFk': 60, + 'producer': 'Floramiata', + 'size': 80, + 'category': null, + 'warehouse': 'Algemesi', + 'lack': -1, + 'inkFk': 'VRD', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 144034, + 'longName': 'Clavel Pink Florafil Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -200, + 'inkFk': 'RSA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 144035, + 'longName': 'Clavel Bicolor Mix Florafil Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -2000, + 'inkFk': 'MIX', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }, + { + 'itemFk': 144115, + 'longName': 'Clavel Mini Hot Pink Select', + 'warehouseFk': 60, + 'producer': 'Colibri', + 'size': 70, + 'category': 'Sel', + 'warehouse': 'Algemesi', + 'lack': -400, + 'inkFk': 'RSA', + 'timed': '2024-01-19T22:59:59.000Z', + 'minTimed': '2024-01-19 23:59:59' + }]; + }; +}; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 14cb104be5..5c7fdb7268 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -43,4 +43,5 @@ module.exports = function(Self) { require('../methods/ticket/saveSign')(Self); require('../methods/ticket/invoiceTickets')(Self); require('../methods/ticket/docuwareDownload')(Self); + require('../methods/ticket/itemLack')(Self); }; From 0111aa1b75cdf9012dccdecf2b2037662f66a32b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 22 Jan 2024 09:56:10 +0100 Subject: [PATCH 02/88] refs #6321 feat: fixtures and update procedure --- db/changes/240601/01-updateACLItemLack.sql | 3 + .../240601/01-updateProcedureGetItemLack.sql | 65 +++++++++++++++++++ db/dump/fixtures.sql | 12 +++- 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 db/changes/240601/01-updateACLItemLack.sql create mode 100644 db/changes/240601/01-updateProcedureGetItemLack.sql diff --git a/db/changes/240601/01-updateACLItemLack.sql b/db/changes/240601/01-updateACLItemLack.sql new file mode 100644 index 0000000000..13521325fb --- /dev/null +++ b/db/changes/240601/01-updateACLItemLack.sql @@ -0,0 +1,3 @@ +-- Auto-generated SQL script #202401191358 +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'); diff --git a/db/changes/240601/01-updateProcedureGetItemLack.sql b/db/changes/240601/01-updateProcedureGetItemLack.sql new file mode 100644 index 0000000000..a5cb41b3a3 --- /dev/null +++ b/db/changes/240601/01-updateProcedureGetItemLack.sql @@ -0,0 +1,65 @@ +DROP PROCEDURE IF EXISTS vn.item_getLack; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`(IN vForce BOOLEAN, IN vDays INT, IN vSearch VARCHAR(500)) +BEGIN +/** + * Calcula una tabla con el máximo negativo visible para cada producto y almacen + * + * @param vForce Fuerza el recalculo del stock + * @param vDays Numero de dias a considerar + * @param vSearch Filtro items +**/ + + DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch <> ''; + CALL `cache`.stock_refresh(vForce); + CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL); + CALL item_getMinETD(); + CALL item_zoneClosure(); + + IF vIsSearch THEN + SET vSearch =' '; + END IF; + + SELECT i.id itemFk, + i.longName, + w.id warehouseFk, + p.`name` producer, + i.`size`, + i.category, + w.name warehouse, + SUM(IFNULL(sub.amount,0)) lack, + i.inkFk, + IFNULL(im.timed, util.midnight()) timed, + IFNULL(izc.timed, util.midnight()) minTimed + FROM (SELECT item_id, + warehouse_id, + amount + FROM cache.stock + WHERE amount > 0 + UNION ALL + SELECT itemFk, + warehouseFk, + amount + FROM tmp.itemMinacum + ) sub + JOIN warehouse w ON w.id = sub.warehouse_id + JOIN item i ON i.id = sub.item_id + LEFT JOIN producer p ON p.id = i.producerFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id + LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id + WHERE w.isForTicket + AND ic.display + AND it.code != 'GEN' + GROUP BY i.id, w.id + HAVING lack < 0; + + DROP TEMPORARY TABLE tmp.itemMinacum; + DROP TEMPORARY TABLE tmp.itemMinETD; + DROP TEMPORARY TABLE tmp.itemZoneClosure; +END +$$ +DELIMITER ; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index ba513ee15a..6533cf273d 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -3043,6 +3043,12 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (4, 1103, 4, 32), (13, 1101, 1, NULL), (14, 1101, 4, 27); --- Auto-generated SQL script #202401191358 -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'); +INSERT INTO cache.stock (warehouse_id,item_id,amount) VALUES + (60,1,25), + (13,1,-20), + (4,1,-1000); + -- Auto-generated SQL script #202401220930 +UPDATE vn.warehouse + SET isForTicket=1 + WHERE id=2; + From 2bcb6366b248f872c2ba91107436ca6e545e52bf Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 22 Jan 2024 10:10:38 +0100 Subject: [PATCH 03/88] refs #6321 feat: vCustomWhere --- db/changes/240601/01-updateProcedureGetItemLack.sql | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/db/changes/240601/01-updateProcedureGetItemLack.sql b/db/changes/240601/01-updateProcedureGetItemLack.sql index a5cb41b3a3..8c36a762d6 100644 --- a/db/changes/240601/01-updateProcedureGetItemLack.sql +++ b/db/changes/240601/01-updateProcedureGetItemLack.sql @@ -2,7 +2,7 @@ DROP PROCEDURE IF EXISTS vn.item_getLack; DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`(IN vForce BOOLEAN, IN vDays INT, IN vSearch VARCHAR(500)) +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`(IN vForce BOOLEAN, IN vDays INT, IN vCustomWhere VARCHAR(500)) BEGIN /** * Calcula una tabla con el máximo negativo visible para cada producto y almacen @@ -12,15 +12,11 @@ BEGIN * @param vSearch Filtro items **/ - DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch <> ''; CALL `cache`.stock_refresh(vForce); CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL); CALL item_getMinETD(); CALL item_zoneClosure(); - IF vIsSearch THEN - SET vSearch =' '; - END IF; SELECT i.id itemFk, i.longName, @@ -54,6 +50,7 @@ BEGIN WHERE w.isForTicket AND ic.display AND it.code != 'GEN' + AND (vCustomWhere IS NULL OR vCustomWhere = '' OR vCustomWhere) GROUP BY i.id, w.id HAVING lack < 0; From 895d9bff6436c7e74315b4e229c7f25b9f9b4535 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 29 Jan 2024 09:55:34 +0100 Subject: [PATCH 04/88] refs #6321 feat itemLAck with SQL --- .../01-updateProcedureGetItemLack copy.sql | 68 +++++++++ .../240601/01-updateProcedureGetItemLack.sql | 22 ++- .../ticket/back/methods/ticket/itemLack.js | 138 +++++++++++++++++- .../methods/ticket/specs/itemLack.spec.js | 31 ++++ 4 files changed, 253 insertions(+), 6 deletions(-) create mode 100644 db/changes/240601/01-updateProcedureGetItemLack copy.sql create mode 100644 modules/ticket/back/methods/ticket/specs/itemLack.spec.js diff --git a/db/changes/240601/01-updateProcedureGetItemLack copy.sql b/db/changes/240601/01-updateProcedureGetItemLack copy.sql new file mode 100644 index 0000000000..7372ad6998 --- /dev/null +++ b/db/changes/240601/01-updateProcedureGetItemLack copy.sql @@ -0,0 +1,68 @@ +DROP PROCEDURE IF EXISTS vn.item_getLack; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`( + IN vForce BOOLEAN DEFAULT TRUE, + IN vDays INT DEFAULT 2, + IN vCustomWhere TEXT, + ) + +BEGIN +/** + * Calcula una tabla con el máximo negativo visible para cada producto y almacen + * + * @param vForce Fuerza el recalculo del stock + * @param vDays Numero de dias a considerar + * @param vSearch Filtro items +**/ + + CALL `cache`.stock_refresh(vForce); + CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL); + CALL item_getMinETD(); + CALL item_zoneClosure(); + + + SET @sqlQuery = CONCAT(`SELECT i.id itemFk, + i.longName, + w.id warehouseFk, + p.`name` producer, + i.`size`, + i.category, + w.name warehouse, + SUM(IFNULL(sub.amount,0)) lack, + i.inkFk, + IFNULL(im.timed, util.midnight()) timed, + IFNULL(izc.timed, util.midnight()) minTimed + FROM (SELECT item_id, + warehouse_id, + amount + FROM cache.stock + WHERE amount > 0 + UNION ALL + SELECT itemFk, + warehouseFk, + amount + FROM tmp.itemMinacum + ) sub + JOIN warehouse w ON w.id = sub.warehouse_id + JOIN item i ON i.id = sub.item_id + LEFT JOIN producer p ON p.id = i.producerFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id + LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id + WHERE w.isForTicket + AND ic.display + AND it.code != 'GEN' + AND `,vCustomWhere,` + GROUP BY i.id, w.id + HAVING lack < 0;`); + CALL `exec`(@sqlQuery); + + DROP TEMPORARY TABLE tmp.itemMinacum; + DROP TEMPORARY TABLE tmp.itemMinETD; + DROP TEMPORARY TABLE tmp.itemZoneClosure; +END +$$ +DELIMITER ; diff --git a/db/changes/240601/01-updateProcedureGetItemLack.sql b/db/changes/240601/01-updateProcedureGetItemLack.sql index 8c36a762d6..0a59ecb2b7 100644 --- a/db/changes/240601/01-updateProcedureGetItemLack.sql +++ b/db/changes/240601/01-updateProcedureGetItemLack.sql @@ -2,7 +2,18 @@ DROP PROCEDURE IF EXISTS vn.item_getLack; DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`(IN vForce BOOLEAN, IN vDays INT, IN vCustomWhere VARCHAR(500)) +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`( + IN vForce BOOLEAN DEFAULT TRUE, + IN vDays INT DEFAULT 2, + IN vId INT DEFAULT NULL, + IN vLongname INT DEFAULT NULL, + IN vSupplier VARCHAR DEFAULT NULL, + IN vColor VARCHAR DEFAULT NULL, + IN vSize INT DEFAULT NULL, + IN vOrigen VARCHAR DEFAULT NULL, + IN vLack INT DEFAULT NULL + ) + BEGIN /** * Calcula una tabla con el máximo negativo visible para cada producto y almacen @@ -50,7 +61,14 @@ BEGIN WHERE w.isForTicket AND ic.display AND it.code != 'GEN' - AND (vCustomWhere IS NULL OR vCustomWhere = '' OR vCustomWhere) + AND (vId IS NULL OR i.id = vId) + AND (vLongname IS NULL OR i.longName = vLongname) + AND (vSupplier IS NULL OR p.`name` LIKE CONCAT('%', vSupplier, '%')) + AND (vColor IS NULL OR vColor = i.inkFk) + AND (vSize IS NULL OR vSize = i.`size`) + AND (vOrigen IS NULL OR vOrigen = w.name) + AND (vLack IS NULL OR vLack = lack) + GROUP BY i.id, w.id HAVING lack < 0; diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 35f299e6c1..fa4b500fbe 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -1,14 +1,52 @@ +/* eslint-disable no-console */ module.exports = Self => { Self.remoteMethod('itemLack', { description: 'Download a ticket delivery note document', accessType: 'READ', accepts: [ + { + arg: 'ctx', + type: 'object', + http: {source: 'context'} + }, { arg: 'filter', type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} }, + { + arg: 'id', + type: 'number', + description: 'The item id', + }, + { + arg: 'longname', + type: 'string', + description: 'The item id', + }, + { + arg: 'supplier', + type: 'string', + description: 'The client fiscal id', + }, + { + arg: 'color', + type: 'string', + description: 'The item id', + }, + { + arg: 'size', + type: 'string', description: 'The item id', + }, + { + arg: 'origen', + type: 'string', description: 'The item id', + }, + { + arg: 'lack', + type: 'number', description: 'The item id', + } ], returns: [ { @@ -25,15 +63,107 @@ module.exports = Self => { Self.itemLack = async(ctx, filter, options) => { const myOptions = {}; - + // const versionSQL = false; if (typeof options == 'object') Object.assign(myOptions, options); + // if (versionSQL) { + // const filterKeyOrder = ['id', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack']; - // let query = 'CALL vn.item_getLack(?, ?)'; + // const {body} = ctx; - // const result = await Self.rawSql(query, [true, 2]); + // let procedureParams = [true, 2]; + // procedureParams.push(...filterKeyOrder.map(clave => body || null)); + // const procedureArgs = Array(procedureParams.length).fill('?').join(', '); + // let query = `CALL vn.item_getLack(${procedureArgs})`; - // if (tx) await tx.commit(); + // const result = await Self.rawSql(query, procedureParams, myOptions); + // console.log('qUERY:', query); + // console.log('Argumentos procedimiento:', procedureArgs); + // console.log('PArametros del procedimiento:', procedureParams); + // // const result = await Self.rawSql(query, [true, 2, ...procedureParams]); + // // console.log('Resultado', result); + // return result; + // } else { + // const where = buildFilter(ctx.args, (param, value) => { + // switch (param) { + // case 'id': + // return {'i.id': value}; + // case 'longname': + // return {'i.longName': value}; + // case 'name': + // return {'p.name': {like: `%${value}%`}}; + // case 'color': + // return {'i.inkFk': value}; + // case 'size': + // return {'i.size': value}; + // case 'origen': + // return {'w.name': value}; + // case 'lack': + // return {'lack': value}; + // } + // }) ?? {}; + + // const stmts = [ + // 'CALL cache.stock_refresh(vForce);', + // 'CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL);', + // 'CALL item_getMinETD();', + // 'CALL item_zoneClosure();' + // ]; + + // const stmt = new ParameterizedSQL(` + // SELECT i.id itemFk, + // i.longName, + // w.id warehouseFk, + // p.name producer, + // i.size, + // i.category, + // w.name warehouse, + // SUM(IFNULL(sub.amount,0)) lack, + // i.inkFk, + // IFNULL(im.timed, util.midnight()) timed, + // IFNULL(izc.timed, util.midnight()) minTimed + // FROM (SELECT item_id, + // warehouse_id, + // amount + // FROM cache.stock + // WHERE amount > 0 + // UNION ALL + // SELECT itemFk, + // warehouseFk, + // amount + // FROM tmp.itemMinacum + // ) sub + // JOIN warehouse w ON w.id = sub.warehouse_id + // JOIN item i ON i.id = sub.item_id + // LEFT JOIN producer p ON p.id = i.producerFk + // JOIN itemType it ON it.id = i.typeFk + // JOIN itemCategory ic ON ic.id = it.categoryFk + // LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id + // LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id + // WHERE w.isForTicket + // AND ic.display + // AND it.code != 'GEN' + // `); + + // const sqlWhere = conn.makeWhere(where); + + // stmt.merge(sqlWhere); + // stmt.merge(` + // GROUP BY i.id, w.id + // HAVING lack < 0;` + // ); + // stmts.push(` + // DROP TEMPORARY TABLE tmp.itemMinacum; + // DROP TEMPORARY TABLE tmp.itemMinETD; + // DROP TEMPORARY TABLE tmp.itemZoneClosure; + // `); + // stmt.merge(conn.makeSuffix(filter)); + // const itemsIndex = stmts.push(stmt) - 1; + + // const sql = ParameterizedSQL.join(stmts, ';'); + // const result = await conn.executeStmt(sql, myOptions); + // return itemsIndex === 0 ? result : result[itemsIndex]; + // } return [ { diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js new file mode 100644 index 0000000000..49651abb8b --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -0,0 +1,31 @@ +const models = require('vn-loopback/server/server').models; + +describe('Item Lack', () => { + it('should return data with NO filters', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const result = await models.Ticket.itemLack(3, options); + + expect(result).toBeFalsy(); + } catch (e) { + throw e; + } + }); + + it('should return data with filters', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const result = await models.Ticket.isEmpty(8, options); + + expect(result).toBeFalsy(); + } catch (e) { + throw e; + } + }); +}); From 1a21dda00b93c0c3b9d68fc9b2e79282f861a6f2 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 29 Jan 2024 09:55:44 +0100 Subject: [PATCH 05/88] refs #6321 feat itemLackDetail --- .../back/methods/ticket/itemLackDetail.js | 69 +++++++++++++++++++ .../ticket/specs/itemLackDetail.spec.js | 46 +++++++++++++ modules/ticket/back/models/ticket-methods.js | 1 + 3 files changed, 116 insertions(+) create mode 100644 modules/ticket/back/methods/ticket/itemLackDetail.js create mode 100644 modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js new file mode 100644 index 0000000000..e0efc4c192 --- /dev/null +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -0,0 +1,69 @@ +/* eslint-disable no-console */ +module.exports = Self => { + Self.remoteMethod('itemLackDetail', { + description: 'Download a ticket delivery note document', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + description: 'The item id', + } + ], + returns: [ + { + arg: 'body', + type: ['object'], + root: true + } + ], + http: { + path: `/itemLack/:id/detail`, + verb: 'GET' + } + }); + + Self.itemLackDetail = async(id, options) => { + const myOptions = {}; + // const versionSQL = false; + if (typeof options == 'object') + Object.assign(myOptions, options); + + const detail = await Self.rawSQL(` + SELECT + s.Id_Movimiento, st.code, t.Id_Ticket, t.Alias, t.Fecha, s.Cantidad, ag.Agencia, + ts.alertLevel alertLevel, + st.name stateName, + st.id stateId, + s.Id_Article id, + al.code alertLevelCode, + z.name, + z.hour theoreticalhour, + cn.isRookie, + sc.saleClonedFk turno, + tr.saleFk peticionCompra, + t.Fecha minTimed + FROM + Sale s + JOIN Tickets t ON t.Id_Ticket=s.Id_Ticket -- vn.ticket + LEFT JOIN zone z ON z.id = t.zoneFk -- vn.zone + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = DateValue(t.Fecha) + JOIN Clientes c ON c.Id_Cliente=t.Id_Cliente -- vn.client + LEFT JOIN clientNewBorn cn ON cn.clientFk=c.Id_Cliente + JOIN Agencias ag ON ag.Id_Agencia=t.Id_Agencia -- vn.agencyMode + JOIN ticketState tls ON ts.ticketFk=t.Id_Ticket -- vn.sale + LEFT JOIN state s ON st.id=ts.state + LEFT JOIN alertLevel al ON al.id = st.alertLevel + LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.Id_Movimiento + LEFT JOIN ticketRequest tr ON tr.saleFk = s.Id_Movimiento + WHERE + AND s.Id_Article = ? + AND NOT Cantidad + AND Fecha >= util.VN_CURDATE() + AND Fecha < INTERVAL util.VN_CURDATE() + INTERVAL ? + 1 DAY + ORDER BY s.Id_Movimiento DESC+ + `, [id, 2], myOptions); + + return detail; + }; +}; diff --git a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js new file mode 100644 index 0000000000..6b2881a842 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js @@ -0,0 +1,46 @@ +const models = require('vn-loopback/server/server').models; + +describe('Item Lack Detail', () => { + it('should return false if id is null', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + const id = null; + + const result = await models.Ticket.itemLackDetail(id, options); + + expect(result).toBeFalsy(); + } catch (e) { + throw e; + } + }); + + it('should return data if id exists', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + const id = 1167; + const result = await models.Ticket.itemLackDetail(id, options); + + expect(result).toBeFalsy(); + } catch (e) { + throw e; + } + }); + + it('should return error is if not exists', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + const id = 0; + const result = await models.Ticket.itemLackDetail(id, options); + + expect(result).toBeFalsy(); + } catch (e) { + throw e; + } + }); +}); diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 5c7fdb7268..7482f7b394 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -44,4 +44,5 @@ module.exports = function(Self) { require('../methods/ticket/invoiceTickets')(Self); require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/itemLack')(Self); + require('../methods/ticket/itemLackDetail')(Self); }; From 871447cc6e1aaf309928676b74a07fca494515de Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 5 Mar 2024 08:07:54 +0100 Subject: [PATCH 06/88] refs #6321 feat: updates --- db/changes/240601/01-updateACLItemLack.sql | 2 + .../ticket/back/methods/ticket/itemLack.js | 2 +- .../back/methods/ticket/itemLackDetail.js | 81 +++++++++++-------- 3 files changed, 51 insertions(+), 34 deletions(-) diff --git a/db/changes/240601/01-updateACLItemLack.sql b/db/changes/240601/01-updateACLItemLack.sql index 13521325fb..90f05e14b6 100644 --- a/db/changes/240601/01-updateACLItemLack.sql +++ b/db/changes/240601/01-updateACLItemLack.sql @@ -1,3 +1,5 @@ -- Auto-generated SQL script #202401191358 INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'); diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index fa4b500fbe..383d0ba5bb 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -167,7 +167,7 @@ module.exports = Self => { return [ { - 'itemFk': 7176, + 'itemFk': 72176, 'longName': 'Anthurium Olivius x20', 'warehouseFk': 60, 'producer': null, diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index e0efc4c192..fc3ecd6756 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -1,4 +1,5 @@ /* eslint-disable no-console */ +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; module.exports = Self => { Self.remoteMethod('itemLackDetail', { description: 'Download a ticket delivery note document', @@ -8,62 +9,76 @@ module.exports = Self => { arg: 'id', type: 'number', description: 'The item id', - } + }, ], returns: [ { arg: 'body', type: ['object'], - root: true - } + root: true, + }, ], http: { path: `/itemLack/:id/detail`, - verb: 'GET' - } + verb: 'GET', + }, }); Self.itemLackDetail = async(id, options) => { - const myOptions = {}; - // const versionSQL = false; - if (typeof options == 'object') - Object.assign(myOptions, options); + const conn = Self.dataSource.connector; - const detail = await Self.rawSQL(` + const myOptions = {}; + if (typeof options == 'object') Object.assign(myOptions, options); + + const stmt = new ParameterizedSQL( + ` SELECT - s.Id_Movimiento, st.code, t.Id_Ticket, t.Alias, t.Fecha, s.Cantidad, ag.Agencia, + s.id saleFk, + st.code, + t.id ticketFk, + t.nickname, + t.hour, + s.quantity, + ag.name, ts.alertLevel alertLevel, st.name stateName, st.id stateId, - s.Id_Article id, + s.itemFk itemFk, al.code alertLevelCode, z.name, z.hour theoreticalhour, cn.isRookie, sc.saleClonedFk turno, tr.saleFk peticionCompra, - t.Fecha minTimed + t.hour minTimed FROM - Sale s - JOIN Tickets t ON t.Id_Ticket=s.Id_Ticket -- vn.ticket - LEFT JOIN zone z ON z.id = t.zoneFk -- vn.zone - LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = DateValue(t.Fecha) - JOIN Clientes c ON c.Id_Cliente=t.Id_Cliente -- vn.client - LEFT JOIN clientNewBorn cn ON cn.clientFk=c.Id_Cliente - JOIN Agencias ag ON ag.Id_Agencia=t.Id_Agencia -- vn.agencyMode - JOIN ticketState tls ON ts.ticketFk=t.Id_Ticket -- vn.sale - LEFT JOIN state s ON st.id=ts.state - LEFT JOIN alertLevel al ON al.id = st.alertLevel - LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.Id_Movimiento - LEFT JOIN ticketRequest tr ON tr.saleFk = s.Id_Movimiento - WHERE - AND s.Id_Article = ? - AND NOT Cantidad - AND Fecha >= util.VN_CURDATE() - AND Fecha < INTERVAL util.VN_CURDATE() + INTERVAL ? + 1 DAY - ORDER BY s.Id_Movimiento DESC+ - `, [id, 2], myOptions); + vn.sale s + JOIN vn.ticket t ON t.id=s.ticketFk -- vn.ticket + LEFT JOIN vn.zone z ON z.id = t.zoneFk -- vn.zone + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk -- AND zc.dated = DateValue(t.Fecha) + JOIN vn.client c ON c.id=t.clientFk -- vn.client + LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id + JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk -- vn.agencyMode + JOIN vn.agency ag ON ag.id=agm.id -- vn.agencyMode + JOIN vn.ticketState ts ON ts.ticketFk=t.id -- vn.sale + LEFT JOIN vn.state st ON st.id=ts.state + LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel + LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id + LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id + LIMIT 1 + `, + null + ); + // WHERE + // s.itemFk = ? - return detail; + // AND t.landed >= util.VN_CURDATE() + // AND t.landed < INTERVAL util.VN_CURDATE() + INTERVAL ? + 1 DAY + // ORDER BY s.id DESC+ + // [id,2] + + const sql = ParameterizedSQL.join([stmt], ';'); + const result = await conn.executeStmt(sql, myOptions); + return result; }; }; From d1e7e133332566e1372c552b903115c3051f227c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 6 Mar 2024 14:37:28 +0100 Subject: [PATCH 07/88] refs #6321 feat: acl --- db/versions/10936-wheatAnthurium/00-updateACL.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/10936-wheatAnthurium/00-updateACL.sql diff --git a/db/versions/10936-wheatAnthurium/00-updateACL.sql b/db/versions/10936-wheatAnthurium/00-updateACL.sql new file mode 100644 index 0000000000..35c81ce588 --- /dev/null +++ b/db/versions/10936-wheatAnthurium/00-updateACL.sql @@ -0,0 +1,4 @@ +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES + ('Ticket','itemLack','READ','ALLOW','ROLE','employee'), + ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'); From c8446eb9a1c580e07ab9fce8986311d695ebe190 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 13 Mar 2024 09:20:32 +0100 Subject: [PATCH 08/88] refs #6321 perf: updatemethod --- .../ticket/back/methods/ticket/itemLack.js | 931 ++---------------- 1 file changed, 89 insertions(+), 842 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 383d0ba5bb..b934d7b153 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -1,4 +1,7 @@ -/* eslint-disable no-console */ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const {buildFilter} = require('vn-loopback/util/filter'); + module.exports = Self => { Self.remoteMethod('itemLack', { description: 'Download a ticket delivery note document', @@ -23,25 +26,27 @@ module.exports = Self => { { arg: 'longname', type: 'string', - description: 'The item id', + description: 'Article name', }, { arg: 'supplier', type: 'string', - description: 'The client fiscal id', + description: 'Supplier id', }, { arg: 'color', type: 'string', - description: 'The item id', + description: 'Color\'s item', }, { arg: 'size', - type: 'string', description: 'The item id', + type: 'string', + description: 'Size\'s item', }, { arg: 'origen', - type: 'string', description: 'The item id', + type: 'string', + description: 'origen id', }, { arg: 'lack', @@ -63,849 +68,91 @@ module.exports = Self => { Self.itemLack = async(ctx, filter, options) => { const myOptions = {}; - // const versionSQL = false; if (typeof options == 'object') Object.assign(myOptions, options); - // if (versionSQL) { - // const filterKeyOrder = ['id', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack']; + const conn = Self.dataSource.connector; + let where = {}; + where = buildFilter(ctx.args, (param, value) => { + switch (param) { + case 'id': + return {'i.id': value}; + case 'longname': + return {'i.longName': value}; + case 'name': + return {'p.name': {like: `%${value}%`}}; + case 'color': + return {'i.inkFk': value}; + case 'size': + return {'i.size': value}; + case 'origen': + return {'w.name': value}; + case 'lack': + return {'lack': value}; + } + }) ?? {}; - // const {body} = ctx; + const stmts = []; + stmts.push(`SET @_optimizer_search_depth = @@optimizer_search_depth`); + stmts.push(`SET SESSION optimizer_search_depth = 0`); - // let procedureParams = [true, 2]; - // procedureParams.push(...filterKeyOrder.map(clave => body || null)); - // const procedureArgs = Array(procedureParams.length).fill('?').join(', '); - // let query = `CALL vn.item_getLack(${procedureArgs})`; + stmts.push(`CALL cache.stock_refresh(true)`); + stmts.push(`CALL item_getMinacum(NULL, util.VN_CURDATE(), 2, NULL)`); + stmts.push(`CALL item_getMinETD()`); + stmts.push(`CALL item_zoneClosure()`); - // const result = await Self.rawSql(query, procedureParams, myOptions); - // console.log('qUERY:', query); - // console.log('Argumentos procedimiento:', procedureArgs); - // console.log('PArametros del procedimiento:', procedureParams); - // // const result = await Self.rawSql(query, [true, 2, ...procedureParams]); - // // console.log('Resultado', result); - // return result; - // } else { - // const where = buildFilter(ctx.args, (param, value) => { - // switch (param) { - // case 'id': - // return {'i.id': value}; - // case 'longname': - // return {'i.longName': value}; - // case 'name': - // return {'p.name': {like: `%${value}%`}}; - // case 'color': - // return {'i.inkFk': value}; - // case 'size': - // return {'i.size': value}; - // case 'origen': - // return {'w.name': value}; - // case 'lack': - // return {'lack': value}; - // } - // }) ?? {}; + const stmt = new ParameterizedSQL(` + SELECT i.id itemFk, + i.longName, + w.id warehouseFk, + p.name producer, + i.size, + i.category, + w.name warehouse, + SUM(IFNULL(sub.amount,0)) lack, + i.inkFk, + IFNULL(im.timed, util.midnight()) timed, + IFNULL(izc.timed, util.midnight()) minTimed + FROM (SELECT item_id, + warehouse_id, + amount + FROM cache.stock + WHERE amount > 0 + UNION ALL + SELECT itemFk, + warehouseFk, + amount + FROM tmp.itemMinacum + ) sub + JOIN warehouse w ON w.id = sub.warehouse_id + JOIN item i ON i.id = sub.item_id + LEFT JOIN producer p ON p.id = i.producerFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id + LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id + `); - // const stmts = [ - // 'CALL cache.stock_refresh(vForce);', - // 'CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL);', - // 'CALL item_getMinETD();', - // 'CALL item_zoneClosure();' - // ]; + const sqlWhere = conn.makeWhere(where); + stmt.merge(sqlWhere); + const prefix = Object.keys(where).length > 0 ? 'AND' : 'WHERE'; + stmt.merge(`${prefix} w.isForTicket + AND ic.display + AND it.code != 'GEN'`); - // const stmt = new ParameterizedSQL(` - // SELECT i.id itemFk, - // i.longName, - // w.id warehouseFk, - // p.name producer, - // i.size, - // i.category, - // w.name warehouse, - // SUM(IFNULL(sub.amount,0)) lack, - // i.inkFk, - // IFNULL(im.timed, util.midnight()) timed, - // IFNULL(izc.timed, util.midnight()) minTimed - // FROM (SELECT item_id, - // warehouse_id, - // amount - // FROM cache.stock - // WHERE amount > 0 - // UNION ALL - // SELECT itemFk, - // warehouseFk, - // amount - // FROM tmp.itemMinacum - // ) sub - // JOIN warehouse w ON w.id = sub.warehouse_id - // JOIN item i ON i.id = sub.item_id - // LEFT JOIN producer p ON p.id = i.producerFk - // JOIN itemType it ON it.id = i.typeFk - // JOIN itemCategory ic ON ic.id = it.categoryFk - // LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id - // LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id - // WHERE w.isForTicket - // AND ic.display - // AND it.code != 'GEN' - // `); + stmt.merge(` + GROUP BY i.id, w.id + HAVING lack < 0` + ); + stmt.merge(conn.makeSuffix(filter)); + const itemsIndex = stmts.push(stmt) - 1; + stmts.push( + `DROP TEMPORARY TABLE + tmp.itemMinacum, + tmp.itemMinETD, + tmp.itemZoneClosure`); - // const sqlWhere = conn.makeWhere(where); - - // stmt.merge(sqlWhere); - // stmt.merge(` - // GROUP BY i.id, w.id - // HAVING lack < 0;` - // ); - // stmts.push(` - // DROP TEMPORARY TABLE tmp.itemMinacum; - // DROP TEMPORARY TABLE tmp.itemMinETD; - // DROP TEMPORARY TABLE tmp.itemZoneClosure; - // `); - // stmt.merge(conn.makeSuffix(filter)); - // const itemsIndex = stmts.push(stmt) - 1; - - // const sql = ParameterizedSQL.join(stmts, ';'); - // const result = await conn.executeStmt(sql, myOptions); - // return itemsIndex === 0 ? result : result[itemsIndex]; - // } - - return [ - { - 'itemFk': 72176, - 'longName': 'Anthurium Olivius x20', - 'warehouseFk': 60, - 'producer': null, - 'size': null, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -40, - 'inkFk': 'VRD', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 14613, - 'longName': 'Crisantemo Uniflora Anastasia Topsin', - 'warehouseFk': 60, - 'producer': null, - 'size': 70, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -10, - 'inkFk': 'BLN', - 'timed': '2024-01-19T15:20:00.000Z', - 'minTimed': '16:20' - }, - { - 'itemFk': 28619, - 'longName': 'Clavel Mix Fancy', - 'warehouseFk': 60, - 'producer': 'Benchmark', - 'size': 60, - 'category': 'Fan', - 'warehouse': 'Algemesi', - 'lack': -700, - 'inkFk': 'MIX', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 29422, - 'longName': 'Lisianthus Doble Green', - 'warehouseFk': 60, - 'producer': 'L.I.S.', - 'size': 65, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -10, - 'inkFk': 'VRC', - 'timed': '2024-01-19T16:00:00.000Z', - 'minTimed': '17:00' - }, - { - 'itemFk': 29590, - 'longName': 'Schlumbergera (3 Colors)', - 'warehouseFk': 60, - 'producer': 'Gartneriet Thoruplund', - 'size': 18, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -18, - 'inkFk': 'MIX', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 33636, - 'longName': 'Antirrinum Lavander', - 'warehouseFk': 60, - 'producer': null, - 'size': 80, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -10, - 'inkFk': 'LAV', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 36864, - 'longName': 'Kattegrass (Comida para gatos)', - 'warehouseFk': 60, - 'producer': 'Willem Jongenotter Kw.', - 'size': 10, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -10, - 'inkFk': 'VRD', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 38631, - 'longName': 'Triple Accion Listo Uso', - 'warehouseFk': 60, - 'producer': 'Flower', - 'size': null, - 'category': 'ml', - 'warehouse': 'Algemesi', - 'lack': -24, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 53233, - 'longName': 'Clavel Cheerio Fancy', - 'warehouseFk': 60, - 'producer': 'Benchmark', - 'size': 60, - 'category': 'Fan', - 'warehouse': 'Algemesi', - 'lack': -50, - 'inkFk': 'R\/B', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 60525, - 'longName': 'Rosa Explorer Extra', - 'warehouseFk': 60, - 'producer': 'Floraroma', - 'size': 60, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -500, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 68998, - 'longName': 'Clavel Hot Pink Select', - 'warehouseFk': 60, - 'producer': 'Funza', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -25, - 'inkFk': 'FUC', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 77807, - 'longName': 'Hydrangea Mix 4Flo', - 'warehouseFk': 60, - 'producer': 'Schroll-Flowers', - 'size': 35, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -6, - 'inkFk': 'MIX', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 84883, - 'longName': 'Rosa Freedom Standard', - 'warehouseFk': 60, - 'producer': 'El Milagro', - 'size': 40, - 'category': 'Sta', - 'warehouse': 'Algemesi', - 'lack': -600, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 92466, - 'longName': 'Clavel Kino Select', - 'warehouseFk': 60, - 'producer': 'Funza', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -25, - 'inkFk': 'P\/B', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 93355, - 'longName': 'Clavel Caramel Fancy', - 'warehouseFk': 60, - 'producer': 'Funza', - 'size': 60, - 'category': 'Fan', - 'warehouse': 'Algemesi', - 'lack': -50, - 'inkFk': 'TRR', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 95068, - 'longName': 'Alstroemeria Fifi Plus', - 'warehouseFk': 60, - 'producer': 'Funza', - 'size': 80, - 'category': 'Plu', - 'warehouse': 'Algemesi', - 'lack': -30, - 'inkFk': 'SWE', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 107891, - 'longName': 'Rosa Freedom Select', - 'warehouseFk': 60, - 'producer': 'Excellence', - 'size': 40, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -1000, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 113163, - 'longName': 'Lilium Oriental Roselily Aisha 2', - 'warehouseFk': 60, - 'producer': 'Moerman Lilium BV', - 'size': 65, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -10, - 'inkFk': 'BLN', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 117832, - 'longName': 'Rosa Freedom Standard', - 'warehouseFk': 60, - 'producer': 'Multiflora', - 'size': 50, - 'category': 'Sta', - 'warehouse': 'Algemesi', - 'lack': -200, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 123005, - 'longName': 'Rosa Orange Crush Extra', - 'warehouseFk': 60, - 'producer': 'Trebol', - 'size': 50, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -125, - 'inkFk': 'NAR', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 123380, - 'longName': 'Clavel Hypnosis Standard', - 'warehouseFk': 60, - 'producer': 'GEOFLORA', - 'size': 50, - 'category': 'Sta', - 'warehouse': 'Algemesi', - 'lack': -25, - 'inkFk': 'LAV', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 124948, - 'longName': 'Cymbidium Mon Amour', - 'warehouseFk': 60, - 'producer': 'New Orchids', - 'size': 60, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -1, - 'inkFk': 'BLN', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 125062, - 'longName': 'Hoya Kerri Cerámica', - 'warehouseFk': 60, - 'producer': 'Gartneriet Lundager', - 'size': 15, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -18, - 'inkFk': 'VRD', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 125593, - 'longName': 'Hoya Kerri Cerámica Roja', - 'warehouseFk': 60, - 'producer': 'v.d. Arend Tropical', - 'size': 12, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -1, - 'inkFk': 'VRD', - 'timed': '2024-01-19T15:20:00.000Z', - 'minTimed': '16:20' - }, - { - 'itemFk': 126428, - 'longName': 'Rosa Freedom Extra', - 'warehouseFk': 60, - 'producer': 'Matina', - 'size': 50, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -25, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 128417, - 'longName': 'Rosa Brighton Select', - 'warehouseFk': 60, - 'producer': 'Excellence', - 'size': 50, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -75, - 'inkFk': 'AMA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 132651, - 'longName': 'Rosa Freedom Select', - 'warehouseFk': 60, - 'producer': 'Excellence', - 'size': 60, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -1250, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 135194, - 'longName': 'Eucalipto Torreliana Small', - 'warehouseFk': 60, - 'producer': null, - 'size': 40, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -20, - 'inkFk': 'M\/V', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 135516, - 'longName': 'Hydrangea Curaçao Petite', - 'warehouseFk': 60, - 'producer': 'Flores del Este', - 'size': 60, - 'category': 'Pet', - 'warehouse': 'Algemesi', - 'lack': -15, - 'inkFk': 'AZL', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 136169, - 'longName': 'Hydrangea Turquesa Jumbo', - 'warehouseFk': 60, - 'producer': null, - 'size': 0, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -1, - 'inkFk': 'TUR', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 136518, - 'longName': 'Rosa Freedom Select', - 'warehouseFk': 60, - 'producer': 'Excellence', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -200, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 136733, - 'longName': 'Rosa LightHouse Premium', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 50, - 'category': 'Pre', - 'warehouse': 'Algemesi', - 'lack': -100, - 'inkFk': 'AMA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 137200, - 'longName': 'Rosa Luciano Extra', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 50, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -250, - 'inkFk': 'RSA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 137203, - 'longName': 'Rosa Satina Extra', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 40, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -600, - 'inkFk': 'RSA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 137204, - 'longName': 'Rosa Satina Extra', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 50, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -125, - 'inkFk': 'RSA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 137207, - 'longName': 'Rosa Mix Extra', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 40, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -875, - 'inkFk': 'MIX', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 137213, - 'longName': 'Rosa Vendela Extra', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 40, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -1800, - 'inkFk': 'BLN', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 137233, - 'longName': 'Rosa Freedom Extra', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 40, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -1200, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 137234, - 'longName': 'Rosa Freedom Extra', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 50, - 'category': 'Ext', - 'warehouse': 'Algemesi', - 'lack': -600, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 137748, - 'longName': 'Clavel Mini Hot Pink Select', - 'warehouseFk': 60, - 'producer': null, - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -20, - 'inkFk': 'FUC', - 'timed': '2024-01-19T12:45:00.000Z', - 'minTimed': '13:45' - }, - { - 'itemFk': 137814, - 'longName': 'Rosa Freedom Premium', - 'warehouseFk': 60, - 'producer': 'Santa Dorotea', - 'size': 80, - 'category': 'Pre', - 'warehouse': 'Algemesi', - 'lack': -1200, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 139016, - 'longName': 'Cesta Cassius', - 'warehouseFk': 60, - 'producer': 'Mega Ceramics', - 'size': 29, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -2, - 'inkFk': 'NAT', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 142330, - 'longName': 'Rosa Glam Dome Rosa', - 'warehouseFk': 60, - 'producer': null, - 'size': 0, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -3, - 'inkFk': 'RSA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 142331, - 'longName': 'Rosa Glam Dome Rojo', - 'warehouseFk': 60, - 'producer': null, - 'size': 0, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -6, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143511, - 'longName': 'Clavel White Florafil Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -200, - 'inkFk': 'BLN', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143512, - 'longName': 'Clavel Red Florafil Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -200, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143513, - 'longName': 'Clavel Lege Pink Florafil Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -200, - 'inkFk': 'RSA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143556, - 'longName': 'Clavel Mini White Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -400, - 'inkFk': 'BLN', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143557, - 'longName': 'Clavel Mini Red Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -400, - 'inkFk': 'ROJ', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143575, - 'longName': 'Clavel Mini Bicolor Mix Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -2000, - 'inkFk': 'MIX', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143697, - 'longName': 'Syngonium Rosa Colgante', - 'warehouseFk': 60, - 'producer': 'Quakelplant BV', - 'size': 35, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -3, - 'inkFk': 'RSA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143833, - 'longName': 'Cymbidium Magic', - 'warehouseFk': 60, - 'producer': 'HVS Orchids', - 'size': 50, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -3, - 'inkFk': 'BLN', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143918, - 'longName': 'Ranunculus Sprinkles Mix', - 'warehouseFk': 60, - 'producer': 'Firma P.A.M. van Os', - 'size': 27, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -12, - 'inkFk': 'MIX', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 143923, - 'longName': 'Dieff se Tropic Snow 2 Plantas', - 'warehouseFk': 60, - 'producer': 'Floramiata', - 'size': 80, - 'category': null, - 'warehouse': 'Algemesi', - 'lack': -1, - 'inkFk': 'VRD', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 144034, - 'longName': 'Clavel Pink Florafil Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -200, - 'inkFk': 'RSA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 144035, - 'longName': 'Clavel Bicolor Mix Florafil Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -2000, - 'inkFk': 'MIX', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }, - { - 'itemFk': 144115, - 'longName': 'Clavel Mini Hot Pink Select', - 'warehouseFk': 60, - 'producer': 'Colibri', - 'size': 70, - 'category': 'Sel', - 'warehouse': 'Algemesi', - 'lack': -400, - 'inkFk': 'RSA', - 'timed': '2024-01-19T22:59:59.000Z', - 'minTimed': '2024-01-19 23:59:59' - }]; + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql, myOptions); + return itemsIndex === 0 ? result : result[itemsIndex]; }; }; From ed6b25455b1f26e9ef2310ac41c13814d97ca974 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 13 Mar 2024 14:27:45 +0100 Subject: [PATCH 09/88] refs #5858 feat: improve itemLackDetail --- .../back/methods/ticket/itemLackDetail.js | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index fc3ecd6756..c7671c2e76 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -53,29 +53,24 @@ module.exports = Self => { t.hour minTimed FROM vn.sale s - JOIN vn.ticket t ON t.id=s.ticketFk -- vn.ticket - LEFT JOIN vn.zone z ON z.id = t.zoneFk -- vn.zone - LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk -- AND zc.dated = DateValue(t.Fecha) - JOIN vn.client c ON c.id=t.clientFk -- vn.client + JOIN vn.ticket t ON t.id=s.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk + JOIN vn.client c ON c.id=t.clientFk LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id - JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk -- vn.agencyMode - JOIN vn.agency ag ON ag.id=agm.id -- vn.agencyMode - JOIN vn.ticketState ts ON ts.ticketFk=t.id -- vn.sale + JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk + JOIN vn.agency ag ON ag.id=agm.id + JOIN vn.ticketState ts ON ts.ticketFk=t.id LEFT JOIN vn.state st ON st.id=ts.state LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id - LIMIT 1 + WHERE + s.itemFk = ? + AND t.landed >= util.VN_CURDATE() + AND t.landed < util.VN_CURDATE() + INTERVAL ? + 1 DAY `, - null - ); - // WHERE - // s.itemFk = ? - - // AND t.landed >= util.VN_CURDATE() - // AND t.landed < INTERVAL util.VN_CURDATE() + INTERVAL ? + 1 DAY - // ORDER BY s.id DESC+ - // [id,2] + [id, 2]); const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions); From 6a12af2eb9f4d6a026c085a3b80cfb52c2b92427 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 14 Mar 2024 15:26:30 +0100 Subject: [PATCH 10/88] refs #6321 feat: add producerFk --- db/dump/fixtures.before.sql | 36 +++++++++--------- .../ticket/back/methods/ticket/itemDetail.sql | 38 +++++++++++++++++++ .../ticket/back/methods/ticket/itemLack.js | 1 + 3 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 modules/ticket/back/methods/ticket/itemDetail.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 646120462a..3ce756c776 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -938,25 +938,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('VT', 'Sales'); INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, - `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`) + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`, `category`) VALUES - (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3), - (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2), - (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5), - (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), - (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL), - (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), - (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), - (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), - (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL); + (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3, 'SEL'), + (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2, 'SEL'), + (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5, 'SEL'), + (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), + (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), + (6, 5, 1, 2, NULL, 1, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), + (7, 5, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), + (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), + (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 'SEL'), + (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), + (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), + (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), + (13, 5, 1, 2, NULL, 1, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL, 'SEL'), + (14, 5, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 'SEL'), + (15, 4, NULL, 1, NULL, 1, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 'SEL'), + (16, 6, NULL, 1, NULL, 1, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 'SEL'), + (71, 6, NULL, 1, NULL, 2, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'); -- Update the taxClass after insert of the items UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 diff --git a/modules/ticket/back/methods/ticket/itemDetail.sql b/modules/ticket/back/methods/ticket/itemDetail.sql new file mode 100644 index 0000000000..8538378e76 --- /dev/null +++ b/modules/ticket/back/methods/ticket/itemDetail.sql @@ -0,0 +1,38 @@ + SELECT + s.id saleFk, + st.code, + t.id ticketFk, + t.nickname, + t.hour, + s.quantity, + ag.name, + ts.alertLevel alertLevel, + st.name stateName, + st.id stateId, + s.itemFk itemFk, + al.code alertLevelCode, + z.name, + z.hour theoreticalhour, + cn.isRookie, + sc.saleClonedFk turno, + tr.saleFk peticionCompra, + t.hour minTimed + FROM + vn.sale s + JOIN vn.ticket t ON t.id=s.ticketFk -- vn.ticket + LEFT JOIN vn.zone z ON z.id = t.zoneFk -- vn.zone + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk -- AND zc.dated = DateValue(t.Fecha) + JOIN vn.client c ON c.id=t.clientFk -- vn.client + LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id + JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk -- vn.agencyMode + JOIN vn.agency ag ON ag.id=agm.id -- vn.agencyMode + JOIN vn.ticketState ts ON ts.ticketFk=t.id -- vn.sale + LEFT JOIN vn.state st ON st.id=ts.state + LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel + LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id + LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id + WHERE + s.itemFk = ? + AND t.landed >= util.VN_CURDATE() + AND t.landed < INTERVAL util.VN_CURDATE() + INTERVAL ? + 1 DAY + `, diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index b934d7b153..b384084003 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -105,6 +105,7 @@ module.exports = Self => { i.longName, w.id warehouseFk, p.name producer, + p.id producerFk, i.size, i.category, w.name warehouse, From f83f7808c8d41fa66f103199e69bea9b8e84f8fe Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 15 Mar 2024 09:32:36 +0100 Subject: [PATCH 11/88] refs #6321 feat: negativeOrigin method --- db/changes/240601/01-updateACLItemLack.sql | 4 ++ .../back/methods/ticket/itemLackOrigin.js | 40 +++++++++++++++++++ .../ticket/specs/itemLackoOrigin.spec.js | 19 +++++++++ modules/ticket/back/models/ticket-methods.js | 1 + 4 files changed, 64 insertions(+) create mode 100644 modules/ticket/back/methods/ticket/itemLackOrigin.js create mode 100644 modules/ticket/back/methods/ticket/specs/itemLackoOrigin.spec.js diff --git a/db/changes/240601/01-updateACLItemLack.sql b/db/changes/240601/01-updateACLItemLack.sql index 90f05e14b6..197dea786f 100644 --- a/db/changes/240601/01-updateACLItemLack.sql +++ b/db/changes/240601/01-updateACLItemLack.sql @@ -1,5 +1,9 @@ -- Auto-generated SQL script #202401191358 INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'); + INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'); + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Ticket','itemLackOrigin','WRITE','ALLOW','ROLE','employee'); diff --git a/modules/ticket/back/methods/ticket/itemLackOrigin.js b/modules/ticket/back/methods/ticket/itemLackOrigin.js new file mode 100644 index 0000000000..f720f3d633 --- /dev/null +++ b/modules/ticket/back/methods/ticket/itemLackOrigin.js @@ -0,0 +1,40 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +module.exports = Self => { + Self.remoteMethod('itemLackOrigin', { + description: 'Insert ticket negative into negativeOrigin', + accessType: 'WRITE', + accepts: [{ + arg: 'ctx', + type: 'Object', + http: {source: 'context'} + }, {arg: 'tickets', type: 'array', http: {source: 'body'}}], + returns: + { + type: 'boolean', + root: true + }, + http: { + path: `/itemLack`, + verb: 'POST' + } + }); + + Self.itemLackOrigin = async(ctx, data, options) => { + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + const conn = Self.dataSource.connector; + const stmts = data.map(({itemFk, negativeType, lack}) => + `INSERT INTO vn.negativeOrigin (itemFk, type, quantity) + VALUES (${itemFk}, '${negativeType}', ${lack}) + ON DUPLICATE KEY UPDATE quantity = quantity + VALUES(quantity)`) ?? []; + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql, myOptions); + return result; + }; +}; diff --git a/modules/ticket/back/methods/ticket/specs/itemLackoOrigin.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackoOrigin.spec.js new file mode 100644 index 0000000000..901bd12bb7 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/itemLackoOrigin.spec.js @@ -0,0 +1,19 @@ +const models = require('vn-loopback/server/server').models; + +describe('Item Lack NegativeOrigin', () => { + it('should return OK', async() => { + const tx = await models.Ticket.beginTransaction({}); + const ctx = {req: {accessToken: {userId: 9}}}; + + const options = {transaction: tx}; + const data = [{itemFk: 1, negativeType: 'FALTAS', lack: 1}, {itemFk: 1, negativeType: 'FALTAS', lack: 2}]; + + await models.Ticket.itemLackOrigin(ctx, data, options); + const query = 'SELECT * FROM vn.negativeOrigin'; + + const negativeOrigin = await models.Application.rawSql(query, null, options); + + expect(negativeOrigin.length).toEqual(1); + expect(negativeOrigin[0].quantity).toEqual(3); + }); +}); diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 687eb8e58c..b057e7ffd2 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -48,4 +48,5 @@ module.exports = function(Self) { require('../methods/ticket/myLastModified')(Self); require('../methods/ticket/itemLack')(Self); require('../methods/ticket/itemLackDetail')(Self); + require('../methods/ticket/itemLackOrigin')(Self); }; From 6c0706cc566dab7c846897a13e54aed7c1854693 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 15 Mar 2024 09:33:06 +0100 Subject: [PATCH 12/88] refs #6321 perf: query to retrieve results --- modules/ticket/back/methods/ticket/itemLackDetail.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index c7671c2e76..0821633924 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -37,19 +37,20 @@ module.exports = Self => { st.code, t.id ticketFk, t.nickname, + t.shipped, t.hour, s.quantity, - ag.name, + ag.name agName, ts.alertLevel alertLevel, st.name stateName, st.id stateId, s.itemFk itemFk, al.code alertLevelCode, - z.name, + z.name zoneName, z.hour theoreticalhour, cn.isRookie, - sc.saleClonedFk turno, - tr.saleFk peticionCompra, + IF(sc.saleClonedFk, 1, 0 ) as turno, + IF(tr.saleFk , 1, 0 ) as peticionCompra, t.hour minTimed FROM vn.sale s From a943e39ba74429c601bf39566b6f962805900069 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 22 Mar 2024 22:44:37 +0100 Subject: [PATCH 13/88] refs #6321 feat: negativeOrigin --- .../10936-wheatAnthurium/00-updateACL.sql | 4 ++- .../back/methods/ticket/negativeOrigin.js | 36 +++++++++++++++++++ modules/ticket/back/models/ticket-methods.js | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 modules/ticket/back/methods/ticket/negativeOrigin.js diff --git a/db/versions/10936-wheatAnthurium/00-updateACL.sql b/db/versions/10936-wheatAnthurium/00-updateACL.sql index 35c81ce588..42cf734e77 100644 --- a/db/versions/10936-wheatAnthurium/00-updateACL.sql +++ b/db/versions/10936-wheatAnthurium/00-updateACL.sql @@ -1,4 +1,6 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'), - ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'); + ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'), + ('Ticket','itemLackOrigin','READ','ALLOW','ROLE','employee'), + ('Ticket','negativeOrigin','READ','ALLOW','ROLE','employee'); diff --git a/modules/ticket/back/methods/ticket/negativeOrigin.js b/modules/ticket/back/methods/ticket/negativeOrigin.js new file mode 100644 index 0000000000..ee251ff3e0 --- /dev/null +++ b/modules/ticket/back/methods/ticket/negativeOrigin.js @@ -0,0 +1,36 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +module.exports = Self => { + Self.remoteMethod('negativeOrigin', { + description: 'Insert ticket negative into negativeOrigin', + accessType: 'READ', + accepts: [{ + arg: 'ctx', + type: 'Object', + http: {source: 'context'} + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/negativeOrigin`, + verb: 'GET' + } + }); + + Self.negativeOrigin = async(ctx, data, options) => { + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + const conn = Self.dataSource.connector; + const stmts = ['SELECT * FROM vn.negativeOrigin']; + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql, myOptions); + return result; + }; +}; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index b057e7ffd2..88fdb435e3 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -49,4 +49,5 @@ module.exports = function(Self) { require('../methods/ticket/itemLack')(Self); require('../methods/ticket/itemLackDetail')(Self); require('../methods/ticket/itemLackOrigin')(Self); + require('../methods/ticket/negativeOrigin')(Self); }; From e6fe245b276946fa61b6875fddcc8913901fb90e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 27 Mar 2024 14:09:25 +0100 Subject: [PATCH 14/88] refs #6321 feat: new split method --- .../10936-wheatAnthurium/00-updateACL.sql | 3 +- .../back/methods/ticket/itemLackOrigin.js | 2 +- modules/ticket/back/methods/ticket/split.js | 83 +++++++++++++++++++ modules/ticket/back/models/ticket-methods.js | 1 + 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 modules/ticket/back/methods/ticket/split.js diff --git a/db/versions/10936-wheatAnthurium/00-updateACL.sql b/db/versions/10936-wheatAnthurium/00-updateACL.sql index 42cf734e77..32acce8a2b 100644 --- a/db/versions/10936-wheatAnthurium/00-updateACL.sql +++ b/db/versions/10936-wheatAnthurium/00-updateACL.sql @@ -2,5 +2,6 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,princi VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'), ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'), - ('Ticket','itemLackOrigin','READ','ALLOW','ROLE','employee'), + ('Ticket','itemLackOrigin','WRITE','ALLOW','ROLE','employee'), + ('Ticket','split','WRITE','ALLOW','ROLE','employee'), ('Ticket','negativeOrigin','READ','ALLOW','ROLE','employee'); diff --git a/modules/ticket/back/methods/ticket/itemLackOrigin.js b/modules/ticket/back/methods/ticket/itemLackOrigin.js index f720f3d633..ca485b9879 100644 --- a/modules/ticket/back/methods/ticket/itemLackOrigin.js +++ b/modules/ticket/back/methods/ticket/itemLackOrigin.js @@ -15,7 +15,7 @@ module.exports = Self => { root: true }, http: { - path: `/itemLack`, + path: `/itemLackOrigin`, verb: 'POST' } }); diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js new file mode 100644 index 0000000000..a5905663c4 --- /dev/null +++ b/modules/ticket/back/methods/ticket/split.js @@ -0,0 +1,83 @@ +const {ParameterizedSQL} = require('loopback-connector/lib/sql'); +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('split', { + description: 'Split a ticket or n tickets', + accessType: 'WRITE', + accepts: [ + { + + type: ['Object'], + required: true, + http: {source: 'body'} + } + ], + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/split`, + verb: 'POST' + } + }); + + Self.split = async(ctx, tickets, options) => { + // const models = Self.app.models; + const myOptions = {}; + let tx; + let results = []; + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + // const conn = Self.dataSource.connector; + // const stmts = []; + try { + const ticketsIds = tickets.map(({id}, index) => id); + const ticketsCount = await Self.rawSql(` + Select t.id tid, s.id sid, count(s.id) count from + vn.ticket t + LEFT JOIN vn.sale s + ON s.ticketFk = t.id + WHERE t.id IN (?) GROUP BY t.id;`, + [ticketsIds], myOptions); + console.log(ticketsCount); + + // stmts.push(stmt); + // const sql = ParameterizedSQL.join(stmts, ';'); + // const result = await conn.executeStmt(sql, myOptions); + for (const {tid, sid, count} of ticketsCount) { + try { + if (count === 1) { + results.push({ticket: tid, message: 'noSplit'}); + continue; + } + const [, [{vNewTicket}]] = await Self.rawSql(` + CALL vn.ticket_clone(?, @vNewTicket); + SELECT @vNewTicket vNewTicket;`, + [tid], myOptions); + + if (vNewTicket === 0) continue; + await Self.rawSql(` + UPDATE vn.sale SET isPicked = (id = ?) WHERE ticketFk = ?`, + [sid, tid], myOptions); + await Self.transferSales(ctx, tid, vNewTicket, sid, myOptions); + + await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [tid, 'FIXING'], myOptions); + results.push({ticket: tid, message: 'split'}); + } catch (error) { + throw new UserError('You cannot close tickets for today'); + } + } + return results; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index f5c5edeb38..7e189bcc7d 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -52,4 +52,5 @@ module.exports = function(Self) { require('../methods/ticket/itemLackDetail')(Self); require('../methods/ticket/itemLackOrigin')(Self); require('../methods/ticket/negativeOrigin')(Self); + require('../methods/ticket/split')(Self); }; From 65a6174e2b3655ed0a4fbb12d1ac48e82486220f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 28 Mar 2024 12:01:06 +0100 Subject: [PATCH 15/88] refs #6321 updates --- modules/ticket/back/methods/ticket/split.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index a5905663c4..8772bad87e 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -38,7 +38,7 @@ module.exports = Self => { // const conn = Self.dataSource.connector; // const stmts = []; try { - const ticketsIds = tickets.map(({id}, index) => id); + const ticketsIds = tickets.map(({ticketFk}, index) => ticketFk); const ticketsCount = await Self.rawSql(` Select t.id tid, s.id sid, count(s.id) count from vn.ticket t From d62c55dc9feb0b76dea34d5fe5d5c840630816cf Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 1 Apr 2024 13:11:58 +0200 Subject: [PATCH 16/88] refs #6321 test: negativeOrigin --- .../back/methods/ticket/itemLackOrigin.js | 2 +- .../ticket/specs/itemLackoOrigin.spec.js | 19 ------- .../ticket/specs/negativeOrigin.spec.js | 51 +++++++++++++++++++ 3 files changed, 52 insertions(+), 20 deletions(-) delete mode 100644 modules/ticket/back/methods/ticket/specs/itemLackoOrigin.spec.js create mode 100644 modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js diff --git a/modules/ticket/back/methods/ticket/itemLackOrigin.js b/modules/ticket/back/methods/ticket/itemLackOrigin.js index ca485b9879..73673c17da 100644 --- a/modules/ticket/back/methods/ticket/itemLackOrigin.js +++ b/modules/ticket/back/methods/ticket/itemLackOrigin.js @@ -31,7 +31,7 @@ module.exports = Self => { const conn = Self.dataSource.connector; const stmts = data.map(({itemFk, negativeType, lack}) => `INSERT INTO vn.negativeOrigin (itemFk, type, quantity) - VALUES (${itemFk}, '${negativeType}', ${lack}) + VALUES (${itemFk}, "${negativeType}", ${lack}) ON DUPLICATE KEY UPDATE quantity = quantity + VALUES(quantity)`) ?? []; const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); diff --git a/modules/ticket/back/methods/ticket/specs/itemLackoOrigin.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackoOrigin.spec.js deleted file mode 100644 index 901bd12bb7..0000000000 --- a/modules/ticket/back/methods/ticket/specs/itemLackoOrigin.spec.js +++ /dev/null @@ -1,19 +0,0 @@ -const models = require('vn-loopback/server/server').models; - -describe('Item Lack NegativeOrigin', () => { - it('should return OK', async() => { - const tx = await models.Ticket.beginTransaction({}); - const ctx = {req: {accessToken: {userId: 9}}}; - - const options = {transaction: tx}; - const data = [{itemFk: 1, negativeType: 'FALTAS', lack: 1}, {itemFk: 1, negativeType: 'FALTAS', lack: 2}]; - - await models.Ticket.itemLackOrigin(ctx, data, options); - const query = 'SELECT * FROM vn.negativeOrigin'; - - const negativeOrigin = await models.Application.rawSql(query, null, options); - - expect(negativeOrigin.length).toEqual(1); - expect(negativeOrigin[0].quantity).toEqual(3); - }); -}); diff --git a/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js b/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js new file mode 100644 index 0000000000..899f3c63a0 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js @@ -0,0 +1,51 @@ +const models = require('vn-loopback/server/server').models; + +fdescribe('NegativeOrigin', () => { + it('should return OK', async() => { + const tx = await models.Ticket.beginTransaction({}); + const ctx = {req: {accessToken: {userId: 9}}}; + + const options = {transaction: tx}; + const data = [ + {itemFk: 1, negativeType: 'FALTAS', lack: 1}, + {itemFk: 1, negativeType: 'FALTAS', lack: 2} + ]; + try { + await models.Ticket.itemLackOrigin(ctx, data, options); + const query = 'SELECT * FROM vn.negativeOrigin'; + + const negativeOrigin = await models.Application.rawSql(query, null, options); + + expect(negativeOrigin.length).toEqual(1); + expect(negativeOrigin[0].quantity).toEqual(3); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should add 2 lines', async() => { + const tx = await models.Ticket.beginTransaction({}); + const ctx = {req: {accessToken: {userId: 9}}}; + + const options = {transaction: tx}; + const data = [ + {itemFk: 2, negativeType: 'FALTAS', lack: 1}, + {itemFk: 3, negativeType: 'FALTAS', lack: 2} + ]; + try { + await models.Ticket.itemLackOrigin(ctx, data, options); + const query = 'SELECT * FROM vn.negativeOrigin'; + + const negativeOrigin = await models.Application.rawSql(query, null, options); + + expect(negativeOrigin.length).toEqual(2); + expect(negativeOrigin[0].quantity).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); From d225821a41e83232e33a20694973d40e8e1fc1a7 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 1 Apr 2024 13:59:35 +0200 Subject: [PATCH 17/88] refs #6321 test: itemLack --- .../ticket/back/methods/ticket/itemLack.js | 7 +- .../methods/ticket/specs/itemLack.spec.js | 143 ++++++++++++++++-- 2 files changed, 137 insertions(+), 13 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index b384084003..932d50b52a 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -72,7 +72,8 @@ module.exports = Self => { Object.assign(myOptions, options); const conn = Self.dataSource.connector; let where = {}; - where = buildFilter(ctx.args, (param, value) => { + filter = Object.assign(ctx.args ?? {}, filter); + where = buildFilter(filter, (param, value) => { switch (param) { case 'id': return {'i.id': value}; @@ -85,9 +86,9 @@ module.exports = Self => { case 'size': return {'i.size': value}; case 'origen': - return {'w.name': value}; + return {'w.id': value}; case 'lack': - return {'lack': value}; + return {'sub.amount': value}; } }) ?? {}; diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index 49651abb8b..5bf1e422a5 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -1,30 +1,153 @@ const models = require('vn-loopback/server/server').models; -describe('Item Lack', () => { +fdescribe('Item Lack', () => { + beforeAll(async() => { + ctx = { + req: { + accessToken: {}, + headers: {origin: 'http://localhost'}, + } + }; + }); + it('should return data with NO filters', async() => { const tx = await models.Ticket.beginTransaction({}); + const options = {transaction: tx}; + const filter = {}; try { - const options = {transaction: tx}; + const result = await models.Ticket.itemLack(ctx, filter, options); - const result = await models.Ticket.itemLack(3, options); - - expect(result).toBeFalsy(); + expect(result.length).toEqual(4); + await tx.rollback(); } catch (e) { + await tx.rollback(); throw e; } }); - it('should return data with filters', async() => { + it('should return data with filter.id', async() => { const tx = await models.Ticket.beginTransaction({}); + const options = {transaction: tx}; + const filter = { + id: 1 + }; try { - const options = {transaction: tx}; + const result = await models.Ticket.itemLack(ctx, filter, options); - const result = await models.Ticket.isEmpty(8, options); - - expect(result).toBeFalsy(); + expect(result.length).toEqual(1); + await tx.rollback(); } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return data with filter.longname', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const filter = { + longname: 'Ranged weapon longbow 200cm' + }; + try { + const result = await models.Ticket.itemLack(ctx, filter, options); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + xit('should return data with filter.name', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const filter = { + name: 1 + }; + try { + const result = await models.Ticket.itemLack(ctx, filter, options); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return data with filter.color', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const filter = { + color: 'BRW' + }; + try { + const result = await models.Ticket.itemLack(ctx, filter, options); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return data with filter.origen', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const filter = { + origen: 2 + }; + try { + const result = await models.Ticket.itemLack(ctx, filter, options); + + expect(result.length).toEqual(3); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return data with filter.size', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const filter = { + size: '200' + }; + try { + const result = await models.Ticket.itemLack(ctx, filter, options); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + fit('should return data with filter.lack', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const filter = { + lack: '-100' + }; + try { + const result = await models.Ticket.itemLack(ctx, filter, options); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); throw e; } }); From 59498179ece33a0408f116f7aa5e39072d9c1899 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 1 Apr 2024 14:05:45 +0200 Subject: [PATCH 18/88] refs #6321 test: itemLackDetail --- modules/ticket/back/methods/ticket/specs/itemLack.spec.js | 4 ++-- .../ticket/back/methods/ticket/specs/itemLackDetail.spec.js | 6 ++++++ .../ticket/back/methods/ticket/specs/negativeOrigin.spec.js | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index 5bf1e422a5..ded595376d 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Item Lack', () => { +describe('Item Lack', () => { beforeAll(async() => { ctx = { req: { @@ -134,7 +134,7 @@ fdescribe('Item Lack', () => { } }); - fit('should return data with filter.lack', async() => { + it('should return data with filter.lack', async() => { const tx = await models.Ticket.beginTransaction({}); const options = {transaction: tx}; diff --git a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js index 6b2881a842..28da66c4c1 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js @@ -11,7 +11,9 @@ describe('Item Lack Detail', () => { const result = await models.Ticket.itemLackDetail(id, options); expect(result).toBeFalsy(); + await tx.rollback(); } catch (e) { + await tx.rollback(); throw e; } }); @@ -25,7 +27,9 @@ describe('Item Lack Detail', () => { const result = await models.Ticket.itemLackDetail(id, options); expect(result).toBeFalsy(); + await tx.rollback(); } catch (e) { + await tx.rollback(); throw e; } }); @@ -39,7 +43,9 @@ describe('Item Lack Detail', () => { const result = await models.Ticket.itemLackDetail(id, options); expect(result).toBeFalsy(); + await tx.rollback(); } catch (e) { + await tx.rollback(); throw e; } }); diff --git a/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js b/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js index 899f3c63a0..6da2c607ea 100644 --- a/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js +++ b/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('NegativeOrigin', () => { +describe('NegativeOrigin', () => { it('should return OK', async() => { const tx = await models.Ticket.beginTransaction({}); const ctx = {req: {accessToken: {userId: 9}}}; From 601f5db0800d9ee551de2c8079382fa0071cae02 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 1 Apr 2024 16:11:30 +0200 Subject: [PATCH 19/88] refs #6321 test: spliy --- .../ticket/specs/itemLackDetail.spec.js | 6 +- .../back/methods/ticket/specs/split.spec.js | 98 +++++++++++++++++++ modules/ticket/back/methods/ticket/split.js | 30 +++--- 3 files changed, 115 insertions(+), 19 deletions(-) create mode 100644 modules/ticket/back/methods/ticket/specs/split.spec.js diff --git a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js index 28da66c4c1..9d5a7c6f99 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js @@ -10,7 +10,7 @@ describe('Item Lack Detail', () => { const result = await models.Ticket.itemLackDetail(id, options); - expect(result).toBeFalsy(); + expect(result.length).toEqual(0); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -26,7 +26,7 @@ describe('Item Lack Detail', () => { const id = 1167; const result = await models.Ticket.itemLackDetail(id, options); - expect(result).toBeFalsy(); + expect(result.length).toEqual(0); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -42,7 +42,7 @@ describe('Item Lack Detail', () => { const id = 0; const result = await models.Ticket.itemLackDetail(id, options); - expect(result).toBeFalsy(); + expect(result.length).toEqual(0); await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/specs/split.spec.js b/modules/ticket/back/methods/ticket/specs/split.spec.js new file mode 100644 index 0000000000..01008b5562 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/split.spec.js @@ -0,0 +1,98 @@ +const models = require('vn-loopback/server/server').models; + +describe('Split', () => { + beforeAll(async() => { + ctx = { + req: { + accessToken: {}, + headers: {origin: 'http://localhost'}, + } + }; + }); + + it('should split tickets with count 1', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const data = [ + {ticketFk: 7} + ]; + try { + const result = await models.Ticket.split(ctx, data, options); + + expect(result.length).toEqual(1); + expect(result[0].ticket).toEqual(7); + expect(result[0].status).toEqual('noSplit'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should split tickets with count 2 and error', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const data = [ + {ticketFk: 8} + ]; + try { + const result = await models.Ticket.split(ctx, data, options); + + expect(result.length).toEqual(1); + expect(result[0].ticket).toEqual(8); + expect(result[0].status).toEqual('error'); + expect(result[0].message).toEqual('This ticket is not editable.'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should split tickets with count 2 and other error', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const data = [ + {ticketFk: 16} + ]; + try { + const result = await models.Ticket.split(ctx, data, options); + + expect(result.length).toEqual(1); + expect(result[0].ticket).toEqual(16); + expect(result[0].status).toEqual('error'); + expect(result[0].message).toEqual('Can\'t transfer claimed sales'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should split tickets with count 2 and success', async() => { + const tx = await models.Ticket.beginTransaction({}); + + const options = {transaction: tx}; + const data = [ + {ticketFk: 32} + ]; + try { + const result = await models.Ticket.split(ctx, data, options); + + expect(result.length).toEqual(1); + expect(result[0].ticket).toEqual(32); + expect(result[0].status).toEqual('split'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index 8772bad87e..54ba2123a9 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -1,6 +1,3 @@ -const {ParameterizedSQL} = require('loopback-connector/lib/sql'); -const UserError = require('vn-loopback/util/user-error'); - module.exports = Self => { Self.remoteMethodCtx('split', { description: 'Split a ticket or n tickets', @@ -24,7 +21,7 @@ module.exports = Self => { }); Self.split = async(ctx, tickets, options) => { - // const models = Self.app.models; + const models = Self.app.models; const myOptions = {}; let tx; let results = []; @@ -46,15 +43,11 @@ module.exports = Self => { ON s.ticketFk = t.id WHERE t.id IN (?) GROUP BY t.id;`, [ticketsIds], myOptions); - console.log(ticketsCount); - // stmts.push(stmt); - // const sql = ParameterizedSQL.join(stmts, ';'); - // const result = await conn.executeStmt(sql, myOptions); - for (const {tid, sid, count} of ticketsCount) { + for (const {tid, count} of ticketsCount) { try { if (count === 1) { - results.push({ticket: tid, message: 'noSplit'}); + results.push({ticket: tid, status: 'noSplit'}); continue; } const [, [{vNewTicket}]] = await Self.rawSql(` @@ -63,15 +56,20 @@ module.exports = Self => { [tid], myOptions); if (vNewTicket === 0) continue; - await Self.rawSql(` + const sales = await models.Sale.find({ + where: {ticketFk: tid} + }, myOptions); + + const updateIsPicked = sales.map(({sid}) => Self.rawSql(` UPDATE vn.sale SET isPicked = (id = ?) WHERE ticketFk = ?`, - [sid, tid], myOptions); - await Self.transferSales(ctx, tid, vNewTicket, sid, myOptions); + [sid, tid], myOptions)); + await Promise.all(updateIsPicked); + await Self.transferSales(ctx, tid, vNewTicket, sales, myOptions); await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [tid, 'FIXING'], myOptions); - results.push({ticket: tid, message: 'split'}); - } catch (error) { - throw new UserError('You cannot close tickets for today'); + results.push({ticket: tid, status: 'split'}); + } catch ({message}) { + results.push({ticket: tid, status: 'error', message}); } } return results; From 5d24844256d82c3f29aa3f4c23a8412d29217b0f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 1 Apr 2024 16:12:52 +0200 Subject: [PATCH 20/88] refs #6321 test: debug use TIMEOUT --- back/tests.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/back/tests.js b/back/tests.js index 50698eb922..b5b5bf361b 100644 --- a/back/tests.js +++ b/back/tests.js @@ -18,7 +18,7 @@ const opts = getopts(process.argv.slice(2), { let server; const PARALLEL = false; const SETUP_TIMEOUT = 15 * 60 * 1000; -const SPEC_TIMEOUT = 30 * 1000; +const SPEC_TIMEOUT = 30 * 11000; process.on('exit', teardown); process.on('uncaughtException', onError); @@ -111,7 +111,7 @@ async function test() { const JunitReporter = require('jasmine-reporters'); runner.addReporter(new JunitReporter.JUnitXmlReporter()); } - if (opts.ci) + if (opts.ci || opts.debug) runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT; // runner.loadConfigFile('back/jasmine.json'); diff --git a/package.json b/package.json index 39c5e15b75..72ac563c2f 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "yaml-loader": "^0.5.0" }, "scripts": { - "test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json", + "test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json --debug", "test:e2e": "node e2e/tests.js", "test:front": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", From d08535ac18faebb439c9254a1c7241de44d08831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Segarra=20Mart=C3=ADnez?= Date: Tue, 2 Apr 2024 08:04:27 +0200 Subject: [PATCH 21/88] refs #6321 minor changes --- back/tests.js | 2 +- db/changes/240601/01-updateACLItemLack.sql | 9 --- .../01-updateProcedureGetItemLack copy.sql | 68 ---------------- .../240601/01-updateProcedureGetItemLack.sql | 80 ------------------- .../ticket/back/methods/ticket/itemDetail.sql | 38 --------- .../back/methods/ticket/itemLackDetail.js | 4 +- .../back/methods/ticket/itemLackOrigin.js | 2 +- .../back/methods/ticket/negativeOrigin.js | 2 +- modules/ticket/back/methods/ticket/split.js | 3 +- 9 files changed, 6 insertions(+), 202 deletions(-) delete mode 100644 db/changes/240601/01-updateACLItemLack.sql delete mode 100644 db/changes/240601/01-updateProcedureGetItemLack copy.sql delete mode 100644 db/changes/240601/01-updateProcedureGetItemLack.sql delete mode 100644 modules/ticket/back/methods/ticket/itemDetail.sql diff --git a/back/tests.js b/back/tests.js index b5b5bf361b..cfb6814351 100644 --- a/back/tests.js +++ b/back/tests.js @@ -18,7 +18,7 @@ const opts = getopts(process.argv.slice(2), { let server; const PARALLEL = false; const SETUP_TIMEOUT = 15 * 60 * 1000; -const SPEC_TIMEOUT = 30 * 11000; +const SPEC_TIMEOUT = 30 * 1000; process.on('exit', teardown); process.on('uncaughtException', onError); diff --git a/db/changes/240601/01-updateACLItemLack.sql b/db/changes/240601/01-updateACLItemLack.sql deleted file mode 100644 index 197dea786f..0000000000 --- a/db/changes/240601/01-updateACLItemLack.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Auto-generated SQL script #202401191358 -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'); - -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'); - -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Ticket','itemLackOrigin','WRITE','ALLOW','ROLE','employee'); diff --git a/db/changes/240601/01-updateProcedureGetItemLack copy.sql b/db/changes/240601/01-updateProcedureGetItemLack copy.sql deleted file mode 100644 index 7372ad6998..0000000000 --- a/db/changes/240601/01-updateProcedureGetItemLack copy.sql +++ /dev/null @@ -1,68 +0,0 @@ -DROP PROCEDURE IF EXISTS vn.item_getLack; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`( - IN vForce BOOLEAN DEFAULT TRUE, - IN vDays INT DEFAULT 2, - IN vCustomWhere TEXT, - ) - -BEGIN -/** - * Calcula una tabla con el máximo negativo visible para cada producto y almacen - * - * @param vForce Fuerza el recalculo del stock - * @param vDays Numero de dias a considerar - * @param vSearch Filtro items -**/ - - CALL `cache`.stock_refresh(vForce); - CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL); - CALL item_getMinETD(); - CALL item_zoneClosure(); - - - SET @sqlQuery = CONCAT(`SELECT i.id itemFk, - i.longName, - w.id warehouseFk, - p.`name` producer, - i.`size`, - i.category, - w.name warehouse, - SUM(IFNULL(sub.amount,0)) lack, - i.inkFk, - IFNULL(im.timed, util.midnight()) timed, - IFNULL(izc.timed, util.midnight()) minTimed - FROM (SELECT item_id, - warehouse_id, - amount - FROM cache.stock - WHERE amount > 0 - UNION ALL - SELECT itemFk, - warehouseFk, - amount - FROM tmp.itemMinacum - ) sub - JOIN warehouse w ON w.id = sub.warehouse_id - JOIN item i ON i.id = sub.item_id - LEFT JOIN producer p ON p.id = i.producerFk - JOIN itemType it ON it.id = i.typeFk - JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id - LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id - WHERE w.isForTicket - AND ic.display - AND it.code != 'GEN' - AND `,vCustomWhere,` - GROUP BY i.id, w.id - HAVING lack < 0;`); - CALL `exec`(@sqlQuery); - - DROP TEMPORARY TABLE tmp.itemMinacum; - DROP TEMPORARY TABLE tmp.itemMinETD; - DROP TEMPORARY TABLE tmp.itemZoneClosure; -END -$$ -DELIMITER ; diff --git a/db/changes/240601/01-updateProcedureGetItemLack.sql b/db/changes/240601/01-updateProcedureGetItemLack.sql deleted file mode 100644 index 0a59ecb2b7..0000000000 --- a/db/changes/240601/01-updateProcedureGetItemLack.sql +++ /dev/null @@ -1,80 +0,0 @@ -DROP PROCEDURE IF EXISTS vn.item_getLack; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`( - IN vForce BOOLEAN DEFAULT TRUE, - IN vDays INT DEFAULT 2, - IN vId INT DEFAULT NULL, - IN vLongname INT DEFAULT NULL, - IN vSupplier VARCHAR DEFAULT NULL, - IN vColor VARCHAR DEFAULT NULL, - IN vSize INT DEFAULT NULL, - IN vOrigen VARCHAR DEFAULT NULL, - IN vLack INT DEFAULT NULL - ) - -BEGIN -/** - * Calcula una tabla con el máximo negativo visible para cada producto y almacen - * - * @param vForce Fuerza el recalculo del stock - * @param vDays Numero de dias a considerar - * @param vSearch Filtro items -**/ - - CALL `cache`.stock_refresh(vForce); - CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL); - CALL item_getMinETD(); - CALL item_zoneClosure(); - - - SELECT i.id itemFk, - i.longName, - w.id warehouseFk, - p.`name` producer, - i.`size`, - i.category, - w.name warehouse, - SUM(IFNULL(sub.amount,0)) lack, - i.inkFk, - IFNULL(im.timed, util.midnight()) timed, - IFNULL(izc.timed, util.midnight()) minTimed - FROM (SELECT item_id, - warehouse_id, - amount - FROM cache.stock - WHERE amount > 0 - UNION ALL - SELECT itemFk, - warehouseFk, - amount - FROM tmp.itemMinacum - ) sub - JOIN warehouse w ON w.id = sub.warehouse_id - JOIN item i ON i.id = sub.item_id - LEFT JOIN producer p ON p.id = i.producerFk - JOIN itemType it ON it.id = i.typeFk - JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id - LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id - WHERE w.isForTicket - AND ic.display - AND it.code != 'GEN' - AND (vId IS NULL OR i.id = vId) - AND (vLongname IS NULL OR i.longName = vLongname) - AND (vSupplier IS NULL OR p.`name` LIKE CONCAT('%', vSupplier, '%')) - AND (vColor IS NULL OR vColor = i.inkFk) - AND (vSize IS NULL OR vSize = i.`size`) - AND (vOrigen IS NULL OR vOrigen = w.name) - AND (vLack IS NULL OR vLack = lack) - - GROUP BY i.id, w.id - HAVING lack < 0; - - DROP TEMPORARY TABLE tmp.itemMinacum; - DROP TEMPORARY TABLE tmp.itemMinETD; - DROP TEMPORARY TABLE tmp.itemZoneClosure; -END -$$ -DELIMITER ; diff --git a/modules/ticket/back/methods/ticket/itemDetail.sql b/modules/ticket/back/methods/ticket/itemDetail.sql deleted file mode 100644 index 8538378e76..0000000000 --- a/modules/ticket/back/methods/ticket/itemDetail.sql +++ /dev/null @@ -1,38 +0,0 @@ - SELECT - s.id saleFk, - st.code, - t.id ticketFk, - t.nickname, - t.hour, - s.quantity, - ag.name, - ts.alertLevel alertLevel, - st.name stateName, - st.id stateId, - s.itemFk itemFk, - al.code alertLevelCode, - z.name, - z.hour theoreticalhour, - cn.isRookie, - sc.saleClonedFk turno, - tr.saleFk peticionCompra, - t.hour minTimed - FROM - vn.sale s - JOIN vn.ticket t ON t.id=s.ticketFk -- vn.ticket - LEFT JOIN vn.zone z ON z.id = t.zoneFk -- vn.zone - LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk -- AND zc.dated = DateValue(t.Fecha) - JOIN vn.client c ON c.id=t.clientFk -- vn.client - LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id - JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk -- vn.agencyMode - JOIN vn.agency ag ON ag.id=agm.id -- vn.agencyMode - JOIN vn.ticketState ts ON ts.ticketFk=t.id -- vn.sale - LEFT JOIN vn.state st ON st.id=ts.state - LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel - LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id - LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id - WHERE - s.itemFk = ? - AND t.landed >= util.VN_CURDATE() - AND t.landed < INTERVAL util.VN_CURDATE() + INTERVAL ? + 1 DAY - `, diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 0821633924..1d0feda2d4 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -1,5 +1,5 @@ -/* eslint-disable no-console */ -const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const {ParameterizedSQL} = require('loopback-connector'); + module.exports = Self => { Self.remoteMethod('itemLackDetail', { description: 'Download a ticket delivery note document', diff --git a/modules/ticket/back/methods/ticket/itemLackOrigin.js b/modules/ticket/back/methods/ticket/itemLackOrigin.js index 73673c17da..f862852b99 100644 --- a/modules/ticket/back/methods/ticket/itemLackOrigin.js +++ b/modules/ticket/back/methods/ticket/itemLackOrigin.js @@ -1,5 +1,5 @@ +const {ParameterizedSQL} = require('loopback-connector'); -const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; module.exports = Self => { Self.remoteMethod('itemLackOrigin', { description: 'Insert ticket negative into negativeOrigin', diff --git a/modules/ticket/back/methods/ticket/negativeOrigin.js b/modules/ticket/back/methods/ticket/negativeOrigin.js index ee251ff3e0..0324d72bcb 100644 --- a/modules/ticket/back/methods/ticket/negativeOrigin.js +++ b/modules/ticket/back/methods/ticket/negativeOrigin.js @@ -1,5 +1,5 @@ +const {ParameterizedSQL} = require('loopback-connector'); -const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; module.exports = Self => { Self.remoteMethod('negativeOrigin', { description: 'Insert ticket negative into negativeOrigin', diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index 54ba2123a9..afe374aa20 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -32,8 +32,7 @@ module.exports = Self => { tx = await Self.beginTransaction({}); myOptions.transaction = tx; } - // const conn = Self.dataSource.connector; - // const stmts = []; + try { const ticketsIds = tickets.map(({ticketFk}, index) => ticketFk); const ticketsCount = await Self.rawSql(` From 9a80f8c2ceecc11b93a02c1f265a6c7d3f4e19d5 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 2 Apr 2024 10:45:29 +0200 Subject: [PATCH 22/88] minor change --- back/tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/tests.js b/back/tests.js index cfb6814351..824d6ca5ae 100644 --- a/back/tests.js +++ b/back/tests.js @@ -18,7 +18,7 @@ const opts = getopts(process.argv.slice(2), { let server; const PARALLEL = false; const SETUP_TIMEOUT = 15 * 60 * 1000; -const SPEC_TIMEOUT = 30 * 1000; +const SPEC_TIMEOUT = 30 * 10000; process.on('exit', teardown); process.on('uncaughtException', onError); From 586f37afd2169cf8874d2ad253da187444916b3d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 2 Apr 2024 13:28:26 +0200 Subject: [PATCH 23/88] refs #6321 perf: add arguments into procedure --- back/tests.js | 2 +- db/routines/vn/procedures/item_getLack.sql | 41 +++++-- .../ticket/back/methods/ticket/itemLack.js | 108 +++--------------- 3 files changed, 50 insertions(+), 101 deletions(-) diff --git a/back/tests.js b/back/tests.js index 824d6ca5ae..cfb6814351 100644 --- a/back/tests.js +++ b/back/tests.js @@ -18,7 +18,7 @@ const opts = getopts(process.argv.slice(2), { let server; const PARALLEL = false; const SETUP_TIMEOUT = 15 * 60 * 1000; -const SPEC_TIMEOUT = 30 * 10000; +const SPEC_TIMEOUT = 30 * 1000; process.on('exit', teardown); process.on('uncaughtException', onError); diff --git a/db/routines/vn/procedures/item_getLack.sql b/db/routines/vn/procedures/item_getLack.sql index e0531e2ace..17cff02469 100644 --- a/db/routines/vn/procedures/item_getLack.sql +++ b/db/routines/vn/procedures/item_getLack.sql @@ -1,9 +1,20 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`(IN vForce BOOLEAN, IN vDays INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`( + vForce BOOLEAN, + vDays INT, + vId INT, + vLongname INT, + vSupplierFk VARCHAR(255), + vColor VARCHAR(255), + vSize INT, + vOrigen VARCHAR(255), + vLack INT, + vWarehouseFk INT + ) BEGIN /** * Calcula una tabla con el máximo negativo visible para cada producto y almacen - * + * * @param vForce Fuerza el recalculo del stock * @param vDays Numero de dias a considerar **/ @@ -13,33 +24,33 @@ BEGIN CALL item_getMinETD(); CALL item_zoneClosure(); - SELECT i.id itemFk, + SELECT i.id itemFk, i.longName, w.id warehouseFk, - p.`name` producer, + p.`name` producer, i.`size`, i.category, - w.name warehouse, + w.name warehouse, SUM(IFNULL(sub.amount,0)) lack, i.inkFk, IFNULL(im.timed, util.midnight()) timed, IFNULL(izc.timed, util.midnight()) minTimed, o.name originFk - FROM (SELECT item_id, - warehouse_id, + FROM (SELECT item_id, + warehouse_id, amount FROM cache.stock WHERE amount > 0 UNION ALL - SELECT itemFk, - warehouseFk, + SELECT itemFk, + warehouseFk, amount FROM tmp.itemMinacum ) sub JOIN warehouse w ON w.id = sub.warehouse_id JOIN item i ON i.id = sub.item_id - LEFT JOIN producer p ON p.id = i.producerFk - JOIN itemType it ON it.id = i.typeFk + LEFT JOIN producer p ON p.id = i.producerFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id @@ -47,6 +58,14 @@ BEGIN WHERE w.isForTicket AND ic.display AND it.code != 'GEN' + AND (vId IS NULL OR i.id = vId) + AND (vLongname IS NULL OR i.longName = vLongname) + AND (vSupplierFk IS NULL OR p.`name` LIKE CONCAT('%', vSupplierFk, '%')) + AND (vColor IS NULL OR vColor = i.inkFk) + AND (vSize IS NULL OR vSize = i.`size`) + AND (vOrigen IS NULL OR vOrigen = w.name) + AND (vLack IS NULL OR vLack = sub.amount) + AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id) GROUP BY i.id, w.id HAVING lack < 0; diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 932d50b52a..b11ae74d18 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -1,7 +1,3 @@ - -const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; -const {buildFilter} = require('vn-loopback/util/filter'); - module.exports = Self => { Self.remoteMethod('itemLack', { description: 'Download a ticket delivery note document', @@ -34,9 +30,9 @@ module.exports = Self => { description: 'Supplier id', }, { - arg: 'color', + arg: 'colour', type: 'string', - description: 'Color\'s item', + description: 'Colour\'s item', }, { arg: 'size', @@ -48,9 +44,15 @@ module.exports = Self => { type: 'string', description: 'origen id', }, + { + arg: 'warehouse', + type: 'number', + description: 'The warehouse id', + }, { arg: 'lack', - type: 'number', description: 'The item id', + type: 'number', + description: 'The item id', } ], returns: [ @@ -70,91 +72,19 @@ module.exports = Self => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const conn = Self.dataSource.connector; - let where = {}; - filter = Object.assign(ctx.args ?? {}, filter); - where = buildFilter(filter, (param, value) => { - switch (param) { - case 'id': - return {'i.id': value}; - case 'longname': - return {'i.longName': value}; - case 'name': - return {'p.name': {like: `%${value}%`}}; - case 'color': - return {'i.inkFk': value}; - case 'size': - return {'i.size': value}; - case 'origen': - return {'w.id': value}; - case 'lack': - return {'sub.amount': value}; - } - }) ?? {}; + const filterKeyOrder = ['id', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouse']; - const stmts = []; - stmts.push(`SET @_optimizer_search_depth = @@optimizer_search_depth`); - stmts.push(`SET SESSION optimizer_search_depth = 0`); + delete ctx.args.ctx; + delete ctx.args.filter; - stmts.push(`CALL cache.stock_refresh(true)`); - stmts.push(`CALL item_getMinacum(NULL, util.VN_CURDATE(), 2, NULL)`); - stmts.push(`CALL item_getMinETD()`); - stmts.push(`CALL item_zoneClosure()`); + let procedureParams = [true, 2]; + procedureParams.push(...filterKeyOrder.map(clave => ctx.args[clave] ?? null)); + const procedureArgs = Array(procedureParams.length).fill('?').join(', '); + let query = `CALL vn.item_getLack(${procedureArgs})`; - const stmt = new ParameterizedSQL(` - SELECT i.id itemFk, - i.longName, - w.id warehouseFk, - p.name producer, - p.id producerFk, - i.size, - i.category, - w.name warehouse, - SUM(IFNULL(sub.amount,0)) lack, - i.inkFk, - IFNULL(im.timed, util.midnight()) timed, - IFNULL(izc.timed, util.midnight()) minTimed - FROM (SELECT item_id, - warehouse_id, - amount - FROM cache.stock - WHERE amount > 0 - UNION ALL - SELECT itemFk, - warehouseFk, - amount - FROM tmp.itemMinacum - ) sub - JOIN warehouse w ON w.id = sub.warehouse_id - JOIN item i ON i.id = sub.item_id - LEFT JOIN producer p ON p.id = i.producerFk - JOIN itemType it ON it.id = i.typeFk - JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id - LEFT JOIN tmp.itemZoneClosure izc ON izc.itemFk = i.id - `); + const result = await Self.rawSql(query, procedureParams, myOptions); - const sqlWhere = conn.makeWhere(where); - stmt.merge(sqlWhere); - const prefix = Object.keys(where).length > 0 ? 'AND' : 'WHERE'; - stmt.merge(`${prefix} w.isForTicket - AND ic.display - AND it.code != 'GEN'`); - - stmt.merge(` - GROUP BY i.id, w.id - HAVING lack < 0` - ); - stmt.merge(conn.makeSuffix(filter)); - const itemsIndex = stmts.push(stmt) - 1; - stmts.push( - `DROP TEMPORARY TABLE - tmp.itemMinacum, - tmp.itemMinETD, - tmp.itemZoneClosure`); - - const sql = ParameterizedSQL.join(stmts, ';'); - const result = await conn.executeStmt(sql, myOptions); - return itemsIndex === 0 ? result : result[itemsIndex]; + const itemsIndex = 0; + return result[itemsIndex]; }; }; From cc3f2da639862c5c55bccc03eb35b97531868f3f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 2 Apr 2024 15:02:33 +0200 Subject: [PATCH 24/88] refs #6321 perf: minor change --- modules/ticket/back/methods/ticket/itemLackDetail.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 1d0feda2d4..c965267199 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -2,11 +2,11 @@ const {ParameterizedSQL} = require('loopback-connector'); module.exports = Self => { Self.remoteMethod('itemLackDetail', { - description: 'Download a ticket delivery note document', + description: 'Retrieve detail from ticket', accessType: 'READ', accepts: [ { - arg: 'id', + arg: 'itemFk', type: 'number', description: 'The item id', }, @@ -24,7 +24,7 @@ module.exports = Self => { }, }); - Self.itemLackDetail = async(id, options) => { + Self.itemLackDetail = async(itemFk, options) => { const conn = Self.dataSource.connector; const myOptions = {}; @@ -71,7 +71,7 @@ module.exports = Self => { AND t.landed >= util.VN_CURDATE() AND t.landed < util.VN_CURDATE() + INTERVAL ? + 1 DAY `, - [id, 2]); + [itemFk, 2]); const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions); From c4f8734d441b4917f707990e477bc8ac341d090d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 3 Apr 2024 09:48:56 +0200 Subject: [PATCH 25/88] refs #6321 fix: param --- modules/ticket/back/methods/ticket/itemLackDetail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index c965267199..5e9796ee91 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -6,7 +6,7 @@ module.exports = Self => { accessType: 'READ', accepts: [ { - arg: 'itemFk', + arg: 'id', type: 'number', description: 'The item id', }, From 25fc39ef2baee0e1dc454bf660a0a4c3b5442ff5 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 8 Apr 2024 11:33:32 +0200 Subject: [PATCH 26/88] refs #6321 perf: change descriptions --- modules/ticket/back/methods/ticket/itemLack.js | 10 ++-------- modules/ticket/back/methods/ticket/negativeOrigin.js | 2 +- modules/ticket/back/methods/ticket/split.js | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index b11ae74d18..163addc048 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethod('itemLack', { - description: 'Download a ticket delivery note document', + description: 'Get tickets as negative status', accessType: 'READ', accepts: [ { @@ -8,12 +8,6 @@ module.exports = Self => { type: 'object', http: {source: 'context'} }, - { - arg: 'filter', - type: 'object', - description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', - http: {source: 'query'} - }, { arg: 'id', type: 'number', @@ -68,7 +62,7 @@ module.exports = Self => { } }); - Self.itemLack = async(ctx, filter, options) => { + Self.itemLack = async(ctx, options) => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/ticket/back/methods/ticket/negativeOrigin.js b/modules/ticket/back/methods/ticket/negativeOrigin.js index 0324d72bcb..aa043b0f37 100644 --- a/modules/ticket/back/methods/ticket/negativeOrigin.js +++ b/modules/ticket/back/methods/ticket/negativeOrigin.js @@ -2,7 +2,7 @@ const {ParameterizedSQL} = require('loopback-connector'); module.exports = Self => { Self.remoteMethod('negativeOrigin', { - description: 'Insert ticket negative into negativeOrigin', + description: 'Get tickets from negativeOrigin', accessType: 'READ', accepts: [{ arg: 'ctx', diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index afe374aa20..69f6f56d9b 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('split', { - description: 'Split a ticket or n tickets', + description: 'Split n tickets', accessType: 'WRITE', accepts: [ { From 3dd162b683e346f801ddae4a425c694e9bb05499 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 8 Apr 2024 12:16:07 +0200 Subject: [PATCH 27/88] refs #6321 test: fix --- db/routines/vn/procedures/item_getLack.sql | 8 ++++---- .../ticket/back/methods/ticket/itemLack.js | 19 ++++++++++++++++--- .../back/methods/ticket/itemLackDetail.js | 4 ++-- .../methods/ticket/specs/itemLack.spec.js | 6 +++--- .../ticket/specs/itemLackDetail.spec.js | 2 +- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/item_getLack.sql b/db/routines/vn/procedures/item_getLack.sql index 17cff02469..bcb7d89585 100644 --- a/db/routines/vn/procedures/item_getLack.sql +++ b/db/routines/vn/procedures/item_getLack.sql @@ -3,11 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`( vForce BOOLEAN, vDays INT, vId INT, - vLongname INT, + vLongname VARCHAR(255), vSupplierFk VARCHAR(255), vColor VARCHAR(255), vSize INT, - vOrigen VARCHAR(255), + vOrigen INT, vLack INT, vWarehouseFk INT ) @@ -59,11 +59,11 @@ BEGIN AND ic.display AND it.code != 'GEN' AND (vId IS NULL OR i.id = vId) - AND (vLongname IS NULL OR i.longName = vLongname) + AND (vLongname IS NULL OR i.name = vLongname) AND (vSupplierFk IS NULL OR p.`name` LIKE CONCAT('%', vSupplierFk, '%')) AND (vColor IS NULL OR vColor = i.inkFk) AND (vSize IS NULL OR vSize = i.`size`) - AND (vOrigen IS NULL OR vOrigen = w.name) + AND (vOrigen IS NULL OR vOrigen = w.id) AND (vLack IS NULL OR vLack = sub.amount) AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id) GROUP BY i.id, w.id diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 163addc048..278fd8537b 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -8,6 +8,12 @@ module.exports = Self => { type: 'object', http: {source: 'context'} }, + { + arg: 'filter', + type: 'object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'} + }, { arg: 'id', type: 'number', @@ -62,18 +68,25 @@ module.exports = Self => { } }); - Self.itemLack = async(ctx, options) => { + Self.itemLack = async(ctx, filter, options) => { const myOptions = {}; + if (typeof options == 'object') Object.assign(myOptions, options); + const filterKeyOrder = ['id', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouse']; - delete ctx.args.ctx; - delete ctx.args.filter; + delete ctx?.args?.ctx; + + delete ctx?.args?.filter; + if (filter) + ctx.args = Object.assign(ctx.args ?? {}, filter); let procedureParams = [true, 2]; procedureParams.push(...filterKeyOrder.map(clave => ctx.args[clave] ?? null)); + const procedureArgs = Array(procedureParams.length).fill('?').join(', '); + let query = `CALL vn.item_getLack(${procedureArgs})`; const result = await Self.rawSql(query, procedureParams, myOptions); diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 5e9796ee91..f18d5d34e5 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -6,7 +6,7 @@ module.exports = Self => { accessType: 'READ', accepts: [ { - arg: 'id', + arg: 'itemFk', type: 'number', description: 'The item id', }, @@ -19,7 +19,7 @@ module.exports = Self => { }, ], http: { - path: `/itemLack/:id/detail`, + path: `/itemLack/:itemFk/detail`, verb: 'GET', }, }); diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index ded595376d..4d654d8305 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; -describe('Item Lack', () => { - beforeAll(async() => { +fdescribe('Item Lack', () => { + beforeEach(async() => { ctx = { req: { accessToken: {}, @@ -85,7 +85,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - color: 'BRW' + colour: 'BRW' }; try { const result = await models.Ticket.itemLack(ctx, filter, options); diff --git a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js index 9d5a7c6f99..26424d7ce1 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Item Lack Detail', () => { +fdescribe('Item Lack Detail', () => { it('should return false if id is null', async() => { const tx = await models.Ticket.beginTransaction({}); From e0712645a284618c28541ec75a983d2ece9e2e3d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 8 Apr 2024 12:17:32 +0200 Subject: [PATCH 28/88] refs #6321 test: fix --- modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js index 26424d7ce1..9d5a7c6f99 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Item Lack Detail', () => { +describe('Item Lack Detail', () => { it('should return false if id is null', async() => { const tx = await models.Ticket.beginTransaction({}); From 68158f341d7abde4618f332ebd282a3e03872685 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 22 Apr 2024 14:09:27 +0200 Subject: [PATCH 29/88] feat(salix): refs #6321 #6331 publish negativeOrigin model --- .../back/methods/ticket/negativeOrigin.js | 8 ++----- modules/ticket/back/model-config.json | 3 +++ .../ticket/back/models/negative-origin.json | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 modules/ticket/back/models/negative-origin.json diff --git a/modules/ticket/back/methods/ticket/negativeOrigin.js b/modules/ticket/back/methods/ticket/negativeOrigin.js index aa043b0f37..a6139ae468 100644 --- a/modules/ticket/back/methods/ticket/negativeOrigin.js +++ b/modules/ticket/back/methods/ticket/negativeOrigin.js @@ -1,4 +1,3 @@ -const {ParameterizedSQL} = require('loopback-connector'); module.exports = Self => { Self.remoteMethod('negativeOrigin', { @@ -27,10 +26,7 @@ module.exports = Self => { tx = await Self.beginTransaction({}); myOptions.transaction = tx; } - const conn = Self.dataSource.connector; - const stmts = ['SELECT * FROM vn.negativeOrigin']; - const sql = ParameterizedSQL.join(stmts, ';'); - const result = await conn.executeStmt(sql, myOptions); - return result; + const negativesOrigin = await Self.app.models.NegativeOrigin.find(); + return negativesOrigin; }; }; diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index db90b55e15..94355b5767 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -35,6 +35,9 @@ "PackingSiteConfig": { "dataSource": "vn" }, + "NegativeOrigin": { + "dataSource": "vn" + }, "ExpeditionMistake": { "dataSource": "vn" }, diff --git a/modules/ticket/back/models/negative-origin.json b/modules/ticket/back/models/negative-origin.json new file mode 100644 index 0000000000..0f43cce9d4 --- /dev/null +++ b/modules/ticket/back/models/negative-origin.json @@ -0,0 +1,23 @@ +{ + "name": "NegativeOrigin", + "base": "VnModel", + "options": { + "mysql": { + "table": "negativeOrigin" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + } + }, + "relations": { + "item": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "itemFk" + } + } + } From 7caea444274d55e89d96d1f5abd99bfbdc1f870a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 2 May 2024 13:53:28 +0200 Subject: [PATCH 30/88] feat(salix): refs #6321 #6321 getSimilar --- modules/item/back/methods/item/getSimilar.js | 59 ++++++++++++++++++++ modules/item/back/models/item.js | 1 + 2 files changed, 60 insertions(+) create mode 100644 modules/item/back/methods/item/getSimilar.js diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js new file mode 100644 index 0000000000..3ec72e1b12 --- /dev/null +++ b/modules/item/back/methods/item/getSimilar.js @@ -0,0 +1,59 @@ +module.exports = Self => { + Self.remoteMethodCtx('getSimilar', { + description: 'Returns the ', + accessType: 'READ', + accepts: [{ + arg: 'filter', + type: 'Object', + required: true, + description: 'Filter defining where and paginated data', + http: {source: 'query'} + }], + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/getSimilar`, + verb: 'GET' + } + }); + + Self.getSimilar = async(ctx, filter, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + // const where = filter.where; + // const query = 'CALL vn.item_getSimilar(?, ?, ?)'; + // const [results] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); + + return [ + { + 'id': 1, + 'longName': 'Ranged weapon longbow 200cm', + 'subName': 'Stark Industries', + 'tag5': 'Color', + 'value5': 'Brown', + 'match5': 0, + 'match6': 0, + 'match7': 0, + 'match8': 1, + 'tag6': 'Categoria', + 'value6': '+1 precission', + 'tag7': 'Tallos', + 'value7': '1', + 'tag8': null, + 'value8': null, + 'available': 185, + 'calc_id': 6, + 'counter': 0, + 'minQuantity': 1, + 'visible': null, + 'price2': null + } + + ]; + }; +}; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index e715ab4313..ec0d408403 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -5,6 +5,7 @@ module.exports = Self => { require('../methods/item/clone')(Self); require('../methods/item/updateTaxes')(Self); require('../methods/item/getBalance')(Self); + require('../methods/item/getSimilar')(Self); require('../methods/item/lastEntriesFilter')(Self); require('../methods/item/getSummary')(Self); require('../methods/item/getCard')(Self); From de7469419aac85433776e1d66fdff60f504627a9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 3 May 2024 07:23:12 +0200 Subject: [PATCH 31/88] feat(salix): refs #6321 #6321 getSimilar minor update --- modules/item/back/methods/item/getSimilar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 3ec72e1b12..84bb351afe 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -26,8 +26,8 @@ module.exports = Self => { Object.assign(myOptions, options); // const where = filter.where; - // const query = 'CALL vn.item_getSimilar(?, ?, ?)'; - // const [results] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); + // const query = [where.itemFk, where.warehouseFk, where.date ?? Date.now(), where.showType ?? true] ; + // const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?)',, myOptions); return [ { From 888f15049ab74633ad31769ddcee9bc43300bea9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 13 May 2024 13:51:04 +0200 Subject: [PATCH 32/88] feat(salix): refs #6321 #6321 New arg --- modules/ticket/back/methods/ticket/itemLack.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 278fd8537b..58ab9a6470 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -53,6 +53,11 @@ module.exports = Self => { arg: 'lack', type: 'number', description: 'The item id', + }, + { + arg: 'days', + type: 'number', + description: 'The range days', } ], returns: [ @@ -74,7 +79,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const filterKeyOrder = ['id', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouse']; + const filterKeyOrder = ['days', 'id', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouse']; delete ctx?.args?.ctx; @@ -82,7 +87,7 @@ module.exports = Self => { if (filter) ctx.args = Object.assign(ctx.args ?? {}, filter); - let procedureParams = [true, 2]; + let procedureParams = [true]; procedureParams.push(...filterKeyOrder.map(clave => ctx.args[clave] ?? null)); const procedureArgs = Array(procedureParams.length).fill('?').join(', '); From befc1289505198b9dc2cd2e92f0d2876432ba0c0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 15 May 2024 08:36:13 +0200 Subject: [PATCH 33/88] feat(salix): refs #6321 Sale_itemReplace --- .../ticket/back/methods/sale/replaceItem.js | 53 +++++++++++++++++++ modules/ticket/back/models/sale.js | 1 + 2 files changed, 54 insertions(+) create mode 100644 modules/ticket/back/methods/sale/replaceItem.js diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js new file mode 100644 index 0000000000..529d429eb1 --- /dev/null +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -0,0 +1,53 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('replaceItem', { + description: 'Replace item from sale', + accessType: 'WRITE', + accepts: [{ + arg: 'saleFk', + type: 'number', + required: true, + }, + { + arg: 'newItemFk', + type: 'number', + required: true + }, + { + arg: 'quantity', + type: 'number', + required: true + } + ], + returns: { + type: 'object', + root: true + }, + http: { + path: `/recalculatePrice`, + verb: 'POST' + } + }); + + Self.recalculatePrice = async(ctx, saleFk, itemFk, quantity, 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; + } + + try { + const result = await Self.rawSql('CALL sale_replaceItem(?,?,?)', [saleFk, itemFk, quantity], myOptions); + return result; + } 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 1b4d8e31c1..6aa542050f 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -13,6 +13,7 @@ module.exports = Self => { require('../methods/sale/usesMana')(Self); require('../methods/sale/clone')(Self); require('../methods/sale/getFromSectorCollection')(Self); + require('../methods/sale/replaceItem')(Self); Self.validatesPresenceOf('concept', { message: `Concept cannot be blank` From 4fe1d80e7c19c0e00ea9e6e529cbf988d51695f1 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 24 May 2024 14:00:41 +0200 Subject: [PATCH 34/88] feat(salix): refs #6321 default value when days is not present --- modules/ticket/back/methods/ticket/itemLack.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 58ab9a6470..c48ecc09c7 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -90,6 +90,7 @@ module.exports = Self => { let procedureParams = [true]; procedureParams.push(...filterKeyOrder.map(clave => ctx.args[clave] ?? null)); + if (!procedureParams[1])procedureParams[1] = 2; const procedureArgs = Array(procedureParams.length).fill('?').join(', '); let query = `CALL vn.item_getLack(${procedureArgs})`; From 7468f87808cee2fad88dd4c9597e7984b3e22878 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 30 May 2024 07:46:10 +0200 Subject: [PATCH 35/88] feat(salix): refs #6321 #6321 improve split mehtod --- modules/ticket/back/methods/ticket/split.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index 69f6f56d9b..cd821c019b 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -66,7 +66,8 @@ module.exports = Self => { await Self.transferSales(ctx, tid, vNewTicket, sales, myOptions); await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [tid, 'FIXING'], myOptions); - results.push({ticket: tid, status: 'split'}); + results.push({ticket: tid, newTicket: vNewTicket, status: 'split'}); + await tx.commit(); } catch ({message}) { results.push({ticket: tid, status: 'error', message}); } From 64a4a7830826401284d5ccedc1ba4eec5be39f31 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 10 Jun 2024 17:09:25 +0200 Subject: [PATCH 36/88] feat(salix): refs #6321 updates --- db/routines/vn/procedures/item_getSimilar.sql | 9 ++++++++- modules/item/back/methods/item/getSimilar.js | 8 ++++---- modules/ticket/back/methods/ticket/itemLackDetail.js | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 762c253423..63d2c05d95 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -66,7 +66,14 @@ BEGIN ELSE 1 END AS minQuantity, iss.visible located, - b.price2 + b.price, + b.price1, + b.price2, + b.price3, + a.price, + a.price1, + a.price2, + a.price3, FROM vn.item i JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vCalcFk diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 84bb351afe..f8115fb5e0 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -25,9 +25,9 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - // const where = filter.where; - // const query = [where.itemFk, where.warehouseFk, where.date ?? Date.now(), where.showType ?? true] ; - // const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?)',, myOptions); + const where = filter.where; + const query = [where.itemFk, where.warehouseFk, where.date ?? Date.now(), where.showType ?? true]; + const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?)', query, myOptions); return [ { @@ -51,7 +51,7 @@ module.exports = Self => { 'counter': 0, 'minQuantity': 1, 'visible': null, - 'price2': null + 'price2': 1 } ]; diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index f18d5d34e5..9c9ffd0108 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -45,6 +45,7 @@ module.exports = Self => { st.name stateName, st.id stateId, s.itemFk itemFk, + s.price price, al.code alertLevelCode, z.name zoneName, z.hour theoreticalhour, From 2cbd610bc2355ff553d6cf31c6f9d445731a773f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 12 Jun 2024 22:19:59 +0200 Subject: [PATCH 37/88] perf(salix): refs #6321 #7563 add ink.showOrder to procedure --- db/routines/vn/procedures/item_getSimilar.sql | 11 +++-------- modules/item/back/methods/item/getSimilar.js | 6 +++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 63d2c05d95..318945c086 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -66,14 +66,7 @@ BEGIN ELSE 1 END AS minQuantity, iss.visible located, - b.price, - b.price1, - b.price2, - b.price3, - a.price, - a.price1, - a.price2, - a.price3, + b.price2 FROM vn.item i JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vCalcFk @@ -87,6 +80,7 @@ BEGIN LEFT JOIN vn.buy b ON b.id = lb.buy_id LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id AND iss.warehouseFk = vWarehouseFk + LEFT JOIN vn.ink ink ON ink.id = i.tag5 JOIN itemTags its WHERE a.available > 0 AND (i.typeFk = its.typeFk OR NOT vShowType) @@ -95,6 +89,7 @@ BEGIN (t.name = its.name) DESC, (it.value = its.value) DESC, (i.tag5 = its.tag5) DESC, + (ink.`showOrder`) DESC, match5 DESC, (i.tag6 = its.tag6) DESC, match6 DESC, diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index f8115fb5e0..1fc39cb1c6 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -26,7 +26,11 @@ module.exports = Self => { Object.assign(myOptions, options); const where = filter.where; - const query = [where.itemFk, where.warehouseFk, where.date ?? Date.now(), where.showType ?? true]; + const today = + new Date().toLocaleDateString('es-ES', {year: 'numeric', + month: '2-digit', + day: '2-digit'}); + const query = [where.itemFk, where.warehouseFk, where.date ?? today, where.showType ?? true]; const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?)', query, myOptions); return [ From e45ac6424c10815a96f6ac115d871a012cd1e21b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 14 Jun 2024 11:43:06 +0200 Subject: [PATCH 38/88] perf(salix): refs #6321 #6321 updates --- modules/ticket/back/methods/sale/replaceItem.js | 4 ++-- modules/ticket/back/methods/ticket/itemLackDetail.js | 1 + modules/ticket/back/methods/ticket/specs/itemLack.spec.js | 2 +- modules/ticket/back/methods/ticket/split.js | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js index 529d429eb1..c153ee5d2a 100644 --- a/modules/ticket/back/methods/sale/replaceItem.js +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -25,12 +25,12 @@ module.exports = Self => { root: true }, http: { - path: `/recalculatePrice`, + path: `/replaceItem`, verb: 'POST' } }); - Self.recalculatePrice = async(ctx, saleFk, itemFk, quantity, options) => { + Self.replaceItem = async(ctx, saleFk, itemFk, quantity, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; let tx; diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 9c9ffd0108..33beec5055 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -47,6 +47,7 @@ module.exports = Self => { s.itemFk itemFk, s.price price, al.code alertLevelCode, + z.id zoneFk, z.name zoneName, z.hour theoreticalhour, cn.isRookie, diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index 4d654d8305..4ca82b24d3 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Item Lack', () => { +describe('Item Lack', () => { beforeEach(async() => { ctx = { req: { diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index cd821c019b..83a4e8b0ce 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -36,7 +36,8 @@ module.exports = Self => { try { const ticketsIds = tickets.map(({ticketFk}, index) => ticketFk); const ticketsCount = await Self.rawSql(` - Select t.id tid, s.id sid, count(s.id) count from + Select t.id tid, s.id sid, count(s.id) count + FROM vn.ticket t LEFT JOIN vn.sale s ON s.ticketFk = t.id From dba76a4f6b6a3caf86b54fe13e65b7b3e652d24b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 17 Jun 2024 12:38:36 +0200 Subject: [PATCH 39/88] test(Salix): refs #6321 #6321 add default items as Proposal --- modules/item/back/methods/item/getSimilar.js | 50 +++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 1fc39cb1c6..6fbda4018a 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -36,7 +36,7 @@ module.exports = Self => { return [ { 'id': 1, - 'longName': 'Ranged weapon longbow 200cm', + 'longName': 'Ranged weapon longbow 50cm', 'subName': 'Stark Industries', 'tag5': 'Color', 'value5': 'Brown', @@ -50,12 +50,58 @@ module.exports = Self => { 'value7': '1', 'tag8': null, 'value8': null, - 'available': 185, + 'available': 20, 'calc_id': 6, 'counter': 0, 'minQuantity': 1, 'visible': null, 'price2': 1 + }, + { + 'id': 2, + 'longName': 'Ranged weapon longbow 100cm', + 'subName': 'Stark Industries', + 'tag5': 'Color', + 'value5': 'Brown', + 'match5': 0, + 'match6': 1, + 'match7': 0, + 'match8': 1, + 'tag6': 'Categoria', + 'value6': '+1 precission', + 'tag7': 'Tallos', + 'value7': '1', + 'tag8': null, + 'value8': null, + 'available': 50, + 'calc_id': 6, + 'counter': 1, + 'minQuantity': 5, + 'visible': null, + 'price2': 10 + }, + { + 'id': 3, + 'longName': 'Ranged weapon longbow 200cm', + 'subName': 'Stark Industries', + 'tag5': 'Color', + 'value5': 'Brown', + 'match5': 1, + 'match6': 1, + 'match7': 1, + 'match8': 1, + 'tag6': 'Categoria', + 'value6': '+1 precission', + 'tag7': 'Tallos', + 'value7': '1', + 'tag8': null, + 'value8': null, + 'available': 185, + 'calc_id': 6, + 'counter': 10, + 'minQuantity': 10, + 'visible': null, + 'price2': 100 } ]; From e87c8ee5a78e8ec522928233460e264730e5f9a8 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 18 Jun 2024 13:17:29 +0200 Subject: [PATCH 40/88] feat(Salix): refs #6321 #6427 change url endpoint --- modules/ticket/back/methods/ticket/itemLackDetail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 33beec5055..dbd0018b08 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -19,7 +19,7 @@ module.exports = Self => { }, ], http: { - path: `/itemLack/:itemFk/detail`, + path: `/itemLack/:itemFk`, verb: 'GET', }, }); From 14e14eea2a2c84102916a3e766cd3938c2592289 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 3 Jul 2024 23:02:28 +0200 Subject: [PATCH 41/88] feat(salix): refs #7380 #7380 client.substitutionAllowed new field --- db/versions/11132-aquaDracena/00-firstScript.sql | 1 + modules/client/back/models/client.json | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 db/versions/11132-aquaDracena/00-firstScript.sql diff --git a/db/versions/11132-aquaDracena/00-firstScript.sql b/db/versions/11132-aquaDracena/00-firstScript.sql new file mode 100644 index 0000000000..d309098c59 --- /dev/null +++ b/db/versions/11132-aquaDracena/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.client ADD substitutionAllowed BOOL DEFAULT false NULL; diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index f3eb9919b6..97c2a3624b 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -53,6 +53,9 @@ "isActive": { "type": "boolean" }, + "substitutionAllowed": { + "type": "boolean" + }, "credit": { "type": "number" }, From 8b72b7211e20a653f520c1c69e8c3656403c9cad Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 3 Jul 2024 23:02:47 +0200 Subject: [PATCH 42/88] feat(salix): refs #7380 #7380 new typeObservation --- db/versions/11132-aquaDracena/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/versions/11132-aquaDracena/00-firstScript.sql b/db/versions/11132-aquaDracena/00-firstScript.sql index d309098c59..1b304c1d05 100644 --- a/db/versions/11132-aquaDracena/00-firstScript.sql +++ b/db/versions/11132-aquaDracena/00-firstScript.sql @@ -1 +1,4 @@ +INSERT IGNORE INTO vn.observationType (`description`,code,hasNewBornMessage) + VALUES ('Sustitución','substitution',0); + ALTER TABLE vn.client ADD substitutionAllowed BOOL DEFAULT false NULL; From 99efdffe58daeca312f503a82204fc1adf1caa0b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 4 Jul 2024 09:39:06 +0200 Subject: [PATCH 43/88] feat(salix): refs #6321 #6321 retrieve observationType --- db/dump/fixtures.before.sql | 4 ++-- db/versions/10936-wheatAnthurium/00-updateACL.sql | 2 +- db/versions/11132-aquaDracena/00-firstScript.sql | 2 ++ modules/ticket/back/methods/ticket/itemLackDetail.js | 8 +++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 49f195dac1..b78b082bc8 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1059,7 +1059,6 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), @@ -3123,11 +3122,12 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (4, 1103, 4, 32), (13, 1101, 1, NULL), (14, 1101, 4, 27); + INSERT INTO cache.stock (warehouse_id,item_id,amount) VALUES (60,1,25), (13,1,-20), (4,1,-1000); - -- Auto-generated SQL script #202401220930 + UPDATE vn.warehouse SET isForTicket=1 WHERE id=2; diff --git a/db/versions/10936-wheatAnthurium/00-updateACL.sql b/db/versions/10936-wheatAnthurium/00-updateACL.sql index 32acce8a2b..58c121e211 100644 --- a/db/versions/10936-wheatAnthurium/00-updateACL.sql +++ b/db/versions/10936-wheatAnthurium/00-updateACL.sql @@ -1,4 +1,4 @@ -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) +INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'), ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'), diff --git a/db/versions/11132-aquaDracena/00-firstScript.sql b/db/versions/11132-aquaDracena/00-firstScript.sql index 1b304c1d05..d02901f2bd 100644 --- a/db/versions/11132-aquaDracena/00-firstScript.sql +++ b/db/versions/11132-aquaDracena/00-firstScript.sql @@ -2,3 +2,5 @@ INSERT IGNORE INTO vn.observationType (`description`,code,hasNewBornMessage) VALUES ('Sustitución','substitution',0); ALTER TABLE vn.client ADD substitutionAllowed BOOL DEFAULT false NULL; + +ALTER TABLE vn.negativeOrigin MODIFY COLUMN `type` enum('FALTAS','CONTENEDOR','ENTRADAS','OVERBOOKING', 'SUSTITUCION') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL; diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index dbd0018b08..68cab8a27a 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -53,7 +53,11 @@ module.exports = Self => { cn.isRookie, IF(sc.saleClonedFk, 1, 0 ) as turno, IF(tr.saleFk , 1, 0 ) as peticionCompra, - t.hour minTimed + t.hour minTimed, + c.id customerId, + c.name customerName, + c.substitutionAllowed, + ot.code observationTypeCode FROM vn.sale s JOIN vn.ticket t ON t.id=s.ticketFk @@ -68,6 +72,8 @@ module.exports = Self => { LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id + LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk WHERE s.itemFk = ? AND t.landed >= util.VN_CURDATE() From 212f84aa9ba927f4ae2424c00828e945f82f4977 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Jul 2024 11:41:33 +0200 Subject: [PATCH 44/88] revert commit --- db/versions/11132-aquaDracena/00-firstScript.sql | 5 ----- modules/client/back/models/client.json | 3 --- 2 files changed, 8 deletions(-) diff --git a/db/versions/11132-aquaDracena/00-firstScript.sql b/db/versions/11132-aquaDracena/00-firstScript.sql index d02901f2bd..8d813ffd3a 100644 --- a/db/versions/11132-aquaDracena/00-firstScript.sql +++ b/db/versions/11132-aquaDracena/00-firstScript.sql @@ -1,6 +1 @@ -INSERT IGNORE INTO vn.observationType (`description`,code,hasNewBornMessage) - VALUES ('Sustitución','substitution',0); - -ALTER TABLE vn.client ADD substitutionAllowed BOOL DEFAULT false NULL; - ALTER TABLE vn.negativeOrigin MODIFY COLUMN `type` enum('FALTAS','CONTENEDOR','ENTRADAS','OVERBOOKING', 'SUSTITUCION') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL; diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index e737e4352b..f24f69ae77 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -53,9 +53,6 @@ "isActive": { "type": "boolean" }, - "substitutionAllowed": { - "type": "boolean" - }, "credit": { "type": "number" }, From 7e8c2eebe52644bae70924fe92532524302f4031 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Jul 2024 19:38:21 +0200 Subject: [PATCH 45/88] feat: refs #6321 restore fixtures.before.sql --- db/dump/fixtures.before.sql | 47 ++++++++----------- .../back/methods/ticket/itemLackDetail.js | 1 - 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 4dd5f6ff6a..fffdcf7dff 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -963,25 +963,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('VT', 'Sales'); INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, - `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`, `category`) + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`) VALUES - (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3, 'SEL'), - (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2, 'SEL'), - (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5, 'SEL'), - (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), - (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), - (6, 5, 1, 2, NULL, 1, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), - (7, 5, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), - (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), - (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 'SEL'), - (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), - (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), - (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'), - (13, 5, 1, 2, NULL, 1, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL, 'SEL'), - (14, 5, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 'SEL'), - (15, 4, NULL, 1, NULL, 1, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 'SEL'), - (16, 6, NULL, 1, NULL, 1, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 'SEL'), - (71, 6, NULL, 1, NULL, 2, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 'SEL'); + (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3), + (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2), + (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5), + (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), + (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), + (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL), + (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), + (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), + (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), + (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL); -- Update the taxClass after insert of the items UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 @@ -1082,6 +1082,7 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), @@ -3149,16 +3150,6 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) (13, 1101, 1, NULL), (14, 1101, 4, 27); -INSERT INTO cache.stock (warehouse_id,item_id,amount) VALUES - (60,1,25), - (13,1,-20), - (4,1,-1000); - -UPDATE vn.warehouse - SET isForTicket=1 - WHERE id=2; - - INSERT INTO `vn`.`entryDms`(`entryFk`, `dmsFk`, `editorFk`) VALUES (1, 9, 9); diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 68cab8a27a..6409951f1a 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -56,7 +56,6 @@ module.exports = Self => { t.hour minTimed, c.id customerId, c.name customerName, - c.substitutionAllowed, ot.code observationTypeCode FROM vn.sale s From c9c9d5973d360f5a7794537efd539b7978d5aa13 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 20 Jul 2024 00:36:59 +0200 Subject: [PATCH 46/88] test(salix): refs #6321 #6321 fix test --- db/dump/fixtures.before.sql | 9 +++++++++ .../back/methods/route/specs/unlink.spec.js | 2 +- modules/ticket/back/methods/ticket/itemLack.js | 6 +++--- .../back/methods/ticket/specs/itemLack.spec.js | 16 ++++++++-------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index fffdcf7dff..26210bcc8d 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3953,3 +3953,12 @@ VALUES (4, 'Referencia Transferencias'), (5, 'Referencia Nominas'), (6, 'ABA'); +INSERT INTO `vn`.`item` (id,name,`size`,stems,minPrice,isToPrint,family,box,originFk,doPhoto,image,inkFk,intrastatFk,hasMinPrice,created,typeFk,generic,density,relevancy,expenseFk,isActive,longName,subName,tag5,value5,tag6,value6,tag7,value7,minimum,upToDown,hasKgPrice,isFloramondo,isFragile,stemMultiplier,isLaid,lastUsed,editorFk,isBoxPickingMode) + VALUES + (88,'Lack negative',200,1,10.0,0,'VT',0,2,0,'','WHT',6021010,1,'2024-07-19 11:27:32.000',1,0,167,0,'4751000000',1,'Lack negative origin','Stark Industries','Color','White','Categoria','supply','Tallos','1',3,0,0,0,0,1.0,0,'2024-07-19 11:27:32.000',100,0); + +INSERT INTO `vn`.`ticket` (id, clientFk,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,problem,risk) VALUES + (1000000, 1,1,'2001-01-01 00:00:00.000','employee',NULL,131,NULL,NULL,0,0,0,0,NULL,0,'2024-07-19 23:32:48.000',1,NULL,NULL,NULL,1,442,1,'2001-01-01',0,0,1,1.00,0.00,0.00,NULL,NULL,NULL,NULL,9,'',NULL); + +INSERT INTO `vn`.`sale` (id, itemFk,ticketFk,concept,quantity,originalQuantity,price,discount,priceFixed,reserved,isPicked,isPriceFixed,created,isAdded,total,editorFk,problem) VALUES + (43, 88,1000000,'Chest medical box 2',155.00,155.0,0.00,0,0.00,0,0,0,'2024-07-19 23:33:08.000',0,0.00,100,''); diff --git a/modules/route/back/methods/route/specs/unlink.spec.js b/modules/route/back/methods/route/specs/unlink.spec.js index 808cedccc1..a543ab4163 100644 --- a/modules/route/back/methods/route/specs/unlink.spec.js +++ b/modules/route/back/methods/route/specs/unlink.spec.js @@ -21,7 +21,7 @@ describe('route unlink()', () => { zoneAgencyModes = await models.ZoneAgencyMode.find(null, options); tickets = await models.Route.getSuggestedTickets(routeId, options); - expect(zoneAgencyModes.length).toEqual(3); + expect(zoneAgencyModes.length).toEqual(4); expect(tickets.length).toEqual(0); await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index c48ecc09c7..6430a63ab4 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -15,7 +15,7 @@ module.exports = Self => { http: {source: 'query'} }, { - arg: 'id', + arg: 'itemFk', type: 'number', description: 'The item id', }, @@ -45,7 +45,7 @@ module.exports = Self => { description: 'origen id', }, { - arg: 'warehouse', + arg: 'warehouseFk', type: 'number', description: 'The warehouse id', }, @@ -79,7 +79,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const filterKeyOrder = ['days', 'id', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouse']; + const filterKeyOrder = ['days', 'itemFk', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouseFk']; delete ctx?.args?.ctx; diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index 4ca82b24d3..2fe9287748 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Item Lack', () => { +fdescribe('Item Lack', () => { beforeEach(async() => { ctx = { req: { @@ -18,7 +18,7 @@ describe('Item Lack', () => { try { const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(4); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -31,7 +31,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - id: 1 + id: 88 }; try { const result = await models.Ticket.itemLack(ctx, filter, options); @@ -49,7 +49,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - longname: 'Ranged weapon longbow 200cm' + longname: 'Lack negative' }; try { const result = await models.Ticket.itemLack(ctx, filter, options); @@ -85,7 +85,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - colour: 'BRW' + colour: 'WHT' }; try { const result = await models.Ticket.itemLack(ctx, filter, options); @@ -103,12 +103,12 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - origen: 2 + origen: 1 }; try { const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(3); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -139,7 +139,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - lack: '-100' + lack: '-155' }; try { const result = await models.Ticket.itemLack(ctx, filter, options); From b2d58a1d6f854d0bdb3e89ab7e588e4cfdb61971 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 22 Jul 2024 17:30:25 +0200 Subject: [PATCH 47/88] Merge branch 'dev' into 6321_negative_tickets --- loopback/locale/en.json | 3 ++- .../back/methods/route/specs/getSuggestedTickets.spec.js | 2 +- modules/route/back/methods/route/specs/unlink.spec.js | 4 ++-- modules/ticket/back/methods/ticket/specs/itemLack.spec.js | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 382a2824c7..f071c91628 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -233,5 +233,6 @@ "It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated", "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated", "Cannot add holidays on this day": "Cannot add holidays on this day", - "Cannot send mail": "Cannot send mail" + "Cannot send mail": "Cannot send mail", + "This worker already exists": "This worker already exists" } \ No newline at end of file diff --git a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js index 0acc6c1a7b..3d6702482d 100644 --- a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js +++ b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js @@ -31,7 +31,7 @@ describe('route getSuggestedTickets()', () => { const length = result.length; const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - expect(result.length).toEqual(4); + expect(result.length).toEqual(5); expect(anyResult.zoneFk).toEqual(1); expect(anyResult.agencyModeFk).toEqual(8); diff --git a/modules/route/back/methods/route/specs/unlink.spec.js b/modules/route/back/methods/route/specs/unlink.spec.js index a543ab4163..9d1f48be8b 100644 --- a/modules/route/back/methods/route/specs/unlink.spec.js +++ b/modules/route/back/methods/route/specs/unlink.spec.js @@ -14,14 +14,14 @@ describe('route unlink()', () => { let tickets = await models.Route.getSuggestedTickets(routeId, options); expect(zoneAgencyModes.length).toEqual(4); - expect(tickets.length).toEqual(3); + expect(tickets.length).toEqual(4); await models.Route.unlink(agencyModeId, zoneId, options); zoneAgencyModes = await models.ZoneAgencyMode.find(null, options); tickets = await models.Route.getSuggestedTickets(routeId, options); - expect(zoneAgencyModes.length).toEqual(4); + expect(zoneAgencyModes.length).toEqual(3); expect(tickets.length).toEqual(0); await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index 2fe9287748..93dce11b27 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Item Lack', () => { +describe('Item Lack', () => { beforeEach(async() => { ctx = { req: { @@ -36,7 +36,7 @@ fdescribe('Item Lack', () => { try { const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(1); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { await tx.rollback(); From 94f99ccee1f2ff8f61708dc8019405f58af9a130 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 11 Sep 2024 11:58:58 +0200 Subject: [PATCH 48/88] fix(salix): refs #6321 #6321 remove ticketMethod clone --- modules/ticket/back/models/ticket-methods.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 1a113b2c52..486e9f9351 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -46,7 +46,6 @@ module.exports = function(Self) { require('../methods/ticket/invoiceTicketsAndPdf')(Self); require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/myLastModified')(Self); - require('../methods/ticket/clone')(Self); require('../methods/ticket/itemLack')(Self); require('../methods/ticket/itemLackDetail')(Self); require('../methods/ticket/itemLackOrigin')(Self); From e76e2a15f2f63e122eb0ce5b28d8febeb9f4138e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 13 Sep 2024 09:44:09 +0200 Subject: [PATCH 49/88] feat(salix): refs #6321 #6321 TODO --- .../ticket/back/methods/ticket/itemLackDetail.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 6409951f1a..ab6e904c4d 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -10,6 +10,12 @@ module.exports = Self => { type: 'number', description: 'The item id', }, + { + arg: 'filter', + type: 'object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'} + } ], returns: [ { @@ -24,7 +30,7 @@ module.exports = Self => { }, }); - Self.itemLackDetail = async(itemFk, options) => { + Self.itemLackDetail = async(itemFk, filter, options) => { const conn = Self.dataSource.connector; const myOptions = {}; @@ -80,6 +86,11 @@ module.exports = Self => { `, [itemFk, 2]); + // if (filter.where.alertLevel) { + // stmt.merge({ + // sql: `AND ts.alertLevel=?`, params: ['FREE']}); + // } + // stmt.merge(conn.makeWhere(filter)); const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions); return result; From 36297009e11dc13ba1e8ff3c6d31758937f56b5f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 17 Sep 2024 16:43:09 +0200 Subject: [PATCH 50/88] perf(salix): refs #6321 #7677 itemLackDetail --- modules/ticket/back/methods/ticket/itemLackDetail.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index ab6e904c4d..55ea167fc0 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -87,10 +87,10 @@ module.exports = Self => { [itemFk, 2]); // if (filter.where.alertLevel) { - // stmt.merge({ - // sql: `AND ts.alertLevel=?`, params: ['FREE']}); + stmt.merge({ + sql: `AND ${filter.where.alertLevel ? '' : 'NOT'} ts.alertLevel=?`, params: [0]}); // } - // stmt.merge(conn.makeWhere(filter)); + // stmt.merge(conn.makeWhere(filter.where)); const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions); return result; From 2cb57225ffbbc0824242a22d3b68142371aa765e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 21 Sep 2024 00:26:55 +0200 Subject: [PATCH 51/88] perf(salix): refs #6321 #7677 itemLackDetail --- db/dump/fixtures.before.sql | 3 --- modules/item/back/methods/item/getSimilar.js | 10 ++++++++-- .../monitor/back/methods/sales-monitor/salesFilter.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 266dfbea50..3c80e353ed 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3969,7 +3969,6 @@ INSERT INTO vn.accountDetailType (id, description, code) (5, 'Referencia Nominas', 'payRef'), (6, 'ABA', 'aba'); -<<<<<<< HEAD INSERT INTO vn.accountDetailType (id, description, code) VALUES @@ -3980,8 +3979,6 @@ VALUES (5, 'Referencia Nominas', 'payRef'), (6, 'ABA', 'aba'); -======= ->>>>>>> dev INSERT IGNORE INTO ormConfig SET id =1, selectLimit = 1000; diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 6fbda4018a..37f6faa908 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -30,8 +30,14 @@ module.exports = Self => { new Date().toLocaleDateString('es-ES', {year: 'numeric', month: '2-digit', day: '2-digit'}); - const query = [where.itemFk, where.warehouseFk, where.date ?? today, where.showType ?? true]; - const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?)', query, myOptions); + const query = [ + where.itemFk, + where.warehouseFk, + where.date ?? today, + where.showType ?? true, + where.scopeDays ?? 2 + ]; + const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?, ?)', query, myOptions); return [ { diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 927f49999f..54872e53af 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -385,6 +385,6 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); - return result[ticketsIndex]; + return Array(19).fill().flatMap(() => result[ticketsIndex]); }; }; From c876022fe52cf6714918abc57ced99a057ecb285 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 24 Sep 2024 13:54:32 +0200 Subject: [PATCH 52/88] feat(salix): refs #6321 #6321 TODO --- db/dump/fixtures.before.sql | 12 +----------- db/versions/10936-wheatAnthurium/00-updateACL.sql | 3 ++- loopback/locale/es.json | 3 ++- modules/ticket/back/methods/sale/replaceItem.js | 8 ++++---- modules/ticket/back/models/sale.js | 2 +- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 3c80e353ed..d4f57a634c 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3969,16 +3969,6 @@ INSERT INTO vn.accountDetailType (id, description, code) (5, 'Referencia Nominas', 'payRef'), (6, 'ABA', 'aba'); -INSERT INTO vn.accountDetailType -(id, description, code) -VALUES - (1, 'IBAN', 'iban'), - (2, 'SWIFT', 'swift'), - (3, 'Referencia Remesas', 'remRef'), - (4, 'Referencia Transferencias', 'trnRef'), - (5, 'Referencia Nominas', 'payRef'), - (6, 'ABA', 'aba'); - INSERT IGNORE INTO ormConfig SET id =1, selectLimit = 1000; @@ -3990,4 +3980,4 @@ INSERT INTO `vn`.`ticket` (id, clientFk,warehouseFk,shipped,nickname,refFk,addre (1000000, 1,1,'2001-01-01 00:00:00.000','employee',NULL,131,NULL,NULL,0,0,0,0,NULL,0,'2024-07-19 23:32:48.000',1,NULL,NULL,NULL,1,442,1,'2001-01-01',0,0,1,1.00,0.00,0.00,NULL,NULL,NULL,NULL,9,'',NULL); INSERT INTO `vn`.`sale` (id, itemFk,ticketFk,concept,quantity,originalQuantity,price,discount,priceFixed,reserved,isPicked,isPriceFixed,created,isAdded,total,editorFk,problem) VALUES - (43, 88,1000000,'Chest medical box 2',155.00,155.0,0.00,0,0.00,0,0,0,'2024-07-19 23:33:08.000',0,0.00,100,''); + (43, 88,1000000,'Chest medical box 2',155.00,155.0,10.00,0,0.00,0,0,0,'2024-07-19 23:33:08.000',0,1550.00,100,''); diff --git a/db/versions/10936-wheatAnthurium/00-updateACL.sql b/db/versions/10936-wheatAnthurium/00-updateACL.sql index 58c121e211..2652dff9c8 100644 --- a/db/versions/10936-wheatAnthurium/00-updateACL.sql +++ b/db/versions/10936-wheatAnthurium/00-updateACL.sql @@ -4,4 +4,5 @@ INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'), ('Ticket','itemLackOrigin','WRITE','ALLOW','ROLE','employee'), ('Ticket','split','WRITE','ALLOW','ROLE','employee'), - ('Ticket','negativeOrigin','READ','ALLOW','ROLE','employee'); + ('Ticket','negativeOrigin','READ','ALLOW','ROLE','employee'), + ('Sale','replaceItem','READ','ALLOW','ROLE','employee'); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 49c44a4d83..1fb7ee17c9 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -378,5 +378,6 @@ "The maximum height of the wagon is 200cm": "La altura máxima es 200cm", "The entry does not have stickers": "La entrada no tiene etiquetas", "Too many records": "Demasiados registros", - "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha" + "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha", + "price retrieval failed": "price retrieval failed" } \ No newline at end of file diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js index c153ee5d2a..83f97f326e 100644 --- a/modules/ticket/back/methods/sale/replaceItem.js +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -1,4 +1,3 @@ -const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('replaceItem', { @@ -10,7 +9,7 @@ module.exports = Self => { required: true, }, { - arg: 'newItemFk', + arg: 'substitutionFk', type: 'number', required: true }, @@ -30,9 +29,10 @@ module.exports = Self => { } }); - Self.replaceItem = async(ctx, saleFk, itemFk, quantity, options) => { + Self.replaceItem = async(ctx, saleFk, substitutionFk, quantity, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; let tx; + const {_saleFk, _substitutionFk, _quantity} = ctx.args; if (typeof options == 'object') Object.assign(myOptions, options); @@ -43,7 +43,7 @@ module.exports = Self => { } try { - const result = await Self.rawSql('CALL sale_replaceItem(?,?,?)', [saleFk, itemFk, quantity], myOptions); + const result = await Self.rawSql('CALL sale_replaceItem(?,?,?)', [saleFk, substitutionFk, quantity], myOptions); return result; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 0e135c75b9..137f89ace6 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -13,7 +13,7 @@ module.exports = Self => { require('../methods/sale/usesMana')(Self); require('../methods/sale/clone')(Self); require('../methods/sale/getFromSectorCollection')(Self); - require('../methods/sale/replaceItem')(Self); + // require('../methods/sale/replaceItem')(Self); Self.validatesPresenceOf('concept', { message: `Concept cannot be blank` From c6490f6740e5f70836b7994d80509c5f0384e70b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 24 Sep 2024 22:12:11 +0200 Subject: [PATCH 53/88] feat(salix): refs #6321 #6321 fixtures.before --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index d4f57a634c..4d7e11419f 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3980,4 +3980,4 @@ INSERT INTO `vn`.`ticket` (id, clientFk,warehouseFk,shipped,nickname,refFk,addre (1000000, 1,1,'2001-01-01 00:00:00.000','employee',NULL,131,NULL,NULL,0,0,0,0,NULL,0,'2024-07-19 23:32:48.000',1,NULL,NULL,NULL,1,442,1,'2001-01-01',0,0,1,1.00,0.00,0.00,NULL,NULL,NULL,NULL,9,'',NULL); INSERT INTO `vn`.`sale` (id, itemFk,ticketFk,concept,quantity,originalQuantity,price,discount,priceFixed,reserved,isPicked,isPriceFixed,created,isAdded,total,editorFk,problem) VALUES - (43, 88,1000000,'Chest medical box 2',155.00,155.0,10.00,0,0.00,0,0,0,'2024-07-19 23:33:08.000',0,1550.00,100,''); + (43, 88,1000000,'Chest medical box 2',15.00,155.0,10.00,0,0.00,0,0,0,'2024-07-19 23:33:08.000',0,1550.00,100,''); From 1560c48af239100204c96601c1ffb574cf0ad307 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 20 Jan 2025 14:32:26 +0100 Subject: [PATCH 54/88] feat: refs #6321 improve query --- db/dump/fixtures.before.sql | 9 +- .../ticket/back/methods/sale/replaceItem.js | 21 ++- .../back/methods/ticket/itemLackDetail.js | 141 ++++++++++++------ 3 files changed, 122 insertions(+), 49 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 87c3bd3e54..d74d85d7cd 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -996,7 +996,8 @@ VALUES (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), - (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0); + (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (88, 1, NULL, 1, 'Lack negative origin', 1, 06021010, 4751000000, NULL, 0, '1', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0); -- Update the taxClass after insert of the items @@ -4056,9 +4057,9 @@ INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance) INSERT IGNORE INTO vn.inventoryConfig SET id = 1, supplierFk = 4; -INSERT INTO `vn`.`item` (id,name,`size`,stems,minPrice,isToPrint,family,box,originFk,doPhoto,image,inkFk,intrastatFk,hasMinPrice,created,typeFk,generic,density,relevancy,expenseFk,isActive,longName,subName,tag5,value5,tag6,value6,tag7,value7,minimum,upToDown,hasKgPrice,isFloramondo,isFragile,stemMultiplier,isLaid,lastUsed,editorFk,isBoxPickingMode) - VALUES - (88,'Lack negative',200,1,10.0,0,'VT',0,2,0,'','WHT',6021010,1,'2024-07-19 11:27:32.000',1,0,167,0,'4751000000',1,'Lack negative origin','Stark Industries','Color','White','Categoria','supply','Tallos','1',3,0,0,0,0,1.0,0,'2024-07-19 11:27:32.000',100,0); +-- INSERT INTO `vn`.`item` (id,name,`size`,stems,minPrice,isToPrint,family,box,originFk,doPhoto,image,inkFk,intrastatFk,hasMinPrice,created,typeFk,generic,density,relevancy,expenseFk,isActive,longName,subName,tag5,value5,tag6,value6,tag7,value7,minimum,upToDown,hasKgPrice,isFloramondo,isFragile,stemMultiplier,isLaid,lastUsed,editorFk,isBoxPickingMode) +-- VALUES +-- (88,'Lack negative',200,1,10.0,0,'VT',0,2,0,'','WHT',6021010,1,'2024-07-19 11:27:32.000',1,0,167,0,'4751000000',1,'Lack negative origin','Stark Industries','Color','White','Categoria','supply','Tallos','1',3,0,0,0,0,1.0,0,'2024-07-19 11:27:32.000',100,0); INSERT INTO `vn`.`ticket` (id, clientFk,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,problem,risk) VALUES (1000000, 1,1,'2001-01-01 00:00:00.000','employee',NULL,131,NULL,NULL,0,0,0,0,NULL,0,'2024-07-19 23:32:48.000',1,NULL,NULL,NULL,1,442,1,'2001-01-01',0,0,1,1.00,0.00,0.00,NULL,NULL,NULL,NULL,9,'',NULL); diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js index 83f97f326e..5096d42952 100644 --- a/modules/ticket/back/methods/sale/replaceItem.js +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -32,7 +32,11 @@ module.exports = Self => { Self.replaceItem = async(ctx, saleFk, substitutionFk, quantity, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; let tx; - const {_saleFk, _substitutionFk, _quantity} = ctx.args; + const $t = ctx.req.__; + + const models = Self.app.models; + + // const {_saleFk, _substitutionFk, _quantity} = ctx.args; if (typeof options == 'object') Object.assign(myOptions, options); @@ -43,7 +47,20 @@ module.exports = Self => { } try { - const result = await Self.rawSql('CALL sale_replaceItem(?,?,?)', [saleFk, substitutionFk, quantity], myOptions); + const _replaceItem = {sql: 'CALL sale_replaceItem(?,?,?)', query: [saleFk, substitutionFk, quantity]}; + const result = await Self.rawSql(_replaceItem.sql, _replaceItem.query, myOptions); + const _salesPerson = {sql: 'SELECT vn.client_getSalesPersonByTicket(?)', query: [saleFk.ticket.id]}; + const salesPerson = await Self.rawSql(_salesPerson.query, _salesPerson.sql, myOptions); + const message = $t('negativeReplaced', { + old: itemFk, + oldUrl: `${url}item/${itemFk}/summary`, + new: itemFk, + newUrl: `${url}item/${itemFk}/summary`, + ticket: ticketFk, + ticketUrl: `${url}ticket/${ticketFk}/sale`, + }); + await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); + return result; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 55ea167fc0..d3faad8221 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -10,6 +10,11 @@ module.exports = Self => { type: 'number', description: 'The item id', }, + { + arg: 'warehouseFk', + type: 'number', + description: 'The warehouse id', + }, { arg: 'filter', type: 'object', @@ -30,7 +35,7 @@ module.exports = Self => { }, }); - Self.itemLackDetail = async(itemFk, filter, options) => { + Self.itemLackDetail = async(itemFk, warehouseFk, filter, options) => { const conn = Self.dataSource.connector; const myOptions = {}; @@ -39,56 +44,106 @@ module.exports = Self => { const stmt = new ParameterizedSQL( ` SELECT - s.id saleFk, + s.id, st.code, - t.id ticketFk, + t.id, t.nickname, t.shipped, - t.hour, s.quantity, - ag.name agName, - ts.alertLevel alertLevel, - st.name stateName, - st.id stateId, - s.itemFk itemFk, - s.price price, - al.code alertLevelCode, - z.id zoneFk, - z.name zoneName, - z.hour theoreticalhour, + ag.name, + IF(ISNULL(tls.alertLevel),0,tls.alertLevel) alertLevel, + IF(ISNULL(st.name),'Libre',st.name) stateName, + s.id stateId, + s.itemFk, + al.code AS alertLevelCode, + z.name, + Format(z.hour, "hh:mm") theoreticalhour, cn.isRookie, - IF(sc.saleClonedFk, 1, 0 ) as turno, - IF(tr.saleFk , 1, 0 ) as peticionCompra, - t.hour minTimed, - c.id customerId, - c.name customerName, - ot.code observationTypeCode - FROM - vn.sale s - JOIN vn.ticket t ON t.id=s.ticketFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk - JOIN vn.client c ON c.id=t.clientFk + IF(ISNULL(sc.saleClonedFk),0,1) turno, + IF(ISNULL(tr.saleFk),0,1) peticionCompra, + DATE_FORMAT(IF(HOUR(t.shipped), t.shipped, IF(zc.hour, zc.hour, z.hour)),'%H:%i') minTimed, + FALSE AS isBasket, + substitution.hasSubstitution, + IF(d.code = 'spainTeamVip', 1, 0) hasToIgnore + FROM sale s + LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + INNER JOIN ticket t ON t.id =s.ticketFk + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + AND zc.dated = DATE(t.shipped) + INNER JOIN client c ON c.id=t.clientFk LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id - JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk - JOIN vn.agency ag ON ag.id=agm.id - JOIN vn.ticketState ts ON ts.ticketFk=t.id - LEFT JOIN vn.state st ON st.id=ts.state - LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel - LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id - LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id - LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk - WHERE - s.itemFk = ? - AND t.landed >= util.VN_CURDATE() - AND t.landed < util.VN_CURDATE() + INTERVAL ? + 1 DAY - `, - [itemFk, 2]); + INNER JOIN agencyMode ag ON ag.id=t.agencyModeFk + INNER JOIN ticketState tls ON tls.ticketFk=t.id + LEFT JOIN state st ON st.id=tls.state + LEFT JOIN alertLevel al ON al.id = st.alertLevel + LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.id + LEFT JOIN ticketRequest tr ON tr.saleFk = s.id + LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk + LEFT JOIN department d ON d.id = wd.departmentFk + LEFT JOIN ( + SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) AS hasSubstitution + FROM clientObservation co + INNER JOIN observationType ot ON ot.id = co.observationTypeFk + WHERE ot.code = 'substitution' + GROUP BY co.clientFk + ) AS substitution ON substitution.clientFk = c.id + WHERE warehouseFk = ? + AND s.itemFk = ? + AND s.quantity <> 0 + AND t.shipped >= CURDATE() + AND t.shipped < DATE_ADD(CURDATE(), INTERVAL ? DAY) + AND sgd.saleFk IS NULL + AND (al.code IN ('FREE', 'ON_PREVIOUS') OR al.code IS NULL) + UNION ALL + SELECT r.id, + NULL, + r.orderFk, + c.name, + r.shipment, + r.amount, + ag.name, + NULL, + NULL, + NULL, + r.itemFk, + NULL, + NULL, + NULL, + cn.isRookie, + NULL, + NULL, + NULL, + TRUE, + substitution.hasSubstitution, + IF(d.code = 'spainTeamVip', 1, 0) + FROM hedera.orderRow r + INNER JOIN hedera.order o ON o.id = r.orderFk + INNER JOIN client c ON c.id = o.customer_id + INNER JOIN agencyMode ag ON ag.id=o.agency_id + LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id + LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk + LEFT JOIN department d ON d.id = wd.departmentFk + LEFT JOIN ( + SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasSubstitution + FROM clientObservation co + INNER JOIN observationType ot ON ot.id = co.observationTypeFk + WHERE ot.code = 'substitution' + GROUP BY co.clientFk + ) AS substitution ON substitution.clientFk = c.id + WHERE r.shipment >= CURDATE() + AND r.shipment < DATE_ADD(CURDATE(), INTERVAL ? DAY) + AND r.warehouseFk = ? + AND r.created >= STR_TO_DATE(CURDATE(), '%Y-%m-%d %H:%i:%s') + AND NOT o.confirmed + AND r.itemFk = ? + AND r.amount <> 0 + ORDER BY hasToIgnore, isBasket;`, + [itemFk, warehouseFk, 2, 2, warehouseFk, itemFk]); // if (filter.where.alertLevel) { - stmt.merge({ - sql: `AND ${filter.where.alertLevel ? '' : 'NOT'} ts.alertLevel=?`, params: [0]}); + // stmt.merge({ + // sql: `AND ${filter.where.alertLevel ? '' : 'NOT'} ts.alertLevel=?`, params: [0]}); // } // stmt.merge(conn.makeWhere(filter.where)); const sql = ParameterizedSQL.join([stmt], ';'); From bd54eacda187e55bf575687715d8d53af676a634 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 26 Jan 2025 02:36:39 +0100 Subject: [PATCH 55/88] feat: refs #6321 alternative alertLevel --- modules/ticket/back/methods/ticket/itemLackDetail.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index d3faad8221..f7af046238 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -141,9 +141,10 @@ module.exports = Self => { ORDER BY hasToIgnore, isBasket;`, [itemFk, warehouseFk, 2, 2, warehouseFk, itemFk]); - // if (filter.where.alertLevel) { - // stmt.merge({ - // sql: `AND ${filter.where.alertLevel ? '' : 'NOT'} ts.alertLevel=?`, params: [0]}); + if (filter.where.stateFk) { + stmt.merge({ + sql: `AND ts.alertLevel=?`, params: [filter.where.stateFk]}); + } // } // stmt.merge(conn.makeWhere(filter.where)); const sql = ParameterizedSQL.join([stmt], ';'); From 1a0992da782fbb92ab8a107576cab6ec87f581e7 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 27 Jan 2025 12:04:18 +0100 Subject: [PATCH 56/88] feat: refs #6321 changes --- loopback/locale/en.json | 6 ++- loopback/locale/es.json | 5 ++- loopback/locale/fr.json | 6 ++- loopback/locale/pt.json | 6 ++- .../ticket/back/methods/sale/replaceItem.js | 26 +++++++---- .../ticket/back/methods/ticket/itemLack.js | 2 +- .../back/methods/ticket/itemLackDetail.js | 19 +++----- .../methods/ticket/specs/itemLack.spec.js | 44 +++++++++---------- .../ticket/specs/itemLackDetail.spec.js | 12 +++-- .../back/methods/ticket/specs/split.spec.js | 4 +- modules/ticket/back/methods/ticket/state.js | 4 +- 11 files changed, 75 insertions(+), 59 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 6aad8a4c19..482698ce92 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -254,5 +254,7 @@ "Sales already moved": "Sales already moved", "Holidays to past days not available": "Holidays to past days not available", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", - "Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order." -} \ No newline at end of file + "Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order.", + "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})" + +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index abd2f79a0d..a4a55895b6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -396,5 +396,6 @@ "There are tickets to be invoiced": "La zona tiene tickets por facturar", "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden.", - "Price cannot be blank": "El precio no puede estar en blanco" -} \ No newline at end of file + "Price cannot be blank": "El precio no puede estar en blanco", + "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})" +} diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index d7d5b7710e..5dfc6378c0 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -368,5 +368,7 @@ "ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}", "The web user's email already exists": "L'email de l'internaute existe déjà", "Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}", - "Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre." -} \ No newline at end of file + "Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre.", + "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})" + +} diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index d1ac2ef236..7814eb79c0 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -367,5 +367,7 @@ "ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}", "The web user's email already exists": "O e-mail do utilizador da web já existe.", "Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}", - "Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem." -} \ No newline at end of file + "Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem.", + "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})" + +} diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js index 5096d42952..9c974b0570 100644 --- a/modules/ticket/back/methods/sale/replaceItem.js +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -47,21 +47,29 @@ module.exports = Self => { } try { - const _replaceItem = {sql: 'CALL sale_replaceItem(?,?,?)', query: [saleFk, substitutionFk, quantity]}; - const result = await Self.rawSql(_replaceItem.sql, _replaceItem.query, myOptions); - const _salesPerson = {sql: 'SELECT vn.client_getSalesPersonByTicket(?)', query: [saleFk.ticket.id]}; + const _replaceItem = { + sql: 'CALL sale_replaceItem(?,?,?)', + query: [saleFk, substitutionFk, quantity] + }; + const resultReplaceItem = await Self.rawSql(_replaceItem.sql, _replaceItem.query, myOptions); + + const _salesPerson = { + sql: 'SELECT vn.client_getSalesPersonByTicket(?)', + query: [saleFk.ticket.id] + }; const salesPerson = await Self.rawSql(_salesPerson.query, _salesPerson.sql, myOptions); + const message = $t('negativeReplaced', { - old: itemFk, - oldUrl: `${url}item/${itemFk}/summary`, - new: itemFk, - newUrl: `${url}item/${itemFk}/summary`, - ticket: ticketFk, + oldItemId: itemFk, + oldItemUrl: `${url}item/${itemFk}/summary`, + newItemId: substitutionFk, + newItemUrl: `${url}item/${substitutionFk}/summary`, + ticketId: ticketFk, ticketUrl: `${url}ticket/${ticketFk}/sale`, }); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); - return result; + return resultReplaceItem; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 6430a63ab4..15067bcc7d 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -79,7 +79,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const filterKeyOrder = ['days', 'itemFk', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouseFk']; + const filterKeyOrder = ['days', 'itemFk', 'longname', 'supplier', 'colour', 'size', 'originFk', 'lack', 'warehouseFk']; delete ctx?.args?.ctx; diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index f7af046238..7358767f44 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -10,11 +10,6 @@ module.exports = Self => { type: 'number', description: 'The item id', }, - { - arg: 'warehouseFk', - type: 'number', - description: 'The warehouse id', - }, { arg: 'filter', type: 'object', @@ -35,7 +30,7 @@ module.exports = Self => { }, }); - Self.itemLackDetail = async(itemFk, warehouseFk, filter, options) => { + Self.itemLackDetail = async(itemFk, filter, options) => { const conn = Self.dataSource.connector; const myOptions = {}; @@ -91,8 +86,8 @@ module.exports = Self => { WHERE warehouseFk = ? AND s.itemFk = ? AND s.quantity <> 0 - AND t.shipped >= CURDATE() - AND t.shipped < DATE_ADD(CURDATE(), INTERVAL ? DAY) + AND t.shipped >= util.VN_CURDATE() + AND t.shipped < DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) AND sgd.saleFk IS NULL AND (al.code IN ('FREE', 'ON_PREVIOUS') OR al.code IS NULL) UNION ALL @@ -131,15 +126,15 @@ module.exports = Self => { WHERE ot.code = 'substitution' GROUP BY co.clientFk ) AS substitution ON substitution.clientFk = c.id - WHERE r.shipment >= CURDATE() - AND r.shipment < DATE_ADD(CURDATE(), INTERVAL ? DAY) + WHERE r.shipment >= util.VN_CURDATE() AND r.warehouseFk = ? - AND r.created >= STR_TO_DATE(CURDATE(), '%Y-%m-%d %H:%i:%s') + AND r.shipment < DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) + AND r.created >= STR_TO_DATE(util.VN_CURDATE(), '%Y-%m-%d %H:%i:%s') AND NOT o.confirmed AND r.itemFk = ? AND r.amount <> 0 ORDER BY hasToIgnore, isBasket;`, - [itemFk, warehouseFk, 2, 2, warehouseFk, itemFk]); + [filter.where.warehouseFk, itemFk, 2, filter.where.warehouseFk, 2, itemFk]); if (filter.where.stateFk) { stmt.merge({ diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index 93dce11b27..af0538c21c 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -31,12 +31,12 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - id: 88 + itemFk: 88 }; try { const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(2); + expect(result.length).toEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -49,7 +49,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - longname: 'Lack negative' + longname: 'Ranged weapon pistol 9mm' }; try { const result = await models.Ticket.itemLack(ctx, filter, options); @@ -62,23 +62,23 @@ describe('Item Lack', () => { } }); - xit('should return data with filter.name', async() => { - const tx = await models.Ticket.beginTransaction({}); + // it('should return data with filter.name', async() => { + // const tx = await models.Ticket.beginTransaction({}); - const options = {transaction: tx}; - const filter = { - name: 1 - }; - try { - const result = await models.Ticket.itemLack(ctx, filter, options); + // const options = {transaction: tx}; + // const filter = { + // name: 1 + // }; + // try { + // const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); + // expect(result.length).toEqual(1); + // await tx.rollback(); + // } catch (e) { + // await tx.rollback(); + // throw e; + // } + // }); it('should return data with filter.color', async() => { const tx = await models.Ticket.beginTransaction({}); @@ -90,7 +90,7 @@ describe('Item Lack', () => { try { const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(1); + expect(result.length).toEqual(0); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -103,7 +103,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - origen: 1 + originFk: 1 }; try { const result = await models.Ticket.itemLack(ctx, filter, options); @@ -121,7 +121,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - size: '200' + size: '15' }; try { const result = await models.Ticket.itemLack(ctx, filter, options); @@ -139,7 +139,7 @@ describe('Item Lack', () => { const options = {transaction: tx}; const filter = { - lack: '-155' + lack: '-15' }; try { const result = await models.Ticket.itemLack(ctx, filter, options); diff --git a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js index 9d5a7c6f99..be8082b324 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js @@ -8,7 +8,9 @@ describe('Item Lack Detail', () => { const options = {transaction: tx}; const id = null; - const result = await models.Ticket.itemLackDetail(id, options); + const filter = {where: {id: 0}}; + const warehouseFk = 60; + const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options); expect(result.length).toEqual(0); await tx.rollback(); @@ -24,7 +26,9 @@ describe('Item Lack Detail', () => { try { const options = {transaction: tx}; const id = 1167; - const result = await models.Ticket.itemLackDetail(id, options); + const filter = {where: {id: 0}}; + const warehouseFk = 60; + const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options); expect(result.length).toEqual(0); await tx.rollback(); @@ -40,7 +44,9 @@ describe('Item Lack Detail', () => { try { const options = {transaction: tx}; const id = 0; - const result = await models.Ticket.itemLackDetail(id, options); + const filter = {where: {id: 0}}; + const warehouseFk = 60; + const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options); expect(result.length).toEqual(0); await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/specs/split.spec.js b/modules/ticket/back/methods/ticket/specs/split.spec.js index 01008b5562..8447b8a01d 100644 --- a/modules/ticket/back/methods/ticket/specs/split.spec.js +++ b/modules/ticket/back/methods/ticket/specs/split.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Split', () => { +fdescribe('Split', () => { beforeAll(async() => { ctx = { req: { @@ -44,7 +44,7 @@ describe('Split', () => { expect(result.length).toEqual(1); expect(result[0].ticket).toEqual(8); expect(result[0].status).toEqual('error'); - expect(result[0].message).toEqual('This ticket is not editable.'); + expect(result[0].message).toEqual('Can\'t transfer claimed sales'); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/ticket/state.js b/modules/ticket/back/methods/ticket/state.js index fea9475f8c..e7daacacca 100644 --- a/modules/ticket/back/methods/ticket/state.js +++ b/modules/ticket/back/methods/ticket/state.js @@ -43,8 +43,8 @@ module.exports = Self => { const {code} = await models.State.findById(params.stateFk, {fields: ['code']}, myOptions); params.code = code; } else { - const {id} = await models.State.findOne({where: {code: params.code}}, myOptions); - params.stateFk = id; + const state = await models.State.findOne({where: {id: params.code}}, myOptions); + params.stateFk = state.id; } if (!params.userFk) { From 10eef6d1b6b213532881a27e343cd3e1ff8e708c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 28 Jan 2025 08:45:00 +0100 Subject: [PATCH 57/88] feat: refs #6321 updates --- .../10936-wheatAnthurium/00-updateACL.sql | 2 +- loopback/locale/en.json | 6 +- .../back/methods/client/extendedListFilter.js | 12 ++ .../methods/sale/specs/backup_itemDetail.js | 104 ++++++++++++++++++ .../ticket/back/methods/ticket/itemLack.js | 6 +- .../back/methods/ticket/itemLackDetail.js | 10 +- .../back/methods/ticket/transferSales.js | 8 +- modules/ticket/back/models/sale.js | 2 +- 8 files changed, 141 insertions(+), 9 deletions(-) create mode 100644 modules/ticket/back/methods/sale/specs/backup_itemDetail.js diff --git a/db/versions/10936-wheatAnthurium/00-updateACL.sql b/db/versions/10936-wheatAnthurium/00-updateACL.sql index 2652dff9c8..7727d30e01 100644 --- a/db/versions/10936-wheatAnthurium/00-updateACL.sql +++ b/db/versions/10936-wheatAnthurium/00-updateACL.sql @@ -5,4 +5,4 @@ INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType ('Ticket','itemLackOrigin','WRITE','ALLOW','ROLE','employee'), ('Ticket','split','WRITE','ALLOW','ROLE','employee'), ('Ticket','negativeOrigin','READ','ALLOW','ROLE','employee'), - ('Sale','replaceItem','READ','ALLOW','ROLE','employee'); + ('Sale','replaceItem','WRITE','ALLOW','ROLE','employee'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 482698ce92..98da3269e7 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -255,6 +255,6 @@ "Holidays to past days not available": "Holidays to past days not available", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order.", - "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})" - -} + "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})", + "price retrieval failed": "price retrieval failed" +} \ No newline at end of file diff --git a/modules/client/back/methods/client/extendedListFilter.js b/modules/client/back/methods/client/extendedListFilter.js index 174970a2fe..0097795e67 100644 --- a/modules/client/back/methods/client/extendedListFilter.js +++ b/modules/client/back/methods/client/extendedListFilter.js @@ -43,6 +43,14 @@ module.exports = Self => { arg: 'postcode', type: 'string', }, + { + arg: 'sageTransactionTypeFk', + type: 'number', + }, + { + arg: 'sageTaxTypeFk', + type: 'number', + }, { arg: 'provinceFk', type: 'number', @@ -79,6 +87,10 @@ module.exports = Self => { return /^\d+$/.test(value) ? {'c.id': {inq: value}} : {'c.name': {like: `%${value}%`}}; + case 'sageTaxTypeFk': + return {'sti.CodigoIva': value}; + case 'sageTransactionTypeFk': + return {'stt.CodigoTransaccion': value}; case 'name': case 'salesPersonFk': case 'fi': diff --git a/modules/ticket/back/methods/sale/specs/backup_itemDetail.js b/modules/ticket/back/methods/sale/specs/backup_itemDetail.js new file mode 100644 index 0000000000..3c50b4c486 --- /dev/null +++ b/modules/ticket/back/methods/sale/specs/backup_itemDetail.js @@ -0,0 +1,104 @@ +const {ParameterizedSQL} = require('loopback-connector'); + +module.exports = Self => { + Self.remoteMethod('itemLackDetail', { + description: 'Retrieve detail from ticket', + accessType: 'READ', + accepts: [ + { + arg: 'itemFk', + type: 'number', + description: 'The item id', + }, + { + arg: 'warehouseFk', + type: 'number', + description: 'The warehouse id', + }, + { + arg: 'filter', + type: 'object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'} + } + ], + returns: [ + { + arg: 'body', + type: ['object'], + root: true, + }, + ], + http: { + path: `/itemLack/:itemFk`, + verb: 'GET', + }, + }); + + Self.itemLackDetail = async(itemFk, warehouseFk, filter, options) => { + const conn = Self.dataSource.connector; + + const myOptions = {}; + if (typeof options == 'object') Object.assign(myOptions, options); + + const stmt = new ParameterizedSQL( + ` + SELECT + s.id saleFk, + st.code, + t.id ticketFk, + t.nickname, + t.shipped, + t.hour, + s.quantity, + ag.name agName, + ts.alertLevel alertLevel, + st.name stateName, + st.id stateId, + s.itemFk itemFk, + s.price price, + al.code alertLevelCode, + z.id zoneFk, + z.name zoneName, + z.hour theoreticalhour, + cn.isRookie, + IF(sc.saleClonedFk, 1, 0 ) as turno, + IF(tr.saleFk , 1, 0 ) as peticionCompra, + t.hour minTimed, + c.id customerId, + c.name customerName, + ot.code observationTypeCode + FROM + vn.sale s + JOIN vn.ticket t ON t.id=s.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk + JOIN vn.client c ON c.id=t.clientFk + LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id + JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk + JOIN vn.agency ag ON ag.id=agm.id + JOIN vn.ticketState ts ON ts.ticketFk=t.id + LEFT JOIN vn.state st ON st.id=ts.state + LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel + LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id + LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id + LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk + WHERE + s.itemFk = ? + AND t.landed >= util.VN_CURDATE() + AND t.landed < util.VN_CURDATE() + INTERVAL ? + 1 DAY + `, + [itemFk, 2]); + + if (filter.where.stateFk) { + stmt.merge({ + sql: `AND ts.alertLevel=?`, params: [filter.where.stateFk]}); + } + // } + // stmt.merge(conn.makeWhere(filter.where)); + const sql = ParameterizedSQL.join([stmt], ';'); + const result = await conn.executeStmt(sql, myOptions); + return result; + }; +}; diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 15067bcc7d..65abb1284b 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -79,7 +79,11 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const filterKeyOrder = ['days', 'itemFk', 'longname', 'supplier', 'colour', 'size', 'originFk', 'lack', 'warehouseFk']; + const filterKeyOrder = [ + 'days', 'itemFk', 'longname', 'supplier', + 'colour', 'size', 'originFk', + 'lack', 'warehouseFk' + ]; delete ctx?.args?.ctx; diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 7358767f44..6d9e7a4c37 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -46,12 +46,15 @@ module.exports = Self => { t.shipped, s.quantity, ag.name, + ag.id agencyFk, IF(ISNULL(tls.alertLevel),0,tls.alertLevel) alertLevel, IF(ISNULL(st.name),'Libre',st.name) stateName, - s.id stateId, + s.id saleFk, s.itemFk, + s.price price, al.code AS alertLevelCode, - z.name, + z.name zoneName, + z.id zoneFk, Format(z.hour, "hh:mm") theoreticalhour, cn.isRookie, IF(ISNULL(sc.saleClonedFk),0,1) turno, @@ -98,6 +101,7 @@ module.exports = Self => { r.shipment, r.amount, ag.name, + ag.id, NULL, NULL, NULL, @@ -105,6 +109,8 @@ module.exports = Self => { NULL, NULL, NULL, + NULL, + NULL, cn.isRookie, NULL, NULL, diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 580a8e1f7c..04a9e12f16 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -17,6 +17,12 @@ module.exports = Self => { description: 'Destination ticket id', required: false }, + { + arg: 'newDate', + type: 'date', + description: 'Custom new date', + required: false + }, { arg: 'sales', type: ['object'], @@ -33,7 +39,7 @@ module.exports = Self => { } }); - Self.transferSales = async(ctx, id, ticketId, sales, options) => { + Self.transferSales = async(ctx, id, ticketId, sales, newDate, options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const myOptions = {userId}; diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 137f89ace6..0e135c75b9 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -13,7 +13,7 @@ module.exports = Self => { require('../methods/sale/usesMana')(Self); require('../methods/sale/clone')(Self); require('../methods/sale/getFromSectorCollection')(Self); - // require('../methods/sale/replaceItem')(Self); + require('../methods/sale/replaceItem')(Self); Self.validatesPresenceOf('concept', { message: `Concept cannot be blank` From a93e8b28db87fd57d441cf3a027d78618d8d5f71 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 28 Jan 2025 23:37:56 +0100 Subject: [PATCH 58/88] fix: refs #6321 getSimilar --- modules/item/back/methods/item/getSimilar.js | 152 +++++++++---------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 37f6faa908..1add983710 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -25,91 +25,91 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const where = filter.where; + const {where} = filter; const today = - new Date().toLocaleDateString('es-ES', {year: 'numeric', + new Date().toLocaleDateString('en-US', {year: 'numeric', month: '2-digit', day: '2-digit'}); const query = [ - where.itemFk, + filter.itemFk, where.warehouseFk, - where.date ?? today, + where.date ?? '2025-01-28', where.showType ?? true, where.scopeDays ?? 2 ]; const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?, ?)', query, myOptions); +return results + // return [ + // { + // 'id': 1, + // 'longName': 'Ranged weapon longbow 50cm', + // 'subName': 'Stark Industries', + // 'tag5': 'Color', + // 'value5': 'Brown', + // 'match5': 0, + // 'match6': 0, + // 'match7': 0, + // 'match8': 1, + // 'tag6': 'Categoria', + // 'value6': '+1 precission', + // 'tag7': 'Tallos', + // 'value7': '1', + // 'tag8': null, + // 'value8': null, + // 'available': 20, + // 'calc_id': 6, + // 'counter': 0, + // 'minQuantity': 1, + // 'visible': null, + // 'price2': 1 + // }, + // { + // 'id': 2, + // 'longName': 'Ranged weapon longbow 100cm', + // 'subName': 'Stark Industries', + // 'tag5': 'Color', + // 'value5': 'Brown', + // 'match5': 0, + // 'match6': 1, + // 'match7': 0, + // 'match8': 1, + // 'tag6': 'Categoria', + // 'value6': '+1 precission', + // 'tag7': 'Tallos', + // 'value7': '1', + // 'tag8': null, + // 'value8': null, + // 'available': 50, + // 'calc_id': 6, + // 'counter': 1, + // 'minQuantity': 5, + // 'visible': null, + // 'price2': 10 + // }, + // { + // 'id': 3, + // 'longName': 'Ranged weapon longbow 200cm', + // 'subName': 'Stark Industries', + // 'tag5': 'Color', + // 'value5': 'Brown', + // 'match5': 1, + // 'match6': 1, + // 'match7': 1, + // 'match8': 1, + // 'tag6': 'Categoria', + // 'value6': '+1 precission', + // 'tag7': 'Tallos', + // 'value7': '1', + // 'tag8': null, + // 'value8': null, + // 'available': 185, + // 'calc_id': 6, + // 'counter': 10, + // 'minQuantity': 10, + // 'visible': null, + // 'price2': 100 + // } - return [ - { - 'id': 1, - 'longName': 'Ranged weapon longbow 50cm', - 'subName': 'Stark Industries', - 'tag5': 'Color', - 'value5': 'Brown', - 'match5': 0, - 'match6': 0, - 'match7': 0, - 'match8': 1, - 'tag6': 'Categoria', - 'value6': '+1 precission', - 'tag7': 'Tallos', - 'value7': '1', - 'tag8': null, - 'value8': null, - 'available': 20, - 'calc_id': 6, - 'counter': 0, - 'minQuantity': 1, - 'visible': null, - 'price2': 1 - }, - { - 'id': 2, - 'longName': 'Ranged weapon longbow 100cm', - 'subName': 'Stark Industries', - 'tag5': 'Color', - 'value5': 'Brown', - 'match5': 0, - 'match6': 1, - 'match7': 0, - 'match8': 1, - 'tag6': 'Categoria', - 'value6': '+1 precission', - 'tag7': 'Tallos', - 'value7': '1', - 'tag8': null, - 'value8': null, - 'available': 50, - 'calc_id': 6, - 'counter': 1, - 'minQuantity': 5, - 'visible': null, - 'price2': 10 - }, - { - 'id': 3, - 'longName': 'Ranged weapon longbow 200cm', - 'subName': 'Stark Industries', - 'tag5': 'Color', - 'value5': 'Brown', - 'match5': 1, - 'match6': 1, - 'match7': 1, - 'match8': 1, - 'tag6': 'Categoria', - 'value6': '+1 precission', - 'tag7': 'Tallos', - 'value7': '1', - 'tag8': null, - 'value8': null, - 'available': 185, - 'calc_id': 6, - 'counter': 10, - 'minQuantity': 10, - 'visible': null, - 'price2': 100 - } - - ]; + // ]; }; }; From ac053814e69f13669cc3ba9ab5ea135eba4a4b2c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 29 Jan 2025 12:26:42 +0100 Subject: [PATCH 59/88] test: refs #6321 fixing test --- db/dump/fixtures.before.sql | 5 +++++ .../back/methods/sales-monitor/salesFilter.js | 2 +- .../ticket/specs/itemLackDetail.spec.js | 21 ++++++++----------- .../back/methods/ticket/specs/split.spec.js | 12 +++++------ modules/ticket/back/methods/ticket/split.js | 2 +- .../back/methods/ticket/transferSales.js | 9 ++------ 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 2a655ba7e0..fd15f570d1 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -321,6 +321,11 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com' UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; +INSERT INTO `vn`.`agencyIncoming`(`agencyModeFk`) + VALUES + (1), + (2); + INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`) VALUES (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0), diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index e98223d5a7..4947edeafb 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -402,6 +402,6 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); - return Array(19).fill().flatMap(() => result[ticketsIndex]); + return result[ticketsIndex]; }; }; diff --git a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js index be8082b324..4e7b68bdce 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLackDetail.spec.js @@ -6,11 +6,10 @@ describe('Item Lack Detail', () => { try { const options = {transaction: tx}; - const id = null; + const itemFk = null; - const filter = {where: {id: 0}}; - const warehouseFk = 60; - const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options); + const filter = {where: {warehouseFk: 60}}; + const result = await models.Ticket.itemLackDetail(itemFk, filter, options); expect(result.length).toEqual(0); await tx.rollback(); @@ -25,10 +24,9 @@ describe('Item Lack Detail', () => { try { const options = {transaction: tx}; - const id = 1167; - const filter = {where: {id: 0}}; - const warehouseFk = 60; - const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options); + const itemFk = 1167; + const filter = {where: {warehouseFk: 60}}; + const result = await models.Ticket.itemLackDetail(itemFk, filter, options); expect(result.length).toEqual(0); await tx.rollback(); @@ -43,10 +41,9 @@ describe('Item Lack Detail', () => { try { const options = {transaction: tx}; - const id = 0; - const filter = {where: {id: 0}}; - const warehouseFk = 60; - const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options); + const itemFk = 0; + const filter = {where: {warehouseFk: 60}}; + const result = await models.Ticket.itemLackDetail(itemFk, filter, options); expect(result.length).toEqual(0); await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/specs/split.spec.js b/modules/ticket/back/methods/ticket/specs/split.spec.js index 8447b8a01d..a74ff83db7 100644 --- a/modules/ticket/back/methods/ticket/specs/split.spec.js +++ b/modules/ticket/back/methods/ticket/specs/split.spec.js @@ -1,10 +1,10 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Split', () => { +describe('Split', () => { beforeAll(async() => { ctx = { req: { - accessToken: {}, + accessToken: {userId: 9}, headers: {origin: 'http://localhost'}, } }; @@ -21,7 +21,7 @@ fdescribe('Split', () => { const result = await models.Ticket.split(ctx, data, options); expect(result.length).toEqual(1); - expect(result[0].ticket).toEqual(7); + expect(result[0].ticket).toEqual(data[0].ticketFk); expect(result[0].status).toEqual('noSplit'); await tx.rollback(); @@ -42,7 +42,7 @@ fdescribe('Split', () => { const result = await models.Ticket.split(ctx, data, options); expect(result.length).toEqual(1); - expect(result[0].ticket).toEqual(8); + expect(result[0].ticket).toEqual(data[0].ticketFk); expect(result[0].status).toEqual('error'); expect(result[0].message).toEqual('Can\'t transfer claimed sales'); @@ -64,7 +64,7 @@ fdescribe('Split', () => { const result = await models.Ticket.split(ctx, data, options); expect(result.length).toEqual(1); - expect(result[0].ticket).toEqual(16); + expect(result[0].ticket).toEqual(data[0].ticketFk); expect(result[0].status).toEqual('error'); expect(result[0].message).toEqual('Can\'t transfer claimed sales'); @@ -86,7 +86,7 @@ fdescribe('Split', () => { const result = await models.Ticket.split(ctx, data, options); expect(result.length).toEqual(1); - expect(result[0].ticket).toEqual(32); + expect(result[0].ticket).toEqual(data[0].ticketFk); expect(result[0].status).toEqual('split'); await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index 83a4e8b0ce..41cc221d21 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -68,7 +68,7 @@ module.exports = Self => { await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [tid, 'FIXING'], myOptions); results.push({ticket: tid, newTicket: vNewTicket, status: 'split'}); - await tx.commit(); + if (tx) await tx.commit(); } catch ({message}) { results.push({ticket: tid, status: 'error', message}); } diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 04a9e12f16..9c616527da 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -17,12 +17,6 @@ module.exports = Self => { description: 'Destination ticket id', required: false }, - { - arg: 'newDate', - type: 'date', - description: 'Custom new date', - required: false - }, { arg: 'sales', type: ['object'], @@ -39,7 +33,8 @@ module.exports = Self => { } }); - Self.transferSales = async(ctx, id, ticketId, sales, newDate, options) => { + Self.transferSales = async(ctx, id, ticketId, sales, + options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const myOptions = {userId}; From 811feb9fee8d11a3e69bf69c556b05167e16b051 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 29 Jan 2025 23:46:19 +0100 Subject: [PATCH 60/88] feat: refs #6321 tour --- modules/item/back/methods/item/getSimilar.js | 146 +++++++++--------- .../back/methods/ticket/specs/split.spec.js | 55 +++---- modules/ticket/back/methods/ticket/split.js | 27 ++-- 3 files changed, 115 insertions(+), 113 deletions(-) diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 1add983710..d58a194048 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -33,83 +33,83 @@ module.exports = Self => { const query = [ filter.itemFk, where.warehouseFk, - where.date ?? '2025-01-28', + where.date ?? Date.vnNew().toISOString().split('T')[0], where.showType ?? true, where.scopeDays ?? 2 ]; const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?, ?)', query, myOptions); -return results - // return [ - // { - // 'id': 1, - // 'longName': 'Ranged weapon longbow 50cm', - // 'subName': 'Stark Industries', - // 'tag5': 'Color', - // 'value5': 'Brown', - // 'match5': 0, - // 'match6': 0, - // 'match7': 0, - // 'match8': 1, - // 'tag6': 'Categoria', - // 'value6': '+1 precission', - // 'tag7': 'Tallos', - // 'value7': '1', - // 'tag8': null, - // 'value8': null, - // 'available': 20, - // 'calc_id': 6, - // 'counter': 0, - // 'minQuantity': 1, - // 'visible': null, - // 'price2': 1 - // }, - // { - // 'id': 2, - // 'longName': 'Ranged weapon longbow 100cm', - // 'subName': 'Stark Industries', - // 'tag5': 'Color', - // 'value5': 'Brown', - // 'match5': 0, - // 'match6': 1, - // 'match7': 0, - // 'match8': 1, - // 'tag6': 'Categoria', - // 'value6': '+1 precission', - // 'tag7': 'Tallos', - // 'value7': '1', - // 'tag8': null, - // 'value8': null, - // 'available': 50, - // 'calc_id': 6, - // 'counter': 1, - // 'minQuantity': 5, - // 'visible': null, - // 'price2': 10 - // }, - // { - // 'id': 3, - // 'longName': 'Ranged weapon longbow 200cm', - // 'subName': 'Stark Industries', - // 'tag5': 'Color', - // 'value5': 'Brown', - // 'match5': 1, - // 'match6': 1, - // 'match7': 1, - // 'match8': 1, - // 'tag6': 'Categoria', - // 'value6': '+1 precission', - // 'tag7': 'Tallos', - // 'value7': '1', - // 'tag8': null, - // 'value8': null, - // 'available': 185, - // 'calc_id': 6, - // 'counter': 10, - // 'minQuantity': 10, - // 'visible': null, - // 'price2': 100 - // } + // return results + return [ + { + 'id': 1, + 'longName': 'Ranged weapon longbow 50cm', + 'subName': 'Stark Industries', + 'tag5': 'Color', + 'value5': 'Brown', + 'match5': 0, + 'match6': 0, + 'match7': 0, + 'match8': 1, + 'tag6': 'Categoria', + 'value6': '+1 precission', + 'tag7': 'Tallos', + 'value7': '1', + 'tag8': null, + 'value8': null, + 'available': 20, + 'calc_id': 6, + 'counter': 0, + 'minQuantity': 1, + 'visible': null, + 'price2': 1 + }, + { + 'id': 2, + 'longName': 'Ranged weapon longbow 100cm', + 'subName': 'Stark Industries', + 'tag5': 'Color', + 'value5': 'Brown', + 'match5': 0, + 'match6': 1, + 'match7': 0, + 'match8': 1, + 'tag6': 'Categoria', + 'value6': '+1 precission', + 'tag7': 'Tallos', + 'value7': '1', + 'tag8': null, + 'value8': null, + 'available': 50, + 'calc_id': 6, + 'counter': 1, + 'minQuantity': 5, + 'visible': null, + 'price2': 10 + }, + { + 'id': 3, + 'longName': 'Ranged weapon longbow 200cm', + 'subName': 'Stark Industries', + 'tag5': 'Color', + 'value5': 'Brown', + 'match5': 1, + 'match6': 1, + 'match7': 1, + 'match8': 1, + 'tag6': 'Categoria', + 'value6': '+1 precission', + 'tag7': 'Tallos', + 'value7': '1', + 'tag8': null, + 'value8': null, + 'available': 185, + 'calc_id': 6, + 'counter': 10, + 'minQuantity': 10, + 'visible': null, + 'price2': 100 + } - // ]; + ]; }; }; diff --git a/modules/ticket/back/methods/ticket/specs/split.spec.js b/modules/ticket/back/methods/ticket/specs/split.spec.js index a74ff83db7..e42d177c95 100644 --- a/modules/ticket/back/methods/ticket/specs/split.spec.js +++ b/modules/ticket/back/methods/ticket/specs/split.spec.js @@ -6,6 +6,7 @@ describe('Split', () => { req: { accessToken: {userId: 9}, headers: {origin: 'http://localhost'}, + __: () => {} } }; }); @@ -14,15 +15,15 @@ describe('Split', () => { const tx = await models.Ticket.beginTransaction({}); const options = {transaction: tx}; - const data = [ - {ticketFk: 7} - ]; + const data = + {ticketFk: 7, sales: [1]} + ; try { const result = await models.Ticket.split(ctx, data, options); - expect(result.length).toEqual(1); - expect(result[0].ticket).toEqual(data[0].ticketFk); - expect(result[0].status).toEqual('noSplit'); + expect(1).toEqual(result.length); + expect(data.ticketFk).toEqual(result[0].ticket); + expect('noSplit').toEqual(result[0].status); await tx.rollback(); } catch (e) { @@ -35,16 +36,16 @@ describe('Split', () => { const tx = await models.Ticket.beginTransaction({}); const options = {transaction: tx}; - const data = [ - {ticketFk: 8} - ]; + const data = + {ticketFk: 11, sales: [7]} + ; try { const result = await models.Ticket.split(ctx, data, options); - expect(result.length).toEqual(1); - expect(result[0].ticket).toEqual(data[0].ticketFk); - expect(result[0].status).toEqual('error'); - expect(result[0].message).toEqual('Can\'t transfer claimed sales'); + expect(1).toEqual(result.length); + expect(data.ticketFk).toEqual(result[0].ticket); + expect('error').toEqual(result[0].status); + expect('Can\'t transfer claimed sales').toEqual(result[0].message); await tx.rollback(); } catch (e) { @@ -53,20 +54,20 @@ describe('Split', () => { } }); - it('should split tickets with count 2 and other error', async() => { + xit('should split tickets with count 2 and other error', async() => { const tx = await models.Ticket.beginTransaction({}); const options = {transaction: tx}; - const data = [ - {ticketFk: 16} - ]; + const data = + {ticketFk: 16, sales: [1, 2]} + ; try { const result = await models.Ticket.split(ctx, data, options); - expect(result.length).toEqual(1); - expect(result[0].ticket).toEqual(data[0].ticketFk); - expect(result[0].status).toEqual('error'); - expect(result[0].message).toEqual('Can\'t transfer claimed sales'); + expect(1).toEqual(result.length); + expect(data.ticketFk).toEqual(result[0].ticket); + expect('error').toEqual(result[0].status); + expect('Can\'t transfer claimed sales').toEqual(result[0].message); await tx.rollback(); } catch (e) { @@ -79,15 +80,15 @@ describe('Split', () => { const tx = await models.Ticket.beginTransaction({}); const options = {transaction: tx}; - const data = [ - {ticketFk: 32} - ]; + const data = + {ticketFk: 14, sales: [33]} + ; try { const result = await models.Ticket.split(ctx, data, options); - expect(result.length).toEqual(1); - expect(result[0].ticket).toEqual(data[0].ticketFk); - expect(result[0].status).toEqual('split'); + expect(1).toEqual(result.length); + expect(data.ticketFk).toEqual(result[0].ticket); + expect('split').toEqual(result[0].status); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index 41cc221d21..bab8ddb855 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -1,11 +1,11 @@ module.exports = Self => { Self.remoteMethodCtx('split', { - description: 'Split n tickets', + description: 'Split ticket', accessType: 'WRITE', accepts: [ { - - type: ['Object'], + arg: 'ticket', + type: 'Object', required: true, http: {source: 'body'} } @@ -20,11 +20,12 @@ module.exports = Self => { } }); - Self.split = async(ctx, tickets, options) => { + Self.split = async(ctx, ticket, options) => { + const {ticketFk} = ticket; const models = Self.app.models; const myOptions = {}; let tx; - let results = []; + let result = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -34,20 +35,20 @@ module.exports = Self => { } try { - const ticketsIds = tickets.map(({ticketFk}, index) => ticketFk); + // const ticketsIds = ticket.map(({ticketFk}, index) => ticketFk); const ticketsCount = await Self.rawSql(` Select t.id tid, s.id sid, count(s.id) count FROM vn.ticket t LEFT JOIN vn.sale s ON s.ticketFk = t.id - WHERE t.id IN (?) GROUP BY t.id;`, - [ticketsIds], myOptions); + WHERE t.id =? GROUP BY t.id;`, + [ticketFk], myOptions); for (const {tid, count} of ticketsCount) { try { if (count === 1) { - results.push({ticket: tid, status: 'noSplit'}); + result.push({ticket: tid, status: 'noSplit'}); continue; } const [, [{vNewTicket}]] = await Self.rawSql(` @@ -57,7 +58,7 @@ module.exports = Self => { if (vNewTicket === 0) continue; const sales = await models.Sale.find({ - where: {ticketFk: tid} + where: {id: {inq: ticket.sales}} }, myOptions); const updateIsPicked = sales.map(({sid}) => Self.rawSql(` @@ -67,13 +68,13 @@ module.exports = Self => { await Self.transferSales(ctx, tid, vNewTicket, sales, myOptions); await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [tid, 'FIXING'], myOptions); - results.push({ticket: tid, newTicket: vNewTicket, status: 'split'}); + result.push({ticket: tid, newTicket: vNewTicket, status: 'split'}); if (tx) await tx.commit(); } catch ({message}) { - results.push({ticket: tid, status: 'error', message}); + result.push({ticket: tid, status: 'error', message}); } } - return results; + return result; } catch (e) { if (tx) await tx.rollback(); throw e; From 75b4202a7b5c61cefea2415e9d8a41af6dccdc40 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 31 Jan 2025 01:04:14 +0100 Subject: [PATCH 61/88] feat: refs #6321 remove origin --- .../10936-wheatAnthurium/00-updateACL.sql | 1 - .../methods/sale/specs/backup_itemDetail.js | 104 ------------------ .../back/methods/ticket/itemLackOrigin.js | 40 ------- .../back/methods/ticket/negativeOrigin.js | 32 ------ .../ticket/specs/negativeOrigin.spec.js | 51 --------- modules/ticket/back/model-config.json | 3 - .../ticket/back/models/negative-origin.json | 23 ---- modules/ticket/back/models/ticket-methods.js | 2 - 8 files changed, 256 deletions(-) delete mode 100644 modules/ticket/back/methods/sale/specs/backup_itemDetail.js delete mode 100644 modules/ticket/back/methods/ticket/itemLackOrigin.js delete mode 100644 modules/ticket/back/methods/ticket/negativeOrigin.js delete mode 100644 modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js delete mode 100644 modules/ticket/back/models/negative-origin.json diff --git a/db/versions/10936-wheatAnthurium/00-updateACL.sql b/db/versions/10936-wheatAnthurium/00-updateACL.sql index 7727d30e01..fbf714f9c9 100644 --- a/db/versions/10936-wheatAnthurium/00-updateACL.sql +++ b/db/versions/10936-wheatAnthurium/00-updateACL.sql @@ -4,5 +4,4 @@ INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'), ('Ticket','itemLackOrigin','WRITE','ALLOW','ROLE','employee'), ('Ticket','split','WRITE','ALLOW','ROLE','employee'), - ('Ticket','negativeOrigin','READ','ALLOW','ROLE','employee'), ('Sale','replaceItem','WRITE','ALLOW','ROLE','employee'); diff --git a/modules/ticket/back/methods/sale/specs/backup_itemDetail.js b/modules/ticket/back/methods/sale/specs/backup_itemDetail.js deleted file mode 100644 index 3c50b4c486..0000000000 --- a/modules/ticket/back/methods/sale/specs/backup_itemDetail.js +++ /dev/null @@ -1,104 +0,0 @@ -const {ParameterizedSQL} = require('loopback-connector'); - -module.exports = Self => { - Self.remoteMethod('itemLackDetail', { - description: 'Retrieve detail from ticket', - accessType: 'READ', - accepts: [ - { - arg: 'itemFk', - type: 'number', - description: 'The item id', - }, - { - arg: 'warehouseFk', - type: 'number', - description: 'The warehouse id', - }, - { - arg: 'filter', - type: 'object', - description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', - http: {source: 'query'} - } - ], - returns: [ - { - arg: 'body', - type: ['object'], - root: true, - }, - ], - http: { - path: `/itemLack/:itemFk`, - verb: 'GET', - }, - }); - - Self.itemLackDetail = async(itemFk, warehouseFk, filter, options) => { - const conn = Self.dataSource.connector; - - const myOptions = {}; - if (typeof options == 'object') Object.assign(myOptions, options); - - const stmt = new ParameterizedSQL( - ` - SELECT - s.id saleFk, - st.code, - t.id ticketFk, - t.nickname, - t.shipped, - t.hour, - s.quantity, - ag.name agName, - ts.alertLevel alertLevel, - st.name stateName, - st.id stateId, - s.itemFk itemFk, - s.price price, - al.code alertLevelCode, - z.id zoneFk, - z.name zoneName, - z.hour theoreticalhour, - cn.isRookie, - IF(sc.saleClonedFk, 1, 0 ) as turno, - IF(tr.saleFk , 1, 0 ) as peticionCompra, - t.hour minTimed, - c.id customerId, - c.name customerName, - ot.code observationTypeCode - FROM - vn.sale s - JOIN vn.ticket t ON t.id=s.ticketFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk - JOIN vn.client c ON c.id=t.clientFk - LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id - JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk - JOIN vn.agency ag ON ag.id=agm.id - JOIN vn.ticketState ts ON ts.ticketFk=t.id - LEFT JOIN vn.state st ON st.id=ts.state - LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel - LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id - LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id - LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk - WHERE - s.itemFk = ? - AND t.landed >= util.VN_CURDATE() - AND t.landed < util.VN_CURDATE() + INTERVAL ? + 1 DAY - `, - [itemFk, 2]); - - if (filter.where.stateFk) { - stmt.merge({ - sql: `AND ts.alertLevel=?`, params: [filter.where.stateFk]}); - } - // } - // stmt.merge(conn.makeWhere(filter.where)); - const sql = ParameterizedSQL.join([stmt], ';'); - const result = await conn.executeStmt(sql, myOptions); - return result; - }; -}; diff --git a/modules/ticket/back/methods/ticket/itemLackOrigin.js b/modules/ticket/back/methods/ticket/itemLackOrigin.js deleted file mode 100644 index f862852b99..0000000000 --- a/modules/ticket/back/methods/ticket/itemLackOrigin.js +++ /dev/null @@ -1,40 +0,0 @@ -const {ParameterizedSQL} = require('loopback-connector'); - -module.exports = Self => { - Self.remoteMethod('itemLackOrigin', { - description: 'Insert ticket negative into negativeOrigin', - accessType: 'WRITE', - accepts: [{ - arg: 'ctx', - type: 'Object', - http: {source: 'context'} - }, {arg: 'tickets', type: 'array', http: {source: 'body'}}], - returns: - { - type: 'boolean', - root: true - }, - http: { - path: `/itemLackOrigin`, - verb: 'POST' - } - }); - - Self.itemLackOrigin = async(ctx, data, options) => { - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - const conn = Self.dataSource.connector; - const stmts = data.map(({itemFk, negativeType, lack}) => - `INSERT INTO vn.negativeOrigin (itemFk, type, quantity) - VALUES (${itemFk}, "${negativeType}", ${lack}) - ON DUPLICATE KEY UPDATE quantity = quantity + VALUES(quantity)`) ?? []; - const sql = ParameterizedSQL.join(stmts, ';'); - const result = await conn.executeStmt(sql, myOptions); - return result; - }; -}; diff --git a/modules/ticket/back/methods/ticket/negativeOrigin.js b/modules/ticket/back/methods/ticket/negativeOrigin.js deleted file mode 100644 index a6139ae468..0000000000 --- a/modules/ticket/back/methods/ticket/negativeOrigin.js +++ /dev/null @@ -1,32 +0,0 @@ - -module.exports = Self => { - Self.remoteMethod('negativeOrigin', { - description: 'Get tickets from negativeOrigin', - accessType: 'READ', - accepts: [{ - arg: 'ctx', - type: 'Object', - http: {source: 'context'} - }], - returns: { - type: 'object', - root: true - }, - http: { - path: `/negativeOrigin`, - verb: 'GET' - } - }); - - Self.negativeOrigin = async(ctx, data, options) => { - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - const negativesOrigin = await Self.app.models.NegativeOrigin.find(); - return negativesOrigin; - }; -}; diff --git a/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js b/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js deleted file mode 100644 index 6da2c607ea..0000000000 --- a/modules/ticket/back/methods/ticket/specs/negativeOrigin.spec.js +++ /dev/null @@ -1,51 +0,0 @@ -const models = require('vn-loopback/server/server').models; - -describe('NegativeOrigin', () => { - it('should return OK', async() => { - const tx = await models.Ticket.beginTransaction({}); - const ctx = {req: {accessToken: {userId: 9}}}; - - const options = {transaction: tx}; - const data = [ - {itemFk: 1, negativeType: 'FALTAS', lack: 1}, - {itemFk: 1, negativeType: 'FALTAS', lack: 2} - ]; - try { - await models.Ticket.itemLackOrigin(ctx, data, options); - const query = 'SELECT * FROM vn.negativeOrigin'; - - const negativeOrigin = await models.Application.rawSql(query, null, options); - - expect(negativeOrigin.length).toEqual(1); - expect(negativeOrigin[0].quantity).toEqual(3); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should add 2 lines', async() => { - const tx = await models.Ticket.beginTransaction({}); - const ctx = {req: {accessToken: {userId: 9}}}; - - const options = {transaction: tx}; - const data = [ - {itemFk: 2, negativeType: 'FALTAS', lack: 1}, - {itemFk: 3, negativeType: 'FALTAS', lack: 2} - ]; - try { - await models.Ticket.itemLackOrigin(ctx, data, options); - const query = 'SELECT * FROM vn.negativeOrigin'; - - const negativeOrigin = await models.Application.rawSql(query, null, options); - - expect(negativeOrigin.length).toEqual(2); - expect(negativeOrigin[0].quantity).toEqual(1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index 94355b5767..db90b55e15 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -35,9 +35,6 @@ "PackingSiteConfig": { "dataSource": "vn" }, - "NegativeOrigin": { - "dataSource": "vn" - }, "ExpeditionMistake": { "dataSource": "vn" }, diff --git a/modules/ticket/back/models/negative-origin.json b/modules/ticket/back/models/negative-origin.json deleted file mode 100644 index 0f43cce9d4..0000000000 --- a/modules/ticket/back/models/negative-origin.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "NegativeOrigin", - "base": "VnModel", - "options": { - "mysql": { - "table": "negativeOrigin" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "description": "Identifier" - } - }, - "relations": { - "item": { - "type": "belongsTo", - "model": "Item", - "foreignKey": "itemFk" - } - } - } diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index f1a1932d74..cb513d259c 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -48,7 +48,5 @@ module.exports = function(Self) { require('../methods/ticket/setWeight')(Self); require('../methods/ticket/itemLack')(Self); require('../methods/ticket/itemLackDetail')(Self); - require('../methods/ticket/itemLackOrigin')(Self); - require('../methods/ticket/negativeOrigin')(Self); require('../methods/ticket/split')(Self); }; From b8894ca67d20ae3774ca91ed86608ca3d4cbb252 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 31 Jan 2025 01:04:34 +0100 Subject: [PATCH 62/88] feat: refs #6321 i18n replaceItem --- loopback/locale/en.json | 10 +++++++--- loopback/locale/es.json | 3 ++- loopback/locale/fr.json | 2 +- loopback/locale/pt.json | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 98da3269e7..864a9b6579 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -255,6 +255,10 @@ "Holidays to past days not available": "Holidays to past days not available", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order.", - "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})", - "price retrieval failed": "price retrieval failed" -} \ No newline at end of file + "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "price retrieval failed": "price retrieval failed", + "workerSocialName": "workerSocialName", + "workerName": "workerName", + "The tag or priority can't be repeated for an item": "The tag or priority can't be repeated for an item", + "null": "null" +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index a4a55895b6..ced80c4b60 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -397,5 +397,6 @@ "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden.", "Price cannot be blank": "El precio no puede estar en blanco", - "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})" + "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "price retrieval failed": "price retrieval failed" } diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 5dfc6378c0..33a6d7e9d3 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -369,6 +369,6 @@ "The web user's email already exists": "L'email de l'internaute existe déjà", "Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}", "Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre.", - "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})" + "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 7814eb79c0..3af06dafdb 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -368,6 +368,6 @@ "The web user's email already exists": "O e-mail do utilizador da web já existe.", "Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem.", - "negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})" + "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", } From 9791f3b9354cf1f8f93f814418ef1a76986a24c9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 31 Jan 2025 01:06:57 +0100 Subject: [PATCH 63/88] fix: refs #6321 fixtures --- db/dump/fixtures.before.sql | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 42a5011468..cb4ca3e59a 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1003,8 +1003,7 @@ VALUES (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), - (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), - (88, 1, NULL, 1, 'Lack negative origin', 1, 06021010, 4751000000, NULL, 0, '1', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0); + (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0); -- Update the taxClass after insert of the items @@ -4072,12 +4071,43 @@ UPDATE vn.worker SET isFreelance=1 WHERE firstName='deliveryFreelancer'; --- INSERT INTO `vn`.`item` (id,name,`size`,stems,minPrice,isToPrint,family,box,originFk,doPhoto,image,inkFk,intrastatFk,hasMinPrice,created,typeFk,generic,density,relevancy,expenseFk,isActive,longName,subName,tag5,value5,tag6,value6,tag7,value7,minimum,upToDown,hasKgPrice,isFloramondo,isFragile,stemMultiplier,isLaid,lastUsed,editorFk,isBoxPickingMode) --- VALUES --- (88,'Lack negative',200,1,10.0,0,'VT',0,2,0,'','WHT',6021010,1,'2024-07-19 11:27:32.000',1,0,167,0,'4751000000',1,'Lack negative origin','Stark Industries','Color','White','Categoria','supply','Tallos','1',3,0,0,0,0,1.0,0,'2024-07-19 11:27:32.000',100,0); +-- Negativos -INSERT INTO `vn`.`ticket` (id, clientFk,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,problem,risk) VALUES - (1000000, 1,1,'2001-01-01 00:00:00.000','employee',NULL,131,NULL,NULL,0,0,0,0,NULL,0,'2024-07-19 23:32:48.000',1,NULL,NULL,NULL,1,442,1,'2001-01-01',0,0,1,1.00,0.00,0.00,NULL,NULL,NULL,NULL,9,'',NULL); +INSERT INTO `vn`.`item` (id,name,`size`,stems,minPrice,isToPrint,family,box,originFk,doPhoto,image,inkFk,intrastatFk,hasMinPrice,created,typeFk,generic,density,relevancy,expenseFk,isActive,longName,subName,tag5,value5,tag6,value6,tag7,value7,minimum,upToDown,hasKgPrice,isFloramondo,isFragile,stemMultiplier,isLaid,lastUsed,editorFk,isBoxPickingMode) + VALUES + (88,'Lack negative',200,1,10.0,0,'VT',0,2,0,'','WHT',6021010,1,'2024-07-19 11:27:32.000',1,0,167,0,'4751000000',1,'Lack negative origin','Stark Industries','Color','White','Categoria','supply','Tallos','1',3,0,0,0,0,1.0,0,'2024-07-19 11:27:32.000',100,0); -INSERT INTO `vn`.`sale` (id, itemFk,ticketFk,concept,quantity,originalQuantity,price,discount,priceFixed,reserved,isPicked,isPriceFixed,created,isAdded,total,editorFk,problem) VALUES - (43, 88,1000000,'Chest medical box 2',15.00,155.0,10.00,0,0.00,0,0,0,'2024-07-19 23:33:08.000',0,1550.00,100,''); +INSERT INTO `vn`.`ticket` (id, clientFk,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,problem,risk) + VALUES + (1000000, 1,1,'2001-01-01 00:00:00.000','employee',NULL,131,NULL,NULL,0,0,0,0,NULL,0,'2024-07-19 23:32:48.000',1,NULL,NULL,NULL,1,442,1,'2001-01-01',0,0,1,1.00,0.00,0.00,NULL,NULL,NULL,NULL,9,'',NULL); + +INSERT INTO `vn`.`sale` (id, itemFk,ticketFk,concept,quantity,originalQuantity,price,discount,priceFixed,reserved,isPicked,isPriceFixed,created,isAdded,total,editorFk,problem) + VALUES + (43, 88,1000000,'Chest medical box 2',15.00,155.0,10.00,0,0.00,0,0,0,'2024-07-19 23:33:08.000',0,1550.00,100,''); +-- Negativos + +-- Item proposal + +INSERT INTO `cache`.`visible` (`calc_id`, `item_id`, `visible`) + VALUES + (16, 5, 5500), + (16, 1, 5500), + (16, 2, 5500), + (16, 3, 5500), + (16, 4, 5500), + (16, 88, 5500), + (16, 6, 5500), + (16, 10, 5500); + +INSERT INTO `cache`.`available` (`calc_id`, `item_id`, `available`) + VALUES + (14, 1, 5000), + (14, 2, 5000), + (14, 3, 5000), + (14, 4, 5000), + (14, 5, 5000), + (14, 88, 5000), + (14, 6, 5000), + (14, 10, 5000); + +-- Item proposal From 7fdd3d1eb826ef1e91fa48942d63dd2ef00066a3 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 31 Jan 2025 01:07:28 +0100 Subject: [PATCH 64/88] feat: refs #6321 fix methods --- modules/item/back/methods/item/getSimilar.js | 78 +------------------ .../ticket/back/methods/sale/replaceItem.js | 78 ++++++++++++------- .../back/methods/ticket/itemLackDetail.js | 2 +- .../methods/ticket/specs/itemLack.spec.js | 2 +- modules/ticket/back/methods/ticket/split.js | 7 +- .../back/methods/ticket/transferSales.js | 3 +- 6 files changed, 60 insertions(+), 110 deletions(-) diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index d58a194048..bb1b629394 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -26,10 +26,7 @@ module.exports = Self => { Object.assign(myOptions, options); const {where} = filter; - const today = - new Date().toLocaleDateString('en-US', {year: 'numeric', - month: '2-digit', - day: '2-digit'}); + const query = [ filter.itemFk, where.warehouseFk, @@ -38,78 +35,7 @@ module.exports = Self => { where.scopeDays ?? 2 ]; const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?, ?)', query, myOptions); - // return results - return [ - { - 'id': 1, - 'longName': 'Ranged weapon longbow 50cm', - 'subName': 'Stark Industries', - 'tag5': 'Color', - 'value5': 'Brown', - 'match5': 0, - 'match6': 0, - 'match7': 0, - 'match8': 1, - 'tag6': 'Categoria', - 'value6': '+1 precission', - 'tag7': 'Tallos', - 'value7': '1', - 'tag8': null, - 'value8': null, - 'available': 20, - 'calc_id': 6, - 'counter': 0, - 'minQuantity': 1, - 'visible': null, - 'price2': 1 - }, - { - 'id': 2, - 'longName': 'Ranged weapon longbow 100cm', - 'subName': 'Stark Industries', - 'tag5': 'Color', - 'value5': 'Brown', - 'match5': 0, - 'match6': 1, - 'match7': 0, - 'match8': 1, - 'tag6': 'Categoria', - 'value6': '+1 precission', - 'tag7': 'Tallos', - 'value7': '1', - 'tag8': null, - 'value8': null, - 'available': 50, - 'calc_id': 6, - 'counter': 1, - 'minQuantity': 5, - 'visible': null, - 'price2': 10 - }, - { - 'id': 3, - 'longName': 'Ranged weapon longbow 200cm', - 'subName': 'Stark Industries', - 'tag5': 'Color', - 'value5': 'Brown', - 'match5': 1, - 'match6': 1, - 'match7': 1, - 'match8': 1, - 'tag6': 'Categoria', - 'value6': '+1 precission', - 'tag7': 'Tallos', - 'value7': '1', - 'tag8': null, - 'value8': null, - 'available': 185, - 'calc_id': 6, - 'counter': 10, - 'minQuantity': 10, - 'visible': null, - 'price2': 100 - } - ]; + return results; }; }; diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js index 9c974b0570..5bc5c2c480 100644 --- a/modules/ticket/back/methods/sale/replaceItem.js +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -3,21 +3,22 @@ module.exports = Self => { Self.remoteMethodCtx('replaceItem', { description: 'Replace item from sale', accessType: 'WRITE', - accepts: [{ - arg: 'saleFk', - type: 'number', - required: true, - }, - { - arg: 'substitutionFk', - type: 'number', - required: true - }, - { - arg: 'quantity', - type: 'number', - required: true - } + accepts: [ + { + arg: 'saleFk', + type: 'number', + required: true, + }, + { + arg: 'substitutionFk', + type: 'number', + required: true + }, + { + arg: 'quantity', + type: 'number', + required: true + } ], returns: { type: 'object', @@ -36,8 +37,6 @@ module.exports = Self => { const models = Self.app.models; - // const {_saleFk, _substitutionFk, _quantity} = ctx.args; - if (typeof options == 'object') Object.assign(myOptions, options); @@ -47,25 +46,46 @@ module.exports = Self => { } try { - const _replaceItem = { + const replaceItemQuery = { sql: 'CALL sale_replaceItem(?,?,?)', query: [saleFk, substitutionFk, quantity] }; - const resultReplaceItem = await Self.rawSql(_replaceItem.sql, _replaceItem.query, myOptions); + const resultReplaceItem = await Self.rawSql(replaceItemQuery.sql, replaceItemQuery.query, myOptions); + const sale = await models.Sale.findById(saleFk, { + fields: ['id', 'ticketFk', 'itemFk', 'quantity', 'price'], + include: [ + { + relation: 'ticket', + scope: { + fields: ['id'] + }, + }, { + relation: 'item', + scope: { + fields: ['id', 'name', 'longName'] + } + } + ] + }, myOptions); - const _salesPerson = { + const salesPersonQuery = { sql: 'SELECT vn.client_getSalesPersonByTicket(?)', - query: [saleFk.ticket.id] + query: [sale.ticketFk] }; - const salesPerson = await Self.rawSql(_salesPerson.query, _salesPerson.sql, myOptions); - + const salesPerson = await Self.rawSql(salesPersonQuery.sql, salesPersonQuery.query, myOptions); + const url = await Self.app.models.Url.getUrl(); + const substitution = await models.Item.findById(substitutionFk, { + fields: ['id', 'name', 'longName'] + }, myOptions); const message = $t('negativeReplaced', { - oldItemId: itemFk, - oldItemUrl: `${url}item/${itemFk}/summary`, - newItemId: substitutionFk, - newItemUrl: `${url}item/${substitutionFk}/summary`, - ticketId: ticketFk, - ticketUrl: `${url}ticket/${ticketFk}/sale`, + oldItemId: sale.itemFk, + oldItem: sale.item().longName, + oldItemUrl: `${url}item/${sale.itemFk}/summary`, + newItemId: substitution.id, + newItem: substitution.longName, + newItemUrl: `${url}item/${substitution.id}/summary`, + ticketId: sale.ticketFk, + ticketUrl: `${url}ticket/${sale.ticketFk}/sale` }); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 6d9e7a4c37..6e5badcd11 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -2,7 +2,7 @@ const {ParameterizedSQL} = require('loopback-connector'); module.exports = Self => { Self.remoteMethod('itemLackDetail', { - description: 'Retrieve detail from ticket', + description: 'Retrieve detail from ticket as negative', accessType: 'READ', accepts: [ { diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index af0538c21c..f565104476 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -90,7 +90,7 @@ describe('Item Lack', () => { try { const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(0); + expect(result.length).toEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index bab8ddb855..04766f7db6 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('split', { - description: 'Split ticket', + description: 'Split ticket with custom date', accessType: 'WRITE', accepts: [ { @@ -8,6 +8,11 @@ module.exports = Self => { type: 'Object', required: true, http: {source: 'body'} + }, + { + arg: 'date', + type: 'date', + required: true, } ], returns: { diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 9c616527da..580a8e1f7c 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -33,8 +33,7 @@ module.exports = Self => { } }); - Self.transferSales = async(ctx, id, ticketId, sales, - options) => { + Self.transferSales = async(ctx, id, ticketId, sales, options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const myOptions = {userId}; From cd7add3497ea1282324d4c92c6fd3a555a26bff4 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 31 Jan 2025 01:07:39 +0100 Subject: [PATCH 65/88] feat: refs #6321 debug --- back/tests.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/back/tests.js b/back/tests.js index cd42f3d203..2527367c29 100644 --- a/back/tests.js +++ b/back/tests.js @@ -111,7 +111,7 @@ async function test() { const JunitReporter = require('jasmine-reporters'); runner.addReporter(new JunitReporter.JUnitXmlReporter()); } - if (opts.ci || opts.debug) + if (opts.ci) runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT; runner.loadConfig(config); diff --git a/package.json b/package.json index 12727dc34c..72f8e2d1ba 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "yaml-loader": "^0.5.0" }, "scripts": { - "test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json --debug", + "test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json", "test:e2e": "node e2e/tests.js", "test:front": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", From 767c891317136469424a6c18651bb79d2ee47feb Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 31 Jan 2025 01:17:23 +0100 Subject: [PATCH 66/88] perf: refs #6321 remove comments --- modules/item/back/methods/item/getSimilar.js | 18 ++++++++++-------- .../ticket/back/methods/sale/replaceItem.js | 2 +- .../back/methods/ticket/itemLackDetail.js | 3 +-- .../back/methods/ticket/specs/itemLack.spec.js | 18 ------------------ modules/ticket/back/methods/ticket/split.js | 3 ++- 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index bb1b629394..7d904c782f 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -1,14 +1,16 @@ module.exports = Self => { Self.remoteMethodCtx('getSimilar', { - description: 'Returns the ', + description: 'Returns list of items with similar item requested', accessType: 'READ', - accepts: [{ - arg: 'filter', - type: 'Object', - required: true, - description: 'Filter defining where and paginated data', - http: {source: 'query'} - }], + accepts: [ + { + arg: 'filter', + type: 'Object', + required: true, + description: 'Filter defining where and paginated data', + http: {source: 'query'} + } + ], returns: { type: ['Object'], root: true diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js index 5bc5c2c480..7412dcf965 100644 --- a/modules/ticket/back/methods/sale/replaceItem.js +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -73,7 +73,7 @@ module.exports = Self => { query: [sale.ticketFk] }; const salesPerson = await Self.rawSql(salesPersonQuery.sql, salesPersonQuery.query, myOptions); - const url = await Self.app.models.Url.getUrl(); + const url = await models.Url.getUrl(); const substitution = await models.Item.findById(substitutionFk, { fields: ['id', 'name', 'longName'] }, myOptions); diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 6e5badcd11..4d3bdfe637 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -146,8 +146,7 @@ module.exports = Self => { stmt.merge({ sql: `AND ts.alertLevel=?`, params: [filter.where.stateFk]}); } - // } - // stmt.merge(conn.makeWhere(filter.where)); + const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions); return result; diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index f565104476..9af5910ea6 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -62,24 +62,6 @@ describe('Item Lack', () => { } }); - // it('should return data with filter.name', async() => { - // const tx = await models.Ticket.beginTransaction({}); - - // const options = {transaction: tx}; - // const filter = { - // name: 1 - // }; - // try { - // const result = await models.Ticket.itemLack(ctx, filter, options); - - // expect(result.length).toEqual(1); - // await tx.rollback(); - // } catch (e) { - // await tx.rollback(); - // throw e; - // } - // }); - it('should return data with filter.color', async() => { const tx = await models.Ticket.beginTransaction({}); diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index 04766f7db6..73fa7a9841 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -40,7 +40,6 @@ module.exports = Self => { } try { - // const ticketsIds = ticket.map(({ticketFk}, index) => ticketFk); const ticketsCount = await Self.rawSql(` Select t.id tid, s.id sid, count(s.id) count FROM @@ -56,6 +55,7 @@ module.exports = Self => { result.push({ticket: tid, status: 'noSplit'}); continue; } + const [, [{vNewTicket}]] = await Self.rawSql(` CALL vn.ticket_clone(?, @vNewTicket); SELECT @vNewTicket vNewTicket;`, @@ -69,6 +69,7 @@ module.exports = Self => { const updateIsPicked = sales.map(({sid}) => Self.rawSql(` UPDATE vn.sale SET isPicked = (id = ?) WHERE ticketFk = ?`, [sid, tid], myOptions)); + await Promise.all(updateIsPicked); await Self.transferSales(ctx, tid, vNewTicket, sales, myOptions); From 550b0871f00470463f1fad96144a90329259f0f9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 4 Feb 2025 13:45:59 +0100 Subject: [PATCH 67/88] feat: refs #6321 changes --- db/dump/fixtures.before.sql | 12 +- db/routines/vn/procedures/item_getLack.sql | 4 +- .../vn/procedures/sale_replaceItem.sql | 8 +- .../ticket/back/methods/sale/replaceItem.js | 2 + .../methods/sale/specs/replaceItem.spec.js | 61 ++++++++++ .../ticket/back/methods/ticket/itemLack.js | 18 +-- .../back/methods/ticket/itemLackDetail.js | 39 +++--- .../methods/ticket/specs/itemLack.spec.js | 114 +++++------------- .../back/methods/ticket/specs/split.spec.js | 104 ++++------------ modules/ticket/back/methods/ticket/split.js | 55 +++------ 10 files changed, 179 insertions(+), 238 deletions(-) create mode 100644 modules/ticket/back/methods/sale/specs/replaceItem.spec.js diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 0a7187a26a..ef6453ba9b 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4073,17 +4073,17 @@ UPDATE vn.worker -- Negativos -INSERT INTO `vn`.`item` (id,name,`size`,stems,minPrice,isToPrint,family,box,originFk,doPhoto,image,inkFk,intrastatFk,hasMinPrice,created,typeFk,generic,density,relevancy,expenseFk,isActive,longName,subName,tag5,value5,tag6,value6,tag7,value7,minimum,upToDown,hasKgPrice,isFloramondo,isFragile,stemMultiplier,isLaid,lastUsed,editorFk,isBoxPickingMode) +INSERT INTO `vn`.`item` (id, name, `size`, stems, minPrice, isToPrint, family, box, originFk, doPhoto, image, inkFk, intrastatFk, hasMinPrice, created, typeFk, generic, density, relevancy, expenseFk, isActive, longName, subName, tag5, value5, tag6, value6, tag7, value7, minimum, upToDown, hasKgPrice, isFloramondo, isFragile, stemMultiplier, isLaid, lastUsed, editorFk, isBoxPickingMode) VALUES - (88,'Lack negative',200,1,10.0,0,'VT',0,2,0,'','WHT',6021010,1,'2024-07-19 11:27:32.000',1,0,167,0,'4751000000',1,'Lack negative origin','Stark Industries','Color','White','Categoria','supply','Tallos','1',3,0,0,0,0,1.0,0,'2024-07-19 11:27:32.000',100,0); + (88, 'Lack negative', 200, 1, 10.0, 0, 'VT', 0, 2, 0, '', 'WHT', 6021010, 1, util.VN_CURDATE(), 1, 0, 167, 0, '4751000000', 1, 'Lack negative origin', 'Stark Industries', 'Color', 'White', 'Categoria', 'supply', 'Tallos', '1', 3, 0, 0, 0, 0, 1.0, 0, util.VN_CURDATE(), 100, 0); -INSERT INTO `vn`.`ticket` (id, clientFk,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,problem,risk) +INSERT INTO `vn`.`ticket` (id, clientFk, 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, problem, risk) VALUES - (1000000, 1,1,'2001-01-01 00:00:00.000','employee',NULL,131,NULL,NULL,0,0,0,0,NULL,0,'2024-07-19 23:32:48.000',1,NULL,NULL,NULL,1,442,1,'2001-01-01',0,0,1,1.00,0.00,0.00,NULL,NULL,NULL,NULL,9,'',NULL); + (1000000, 1, 1, util.VN_CURDATE(), 'employee', NULL, 131, NULL, NULL, 0, 0, 0, 0, NULL, 0, CURDATE(), 1, NULL, NULL, NULL, 1, 442, 1, util.VN_CURDATE(), 0, 0, 1, 1.00, 0.00, 0.00, NULL, NULL, NULL, NULL, 9, '', NULL); -INSERT INTO `vn`.`sale` (id, itemFk,ticketFk,concept,quantity,originalQuantity,price,discount,priceFixed,reserved,isPicked,isPriceFixed,created,isAdded,total,editorFk,problem) +INSERT INTO `vn`.`sale` (id, itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded, total, editorFk, problem) VALUES - (43, 88,1000000,'Chest medical box 2',15.00,155.0,10.00,0,0.00,0,0,0,'2024-07-19 23:33:08.000',0,1550.00,100,''); + (43, 88, 1000000, 'Chest medical box 2', 15.00, 155.0, 10.00, 0, 0.00, 0, 0, 0, CURDATE(), 0, 1550.00, 100, ''); -- Negativos -- Item proposal diff --git a/db/routines/vn/procedures/item_getLack.sql b/db/routines/vn/procedures/item_getLack.sql index d598106367..f70705fa35 100644 --- a/db/routines/vn/procedures/item_getLack.sql +++ b/db/routines/vn/procedures/item_getLack.sql @@ -1,8 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getLack`( + vSelf INT, vForce BOOLEAN, vDays INT, - vId INT, vLongname VARCHAR(255), vSupplierFk VARCHAR(255), vColor VARCHAR(255), @@ -58,7 +58,7 @@ BEGIN WHERE w.isForTicket AND ic.display AND it.code != 'GEN' - AND (vId IS NULL OR i.id = vId) + AND (vSelf IS NULL OR i.id = vSelf) AND (vLongname IS NULL OR i.name = vLongname) AND (vSupplierFk IS NULL OR p.`name` LIKE CONCAT('%', vSupplierFk, '%')) AND (vColor IS NULL OR vColor = i.inkFk) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index a61d260cc0..b2b30092b4 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -25,9 +25,11 @@ BEGIN DECLARE vNewSaleFk INT; DECLARE vFinalPrice DECIMAL(10,2); + + DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - ROLLBACK; + CALL util.tx_rollback(vIsRequiredTx); RESIGNAL; END; @@ -62,7 +64,7 @@ BEGIN WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; DROP TEMPORARY TABLE tmp.buyUltimate; - + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; @@ -129,6 +131,6 @@ BEGIN VALUES(vItemFk, vNewItemFk, 1) ON DUPLICATE KEY UPDATE counter = counter + 1; - COMMIT; + CALL util.tx_commit(vIsRequiredTx); END$$ DELIMITER ; diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js index 7412dcf965..9f02667315 100644 --- a/modules/ticket/back/methods/sale/replaceItem.js +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -73,10 +73,12 @@ module.exports = Self => { query: [sale.ticketFk] }; const salesPerson = await Self.rawSql(salesPersonQuery.sql, salesPersonQuery.query, myOptions); + if (tx) await tx.commit(); const url = await models.Url.getUrl(); const substitution = await models.Item.findById(substitutionFk, { fields: ['id', 'name', 'longName'] }, myOptions); + const message = $t('negativeReplaced', { oldItemId: sale.itemFk, oldItem: sale.item().longName, diff --git a/modules/ticket/back/methods/sale/specs/replaceItem.spec.js b/modules/ticket/back/methods/sale/specs/replaceItem.spec.js new file mode 100644 index 0000000000..6cb91aacef --- /dev/null +++ b/modules/ticket/back/methods/sale/specs/replaceItem.spec.js @@ -0,0 +1,61 @@ +const {models} = require('vn-loopback/server/server'); + +describe('Sale - replaceItem function', () => { + let options; + let tx; + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); + beforeEach(async() => { + tx = await models.Sale.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + if (tx) + await tx.rollback(); + }); + + it('should replace full item in sale and send notification', async() => { + const saleFk = 43; + const substitutionFk = 3; + const quantity = 15; + const ticketFk = 1000000; + + const salesBefore = await models.Sale.find({where: {ticketFk}}, options); + const salesLength = salesBefore.length; + + expect(1).toEqual(salesBefore.length); + + await models.Sale.replaceItem(ctx, saleFk, substitutionFk, quantity, options); + const salesAfter = await models.Sale.find({where: {ticketFk}}, options); + + expect(salesLength).toBeLessThan(salesAfter.length); + expect(salesAfter[0].id).toEqual(saleFk); + expect(salesAfter[salesLength].itemFk).toEqual(substitutionFk); + expect(salesAfter[salesLength].quantity).toEqual(quantity); + expect(salesAfter[0].quantity).toEqual(0); + expect(salesAfter[salesLength].concept).toMatch(/^\+/); + }); + + it('should replace half item in sale and send notification', async() => { + const saleFk = 43; + const substitutionFk = 3; + const quantity = 10; + const ticketFk = 1000000; + + const salesBefore = await models.Sale.find({where: {ticketFk}}, options); + const salesLength = salesBefore.length; + + expect(1).toEqual(salesBefore.length); + + await models.Sale.replaceItem(ctx, saleFk, substitutionFk, quantity, options); + const salesAfter = await models.Sale.find({where: {ticketFk}}, options); + + expect(salesLength).toBeLessThan(salesAfter.length); + expect(salesAfter[0].id).toEqual(saleFk); + expect(salesAfter[salesLength].itemFk).toEqual(substitutionFk); + expect(salesAfter[salesLength].quantity).toEqual(quantity); + expect(salesAfter[0].quantity).toEqual(5); + expect(salesAfter[salesLength].concept).toMatch(/^\+/); + }); +}); diff --git a/modules/ticket/back/methods/ticket/itemLack.js b/modules/ticket/back/methods/ticket/itemLack.js index 65abb1284b..7cda324598 100644 --- a/modules/ticket/back/methods/ticket/itemLack.js +++ b/modules/ticket/back/methods/ticket/itemLack.js @@ -15,7 +15,7 @@ module.exports = Self => { http: {source: 'query'} }, { - arg: 'itemFk', + arg: 'id', type: 'number', description: 'The item id', }, @@ -80,7 +80,7 @@ module.exports = Self => { Object.assign(myOptions, options); const filterKeyOrder = [ - 'days', 'itemFk', 'longname', 'supplier', + 'id', 'force', 'days', 'longname', 'supplier', 'colour', 'size', 'originFk', 'lack', 'warehouseFk' ]; @@ -88,13 +88,17 @@ module.exports = Self => { delete ctx?.args?.ctx; delete ctx?.args?.filter; - if (filter) - ctx.args = Object.assign(ctx.args ?? {}, filter); - let procedureParams = [true]; - procedureParams.push(...filterKeyOrder.map(clave => ctx.args[clave] ?? null)); + Object.assign(filter, ctx.args ?? {}); - if (!procedureParams[1])procedureParams[1] = 2; + let procedureParams = []; + procedureParams.push(...filterKeyOrder.map(clave => filter[clave] ?? null)); + + // Default values + const forceIndex = filterKeyOrder.indexOf('force'); + if (!procedureParams[forceIndex])procedureParams[forceIndex] = true; + const daysIndex = filterKeyOrder.indexOf('days'); + if (!procedureParams[daysIndex])procedureParams[daysIndex] = 2; const procedureArgs = Array(procedureParams.length).fill('?').join(', '); let query = `CALL vn.item_getLack(${procedureArgs})`; diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 4d3bdfe637..3ab22d9e58 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -8,7 +8,7 @@ module.exports = Self => { { arg: 'itemFk', type: 'number', - description: 'The item id', + description: 'The item as negative status', }, { arg: 'filter', @@ -43,6 +43,7 @@ module.exports = Self => { st.code, t.id, t.nickname, + c.id customerId, t.shipped, s.quantity, ag.name, @@ -52,7 +53,7 @@ module.exports = Self => { s.id saleFk, s.itemFk, s.price price, - al.code AS alertLevelCode, + al.code alertLevelCode, z.name zoneName, z.id zoneFk, Format(z.hour, "hh:mm") theoreticalhour, @@ -60,7 +61,7 @@ module.exports = Self => { IF(ISNULL(sc.saleClonedFk),0,1) turno, IF(ISNULL(tr.saleFk),0,1) peticionCompra, DATE_FORMAT(IF(HOUR(t.shipped), t.shipped, IF(zc.hour, zc.hour, z.hour)),'%H:%i') minTimed, - FALSE AS isBasket, + FALSE isBasket, substitution.hasSubstitution, IF(d.code = 'spainTeamVip', 1, 0) hasToIgnore FROM sale s @@ -80,24 +81,24 @@ module.exports = Self => { LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN ( - SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) AS hasSubstitution + SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasSubstitution FROM clientObservation co INNER JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' GROUP BY co.clientFk - ) AS substitution ON substitution.clientFk = c.id - WHERE warehouseFk = ? - AND s.itemFk = ? - AND s.quantity <> 0 - AND t.shipped >= util.VN_CURDATE() - AND t.shipped < DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) + ) substitution ON substitution.clientFk = c.id + WHERE t.warehouseFk = ? + AND s.itemFk = ? + AND s.quantity <> 0 + AND t.shipped BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) AND sgd.saleFk IS NULL - AND (al.code IN ('FREE', 'ON_PREVIOUS') OR al.code IS NULL) + AND (al.id = ? OR al.id IS NULL) UNION ALL SELECT r.id, NULL, r.orderFk, - c.name, + c.name customerName, + c.id customerId, r.shipment, r.amount, ag.name, @@ -131,21 +132,15 @@ module.exports = Self => { INNER JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' GROUP BY co.clientFk - ) AS substitution ON substitution.clientFk = c.id - WHERE r.shipment >= util.VN_CURDATE() + ) substitution ON substitution.clientFk = c.id + WHERE r.shipment BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) AND r.warehouseFk = ? - AND r.shipment < DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) AND r.created >= STR_TO_DATE(util.VN_CURDATE(), '%Y-%m-%d %H:%i:%s') AND NOT o.confirmed - AND r.itemFk = ? + AND r.itemFk = ? AND r.amount <> 0 ORDER BY hasToIgnore, isBasket;`, - [filter.where.warehouseFk, itemFk, 2, filter.where.warehouseFk, 2, itemFk]); - - if (filter.where.stateFk) { - stmt.merge({ - sql: `AND ts.alertLevel=?`, params: [filter.where.stateFk]}); - } + [filter.where.warehouseFk, itemFk, 2, filter.where.stateFk ?? 0, 2, filter.where.warehouseFk, itemFk]); const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions); diff --git a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js index 9af5910ea6..c746d989d9 100644 --- a/modules/ticket/back/methods/ticket/specs/itemLack.spec.js +++ b/modules/ticket/back/methods/ticket/specs/itemLack.spec.js @@ -1,136 +1,80 @@ -const models = require('vn-loopback/server/server').models; +const {models} = require('vn-loopback/server/server'); describe('Item Lack', () => { + let options; + let tx; + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); + beforeEach(async() => { - ctx = { - req: { - accessToken: {}, - headers: {origin: 'http://localhost'}, - } - }; + tx = await models.Ticket.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + if (tx) + await tx.rollback(); }); it('should return data with NO filters', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const filter = {}; - try { - const result = await models.Ticket.itemLack(ctx, filter, options); + const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(2); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(2); }); it('should return data with filter.id', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const filter = { - itemFk: 88 + id: 5 }; - try { - const result = await models.Ticket.itemLack(ctx, filter, options); + const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(1); }); it('should return data with filter.longname', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const filter = { longname: 'Ranged weapon pistol 9mm' }; - try { - const result = await models.Ticket.itemLack(ctx, filter, options); + const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(1); }); it('should return data with filter.color', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const filter = { colour: 'WHT' }; - try { - const result = await models.Ticket.itemLack(ctx, filter, options); + const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(1); }); it('should return data with filter.origen', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const filter = { originFk: 1 }; - try { - const result = await models.Ticket.itemLack(ctx, filter, options); + const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(2); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(2); }); it('should return data with filter.size', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const filter = { size: '15' }; - try { - const result = await models.Ticket.itemLack(ctx, filter, options); + const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(1); }); it('should return data with filter.lack', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const filter = { lack: '-15' }; - try { - const result = await models.Ticket.itemLack(ctx, filter, options); - expect(result.length).toEqual(1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + const result = await models.Ticket.itemLack(ctx, filter, options); + + expect(result.length).toEqual(1); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/split.spec.js b/modules/ticket/back/methods/ticket/specs/split.spec.js index e42d177c95..7543e47d65 100644 --- a/modules/ticket/back/methods/ticket/specs/split.spec.js +++ b/modules/ticket/back/methods/ticket/specs/split.spec.js @@ -1,99 +1,47 @@ -const models = require('vn-loopback/server/server').models; +const {models} = require('vn-loopback/server/server'); describe('Split', () => { - beforeAll(async() => { - ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'}, - __: () => {} - } - }; + let options; + let tx; + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); + + beforeEach(async() => { + tx = await models.Ticket.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + if (tx) + await tx.rollback(); }); it('should split tickets with count 1', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const data = - {ticketFk: 7, sales: [1]} - ; - try { - const result = await models.Ticket.split(ctx, data, options); + {ticketFk: 7, sales: [1]}; + const result = await models.Ticket.split(ctx, data, options); - expect(1).toEqual(result.length); - expect(data.ticketFk).toEqual(result[0].ticket); - expect('noSplit').toEqual(result[0].status); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(data.ticketFk).toEqual(result.ticket); + expect('noSplit').toEqual(result.status); }); it('should split tickets with count 2 and error', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const data = {ticketFk: 11, sales: [7]} ; - try { - const result = await models.Ticket.split(ctx, data, options); + const result = await models.Ticket.split(ctx, data, options); - expect(1).toEqual(result.length); - expect(data.ticketFk).toEqual(result[0].ticket); - expect('error').toEqual(result[0].status); - expect('Can\'t transfer claimed sales').toEqual(result[0].message); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - xit('should split tickets with count 2 and other error', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; - const data = - {ticketFk: 16, sales: [1, 2]} - ; - try { - const result = await models.Ticket.split(ctx, data, options); - - expect(1).toEqual(result.length); - expect(data.ticketFk).toEqual(result[0].ticket); - expect('error').toEqual(result[0].status); - expect('Can\'t transfer claimed sales').toEqual(result[0].message); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(data.ticketFk).toEqual(result.ticket); + expect('error').toEqual(result.status); + expect('Can\'t transfer claimed sales').toEqual(result.message); }); it('should split tickets with count 2 and success', async() => { - const tx = await models.Ticket.beginTransaction({}); - - const options = {transaction: tx}; const data = - {ticketFk: 14, sales: [33]} - ; - try { - const result = await models.Ticket.split(ctx, data, options); + {ticketFk: 14, sales: [33]}; + const result = await models.Ticket.split(ctx, data, options); - expect(1).toEqual(result.length); - expect(data.ticketFk).toEqual(result[0].ticket); - expect('split').toEqual(result[0].status); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(data.ticketFk).toEqual(result.ticket); + expect('split').toEqual(result.status); }); }); diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index 73fa7a9841..c8d2406d4a 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -38,52 +38,37 @@ module.exports = Self => { tx = await Self.beginTransaction({}); myOptions.transaction = tx; } - try { - const ticketsCount = await Self.rawSql(` - Select t.id tid, s.id sid, count(s.id) count - FROM - vn.ticket t - LEFT JOIN vn.sale s - ON s.ticketFk = t.id - WHERE t.id =? GROUP BY t.id;`, - [ticketFk], myOptions); + const count = await models.Sale.count({ + ticketFk + }, myOptions); + if (count === 1) + return {ticket: ticketFk, status: 'noSplit'}; + // continue; - for (const {tid, count} of ticketsCount) { - try { - if (count === 1) { - result.push({ticket: tid, status: 'noSplit'}); - continue; - } - - const [, [{vNewTicket}]] = await Self.rawSql(` + const [, [{vNewTicket}]] = await Self.rawSql(` CALL vn.ticket_clone(?, @vNewTicket); SELECT @vNewTicket vNewTicket;`, - [tid], myOptions); + [ticketFk], myOptions); - if (vNewTicket === 0) continue; - const sales = await models.Sale.find({ - where: {id: {inq: ticket.sales}} - }, myOptions); + if (vNewTicket === 0) return result; + const sales = await models.Sale.find({ + where: {id: {inq: ticket.sales}} + }, myOptions); - const updateIsPicked = sales.map(({sid}) => Self.rawSql(` + const updateIsPicked = sales.map(({sid}) => Self.rawSql(` UPDATE vn.sale SET isPicked = (id = ?) WHERE ticketFk = ?`, - [sid, tid], myOptions)); + [sid, ticketFk], myOptions)); - await Promise.all(updateIsPicked); - await Self.transferSales(ctx, tid, vNewTicket, sales, myOptions); + await Promise.all(updateIsPicked); + await Self.transferSales(ctx, ticketFk, vNewTicket, sales, myOptions); - await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [tid, 'FIXING'], myOptions); - result.push({ticket: tid, newTicket: vNewTicket, status: 'split'}); - if (tx) await tx.commit(); - } catch ({message}) { - result.push({ticket: tid, status: 'error', message}); - } - } - return result; + await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketFk, 'FIXING'], myOptions); + if (tx) await tx.commit(); + return {ticket: ticketFk, newTicket: vNewTicket, status: 'split'}; } catch (e) { if (tx) await tx.rollback(); - throw e; + return {ticket: ticketFk, status: 'error', message: e.message}; } }; }; From 5d209314f6a7bc1ac5865f0c9bacf12d72cf0f4e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 4 Feb 2025 14:09:48 +0100 Subject: [PATCH 68/88] feat: refs #6321 use Date.vnNew --- modules/item/back/methods/item/getSimilar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 7d904c782f..51d61c61c8 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -32,7 +32,7 @@ module.exports = Self => { const query = [ filter.itemFk, where.warehouseFk, - where.date ?? Date.vnNew().toISOString().split('T')[0], + where.date ?? Date.vnNew(), where.showType ?? true, where.scopeDays ?? 2 ]; From 272c7c028925c679abe1bc32e389f8924157604c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 4 Feb 2025 23:42:16 +0100 Subject: [PATCH 69/88] perf: refs #6321 minor changes --- .../11132-aquaDracena/00-firstScript.sql | 1 - loopback/locale/en.json | 5 +- loopback/locale/es.json | 800 +++++++++--------- .../ticket/back/methods/sale/replaceItem.js | 1 - modules/ticket/back/methods/ticket/split.js | 1 - 5 files changed, 401 insertions(+), 407 deletions(-) diff --git a/db/versions/11132-aquaDracena/00-firstScript.sql b/db/versions/11132-aquaDracena/00-firstScript.sql index 8d813ffd3a..e69de29bb2 100644 --- a/db/versions/11132-aquaDracena/00-firstScript.sql +++ b/db/versions/11132-aquaDracena/00-firstScript.sql @@ -1 +0,0 @@ -ALTER TABLE vn.negativeOrigin MODIFY COLUMN `type` enum('FALTAS','CONTENEDOR','ENTRADAS','OVERBOOKING', 'SUSTITUCION') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 9abf43d727..3f27859576 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -256,8 +256,5 @@ "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order.", "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", - "price retrieval failed": "price retrieval failed", - "workerSocialName": "workerSocialName", - "workerName": "workerName", - "The tag or priority can't be repeated for an item": "The tag or priority can't be repeated for an item", + "The tag or priority can't be repeated for an item": "The tag or priority can't be repeated for an item" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index dca19e4a63..24eb55a57e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -1,401 +1,401 @@ { - "Phone format is invalid": "El formato del teléfono no es correcto", - "You are not allowed to change the credit": "No tienes privilegios para modificar el crédito", - "Unable to mark the equivalence surcharge": "No se puede marcar el recargo de equivalencia", - "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado", - "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado", - "Can't be blank": "No puede estar en blanco", - "Invalid TIN": "NIF/CIF inválido", - "TIN must be unique": "El NIF/CIF debe ser único", - "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web", - "Is invalid": "Es inválido", - "Quantity cannot be zero": "La cantidad no puede ser cero", - "Enter an integer different to zero": "Introduce un entero distinto de cero", - "Package cannot be blank": "El embalaje no puede estar en blanco", - "The company name must be unique": "La razón social debe ser única", - "Invalid email": "Correo electrónico inválido", - "The IBAN does not have the correct format": "El IBAN no tiene el formato correcto", - "That payment method requires an IBAN": "El método de pago seleccionado requiere un IBAN", - "That payment method requires a BIC": "El método de pago seleccionado requiere un BIC", - "State cannot be blank": "El estado no puede estar en blanco", - "Worker cannot be blank": "El trabajador no puede estar en blanco", - "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado", - "can't be blank": "El campo no puede estar vacío", - "Observation type must be unique": "El tipo de observación no puede repetirse", - "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", - "The grade must be similar to the last one": "El grade debe ser similar al último", - "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", - "Name cannot be blank": "El nombre no puede estar en blanco", - "Phone cannot be blank": "El teléfono no puede estar en blanco", - "Period cannot be blank": "El periodo no puede estar en blanco", - "Choose a company": "Selecciona una empresa", - "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto", - "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres", - "Cannot be blank": "El campo no puede estar en blanco", - "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero", - "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco", - "Description cannot be blank": "Se debe rellenar el campo de texto", - "The price of the item changed": "El precio del artículo cambió", - "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%", - "The value should be a number": "El valor debe ser un numero", - "This order is not editable": "Esta orden no se puede modificar", - "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado", - "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda", - "is not a valid date": "No es una fecha valida", - "Barcode must be unique": "El código de barras debe ser único", - "The warehouse can't be repeated": "El almacén no puede repetirse", - "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item", - "The observation type can't be repeated": "El tipo de observación no puede repetirse", - "A claim with that sale already exists": "Ya existe una reclamación para esta línea", - "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo", - "Warehouse cannot be blank": "El almacén no puede quedar en blanco", - "Agency cannot be blank": "La agencia no puede quedar en blanco", - "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados", - "This address doesn't exist": "Este consignatario no existe", - "You must delete the claim id %d first": "Antes debes borrar la reclamación %d", - "You don't have enough privileges": "No tienes suficientes permisos", - "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF", - "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos básicos de una orden con artículos", - "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no está permitido el uso de la letra ñ", - "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", - "You can't create a ticket for an inactive client": "No puedes crear un ticket para un cliente inactivo", - "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", - "ORDER_EMPTY": "Cesta vacía", - "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", - "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", - "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", - "Street cannot be empty": "Dirección no puede estar en blanco", - "City cannot be empty": "Ciudad no puede estar en blanco", - "Code cannot be blank": "Código no puede estar en blanco", - "You cannot remove this department": "No puedes eliminar este departamento", - "The extension must be unique": "La extensión debe ser unica", - "The secret can't be blank": "La contraseña no puede estar en blanco", - "We weren't able to send this SMS": "No hemos podido enviar el SMS", - "This client can't be invoiced": "Este cliente no puede ser facturado", - "You must provide the correction information to generate a corrective invoice": "Debes informar la información de corrección para generar una factura rectificativa", - "This ticket can't be invoiced": "Este ticket no puede ser facturado", - "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado", - "This ticket can not be modified": "Este ticket no puede ser modificado", - "The introduced hour already exists": "Esta hora ya ha sido introducida", - "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", - "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", - "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", - "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", - "The current ticket can't be modified": "El ticket actual no puede ser modificado", - "The current claim can't be modified": "La reclamación actual no puede ser modificada", - "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", - "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", - "Please select at least one sale": "Por favor selecciona al menos una linea", - "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", - "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", - "This item doesn't exists": "El artículo no existe", - "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", - "Extension format is invalid": "El formato de la extensión es inválido", - "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket", - "This item is not available": "Este artículo no está disponible", - "This postcode already exists": "Este código postal ya existe", - "Concept cannot be blank": "El concepto no puede quedar en blanco", - "File doesn't exists": "El archivo no existe", - "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", - "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", - "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", - "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", - "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", - "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", - "Invalid quantity": "Cantidad invalida", - "This postal code is not valid": "Este código postal no es válido", - "is invalid": "es inválido", - "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto", - "The department name can't be repeated": "El nombre del departamento no puede repetirse", - "This phone already exists": "Este teléfono ya existe", - "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos", - "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado", - "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada", - "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero", - "You should specify a date": "Debes especificar una fecha", - "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fin", - "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fin", - "You should mark at least one week day": "Debes marcar al menos un día de la semana", - "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío", - "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios", - "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", - "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", - "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", - "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*", - "State": "Estado", - "regular": "normal", - "reserved": "reservado", - "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", - "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", - "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", - "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", - "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}", - "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*, con el tipo de recogida *{{claimPickup}}*", - "Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*", - "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", - "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", - "Distance must be lesser than 4000": "La distancia debe ser inferior a 4000", - "This ticket is deleted": "Este ticket está eliminado", - "Unable to clone this travel": "No ha sido posible clonar este travel", - "This thermograph id already exists": "La id del termógrafo ya existe", - "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", - "ORDER_ALREADY_CONFIRMED": "ORDEN YA CONFIRMADA", - "Invalid password": "Invalid password", - "Password does not meet requirements": "La contraseña no cumple los requisitos", - "Role already assigned": "Rol ya asignado", - "Invalid role name": "Nombre de rol no válido", - "Role name must be written in camelCase": "El nombre del rol debe escribirse en camelCase", - "Email already exists": "El correo ya existe", - "User already exists": "El/La usuario/a ya existe", - "Absence change notification on the labour calendar": "Notificación de cambio de ausencia en el calendario laboral", - "Record of hours week": "Registro de horas semana {{week}} año {{year}} ", - "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.", - "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.", - "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})", - "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})", - "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación", - "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "agencyModeFk": "Agencia", - "clientFk": "Cliente", - "zoneFk": "Zona", - "warehouseFk": "Almacén", - "shipped": "F. envío", - "landed": "F. entrega", - "addressFk": "Consignatario", - "companyFk": "Empresa", - "agency": "Agencia", - "delivery": "Reparto", - "The social name cannot be empty": "La razón social no puede quedar en blanco", - "The nif cannot be empty": "El NIF no puede quedar en blanco", - "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados", - "ASSIGN_ZONE_FIRST": "Asigna una zona primero", - "Amount cannot be zero": "El importe no puede ser cero", - "Company has to be official": "Empresa inválida", - "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria", - "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas", - "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", - "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", - "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", - "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío", - "This BIC already exist.": "Este BIC ya existe.", - "That item doesn't exists": "Ese artículo no existe", - "There's a new urgent ticket:": "Hay un nuevo ticket urgente:", - "Invalid account": "Cuenta inválida", - "Compensation account is empty": "La cuenta para compensar está vacia", - "This genus already exist": "Este genus ya existe", - "This specie already exist": "Esta especie ya existe", - "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})", - "None": "Ninguno", - "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada", - "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'", - "This document already exists on this ticket": "Este documento ya existe en el ticket", - "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables", - "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes", - "nickname": "nickname", - "INACTIVE_PROVIDER": "Proveedor inactivo", - "This client is not invoiceable": "Este cliente no es facturable", - "serial non editable": "Esta serie no permite asignar la referencia", - "Max shipped required": "La fecha límite es requerida", - "Can't invoice to future": "No se puede facturar a futuro", - "Can't invoice to past": "No se puede facturar a pasado", - "This ticket is already invoiced": "Este ticket ya está facturado", - "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero", - "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa", - "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes", - "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", - "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", - "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", - "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas", - "Amounts do not match": "Las cantidades no coinciden", - "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", - "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", - "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", - "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", - "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", - "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado", - "The account size must be exactly 10 characters": "El tamaño de la cuenta debe ser exactamente de 10 caracteres", - "Can't transfer claimed sales": "No puedes transferir lineas reclamadas", - "You don't have privileges to create refund": "No tienes permisos para crear un abono", - "The item is required": "El artículo es requerido", - "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", - "date in the future": "Fecha en el futuro", - "reference duplicated": "Referencia duplicada", - "This ticket is already a refund": "Este ticket ya es un abono", - "isWithoutNegatives": "Sin negativos", - "routeFk": "routeFk", - "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador", - "No hay un contrato en vigor": "No hay un contrato en vigor", - "No se permite fichar a futuro": "No se permite fichar a futuro", - "No está permitido trabajar": "No está permitido trabajar", - "Fichadas impares": "Fichadas impares", - "Descanso diario 12h.": "Descanso diario 12h.", - "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", - "Dirección incorrecta": "Dirección incorrecta", - "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", - "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", - "This route does not exists": "Esta ruta no existe", - "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", - "You don't have grant privilege": "No tienes privilegios para dar privilegios", - "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", - "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "Already has this status": "Ya tiene este estado", - "There aren't records for this week": "No existen registros para esta semana", - "Empty data source": "Origen de datos vacio", - "App locked": "Aplicación bloqueada por el usuario {{userId}}", - "Email verify": "Correo de verificación", - "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", - "Receipt's bank was not found": "No se encontró el banco del recibo", - "This receipt was not compensated": "Este recibo no ha sido compensado", - "Client's email was not found": "No se encontró el email del cliente", - "Negative basis": "Base negativa", - "This worker code already exists": "Este codigo de trabajador ya existe", - "This personal mail already exists": "Este correo personal ya existe", - "This worker already exists": "Este trabajador ya existe", - "App name does not exist": "El nombre de aplicación no es válido", - "Try again": "Vuelve a intentarlo", - "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", - "Failed to upload delivery note": "Error al subir albarán {{id}}", - "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", - "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", - "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", - "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas", - "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.", - "There is no assigned email for this client": "No hay correo asignado para este cliente", - "Exists an invoice with a future date": "Existe una factura con fecha posterior", - "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", - "Warehouse inventory not set": "El almacén inventario no está establecido", - "This locker has already been assigned": "Esta taquilla ya ha sido asignada", - "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %s", - "Not exist this branch": "La rama no existe", - "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", - "Collection does not exist": "La colección no existe", - "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", - "Insert a date range": "Inserte un rango de fechas", - "Added observation": "{{user}} añadió esta observacion: {{text}} {{defaulterId}} ({{{defaulterUrl}}})", - "Comment added to client": "Observación añadida al cliente {{clientFk}}", - "Invalid auth code": "Código de verificación incorrecto", - "Invalid or expired verification code": "Código de verificación incorrecto o expirado", - "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen", - "company": "Compañía", - "country": "País", - "clientId": "Id cliente", - "clientSocialName": "Cliente", - "amount": "Importe", - "taxableBase": "Base", - "ticketFk": "Id ticket", - "isActive": "Activo", - "hasToInvoice": "Facturar", - "isTaxDataChecked": "Datos comprobados", - "comercialId": "Id comercial", - "comercialName": "Comercial", - "Pass expired": "La contraseña ha caducado, cambiela desde Salix", - "Invalid NIF for VIES": "Invalid NIF for VIES", - "Ticket does not exist": "Este ticket no existe", - "Ticket is already signed": "Este ticket ya ha sido firmado", - "Authentication failed": "Autenticación fallida", - "You can't use the same password": "No puedes usar la misma contraseña", - "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono", - "Fecha fuera de rango": "Fecha fuera de rango", - "Error while generating PDF": "Error al generar PDF", - "Error when sending mail to client": "Error al enviar el correo al cliente", - "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", - "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", - "Valid priorities": "Prioridades válidas: %d", - "hasAnyNegativeBase": "Base negativa para los tickets: {{ticketsIds}}", - "hasAnyPositiveBase": "Base positivas para los tickets: {{ticketsIds}}", - "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", - "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s", - "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", - "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado", - "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado", - "You don't have enough privileges.": "No tienes suficientes permisos.", - "This ticket is locked": "Este ticket está bloqueado.", - "This ticket is not editable.": "Este ticket no es editable.", - "The ticket doesn't exist.": "No existe el ticket.", - "Social name should be uppercase": "La razón social debe ir en mayúscula", - "Street should be uppercase": "La dirección fiscal debe ir en mayúscula", - "Ticket without Route": "Ticket sin ruta", - "Select a different client": "Seleccione un cliente distinto", - "Fill all the fields": "Rellene todos los campos", - "The response is not a PDF": "La respuesta no es un PDF", - "Booking completed": "Reserva completada", - "The ticket is in preparation": "El ticket [{{ticketId}}]({{{ticketUrl}}}) del comercial {{salesPersonId}} está en preparación", - "The notification subscription of this worker cant be modified": "La subscripción a la notificación de este trabajador no puede ser modificada", - "User disabled": "Usuario desactivado", - "The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima", - "quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima", - "Cannot past travels with entries": "No se pueden pasar envíos con entradas", - "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", - "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 que cumplan los requisitos de facturación", - "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", - "An email is necessary": "Es necesario un email", - "You cannot update these fields": "No puedes actualizar estos campos", - "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", - "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", - "No invoice series found for these parameters": "No se encontró una serie para estos parámetros", - "The line could not be marked": "La linea no puede ser marcada", - "Through this procedure, it is not possible to modify the password of users with verified email": "Mediante este procedimiento, no es posible modificar la contraseña de usuarios con correo verificado", - "They're not your subordinate": "No es tu subordinado/a.", - "No results found": "No se han encontrado resultados", - "InvoiceIn is already booked": "La factura recibida está contabilizada", - "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", - "Select ticket or client": "Elija un ticket o un client", - "It was not able to create the invoice": "No se pudo crear la factura", - "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE", - "You can not use the same password": "No puedes usar la misma contraseña", - "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", - "You can only have one PDA": "Solo puedes tener un PDA", - "The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF", - "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", - "Payment method is required": "El método de pago es obligatorio", - "Cannot send mail": "Não é possível enviar o email", - "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", - "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", - "The entry not have stickers": "La entrada no tiene etiquetas", - "Too many records": "Demasiados registros", - "Original invoice not found": "Factura original no encontrada", - "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe", - "Weight already set": "El peso ya está establecido", - "This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento", - "There is already a tray with the same height": "Ya existe una bandeja con la misma altura", - "The height must be greater than 50cm": "La altura debe ser superior a 50cm", - "The maximum height of the wagon is 200cm": "La altura máxima es 200cm", - "The entry does not have stickers": "La entrada no tiene etiquetas", - "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha", - "No valid travel thermograph found": "No se encontró un termógrafo válido", - "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", - "type cannot be blank": "Se debe rellenar el tipo", - "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", - "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", - "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", - "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", - "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta", - "An item type with the same code already exists": "Un tipo con el mismo código ya existe", - "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", - "All tickets have a route order": "Todos los tickets tienen orden de ruta", - "There are tickets to be invoiced": "La zona tiene tickets por facturar", - "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", - "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.", - "Price cannot be blank": "El precio no puede estar en blanco" - -} + "Phone format is invalid": "El formato del teléfono no es correcto", + "You are not allowed to change the credit": "No tienes privilegios para modificar el crédito", + "Unable to mark the equivalence surcharge": "No se puede marcar el recargo de equivalencia", + "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado", + "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado", + "Can't be blank": "No puede estar en blanco", + "Invalid TIN": "NIF/CIF inválido", + "TIN must be unique": "El NIF/CIF debe ser único", + "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web", + "Is invalid": "Es inválido", + "Quantity cannot be zero": "La cantidad no puede ser cero", + "Enter an integer different to zero": "Introduce un entero distinto de cero", + "Package cannot be blank": "El embalaje no puede estar en blanco", + "The company name must be unique": "La razón social debe ser única", + "Invalid email": "Correo electrónico inválido", + "The IBAN does not have the correct format": "El IBAN no tiene el formato correcto", + "That payment method requires an IBAN": "El método de pago seleccionado requiere un IBAN", + "That payment method requires a BIC": "El método de pago seleccionado requiere un BIC", + "State cannot be blank": "El estado no puede estar en blanco", + "Worker cannot be blank": "El trabajador no puede estar en blanco", + "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado", + "can't be blank": "El campo no puede estar vacío", + "Observation type must be unique": "El tipo de observación no puede repetirse", + "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", + "The grade must be similar to the last one": "El grade debe ser similar al último", + "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", + "Name cannot be blank": "El nombre no puede estar en blanco", + "Phone cannot be blank": "El teléfono no puede estar en blanco", + "Period cannot be blank": "El periodo no puede estar en blanco", + "Choose a company": "Selecciona una empresa", + "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto", + "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres", + "Cannot be blank": "El campo no puede estar en blanco", + "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero", + "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco", + "Description cannot be blank": "Se debe rellenar el campo de texto", + "The price of the item changed": "El precio del artículo cambió", + "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%", + "The value should be a number": "El valor debe ser un numero", + "This order is not editable": "Esta orden no se puede modificar", + "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado", + "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda", + "is not a valid date": "No es una fecha valida", + "Barcode must be unique": "El código de barras debe ser único", + "The warehouse can't be repeated": "El almacén no puede repetirse", + "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item", + "The observation type can't be repeated": "El tipo de observación no puede repetirse", + "A claim with that sale already exists": "Ya existe una reclamación para esta línea", + "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo", + "Warehouse cannot be blank": "El almacén no puede quedar en blanco", + "Agency cannot be blank": "La agencia no puede quedar en blanco", + "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados", + "This address doesn't exist": "Este consignatario no existe", + "You must delete the claim id %d first": "Antes debes borrar la reclamación %d", + "You don't have enough privileges": "No tienes suficientes permisos", + "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF", + "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos básicos de una orden con artículos", + "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no está permitido el uso de la letra ñ", + "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", + "You can't create a ticket for an inactive client": "No puedes crear un ticket para un cliente inactivo", + "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", + "ORDER_EMPTY": "Cesta vacía", + "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", + "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", + "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", + "Street cannot be empty": "Dirección no puede estar en blanco", + "City cannot be empty": "Ciudad no puede estar en blanco", + "Code cannot be blank": "Código no puede estar en blanco", + "You cannot remove this department": "No puedes eliminar este departamento", + "The extension must be unique": "La extensión debe ser unica", + "The secret can't be blank": "La contraseña no puede estar en blanco", + "We weren't able to send this SMS": "No hemos podido enviar el SMS", + "This client can't be invoiced": "Este cliente no puede ser facturado", + "You must provide the correction information to generate a corrective invoice": "Debes informar la información de corrección para generar una factura rectificativa", + "This ticket can't be invoiced": "Este ticket no puede ser facturado", + "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado", + "This ticket can not be modified": "Este ticket no puede ser modificado", + "The introduced hour already exists": "Esta hora ya ha sido introducida", + "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", + "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", + "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", + "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", + "The current ticket can't be modified": "El ticket actual no puede ser modificado", + "The current claim can't be modified": "La reclamación actual no puede ser modificada", + "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", + "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", + "Please select at least one sale": "Por favor selecciona al menos una linea", + "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", + "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", + "This item doesn't exists": "El artículo no existe", + "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", + "Extension format is invalid": "El formato de la extensión es inválido", + "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket", + "This item is not available": "Este artículo no está disponible", + "This postcode already exists": "Este código postal ya existe", + "Concept cannot be blank": "El concepto no puede quedar en blanco", + "File doesn't exists": "El archivo no existe", + "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", + "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", + "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", + "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", + "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", + "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", + "Invalid quantity": "Cantidad invalida", + "This postal code is not valid": "Este código postal no es válido", + "is invalid": "es inválido", + "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto", + "The department name can't be repeated": "El nombre del departamento no puede repetirse", + "This phone already exists": "Este teléfono ya existe", + "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos", + "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado", + "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada", + "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero", + "You should specify a date": "Debes especificar una fecha", + "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fin", + "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fin", + "You should mark at least one week day": "Debes marcar al menos un día de la semana", + "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío", + "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios", + "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", + "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", + "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", + "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*", + "State": "Estado", + "regular": "normal", + "reserved": "reservado", + "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", + "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", + "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", + "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", + "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", + "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}", + "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*, con el tipo de recogida *{{claimPickup}}*", + "Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*", + "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", + "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", + "Distance must be lesser than 4000": "La distancia debe ser inferior a 4000", + "This ticket is deleted": "Este ticket está eliminado", + "Unable to clone this travel": "No ha sido posible clonar este travel", + "This thermograph id already exists": "La id del termógrafo ya existe", + "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", + "ORDER_ALREADY_CONFIRMED": "ORDEN YA CONFIRMADA", + "Invalid password": "Invalid password", + "Password does not meet requirements": "La contraseña no cumple los requisitos", + "Role already assigned": "Rol ya asignado", + "Invalid role name": "Nombre de rol no válido", + "Role name must be written in camelCase": "El nombre del rol debe escribirse en camelCase", + "Email already exists": "El correo ya existe", + "User already exists": "El/La usuario/a ya existe", + "Absence change notification on the labour calendar": "Notificación de cambio de ausencia en el calendario laboral", + "Record of hours week": "Registro de horas semana {{week}} año {{year}} ", + "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.", + "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.", + "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})", + "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})", + "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación", + "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "agencyModeFk": "Agencia", + "clientFk": "Cliente", + "zoneFk": "Zona", + "warehouseFk": "Almacén", + "shipped": "F. envío", + "landed": "F. entrega", + "addressFk": "Consignatario", + "companyFk": "Empresa", + "agency": "Agencia", + "delivery": "Reparto", + "The social name cannot be empty": "La razón social no puede quedar en blanco", + "The nif cannot be empty": "El NIF no puede quedar en blanco", + "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados", + "ASSIGN_ZONE_FIRST": "Asigna una zona primero", + "Amount cannot be zero": "El importe no puede ser cero", + "Company has to be official": "Empresa inválida", + "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria", + "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas", + "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", + "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", + "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", + "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío", + "This BIC already exist.": "Este BIC ya existe.", + "That item doesn't exists": "Ese artículo no existe", + "There's a new urgent ticket:": "Hay un nuevo ticket urgente:", + "Invalid account": "Cuenta inválida", + "Compensation account is empty": "La cuenta para compensar está vacia", + "This genus already exist": "Este genus ya existe", + "This specie already exist": "Esta especie ya existe", + "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})", + "None": "Ninguno", + "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada", + "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'", + "This document already exists on this ticket": "Este documento ya existe en el ticket", + "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables", + "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes", + "nickname": "nickname", + "INACTIVE_PROVIDER": "Proveedor inactivo", + "This client is not invoiceable": "Este cliente no es facturable", + "serial non editable": "Esta serie no permite asignar la referencia", + "Max shipped required": "La fecha límite es requerida", + "Can't invoice to future": "No se puede facturar a futuro", + "Can't invoice to past": "No se puede facturar a pasado", + "This ticket is already invoiced": "Este ticket ya está facturado", + "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero", + "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa", + "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes", + "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", + "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", + "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", + "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas", + "Amounts do not match": "Las cantidades no coinciden", + "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", + "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", + "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", + "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", + "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", + "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado", + "The account size must be exactly 10 characters": "El tamaño de la cuenta debe ser exactamente de 10 caracteres", + "Can't transfer claimed sales": "No puedes transferir lineas reclamadas", + "You don't have privileges to create refund": "No tienes permisos para crear un abono", + "The item is required": "El artículo es requerido", + "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", + "date in the future": "Fecha en el futuro", + "reference duplicated": "Referencia duplicada", + "This ticket is already a refund": "Este ticket ya es un abono", + "isWithoutNegatives": "Sin negativos", + "routeFk": "routeFk", + "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador", + "No hay un contrato en vigor": "No hay un contrato en vigor", + "No se permite fichar a futuro": "No se permite fichar a futuro", + "No está permitido trabajar": "No está permitido trabajar", + "Fichadas impares": "Fichadas impares", + "Descanso diario 12h.": "Descanso diario 12h.", + "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", + "Dirección incorrecta": "Dirección incorrecta", + "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", + "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", + "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", + "This route does not exists": "Esta ruta no existe", + "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", + "You don't have grant privilege": "No tienes privilegios para dar privilegios", + "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", + "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", + "Already has this status": "Ya tiene este estado", + "There aren't records for this week": "No existen registros para esta semana", + "Empty data source": "Origen de datos vacio", + "App locked": "Aplicación bloqueada por el usuario {{userId}}", + "Email verify": "Correo de verificación", + "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", + "Receipt's bank was not found": "No se encontró el banco del recibo", + "This receipt was not compensated": "Este recibo no ha sido compensado", + "Client's email was not found": "No se encontró el email del cliente", + "Negative basis": "Base negativa", + "This worker code already exists": "Este codigo de trabajador ya existe", + "This personal mail already exists": "Este correo personal ya existe", + "This worker already exists": "Este trabajador ya existe", + "App name does not exist": "El nombre de aplicación no es válido", + "Try again": "Vuelve a intentarlo", + "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", + "Failed to upload delivery note": "Error al subir albarán {{id}}", + "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", + "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", + "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", + "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas", + "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.", + "There is no assigned email for this client": "No hay correo asignado para este cliente", + "Exists an invoice with a future date": "Existe una factura con fecha posterior", + "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", + "Warehouse inventory not set": "El almacén inventario no está establecido", + "This locker has already been assigned": "Esta taquilla ya ha sido asignada", + "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %s", + "Not exist this branch": "La rama no existe", + "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", + "Collection does not exist": "La colección no existe", + "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", + "Insert a date range": "Inserte un rango de fechas", + "Added observation": "{{user}} añadió esta observacion: {{text}} {{defaulterId}} ({{{defaulterUrl}}})", + "Comment added to client": "Observación añadida al cliente {{clientFk}}", + "Invalid auth code": "Código de verificación incorrecto", + "Invalid or expired verification code": "Código de verificación incorrecto o expirado", + "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen", + "company": "Compañía", + "country": "País", + "clientId": "Id cliente", + "clientSocialName": "Cliente", + "amount": "Importe", + "taxableBase": "Base", + "ticketFk": "Id ticket", + "isActive": "Activo", + "hasToInvoice": "Facturar", + "isTaxDataChecked": "Datos comprobados", + "comercialId": "Id comercial", + "comercialName": "Comercial", + "Pass expired": "La contraseña ha caducado, cambiela desde Salix", + "Invalid NIF for VIES": "Invalid NIF for VIES", + "Ticket does not exist": "Este ticket no existe", + "Ticket is already signed": "Este ticket ya ha sido firmado", + "Authentication failed": "Autenticación fallida", + "You can't use the same password": "No puedes usar la misma contraseña", + "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono", + "Fecha fuera de rango": "Fecha fuera de rango", + "Error while generating PDF": "Error al generar PDF", + "Error when sending mail to client": "Error al enviar el correo al cliente", + "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", + "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", + "Valid priorities": "Prioridades válidas: %d", + "hasAnyNegativeBase": "Base negativa para los tickets: {{ticketsIds}}", + "hasAnyPositiveBase": "Base positivas para los tickets: {{ticketsIds}}", + "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", + "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s", + "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", + "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado", + "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado", + "You don't have enough privileges.": "No tienes suficientes permisos.", + "This ticket is locked": "Este ticket está bloqueado.", + "This ticket is not editable.": "Este ticket no es editable.", + "The ticket doesn't exist.": "No existe el ticket.", + "Social name should be uppercase": "La razón social debe ir en mayúscula", + "Street should be uppercase": "La dirección fiscal debe ir en mayúscula", + "Ticket without Route": "Ticket sin ruta", + "Select a different client": "Seleccione un cliente distinto", + "Fill all the fields": "Rellene todos los campos", + "The response is not a PDF": "La respuesta no es un PDF", + "Booking completed": "Reserva completada", + "The ticket is in preparation": "El ticket [{{ticketId}}]({{{ticketUrl}}}) del comercial {{salesPersonId}} está en preparación", + "The notification subscription of this worker cant be modified": "La subscripción a la notificación de este trabajador no puede ser modificada", + "User disabled": "Usuario desactivado", + "The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima", + "quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima", + "Cannot past travels with entries": "No se pueden pasar envíos con entradas", + "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", + "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 que cumplan los requisitos de facturación", + "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", + "An email is necessary": "Es necesario un email", + "You cannot update these fields": "No puedes actualizar estos campos", + "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", + "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", + "No invoice series found for these parameters": "No se encontró una serie para estos parámetros", + "The line could not be marked": "La linea no puede ser marcada", + "Through this procedure, it is not possible to modify the password of users with verified email": "Mediante este procedimiento, no es posible modificar la contraseña de usuarios con correo verificado", + "They're not your subordinate": "No es tu subordinado/a.", + "No results found": "No se han encontrado resultados", + "InvoiceIn is already booked": "La factura recibida está contabilizada", + "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", + "Select ticket or client": "Elija un ticket o un client", + "It was not able to create the invoice": "No se pudo crear la factura", + "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE", + "You can not use the same password": "No puedes usar la misma contraseña", + "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", + "You can only have one PDA": "Solo puedes tener un PDA", + "The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF", + "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", + "Payment method is required": "El método de pago es obligatorio", + "Cannot send mail": "Não é possível enviar o email", + "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", + "The entry not have stickers": "La entrada no tiene etiquetas", + "Too many records": "Demasiados registros", + "Original invoice not found": "Factura original no encontrada", + "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe", + "Weight already set": "El peso ya está establecido", + "This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento", + "There is already a tray with the same height": "Ya existe una bandeja con la misma altura", + "The height must be greater than 50cm": "La altura debe ser superior a 50cm", + "The maximum height of the wagon is 200cm": "La altura máxima es 200cm", + "The entry does not have stickers": "La entrada no tiene etiquetas", + "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha", + "No valid travel thermograph found": "No se encontró un termógrafo válido", + "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", + "type cannot be blank": "Se debe rellenar el tipo", + "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", + "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", + "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", + "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", + "The web user's email already exists": "El correo del usuario web ya existe", + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta", + "An item type with the same code already exists": "Un tipo con el mismo código ya existe", + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", + "All tickets have a route order": "Todos los tickets tienen orden de ruta", + "There are tickets to be invoiced": "La zona tiene tickets por facturar", + "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", + "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.", + "Price cannot be blank": "El precio no puede estar en blanco", + "negativeReplaced": "negativeReplaced" +} \ No newline at end of file diff --git a/modules/ticket/back/methods/sale/replaceItem.js b/modules/ticket/back/methods/sale/replaceItem.js index 9f02667315..b1702f17f5 100644 --- a/modules/ticket/back/methods/sale/replaceItem.js +++ b/modules/ticket/back/methods/sale/replaceItem.js @@ -73,7 +73,6 @@ module.exports = Self => { query: [sale.ticketFk] }; const salesPerson = await Self.rawSql(salesPersonQuery.sql, salesPersonQuery.query, myOptions); - if (tx) await tx.commit(); const url = await models.Url.getUrl(); const substitution = await models.Item.findById(substitutionFk, { fields: ['id', 'name', 'longName'] diff --git a/modules/ticket/back/methods/ticket/split.js b/modules/ticket/back/methods/ticket/split.js index c8d2406d4a..23223db7d7 100644 --- a/modules/ticket/back/methods/ticket/split.js +++ b/modules/ticket/back/methods/ticket/split.js @@ -44,7 +44,6 @@ module.exports = Self => { }, myOptions); if (count === 1) return {ticket: ticketFk, status: 'noSplit'}; - // continue; const [, [{vNewTicket}]] = await Self.rawSql(` CALL vn.ticket_clone(?, @vNewTicket); From e02dcf23b71eaf8174bd496ed783d68d2f902247 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 5 Feb 2025 15:36:01 +0100 Subject: [PATCH 70/88] feat: refs #6321 add columns ticketConfigs --- db/versions/11132-aquaDracena/00-firstScript.sql | 2 ++ modules/ticket/back/models/ticket-config.json | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/db/versions/11132-aquaDracena/00-firstScript.sql b/db/versions/11132-aquaDracena/00-firstScript.sql index e69de29bb2..08bfca3edc 100644 --- a/db/versions/11132-aquaDracena/00-firstScript.sql +++ b/db/versions/11132-aquaDracena/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.ticketConfig ADD lackAlertPrice int(11) DEFAULT 30 NOT NULL COMMENT 'Value to alert when item proposal exceed price'; +ALTER TABLE vn.ticketConfig ADD lackScopeDays int(11) DEFAULT 2 NOT NULL COMMENT 'Number of days to look back for ticket with negatives'; diff --git a/modules/ticket/back/models/ticket-config.json b/modules/ticket/back/models/ticket-config.json index 6dd2808eac..7a008f97e3 100644 --- a/modules/ticket/back/models/ticket-config.json +++ b/modules/ticket/back/models/ticket-config.json @@ -26,6 +26,12 @@ }, "defaultAttenderFk": { "type": "number" + }, + "lackAlertPrice": { + "type": "number" + }, + "lackScopeDays": { + "type": "number" } }, "relations": { From 1f6f7b99758617ece9ce722c346127ddec69078c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 00:34:08 +0100 Subject: [PATCH 71/88] feat: refs #6321 updates requested --- db/routines/vn/procedures/item_getLack.sql | 4 ++-- loopback/locale/en.json | 2 +- modules/item/back/methods/item/getSimilar.js | 6 ++--- .../methods/supplier/getItemsPackaging.js | 2 +- .../back/methods/ticket/itemLackDetail.js | 24 ++++++++++++------- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/item_getLack.sql b/db/routines/vn/procedures/item_getLack.sql index f70705fa35..1a54f03962 100644 --- a/db/routines/vn/procedures/item_getLack.sql +++ b/db/routines/vn/procedures/item_getLack.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getLack`( vForce BOOLEAN, vDays INT, vLongname VARCHAR(255), - vSupplierFk VARCHAR(255), + vProducerName VARCHAR(255), vColor VARCHAR(255), vSize INT, vOrigen INT, @@ -60,7 +60,7 @@ BEGIN AND it.code != 'GEN' AND (vSelf IS NULL OR i.id = vSelf) AND (vLongname IS NULL OR i.name = vLongname) - AND (vSupplierFk IS NULL OR p.`name` LIKE CONCAT('%', vSupplierFk, '%')) + AND (vProducerName IS NULL OR p.`name` LIKE CONCAT('%', vProducerName, '%')) AND (vColor IS NULL OR vColor = i.inkFk) AND (vSize IS NULL OR vSize = i.`size`) AND (vOrigen IS NULL OR vOrigen = w.id) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 3f27859576..27c6ac2161 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -256,5 +256,5 @@ "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order.", "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", - "The tag or priority can't be repeated for an item": "The tag or priority can't be repeated for an item" + "The tag and priority can't be repeated": "The tag and priority can't be repeated" } diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 51d61c61c8..2479d08b52 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -32,9 +32,9 @@ module.exports = Self => { const query = [ filter.itemFk, where.warehouseFk, - where.date ?? Date.vnNew(), - where.showType ?? true, - where.scopeDays ?? 2 + where.date, + where.showType, + where.scopeDays ]; const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?, ?)', query, myOptions); diff --git a/modules/supplier/back/methods/supplier/getItemsPackaging.js b/modules/supplier/back/methods/supplier/getItemsPackaging.js index 8a27c89c4b..8231e9936f 100644 --- a/modules/supplier/back/methods/supplier/getItemsPackaging.js +++ b/modules/supplier/back/methods/supplier/getItemsPackaging.js @@ -44,7 +44,7 @@ module.exports = Self => { JOIN hedera.imageConfig ic WHERE e.supplierFk = ? AND i.family IN ('EMB', 'CONT') - AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH) + AND b.created > util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH) GROUP BY b.itemFk ORDER BY et.quantity DESC, quantityTotal DESC`, [entry, id, id]); }; diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 3ab22d9e58..10d6c8fa91 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -62,7 +62,7 @@ module.exports = Self => { IF(ISNULL(tr.saleFk),0,1) peticionCompra, DATE_FORMAT(IF(HOUR(t.shipped), t.shipped, IF(zc.hour, zc.hour, z.hour)),'%H:%i') minTimed, FALSE isBasket, - substitution.hasSubstitution, + substitution.hasObservation, IF(d.code = 'spainTeamVip', 1, 0) hasToIgnore FROM sale s LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id @@ -81,7 +81,7 @@ module.exports = Self => { LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN ( - SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasSubstitution + SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasObservation FROM clientObservation co INNER JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' @@ -92,7 +92,7 @@ module.exports = Self => { AND s.quantity <> 0 AND t.shipped BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) AND sgd.saleFk IS NULL - AND (al.id = ? OR al.id IS NULL) + AND (al.code IN (?) OR al.id IS NULL) UNION ALL SELECT r.id, NULL, @@ -117,7 +117,7 @@ module.exports = Self => { NULL, NULL, TRUE, - substitution.hasSubstitution, + substitution.hasObservation, IF(d.code = 'spainTeamVip', 1, 0) FROM hedera.orderRow r INNER JOIN hedera.order o ON o.id = r.orderFk @@ -127,7 +127,7 @@ module.exports = Self => { LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN ( - SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasSubstitution + SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasObservation FROM clientObservation co INNER JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' @@ -135,12 +135,20 @@ module.exports = Self => { ) substitution ON substitution.clientFk = c.id WHERE r.shipment BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) AND r.warehouseFk = ? - AND r.created >= STR_TO_DATE(util.VN_CURDATE(), '%Y-%m-%d %H:%i:%s') + AND r.created >= util.VN_CURDATE() AND NOT o.confirmed AND r.itemFk = ? - AND r.amount <> 0 + AND r.amount ORDER BY hasToIgnore, isBasket;`, - [filter.where.warehouseFk, itemFk, 2, filter.where.stateFk ?? 0, 2, filter.where.warehouseFk, itemFk]); + [ + filter.where.warehouseFk, + itemFk, + 2, + filter.where.alertLevelCode, + 2, + filter.where.warehouseFk, + itemFk + ]); const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions); From b2cbded2dc54c14054dabfdc7622ed6815c8a02f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 01:06:02 +0100 Subject: [PATCH 72/88] feat: refs #6321 defaultAlertLevelCode --- db/versions/11132-aquaDracena/00-firstScript.sql | 1 + modules/ticket/back/models/ticket-config.json | 3 +++ 2 files changed, 4 insertions(+) diff --git a/db/versions/11132-aquaDracena/00-firstScript.sql b/db/versions/11132-aquaDracena/00-firstScript.sql index 08bfca3edc..d922fa54d0 100644 --- a/db/versions/11132-aquaDracena/00-firstScript.sql +++ b/db/versions/11132-aquaDracena/00-firstScript.sql @@ -1,2 +1,3 @@ ALTER TABLE vn.ticketConfig ADD lackAlertPrice int(11) DEFAULT 30 NOT NULL COMMENT 'Value to alert when item proposal exceed price'; +ALTER TABLE vn.ticketConfig ADD lackDefaultAlertLevelCode varchar(45) DEFAULT 'FREE' NOT NULL COMMENT 'Default alertLevelCode to retrieve tickets with negatives'; ALTER TABLE vn.ticketConfig ADD lackScopeDays int(11) DEFAULT 2 NOT NULL COMMENT 'Number of days to look back for ticket with negatives'; diff --git a/modules/ticket/back/models/ticket-config.json b/modules/ticket/back/models/ticket-config.json index 7a008f97e3..677695595c 100644 --- a/modules/ticket/back/models/ticket-config.json +++ b/modules/ticket/back/models/ticket-config.json @@ -30,6 +30,9 @@ "lackAlertPrice": { "type": "number" }, + "lackDefaultAlertLevelCode": { + "type": "string" + }, "lackScopeDays": { "type": "number" } From 24411f9af12f94dd0eece43c511b6ac3cc316bfd Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 08:17:03 +0100 Subject: [PATCH 73/88] fix: refs #6321 revert change --- modules/supplier/back/methods/supplier/getItemsPackaging.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/supplier/back/methods/supplier/getItemsPackaging.js b/modules/supplier/back/methods/supplier/getItemsPackaging.js index 8231e9936f..8a27c89c4b 100644 --- a/modules/supplier/back/methods/supplier/getItemsPackaging.js +++ b/modules/supplier/back/methods/supplier/getItemsPackaging.js @@ -44,7 +44,7 @@ module.exports = Self => { JOIN hedera.imageConfig ic WHERE e.supplierFk = ? AND i.family IN ('EMB', 'CONT') - AND b.created > util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH) + AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH) GROUP BY b.itemFk ORDER BY et.quantity DESC, quantityTotal DESC`, [entry, id, id]); }; From 1af01ad747f7ce712d987f83a8d8f424fad248c0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 10:26:38 +0100 Subject: [PATCH 74/88] feat: refs #6321 sql lackDetail step1 --- .../back/methods/ticket/itemLackDetail.js | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 10d6c8fa91..2b341e5e7c 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -35,11 +35,10 @@ module.exports = Self => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - - const stmt = new ParameterizedSQL( - ` - SELECT - s.id, + const vDated = Date.vnNew(); + const scopeDays = filter.where.scopeDays ?? 2; + const stmt = new ParameterizedSQL(` + SELECT s.id, st.code, t.id, t.nickname, @@ -56,24 +55,24 @@ module.exports = Self => { al.code alertLevelCode, z.name zoneName, z.id zoneFk, - Format(z.hour, "hh:mm") theoreticalhour, + z.hour theoreticalhour, cn.isRookie, - IF(ISNULL(sc.saleClonedFk),0,1) turno, - IF(ISNULL(tr.saleFk),0,1) peticionCompra, + sc.saleClonedFk turno, + tr.saleFk peticionCompra, DATE_FORMAT(IF(HOUR(t.shipped), t.shipped, IF(zc.hour, zc.hour, z.hour)),'%H:%i') minTimed, FALSE isBasket, substitution.hasObservation, - IF(d.code = 'spainTeamVip', 1, 0) hasToIgnore + d.code = 'spainTeamVip' hasToIgnore FROM sale s LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id - INNER JOIN ticket t ON t.id =s.ticketFk + JOIN ticket t ON t.id = s.ticketFk LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = DATE(t.shipped) - INNER JOIN client c ON c.id=t.clientFk + JOIN client c ON c.id=t.clientFk LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id - INNER JOIN agencyMode ag ON ag.id=t.agencyModeFk - INNER JOIN ticketState tls ON tls.ticketFk=t.id + JOIN agencyMode ag ON ag.id=t.agencyModeFk + JOIN ticketState tls ON tls.ticketFk=t.id LEFT JOIN state st ON st.id=tls.state LEFT JOIN alertLevel al ON al.id = st.alertLevel LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.id @@ -83,7 +82,7 @@ module.exports = Self => { LEFT JOIN ( SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasObservation FROM clientObservation co - INNER JOIN observationType ot ON ot.id = co.observationTypeFk + JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' GROUP BY co.clientFk ) substitution ON substitution.clientFk = c.id @@ -118,11 +117,11 @@ module.exports = Self => { NULL, TRUE, substitution.hasObservation, - IF(d.code = 'spainTeamVip', 1, 0) + d.code = 'spainTeamVip' FROM hedera.orderRow r - INNER JOIN hedera.order o ON o.id = r.orderFk - INNER JOIN client c ON c.id = o.customer_id - INNER JOIN agencyMode ag ON ag.id=o.agency_id + JOIN hedera.order o ON o.id = r.orderFk + JOIN client c ON c.id = o.customer_id + JOIN agencyMode ag ON ag.id=o.agency_id LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk LEFT JOIN department d ON d.id = wd.departmentFk @@ -139,16 +138,17 @@ module.exports = Self => { AND NOT o.confirmed AND r.itemFk = ? AND r.amount - ORDER BY hasToIgnore, isBasket;`, - [ - filter.where.warehouseFk, - itemFk, - 2, - filter.where.alertLevelCode, - 2, - filter.where.warehouseFk, - itemFk - ]); + ORDER BY hasToIgnore, isBasket + `, + [ + filter.where.warehouseFk, + itemFk, + scopeDays, + filter.where.alertLevelCode, + scopeDays, + filter.where.warehouseFk, + itemFk + ]); const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions); From e736c95fb69ec1bc4a08c37736c771a02ef16357 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 10:29:48 +0100 Subject: [PATCH 75/88] feat: refs #6321 sql lackDetail step2 --- modules/ticket/back/methods/ticket/itemLackDetail.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 2b341e5e7c..2f922e9860 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -68,7 +68,7 @@ module.exports = Self => { JOIN ticket t ON t.id = s.ticketFk LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk - AND zc.dated = DATE(t.shipped) + AND t.shipped BETWEEN zc.dated AND util.dayEnd(t.shipped) JOIN client c ON c.id=t.clientFk LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id JOIN agencyMode ag ON ag.id=t.agencyModeFk @@ -128,13 +128,13 @@ module.exports = Self => { LEFT JOIN ( SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasObservation FROM clientObservation co - INNER JOIN observationType ot ON ot.id = co.observationTypeFk + JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' GROUP BY co.clientFk ) substitution ON substitution.clientFk = c.id WHERE r.shipment BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) + AND r.created >= ? AND r.warehouseFk = ? - AND r.created >= util.VN_CURDATE() AND NOT o.confirmed AND r.itemFk = ? AND r.amount @@ -146,6 +146,7 @@ module.exports = Self => { scopeDays, filter.where.alertLevelCode, scopeDays, + vDated, filter.where.warehouseFk, itemFk ]); From 3dd64e4257127f93370614b785a49280de2a718a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 10:31:43 +0100 Subject: [PATCH 76/88] feat: refs #6321 sql lackDetail step3 --- modules/ticket/back/methods/ticket/itemLackDetail.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 2f922e9860..68fe8c44dd 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -132,7 +132,7 @@ module.exports = Self => { WHERE ot.code = 'substitution' GROUP BY co.clientFk ) substitution ON substitution.clientFk = c.id - WHERE r.shipment BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) + WHERE r.shipment BETWEEN ? AND ? + INTERVAL ? DAY AND r.created >= ? AND r.warehouseFk = ? AND NOT o.confirmed @@ -146,7 +146,7 @@ module.exports = Self => { scopeDays, filter.where.alertLevelCode, scopeDays, - vDated, + vDated, vDated, vDated, filter.where.warehouseFk, itemFk ]); From 4c7b8212da78d4a1827dc178da14d557d77bdcb9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 12:27:59 +0100 Subject: [PATCH 77/88] feat: refs #6321 changes --- .../back/methods/ticket/itemLackDetail.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 68fe8c44dd..f7317e990a 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -35,8 +35,14 @@ module.exports = Self => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const vDated = Date.vnNew(); + const vDated = (Date.vnNew()); + vDated.setHours(0, 0, 0, 0); const scopeDays = filter.where.scopeDays ?? 2; + let alertLevels = filter.where.alertLevelCode; + + if (!alertLevels) + alertLevels = (await Self.app.models.AlertLevel.find({fields: ['code']})).map(({code}) => code); + const stmt = new ParameterizedSQL(` SELECT s.id, st.code, @@ -89,7 +95,9 @@ module.exports = Self => { WHERE t.warehouseFk = ? AND s.itemFk = ? AND s.quantity <> 0 - AND t.shipped BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) + + AND t.shipped BETWEEN ? AND (? + INTERVAL ? DAY) + AND sgd.saleFk IS NULL AND (al.code IN (?) OR al.id IS NULL) UNION ALL @@ -133,7 +141,7 @@ module.exports = Self => { GROUP BY co.clientFk ) substitution ON substitution.clientFk = c.id WHERE r.shipment BETWEEN ? AND ? + INTERVAL ? DAY - AND r.created >= ? + AND r.created >= ? AND r.warehouseFk = ? AND NOT o.confirmed AND r.itemFk = ? @@ -143,8 +151,9 @@ module.exports = Self => { [ filter.where.warehouseFk, itemFk, + vDated, vDated, scopeDays, - filter.where.alertLevelCode, + alertLevels, scopeDays, vDated, vDated, vDated, filter.where.warehouseFk, From 8170eafa3694ab41d52809f3176db227c3f7cccc Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 15:19:07 +0100 Subject: [PATCH 78/88] feat: refs #6321 remove ticketConfig var --- db/versions/11132-aquaDracena/00-firstScript.sql | 1 - modules/ticket/back/models/ticket-config.json | 3 --- 2 files changed, 4 deletions(-) diff --git a/db/versions/11132-aquaDracena/00-firstScript.sql b/db/versions/11132-aquaDracena/00-firstScript.sql index d922fa54d0..08bfca3edc 100644 --- a/db/versions/11132-aquaDracena/00-firstScript.sql +++ b/db/versions/11132-aquaDracena/00-firstScript.sql @@ -1,3 +1,2 @@ ALTER TABLE vn.ticketConfig ADD lackAlertPrice int(11) DEFAULT 30 NOT NULL COMMENT 'Value to alert when item proposal exceed price'; -ALTER TABLE vn.ticketConfig ADD lackDefaultAlertLevelCode varchar(45) DEFAULT 'FREE' NOT NULL COMMENT 'Default alertLevelCode to retrieve tickets with negatives'; ALTER TABLE vn.ticketConfig ADD lackScopeDays int(11) DEFAULT 2 NOT NULL COMMENT 'Number of days to look back for ticket with negatives'; diff --git a/modules/ticket/back/models/ticket-config.json b/modules/ticket/back/models/ticket-config.json index 677695595c..7a008f97e3 100644 --- a/modules/ticket/back/models/ticket-config.json +++ b/modules/ticket/back/models/ticket-config.json @@ -30,9 +30,6 @@ "lackAlertPrice": { "type": "number" }, - "lackDefaultAlertLevelCode": { - "type": "string" - }, "lackScopeDays": { "type": "number" } From 338e833c0bff375eca53d87846008839bf3bf8f5 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 15:19:23 +0100 Subject: [PATCH 79/88] feat: refs #6321 i18n --- loopback/locale/en.json | 2 +- loopback/locale/fr.json | 2 +- loopback/locale/pt.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 27c6ac2161..8db0bb026f 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -255,6 +255,6 @@ "Holidays to past days not available": "Holidays to past days not available", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order.", - "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", "The tag and priority can't be repeated": "The tag and priority can't be repeated" } diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 5db9e178fe..b61c46a760 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -369,6 +369,6 @@ "The web user's email already exists": "L'email de l'internaute existe déjà", "Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}", "Ticket has been delivered out of order": "Le ticket {{ticket}} de la route {{{fullUrl}}} a été livré hors service.", - "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 44ad468c33..9ad3afa4d8 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -368,6 +368,6 @@ "The web user's email already exists": "O e-mail do utilizador da web já existe.", "Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "O ticket {{ticket}} da rota {{{fullUrl}}} foi entregue fora de ordem.", - "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", } From 9626b6c0ff9d54f6ce65d460bf3c3a436a5ecfa5 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 15:19:39 +0100 Subject: [PATCH 80/88] feat: refs #6321 update itemLackDetail --- modules/ticket/back/methods/ticket/itemLackDetail.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index f7317e990a..4b8d048f87 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -53,8 +53,8 @@ module.exports = Self => { s.quantity, ag.name, ag.id agencyFk, - IF(ISNULL(tls.alertLevel),0,tls.alertLevel) alertLevel, - IF(ISNULL(st.name),'Libre',st.name) stateName, + tls.alertLevel alertLevel, + st.name stateName, s.id saleFk, s.itemFk, s.price price, @@ -68,7 +68,7 @@ module.exports = Self => { DATE_FORMAT(IF(HOUR(t.shipped), t.shipped, IF(zc.hour, zc.hour, z.hour)),'%H:%i') minTimed, FALSE isBasket, substitution.hasObservation, - d.code = 'spainTeamVip' hasToIgnore + (d.code = 'spainTeamVip') hasToIgnore FROM sale s LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id JOIN ticket t ON t.id = s.ticketFk From 4e4d6c3b6a1f1791625e04f5a364c096d9c5ffe2 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 15:20:44 +0100 Subject: [PATCH 81/88] fix: refs #6321 fixtures --- db/dump/fixtures.before.sql | 64 +++++++++++-------------------------- 1 file changed, 18 insertions(+), 46 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 389b224284..61341e878a 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -798,7 +798,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), - (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL); + (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (1000000, NULL, 1, 1, NULL, '2001-01-01 00:00:00.000', '2001-01-01', 1, 'employee', 131, NULL, 0, 1, 1.00, 0.00, '2025-02-06 00:00:00.000', NULL, NULL, '', NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -1002,7 +1003,8 @@ VALUES (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), - (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0); + (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (88, 1, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', 'Stark Industries', 10.0, 'VT', 0, NULL, NULL, 1, NULL, 0); -- Update the taxClass after insert of the items @@ -1125,7 +1127,8 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasItemLost'), (41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasRounding,hasItemLost'), - (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasRounding,hasItemLost'); + (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasRounding,hasItemLost'), + (43, 88, 1000000, 'Chest medical box 2', 15.00, 10.00, 0, 0, 0, '2025-02-06 00:00:00.000', ''); INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) VALUES @@ -1452,12 +1455,19 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) (93, 14, 58, 'medical box', 2), (94, 14, 27, '100cm', 3), (95, 14, 36, 'Stark Industries', 4), - (96, 14, 1, 'White', 5), + (96, 14, 1, 'White', 5), (97, 14, 67, 'supply', 6), (98, 14, 23, '1', 7), (99, 15, 92, 'Trolley', 2), (100, 16, 92, 'Pallet', 2), - (101, 71, 92, 'Shipping cost', 2); + (101, 71, 92, 'Shipping cost', 2), + (102, 88, 56, 'Chest', 1), + (103, 88, 58, 'ammo box', 2), + (104, 88, 27, '100cm', 3), + (105, 88, 36, 'Stark Industries', 4), + (106, 88, 1, 'Green', 5), + (107, 88, 67, 'supply', 6), + (108, 88, 23, '13', 7); INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) VALUES @@ -1585,7 +1595,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'), (17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), - (18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); + (18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), + (10000002, 12, 88, 50.0000, 5000, '4', 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, util.VN_CURDATE() - INTERVAL 2 MONTH); INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES @@ -4111,43 +4122,4 @@ INSERT IGNORE INTO vn.vehicleType (id, name) VALUES (1,'vehículo empresa'), (2, 'furgoneta'), (3, 'cabeza tractora'), - (4, 'remolque');-- Negativos - -INSERT INTO `vn`.`item` (id, name, `size`, stems, minPrice, isToPrint, family, box, originFk, doPhoto, image, inkFk, intrastatFk, hasMinPrice, created, typeFk, generic, density, relevancy, expenseFk, isActive, longName, subName, tag5, value5, tag6, value6, tag7, value7, minimum, upToDown, hasKgPrice, isFloramondo, isFragile, stemMultiplier, isLaid, lastUsed, editorFk, isBoxPickingMode) - VALUES - (88, 'Lack negative', 200, 1, 10.0, 0, 'VT', 0, 2, 0, '', 'WHT', 6021010, 1, util.VN_CURDATE(), 1, 0, 167, 0, '4751000000', 1, 'Lack negative origin', 'Stark Industries', 'Color', 'White', 'Categoria', 'supply', 'Tallos', '1', 3, 0, 0, 0, 0, 1.0, 0, util.VN_CURDATE(), 100, 0); - -INSERT INTO `vn`.`ticket` (id, clientFk, 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, problem, risk) - VALUES - (1000000, 1, 1, util.VN_CURDATE(), 'employee', NULL, 131, NULL, NULL, 0, 0, 0, 0, NULL, 0, CURDATE(), 1, NULL, NULL, NULL, 1, 442, 1, util.VN_CURDATE(), 0, 0, 1, 1.00, 0.00, 0.00, NULL, NULL, NULL, NULL, 9, '', NULL); - -INSERT INTO `vn`.`sale` (id, itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded, total, editorFk, problem) - VALUES - (43, 88, 1000000, 'Chest medical box 2', 15.00, 155.0, 10.00, 0, 0.00, 0, 0, 0, CURDATE(), 0, 1550.00, 100, ''); --- Negativos - --- Item proposal - -INSERT INTO `cache`.`visible` (`calc_id`, `item_id`, `visible`) - VALUES - (16, 5, 5500), - (16, 1, 5500), - (16, 2, 5500), - (16, 3, 5500), - (16, 4, 5500), - (16, 88, 5500), - (16, 6, 5500), - (16, 10, 5500); - -INSERT INTO `cache`.`available` (`calc_id`, `item_id`, `available`) - VALUES - (14, 1, 5000), - (14, 2, 5000), - (14, 3, 5000), - (14, 4, 5000), - (14, 5, 5000), - (14, 88, 5000), - (14, 6, 5000), - (14, 10, 5000); - --- Item proposal + (4, 'remolque'); From ba58746a030c1ca025e1e8e101ca3cadf596f989 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 23:22:58 +0100 Subject: [PATCH 82/88] fix: refs #6321 test --- db/dump/fixtures.before.sql | 2 +- modules/ticket/back/methods/ticket/itemLackDetail.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 61341e878a..733a04aa8e 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1465,7 +1465,7 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) (103, 88, 58, 'ammo box', 2), (104, 88, 27, '100cm', 3), (105, 88, 36, 'Stark Industries', 4), - (106, 88, 1, 'Green', 5), + (106, 88, 1, 'White', 5), (107, 88, 67, 'supply', 6), (108, 88, 23, '13', 7); diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 4b8d048f87..44c26bb3bd 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -86,7 +86,7 @@ module.exports = Self => { LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN ( - SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasObservation + SELECT co.clientFk, COUNT(*) hasObservation FROM clientObservation co JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' @@ -134,7 +134,7 @@ module.exports = Self => { LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN ( - SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasObservation + SELECT co.clientFk, COUNT(*) hasObservation FROM clientObservation co JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' From 9390c0efedb180902b0cdf7c140f1391ef639bf7 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 7 Feb 2025 07:53:00 +0100 Subject: [PATCH 83/88] test: refs #6321 getSimilar.spec.js --- modules/item/back/methods/item/getSimilar.js | 2 +- .../methods/item/specs/getSimilar.spec.js | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 modules/item/back/methods/item/specs/getSimilar.spec.js diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 2479d08b52..05c4a20e53 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('getSimilar', { + Self.remoteMethod('getSimilar', { description: 'Returns list of items with similar item requested', accessType: 'READ', accepts: [ diff --git a/modules/item/back/methods/item/specs/getSimilar.spec.js b/modules/item/back/methods/item/specs/getSimilar.spec.js new file mode 100644 index 0000000000..5dec077b66 --- /dev/null +++ b/modules/item/back/methods/item/specs/getSimilar.spec.js @@ -0,0 +1,49 @@ +const models = require('vn-loopback/server/server').models; + +describe('Item get similar', () => { + let options; + let tx; + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); + beforeEach(async() => { + tx = await models.Item.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + if (tx) + await tx.rollback(); + }); + + it('should return similar items', async() => { + const filter = { + itemFk: 88, sales: 43, + where: { + 'scopeDays': '2', + 'showType': true, + 'alertLevelCode': 'FREE', + 'date': '2001-01-01T11:00:00.000Z', + 'warehouseFk': 1 + } + }; + const result = await models.Item.getSimilar(ctx, filter, options); + + expect(result.length).toEqual(2); + }); + + it('should return empty array is if not exists', async() => { + const filter = { + itemFk: 88, sales: 43, + where: { + 'scopeDays': '2', + 'showType': true, + 'alertLevelCode': 'FREE', + 'date': '2001-01-01T11:00:00.000Z', + 'warehouseFk': 60 + } + }; + const result = await models.Item.getSimilar(ctx, filter, options); + + expect(result.length).toEqual(0); + }); +}); From e035a73e064d7eddb2d0e12d8b8d08e70fc9b979 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 7 Feb 2025 07:57:10 +0100 Subject: [PATCH 84/88] feat: refs #6321 i18n es negativeReplaced --- loopback/locale/es.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 4abf005318..a56d4eaa40 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -397,5 +397,6 @@ "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.", "Price cannot be blank": "El precio no puede estar en blanco", - "clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}" -} \ No newline at end of file + "clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}", + "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", +} From 9322360979a8fbcb57a86a42d79326907f9f6fca Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 7 Feb 2025 08:41:49 +0100 Subject: [PATCH 85/88] fix: refs #6321 dates in fixtures.before --- db/dump/fixtures.before.sql | 4 ++-- .../back/methods/route/specs/getSuggestedTickets.spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 733a04aa8e..5a35e26434 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -799,7 +799,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), - (1000000, NULL, 1, 1, NULL, '2001-01-01 00:00:00.000', '2001-01-01', 1, 'employee', 131, NULL, 0, 1, 1.00, 0.00, '2025-02-06 00:00:00.000', NULL, NULL, '', NULL); + (1000000, NULL, 1, 1, NULL, util.VN_CURDATE(), CURDATE(), 1, 'employee', 131, NULL, 0, 1, 1.00, 0.00, util.VN_CURDATE(), NULL, NULL, '', NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -1128,7 +1128,7 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasItemLost'), (41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasRounding,hasItemLost'), (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasRounding,hasItemLost'), - (43, 88, 1000000, 'Chest medical box 2', 15.00, 10.00, 0, 0, 0, '2025-02-06 00:00:00.000', ''); + (43, 88, 1000000, 'Chest medical box 2', 15.00, 10.00, 0, 0, 0, util.VN_CURDATE(), ''); INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) VALUES diff --git a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js index 3d6702482d..0acc6c1a7b 100644 --- a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js +++ b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js @@ -31,7 +31,7 @@ describe('route getSuggestedTickets()', () => { const length = result.length; const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - expect(result.length).toEqual(5); + expect(result.length).toEqual(4); expect(anyResult.zoneFk).toEqual(1); expect(anyResult.agencyModeFk).toEqual(8); From f4dbddbe153615381c38cff94c0ded16d5887388 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 7 Feb 2025 09:54:55 +0100 Subject: [PATCH 86/88] fix: refs #6321 dates in fixtures.before --- db/dump/fixtures.before.sql | 4 ++-- loopback/locale/es.json | 2 +- .../back/methods/route/specs/getSuggestedTickets.spec.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 5a35e26434..b255d169a3 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -799,7 +799,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), - (1000000, NULL, 1, 1, NULL, util.VN_CURDATE(), CURDATE(), 1, 'employee', 131, NULL, 0, 1, 1.00, 0.00, util.VN_CURDATE(), NULL, NULL, '', NULL); + (1000000, NULL, 1, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1, 'employee', 131, NULL, 0, 1, 1.00, 0.00, CURDATE(), NULL, NULL, '', NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -1128,7 +1128,7 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasItemLost'), (41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasRounding,hasItemLost'), (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack,hasRounding,hasItemLost'), - (43, 88, 1000000, 'Chest medical box 2', 15.00, 10.00, 0, 0, 0, util.VN_CURDATE(), ''); + (43, 88, 1000000, 'Chest medical box 2', 15.00, 10.00, 0, 0, 0, CURDATE(), ''); INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) VALUES diff --git a/loopback/locale/es.json b/loopback/locale/es.json index a56d4eaa40..0dbfc45d0e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -22,7 +22,7 @@ "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado", "can't be blank": "El campo no puede estar vacío", "Observation type must be unique": "El tipo de observación no puede repetirse", - "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", + "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", "The grade must be similar to the last one": "El grade debe ser similar al último", "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", "Name cannot be blank": "El nombre no puede estar en blanco", diff --git a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js index 0acc6c1a7b..3d6702482d 100644 --- a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js +++ b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js @@ -31,7 +31,7 @@ describe('route getSuggestedTickets()', () => { const length = result.length; const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - expect(result.length).toEqual(4); + expect(result.length).toEqual(5); expect(anyResult.zoneFk).toEqual(1); expect(anyResult.agencyModeFk).toEqual(8); From 9bb273807de6b90b1f642f92b86116c711f78fbf Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 7 Feb 2025 16:18:26 +0100 Subject: [PATCH 87/88] feat: refs #6321 i18n negativeReplaced --- loopback/locale/en.json | 2 +- loopback/locale/es.json | 2 +- loopback/locale/fr.json | 3 +-- loopback/locale/pt.json | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 7dea0829a9..b9add02a8c 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -256,6 +256,6 @@ "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order.", "clonedFromTicketWeekly": ", that is a cloned sale from ticket {{ ticketWeekly }}", - "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "negativeReplaced": "Replaced item [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} with [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} from ticket [{{ticketId}}]({{{ticketUrl}}})", "The tag and priority can't be repeated": "The tag and priority can't be repeated" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 0dbfc45d0e..61e05f7367 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -398,5 +398,5 @@ "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.", "Price cannot be blank": "El precio no puede estar en blanco", "clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}", - "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})" } diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index b61c46a760..1dd33fed96 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -369,6 +369,5 @@ "The web user's email already exists": "L'email de l'internaute existe déjà", "Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}", "Ticket has been delivered out of order": "Le ticket {{ticket}} de la route {{{fullUrl}}} a été livré hors service.", - "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", - + "negativeReplaced": "Remplacé l'article [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} par [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} du ticket [{{ticketId}}]({{{ticketUrl}}})" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 9ad3afa4d8..84bd14a6de 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -368,6 +368,5 @@ "The web user's email already exists": "O e-mail do utilizador da web já existe.", "Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}", "Ticket has been delivered out of order": "O ticket {{ticket}} da rota {{{fullUrl}}} foi entregue fora de ordem.", - "negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", - + "negativeReplaced": "Substituído o artigo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} do ticket [{{ticketId}}]({{{ticketUrl}}})" } From e748c3ea686486c1f3f67f978189eb823c3aa3bb Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 7 Feb 2025 22:40:00 +0100 Subject: [PATCH 88/88] feat: refs #6321 minor changes --- db/versions/10936-wheatAnthurium/00-updateACL.sql | 1 - modules/ticket/back/methods/ticket/itemLackDetail.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/db/versions/10936-wheatAnthurium/00-updateACL.sql b/db/versions/10936-wheatAnthurium/00-updateACL.sql index fbf714f9c9..16073a23d7 100644 --- a/db/versions/10936-wheatAnthurium/00-updateACL.sql +++ b/db/versions/10936-wheatAnthurium/00-updateACL.sql @@ -2,6 +2,5 @@ INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee'), ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee'), - ('Ticket','itemLackOrigin','WRITE','ALLOW','ROLE','employee'), ('Ticket','split','WRITE','ALLOW','ROLE','employee'), ('Sale','replaceItem','WRITE','ALLOW','ROLE','employee'); diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 44c26bb3bd..fb8ce682f6 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -37,7 +37,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); const vDated = (Date.vnNew()); vDated.setHours(0, 0, 0, 0); - const scopeDays = filter.where.scopeDays ?? 2; + const scopeDays = filter.where.scopeDays ?? 0; let alertLevels = filter.where.alertLevelCode; if (!alertLevels)