From c62f8e1c14a3dc72aa30921970d746e9cc7b9abb Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 26 Apr 2023 12:13:14 +0200 Subject: [PATCH 01/13] refs #5297 feat(worker): iban and bankEntity not required --- e2e/paths/03-worker/06_create.spec.js | 1 - modules/worker/back/methods/worker/new.js | 22 +++++++++---------- .../back/methods/worker/specs/new.spec.js | 2 -- modules/worker/front/create/index.js | 5 +++++ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e/paths/03-worker/06_create.spec.js b/e2e/paths/03-worker/06_create.spec.js index 98e67edbf..203d9ba9a 100644 --- a/e2e/paths/03-worker/06_create.spec.js +++ b/e2e/paths/03-worker/06_create.spec.js @@ -25,7 +25,6 @@ describe('Worker create path', () => { await page.write(selectors.workerCreate.postcode, '46680'); await page.write(selectors.workerCreate.street, 'S/ Doomstadt'); await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com'); - await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332'); // should check for autocompleted worker code and worker user name const workerCode = await page diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 144b07f10..68f962254 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -54,18 +54,6 @@ module.exports = Self => { description: `The worker province`, required: true, }, - { - arg: 'iban', - type: 'string', - description: `The worker iban`, - required: true, - }, - { - arg: 'bankEntityFk', - type: 'number', - description: `The worker bank entity`, - required: true, - }, { arg: 'companyFk', type: 'number', @@ -101,6 +89,16 @@ module.exports = Self => { type: 'date', description: `The worker birth`, required: true, + }, + { + arg: 'iban', + type: 'string', + description: `The worker iban`, + }, + { + arg: 'bankEntityFk', + type: 'number', + description: `The worker bank entity`, } ], returns: { diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index dbcc66683..d2c6157fb 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -27,8 +27,6 @@ describe('Worker new', () => { street: 'S/ defaultWorkerStreet', city: 'defaultWorkerCity', provinceFk: 1, - iban: 'ES8304879798578129532677', - bankEntityFk: 128, companyFk: 442, postcode: '46680', phone: '123456789', diff --git a/modules/worker/front/create/index.js b/modules/worker/front/create/index.js index 7966926b0..3db68b245 100644 --- a/modules/worker/front/create/index.js +++ b/modules/worker/front/create/index.js @@ -8,6 +8,11 @@ export default class Controller extends Section { } onSubmit() { + if (!this.worker.iban && !this.worker.bankEntityFk) { + delete this.worker.iban; + delete this.worker.bankEntityFk; + } + return this.$.watcher.submit().then(json => { this.$state.go('worker.card.basicData', {id: json.data.id}); }); From ac55dc4cc72d210fb15e5844b0d88c03dc0f3a1a Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 28 Apr 2023 14:17:19 +0200 Subject: [PATCH 02/13] refs #5297 feat(worker_new): add payMethod --- CHANGELOG.md | 2 ++ .../231601/00-workerConfigPayMethod.sql | 7 +++++ db/dump/fixtures.sql | 4 +-- e2e/helpers/selectors.js | 1 + e2e/paths/03-worker/06_create.spec.js | 3 +- modules/worker/back/methods/worker/new.js | 15 ++++++++-- .../back/methods/worker/specs/new.spec.js | 30 ++++++++++++++++++- modules/worker/back/models/worker-config.json | 3 ++ modules/worker/front/create/index.html | 11 +++++-- modules/worker/front/create/index.js | 3 ++ modules/worker/front/create/locale/es.yml | 1 + 11 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 db/changes/231601/00-workerConfigPayMethod.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 1be03b733..15ecad61b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - (Usuarios -> Histórico) Nueva sección - (Roles -> Histórico) Nueva sección +- (Trabajadores -> Dar de alta) Permite elegir el método de pago ### Changed - (Artículo -> Precio fijado) Modificado el buscador superior por uno lateral +- (Trabajadores -> Dar de alta) Quitada obligatoriedad del iban ### Fixed - diff --git a/db/changes/231601/00-workerConfigPayMethod.sql b/db/changes/231601/00-workerConfigPayMethod.sql new file mode 100644 index 000000000..91f477bec --- /dev/null +++ b/db/changes/231601/00-workerConfigPayMethod.sql @@ -0,0 +1,7 @@ +ALTER TABLE `vn`.`workerConfig` ADD payMethodFk tinyint(3) unsigned NULL; +ALTER TABLE `vn`.`workerConfig` ADD CONSTRAINT workerConfig_FK FOREIGN KEY (roleFk) REFERENCES account.`role`(id) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`workerConfig` ADD CONSTRAINT workerConfig_FK_1 FOREIGN KEY (payMethodFk) REFERENCES `vn`.`payMethod`(id) ON DELETE SET NULL ON UPDATE CASCADE; +-- Cuando se apruebe el PR quitar y poner en redmine para hacerse manualmente +UPDATE `vn`.`workerConfig` + SET payMethodFk = 4 + WHERE id=1; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 15ccece35..b72e3e74a 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2801,9 +2801,9 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`) VALUES (1, 1); -INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`) +INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk`) VALUES - (1, NULL, 1); + (1, NULL, 1, 4); INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 1740db7ca..1bde2b29a 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1041,6 +1041,7 @@ export default { email: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.email"]', boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]', role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]', + payMethod: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.payMethodFk"]', iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]', createButton: 'vn-worker-create vn-submit[label="Create"]', }, diff --git a/e2e/paths/03-worker/06_create.spec.js b/e2e/paths/03-worker/06_create.spec.js index 203d9ba9a..cad9802a1 100644 --- a/e2e/paths/03-worker/06_create.spec.js +++ b/e2e/paths/03-worker/06_create.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Worker create path', () => { +fdescribe('Worker create path', () => { let browser; let page; let newWorker; @@ -25,6 +25,7 @@ describe('Worker create path', () => { await page.write(selectors.workerCreate.postcode, '46680'); await page.write(selectors.workerCreate.street, 'S/ Doomstadt'); await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com'); + await page.autocompleteSearch(selectors.workerCreate.payMethod, 'one'); // should check for autocompleted worker code and worker user name const workerCode = await page diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 68f962254..1c2fde3d3 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -90,15 +90,21 @@ module.exports = Self => { description: `The worker birth`, required: true, }, + { + arg: 'payMethodFk', + type: 'number', + description: `The client payMethod`, + required: true, + }, { arg: 'iban', type: 'string', - description: `The worker iban`, + description: `The client iban`, }, { arg: 'bankEntityFk', type: 'number', - description: `The worker bank entity`, + description: `The client bank entity`, } ], returns: { @@ -160,6 +166,10 @@ module.exports = Self => { myOptions ); + const payMethod = await models.PayMethod.findById(args.payMethodFk, {fields: ['isIbanRequiredForClients']}); + if (payMethod.isIbanRequiredForClients && !args.iban) + throw new UserError(`That payment method requires an IBAN`); + await models.Worker.rawSql( 'CALL vn.clientCreate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ @@ -200,6 +210,7 @@ module.exports = Self => { await client.updateAttributes( { + payMethod: args.payMethod, iban: args.iban, bankEntityFk: args.bankEntityFk, defaultAddressFk: address.id, diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index d2c6157fb..dcd9ab0e9 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -32,7 +32,8 @@ describe('Worker new', () => { phone: '123456789', code: 'DWW', bossFk: 9, - birth: '2022-12-11T23:00:00.000Z' + birth: '2022-12-11T23:00:00.000Z', + payMethodFk: 1 }; it('should return error if personal mail already exists', async() => { @@ -103,6 +104,33 @@ describe('Worker new', () => { expect(error.message).toEqual('This worker already exists'); }); + it('should return error if payMethod require iban', async() => { + const payMethodIbanRequired = await models.PayMethod.findOne({ + where: { + isIbanRequiredForClients: true + }, + fields: ['id'] + }); + + const tx = await models.Worker.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + const ctx = { + args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}) + }; + await models.Worker.new(ctx, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toEqual('That payment method requires an IBAN'); + }); + it('should create a new worker', async() => { const newWorker = await models.Worker.new({args: defaultWorker}); diff --git a/modules/worker/back/models/worker-config.json b/modules/worker/back/models/worker-config.json index 05cdfef42..3ece5acc4 100644 --- a/modules/worker/back/models/worker-config.json +++ b/modules/worker/back/models/worker-config.json @@ -14,6 +14,9 @@ }, "roleFk": { "type": "number" + }, + "payMethodFk": { + "type": "number" } }, "acls": [ diff --git a/modules/worker/front/create/index.html b/modules/worker/front/create/index.html index 5f5ab9d07..eb45704a7 100644 --- a/modules/worker/front/create/index.html +++ b/modules/worker/front/create/index.html @@ -142,12 +142,19 @@ + + + on-change="$ctrl.autofillBic()" + rule> { + if (res.data) this.worker.payMethodFk = res.data.payMethodFk; + }); } onSubmit() { diff --git a/modules/worker/front/create/locale/es.yml b/modules/worker/front/create/locale/es.yml index 8c79d770c..78d24a4c9 100644 --- a/modules/worker/front/create/locale/es.yml +++ b/modules/worker/front/create/locale/es.yml @@ -10,3 +10,4 @@ Street: Dirección Postcode: Código postal Web user: Usuario Web Access permission: Permiso de acceso +Pay method: Metodo de pago From a89f400f104f59820f3f36aea55a12bc0aea388d Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 28 Apr 2023 14:22:24 +0200 Subject: [PATCH 03/13] use iban --- e2e/helpers/selectors.js | 1 - e2e/paths/03-worker/06_create.spec.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 1bde2b29a..1740db7ca 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1041,7 +1041,6 @@ export default { email: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.email"]', boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]', role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]', - payMethod: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.payMethodFk"]', iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]', createButton: 'vn-worker-create vn-submit[label="Create"]', }, diff --git a/e2e/paths/03-worker/06_create.spec.js b/e2e/paths/03-worker/06_create.spec.js index cad9802a1..98e67edbf 100644 --- a/e2e/paths/03-worker/06_create.spec.js +++ b/e2e/paths/03-worker/06_create.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Worker create path', () => { +describe('Worker create path', () => { let browser; let page; let newWorker; @@ -25,7 +25,7 @@ fdescribe('Worker create path', () => { await page.write(selectors.workerCreate.postcode, '46680'); await page.write(selectors.workerCreate.street, 'S/ Doomstadt'); await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com'); - await page.autocompleteSearch(selectors.workerCreate.payMethod, 'one'); + await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332'); // should check for autocompleted worker code and worker user name const workerCode = await page From 7e63bc0004dd65845b7d8cb9b858eca504a44392 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 8 May 2023 09:18:22 +0200 Subject: [PATCH 04/13] refs #5297 quit fdescribe --- e2e/paths/13-supplier/03_fiscal_data.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js index 31b3fafd2..170a8d05a 100644 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -15,7 +15,7 @@ const $inputs = { sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]' }; -fdescribe('Supplier fiscal data path', () => { +describe('Supplier fiscal data path', () => { let browser; let page; From 96b5749e1ea020322f89d69d8282c2b4aaaa33e0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 8 May 2023 10:17:35 +0200 Subject: [PATCH 05/13] refs #5297 cambio actual --- e2e/paths/13-supplier/03_fiscal_data.spec.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js index 080d916e4..891b769c9 100644 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ b/e2e/paths/13-supplier/03_fiscal_data.spec.js @@ -1,6 +1,5 @@ import getBrowser from '../../helpers/puppeteer'; -<<<<<<< HEAD const $ = { saveButton: 'vn-supplier-fiscal-data button[type="submit"]', }; @@ -16,8 +15,6 @@ const $inputs = { sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]' }; -======= ->>>>>>> a51481c00ea9f503d002b0ba0e259ea51b81677d describe('Supplier fiscal data path', () => { let browser; let page; From 4bcb461d363af6985a25ae7db4447860371371dd Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 18 May 2023 11:41:46 +0200 Subject: [PATCH 06/13] refs #3628 added check & date-picker --- modules/item/front/diary/index.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index 03134913f..1d2e34a66 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -38,12 +38,8 @@ class Controller extends Section { if (value && value != this._warehouseFk) { this._warehouseFk = value; this.card.warehouseFk = value; + this.filter.where.warehouseFk = this.warehouseFk; - this.$state.go(this.$state.current.name, { - warehouseFk: value - }); - - this.filter.where.warehouseFk = value; this.$.model.refresh(); } } @@ -52,6 +48,28 @@ class Controller extends Section { return this._warehouseFk; } + set date(value) { + this._date = value; + this.filter.where.date = value; + this.filter.where.warehouseFk = this.warehouseFk; + + this.$.model.refresh(); + } + + get date() { + return this._date; + } + + set showOld(value) { + this._showOld = value; + if (!this._showOld) this.date = null; + else this.date = new Date(); + } + + get showOld() { + return this._showOld; + } + scrollToLine(lineFk) { this.$.$applyAsync(() => { const hashFk = this.lineFk || lineFk; From 2591d2d1155064bc23e13799f705bc16943e9f02 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 18 May 2023 11:42:22 +0200 Subject: [PATCH 07/13] refs #3628 added check & date-picker --- db/dump/structure.sql | 322 +++++++++++------- modules/item/back/methods/item/getBalance.js | 4 +- .../methods/item/specs/getBalance.spec.js | 9 +- modules/item/front/diary/index.html | 20 +- modules/item/front/diary/locale/es.yml | 3 +- modules/item/front/diary/style.scss | 5 +- 6 files changed, 222 insertions(+), 141 deletions(-) diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 3256ecdca..380202eeb 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -59861,141 +59861,205 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`(IN vItemId int, IN vWarehouse int) +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getBalance`(vItemFk int, vWarehouseFk int, vDate DATETIME) BEGIN - DECLARE vDateInventory DATETIME; - DECLARE vCurdate DATE DEFAULT util.VN_CURDATE(); - DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate); +/** + * @vItemFk item a buscar + * @vWarehouseFk almacen donde buscar + * @vDate Si la fecha es null, muestra el histórico desde el inventario. Si la fecha no es null, muestra histórico desde la fecha pasada. + */ - SELECT inventoried INTO vDateInventory FROM config; - SET @a = 0; - SET @currentLineFk = 0; - SET @shipped = ''; + DECLARE vDateInventory DATETIME; + DECLARE vInvCalculated INT; - SELECT DATE(@shipped:= shipped) shipped, - alertLevel, - stateName, - origin, - reference, - clientFk, - name, - `in` AS invalue, - `out`, - @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance, - @currentLineFk := IF (@shipped < util.VN_CURDATE() - OR (@shipped = util.VN_CURDATE() AND (isPicked OR alertLevel >= 2)), - lineFk,@currentLineFk) lastPreparedLineFk, - isTicket, - lineFk, - isPicked, - clientType, - claimFk - FROM - ( SELECT tr.landed AS shipped, - b.quantity AS `in`, - NULL AS `out`, - al.id AS alertLevel, - st.name AS stateName, - s.name AS name, - e.invoiceNumber AS reference, - e.id AS origin, - s.id AS clientFk, - IF(al.id = 3, TRUE, FALSE) isPicked, - FALSE AS isTicket, - b.id lineFk, - NULL `order`, - NULL AS clientType, - NULL AS claimFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.id = - CASE - WHEN tr.landed < util.VN_CURDATE() THEN 3 - WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3 - ELSE 0 - END - JOIN state st ON st.code = al.code - WHERE tr.landed >= vDateInventory - AND vWarehouse = tr.warehouseInFk - AND b.itemFk = vItemId - AND e.isExcludedFromAvailable = FALSE - AND e.isRaid = FALSE - UNION ALL + IF vDate IS NULL THEN + SELECT inventoried INTO vDateInventory + FROM config; + ELSE + SELECT mockUtcTime INTO vDateInventory + FROM util.config; + END IF; - SELECT tr.shipped, - NULL, - b.quantity, - al.id, - st.name, - s.name, - e.invoiceNumber, - e.id, - s.id, - IF(al.id = 3, TRUE, FALSE), - FALSE, - b.id, - NULL, - NULL, - NULL - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN warehouse w ON w.id = tr.warehouseOutFk - JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.id = - CASE - WHEN tr.shipped < util.VN_CURDATE() THEN 3 - WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3 - ELSE 0 - END - JOIN state st ON st.code = al.code - WHERE tr.shipped >= vDateInventory - AND vWarehouse =tr.warehouseOutFk - AND s.id <> 4 - AND b.itemFk = vItemId - AND e.isExcludedFromAvailable = FALSE - AND w.isFeedStock = FALSE - AND e.isRaid = FALSE - UNION ALL + CREATE OR REPLACE TEMPORARY TABLE itemDiary( + shipped DATE, + `in` INT(11), + `out` INT(11), + alertLevel INT(11), + stateName VARCHAR(20), + `name` VARCHAR(50), + reference VARCHAR(50), + origin INT(11), + clientFk INT(11), + isPicked INT(11), + isTicket TINYINT(1), + lineFk INT(11), + `order` TINYINT(3) UNSIGNED, + clientType VARCHAR(20), + claimFk INT(10) UNSIGNED + ); - SELECT DATE(t.shipped), - NULL, - s.quantity, - al.id, - st.name, - t.nickname, - t.refFk, - t.id, - t.clientFk, - stk.id, - TRUE, - s.id, - st.`order`, - ct.code, - cb.claimFk - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN ticketState ts ON ts.ticket = t.id - LEFT JOIN state st ON st.code = ts.code - JOIN client c ON c.id = t.clientFk - JOIN clientType ct ON ct.id = c.clientTypeFk - JOIN alertLevel al ON al.id = - CASE - WHEN t.shipped < util.VN_CURDATE() THEN 3 - WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN 0 - ELSE IFNULL(ts.alertLevel, 0) - END - LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' - LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id - LEFT JOIN claimBeginning cb ON s.id = cb.saleFk - WHERE t.shipped >= vDateInventory - AND s.itemFk = vItemId - AND vWarehouse =t.warehouseFk - ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC - ) AS itemDiary; + INSERT INTO itemDiary + SELECT tr.landed shipped, + b.quantity `in`, + NULL `out`, + al.id alertLevel, + st.name stateName, + s.name `name`, + e.invoiceNumber reference, + e.id origin, + s.id clientFk, + IF(al.code = 'DELIVERED', TRUE, FALSE) isPicked, + FALSE isTicket, + b.id lineFk, + NULL `order`, + NULL clientType, + NULL claimFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + JOIN alertLevel al ON al.code = + CASE + WHEN tr.landed < util.VN_CURDATE() THEN 'DELIVERED' + WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 'DELIVERED' + ELSE 'FREE' + END + JOIN state st ON st.code = al.code + WHERE tr.landed >= vDateInventory + AND vWarehouseFk = tr.warehouseInFk + AND b.itemFk = vItemFk + AND e.isExcludedFromAvailable = FALSE + AND e.isRaid = FALSE + UNION ALL + SELECT tr.shipped, + NULL, + b.quantity, + al.id, + st.name, + s.name, + e.invoiceNumber, + e.id, + s.id, + IF(al.code = 'DELIVERED', TRUE, FALSE), + FALSE, + b.id, + NULL, + NULL, + NULL + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN warehouse w ON w.id = tr.warehouseOutFk + JOIN supplier s ON s.id = e.supplierFk + JOIN alertLevel al ON al.code = + CASE + WHEN tr.shipped < util.VN_CURDATE() THEN 'DELIVERED' + WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 'DELIVERED' + ELSE 'FREE' + END + JOIN state st ON st.code = al.code + JOIN entryConfig ec + WHERE tr.shipped >= vDateInventory + AND vWarehouseFk =tr.warehouseOutFk + AND s.id <> ec.inventorySupplierFk + AND b.itemFk = vItemFk + AND e.isExcludedFromAvailable = FALSE + AND w.isFeedStock = FALSE + AND e.isRaid = FALSE + UNION ALL + SELECT DATE(t.shipped), + NULL, + s.quantity, + al3.id, + st.name, + t.nickname, + t.refFk, + t.id, + t.clientFk, + stk.id, + TRUE, + s.id, + st.`order`, + ct.code, + cb.claimFk + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN ticketState ts ON ts.ticket = t.id + LEFT JOIN state st ON st.code = ts.code + JOIN client c ON c.id = t.clientFk + JOIN clientType ct ON ct.id = c.clientTypeFk + JOIN alertLevel al ON al.code = 'DELIVERED' + JOIN alertLevel al2 ON al2.code = 'FREE' + JOIN alertLevel al3 ON al3.id = + CASE + WHEN t.shipped < util.VN_CURDATE() THEN al.code + WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN al2.code + ELSE IFNULL(ts.alertLevel, al2.code) + END + LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' + LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id + LEFT JOIN claimBeginning cb ON s.id = cb.saleFk + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemFk + AND vWarehouseFk =t.warehouseFk + ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC; + IF vDate IS NULL THEN + SET @a = 0; + SET @currentLineFk = 0; + SET @shipped = ''; + + SELECT DATE(@shipped:= shipped) shipped, + alertLevel, + stateName, + origin, + reference, + clientFk, + name, + `in` AS invalue, + `out`, + @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance, + @currentLineFk := IF (@shipped < util.VN_CURDATE() + OR (@shipped = util.VN_CURDATE() AND (isPicked OR a.code >= 'ON_PREPARATION')), + lineFk, @currentLineFk) lastPreparedLineFk, + isTicket, + lineFk, + isPicked, + clientType, + claimFk + FROM itemDiary + JOIN alertLevel a ON a.id = itemDiary.alertLevel; + ELSE + SELECT sum(`in`) - sum(`out`) INTO vInvCalculated + FROM itemDiary + WHERE shipped < vDate; + + SELECT p1.* + FROM( + SELECT vDate shipped, + 0 alertLevel, + 0 stateName, + 0 origin, + '' reference, + 0 clientFk, + 'Inventario calculado', + vInvCalculated invalue, + NULL `out`, + 0 balance, + 0 lastPreparedLineFk, + 0 isTicket, + 0 lineFk, + 0 isPicked, + 0 clientType, + 0 claimFk + UNION ALL + SELECT shipped, alertlevel, stateName, origin, reference, clientFk, name, `in`, `out`, 0,0, isTicket, lineFk, isPicked, clientType, claimFk + FROM itemDiary + WHERE shipped >= vDate + )as p1; + END IF; + + DROP TEMPORARY TABLE itemDiary; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 50372652d..5751b0a04 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -26,8 +26,8 @@ module.exports = Self => { Object.assign(myOptions, options); const where = filter.where; - const query = 'CALL vn.item_getBalance(?, ?)'; - const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk], myOptions); + const query = 'CALL vn.item_getBalance(?, ?, ?)'; + const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); for (const entry of diary) if (entry.clientType === 'loses') entry.highlighted = true; diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index 779516b19..1ffd3c302 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -21,7 +21,8 @@ describe('item getBalance()', () => { const filter = { where: { itemFk: 1, - warehouseFk: 1 + warehouseFk: 1, + date: null } }; const results = await models.Item.getBalance(filter, options); @@ -45,14 +46,16 @@ describe('item getBalance()', () => { const firstFilter = { where: { itemFk: 1, - warehouseFk: 1 + warehouseFk: 1, + date: null } }; const secondFilter = { where: { itemFk: 2, - warehouseFk: 1 + warehouseFk: 1, + date: null } }; diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 0f00f5854..1814dad06 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -25,6 +25,16 @@ ng-model="$ctrl.warehouseFk" label="Select warehouse"> + + + + @@ -44,7 +54,7 @@ - {{::sale.shipped | date:'dd/MM/yyyy' }} @@ -99,13 +109,13 @@ - - - diff --git a/modules/item/front/diary/locale/es.yml b/modules/item/front/diary/locale/es.yml index e00816d78..6a6fe6636 100644 --- a/modules/item/front/diary/locale/es.yml +++ b/modules/item/front/diary/locale/es.yml @@ -1,4 +1,5 @@ In: Entrada Out: Salida Visible quantity: Cantidad visible -Ticket/Entry: Ticket/Entrada \ No newline at end of file +Ticket/Entry: Ticket/Entrada +Show old to inventory: Mostrar lo anterior al inventario diff --git a/modules/item/front/diary/style.scss b/modules/item/front/diary/style.scss index e8d261ec2..0a6cafcb9 100644 --- a/modules/item/front/diary/style.scss +++ b/modules/item/front/diary/style.scss @@ -27,4 +27,7 @@ vn-item-diary { overflow: hidden; text-overflow: ellipsis; } -} \ No newline at end of file + .table-check{ + justify-content: center; + } +} From cbbb5716382a290ffee9f9f1fdf50218f6833719 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 18 May 2023 11:45:50 +0200 Subject: [PATCH 08/13] refs #3628 changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfff5e53b..d28b22ea0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2322.01] - 2023-06-08 ### Added -- +- (Artículos -> Histórico) Filtro para mostrar lo anterior al inventario ### Changed From 814568f2a9532f18218177cadd7d5df58324da66 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 18 May 2023 13:11:17 +0200 Subject: [PATCH 09/13] refs #5297 errors solve, trad --- CHANGELOG.md | 4 ---- modules/worker/front/create/locale/es.yml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8faeff923..ccca79238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,11 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - (Usuarios -> Histórico) Nueva sección - (Roles -> Histórico) Nueva sección -<<<<<<< HEAD - (Trabajadores -> Dar de alta) Permite elegir el método de pago -======= -- (General -> Traducciones) Correo de bienvenida a clientes al portugués y al francés ->>>>>>> 8a843b37bd9067b6be1dfa090d557b59a0111bcf ### Changed - (Artículo -> Precio fijado) Modificado el buscador superior por uno lateral diff --git a/modules/worker/front/create/locale/es.yml b/modules/worker/front/create/locale/es.yml index 78d24a4c9..1a0f03ef6 100644 --- a/modules/worker/front/create/locale/es.yml +++ b/modules/worker/front/create/locale/es.yml @@ -10,4 +10,4 @@ Street: Dirección Postcode: Código postal Web user: Usuario Web Access permission: Permiso de acceso -Pay method: Metodo de pago +Pay method: Método de pago From 6294fc0435a6c55958b14a47a2012980bfc52861 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 24 May 2023 10:02:02 +0200 Subject: [PATCH 10/13] refs #5297 back&e2e fix changes --- db/changes/{231801 => 232201}/00-workerConfigPayMethod.sql | 0 modules/worker/back/methods/worker/specs/new.spec.js | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename db/changes/{231801 => 232201}/00-workerConfigPayMethod.sql (100%) diff --git a/db/changes/231801/00-workerConfigPayMethod.sql b/db/changes/232201/00-workerConfigPayMethod.sql similarity index 100% rename from db/changes/231801/00-workerConfigPayMethod.sql rename to db/changes/232201/00-workerConfigPayMethod.sql diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index dcd9ab0e9..44f6e9b09 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -33,7 +33,8 @@ describe('Worker new', () => { code: 'DWW', bossFk: 9, birth: '2022-12-11T23:00:00.000Z', - payMethodFk: 1 + payMethodFk: 1, + roleFk: 1 }; it('should return error if personal mail already exists', async() => { From 05fb0a720380ea61d923629b85bcb1dc1471e8bb Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 24 May 2023 12:16:19 +0200 Subject: [PATCH 11/13] refs #5677 tickets without state fixed --- loopback/locale/es.json | 5 +-- .../ticket/back/methods/ticket/saveSign.js | 32 ++++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 45993bdd5..81a75c0cc 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -290,5 +290,6 @@ "isTaxDataChecked": "Datos comprobados", "comercialId": "Id comercial", "comercialName": "Comercial", - "Invalid NIF for VIES": "Invalid NIF for VIES" -} \ No newline at end of file + "Invalid NIF for VIES": "Invalid NIF for VIES", + "Ticket does not exist": "Este ticket no existe" +} diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index aede7de8e..b8f9d5ced 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -29,8 +29,7 @@ module.exports = Self => { } }); - Self.saveSign = async(ctx, options) => { - const args = Object.assign({}, ctx.args); + Self.saveSign = async(ctx, tickets, location, signedTime, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -48,9 +47,9 @@ module.exports = Self => { async function setLocation(ticketId) { await models.Delivery.create({ ticketFk: ticketId, - longitude: args.location.Longitude, - latitude: args.location.Latitude, - dated: args.signedTime || new Date() + longitude: location.Longitude, + latitude: location.Latitude, + dated: signedTime || new Date() }, myOptions); } @@ -107,9 +106,9 @@ module.exports = Self => { } try { - for (let i = 0; i < args.tickets.length; i++) { + for (const ticketId of tickets) { const ticketState = await models.TicketState.findOne( - {where: {ticketFk: args.tickets[i]}, + {where: {ticketFk: ticketId}, fields: ['alertLevel'] }, myOptions); @@ -117,16 +116,19 @@ module.exports = Self => { fields: ['id'] }, myOptions); + if (!ticketState) + throw new UserError('Ticket does not exist'); if (ticketState.alertLevel < packedAlertLevel.id) throw new UserError('This ticket cannot be signed because it has not been boxed'); - else if (!await gestDocExists(args.tickets[i])) { - if (args.location) setLocation(args.tickets[i]); - if (!gestDocCreated) await createGestDoc(args.tickets[i]); - await models.TicketDms.create({ticketFk: args.tickets[i], dmsFk: dms[0].id}, myOptions); - const ticket = await models.Ticket.findById(args.tickets[i], null, myOptions); - await ticket.updateAttribute('isSigned', true, myOptions); - await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [args.tickets[i], 'DELIVERED'], myOptions); - } + if (await gestDocExists(ticketId)) + throw new UserError('Ticket is already signed'); + + if (location) setLocation(ticketId); + if (!gestDocCreated) await createGestDoc(ticketId); + await models.TicketDms.create({ticketFk: ticketId, dmsFk: dms[0].id}, myOptions); + const ticket = await models.Ticket.findById(ticketId, null, myOptions); + await ticket.updateAttribute('isSigned', true, myOptions); + await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, 'DELIVERED'], myOptions); } if (tx) await tx.commit(); From 856dcf18cba282b8a79bff1e77f8d00aa09e294d Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 24 May 2023 12:17:41 +0200 Subject: [PATCH 12/13] refs #5677 locations --- loopback/locale/es.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 81a75c0cc..664a3cf0e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -291,5 +291,6 @@ "comercialId": "Id comercial", "comercialName": "Comercial", "Invalid NIF for VIES": "Invalid NIF for VIES", - "Ticket does not exist": "Este ticket no existe" + "Ticket does not exist": "Este ticket no existe", + "Ticket is already signed": "Este ticket ya ha sido firmado" } From de313b641897c5bd0b27b557336234f835ddede1 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 24 May 2023 13:40:26 +0200 Subject: [PATCH 13/13] refs #3628 Show what's before the inventory --- modules/item/front/diary/index.html | 2 +- modules/item/front/diary/locale/es.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 1814dad06..481cec51a 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -27,7 +27,7 @@