From b8a954caec01299a79b239f21f644141180fac5d Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 7 Apr 2022 11:41:35 +0200 Subject: [PATCH 1/4] feat(client): section unpaid --- db/changes/10440-fallas/00-claimConfig.sql | 2 +- db/changes/10440-fallas/00-claim_packages.sql | 2 +- db/changes/10450-april/00-ClientUnpaid.sql | 10 ++++ db/changes/10450-april/delete.keep | 0 loopback/locale/es.json | 3 +- modules/client/back/model-config.json | 3 ++ modules/client/back/models/client-unpaid.json | 28 ++++++++++ modules/client/front/index.js | 1 + modules/client/front/routes.json | 9 +++- modules/client/front/unpaid/index.html | 51 +++++++++++++++++++ modules/client/front/unpaid/index.js | 18 +++++++ modules/client/front/unpaid/index.spec.js | 39 ++++++++++++++ modules/client/front/unpaid/locale/es.yml | 1 + 13 files changed, 163 insertions(+), 4 deletions(-) create mode 100644 db/changes/10450-april/00-ClientUnpaid.sql delete mode 100644 db/changes/10450-april/delete.keep create mode 100644 modules/client/back/models/client-unpaid.json create mode 100644 modules/client/front/unpaid/index.html create mode 100644 modules/client/front/unpaid/index.js create mode 100644 modules/client/front/unpaid/index.spec.js create mode 100644 modules/client/front/unpaid/locale/es.yml diff --git a/db/changes/10440-fallas/00-claimConfig.sql b/db/changes/10440-fallas/00-claimConfig.sql index 905dea484f..89208dabd2 100644 --- a/db/changes/10440-fallas/00-claimConfig.sql +++ b/db/changes/10440-fallas/00-claimConfig.sql @@ -4,5 +4,5 @@ CREATE TABLE `vn`.`claimConfig` ( PRIMARY KEY (`id`) ); -INSERT INTO vn.claimConfig (id, pickupContact) +INSERT INTO `vn`.`claimConfig` (id, pickupContact) VALUES(1, 'Email: cmorenoa@logista.com Telf: 961594250 Extensión: 206'); \ No newline at end of file diff --git a/db/changes/10440-fallas/00-claim_packages.sql b/db/changes/10440-fallas/00-claim_packages.sql index 54e8ff3267..1ec11a8552 100644 --- a/db/changes/10440-fallas/00-claim_packages.sql +++ b/db/changes/10440-fallas/00-claim_packages.sql @@ -1 +1 @@ -ALTER TABLE vn.claim ADD packages smallint(10) unsigned DEFAULT 0 NULL COMMENT 'packages received by the client'; \ No newline at end of file +ALTER TABLE `vn`.`claim` ADD `packages` smallint(10) unsigned DEFAULT 0 NULL COMMENT 'packages received by the client'; \ No newline at end of file diff --git a/db/changes/10450-april/00-ClientUnpaid.sql b/db/changes/10450-april/00-ClientUnpaid.sql new file mode 100644 index 0000000000..d84fe494a0 --- /dev/null +++ b/db/changes/10450-april/00-ClientUnpaid.sql @@ -0,0 +1,10 @@ +CREATE TABLE `vn`.`clientUnpaid` ( + `clientFk` int(11) NOT NULL, + `dated` date NOT NULL, + `amount` double DEFAULT 0, + PRIMARY KEY (`clientFk`), + CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +); + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative'); \ No newline at end of file diff --git a/db/changes/10450-april/delete.keep b/db/changes/10450-april/delete.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9310ae436d..52917fd9e8 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -224,5 +224,6 @@ "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", "date in the future": "Fecha en el futuro", "reference duplicated": "Referencia duplicada", - "This ticket is already a refund": "Este ticket ya es un abono" + "This ticket is already a refund": "Este ticket ya es un abono", + "can't be set": "can't be set" } \ No newline at end of file diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index 38f5c94272..b6bf715b1b 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -44,6 +44,9 @@ "ClientType": { "dataSource": "vn" }, + "ClientUnpaid": { + "dataSource": "vn" + }, "Defaulter": { "dataSource": "vn" }, diff --git a/modules/client/back/models/client-unpaid.json b/modules/client/back/models/client-unpaid.json new file mode 100644 index 0000000000..a3d1a684c2 --- /dev/null +++ b/modules/client/back/models/client-unpaid.json @@ -0,0 +1,28 @@ +{ + "name": "ClientUnpaid", + "base": "VnModel", + "options": { + "mysql": { + "table": "clientUnpaid" + } + }, + "properties": { + "clientFk": { + "type": "number", + "id": true + }, + "dated": { + "type": "date" + }, + "amount": { + "type": "Number" + } + }, + "relations": { + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + } + } +} \ No newline at end of file diff --git a/modules/client/front/index.js b/modules/client/front/index.js index d9f3a8a177..ea732beea1 100644 --- a/modules/client/front/index.js +++ b/modules/client/front/index.js @@ -46,3 +46,4 @@ import './consumption'; import './consumption-search-panel'; import './defaulter'; import './notification'; +import './unpaid'; diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json index 8398a87453..6b5b03b35f 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -32,7 +32,8 @@ {"state": "client.card.creditInsurance.index", "icon": "icon-solunion"}, {"state": "client.card.contact", "icon": "contact_phone"}, {"state": "client.card.webPayment", "icon": "icon-onlinepayment"}, - {"state": "client.card.dms.index", "icon": "cloud_upload"} + {"state": "client.card.dms.index", "icon": "cloud_upload"}, + {"state": "client.card.unpaid", "icon": "contact_support"} ] } ] @@ -374,6 +375,12 @@ "state": "client.notification", "component": "vn-client-notification", "description": "Notifications" + }, { + "url": "/unpaid", + "state": "client.card.unpaid", + "component": "vn-client-unpaid", + "acl": ["administrative"], + "description": "Unpaid" } ] } diff --git a/modules/client/front/unpaid/index.html b/modules/client/front/unpaid/index.html new file mode 100644 index 0000000000..5f6edfe10c --- /dev/null +++ b/modules/client/front/unpaid/index.html @@ -0,0 +1,51 @@ +
+ + +
+ + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/client/front/unpaid/index.js b/modules/client/front/unpaid/index.js new file mode 100644 index 0000000000..082846426d --- /dev/null +++ b/modules/client/front/unpaid/index.js @@ -0,0 +1,18 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + constructor($, $element) { + super($, $element); + } + + setDefaultDate(hasData) { + if (hasData && !this.clientUnpaid.dated) + this.clientUnpaid.dated = new Date(); + } +} + +ngModule.vnComponent('vnClientUnpaid', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/client/front/unpaid/index.spec.js b/modules/client/front/unpaid/index.spec.js new file mode 100644 index 0000000000..d515f3e242 --- /dev/null +++ b/modules/client/front/unpaid/index.spec.js @@ -0,0 +1,39 @@ +import './index'; + +describe('client unpaid', () => { + describe('Component vnClientUnpaid', () => { + let controller; + + beforeEach(ngModule('client')); + + beforeEach(inject(($componentController, $rootScope) => { + const $element = angular.element(''); + controller = $componentController('vnClientUnpaid', {$element, $scope}); + })); + + describe('setDefaultDate()', () => { + it(`should not set today date if has data`, () => { + const hasData = true; + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + + controller.clientUnpaid = { + dated: yesterday + }; + controller.setDefaultDate(hasData); + + expect(controller.clientUnpaid.dated).toEqual(yesterday); + }); + + it(`should set today if not has data`, () => { + const hasData = false; + const today = new Date(); + + controller.clientUnpaid = {}; + controller.setDefaultDate(hasData); + + expect(controller.clientUnpaid.dated).toEqual(today); + }); + }); + }); +}); diff --git a/modules/client/front/unpaid/locale/es.yml b/modules/client/front/unpaid/locale/es.yml new file mode 100644 index 0000000000..d88764407b --- /dev/null +++ b/modules/client/front/unpaid/locale/es.yml @@ -0,0 +1 @@ +Unpaid client: Cliente impagado \ No newline at end of file From 574729b7c5e16acc683bdd5208443120cf512acf Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 7 Apr 2022 15:05:10 +0200 Subject: [PATCH 2/4] test(client_unpaid): add front test and e2e --- e2e/helpers/selectors.js | 6 ++++ e2e/paths/02-client/22_unpaid.spec.js | 41 +++++++++++++++++++++++ modules/client/front/locale/es.yml | 3 +- modules/client/front/routes.json | 2 +- modules/client/front/unpaid/index.js | 4 --- modules/client/front/unpaid/index.spec.js | 13 ++++--- 6 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 e2e/paths/02-client/22_unpaid.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 21ed271587..94eb4070e3 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -321,6 +321,12 @@ export default { deleteFirstPhone: 'vn-client-contact vn-icon[icon="delete"]', saveButton: 'button[type=submit]' }, + clientUnpaid: { + hasDataCheckBox: 'vn-client-unpaid vn-check[ng-model="watcher.hasData"]', + dated: 'vn-client-unpaid vn-date-picker[ng-model="$ctrl.clientUnpaid.dated"]', + amount: 'vn-client-unpaid vn-input-number[ng-model="$ctrl.clientUnpaid.amount"]', + saveButton: 'vn-submit[label="Save"]' + }, itemsIndex: { createItemButton: `vn-float-button`, firstSearchResult: 'vn-item-index tbody tr:nth-child(1)', diff --git a/e2e/paths/02-client/22_unpaid.spec.js b/e2e/paths/02-client/22_unpaid.spec.js new file mode 100644 index 0000000000..441dba96fd --- /dev/null +++ b/e2e/paths/02-client/22_unpaid.spec.js @@ -0,0 +1,41 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Client unpaid path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('administrative', 'client'); + await page.accessToSearchResult('Charles Xavier'); + await page.accessToSection('client.card.unpaid'); + await page.waitForState('client.card.unpaid'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should set cliet unpaid', async() => { + await page.waitToClick(selectors.clientUnpaid.hasDataCheckBox); + + await page.pickDate(selectors.clientUnpaid.dated); + await page.write(selectors.clientUnpaid.amount, '500'); + }); + + it('should save unpaid', async() => { + await page.waitToClick(selectors.clientUnpaid.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should confirm the unpaid have been saved', async() => { + await page.reloadSection('client.card.unpaid'); + const result = await page.waitToGetProperty(selectors.clientUnpaid.amount, 'value'); + + expect(result).toEqual('500'); + }); +}); diff --git a/modules/client/front/locale/es.yml b/modules/client/front/locale/es.yml index 107931377a..4eb99318c4 100644 --- a/modules/client/front/locale/es.yml +++ b/modules/client/front/locale/es.yml @@ -61,4 +61,5 @@ Log: Historial Consumption: Consumo Compensation Account: Cuenta para compensar Amount to return: Cantidad a devolver -Delivered amount: Cantidad entregada \ No newline at end of file +Delivered amount: Cantidad entregada +Unpaid: Impagado \ No newline at end of file diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json index 6b5b03b35f..293243470d 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -33,7 +33,7 @@ {"state": "client.card.contact", "icon": "contact_phone"}, {"state": "client.card.webPayment", "icon": "icon-onlinepayment"}, {"state": "client.card.dms.index", "icon": "cloud_upload"}, - {"state": "client.card.unpaid", "icon": "contact_support"} + {"state": "client.card.unpaid", "icon": "icon-defaulter"} ] } ] diff --git a/modules/client/front/unpaid/index.js b/modules/client/front/unpaid/index.js index 082846426d..a8ff643864 100644 --- a/modules/client/front/unpaid/index.js +++ b/modules/client/front/unpaid/index.js @@ -2,10 +2,6 @@ import ngModule from '../module'; import Section from 'salix/components/section'; export default class Controller extends Section { - constructor($, $element) { - super($, $element); - } - setDefaultDate(hasData) { if (hasData && !this.clientUnpaid.dated) this.clientUnpaid.dated = new Date(); diff --git a/modules/client/front/unpaid/index.spec.js b/modules/client/front/unpaid/index.spec.js index d515f3e242..bfeb7df193 100644 --- a/modules/client/front/unpaid/index.spec.js +++ b/modules/client/front/unpaid/index.spec.js @@ -6,13 +6,13 @@ describe('client unpaid', () => { beforeEach(ngModule('client')); - beforeEach(inject(($componentController, $rootScope) => { + beforeEach(inject($componentController => { const $element = angular.element(''); - controller = $componentController('vnClientUnpaid', {$element, $scope}); + controller = $componentController('vnClientUnpaid', {$element}); })); describe('setDefaultDate()', () => { - it(`should not set today date if has data`, () => { + it(`should not set today date if has dated`, () => { const hasData = true; const yesterday = new Date(); yesterday.setDate(yesterday.getDate() - 1); @@ -25,14 +25,13 @@ describe('client unpaid', () => { expect(controller.clientUnpaid.dated).toEqual(yesterday); }); - it(`should set today if not has data`, () => { - const hasData = false; - const today = new Date(); + it(`should set today if not has dated`, () => { + const hasData = true; controller.clientUnpaid = {}; controller.setDefaultDate(hasData); - expect(controller.clientUnpaid.dated).toEqual(today); + expect(controller.clientUnpaid.dated).toBeDefined(); }); }); }); From 88d91d8b4793c7f5e8ed8a06d00fa5ffc007ba87 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 13 Apr 2022 08:19:33 +0200 Subject: [PATCH 3/4] change db changes folder --- db/changes/10440-fallas/00-claimConfig.sql | 2 +- db/changes/10440-fallas/00-claim_packages.sql | 2 +- db/changes/{10450-april => 10451-april}/00-ClientUnpaid.sql | 0 db/changes/10451-april/delete-me.keep | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename db/changes/{10450-april => 10451-april}/00-ClientUnpaid.sql (100%) delete mode 100644 db/changes/10451-april/delete-me.keep diff --git a/db/changes/10440-fallas/00-claimConfig.sql b/db/changes/10440-fallas/00-claimConfig.sql index 89208dabd2..905dea484f 100644 --- a/db/changes/10440-fallas/00-claimConfig.sql +++ b/db/changes/10440-fallas/00-claimConfig.sql @@ -4,5 +4,5 @@ CREATE TABLE `vn`.`claimConfig` ( PRIMARY KEY (`id`) ); -INSERT INTO `vn`.`claimConfig` (id, pickupContact) +INSERT INTO vn.claimConfig (id, pickupContact) VALUES(1, 'Email: cmorenoa@logista.com Telf: 961594250 Extensión: 206'); \ No newline at end of file diff --git a/db/changes/10440-fallas/00-claim_packages.sql b/db/changes/10440-fallas/00-claim_packages.sql index de23000b66..3d82eb7b6a 100644 --- a/db/changes/10440-fallas/00-claim_packages.sql +++ b/db/changes/10440-fallas/00-claim_packages.sql @@ -1 +1 @@ -ALTER TABLE `vn`.`claim` ADD `packages` smallint(10) unsigned DEFAULT 0 NULL COMMENT 'packages received by the client'; +ALTER TABLE `vn`.`claim` ADD packages smallint(10) unsigned DEFAULT 0 NULL COMMENT 'packages received by the client'; diff --git a/db/changes/10450-april/00-ClientUnpaid.sql b/db/changes/10451-april/00-ClientUnpaid.sql similarity index 100% rename from db/changes/10450-april/00-ClientUnpaid.sql rename to db/changes/10451-april/00-ClientUnpaid.sql diff --git a/db/changes/10451-april/delete-me.keep b/db/changes/10451-april/delete-me.keep deleted file mode 100644 index e69de29bb2..0000000000 From 32a065c07a883960c75742cae1d155248c14f8ef Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 13 Apr 2022 08:21:00 +0200 Subject: [PATCH 4/4] drop unnecessary locale --- loopback/locale/es.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 52917fd9e8..9310ae436d 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -224,6 +224,5 @@ "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", "date in the future": "Fecha en el futuro", "reference duplicated": "Referencia duplicada", - "This ticket is already a refund": "Este ticket ya es un abono", - "can't be set": "can't be set" + "This ticket is already a refund": "Este ticket ya es un abono" } \ No newline at end of file