From d7f252a57d732365fef7509eee88a3b5497f7303 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 16 Feb 2022 10:30:56 +0100 Subject: [PATCH 01/23] feat(invoiceIn): add section intrastat --- .../10420-valentines/00-aclIntrastat.sql | 3 + .../00-invoiceInIntrastat.sql | 22 ++++ .../back/methods/invoice-in/summary.js | 28 +++++ modules/invoiceIn/back/model-config.json | 3 + .../back/models/invoice-in-intrastat.json | 50 +++++++++ modules/invoiceIn/back/models/invoice-in.json | 5 + modules/invoiceIn/front/index.js | 1 + modules/invoiceIn/front/intrastat/index.html | 102 ++++++++++++++++++ modules/invoiceIn/front/intrastat/index.js | 60 +++++++++++ .../invoiceIn/front/intrastat/index.spec.js | 55 ++++++++++ modules/invoiceIn/front/locale/es.yml | 6 +- modules/invoiceIn/front/routes.json | 14 +++ modules/invoiceIn/front/summary/index.html | 31 ++++++ 13 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 db/changes/10420-valentines/00-aclIntrastat.sql create mode 100644 db/changes/10420-valentines/00-invoiceInIntrastat.sql create mode 100644 modules/invoiceIn/back/models/invoice-in-intrastat.json create mode 100644 modules/invoiceIn/front/intrastat/index.html create mode 100644 modules/invoiceIn/front/intrastat/index.js create mode 100644 modules/invoiceIn/front/intrastat/index.spec.js diff --git a/db/changes/10420-valentines/00-aclIntrastat.sql b/db/changes/10420-valentines/00-aclIntrastat.sql new file mode 100644 index 0000000000..59805ed3f5 --- /dev/null +++ b/db/changes/10420-valentines/00-aclIntrastat.sql @@ -0,0 +1,3 @@ +INSERT INTO salix.ACL +(model, property, accessType, permission, principalType, principalId) +VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10420-valentines/00-invoiceInIntrastat.sql b/db/changes/10420-valentines/00-invoiceInIntrastat.sql new file mode 100644 index 0000000000..5a25940fb5 --- /dev/null +++ b/db/changes/10420-valentines/00-invoiceInIntrastat.sql @@ -0,0 +1,22 @@ +DROP VIEW `vn`.`invoiceInIntrastat__`; +RENAME TABLE `vn`.`invoiceInIntrastat` TO `vn`.`invoiceInIntrastat__`; + +CREATE OR REPLACE +ALGORITHM = UNDEFINED +DEFINER=`root`@`localhost` +VIEW `vn`.`invoiceInIntrastat` AS +SELECT + `id`.`id` AS `id`, + `id`.`recibida_id` AS `invoiceInFk`, + `id`.`neto` AS `net`, + `id`.`intrastat_id` AS `intrastatFk`, + `id`.`importe` AS `amount`, + `id`.`unidades` AS `stems`, + `id`.`Paises_Id` AS `countryFk`, + `id`.`odbc_date` AS `dated`, + `id`.`valorestadistico` AS `statisticalValue` +FROM + `vn2008`.`intrastat_data` `id`; + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); \ No newline at end of file diff --git a/modules/invoiceIn/back/methods/invoice-in/summary.js b/modules/invoiceIn/back/methods/invoice-in/summary.js index acabe29d94..0e55eeaace 100644 --- a/modules/invoiceIn/back/methods/invoice-in/summary.js +++ b/modules/invoiceIn/back/methods/invoice-in/summary.js @@ -64,6 +64,34 @@ module.exports = Self => { }] } }, + { + relation: 'invoiceInIntrastat', + scope: { + fields: [ + 'id', + 'invoiceInFk', + 'net', + 'intrastatFk', + 'amount', + 'stems', + 'countryFk', + 'statisticalValue'], + include: [{ + relation: 'intrastat', + scope: { + fields: [ + 'id', + 'description'] + } + }, + { + relation: 'country', + scope: { + fields: ['code'] + } + }] + } + }, { relation: 'invoiceInTax', scope: { diff --git a/modules/invoiceIn/back/model-config.json b/modules/invoiceIn/back/model-config.json index f0745f53b2..6765ae81c8 100644 --- a/modules/invoiceIn/back/model-config.json +++ b/modules/invoiceIn/back/model-config.json @@ -8,6 +8,9 @@ "InvoiceInDueDay": { "dataSource": "vn" }, + "InvoiceInIntrastat": { + "dataSource": "vn" + }, "InvoiceInLog": { "dataSource": "vn" } diff --git a/modules/invoiceIn/back/models/invoice-in-intrastat.json b/modules/invoiceIn/back/models/invoice-in-intrastat.json new file mode 100644 index 0000000000..65ab1f36af --- /dev/null +++ b/modules/invoiceIn/back/models/invoice-in-intrastat.json @@ -0,0 +1,50 @@ +{ + "name": "InvoiceInIntrastat", + "base": "VnModel", + "options": { + "mysql": { + "table": "invoiceInIntrastat" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "invoiceInFk": { + "type": "number" + }, + "net": { + "type": "number" + }, + "intrastatFk": { + "type": "number" + }, + "amount": { + "type": "number" + }, + "stems": { + "type": "number" + }, + "countryFk": { + "type": "number" + }, + "statisticalValue": { + "type": "number" + } + }, + "relations": { + "intrastat": { + "type": "belongsTo", + "model": "Intrastat", + "foreignKey": "intrastatFk" + }, + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + } + } + +} \ No newline at end of file diff --git a/modules/invoiceIn/back/models/invoice-in.json b/modules/invoiceIn/back/models/invoice-in.json index feb2d9aec0..c6a736b06a 100644 --- a/modules/invoiceIn/back/models/invoice-in.json +++ b/modules/invoiceIn/back/models/invoice-in.json @@ -64,6 +64,11 @@ "model": "InvoiceInDueDay", "foreignKey": "invoiceInFk" }, + "invoiceInIntrastat": { + "type": "hasMany", + "model": "InvoiceInIntrastat", + "foreignKey": "invoiceInFk" + }, "invoiceInTax": { "type": "hasMany", "model": "InvoiceInTax", diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index 18e9d73c27..7b6d6a77cf 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -10,5 +10,6 @@ import './summary'; import './basic-data'; import './tax'; import './dueDay'; +import './intrastat'; import './create'; import './log'; diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html new file mode 100644 index 0000000000..e59d9c1f6d --- /dev/null +++ b/modules/invoiceIn/front/intrastat/index.html @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + +
+ + + + {{id | zeroFill:8}}: {{description}} + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/invoiceIn/front/intrastat/index.js b/modules/invoiceIn/front/intrastat/index.js new file mode 100644 index 0000000000..b2062e7f73 --- /dev/null +++ b/modules/invoiceIn/front/intrastat/index.js @@ -0,0 +1,60 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + set invoceInIntrastat(value) { + this._invoceInIntrastat = value; + + if (value) this.calculateTotals(); + } + + get invoceInIntrastat() { + return this._invoceInIntrastat; + } + + calculateTotals() { + this.amountTotal = 0.0; + this.netTotal = 0.0; + this.stemsTotal = 0.0; + if (!this._invoceInIntrastat) return; + + this._invoceInIntrastat.forEach(intrastat => { + this.amountTotal += intrastat.amount; + this.netTotal += intrastat.net; + this.stemsTotal += intrastat.stems; + }); + } + + add() { + this.$.model.insert({}); + } + + deleteIntrastat($index) { + this.$.model.remove($index); + this.$.model.save().then(() => { + this.vnApp.showSuccess(this.$t('Data saved!')); + this.calculateTotals(); + }); + } + + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + this.calculateTotals(); + this.card.reload(); + }); + } +} + +ngModule.vnComponent('vnInvoiceInIntrastat', { + template: require('./index.html'), + controller: Controller, + require: { + card: '^vnInvoiceInCard' + }, + bindings: { + invoiceIn: '<' + } +}); diff --git a/modules/invoiceIn/front/intrastat/index.spec.js b/modules/invoiceIn/front/intrastat/index.spec.js new file mode 100644 index 0000000000..d0db179041 --- /dev/null +++ b/modules/invoiceIn/front/intrastat/index.spec.js @@ -0,0 +1,55 @@ +import './index.js'; +import watcher from 'core/mocks/watcher'; +import crudModel from 'core/mocks/crud-model'; + +describe('InvoiceIn', () => { + describe('Component intrastat', () => { + let controller; + let $scope; + let vnApp; + + beforeEach(ngModule('invoiceIn')); + + beforeEach(inject(($componentController, $rootScope, _vnApp_) => { + vnApp = _vnApp_; + jest.spyOn(vnApp, 'showError'); + $scope = $rootScope.$new(); + $scope.model = crudModel; + $scope.watcher = watcher; + + const $element = angular.element(''); + controller = $componentController('vnInvoiceInIntrastat', {$element, $scope}); + controller.invoiceIn = {id: 1}; + })); + + describe('calculateTotals()', () => { + it('should set amountTotal, netTotal and stemsTotal to 0 if salesClaimed has no data', () => { + controller.invoceInIntrastat = []; + controller.calculateTotals(); + + expect(controller.amountTotal).toEqual(0); + expect(controller.netTotal).toEqual(0); + expect(controller.stemsTotal).toEqual(0); + }); + }); + + describe('onSubmit()', () => { + it('should make HTTP POST request to save intrastat values', () => { + controller.card = {reload: () => {}}; + jest.spyOn($scope.watcher, 'check'); + jest.spyOn($scope.watcher, 'notifySaved'); + jest.spyOn($scope.watcher, 'updateOriginalData'); + jest.spyOn(controller.card, 'reload'); + jest.spyOn($scope.model, 'save'); + + controller.onSubmit(); + + expect($scope.model.save).toHaveBeenCalledWith(); + expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); + expect($scope.watcher.check).toHaveBeenCalledWith(); + expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); + expect(controller.card.reload).toHaveBeenCalledWith(); + }); + }); + }); +}); diff --git a/modules/invoiceIn/front/locale/es.yml b/modules/invoiceIn/front/locale/es.yml index 1ebfa8fe20..bf93da9b86 100644 --- a/modules/invoiceIn/front/locale/es.yml +++ b/modules/invoiceIn/front/locale/es.yml @@ -9,10 +9,14 @@ InvoiceIn cloned: Factura clonada InvoiceIn deleted: Factura eliminada Invoice list: Listado de facturas recibidas InvoiceIn booked: Factura contabilizada +Net: Neto Remove tax: Quitar iva Remove due day: Quitar vencimiento Sage tax: Sage iva Sage transaction: Sage transaccion Search invoices in by reference: Buscar facturas recibidas por referencia To book: Contabilizar - +Total amount: Total importe +Total net: Total neto +Total stems: Total unidades +Units: Unidades diff --git a/modules/invoiceIn/front/routes.json b/modules/invoiceIn/front/routes.json index 0eb6258d3e..4867b7db9a 100644 --- a/modules/invoiceIn/front/routes.json +++ b/modules/invoiceIn/front/routes.json @@ -27,6 +27,10 @@ "state": "invoiceIn.card.dueDay", "icon": "icon-calendar" }, + { + "state": "invoiceIn.card.intrastat", + "icon": "icon-lines" + }, { "state": "invoiceIn.card.log", "icon": "history" @@ -109,6 +113,16 @@ }, "acl": ["administrative"] }, + { + "url": "/intrastat", + "state": "invoiceIn.card.intrastat", + "component": "vn-invoice-in-intrastat", + "description": "Intrastat", + "params": { + "invoice-in": "$ctrl.invoiceIn" + }, + "acl": ["administrative"] + }, { "url": "/log", "state": "invoiceIn.card.log", diff --git a/modules/invoiceIn/front/summary/index.html b/modules/invoiceIn/front/summary/index.html index ae6d985f86..cb7834c95f 100644 --- a/modules/invoiceIn/front/summary/index.html +++ b/modules/invoiceIn/front/summary/index.html @@ -120,6 +120,37 @@ + + +

+ + Intrastat + +

+ + + + Code + Amount + Net + Units + Country + + + + + {{::intrastat.intrastatFk | zeroFill:8}}: {{::intrastat.intrastat.description}} + {{::intrastat.amount | currency: 'EUR':2}} + {{::intrastat.net}} + {{::intrastat.stems}} + {{::intrastat.country.code}} + + + +
+
From 062a3146a3c49904635cb03161bba7008c654e8c Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 17 Feb 2022 10:03:04 +0100 Subject: [PATCH 02/23] fix: modify intrastat.sql to show "neto" field --- print/templates/reports/invoice/sql/intrastat.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/print/templates/reports/invoice/sql/intrastat.sql b/print/templates/reports/invoice/sql/intrastat.sql index e391056ec5..6bf72c158a 100644 --- a/print/templates/reports/invoice/sql/intrastat.sql +++ b/print/templates/reports/invoice/sql/intrastat.sql @@ -2,9 +2,13 @@ SELECT ir.id AS code, ir.description AS description, CAST(SUM(IFNULL(i.stems,1) * s.quantity) AS DECIMAL(10,2)) as stems, - CAST(SUM( weight) AS DECIMAL(10,2)) as netKg, + CAST(SUM(IF(sv.physicalWeight, sv.physicalWeight, i.density * sub.cm3delivery/1000000)) AS DECIMAL(10,2)) netKg, CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) AS subtotal - FROM vn.sale s + FROM vn.sale s + LEFT JOIN (SELECT ic.itemFk, ic.cm3, ic.cm3delivery + FROM vn.itemCost ic + WHERE ic.cm3 + GROUP BY ic.itemFk) sub ON s.itemFk = sub.itemFk LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id LEFT JOIN vn.ticket t ON t.id = s.ticketFk LEFT JOIN vn.invoiceOut io ON io.ref = t.refFk From a152e22f6e34953cd9c88e60c0c63821f93fc9bf Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 18 Feb 2022 12:26:16 +0100 Subject: [PATCH 03/23] update sql changes --- .../00-invoiceInIntrastat.sql | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/db/changes/10420-valentines/00-invoiceInIntrastat.sql b/db/changes/10420-valentines/00-invoiceInIntrastat.sql index 5a25940fb5..689db69133 100644 --- a/db/changes/10420-valentines/00-invoiceInIntrastat.sql +++ b/db/changes/10420-valentines/00-invoiceInIntrastat.sql @@ -1,22 +1,2 @@ -DROP VIEW `vn`.`invoiceInIntrastat__`; -RENAME TABLE `vn`.`invoiceInIntrastat` TO `vn`.`invoiceInIntrastat__`; - -CREATE OR REPLACE -ALGORITHM = UNDEFINED -DEFINER=`root`@`localhost` -VIEW `vn`.`invoiceInIntrastat` AS -SELECT - `id`.`id` AS `id`, - `id`.`recibida_id` AS `invoiceInFk`, - `id`.`neto` AS `net`, - `id`.`intrastat_id` AS `intrastatFk`, - `id`.`importe` AS `amount`, - `id`.`unidades` AS `stems`, - `id`.`Paises_Id` AS `countryFk`, - `id`.`odbc_date` AS `dated`, - `id`.`valorestadistico` AS `statisticalValue` -FROM - `vn2008`.`intrastat_data` `id`; - INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); \ No newline at end of file From 84ebeed8efbc320a068b1dd2c32cb7adea8d3bd9 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 21 Mar 2022 13:04:25 +0100 Subject: [PATCH 04/23] add fixtures --- db/dump/fixtures.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 07eaf23fdd..fd97e94418 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2395,6 +2395,13 @@ INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `for (6, 29.95, '7001000000', NULL, 7, 20), (7, 58.64, '6210000567', NULL, 8, 20); +INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk`) + VALUES + (1, 30.50, 5080000, 10.00, 162, 5), + (1, 10, 6021010, 20.00, 205, 5), + (2, 13.20, 5080000, 15.00, 580, 5), + (2, 16.10, 6021010, 25.00, 80, 5); + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) SELECT `id` FROM `vn`.`ticket` t From a5ca116571be6bf2fbb331edc0aded119feb7739 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 29 Mar 2022 13:42:37 +0200 Subject: [PATCH 05/23] feat(ticket_sale): add mana options --- db/changes/10440-fallas/00-component.sql | 2 ++ .../back/methods/ticket/updateDiscount.js | 10 ++++++-- modules/ticket/front/sale/index.html | 23 ++++++++++++++++++- modules/ticket/front/sale/index.js | 19 ++++++++++++++- modules/ticket/front/sale/locale/es.yml | 4 +++- 5 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 db/changes/10440-fallas/00-component.sql diff --git a/db/changes/10440-fallas/00-component.sql b/db/changes/10440-fallas/00-component.sql new file mode 100644 index 0000000000..34810280bc --- /dev/null +++ b/db/changes/10440-fallas/00-component.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`) + VALUES ('maná reclamacion',7,4,0,'mana claim',0); \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index cf217348ad..a5550cbb38 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -23,6 +23,12 @@ module.exports = Self => { description: 'The new discount', type: 'number', required: true + }, + { + arg: 'manaType', + description: 'The type of mana', + type: 'string', + required: true } ], returns: { @@ -35,7 +41,7 @@ module.exports = Self => { } }); - Self.updateDiscount = async(ctx, id, salesIds, newDiscount, options) => { + Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaType, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; const myOptions = {}; @@ -98,7 +104,7 @@ module.exports = Self => { }, fields: 'amount'}, myOptions); - const componentCode = usesMana ? 'mana' : 'buyerDiscount'; + const componentCode = usesMana ? manaType : 'buyerDiscount'; const discountComponent = await models.Component.findOne({ where: {code: componentCode}}, myOptions); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 5dc3c94280..7cad8e98a8 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -285,10 +285,21 @@ vn-focus label="Discount" ng-model="$ctrl.edit.discount" - on-change="$ctrl.changeDiscount()" clear-disabled="true" suffix="%"> + + + + + +

New price

@@ -297,6 +308,16 @@

+ + + + + + diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 54167ce96f..5aae9e1ddd 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -6,6 +6,15 @@ class Controller extends Section { constructor($element, $) { super($element, $); this._sales = []; + this.manaType = 'mana'; + } + + get manaType() { + return this._manaType; + } + + set manaType(value) { + this._manaType = value; } get ticket() { @@ -273,7 +282,7 @@ class Controller extends Section { return sale.id; }); - const params = {salesIds: saleIds, newDiscount: this.edit.discount}; + const params = {salesIds: saleIds, newDiscount: this.edit.discount, manaType: this.manaType}; const query = `Tickets/${this.$params.id}/updateDiscount`; this.$http.post(query, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); @@ -479,6 +488,14 @@ class Controller extends Section { ? {id: $search} : {name: {like: '%' + $search + '%'}}; } + + save() { + this.changeDiscount(); + } + + cancel() { + this.$.editDiscount.hide(); + } } ngModule.vnComponent('vnTicketSale', { diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index e4152600f3..7edb0a626d 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -36,4 +36,6 @@ Warehouse: Almacen Agency: Agencia Shipped: F. envio Packaging: Encajado -Pay Back: Abono \ No newline at end of file +Pay Back: Abono +Promotion mana: Maná promoción +Claim mana: Maná reclamación \ No newline at end of file From c15aea213f96945dca7f5224da28bc5c2982b54d Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 29 Mar 2022 13:42:56 +0200 Subject: [PATCH 06/23] feat(ticket_sale): add front test --- modules/ticket/front/sale/index.spec.js | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 15ce1798b3..68d62204cf 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -43,7 +43,7 @@ describe('Ticket', () => { $scope.sms = {open: () => {}}; $scope.ticket = ticket; $scope.model = crudModel; - $scope.editDiscount = {relocate: () => {}}; + $scope.editDiscount = {relocate: () => {}, hide: () => {}}; $scope.editPricePopover = {relocate: () => {}}; $httpBackend = _$httpBackend_; Object.defineProperties($state.params, { @@ -63,6 +63,14 @@ describe('Ticket', () => { controller._sales = sales; })); + describe('manaType() setter/getter', () => { + it('should set the manaType data', () => { + controller.manaType = 'mana claim'; + + expect(controller.manaType).toEqual('mana claim'); + }); + }); + describe('ticket() setter', () => { it('should set the ticket data an then call the isTicketEditable() and isTicketLocked() methods', () => { jest.spyOn(controller, 'isTicketEditable').mockReturnThis(); @@ -446,7 +454,7 @@ describe('Ticket', () => { const expectedSales = [firstSelectedSale, secondSelectedSale]; const expectedSaleIds = [firstSelectedSale.id, secondSelectedSale.id]; - const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount}; + const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaType: 'mana'}; $httpBackend.expect('POST', `Tickets/1/updateDiscount`, expectedParams).respond(200, {discount: 10}); controller.updateDiscount(expectedSales); $httpBackend.flush(); @@ -732,5 +740,23 @@ describe('Ticket', () => { expect(result).toEqual({name: {like: '%' + itemName + '%'}}); }); }); + + describe('save()', () => { + it('should call changeDiscount()', () => { + jest.spyOn(controller, 'changeDiscount').mockReturnThis(); + controller.save(); + + expect(controller.changeDiscount).toHaveBeenCalledWith(); + }); + }); + + describe('cancel()', () => { + it('should call hide()', () => { + jest.spyOn(controller.$.editDiscount, 'hide').mockReturnThis(); + controller.cancel(); + + expect(controller.$.editDiscount.hide).toHaveBeenCalledWith(); + }); + }); }); }); From 86350b2afadb0f1d6d331c3400ea851549fc3091 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 29 Mar 2022 14:00:53 +0200 Subject: [PATCH 07/23] feat(ticket_sale): add backTest --- .../ticket/specs/updateDiscount.spec.js | 45 ++++++++++++++++++- .../back/methods/ticket/updateDiscount.js | 2 +- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js index ae79185e41..1a20b07535 100644 --- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js +++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js @@ -90,7 +90,7 @@ describe('sale updateDiscount()', () => { expect(error.message).toEqual(`The sales of this ticket can't be modified`); }); - it('should update the discount if the salesPerson has mana', async() => { + it('should update the discount if the salesPerson has mana and manaType = "mana"', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -108,8 +108,49 @@ describe('sale updateDiscount()', () => { const newDiscount = 100; const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options); const componentId = manaDiscount.id; + const manaType = 'mana'; - await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, options); + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options); + + const updatedSale = await models.Sale.findById(originalSaleId, null, options); + const createdSaleComponent = await models.SaleComponent.findOne({ + where: { + componentFk: componentId, + saleFk: originalSaleId + } + }, options); + + expect(createdSaleComponent.componentFk).toEqual(componentId); + expect(updatedSale.discount).toEqual(100); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should update the discount if the salesPerson has mana and manaType = "mana claim"', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ctx = { + req: { + accessToken: {userId: 18}, + headers: {origin: 'localhost:5000'}, + __: () => {} + } + }; + const ticketId = 11; + const sales = [originalSaleId]; + const newDiscount = 100; + const manaDiscount = await models.Component.findOne({where: {code: 'mana claim'}}, options); + const componentId = manaDiscount.id; + const manaType = 'mana claim'; + + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options); const updatedSale = await models.Sale.findById(originalSaleId, null, options); const createdSaleComponent = await models.SaleComponent.findOne({ diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index a5550cbb38..9726dae1a3 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -28,7 +28,7 @@ module.exports = Self => { arg: 'manaType', description: 'The type of mana', type: 'string', - required: true + required: false } ], returns: { From 63a857a6169dba35435df15dc012d2e281b5cb79 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 29 Mar 2022 14:33:22 +0200 Subject: [PATCH 08/23] fix: updated test e2e --- e2e/helpers/selectors.js | 1 + e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js | 1 + 2 files changed, 2 insertions(+) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 21ed271587..56902e58d1 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -586,6 +586,7 @@ export default { firstSalePriceInput: '.vn-popover.shown input[ng-model="$ctrl.field"]', firstSaleDiscount: 'vn-ticket-sale vn-table vn-tr:nth-child(1) > vn-td:nth-child(10) > span', firstSaleDiscountInput: '.vn-popover.shown [ng-model="$ctrl.field"]', + saveSaleDiscountButton: '.vn-popover.shown vn-button[label="Save"]', firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(11)', firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)', firstSaleColour: 'vn-ticket-sale vn-tr:nth-child(1) vn-fetched-tags section', diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 5078d5b91a..f22d1af30a 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -176,6 +176,7 @@ describe('Ticket Edit sale path', () => { await page.waitToClick(selectors.ticketSales.firstSaleDiscount); await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput); await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d'); + await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); From e0244f388c869ef813c1433b77db181f01be51c9 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 07:39:42 +0200 Subject: [PATCH 09/23] refator: single quotes in sql files --- db/changes/10420-valentines/00-aclIntrastat.sql | 4 ++-- db/changes/10420-valentines/00-invoiceInIntrastat.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/changes/10420-valentines/00-aclIntrastat.sql b/db/changes/10420-valentines/00-aclIntrastat.sql index 59805ed3f5..16410814d4 100644 --- a/db/changes/10420-valentines/00-aclIntrastat.sql +++ b/db/changes/10420-valentines/00-aclIntrastat.sql @@ -1,3 +1,3 @@ -INSERT INTO salix.ACL -(model, property, accessType, permission, principalType, principalId) +INSERT INTO `salix`.`ACL` +(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10420-valentines/00-invoiceInIntrastat.sql b/db/changes/10420-valentines/00-invoiceInIntrastat.sql index 689db69133..8f65fac294 100644 --- a/db/changes/10420-valentines/00-invoiceInIntrastat.sql +++ b/db/changes/10420-valentines/00-invoiceInIntrastat.sql @@ -1,2 +1,2 @@ -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); \ No newline at end of file From 572cc30a4ee4d3f82acdc3bc3f496752a796b800 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 07:53:00 +0200 Subject: [PATCH 10/23] refactor: updated translate --- modules/invoiceIn/front/intrastat/index.html | 2 +- modules/invoiceIn/front/locale/es.yml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html index e59d9c1f6d..c58839e384 100644 --- a/modules/invoiceIn/front/intrastat/index.html +++ b/modules/invoiceIn/front/intrastat/index.html @@ -63,7 +63,7 @@ vn-focus> diff --git a/modules/invoiceIn/front/locale/es.yml b/modules/invoiceIn/front/locale/es.yml index bf93da9b86..4f36b33fa8 100644 --- a/modules/invoiceIn/front/locale/es.yml +++ b/modules/invoiceIn/front/locale/es.yml @@ -18,5 +18,4 @@ Search invoices in by reference: Buscar facturas recibidas por referencia To book: Contabilizar Total amount: Total importe Total net: Total neto -Total stems: Total unidades -Units: Unidades +Total stems: Total tallos From 5b1d610f2ff9a71c1fbec8aab1b3a943bfa4a40b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 07:55:37 +0200 Subject: [PATCH 11/23] refator: updated translate --- modules/invoiceIn/front/summary/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/invoiceIn/front/summary/index.html b/modules/invoiceIn/front/summary/index.html index cb7834c95f..3a826eeb7c 100644 --- a/modules/invoiceIn/front/summary/index.html +++ b/modules/invoiceIn/front/summary/index.html @@ -135,7 +135,7 @@ Code Amount Net - Units + Stems Country From b78ecc06d21fa60c78ed2f8e00745c8273264b59 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 09:29:57 +0200 Subject: [PATCH 12/23] fix(ticker_sale): only show mana options if currentWorker has mana --- modules/ticket/front/sale/index.html | 2 +- modules/ticket/front/sale/index.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 7cad8e98a8..3643113bc0 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -288,7 +288,7 @@ clear-disabled="true" suffix="%"> - + { + this.currentWorkerMana = res.data; + }); } /** From 23cb8c1215a6d9562bb18977a93d9a1a84edd757 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 09:54:01 +0200 Subject: [PATCH 13/23] refactor(ticket_sale): update frontTest --- modules/ticket/front/sale/index.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 68d62204cf..a1088c0cce 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -123,10 +123,12 @@ describe('Ticket', () => { const expectedAmount = 250; $httpBackend.expect('GET', 'Tickets/1/getSalesPersonMana').respond(200, expectedAmount); + $httpBackend.expect('GET', 'WorkerManas/getCurrentWorkerMana').respond(200, expectedAmount); controller.getMana(); $httpBackend.flush(); expect(controller.edit.mana).toEqual(expectedAmount); + expect(controller.currentWorkerMana).toEqual(expectedAmount); }); }); From 3bf2b46689e49d07e55ae5fcb413cb53b88d469b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 30 Mar 2022 10:09:01 +0200 Subject: [PATCH 14/23] feat(ticket_line): update workerMana if check claimMana option --- .../10440-fallas/00-manaCustomerUpdate.sql | 106 ++++++++++++++++++ .../10440-fallas/00-manaSpellersRequery.sql | 75 +++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 db/changes/10440-fallas/00-manaCustomerUpdate.sql create mode 100644 db/changes/10440-fallas/00-manaSpellersRequery.sql diff --git a/db/changes/10440-fallas/00-manaCustomerUpdate.sql b/db/changes/10440-fallas/00-manaCustomerUpdate.sql new file mode 100644 index 0000000000..6a714f81eb --- /dev/null +++ b/db/changes/10440-fallas/00-manaCustomerUpdate.sql @@ -0,0 +1,106 @@ +DROP PROCEDURE IF EXISTS `bs`.`manaCustomerUpdate`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `bs`.`manaCustomerUpdate`() +BEGIN + DECLARE vToDated DATE; + DECLARE vFromDated DATE; + DECLARE vForDeleteDated DATE; + DECLARE vManaId INT; + DECLARE vManaAutoId INT; + DECLARE vClaimManaId INT; + DECLARE vManaBankId INT; + DECLARE vManaGreugeTypeId INT; + + SELECT id INTO vManaId + FROM `component` WHERE code = 'mana'; + + SELECT id INTO vManaAutoId + FROM `component` WHERE code = 'autoMana'; + + SELECT id INTO vClaimManaId + FROM `component` WHERE code = 'mana claim'; + + SELECT id INTO vManaBankId + FROM `bank` WHERE code = 'mana'; + + SELECT id INTO vManaGreugeTypeId + FROM `greugeType` WHERE code = 'mana'; + + SELECT IFNULL(max(dated), '2016-01-01') + INTO vFromDated + FROM bs.manaCustomer; + + DELETE + FROM bs.manaCustomer + WHERE dated = vFromDated; + + SELECT IFNULL(max(dated), '2016-01-01') + INTO vFromDated + FROM bs.manaCustomer; + + WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO + + SELECT + timestampadd(DAY,30,vFromDated), + timestampadd(DAY,-90,vFromDated) + INTO + vToDated, + vForDeleteDated; + + DELETE FROM bs.manaCustomer + WHERE dated <= vForDeleteDated; + + + INSERT INTO bs.manaCustomer(Id_Cliente, Mana, dated) + + SELECT + Id_Cliente, + cast(sum(mana) as decimal(10,2)) as mana, + vToDated as dated + FROM + + ( + SELECT cs.Id_Cliente, Cantidad * Valor as mana + FROM vn2008.Tickets t + JOIN vn2008.Consignatarios cs using(Id_Consigna) + JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento + WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId) + AND t.Fecha > vFromDated + AND date(t.Fecha) <= vToDated + + + UNION ALL + + SELECT r.Id_Cliente, - Entregado + FROM vn2008.Recibos r + WHERE Id_Banco = vManaBankId + AND Fechacobro > vFromDated + AND Fechacobro <= vToDated + + UNION ALL + + SELECT g.Id_Cliente, g.Importe + FROM vn2008.Greuges g + WHERE Greuges_type_id = vManaGreugeTypeId + AND Fecha > vFromDated + AND Fecha <= vToDated + + UNION ALL + + SELECT Id_Cliente, mana + FROM bs.manaCustomer + WHERE dated = vFromDated + ) sub + + GROUP BY Id_Cliente + HAVING Id_Cliente; + + SET vFromDated = vToDated; + + END WHILE; + +END$$ +DELIMITER ; diff --git a/db/changes/10440-fallas/00-manaSpellersRequery.sql b/db/changes/10440-fallas/00-manaSpellersRequery.sql new file mode 100644 index 0000000000..1a0a03ddb4 --- /dev/null +++ b/db/changes/10440-fallas/00-manaSpellersRequery.sql @@ -0,0 +1,75 @@ +DROP PROCEDURE IF EXISTS `vn`.`manaSpellersRequery`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER) +BEGIN +/** + * Recalcula el mana consumido por un trabajador + * + * @param vWorkerFk Id Trabajador + */ + DECLARE vWorkerIsExcluded BOOLEAN; + DECLARE vFromDated DATE; + DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE()); + DECLARE vMana INT; + DECLARE vAutoMana INT; + DECLARE vClaimMana INT; + DECLARE vManaBank INT; + DECLARE vManaGreugeType INT; + + SELECT COUNT(*) INTO vWorkerIsExcluded + FROM workerManaExcluded + WHERE workerFk = vWorkerFk; + + IF NOT vWorkerIsExcluded THEN + SELECT id INTO vMana + FROM `component` WHERE code = 'mana'; + + SELECT id INTO vAutoMana + FROM `component` WHERE code = 'autoMana'; + + SELECT id INTO vClaimMana + FROM `component` WHERE code = 'mana claim'; + + SELECT id INTO vManaBank + FROM `bank` WHERE code = 'mana'; + + SELECT id INTO vManaGreugeType + FROM `greugeType` WHERE code = 'mana'; + + SELECT max(dated) INTO vFromDated + FROM clientManaCache; + + REPLACE workerMana (workerFk, amount) + SELECT vWorkerFk, sum(mana) FROM + ( + SELECT s.quantity * sc.value as mana + FROM ticket t + JOIN address a ON a.id = t.addressFk + JOIN client c ON c.id = a.clientFk + JOIN sale s ON s.ticketFk = t.id + JOIN saleComponent sc ON sc.saleFk = s.id + WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana, vClaimMana) + AND t.shipped > vFromDated AND t.shipped < vToDated + UNION ALL + SELECT - r.amountPaid + FROM receipt r + JOIN client c ON c.id = r.clientFk + WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank + AND payed > vFromDated + UNION ALL + SELECT g.amount + FROM greuge g + JOIN client c ON c.id = g.clientFk + WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType + AND g.shipped > vFromDated and g.shipped < CURDATE() + UNION ALL + SELECT cc.mana + FROM clientManaCache cc + JOIN client c ON c.id = cc.clientFk + WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated + ) sub; + END IF; +END$$ +DELIMITER ; From 1f826e1214f23844ccb9607f02f84b1e26a648f9 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 09:16:55 +0200 Subject: [PATCH 15/23] sql code for production --- db/changes/10440-fallas/00-country.sql | 88 ++++++++++++++++++++++++++ db/changes/10440-fallas/00-worker.sql | 49 ++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 db/changes/10440-fallas/00-country.sql create mode 100644 db/changes/10440-fallas/00-worker.sql diff --git a/db/changes/10440-fallas/00-country.sql b/db/changes/10440-fallas/00-country.sql new file mode 100644 index 0000000000..06b4f9b949 --- /dev/null +++ b/db/changes/10440-fallas/00-country.sql @@ -0,0 +1,88 @@ +ALTER TABLE `vn`.`country` ADD `a3Code` INT NULL COMMENT 'Código país para a3'; + +UPDATE `vn`.`country` c +JOIN `vn2008`.`payroll_pais` `p` ON `p`.`pais` = `c`.`country` +SET `c`.`a3Code` = `p`.`codpais`; + +UPDATE `vn`.`country` +SET `a3Code` = 710 +WHERE `country` = 'Sud-Africa'; -- ÁFRICA DEL SUR + +UPDATE `vn`.`country` +SET `a3Code` = 643 +WHERE `country` = 'Rusia'; -- FEDERACIÓN DE RUSIA + +UPDATE `vn`.`country` +SET `a3Code` = 28 +WHERE `country` = 'Antigua'; -- ANTIGUA Y BARBUDA + +UPDATE `vn`.`country` +SET `a3Code` = 840 +WHERE `country` = 'USA'; -- ESTADOS UNIDOS + +UPDATE `vn`.`country` +SET `a3Code` = 404 +WHERE `country` = 'Kenya'; -- KENIA + +UPDATE `vn`.`country` +SET `a3Code` = 498 +WHERE `country` = 'Moldavia'; -- REPÚBLICA DE MOLDAVIA + +UPDATE `vn`.`country` +SET `a3Code` = 826 +WHERE `country` = 'Gran Bretaña'; -- REINO UNIDO + +UPDATE `vn`.`country` +SET `a3Code` = 484 +WHERE `country` = 'Mexico'; -- MÉJICO + +UPDATE `vn`.`country` +SET `a3Code` = 716 +WHERE `country` = 'Zimbawe'; -- ZINBABWE + +UPDATE `vn`.`country` +SET `a3Code` = 203 +WHERE `country` = 'Chequia'; -- REPÚBLICA CHECA + +UPDATE `vn`.`country` +SET `a3Code` = 764 +WHERE `country` = 'Thailandia'; -- TAILANDIA + +UPDATE `vn`.`country` +SET `a3Code` = 276 +WHERE `country` = 'Alemania'; -- REPÚBLICA FEDERAL DE ALEMANIA + +UPDATE `vn`.`country` +SET `a3Code` = 112 +WHERE `country` = 'Bielorrusia'; -- BELARUS + +UPDATE `vn`.`country` +SET `a3Code` = 528 +WHERE `country` = 'Holanda'; -- PAÍSES BAJOS + +UPDATE `vn`.`country` +SET `a3Code` = 410 +WHERE `country` = 'Corea del Sur'; -- COREA (REPÚBLICA) + +UPDATE `vn`.`country` +SET `a3Code` = 724 +WHERE `country` = 'España exento'; -- ESPAÑA + +-- Borrar registro USA de country: +UPDATE `vn`.`supplier` `s` + SET `s`.`countryFk` = 62 + WHERE `s`.`countryFk` = 12; + +UPDATE `vn`.`bankEntity` + SET `countryFk` = 62 + WHERE `countryFk` = 12; + +DELETE FROM `vn`.`country` + WHERE `id`= 12; + +UPDATE `vn2008`.`payroll_pais` +SET `pais`='COREA NORTE (REPÚBLICA DEM. POPULAR)' +WHERE `codpais`=408; +UPDATE `vn2008`.`payroll_pais` +SET `pais`='COREA SUR (REPÚBLICA) ' +WHERE `codpais`=410; diff --git a/db/changes/10440-fallas/00-worker.sql b/db/changes/10440-fallas/00-worker.sql new file mode 100644 index 0000000000..5688ebdf11 --- /dev/null +++ b/db/changes/10440-fallas/00-worker.sql @@ -0,0 +1,49 @@ + +ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus__` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +UPDATE `vn`.`worker` `w` + SET `w`.`maritalStatus__` = NULL; + +UPDATE `vn`.`worker` `w` + JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id` + JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id` + JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id` + SET `w`.`maritalStatus__` = `pl`.`estadocivil`; + +ALTER TABLE `vn`.`worker` ADD `originCountryFk` mediumint(8) unsigned NULL COMMENT 'País de origen'; +ALTER TABLE `vn`.`worker` ADD `educationLevelFk` SMALLINT NULL; +ALTER TABLE `vn`.`worker` ADD `SSN` varchar(15) NULL; +ALTER TABLE `vn`.`worker` CHANGE `maritalStatus__` `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`worker` CHANGE `maritalStatus` maritalStatus enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER sectorFk; +ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `vn`.`educationLevel`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `vn`.`country`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +INSERT INTO `vn`.`country` (`country`, `CEE`, `code`, `politicalCountryFk`, `isUeeMember`, `a3Code`) + VALUES + ('Argentina',2,'AR',80,0,32), + ('Cuba',2,'CU',81,0,192), + ('Guinea Ecuatorial',2,'GQ',82,0,226), + ('Guinea',2,'GN',83,0,324), + ('Honduras',2,'HN',84,0,340), + ('Mali',2,'ML',85,0,466), + ('Nicaragua',2,'NI',86,0,558), + ('Pakistán',2,'PK',87,0,586), + ('Paraguay',2,'PY',88,0,600), + ('Senegal',2,'SN',89,0,686), + ('Uruguay',2,'UY',90,0,858), + ('Venezuela',2,'VE',91,0,862), + ('Bulgaria',2,'BG',92,1,100), + ('Georgia',2,'GE',93,0,268); + +UPDATE `vn`.`worker` `w` + JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id` + JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id` + JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id` + JOIN `vn`.`country` `co` ON `co`.`a3Code` = `pl`.`codpais` + SET `w`.`originCountryFk` = `co`.`id`; + +UPDATE `vn`.`worker` `w` + JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id` + JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id` + JOIN `vn2008`.`profile_labour_payroll` pl ON `pl`.`profile_id` = `pr`.`profile_id` + SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`); \ No newline at end of file From bb267dad16426574f797bdc37577a1ecdb211541 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 09:17:27 +0200 Subject: [PATCH 16/23] feat: add fixtures --- db/changes/10440-fallas/00-aclEducationLevel.sql | 2 ++ db/dump/fixtures.sql | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 db/changes/10440-fallas/00-aclEducationLevel.sql diff --git a/db/changes/10440-fallas/00-aclEducationLevel.sql b/db/changes/10440-fallas/00-aclEducationLevel.sql new file mode 100644 index 0000000000..26bf9d16fa --- /dev/null +++ b/db/changes/10440-fallas/00-aclEducationLevel.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES('EducationLevel', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index aa03c39b56..63f206a7d0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -47,6 +47,11 @@ INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active` INSERT INTO `account`.`account`(`id`) SELECT id FROM `account`.`user`; +INSERT INTO `vn`.`educationLevel` (`id`, `name`) + VALUES + (1, 'ESTUDIOS PRIMARIOS COMPLETOS'), + (2, 'ENSEÑANZAS DE BACHILLERATO'); + INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 FROM `vn`.`user`; From 443db55f58e71e7a690ecfe9dd9be5d541154102 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 09:18:18 +0200 Subject: [PATCH 17/23] feat(worker_basic-data): add new fields --- modules/worker/back/model-config.json | 3 ++ .../worker/back/models/education-level.json | 18 ++++++++++ modules/worker/back/models/worker.json | 12 +++++++ modules/worker/front/basic-data/index.html | 36 +++++++++++++++++++ modules/worker/front/basic-data/index.js | 7 ++++ modules/worker/front/basic-data/locale/es.yml | 6 ++++ 6 files changed, 82 insertions(+) create mode 100644 modules/worker/back/models/education-level.json create mode 100644 modules/worker/front/basic-data/locale/es.yml diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index e35e397219..c155e331de 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -17,6 +17,9 @@ "Department": { "dataSource": "vn" }, + "EducationLevel": { + "dataSource": "vn" + }, "WorkCenter": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/education-level.json b/modules/worker/back/models/education-level.json new file mode 100644 index 0000000000..641dfd6b45 --- /dev/null +++ b/modules/worker/back/models/education-level.json @@ -0,0 +1,18 @@ +{ + "name": "EducationLevel", + "base": "VnModel", + "options": { + "mysql": { + "table": "educationLevel" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number" + }, + "name": { + "type": "String" + } + } +} \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index cad38ac3ba..209cc24f48 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -34,6 +34,18 @@ }, "bossFk": { "type" : "Number" + }, + "maritalStatus": { + "type" : "String" + }, + "originCountryFk": { + "type" : "Number" + }, + "educationLevelFk": { + "type" : "Number" + }, + "SSN": { + "type" : "String" } }, "relations": { diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index b61a4cf945..d49b7ab740 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -39,6 +39,42 @@ label="Boss"> + + + + + + + + + + + + diff --git a/modules/worker/front/basic-data/index.js b/modules/worker/front/basic-data/index.js index d2c7f5b706..ea75d7b973 100644 --- a/modules/worker/front/basic-data/index.js +++ b/modules/worker/front/basic-data/index.js @@ -2,6 +2,13 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { + constructor($element, $) { + super($element, $); + this.maritalStatus = [ + {code: 'M', name: this.$t('Married')}, + {code: 'S', name: this.$t('Single')} + ]; + } onSubmit() { return this.$.watcher.submit() .then(() => this.card.reload()); diff --git a/modules/worker/front/basic-data/locale/es.yml b/modules/worker/front/basic-data/locale/es.yml new file mode 100644 index 0000000000..c4fcd5529d --- /dev/null +++ b/modules/worker/front/basic-data/locale/es.yml @@ -0,0 +1,6 @@ +Marital status: Estado civil +Origin country: País origen +Education level: Nivel educación +SSN: NSS +Married: Casado +Single: Soltero \ No newline at end of file From fe32b81d9e43a30ed8a403af34be94aeed3de76d Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 10:50:05 +0200 Subject: [PATCH 18/23] sql update --- db/changes/10440-fallas/00-country.sql | 2 ++ db/changes/10440-fallas/00-worker.sql | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/changes/10440-fallas/00-country.sql b/db/changes/10440-fallas/00-country.sql index 06b4f9b949..6cc4ce1f91 100644 --- a/db/changes/10440-fallas/00-country.sql +++ b/db/changes/10440-fallas/00-country.sql @@ -86,3 +86,5 @@ WHERE `codpais`=408; UPDATE `vn2008`.`payroll_pais` SET `pais`='COREA SUR (REPÚBLICA) ' WHERE `codpais`=410; + +RENAME TABLE `vn2008`.`payroll_pais` TO `vn2008`.`payroll_pais__`; \ No newline at end of file diff --git a/db/changes/10440-fallas/00-worker.sql b/db/changes/10440-fallas/00-worker.sql index 5688ebdf11..0e0def8413 100644 --- a/db/changes/10440-fallas/00-worker.sql +++ b/db/changes/10440-fallas/00-worker.sql @@ -46,4 +46,6 @@ UPDATE `vn`.`worker` `w` JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id` JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id` JOIN `vn2008`.`profile_labour_payroll` pl ON `pl`.`profile_id` = `pr`.`profile_id` - SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`); \ No newline at end of file + SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`); + +RENAME TABLE `vn2008`.`profile_labour_payroll` TO `vn2008`.`profile_labour_payroll__`; From 2c54f31985b98cf8fd42e7cec79408ec29d04d69 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 10:54:30 +0200 Subject: [PATCH 19/23] refactor: uppercase --- modules/worker/back/models/education-level.json | 4 ++-- modules/worker/back/models/worker.json | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/worker/back/models/education-level.json b/modules/worker/back/models/education-level.json index 641dfd6b45..4ae2376c48 100644 --- a/modules/worker/back/models/education-level.json +++ b/modules/worker/back/models/education-level.json @@ -9,10 +9,10 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, "name": { - "type": "String" + "type": "string" } } } \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 209cc24f48..c8054caff4 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -13,7 +13,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -26,26 +26,26 @@ "required": true }, "phone": { - "type" : "String" + "type" : "string" }, "userFk": { - "type" : "Number", + "type" : "number", "required": true }, "bossFk": { - "type" : "Number" + "type" : "number" }, "maritalStatus": { - "type" : "String" + "type" : "string" }, "originCountryFk": { - "type" : "Number" + "type" : "number" }, "educationLevelFk": { - "type" : "Number" + "type" : "number" }, "SSN": { - "type" : "String" + "type" : "string" } }, "relations": { From 5f29b272e1548a227f0603f09208f68f3121cf76 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 31 Mar 2022 11:38:08 +0200 Subject: [PATCH 20/23] feat: add fixtures --- db/dump/fixtures.sql | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 63f206a7d0..bae229513a 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -56,6 +56,27 @@ INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossF SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 FROM `vn`.`user`; +ALTER TABLE `vn`.`worker` ADD `originCountryFk` mediumint(8) unsigned NULL COMMENT 'País de origen'; +ALTER TABLE `vn`.`worker` ADD `educationLevelFk` SMALLINT NULL; +ALTER TABLE `vn`.`worker` ADD `SSN` varchar(15) NULL; +ALTER TABLE `vn`.`worker` CHANGE `maritalStatus__` `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`worker` CHANGE `maritalStatus` maritalStatus enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER sectorFk; +ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `vn`.`educationLevel`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `vn`.`country`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +UPDATE `vn`.`worker` `w` + SET `maritalStatus` = 'S'; + +UPDATE `vn`.`worker` `w` + SET `originCountryFk` = '1'; + +UPDATE `vn`.`worker` `w` + SET `educationLevelFk` = '2'; + +UPDATE `vn`.`worker` `w` + SET `SSN` = '123456789123'; + UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9; UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18; From d8a1bd1b1c22b834da3d2717c5ac36f747cda737 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 11 Apr 2022 08:23:54 +0200 Subject: [PATCH 21/23] fix: pull request changes --- .../00-aclIntrastat.sql | 0 .../00-invoiceInIntrastat.sql | 0 modules/invoiceIn/front/intrastat/index.html | 12 ++++---- modules/invoiceIn/front/intrastat/index.js | 4 +-- .../invoiceIn/front/intrastat/index.spec.js | 30 +++++++++++++++++++ 5 files changed, 37 insertions(+), 9 deletions(-) rename db/changes/{10420-valentines => 10440-fallas}/00-aclIntrastat.sql (100%) rename db/changes/{10420-valentines => 10440-fallas}/00-invoiceInIntrastat.sql (100%) diff --git a/db/changes/10420-valentines/00-aclIntrastat.sql b/db/changes/10440-fallas/00-aclIntrastat.sql similarity index 100% rename from db/changes/10420-valentines/00-aclIntrastat.sql rename to db/changes/10440-fallas/00-aclIntrastat.sql diff --git a/db/changes/10420-valentines/00-invoiceInIntrastat.sql b/db/changes/10440-fallas/00-invoiceInIntrastat.sql similarity index 100% rename from db/changes/10420-valentines/00-invoiceInIntrastat.sql rename to db/changes/10440-fallas/00-invoiceInIntrastat.sql diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html index c58839e384..cb447132d5 100644 --- a/modules/invoiceIn/front/intrastat/index.html +++ b/modules/invoiceIn/front/intrastat/index.html @@ -45,28 +45,26 @@ data="intrastats" ng-model="intrastat.intrastatFk" show-field="description" - rule> + rule + vn-focus> {{id | zeroFill:8}}: {{description}} + rule> + rule> + rule> { + this.invoceInIntrastat.forEach(intrastat => { this.amountTotal += intrastat.amount; this.netTotal += intrastat.net; this.stemsTotal += intrastat.stems; diff --git a/modules/invoiceIn/front/intrastat/index.spec.js b/modules/invoiceIn/front/intrastat/index.spec.js index d0db179041..d7d50ac5bf 100644 --- a/modules/invoiceIn/front/intrastat/index.spec.js +++ b/modules/invoiceIn/front/intrastat/index.spec.js @@ -31,6 +31,36 @@ describe('InvoiceIn', () => { expect(controller.netTotal).toEqual(0); expect(controller.stemsTotal).toEqual(0); }); + + it('should set amountTotal, netTotal and stemsTotal', () => { + controller.invoceInIntrastat = [ + { + id: 1, + invoiceInFk: 1, + net: 30.5, + intrastatFk: 5080000, + amount: 10, + stems: 162, + countryFk: 5, + statisticalValue: 0 + }, + { + id: 2, + invoiceInFk: 1, + net: 10, + intrastatFk: 6021010, + amount: 20, + stems: 205, + countryFk: 5, + statisticalValue: 0 + } + ]; + controller.calculateTotals(); + + expect(controller.amountTotal).toEqual(30); + expect(controller.netTotal).toEqual(40.5); + expect(controller.stemsTotal).toEqual(367); + }); }); describe('onSubmit()', () => { From 655db502f7ec205716112aec9fe97569ceeaf0c0 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 11 Apr 2022 09:04:05 +0200 Subject: [PATCH 22/23] refactor: pull request changes --- db/changes/10440-fallas/00-component.sql | 2 +- .../10440-fallas/00-manaCustomerUpdate.sql | 2 +- .../10440-fallas/00-manaSpellersRequery.sql | 2 +- .../05-ticket/01-sale/02_edit_sale.spec.js | 2 +- .../ticket/specs/updateDiscount.spec.js | 14 +++++++------- .../back/methods/ticket/updateDiscount.js | 6 +++--- modules/ticket/front/sale/index.html | 6 +++--- modules/ticket/front/sale/index.js | 12 ++++++------ modules/ticket/front/sale/index.spec.js | 19 +------------------ 9 files changed, 24 insertions(+), 41 deletions(-) diff --git a/db/changes/10440-fallas/00-component.sql b/db/changes/10440-fallas/00-component.sql index 34810280bc..8d2dd65177 100644 --- a/db/changes/10440-fallas/00-component.sql +++ b/db/changes/10440-fallas/00-component.sql @@ -1,2 +1,2 @@ INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`) - VALUES ('maná reclamacion',7,4,0,'mana claim',0); \ No newline at end of file + VALUES ('maná reclamacion',7,4,0,'manaClaim',0); \ No newline at end of file diff --git a/db/changes/10440-fallas/00-manaCustomerUpdate.sql b/db/changes/10440-fallas/00-manaCustomerUpdate.sql index 6a714f81eb..80838bca28 100644 --- a/db/changes/10440-fallas/00-manaCustomerUpdate.sql +++ b/db/changes/10440-fallas/00-manaCustomerUpdate.sql @@ -20,7 +20,7 @@ BEGIN FROM `component` WHERE code = 'autoMana'; SELECT id INTO vClaimManaId - FROM `component` WHERE code = 'mana claim'; + FROM `component` WHERE code = 'manaClaim'; SELECT id INTO vManaBankId FROM `bank` WHERE code = 'mana'; diff --git a/db/changes/10440-fallas/00-manaSpellersRequery.sql b/db/changes/10440-fallas/00-manaSpellersRequery.sql index 1a0a03ddb4..9c1a10c6a7 100644 --- a/db/changes/10440-fallas/00-manaSpellersRequery.sql +++ b/db/changes/10440-fallas/00-manaSpellersRequery.sql @@ -30,7 +30,7 @@ BEGIN FROM `component` WHERE code = 'autoMana'; SELECT id INTO vClaimMana - FROM `component` WHERE code = 'mana claim'; + FROM `component` WHERE code = 'manaClaim'; SELECT id INTO vManaBank FROM `bank` WHERE code = 'mana'; diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index f22d1af30a..9726847080 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -175,7 +175,7 @@ describe('Ticket Edit sale path', () => { it('should update the discount', async() => { await page.waitToClick(selectors.ticketSales.firstSaleDiscount); await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput); - await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d'); + await page.type(selectors.ticketSales.firstSaleDiscountInput, '50'); await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton); const message = await page.waitForSnackbar(); diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js index 1a20b07535..1873207aad 100644 --- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js +++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js @@ -90,7 +90,7 @@ describe('sale updateDiscount()', () => { expect(error.message).toEqual(`The sales of this ticket can't be modified`); }); - it('should update the discount if the salesPerson has mana and manaType = "mana"', async() => { + it('should update the discount if the salesPerson has mana and manaCode = "mana"', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -108,9 +108,9 @@ describe('sale updateDiscount()', () => { const newDiscount = 100; const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options); const componentId = manaDiscount.id; - const manaType = 'mana'; + const manaCode = 'mana'; - await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options); + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options); const updatedSale = await models.Sale.findById(originalSaleId, null, options); const createdSaleComponent = await models.SaleComponent.findOne({ @@ -130,7 +130,7 @@ describe('sale updateDiscount()', () => { } }); - it('should update the discount if the salesPerson has mana and manaType = "mana claim"', async() => { + it('should update the discount if the salesPerson has mana and manaCode = "manaClaim"', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -146,11 +146,11 @@ describe('sale updateDiscount()', () => { const ticketId = 11; const sales = [originalSaleId]; const newDiscount = 100; - const manaDiscount = await models.Component.findOne({where: {code: 'mana claim'}}, options); + const manaDiscount = await models.Component.findOne({where: {code: 'manaClaim'}}, options); const componentId = manaDiscount.id; - const manaType = 'mana claim'; + const manaCode = 'manaClaim'; - await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options); + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options); const updatedSale = await models.Sale.findById(originalSaleId, null, options); const createdSaleComponent = await models.SaleComponent.findOne({ diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 9726dae1a3..b1291a45bf 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -25,7 +25,7 @@ module.exports = Self => { required: true }, { - arg: 'manaType', + arg: 'manaCode', description: 'The type of mana', type: 'string', required: false @@ -41,7 +41,7 @@ module.exports = Self => { } }); - Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaType, options) => { + Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaCode, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; const myOptions = {}; @@ -104,7 +104,7 @@ module.exports = Self => { }, fields: 'amount'}, myOptions); - const componentCode = usesMana ? manaType : 'buyerDiscount'; + const componentCode = usesMana ? manaCode : 'buyerDiscount'; const discountComponent = await models.Component.findOne({ where: {code: componentCode}}, myOptions); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 3643113bc0..18905f8590 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -292,12 +292,12 @@ + ng-model="$ctrl.manaCode"> + val="manaClaim" + ng-model="$ctrl.manaCode">
diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index b953db9c47..a60c9cb965 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -6,15 +6,15 @@ class Controller extends Section { constructor($element, $) { super($element, $); this._sales = []; - this.manaType = 'mana'; + this.manaCode = 'mana'; } - get manaType() { - return this._manaType; + get manaCode() { + return this._manaCode; } - set manaType(value) { - this._manaType = value; + set manaCode(value) { + this._manaCode = value; } get ticket() { @@ -290,7 +290,7 @@ class Controller extends Section { return sale.id; }); - const params = {salesIds: saleIds, newDiscount: this.edit.discount, manaType: this.manaType}; + const params = {salesIds: saleIds, newDiscount: this.edit.discount, manaCode: this.manaCode}; const query = `Tickets/${this.$params.id}/updateDiscount`; this.$http.post(query, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index a1088c0cce..fc4d1b4f36 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -63,14 +63,6 @@ describe('Ticket', () => { controller._sales = sales; })); - describe('manaType() setter/getter', () => { - it('should set the manaType data', () => { - controller.manaType = 'mana claim'; - - expect(controller.manaType).toEqual('mana claim'); - }); - }); - describe('ticket() setter', () => { it('should set the ticket data an then call the isTicketEditable() and isTicketLocked() methods', () => { jest.spyOn(controller, 'isTicketEditable').mockReturnThis(); @@ -456,7 +448,7 @@ describe('Ticket', () => { const expectedSales = [firstSelectedSale, secondSelectedSale]; const expectedSaleIds = [firstSelectedSale.id, secondSelectedSale.id]; - const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaType: 'mana'}; + const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaCode: 'mana'}; $httpBackend.expect('POST', `Tickets/1/updateDiscount`, expectedParams).respond(200, {discount: 10}); controller.updateDiscount(expectedSales); $httpBackend.flush(); @@ -743,15 +735,6 @@ describe('Ticket', () => { }); }); - describe('save()', () => { - it('should call changeDiscount()', () => { - jest.spyOn(controller, 'changeDiscount').mockReturnThis(); - controller.save(); - - expect(controller.changeDiscount).toHaveBeenCalledWith(); - }); - }); - describe('cancel()', () => { it('should call hide()', () => { jest.spyOn(controller.$.editDiscount, 'hide').mockReturnThis(); From a34876215345d88fdcce981302a1e20a3fffd35f Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 11 Apr 2022 09:09:05 +0200 Subject: [PATCH 23/23] refactor: pull request changes --- modules/worker/front/basic-data/index.html | 4 ---- modules/worker/front/basic-data/locale/es.yml | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index d49b7ab740..cbe6831852 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -30,7 +30,6 @@ rule>