diff --git a/db/changes/10440-fallas/00-claim_packages.sql b/db/changes/10440-fallas/00-claim_packages.sql index fa62fbec9b..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'; \ No newline at end of file +ALTER TABLE `vn`.`claim` ADD packages smallint(10) unsigned DEFAULT 0 NULL COMMENT 'packages received by the client'; diff --git a/db/changes/10451-april/00-ClientUnpaid.sql b/db/changes/10451-april/00-ClientUnpaid.sql new file mode 100644 index 0000000000..d84fe494a0 --- /dev/null +++ b/db/changes/10451-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/10451-april/delete-me.keep b/db/changes/10451-april/delete-me.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 4ed53ce603..799eb8fe70 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/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/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 8398a87453..293243470d 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": "icon-defaulter"} ] } ] @@ -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..a8ff643864 --- /dev/null +++ b/modules/client/front/unpaid/index.js @@ -0,0 +1,14 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + 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..bfeb7df193 --- /dev/null +++ b/modules/client/front/unpaid/index.spec.js @@ -0,0 +1,38 @@ +import './index'; + +describe('client unpaid', () => { + describe('Component vnClientUnpaid', () => { + let controller; + + beforeEach(ngModule('client')); + + beforeEach(inject($componentController => { + const $element = angular.element(''); + controller = $componentController('vnClientUnpaid', {$element}); + })); + + describe('setDefaultDate()', () => { + it(`should not set today date if has dated`, () => { + 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 dated`, () => { + const hasData = true; + + controller.clientUnpaid = {}; + controller.setDefaultDate(hasData); + + expect(controller.clientUnpaid.dated).toBeDefined(); + }); + }); + }); +}); 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