From 961fafb33e4c3e204e8e5a43ceebf8a0ccf41ec8 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 5 Aug 2024 15:32:36 +0200 Subject: [PATCH 01/11] feat: refs #7404 stockBought add and calculate --- back/models/buyer.json | 3 + db/dump/fixtures.before.sql | 17 ++++++ .../vn/procedures/stockBought_calculate.sql | 54 ++++++++++++++++++ db/routines/vn/views/buyer.sql | 4 +- .../11115-turquoiseRose/00-firstScript.sql | 30 ++++++++++ loopback/locale/en.json | 8 ++- loopback/locale/es.json | 5 +- .../account/back/models/mail-alias-account.js | 1 + modules/entry/back/methods/entry/filter.js | 1 - .../methods/stock-bought/getStockBought.js | 52 +++++++++++++++++ .../stock-bought/getStockBoughtDetail.js | 56 +++++++++++++++++++ modules/entry/back/model-config.json | 3 + modules/entry/back/models/stock-bought.js | 10 ++++ modules/entry/back/models/stock-bought.json | 34 +++++++++++ 14 files changed, 272 insertions(+), 6 deletions(-) create mode 100644 db/routines/vn/procedures/stockBought_calculate.sql create mode 100644 db/versions/11115-turquoiseRose/00-firstScript.sql create mode 100644 modules/entry/back/methods/stock-bought/getStockBought.js create mode 100644 modules/entry/back/methods/stock-bought/getStockBoughtDetail.js create mode 100644 modules/entry/back/models/stock-bought.js create mode 100644 modules/entry/back/models/stock-bought.json diff --git a/back/models/buyer.json b/back/models/buyer.json index a17d3b538..a1297eda3 100644 --- a/back/models/buyer.json +++ b/back/models/buyer.json @@ -15,6 +15,9 @@ "nickname": { "type": "string", "required": true + }, + "display": { + "type": "boolean" } }, "acls": [ diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f800a1da1..7f3ede501 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3882,3 +3882,20 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli (1, '2001-05-17', 1, 5), (1, '2001-05-18', 1, 5); +INSERT INTO vn.stockBought (workerFk, bought, reserve, dated) + VALUES(35, 1.00, 1.00, '2001-01-01'); + +INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk) + VALUES (1,0.6,6); + +INSERT INTO vn.warehouse (id,name,isFeedStock,delay,hasAvailable,isForTicket,countryFk,labelZone,hasComission,isInventory,isComparative,valuatedInventory,isManaged,hasConfectionTeam,hasStowaway,hasDms,isBuyerToBeEmailed,hasUbications,hasProduction,hasMachine,isLogiflora,isBionic,isHalt,isOrigin,isDestiny) + VALUES (6,'Warehouse six',0,0.004,1,0,1,0,0,1,1,0,1,0,0,0,0,1,1,0,0,1,0,0,0); + +INSERT INTO vn.travel (id,shipped,landed,warehouseInFk,warehouseOutFk,agencyFk__,`ref`,isDelivered,isReceived,m3,kg,cargoSupplierFk,totalEntries,agencyModeFk,editorFk,awbFk) + VALUES (11,'2001-01-01','2001-01-02',6,3,0,'eleventh travel',0,0,50.00,500,2,0,1,100,4); + +INSERT INTO vn.entry (id,supplierFk,invoiceNumber,isBooked,isExcludedFromAvailable,isConfirmed,isOrdered,isRaid,commission,created,evaNotes,travelFk,currencyFk,companyFk,isBlocked__,reference,editorFk,locked) + VALUES (9,69,'IN2009',0,1,0,0,1,0.0,'2000-12-01 00:00:00.000','',11,1,442,0,'Movement 9',100,'2024-07-30 08:13:49.000'); + +INSERT INTO vn.buy (entryFk,itemFk,quantity,dispatched,buyingValue,freightValue,isIgnored,stickers,packing,`grouping`,groupingMode,comissionValue,packageValue,packagingFk,price1,price2,price3,minPrice,printedStickers,workerFk,isChecked,isPickedOff,created,`__cm2`,weight,itemOriginalFk,editorFk,buyerFk) + VALUES (9,1,5000,0,50.0000,1.500,0,1,1,1,'packing',0.000,1.500,'4',0.00,99.60,99.40,0.00,0,0,1,0,'2024-07-30 08:13:51.000',0,1.00,1,100,35); diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql new file mode 100644 index 000000000..54ac78d8e --- /dev/null +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -0,0 +1,54 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calculate`() +BEGIN +/** + * Inserts the purchase volume per buyer + * into stockBought according to the date. + * + * @param vDated Purchase date + */ + DECLARE vDated DATE; + SET vDated = util.VN_CURDATE(); + + CREATE OR REPLACE TEMPORARY TABLE tStockBought + SELECT workerFk, reserve + FROM stockBought + WHERE dated = vDated + AND reserve; + + DELETE FROM stockBought WHERE dated = vDated; + + INSERT INTO stockBought (workerFk, bought, dated) + SELECT it.workerFk, + ROUND(SUM( + (ac.conversionCoefficient * + (b.quantity / b.packing) * + buy_getVolume(b.id) + ) / (vc.trolleyM3 * 1000000) + ), 1), + vDated + FROM entry e + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + JOIN buy b ON b.entryFk = e.id + JOIN item i ON i.id = b.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN auctionConfig ac + JOIN volumeConfig vc + WHERE t.shipped = vDated + AND t.warehouseInFk = ac.warehouseFk + GROUP BY it.workerFk; + + UPDATE stockBought s + JOIN tStockBought ts ON ts.workerFk = s.workerFk + SET s.reserve = ts.reserve + WHERE s.dated = vDated; + + INSERT INTO stockBought (workerFk, reserve, dated) + SELECT ts.workerFk, ts.reserve, vDated + FROM tStockBought ts + WHERE ts.workerFk NOT IN (SELECT workerFk FROM stockBought WHERE dated = vDated); + + DROP TEMPORARY TABLE tStockBought; +END$$ +DELIMITER ; diff --git a/db/routines/vn/views/buyer.sql b/db/routines/vn/views/buyer.sql index 7114c50bc..455c68770 100644 --- a/db/routines/vn/views/buyer.sql +++ b/db/routines/vn/views/buyer.sql @@ -2,10 +2,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`buyer` AS SELECT DISTINCT `u`.`id` AS `userFk`, - `u`.`nickname` AS `nickname` + `u`.`nickname` AS `nickname`, + `ic`.`display` AS `display` FROM ( `account`.`user` `u` JOIN `vn`.`itemType` `it` ON(`it`.`workerFk` = `u`.`id`) + JOIN `vn`.`itemCategory` `ic` ON(`ic`.`id` = `it`.`categoryFk`) ) WHERE `u`.`active` <> 0 ORDER BY `u`.`nickname` diff --git a/db/versions/11115-turquoiseRose/00-firstScript.sql b/db/versions/11115-turquoiseRose/00-firstScript.sql new file mode 100644 index 000000000..3982936fc --- /dev/null +++ b/db/versions/11115-turquoiseRose/00-firstScript.sql @@ -0,0 +1,30 @@ +-- Place your SQL code here +-- vn.stockBought definition + +CREATE TABLE IF NOT EXISTS vn.stockBought ( + id INT UNSIGNED auto_increment NOT NULL, + workerFk int(10) unsigned NOT NULL, + bought decimal(10,2) NOT NULL COMMENT 'purchase volume in m3 for the day', + reserve decimal(10,2) NULL COMMENT 'reserved volume in m3 for the day', + dated DATE NOT NULL DEFAULT current_timestamp(), + CONSTRAINT stockBought_pk PRIMARY KEY (id), + CONSTRAINT stockBought_unique UNIQUE KEY (workerFk,dated), + CONSTRAINT stockBought_worker_FK FOREIGN KEY (workerFk) REFERENCES vn.worker(id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + + +INSERT IGNORE vn.stockBought (workerFk, bought, reserve, dated) + SELECT userFk, SUM(buyed), SUM(IFNULL(reserved,0)), dated + FROM vn.stockBuyed + WHERE userFk IS NOT NULL + AND buyed IS NOT NULL + GROUP BY userFk, dated; + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('StockBought','*','READ','ALLOW','ROLE','buyer'), + ('StockBought','*','WRITE','ALLOW','ROLE','buyer'), + ('Buyer','*','READ','ALLOW','ROLE','buyer'); + diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 1e5733442..79f7eecc5 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -233,5 +233,9 @@ "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", + "Payment method is required": "Payment method is required", + "This worker already exists": "This worker already exists", + "This personal mail already exists": "This personal mail already exists", + "This buyer has already made a reservation for this date": "This buyer has already made a reservation for this date" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 5b5928993..a11fb6f7c 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -366,5 +366,6 @@ "It has been invoiced but the PDF 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" -} + "Cannot send mail": "Não é possível enviar o email", + "This buyer has already made a reservation for this date": "This buyer has already made a reservation for this date" +} \ No newline at end of file diff --git a/modules/account/back/models/mail-alias-account.js b/modules/account/back/models/mail-alias-account.js index 61ca344e9..0eee6a123 100644 --- a/modules/account/back/models/mail-alias-account.js +++ b/modules/account/back/models/mail-alias-account.js @@ -1,5 +1,6 @@ const ForbiddenError = require('vn-loopback/util/forbiddenError'); +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.rewriteDbError(function(err) { diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 1cd12b737..a8a9d4de1 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; diff --git a/modules/entry/back/methods/stock-bought/getStockBought.js b/modules/entry/back/methods/stock-bought/getStockBought.js new file mode 100644 index 000000000..da194ed80 --- /dev/null +++ b/modules/entry/back/methods/stock-bought/getStockBought.js @@ -0,0 +1,52 @@ +module.exports = Self => { + Self.remoteMethod('getStockBought', { + description: 'Returns the stock bought for a given date', + accessType: 'READ', + accepts: [{ + arg: 'dated', + type: 'date', + description: 'The date to filter', + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/getStockBought`, + verb: 'GET' + } + }); + + Self.getStockBought = async(dated = Date.vnNew()) => { + const models = Self.app.models; + const today = Date.vnNew(); + dated.setHours(0, 0, 0, 0); + today.setHours(0, 0, 0, 0); + + if (dated.getTime() === today.getTime()) + await models.StockBought.rawSql(`CALL vn.stockBought_calculate()`); + + return models.StockBought.find( + { + where: { + dated: dated + }, + include: [ + { + relation: 'worker', + scope: { + include: [ + { + relation: 'user', + scope: { + fields: ['id', 'name'] + } + } + ] + } + } + ] + }); + }; +}; diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js new file mode 100644 index 000000000..471d5c9c4 --- /dev/null +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -0,0 +1,56 @@ +module.exports = Self => { + Self.remoteMethod('getStockBoughtDetail', { + description: 'Returns the detail of stock bought for a given date and a worker', + accessType: 'READ', + accepts: [{ + arg: 'workerFk', + type: 'number', + description: 'The worker to filter', + required: true, + }, { + arg: 'dated', + type: 'string', + description: 'The date to filter', + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/getStockBoughtDetail`, + verb: 'GET' + } + }); + + Self.getStockBoughtDetail = async(workerFk, dated = Date.vnNew()) => { + console.log('dated: ', new Date(dated)); + console.log('new Date(dated).setHours(0, 0, 0, 0): ', new Date(dated).setHours(0, 0, 0, 0)); + return Self.rawSql( + `SELECT e.id entryFk, + i.id itemFk, + i.longName itemName, + b.quantity, + ROUND((ac.conversionCoefficient * + (b.quantity / b.packing) * + buy_getVolume(b.id) + ) / (vc.trolleyM3 * 1000000), + 2 + ) volume, + b.packagingFk, + b.packing + FROM entry e + JOIN travel t ON t.id = e.travelFk + JOIN buy b ON b.entryFk = e.id + JOIN item i ON i.id = b.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN worker w ON w.id = it.workerFk + JOIN auctionConfig ac + JOIN volumeConfig vc + WHERE t.warehouseInFk = ac.warehouseFk + AND it.workerFk = ? + AND t.shipped = ?`, + [workerFk, new Date(dated)] + ); + }; +}; diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index dc7fd86be..85f5e8285 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -25,5 +25,8 @@ }, "EntryType": { "dataSource": "vn" + }, + "StockBought": { + "dataSource": "vn" } } \ No newline at end of file diff --git a/modules/entry/back/models/stock-bought.js b/modules/entry/back/models/stock-bought.js new file mode 100644 index 000000000..ae52e7654 --- /dev/null +++ b/modules/entry/back/models/stock-bought.js @@ -0,0 +1,10 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + require('../methods/stock-bought/getStockBought')(Self); + require('../methods/stock-bought/getStockBoughtDetail')(Self); + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`This buyer has already made a reservation for this date`); + return err; + }); +}; diff --git a/modules/entry/back/models/stock-bought.json b/modules/entry/back/models/stock-bought.json new file mode 100644 index 000000000..18c9f0347 --- /dev/null +++ b/modules/entry/back/models/stock-bought.json @@ -0,0 +1,34 @@ +{ + "name": "StockBought", + "base": "VnModel", + "options": { + "mysql": { + "table": "stockBought" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "workerFk": { + "type": "number" + }, + "bought": { + "type": "number" + }, + "reserve": { + "type": "number" + }, + "dated": { + "type": "date" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } + } +} From 47543d5760cdfcb848eaaacb5b4f094b687d8c2e Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 5 Aug 2024 15:34:01 +0200 Subject: [PATCH 02/11] refactor: refs #7404 remove console.log --- modules/entry/back/methods/stock-bought/getStockBoughtDetail.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js index 471d5c9c4..0657fcb9a 100644 --- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -24,8 +24,6 @@ module.exports = Self => { }); Self.getStockBoughtDetail = async(workerFk, dated = Date.vnNew()) => { - console.log('dated: ', new Date(dated)); - console.log('new Date(dated).setHours(0, 0, 0, 0): ', new Date(dated).setHours(0, 0, 0, 0)); return Self.rawSql( `SELECT e.id entryFk, i.id itemFk, From 6d25cb3c8c1e4a89ecbe133759519f67578cdda7 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 5 Aug 2024 15:35:48 +0200 Subject: [PATCH 03/11] fix: refs #7404 fix translation --- loopback/locale/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index a11fb6f7c..4c7df3e0c 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -366,6 +366,6 @@ "It has been invoiced but the PDF 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", + "Cannot send mail": "No se ha podido enviar el correo", "This buyer has already made a reservation for this date": "This buyer has already made a reservation for this date" } \ No newline at end of file From 0e7272f911d2c2214ae16e0a8d852f95092eb336 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 5 Aug 2024 15:42:21 +0200 Subject: [PATCH 04/11] fix: refs #7404 fix error message --- modules/entry/back/methods/entry/print.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/print.js index c155c3d8b..626e212b7 100644 --- a/modules/entry/back/methods/entry/print.js +++ b/modules/entry/back/methods/entry/print.js @@ -52,7 +52,7 @@ module.exports = Self => { await merger.add(new Uint8Array(pdfBuffer[0])); } - if (!merger._doc) throw new UserError('The entry not have stickers'); + if (!merger._doc) throw new UserError('The entry does not have stickers'); return [await merger.saveAsBuffer(), 'application/pdf', `filename="entry-${id}.pdf"`]; }; }; From 323ab638d79abbc5228d9c152305bf8fe6043af8 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 5 Aug 2024 15:55:44 +0200 Subject: [PATCH 05/11] fix: refs #7404 fix fixtures and back test --- db/dump/fixtures.before.sql | 51 ++++++++----------- .../back/methods/entry/specs/filter.spec.js | 4 +- .../travel/specs/extraCommunityFilter.spec.js | 4 +- .../back/methods/travel/specs/filter.spec.js | 4 +- 4 files changed, 26 insertions(+), 37 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index a0f2537d1..69d838998 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3929,44 +3929,33 @@ INSERT INTO vn.travel (id,shipped,landed,warehouseInFk,warehouseOutFk,agencyFk__ VALUES (11,'2001-01-01','2001-01-02',6,3,0,'eleventh travel',0,0,50.00,500,2,0,1,100,4); INSERT INTO vn.entry (id,supplierFk,invoiceNumber,isBooked,isExcludedFromAvailable,isConfirmed,isOrdered,isRaid,commission,created,evaNotes,travelFk,currencyFk,companyFk,isBlocked__,reference,editorFk,locked) - VALUES (9,69,'IN2009',0,1,0,0,1,0.0,'2000-12-01 00:00:00.000','',11,1,442,0,'Movement 9',100,'2024-07-30 08:13:49.000'); + VALUES (99,69,'IN2009',0,1,0,0,1,0.0,'2000-12-01 00:00:00.000','',11,1,442,0,'Movement 9',100,'2024-07-30 08:13:49.000'); INSERT INTO vn.buy (entryFk,itemFk,quantity,dispatched,buyingValue,freightValue,isIgnored,stickers,packing,`grouping`,groupingMode,comissionValue,packageValue,packagingFk,price1,price2,price3,minPrice,printedStickers,workerFk,isChecked,isPickedOff,created,`__cm2`,weight,itemOriginalFk,editorFk,buyerFk) - VALUES (9,1,5000,0,50.0000,1.500,0,1,1,1,'packing',0.000,1.500,'4',0.00,99.60,99.40,0.00,0,0,1,0,'2024-07-30 08:13:51.000',0,1.00,1,100,35); -INSERT INTO vn.payrollComponent -(id, name, isSalaryAgreed, isVariable, isException) - VALUES - (1, 'Salario1', 1, 0, 0), + VALUES (99,1,5000,0,50.0000,1.500,0,1,1,1,'packing',0.000,1.500,'4',0.00,99.60,99.40,0.00,0,0,1,0,'2024-07-30 08:13:51.000',0,1.00,1,100,35); + +INSERT INTO vn.payrollComponent (id, name, isSalaryAgreed, isVariable, isException) + VALUES (1, 'Salario1', 1, 0, 0), (2, 'Salario2', 1, 1, 0), (3, 'Salario3', 1, 0, 1); - -INSERT INTO vn.workerIncome -(debit, credit, incomeTypeFk, paymentDate, workerFk, concept) - VALUES - (1000.00, 900.00, 2, '2000-01-01', 1106, NULL), +INSERT INTO vn.workerIncome (debit, credit, incomeTypeFk, paymentDate, workerFk, concept) + VALUES (1000.00, 900.00, 2, '2000-01-01', 1106, NULL), (1001.00, 800.00, 2, '2000-01-01', 1106, NULL); +INSERT INTO dipole.printer (id, description) VALUES(1, ''); -INSERT INTO dipole.printer (id, description) -VALUES(1, ''); +INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments) + VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL); -INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, -truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments) -VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL); +INSERT INTO vn.accountDetail (id, value, accountDetailTypeFk, supplierAccountFk) + VALUES (21, 'ES12345B12345678', 3, 241), + (35, 'ES12346B12345679', 3, 241); -INSERT INTO vn.accountDetail -(id, value, accountDetailTypeFk, supplierAccountFk) -VALUES - (21, 'ES12345B12345678', 3, 241), - (35, 'ES12346B12345679', 3, 241); - -INSERT INTO vn.accountDetailType -(id, description) -VALUES - (1, 'IBAN'), - (2, 'SWIFT'), - (3, 'Referencia Remesas'), - (4, 'Referencia Transferencias'), - (5, 'Referencia Nominas'), - (6, 'ABA'); +INSERT INTO vn.accountDetailType (id, description) + VALUES (1, 'IBAN'), + (2, 'SWIFT'), + (3, 'Referencia Remesas'), + (4, 'Referencia Transferencias'), + (5, 'Referencia Nominas'), + (6, 'ABA'); diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index c7156062a..145da170a 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -39,7 +39,7 @@ describe('Entry filter()', () => { const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(11); + expect(result.length).toEqual(12); await tx.rollback(); } catch (e) { @@ -131,7 +131,7 @@ describe('Entry filter()', () => { const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(10); + expect(result.length).toEqual(11); await tx.rollback(); } catch (e) { diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index 7e90c7681..97e1e5e77 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -79,7 +79,7 @@ describe('Travel extraCommunityFilter()', () => { const result = await app.models.Travel.extraCommunityFilter(ctx, filter); - expect(result.length).toEqual(9); + expect(result.length).toEqual(10); }); it('should return the travel matching "cargoSupplierFk"', async() => { @@ -110,6 +110,6 @@ describe('Travel extraCommunityFilter()', () => { const result = await app.models.Travel.extraCommunityFilter(ctx, filter); - expect(result.length).toEqual(2); + expect(result.length).toEqual(3); }); }); diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index a608a980e..2b6885cae 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -68,7 +68,7 @@ describe('Travel filter()', () => { const result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(1); + expect(result.length).toEqual(2); }); it('should return the travel matching "continent"', async() => { @@ -80,6 +80,6 @@ describe('Travel filter()', () => { const result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(6); + expect(result.length).toEqual(7); }); }); From b636b5429aa0d892c73cffa88551d1fb29b9982a Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 9 Aug 2024 08:20:42 +0200 Subject: [PATCH 06/11] fix: refs #7404 refactor fixtures --- db/dump/fixtures.before.sql | 44 ++++++++++++++----------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 69d838998..63be254d3 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -178,12 +178,12 @@ INSERT INTO `vn`.`country`(`id`, `name`, `isUeeMember`, `code`, `currencyFk`, `i (30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2); INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny`) - VALUES - (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), + VALUES (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0), (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0), (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1), (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), + (6, 'Warehouse six', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0), (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0); @@ -1492,16 +1492,16 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`) - VALUES - (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1), - (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2, 2), - (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3), - (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4), - (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5), - (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6), - (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7), - (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10), - (10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10); + VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1), + (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2), + (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3), + (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4), + (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5), + (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6), + (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7), + (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10), + (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10), + (11, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`) VALUES @@ -1514,7 +1514,8 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'), (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''), (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''), - (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''); + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, ''), + (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 1, 1, ''); INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleQuantity`, `saleInternalWaste`, `saleExternalWaste`) VALUES @@ -1534,7 +1535,7 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12'), ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20'); -INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) +INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,freightValue,packageValue,comissionValue,packing,grouping,groupingMode,location,price1,price2,price3,printedStickers,isChecked,isIgnored,weight,created) VALUES (1, 1, 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), (2, 2, 1, 50, 100, 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 1 MONTH), @@ -1550,7 +1551,8 @@ INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagi (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), - (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()); + (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'); 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 @@ -3922,18 +3924,6 @@ INSERT INTO vn.stockBought (workerFk, bought, reserve, dated) INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk) VALUES (1,0.6,6); -INSERT INTO vn.warehouse (id,name,isFeedStock,delay,hasAvailable,isForTicket,countryFk,labelZone,hasComission,isInventory,isComparative,valuatedInventory,isManaged,hasConfectionTeam,hasStowaway,hasDms,isBuyerToBeEmailed,hasUbications,hasProduction,hasMachine,isLogiflora,isBionic,isHalt,isOrigin,isDestiny) - VALUES (6,'Warehouse six',0,0.004,1,0,1,0,0,1,1,0,1,0,0,0,0,1,1,0,0,1,0,0,0); - -INSERT INTO vn.travel (id,shipped,landed,warehouseInFk,warehouseOutFk,agencyFk__,`ref`,isDelivered,isReceived,m3,kg,cargoSupplierFk,totalEntries,agencyModeFk,editorFk,awbFk) - VALUES (11,'2001-01-01','2001-01-02',6,3,0,'eleventh travel',0,0,50.00,500,2,0,1,100,4); - -INSERT INTO vn.entry (id,supplierFk,invoiceNumber,isBooked,isExcludedFromAvailable,isConfirmed,isOrdered,isRaid,commission,created,evaNotes,travelFk,currencyFk,companyFk,isBlocked__,reference,editorFk,locked) - VALUES (99,69,'IN2009',0,1,0,0,1,0.0,'2000-12-01 00:00:00.000','',11,1,442,0,'Movement 9',100,'2024-07-30 08:13:49.000'); - -INSERT INTO vn.buy (entryFk,itemFk,quantity,dispatched,buyingValue,freightValue,isIgnored,stickers,packing,`grouping`,groupingMode,comissionValue,packageValue,packagingFk,price1,price2,price3,minPrice,printedStickers,workerFk,isChecked,isPickedOff,created,`__cm2`,weight,itemOriginalFk,editorFk,buyerFk) - VALUES (99,1,5000,0,50.0000,1.500,0,1,1,1,'packing',0.000,1.500,'4',0.00,99.60,99.40,0.00,0,0,1,0,'2024-07-30 08:13:51.000',0,1.00,1,100,35); - INSERT INTO vn.payrollComponent (id, name, isSalaryAgreed, isVariable, isException) VALUES (1, 'Salario1', 1, 0, 0), (2, 'Salario2', 1, 1, 0), From 8607a60ca7c57267ef3a86f3002fbf997a7a82af Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 11 Sep 2024 07:56:08 +0200 Subject: [PATCH 07/11] feat: refs #7404 format date before select --- db/routines/vn/procedures/stockBought_calculate.sql | 4 +--- .../back/methods/stock-bought/getStockBoughtDetail.js | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index 54ac78d8e..6eabe015c 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -3,9 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calcula BEGIN /** * Inserts the purchase volume per buyer - * into stockBought according to the date. - * - * @param vDated Purchase date + * into stockBought according to the current date. */ DECLARE vDated DATE; SET vDated = util.VN_CURDATE(); diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js index 0657fcb9a..6f09f1f67 100644 --- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -23,7 +23,11 @@ module.exports = Self => { } }); - Self.getStockBoughtDetail = async(workerFk, dated = Date.vnNew()) => { + Self.getStockBoughtDetail = async(workerFk, dated) => { + if (!dated) { + dated = Date.vnNew(); + dated.setHours(0, 0, 0, 0); + } return Self.rawSql( `SELECT e.id entryFk, i.id itemFk, @@ -47,8 +51,8 @@ module.exports = Self => { JOIN volumeConfig vc WHERE t.warehouseInFk = ac.warehouseFk AND it.workerFk = ? - AND t.shipped = ?`, - [workerFk, new Date(dated)] + AND t.shipped = util.VN_CURDATE()`, + [workerFk] ); }; }; From cc1cd0563fe1b8cee7bbedf3b827fe881d908d54 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 16 Sep 2024 09:00:46 +0200 Subject: [PATCH 08/11] feat: refs #7404 fixtures and translates --- db/dump/fixtures.before.sql | 2 +- loopback/locale/en.json | 3 +- .../methods/stock-bought/getStockBought.js | 49 +++++++++++-------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ce33b4e48..cd1a470ff 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -183,7 +183,7 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0), (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1), (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), - (6, 'Warehouse six', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), + (6, 'Warehouse six', 'VNH', 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0), (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 06538a524..b8835f5f3 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -235,5 +235,6 @@ "Cannot add holidays on this day": "Cannot add holidays on this day", "Cannot send mail": "Cannot send mail", "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`", - "This postcode already exists": "This postcode already exists" + "This postcode already exists": "This postcode already exists", + "This buyer has already made a reservation for this date": "This buyer has already made a reservation for this date" } \ No newline at end of file diff --git a/modules/entry/back/methods/stock-bought/getStockBought.js b/modules/entry/back/methods/stock-bought/getStockBought.js index da194ed80..0f67d878d 100644 --- a/modules/entry/back/methods/stock-bought/getStockBought.js +++ b/modules/entry/back/methods/stock-bought/getStockBought.js @@ -3,6 +3,11 @@ module.exports = Self => { description: 'Returns the stock bought for a given date', accessType: 'READ', accepts: [{ + arg: 'workerFk', + type: 'number', + description: 'The id for a buyer', + }, + { arg: 'dated', type: 'date', description: 'The date to filter', @@ -18,7 +23,7 @@ module.exports = Self => { } }); - Self.getStockBought = async(dated = Date.vnNew()) => { + Self.getStockBought = async(workerFk, dated = Date.vnNew()) => { const models = Self.app.models; const today = Date.vnNew(); dated.setHours(0, 0, 0, 0); @@ -27,26 +32,30 @@ module.exports = Self => { if (dated.getTime() === today.getTime()) await models.StockBought.rawSql(`CALL vn.stockBought_calculate()`); - return models.StockBought.find( - { - where: { - dated: dated - }, - include: [ - { - relation: 'worker', - scope: { - include: [ - { - relation: 'user', - scope: { - fields: ['id', 'name'] - } + const filter = { + where: { + dated: dated + }, + include: [ + { + relation: 'worker', + scope: { + include: [ + { + relation: 'user', + scope: { + fields: ['id', 'name'] } - ] - } + } + ] } - ] - }); + } + ] + }; + + if (workerFk) filter.where.workerFk = workerFk; + console.log('workerFk: ', workerFk); + + return models.StockBought.find(filter); }; }; From 138640f9910cfc63efd08db06f0a8650207a6d36 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 16 Sep 2024 12:05:36 +0200 Subject: [PATCH 09/11] fix: refs #7404 update test to match new fixtures for travel by continent --- .../back/methods/travel/specs/extraCommunityFilter.spec.js | 4 ++-- modules/travel/back/methods/travel/specs/filter.spec.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index 97e1e5e77..7e90c7681 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -79,7 +79,7 @@ describe('Travel extraCommunityFilter()', () => { const result = await app.models.Travel.extraCommunityFilter(ctx, filter); - expect(result.length).toEqual(10); + expect(result.length).toEqual(9); }); it('should return the travel matching "cargoSupplierFk"', async() => { @@ -110,6 +110,6 @@ describe('Travel extraCommunityFilter()', () => { const result = await app.models.Travel.extraCommunityFilter(ctx, filter); - expect(result.length).toEqual(3); + expect(result.length).toEqual(2); }); }); diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index 2b6885cae..a608a980e 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -68,7 +68,7 @@ describe('Travel filter()', () => { const result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(2); + expect(result.length).toEqual(1); }); it('should return the travel matching "continent"', async() => { @@ -80,6 +80,6 @@ describe('Travel filter()', () => { const result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(7); + expect(result.length).toEqual(6); }); }); From 1f1da689d4bcec0072e2281d9ed564af610b6c8c Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 16 Sep 2024 12:17:51 +0200 Subject: [PATCH 10/11] fix: refs #7404 remove console log --- modules/entry/back/methods/stock-bought/getStockBought.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/entry/back/methods/stock-bought/getStockBought.js b/modules/entry/back/methods/stock-bought/getStockBought.js index 0f67d878d..94e206ece 100644 --- a/modules/entry/back/methods/stock-bought/getStockBought.js +++ b/modules/entry/back/methods/stock-bought/getStockBought.js @@ -54,7 +54,6 @@ module.exports = Self => { }; if (workerFk) filter.where.workerFk = workerFk; - console.log('workerFk: ', workerFk); return models.StockBought.find(filter); }; From 0c259b7a81f7e0d90ceca94d99ed1737548e1fc1 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 17 Sep 2024 10:32:26 +0200 Subject: [PATCH 11/11] fix: refs #7404 remove duplicate translate --- loopback/locale/en.json | 1 - 1 file changed, 1 deletion(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 875f06e3b..352e08826 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -235,7 +235,6 @@ "Cannot add holidays on this day": "Cannot add holidays on this day", "Cannot send mail": "Cannot send mail", "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`", - "This postcode already exists": "This postcode already exists", "Original invoice not found": "Original invoice not found", "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm",