From 940b4310590259f33a1475a68677e4cb26275ba3 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 5 Oct 2022 14:04:30 +0200 Subject: [PATCH 01/11] feat(model) Created the model for packagingMistake --- modules/ticket/back/model-config.json | 3 +++ .../ticket/back/models/packagingMistake.json | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 modules/ticket/back/models/packagingMistake.json diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index 8a6ac0c00..859ecdef8 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -20,6 +20,9 @@ "Packaging": { "dataSource": "vn" }, + "PackagingMistake": { + "dataSource": "vn" + }, "PrintServerQueue": { "dataSource": "vn" }, diff --git a/modules/ticket/back/models/packagingMistake.json b/modules/ticket/back/models/packagingMistake.json new file mode 100644 index 000000000..7bfc0eca2 --- /dev/null +++ b/modules/ticket/back/models/packagingMistake.json @@ -0,0 +1,25 @@ +{ + "name": "PackagingMistake", + "base": "VnModel", + "options": { + "mysql": { + "table": "packagingMistake" + } + }, + "properties": { + "expeditionFk": { + "id": true, + "type": "number" + }, + "workerFk": { + "type": "number" + }, + "typeFk": { + "type": "number" + }, + "created": { + "type": "date" + } + } + } + \ No newline at end of file From f82870bec674bd3e9c1573a8014a5f71575dc33b Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 19 Dec 2022 14:39:38 +0100 Subject: [PATCH 02/11] feat(item_fixed-price): recalculate rate2 and when change item keep minPrice of item --- db/changes/225001/00-priceFixed_getRate2.sql | 23 ++++++++++ .../item/back/methods/fixed-price/getRate2.js | 34 ++++++++++++++ modules/item/back/models/fixed-price.js | 1 + modules/item/front/fixed-price/index.html | 46 ++++++++++++------- modules/item/front/fixed-price/index.js | 23 +++++++++- modules/item/front/fixed-price/locale/es.yml | 2 - 6 files changed, 109 insertions(+), 20 deletions(-) create mode 100644 db/changes/225001/00-priceFixed_getRate2.sql create mode 100644 modules/item/back/methods/fixed-price/getRate2.js diff --git a/db/changes/225001/00-priceFixed_getRate2.sql b/db/changes/225001/00-priceFixed_getRate2.sql new file mode 100644 index 000000000..cf36efb57 --- /dev/null +++ b/db/changes/225001/00-priceFixed_getRate2.sql @@ -0,0 +1,23 @@ +DROP FUNCTION IF EXISTS `vn`.`priceFixed_getRate2`; + +DELIMITER $$ +$$ +CREATE FUNCTION `vn`.`priceFixed_getRate2`(vFixedPriceFk INT, vRate3 DOUBLE) +RETURNS DOUBLE +BEGIN + + DECLARE vWarehouse INT; + DECLARE vRate2 DOUBLE; + + SELECT round(vRate3 * (1 + ((r.rate2 - r.rate3)/100)), 2) INTO vRate2 + FROM vn.rate r + JOIN vn.priceFixed p ON p.id = vFixedPriceFk + WHERE r.dated <= p.started + AND r.warehouseFk = p.warehouseFk + ORDER BY r.dated DESC + LIMIT 1; + + RETURN vRate2; + +END$$ +DELIMITER ; diff --git a/modules/item/back/methods/fixed-price/getRate2.js b/modules/item/back/methods/fixed-price/getRate2.js new file mode 100644 index 000000000..b8811f425 --- /dev/null +++ b/modules/item/back/methods/fixed-price/getRate2.js @@ -0,0 +1,34 @@ +module.exports = Self => { + Self.remoteMethod('getRate2', { + description: 'Return the rate2.', + accessType: 'READ', + accepts: [ + { + arg: 'fixedPriceId', + type: 'integer', + description: 'The fixedPrice Id', + required: true + }, + { + arg: 'rate3', + type: 'number', + description: `The price rate 3`, + required: true + } + ], + returns: { + type: 'number', + root: true + }, + http: { + path: `/getRate2`, + verb: 'GET' + } + }); + + Self.getRate2 = async(fixedPriceId, rate3) => { + const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`, + [fixedPriceId, rate3]); + return result.rate2; + }; +}; diff --git a/modules/item/back/models/fixed-price.js b/modules/item/back/models/fixed-price.js index 9c78c586f..91010805f 100644 --- a/modules/item/back/models/fixed-price.js +++ b/modules/item/back/models/fixed-price.js @@ -1,4 +1,5 @@ module.exports = Self => { require('../methods/fixed-price/filter')(Self); require('../methods/fixed-price/upsertFixedPrice')(Self); + require('../methods/fixed-price/getRate2')(Self); }; diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index 9498bf96f..f9d177562 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -41,14 +41,12 @@ Warehouse - P.P.U. + field="rate2"> + Grouping price - P.P.P. + field="rate3"> + Packing price Min price @@ -72,7 +70,7 @@ show-field="name" value-field="id" search-function="$ctrl.itemSearchFunc($search)" - on-change="$ctrl.upsertPrice(price)" + on-change="$ctrl.upsertPrice(price, true)" order="id DESC" tabindex="1"> @@ -112,18 +110,32 @@ - - + + {{price.rate2 | currency: 'EUR':2}} + + + + + - - + + {{price.rate3 | currency: 'EUR':2}} + + + + + { + const rate2 = res.data; + if (rate2) { + price.rate2 = rate2; + this.upsertPrice(price); + } + }); + } } ngModule.vnComponent('vnFixedPrice', { diff --git a/modules/item/front/fixed-price/locale/es.yml b/modules/item/front/fixed-price/locale/es.yml index 3f400336d..6bdfcb678 100644 --- a/modules/item/front/fixed-price/locale/es.yml +++ b/modules/item/front/fixed-price/locale/es.yml @@ -3,5 +3,3 @@ Search prices by item ID or code: Buscar por ID de artículo o código Search fixed prices: Buscar precios fijados Add fixed price: Añadir precio fijado This row will be removed: Esta linea se eliminará -Price By Unit: Precio Por Unidad -Price By Package: Precio Por Paquete \ No newline at end of file From 5d2b69d063de91b8b2fa72bb54eb93dc023835e3 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 19 Dec 2022 15:06:59 +0100 Subject: [PATCH 03/11] test(item_fixedPrice): front recalculateRate2 --- .../item/back/methods/fixed-price/getRate2.js | 4 ++-- modules/item/front/fixed-price/index.js | 2 +- modules/item/front/fixed-price/index.spec.js | 20 +++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/item/back/methods/fixed-price/getRate2.js b/modules/item/back/methods/fixed-price/getRate2.js index b8811f425..e1a399be6 100644 --- a/modules/item/back/methods/fixed-price/getRate2.js +++ b/modules/item/back/methods/fixed-price/getRate2.js @@ -11,7 +11,7 @@ module.exports = Self => { }, { arg: 'rate3', - type: 'number', + type: 'object', description: `The price rate 3`, required: true } @@ -29,6 +29,6 @@ module.exports = Self => { Self.getRate2 = async(fixedPriceId, rate3) => { const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`, [fixedPriceId, rate3]); - return result.rate2; + return result; }; }; diff --git a/modules/item/front/fixed-price/index.js b/modules/item/front/fixed-price/index.js index 5a57a123e..f03d73f08 100644 --- a/modules/item/front/fixed-price/index.js +++ b/modules/item/front/fixed-price/index.js @@ -124,7 +124,7 @@ export default class Controller extends Section { }; this.$http.get(query, {params}) .then(res => { - const rate2 = res.data; + const rate2 = res.data.rate2; if (rate2) { price.rate2 = rate2; this.upsertPrice(price); diff --git a/modules/item/front/fixed-price/index.spec.js b/modules/item/front/fixed-price/index.spec.js index 94621e352..db9579444 100644 --- a/modules/item/front/fixed-price/index.spec.js +++ b/modules/item/front/fixed-price/index.spec.js @@ -85,5 +85,25 @@ describe('fixed price', () => { expect(controller.$.model.remove).toHaveBeenCalled(); }); }); + + describe('recalculateRate2()', () => { + it(`should rate2 recalculate`, () => { + jest.spyOn(controller.vnApp, 'showSuccess'); + const price = { + id: 1, + itemFk: 1, + rate2: 2, + rate3: 2 + }; + const response = {rate2: 1}; + controller.recalculateRate2(price); + + const query = `FixedPrices/getRate2?fixedPriceId=${price.id}&rate3=${price.rate3}`; + $httpBackend.expectGET(query).respond(response); + $httpBackend.flush(); + + expect(price.rate2).toEqual(response.rate2); + }); + }); }); }); From 502a6925213db8b67db48cda2b29363fa4b61153 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 21 Dec 2022 12:55:11 +0100 Subject: [PATCH 04/11] test(item_fixedPrice_rate2): backTest and e2e --- .../00-priceFixed_getRate2.sql | 0 e2e/helpers/selectors.js | 4 +- e2e/paths/04-item/13_fixedPrice.spec.js | 6 +-- .../item/back/methods/fixed-price/getRate2.js | 15 ++++--- .../fixed-price/specs/getRate2.spec.js | 39 +++++++++++++++++++ 5 files changed, 54 insertions(+), 10 deletions(-) rename db/changes/{225001 => 225201}/00-priceFixed_getRate2.sql (100%) create mode 100644 modules/item/back/methods/fixed-price/specs/getRate2.spec.js diff --git a/db/changes/225001/00-priceFixed_getRate2.sql b/db/changes/225201/00-priceFixed_getRate2.sql similarity index 100% rename from db/changes/225001/00-priceFixed_getRate2.sql rename to db/changes/225201/00-priceFixed_getRate2.sql diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 9dab10673..f3fb496a0 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -415,8 +415,8 @@ export default { fourthFixedPrice: 'vn-fixed-price tr:nth-child(5)', fourthItemID: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.itemFk"]', fourthWarehouse: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.warehouseFk"]', - fourthPPU: 'vn-fixed-price tr:nth-child(5) > td:nth-child(4)', - fourthPPP: 'vn-fixed-price tr:nth-child(5) > td:nth-child(5)', + fourthGroupingPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(4)', + fourthPackingPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(5)', fourthHasMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-check[ng-model="price.hasMinPrice"]', fourthMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-input-number[ng-model="price.minPrice"]', fourthStarted: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.started"]', diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js index fc7aac3d0..673705eff 100644 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ b/e2e/paths/04-item/13_fixedPrice.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Item fixed prices path', () => { +fdescribe('Item fixed prices path', () => { let browser; let page; beforeAll(async() => { @@ -24,8 +24,8 @@ describe('Item fixed prices path', () => { it('should fill the fixed price data', async() => { const now = new Date(); await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one'); - await page.write(selectors.itemFixedPrice.fourthPPU, '1'); - await page.write(selectors.itemFixedPrice.fourthPPP, '1'); + await page.writeOnEditableTD(selectors.itemFixedPrice.fourthGroupingPrice, '1'); + await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPackingPrice, '1'); await page.write(selectors.itemFixedPrice.fourthMinPrice, '1'); await page.pickDate(selectors.itemFixedPrice.fourthStarted, now); await page.pickDate(selectors.itemFixedPrice.fourthEnded, now); diff --git a/modules/item/back/methods/fixed-price/getRate2.js b/modules/item/back/methods/fixed-price/getRate2.js index e1a399be6..c90a380e3 100644 --- a/modules/item/back/methods/fixed-price/getRate2.js +++ b/modules/item/back/methods/fixed-price/getRate2.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethod('getRate2', { - description: 'Return the rate2.', + description: 'Return the rate2', accessType: 'READ', accepts: [ { @@ -11,13 +11,13 @@ module.exports = Self => { }, { arg: 'rate3', - type: 'object', + type: 'number', description: `The price rate 3`, required: true } ], returns: { - type: 'number', + type: 'object', root: true }, http: { @@ -26,9 +26,14 @@ module.exports = Self => { } }); - Self.getRate2 = async(fixedPriceId, rate3) => { + Self.getRate2 = async(fixedPriceId, rate3, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`, - [fixedPriceId, rate3]); + [fixedPriceId, rate3], myOptions); return result; }; }; diff --git a/modules/item/back/methods/fixed-price/specs/getRate2.spec.js b/modules/item/back/methods/fixed-price/specs/getRate2.spec.js new file mode 100644 index 000000000..2f5dd93cd --- /dev/null +++ b/modules/item/back/methods/fixed-price/specs/getRate2.spec.js @@ -0,0 +1,39 @@ +const models = require('vn-loopback/server/server').models; + +describe('getRate2()', () => { + it(`should return new rate2 if exists rate`, async() => { + const tx = await models.FixedPrice.beginTransaction({}); + + try { + const options = {transaction: tx}; + const fixedPriceId = 1; + const rate3 = 2; + const result = await models.FixedPrice.getRate2(fixedPriceId, rate3, options); + + expect(result.rate2).toEqual(1.9); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it(`should return null if not exists rate`, async() => { + const tx = await models.FixedPrice.beginTransaction({}); + + try { + const options = {transaction: tx}; + const fixedPriceId = 13; + const rate3 = 2; + const result = await models.FixedPrice.getRate2(fixedPriceId, rate3, options); + + expect(result.rate2).toEqual(null); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); From d18e360f735f4c85659efce2d25ec65b9e5e157c Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 21 Dec 2022 13:47:43 +0100 Subject: [PATCH 05/11] unfocus e2e --- e2e/paths/04-item/13_fixedPrice.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js index 673705eff..40ccc009e 100644 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ b/e2e/paths/04-item/13_fixedPrice.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Item fixed prices path', () => { +describe('Item fixed prices path', () => { let browser; let page; beforeAll(async() => { From d827795441461408de1995ca025e8b125e101768 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 23 Dec 2022 12:38:05 +0100 Subject: [PATCH 06/11] refs #4930 agency changed for zone --- modules/claim/front/card/index.js | 4 ++-- modules/claim/front/descriptor/index.html | 27 ++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/claim/front/card/index.js b/modules/claim/front/card/index.js index 747eea9e7..8fb35db75 100644 --- a/modules/claim/front/card/index.js +++ b/modules/claim/front/card/index.js @@ -19,9 +19,9 @@ class Controller extends ModuleCard { }, { relation: 'ticket', scope: { - fields: ['agencyModeFk'], + fields: ['zoneFk'], include: { - relation: 'agencyMode' + relation: 'zone' } } }, { diff --git a/modules/claim/front/descriptor/index.html b/modules/claim/front/descriptor/index.html index 0bbacf94b..90246824b 100644 --- a/modules/claim/front/descriptor/index.html +++ b/modules/claim/front/descriptor/index.html @@ -27,16 +27,16 @@
- {{$ctrl.claim.client.salesPersonUser.name}} @@ -44,19 +44,23 @@ - {{$ctrl.claim.worker.user.name}} + label="Zone"> + + {{$ctrl.claim.ticket.zoneFk}} + - {{$ctrl.claim.ticketFk}} @@ -94,12 +98,15 @@ question="Delete claim" message="Are you sure you want to delete this claim?"> - - - \ No newline at end of file + + + From 1f560761a45bb49ed30caec21c0878c1b4c14fea Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 27 Dec 2022 08:31:35 +0100 Subject: [PATCH 07/11] refs #4930 changelog modified --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95b3028de..a23bd0fe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- +- ### Changed -- \ No newline at end of file +- Cambiado el campo Agencia por Zona en el descriptor de Reclamaciones From 8184749626775d0bd8c37d154f96aa94383542e0 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 4 Jan 2023 09:40:27 +0100 Subject: [PATCH 08/11] change db version folder --- db/changes/{225201 => 230201}/00-priceFixed_getRate2.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{225201 => 230201}/00-priceFixed_getRate2.sql (100%) diff --git a/db/changes/225201/00-priceFixed_getRate2.sql b/db/changes/230201/00-priceFixed_getRate2.sql similarity index 100% rename from db/changes/225201/00-priceFixed_getRate2.sql rename to db/changes/230201/00-priceFixed_getRate2.sql From d540e278eb659c537d73a3aad5171ee04dcae1d4 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 10 Jan 2023 13:52:30 +0100 Subject: [PATCH 09/11] refs #4605 @30min --- modules/ticket/back/model-config.json | 2 +- .../models/{packagingMistake.json => expeditionMistake.json} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename modules/ticket/back/models/{packagingMistake.json => expeditionMistake.json} (82%) diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index 859ecdef8..4187973d0 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -20,7 +20,7 @@ "Packaging": { "dataSource": "vn" }, - "PackagingMistake": { + "ExpeditionMistake": { "dataSource": "vn" }, "PrintServerQueue": { diff --git a/modules/ticket/back/models/packagingMistake.json b/modules/ticket/back/models/expeditionMistake.json similarity index 82% rename from modules/ticket/back/models/packagingMistake.json rename to modules/ticket/back/models/expeditionMistake.json index 7bfc0eca2..e01f2f4be 100644 --- a/modules/ticket/back/models/packagingMistake.json +++ b/modules/ticket/back/models/expeditionMistake.json @@ -1,9 +1,9 @@ { - "name": "PackagingMistake", + "name": "ExpeditionMistake", "base": "VnModel", "options": { "mysql": { - "table": "packagingMistake" + "table": "expeditionMistake" } }, "properties": { From a8e4c9e1debc1917133da3336248efe4c1bb3c26 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 13 Jan 2023 15:42:00 +0100 Subject: [PATCH 10/11] cambiar fks por relaciones --- .../ticket/back/models/expeditionMistake.json | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/ticket/back/models/expeditionMistake.json b/modules/ticket/back/models/expeditionMistake.json index e01f2f4be..43033194a 100644 --- a/modules/ticket/back/models/expeditionMistake.json +++ b/modules/ticket/back/models/expeditionMistake.json @@ -7,19 +7,27 @@ } }, "properties": { - "expeditionFk": { - "id": true, - "type": "number" - }, - "workerFk": { - "type": "number" - }, - "typeFk": { - "type": "number" - }, "created": { "type": "date" } + }, + "relations": { + "expedition": { + "type": "belongsTo", + "model": "Expedition", + "foreignKey": "expeditionFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "type": { + "type": "belongsTo", + "model": "MistakeType", + "foreignKey": "typeFk" + } } + } \ No newline at end of file From c371c2fe92bb91bcb368355fd75c410911eab912 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 17 Jan 2023 09:03:13 +0100 Subject: [PATCH 11/11] refs #4930 refresh structure --- db/dump/structure.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 4626279e4..772d6055d 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -80203,3 +80203,4 @@ USE `vncontrol`; -- Dump completed on 2022-11-21 7:57:28 +