From b2dd9e607618818dee53fe2700ba76743e1bc4c4 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 2 Nov 2021 07:55:35 +0100 Subject: [PATCH 01/16] feat(zone): filter calendar --- .../back/methods/zone/getEventsFiltered.js | 21 +++++++++++++ modules/zone/back/models/zone.js | 1 + modules/zone/front/events/index.js | 30 +++++++++---------- 3 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 modules/zone/back/methods/zone/getEventsFiltered.js diff --git a/modules/zone/back/methods/zone/getEventsFiltered.js b/modules/zone/back/methods/zone/getEventsFiltered.js new file mode 100644 index 000000000..ea339d88f --- /dev/null +++ b/modules/zone/back/methods/zone/getEventsFiltered.js @@ -0,0 +1,21 @@ +module.exports = Self => { + Self.remoteMethodCtx('getEventsFiltered', { + description: 'Get events filtered for zone and date', + accessType: 'READ', + returns: { + type: 'object', + root: true + }, + http: { + path: `/getEventsFiltered`, + verb: 'GET' + } + }); + + Self.getEventsFiltered = async(zoneFk, started, ended) => { + query = `CALL vn.zone_getEventsFiltered(?,?,?)`; + const [events, exclusions] = await Self.rawSql(query, [zoneFk, started, ended]); + console.log(events); + return {events, exclusions}; + }; +}; diff --git a/modules/zone/back/models/zone.js b/modules/zone/back/models/zone.js index 0b1b9d106..9771c958b 100644 --- a/modules/zone/back/models/zone.js +++ b/modules/zone/back/models/zone.js @@ -2,6 +2,7 @@ module.exports = Self => { require('../methods/zone/clone')(Self); require('../methods/zone/getLeaves')(Self); require('../methods/zone/getEvents')(Self); + require('../methods/zone/getEventsFiltered')(Self); require('../methods/zone/toggleIsIncluded')(Self); require('../methods/zone/getUpcomingDeliveries')(Self); require('../methods/zone/deleteZone')(Self); diff --git a/modules/zone/front/events/index.js b/modules/zone/front/events/index.js index 29b534c0c..e10c1c6f1 100644 --- a/modules/zone/front/events/index.js +++ b/modules/zone/front/events/index.js @@ -12,22 +12,22 @@ class Controller extends Section { this.refresh(); } - get path() { - return `Zones/${this.$params.id}/events`; - } - - get exclusionsPath() { - return `Zones/${this.$params.id}/exclusions`; - } - refresh() { - let data = {}; - this.$q.all([ - this.$http.get(this.path) - .then(res => data.events = res.data), - this.$http.get(this.exclusionsPath) - .then(res => data.exclusions = res.data) - ]).finally(() => { + this.$.data = null; + let params = { + ended: '2022-01-31', + started: '2021-10-01', + zoneFk: 10 + }; + let ended = '2022-01-31'; + let started = '2021-10-01'; + let zoneFk = 10; + // let filter = encodeURIComponent(JSON.stringify(params)); + let path = `Zones/getEventsFiltered?zoneFk=${zoneFk}&started=${started}&ended=${ended}`; + console.log(path); + this.$http.get(path).then(res => { + console.log(res.data); + let data = res.data; this.$.data = data; }); } From 3324f4acd2a7c49359591cb774cd55e5a6c493c8 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 4 Nov 2021 07:56:12 +0100 Subject: [PATCH 02/16] fix(zone): back remoteMethod --- .../back/methods/zone/getEventsFiltered.js | 47 +++++++++++++++++-- modules/zone/front/events/index.js | 24 +++++----- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/modules/zone/back/methods/zone/getEventsFiltered.js b/modules/zone/back/methods/zone/getEventsFiltered.js index ea339d88f..76a9e8fb3 100644 --- a/modules/zone/back/methods/zone/getEventsFiltered.js +++ b/modules/zone/back/methods/zone/getEventsFiltered.js @@ -1,7 +1,24 @@ module.exports = Self => { - Self.remoteMethodCtx('getEventsFiltered', { + Self.remoteMethod('getEventsFiltered', { description: 'Get events filtered for zone and date', - accessType: 'READ', + accepts: [ + { + arg: 'zoneFk', + type: 'number', + description: 'The zone id', + required: true + }, + { + arg: 'started', + type: 'date', + description: 'The date calendar start', + }, + { + arg: 'ended', + type: 'date', + description: 'The date calendar end', + } + ], returns: { type: 'object', root: true @@ -13,9 +30,29 @@ module.exports = Self => { }); Self.getEventsFiltered = async(zoneFk, started, ended) => { - query = `CALL vn.zone_getEventsFiltered(?,?,?)`; - const [events, exclusions] = await Self.rawSql(query, [zoneFk, started, ended]); - console.log(events); + query = ` + SELECT * + FROM vn.zoneEvent + WHERE zoneFk = ? + AND ((type = 'indefinitely') + OR (type = 'day' AND dated BETWEEN ? AND ?) + OR (type = 'range' + AND ( + (started BETWEEN ? AND ?) + OR (ended BETWEEN ? AND ?) + ) + ) + ) + ORDER BY type='indefinitely',type='range',type='day';`; + const events = await Self.rawSql(query, [zoneFk, started, ended, started, ended, started, ended]); + + query = ` + SELECT * + FROM vn.zoneExclusion + WHERE zoneFk = ? + AND dated BETWEEN ? AND ?;`; + const exclusions = await Self.rawSql(query, [zoneFk, started, ended]); + return {events, exclusions}; }; }; diff --git a/modules/zone/front/events/index.js b/modules/zone/front/events/index.js index e10c1c6f1..c9430474f 100644 --- a/modules/zone/front/events/index.js +++ b/modules/zone/front/events/index.js @@ -12,21 +12,23 @@ class Controller extends Section { this.refresh(); } + get path() { + return `Zones/${this.$params.id}/events`; + } + + get exclusionsPath() { + return `Zones/${this.$params.id}/exclusions`; + } + refresh() { this.$.data = null; let params = { - ended: '2022-01-31', - started: '2021-10-01', - zoneFk: 10 + zoneFk: 10, + started: new Date('2021-10-01'), + ended: new Date('2022-02-31') }; - let ended = '2022-01-31'; - let started = '2021-10-01'; - let zoneFk = 10; - // let filter = encodeURIComponent(JSON.stringify(params)); - let path = `Zones/getEventsFiltered?zoneFk=${zoneFk}&started=${started}&ended=${ended}`; - console.log(path); - this.$http.get(path).then(res => { - console.log(res.data); + + this.$http.get(`Zones/getEventsFiltered`, {params}).then(res => { let data = res.data; this.$.data = data; }); From fbbb1ecdf62a58837ee81d4ac14e7f808b731272 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 8 Nov 2021 08:59:42 +0100 Subject: [PATCH 03/16] feat(client_balance): add maxImport if "cash" --- back/models/accounting-type.json | 3 +++ modules/client/front/balance/create/index.html | 3 ++- modules/client/front/balance/create/index.js | 11 ++++++++++- modules/client/front/balance/create/locale/es.yml | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/back/models/accounting-type.json b/back/models/accounting-type.json index c2bf977b2..be08ac533 100644 --- a/back/models/accounting-type.json +++ b/back/models/accounting-type.json @@ -25,6 +25,9 @@ }, "isAutoConciliated": { "type": "boolean" + }, + "maxAmount": { + "type": "number" } }, "acls": [{ diff --git a/modules/client/front/balance/create/index.html b/modules/client/front/balance/create/index.html index f9bf89b04..56e505463 100644 --- a/modules/client/front/balance/create/index.html +++ b/modules/client/front/balance/create/index.html @@ -44,7 +44,8 @@ label="Amount" ng-model="$ctrl.amountPaid" step="0.01" - required="true"> + required="true" + max="$ctrl.maxAmount"> diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 5b5866732..b9716db18 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -61,8 +61,14 @@ class Controller extends Dialog { if (value) { const accountingType = value.accountingType; - this.receipt.description = + if (this.originalDescription) { + this.receipt.description = `${accountingType && accountingType.receiptDescription}, ${this.originalDescription}`; + } else { + this.receipt.description = + `${accountingType && accountingType.receiptDescription}`; + } + this.maxAmount = accountingType && accountingType.maxAmount; } } @@ -123,6 +129,9 @@ class Controller extends Dialog { if (response !== 'accept') return super.responseHandler(response); + if (this.bankSelection.accountingType.code == 'cash' && this.receipt.amountPaid > this.maxAmount) + return this.vnApp.showError(this.$t('Amount exceeded', {maxAmount: this.maxAmount})); + let receiptId; return this.$http.post(`Clients/${this.clientFk}/createReceipt`, this.receipt) .then(res => { diff --git a/modules/client/front/balance/create/locale/es.yml b/modules/client/front/balance/create/locale/es.yml index 266e4365c..056590966 100644 --- a/modules/client/front/balance/create/locale/es.yml +++ b/modules/client/front/balance/create/locale/es.yml @@ -1 +1,2 @@ -View receipt: Ver recibo \ No newline at end of file +View receipt: Ver recibo +Amount exceeded: Según ley contra el fraude no se puede recibir cobros por importe igual o superior a {{maxAmount}} \ No newline at end of file From 000ae21ce5e6053516ba9a732dae288c68ddaa6a Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 8 Nov 2021 09:16:27 +0100 Subject: [PATCH 04/16] create colum sql --- db/changes/10370-pickles/00-accountingType.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/changes/10370-pickles/00-accountingType.sql diff --git a/db/changes/10370-pickles/00-accountingType.sql b/db/changes/10370-pickles/00-accountingType.sql new file mode 100644 index 000000000..79331ce92 --- /dev/null +++ b/db/changes/10370-pickles/00-accountingType.sql @@ -0,0 +1,5 @@ +ALTER TABLE vn.accountingType ADD maxAmount INT DEFAULT NULL NULL; + +UPDATE vn.accountingType + SET maxAmount = 1000 + WHERE code = 'cash'; From 6e2f7d9e0dc7563f0e0573241200419085b7552d Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 8 Nov 2021 11:30:00 +0100 Subject: [PATCH 05/16] feat(events): get range date of calendar --- .../back/methods/zone/getEventsFiltered.js | 2 +- modules/zone/front/events/index.html | 1 + modules/zone/front/events/index.js | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/zone/back/methods/zone/getEventsFiltered.js b/modules/zone/back/methods/zone/getEventsFiltered.js index 76a9e8fb3..aa3cd8b75 100644 --- a/modules/zone/back/methods/zone/getEventsFiltered.js +++ b/modules/zone/back/methods/zone/getEventsFiltered.js @@ -43,7 +43,7 @@ module.exports = Self => { ) ) ) - ORDER BY type='indefinitely',type='range',type='day';`; + ORDER BY type='indefinitely' DESC, type='range' DESC, type='day' DESC;`; const events = await Self.rawSql(query, [zoneFk, started, ended, started, ended, started, ended]); query = ` diff --git a/modules/zone/front/events/index.html b/modules/zone/front/events/index.html index d48b5f0d8..25ec2827f 100644 --- a/modules/zone/front/events/index.html +++ b/modules/zone/front/events/index.html @@ -1,5 +1,6 @@ diff --git a/modules/zone/front/events/index.js b/modules/zone/front/events/index.js index c9430474f..0df16a42a 100644 --- a/modules/zone/front/events/index.js +++ b/modules/zone/front/events/index.js @@ -22,15 +22,17 @@ class Controller extends Section { refresh() { this.$.data = null; - let params = { - zoneFk: 10, - started: new Date('2021-10-01'), - ended: new Date('2022-02-31') - }; + this.$.$applyAsync(() => { + const params = { + zoneFk: this.$params.id, + started: this.$.calendar.firstDay, + ended: this.$.calendar.lastDay + }; - this.$http.get(`Zones/getEventsFiltered`, {params}).then(res => { - let data = res.data; - this.$.data = data; + this.$http.get(`Zones/getEventsFiltered`, {params}).then(res => { + const data = res.data; + this.$.data = data; + }); }); } From bfbc9b50c4ee339c65ad4582a9f1bb8b5e110974 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 8 Nov 2021 13:02:42 +0100 Subject: [PATCH 06/16] feat(client_balance): add maxImport if "cash" --- db/dump/fixtures.sql | 18 +++++++++--------- db/dump/structure.sql | 1 + .../client/front/balance/create/index.spec.js | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 4c82be909..6bcda3f4c 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -154,16 +154,16 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park ('GVC', '1', '0', '1', '0', '1106'), ('HEJ', '2', '0', '1', '0', '1106'); -INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`) +INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`) VALUES - (1, 'CC y Polizas de crédito', NULL, NULL), - (2, 'Cash', 'Cash', 'cash'), - (3, 'Credit card', 'Credit Card', 'creditCard'), - (4, 'Finalcial lines', NULL, NULL), - (5, 'Other products', NULL, NULL), - (6, 'Loans', NULL, NULL), - (7, 'Leasing', NULL, NULL), - (8, 'Compensations', 'Compensations', 'compensation'); + (1, 'CC y Polizas de crédito', NULL, NULL, NULL), + (2, 'Cash', 'Cash', 'cash', 1000), + (3, 'Credit card', 'Credit Card', 'creditCard', NULL), + (4, 'Finalcial lines', NULL, NULL, NULL), + (5, 'Other products', NULL, NULL, NULL), + (6, 'Loans', NULL, NULL, NULL), + (7, 'Leasing', NULL, NULL, NULL), + (8, 'Compensations', 'Compensations', 'compensation', NULL); INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) VALUES diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 734a926d1..338e88d97 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -24922,6 +24922,7 @@ CREATE TABLE `accountingType` ( `receiptDescription` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Descripción por defecto al crear nuevo recibo', `code` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `isAutoConciliated` tinyint(1) DEFAULT '1' COMMENT 'Si hay que marcar como conciliado el recibo al usar este tipo', + `maxAmount` int(11) DEFAULT NULL COMMENT 'Importe máximo', PRIMARY KEY (`id`), KEY `accountingType_code_IDX` (`code`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='descripcio dels valors de la columna "cash" de la taula vn2008.Bancios'; diff --git a/modules/client/front/balance/create/index.spec.js b/modules/client/front/balance/create/index.spec.js index a2e3e2015..77fe32e0f 100644 --- a/modules/client/front/balance/create/index.spec.js +++ b/modules/client/front/balance/create/index.spec.js @@ -23,6 +23,7 @@ describe('Client', () => { clientFk: 1101, companyFk: 442 }; + controller.bankSelection = {accountingType: {code: 'myCode'}}; })); describe('bankSelection() setter', () => { From 9e4627617d9907418f75515a51306c55f460e469 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 8 Nov 2021 14:08:44 +0100 Subject: [PATCH 07/16] fix(time-control): modify select & refactor dates --- .../back/methods/worker/getWorkedHours.js | 18 ++++++------------ modules/worker/front/time-control/index.js | 6 ++++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/worker/back/methods/worker/getWorkedHours.js b/modules/worker/back/methods/worker/getWorkedHours.js index 9957fca25..44f3eca3a 100644 --- a/modules/worker/back/methods/worker/getWorkedHours.js +++ b/modules/worker/back/methods/worker/getWorkedHours.js @@ -42,27 +42,21 @@ module.exports = Self => { const stmts = []; - const startedMinusOne = new Date(started); - startedMinusOne.setDate(started.getDate() - 1); - - const endedPlusOne = new Date(ended); - endedPlusOne.setDate(ended.getDate() + 1); - stmts.push(` DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate, tmp.timeBusinessCalculate `); - stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne])); + stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, started, ended])); - stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne])); + stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, started, ended])); const resultIndex = stmts.push(new ParameterizedSQL(` - SELECT tbc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours - FROM tmp.timeBusinessCalculate tbc - LEFT JOIN tmp.timeControlCalculate tcc ON tcc.dated = tbc.dated - WHERE tbc.dated BETWEEN ? AND ? + SELECT tcc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours + FROM tmp.timeControlCalculate tcc + LEFT JOIN tmp.timeBusinessCalculate tbc ON tcc.dated = tbc.dated + WHERE tcc.dated BETWEEN DATE(?) AND DATE(?) `, [started, ended])) - 1; stmts.push(` diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 0fb5f9dbe..4c0793933 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -171,10 +171,11 @@ class Controller extends Section { from: from, to: to }; - + console.log(from, to); const query = `Workers/${this.$params.id}/getWorkedHours`; return this.$http.get(query, {params}).then(res => { const workDays = res.data; + console.log(res.data); const map = new Map(); for (const workDay of workDays) { @@ -212,7 +213,8 @@ class Controller extends Section { let todayInWeek = this.weekDays.find(day => day.dated.getTime() === today.getTime()); if (todayInWeek && todayInWeek.hours && todayInWeek.hours.length) { - const remainingTime = todayInWeek.workedHours ? ((todayInWeek.expectedHours - todayInWeek.workedHours) * 1000) : null; + const remainingTime = todayInWeek.workedHours ? + ((todayInWeek.expectedHours - todayInWeek.workedHours) * 1000) : null; const lastKnownEntry = todayInWeek.hours[todayInWeek.hours.length - 1]; const lastKnownTime = new Date(lastKnownEntry.timed).getTime(); const finishTimeStamp = lastKnownTime && remainingTime ? lastKnownTime + remainingTime : null; From 9ab51fc21f56697da34fdf2d7da2f892e6ef0567 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 9 Nov 2021 08:39:20 +0100 Subject: [PATCH 08/16] feat(eventsFiltered): add backTest & refactor zone --- .../back/methods/zone/getEventsFiltered.js | 11 +++++++--- .../back/methods/zone/specs/clone.spec.js | 6 ++--- .../methods/zone/specs/deleteZone.spec.js | 16 +++++++------- .../back/methods/zone/specs/getEvents.spec.js | 6 ++--- .../zone/specs/getEventsFiltered.spec.js | 21 ++++++++++++++++++ .../back/methods/zone/specs/getLeaves.spec.js | 6 ++--- .../zone/specs/includingExpired.spec.js | 14 ++++++------ .../zone/specs/toggleIsIncluded.spec.js | 16 +++++++------- modules/zone/front/events/index.spec.js | 22 +++++++++++++++++-- 9 files changed, 81 insertions(+), 37 deletions(-) create mode 100644 modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js diff --git a/modules/zone/back/methods/zone/getEventsFiltered.js b/modules/zone/back/methods/zone/getEventsFiltered.js index aa3cd8b75..2788f45d0 100644 --- a/modules/zone/back/methods/zone/getEventsFiltered.js +++ b/modules/zone/back/methods/zone/getEventsFiltered.js @@ -29,7 +29,12 @@ module.exports = Self => { } }); - Self.getEventsFiltered = async(zoneFk, started, ended) => { + Self.getEventsFiltered = async(zoneFk, started, ended, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + query = ` SELECT * FROM vn.zoneEvent @@ -44,14 +49,14 @@ module.exports = Self => { ) ) ORDER BY type='indefinitely' DESC, type='range' DESC, type='day' DESC;`; - const events = await Self.rawSql(query, [zoneFk, started, ended, started, ended, started, ended]); + const events = await Self.rawSql(query, [zoneFk, started, ended, started, ended, started, ended], myOptions); query = ` SELECT * FROM vn.zoneExclusion WHERE zoneFk = ? AND dated BETWEEN ? AND ?;`; - const exclusions = await Self.rawSql(query, [zoneFk, started, ended]); + const exclusions = await Self.rawSql(query, [zoneFk, started, ended], myOptions); return {events, exclusions}; }; diff --git a/modules/zone/back/methods/zone/specs/clone.spec.js b/modules/zone/back/methods/zone/specs/clone.spec.js index 1ede5feb7..92392d789 100644 --- a/modules/zone/back/methods/zone/specs/clone.spec.js +++ b/modules/zone/back/methods/zone/specs/clone.spec.js @@ -1,12 +1,12 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('agency clone()', () => { it('should clone a zone', async() => { - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - const newZone = await app.models.Zone.clone(1, options); + const newZone = await models.Zone.clone(1, options); expect(newZone.name).toEqual('Zone pickup A'); diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index d8abe1da8..968685fec 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -1,4 +1,4 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('zone deletezone()', () => { @@ -16,13 +16,13 @@ describe('zone deletezone()', () => { active: activeCtx }); try { - const originalTickets = await app.models.Ticket.find({ + const originalTickets = await models.Ticket.find({ where: { zoneFk: zoneId } }); ticketIDs = originalTickets.map(ticket => ticket.id); - originalTicketStates = await app.models.TicketState.find({where: { + originalTicketStates = await models.TicketState.find({where: { ticketFk: {inq: ticketIDs}, code: 'FIXING'}}); } catch (error) { @@ -31,16 +31,16 @@ describe('zone deletezone()', () => { }); it('should delete a zone and update their tickets', async() => { - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - await app.models.Zone.deleteZone(ctx, zoneId, options); + await models.Zone.deleteZone(ctx, zoneId, options); - const updatedZone = await app.models.Zone.findById(zoneId, null, options); - const anUpdatedTicket = await app.models.Ticket.findById(ticketIDs[0], null, options); + const updatedZone = await models.Zone.findById(zoneId, null, options); + const anUpdatedTicket = await models.Ticket.findById(ticketIDs[0], null, options); - const updatedTicketStates = await app.models.TicketState.find({ + const updatedTicketStates = await models.TicketState.find({ where: { ticketFk: {inq: ticketIDs}, code: 'FIXING' diff --git a/modules/zone/back/methods/zone/specs/getEvents.spec.js b/modules/zone/back/methods/zone/specs/getEvents.spec.js index 4227908bb..d1c51baff 100644 --- a/modules/zone/back/methods/zone/specs/getEvents.spec.js +++ b/modules/zone/back/methods/zone/specs/getEvents.spec.js @@ -1,13 +1,13 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('zone getEvents()', () => { it('should return all events for the specified geo and agency mode', async() => { - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await app.models.Zone.getEvents(20, 1, options); + let result = await models.Zone.getEvents(20, 1, options); expect(result.events.length).toEqual(10); diff --git a/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js b/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js new file mode 100644 index 000000000..ffa416282 --- /dev/null +++ b/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js @@ -0,0 +1,21 @@ +const models = require('vn-loopback/server/server').models; + +describe('zone getEventsFiltered()', () => { + it('should return events and exclusions for the specified zoneFk in a range of dates', async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + + let result = await models.Zone.getEventsFiltered(10, '2021-10-01', '2021-10-02', options); + + expect(result.events.length).toEqual(1); + expect(result.exclusions.length).toEqual(0); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/zone/back/methods/zone/specs/getLeaves.spec.js b/modules/zone/back/methods/zone/specs/getLeaves.spec.js index 853962cc4..db7359671 100644 --- a/modules/zone/back/methods/zone/specs/getLeaves.spec.js +++ b/modules/zone/back/methods/zone/specs/getLeaves.spec.js @@ -1,13 +1,13 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('zone getLeaves()', () => { it('should return the country and the childs containing the search value', async() => { - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await app.models.Zone.getLeaves(1, null, '46000', options); + let result = await models.Zone.getLeaves(1, null, '46000', options); expect(result.length).toEqual(1); diff --git a/modules/zone/back/methods/zone/specs/includingExpired.spec.js b/modules/zone/back/methods/zone/specs/includingExpired.spec.js index ea28727f4..98fdc272d 100644 --- a/modules/zone/back/methods/zone/specs/includingExpired.spec.js +++ b/modules/zone/back/methods/zone/specs/includingExpired.spec.js @@ -1,4 +1,4 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('zone includingExpired()', () => { const inhousePickupId = 1; @@ -6,14 +6,14 @@ describe('zone includingExpired()', () => { const warehouseId = 1; it('should return an array containing all zones', async() => { - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); const ctx = {req: {accessToken: {userId: 1}}}; const where = {}; try { const options = {transaction: tx}; - const result = await app.models.Zone.includingExpired(ctx, {where}, options); + const result = await models.Zone.includingExpired(ctx, {where}, options); expect(result.length).toBeGreaterThan(2); @@ -28,12 +28,12 @@ describe('zone includingExpired()', () => { const ctx = {req: {accessToken: {userId: 1}}}; const where = {agencyModeFk: inhousePickupId}; - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - const result = await app.models.Zone.includingExpired(ctx, {where}, options); + const result = await models.Zone.includingExpired(ctx, {where}, options); const validAgency = result.every(zone => zone.agencyModeFk = inhousePickupId); @@ -56,12 +56,12 @@ describe('zone includingExpired()', () => { warehouseFk: warehouseId }; - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - const result = await app.models.Zone.includingExpired(ctx, {where}, options); + const result = await models.Zone.includingExpired(ctx, {where}, options); const firstZone = result[0]; expect(firstZone.name).toEqual('Zone pickup A'); diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index 5fe948747..562e62f5f 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -1,13 +1,13 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('zone toggleIsIncluded()', () => { it('should return the created location with isIncluded true', async() => { - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await app.models.Zone.toggleIsIncluded(1, 20, true, options); + let result = await models.Zone.toggleIsIncluded(1, 20, true, options); expect(result.isIncluded).toBeTrue(); @@ -19,12 +19,12 @@ describe('zone toggleIsIncluded()', () => { }); it('should return the created location with isIncluded false', async() => { - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await app.models.Zone.toggleIsIncluded(1, 20, false, options); + let result = await models.Zone.toggleIsIncluded(1, 20, false, options); expect(result.isIncluded).toBeFalse(); @@ -36,14 +36,14 @@ describe('zone toggleIsIncluded()', () => { }); it('should return the amount of deleted locations', async() => { - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - await app.models.Zone.toggleIsIncluded(1, 20, false, options); + await models.Zone.toggleIsIncluded(1, 20, false, options); - let result = await app.models.Zone.toggleIsIncluded(1, 20, undefined, options); + let result = await models.Zone.toggleIsIncluded(1, 20, undefined, options); expect(result).toEqual({count: 1}); diff --git a/modules/zone/front/events/index.spec.js b/modules/zone/front/events/index.spec.js index c1b0d78b3..bdb7f36a6 100644 --- a/modules/zone/front/events/index.spec.js +++ b/modules/zone/front/events/index.spec.js @@ -17,8 +17,26 @@ describe('component vnZoneEvents', () => { describe('refresh()', () => { it('should set the zone and then call both getSummary() and getWarehouses()', () => { - $httpBackend.expectGET(`Zones/1/events`).respond({id: 1}); - $httpBackend.expectGET(`Zones/1/exclusions`).respond({id: 1}); + const now = '2021-10-01'; + + controller.$params.id = 999; + controller.$.calendar = { + firstDay: now, + lastDay: now + }; + + const params = { + zoneFk: controller.$params.id, + started: now, + ended: now + }; + + const query = `Zones/getEventsFiltered?ended=${now}&started=${now}&zoneFk=${params.zoneFk}`; + const response = { + events: 'myEvents', + exclusions: 'myExclusions' + }; + $httpBackend.whenGET(query).respond(response); controller.refresh(); $httpBackend.flush(); From da80fee0e291a1bddc864a13ac635866fabaaf4d Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 9 Nov 2021 10:09:44 +0100 Subject: [PATCH 09/16] refactor(time-control): getWorkedHours.spec --- .../back/methods/worker/specs/getWorkedHours.spec.js | 12 ++++++------ modules/worker/front/time-control/index.js | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js index c06ff8502..3132a9003 100644 --- a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js +++ b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js @@ -1,17 +1,17 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('Worker getWorkedHours()', () => { it(`should return the expected hours and the worked hours of a given date`, async() => { const workerID = 1106; - let started = new Date(); + const started = new Date(); started.setHours(0, 0, 0, 0); - let ended = new Date(); - ended.setHours(0, 0, 0, 0); + const ended = new Date(); + ended.setHours(23, 59, 59, 999); - const [result] = await app.models.Worker.getWorkedHours(workerID, started, ended); + const [result] = await models.Worker.getWorkedHours(workerID, started, ended); - expect(result.expectedHours).toEqual(28800); // 8:00 hours seconds + expect(result.expectedHours).toEqual(28800); // 8:00 hours in seconds expect(result.workedHours).toEqual(29400); // 8:10 hours in seconds }); }); diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 4c0793933..96913c505 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -171,11 +171,9 @@ class Controller extends Section { from: from, to: to }; - console.log(from, to); const query = `Workers/${this.$params.id}/getWorkedHours`; return this.$http.get(query, {params}).then(res => { const workDays = res.data; - console.log(res.data); const map = new Map(); for (const workDay of workDays) { From 0aa0358b50cba6a5cf2c6bbe35ecc34eaa32426f Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 9 Nov 2021 10:21:28 +0100 Subject: [PATCH 10/16] refactor(events): name of variable --- modules/zone/front/events/index.spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/zone/front/events/index.spec.js b/modules/zone/front/events/index.spec.js index bdb7f36a6..ed2c91c31 100644 --- a/modules/zone/front/events/index.spec.js +++ b/modules/zone/front/events/index.spec.js @@ -17,21 +17,21 @@ describe('component vnZoneEvents', () => { describe('refresh()', () => { it('should set the zone and then call both getSummary() and getWarehouses()', () => { - const now = '2021-10-01'; + const date = '2021-10-01'; controller.$params.id = 999; controller.$.calendar = { - firstDay: now, - lastDay: now + firstDay: date, + lastDay: date }; const params = { zoneFk: controller.$params.id, - started: now, - ended: now + started: date, + ended: date }; - const query = `Zones/getEventsFiltered?ended=${now}&started=${now}&zoneFk=${params.zoneFk}`; + const query = `Zones/getEventsFiltered?ended=${date}&started=${date}&zoneFk=${params.zoneFk}`; const response = { events: 'myEvents', exclusions: 'myExclusions' From f5977d9f01558b1fa11db84c21ac0ef866a9546f Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 9 Nov 2021 14:35:34 +0100 Subject: [PATCH 11/16] delete maxAmount from structure.sql --- db/changes/10370-pickles/00-accountingType.sql | 4 +--- db/dump/fixtures.sql | 2 +- db/dump/structure.sql | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/db/changes/10370-pickles/00-accountingType.sql b/db/changes/10370-pickles/00-accountingType.sql index 79331ce92..1313e8223 100644 --- a/db/changes/10370-pickles/00-accountingType.sql +++ b/db/changes/10370-pickles/00-accountingType.sql @@ -1,5 +1,3 @@ ALTER TABLE vn.accountingType ADD maxAmount INT DEFAULT NULL NULL; -UPDATE vn.accountingType - SET maxAmount = 1000 - WHERE code = 'cash'; +UPDATE vn.accountingType SET maxAmount = 1000 WHERE code = 'cash'; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 6bcda3f4c..5b8715e13 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -7,7 +7,7 @@ ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) - VALUES + VALUES ('TOTALLY_SECURE_TOKEN', '1209600', CURDATE(), 66); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 3f554f22d..3ab1d5608 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -24510,7 +24510,6 @@ CREATE TABLE `accountingType` ( `receiptDescription` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Descripción por defecto al crear nuevo recibo', `code` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `isAutoConciliated` tinyint(1) DEFAULT '1' COMMENT 'Si hay que marcar como conciliado el recibo al usar este tipo', - `maxAmount` int(11) DEFAULT NULL COMMENT 'Importe máximo', PRIMARY KEY (`id`), KEY `accountingType_code_IDX` (`code`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='descripcio dels valors de la columna "cash" de la taula vn2008.Bancios'; From 833822978a3c6089a0fdbf5708a1a1377cb14d65 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 9 Nov 2021 14:36:39 +0100 Subject: [PATCH 12/16] feat(client_balance): test e2e --- e2e/paths/02-client/14_balance.spec.js | 13 +++++++++++++ modules/client/front/balance/create/index.js | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index d408215ff..89762ff8a 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -98,6 +98,19 @@ describe('Client balance path', () => { expect(message.text).toContain('Data saved!'); }); + it('should create a new payment and check the cash exceeded the maximum', async() => { + const amountPaid = '1001'; + + await page.waitToClick(selectors.clientBalance.newPaymentButton); + await page.write(selectors.clientBalance.newPaymentAmount, amountPaid); + await page.clearInput(selectors.clientBalance.newDescription); + await page.write(selectors.clientBalance.newDescription, 'Payment'); + await page.waitToClick(selectors.clientBalance.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Amount exceeded'); + }); + it('should check the balance value is now -100', async() => { let result = await page .waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText'); diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index b9716db18..d306c6f84 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -129,7 +129,9 @@ class Controller extends Dialog { if (response !== 'accept') return super.responseHandler(response); - if (this.bankSelection.accountingType.code == 'cash' && this.receipt.amountPaid > this.maxAmount) + const exceededAmount = this.receipt.amountPaid > this.maxAmount; + + if (this.bankSelection.accountingType.code == 'cash' && exceededAmount) return this.vnApp.showError(this.$t('Amount exceeded', {maxAmount: this.maxAmount})); let receiptId; From 119d5e45b9c81efe987690801ab0037422b6c838 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 10 Nov 2021 08:43:25 +0100 Subject: [PATCH 13/16] feat(supplier): add checkbox isPayMethodChecked --- db/dump/fixtures.sql | 8 ++++---- e2e/helpers/selectors.js | 1 + e2e/paths/13-supplier/02_basic_data.spec.js | 7 +++++++ modules/supplier/back/models/specs/supplier.spec.js | 1 + modules/supplier/back/models/supplier.json | 5 ++++- modules/supplier/front/basic-data/index.html | 4 ++++ modules/supplier/front/basic-data/locale/es.yml | 1 + 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 4c82be909..e47f4535d 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1285,11 +1285,11 @@ INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `pr (5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'), (6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`) VALUES - (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants'), - (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals'), - (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'flowerPlants'); + (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1), + (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1), + (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'flowerPlants', 1); INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 08a21f838..d4d5d33aa 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1147,6 +1147,7 @@ export default { alias: 'vn-supplier-basic-data vn-textfield[ng-model="$ctrl.supplier.nickname"]', isSerious: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isSerious"]', isActive: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isActive"]', + isPayMethodChecked: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isPayMethodChecked"]', notes: 'vn-supplier-basic-data vn-textarea[ng-model="$ctrl.supplier.note"]', saveButton: 'vn-supplier-basic-data button[type="submit"]', }, diff --git a/e2e/paths/13-supplier/02_basic_data.spec.js b/e2e/paths/13-supplier/02_basic_data.spec.js index 2bc94402b..f98fa779e 100644 --- a/e2e/paths/13-supplier/02_basic_data.spec.js +++ b/e2e/paths/13-supplier/02_basic_data.spec.js @@ -22,6 +22,7 @@ describe('Supplier basic data path', () => { await page.write(selectors.supplierBasicData.alias, 'Plants Nick SL'); await page.waitToClick(selectors.supplierBasicData.isSerious); await page.waitToClick(selectors.supplierBasicData.isActive); + await page.waitToClick(selectors.supplierBasicData.isPayMethodChecked); await page.write(selectors.supplierBasicData.notes, 'Some notes'); await page.waitToClick(selectors.supplierBasicData.saveButton); @@ -52,6 +53,12 @@ describe('Supplier basic data path', () => { expect(result).toBe('unchecked'); }); + it('should check the isPayMethodChecked checkbox is now unchecked', async() => { + const result = await page.checkboxState(selectors.supplierBasicData.isPayMethodChecked); + + expect(result).toBe('unchecked'); + }); + it('should check the notes were edited', async() => { const result = await page.waitToGetProperty(selectors.supplierBasicData.notes, 'value'); diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index c3c99e676..9621549eb 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -37,6 +37,7 @@ describe('loopback model Supplier', () => { .catch(e => { error = e; }); + console.log(error); expect(error).toBeDefined(); }); diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 30ed721a5..d08383576 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -101,7 +101,10 @@ "mysql": { "columnName": "withholdingSageFk" } - } + }, + "isPayMethodChecked": { + "type": "boolean" + } }, "relations": { "payMethod": { diff --git a/modules/supplier/front/basic-data/index.html b/modules/supplier/front/basic-data/index.html index a30eee719..0ec80641d 100644 --- a/modules/supplier/front/basic-data/index.html +++ b/modules/supplier/front/basic-data/index.html @@ -36,6 +36,10 @@ label="Active" ng-model="$ctrl.supplier.isActive"> + + Date: Wed, 10 Nov 2021 09:20:54 +0100 Subject: [PATCH 14/16] fix: test e2e --- e2e/paths/02-client/14_balance.spec.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index 89762ff8a..d3de842e3 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -98,10 +98,19 @@ describe('Client balance path', () => { expect(message.text).toContain('Data saved!'); }); + it('should check the balance value is now -100', async() => { + let result = await page + .waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText'); + + expect(result).toContain('-€100.00'); + }); + it('should create a new payment and check the cash exceeded the maximum', async() => { const amountPaid = '1001'; + await page.closePopup(); await page.waitToClick(selectors.clientBalance.newPaymentButton); + await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Cash'); await page.write(selectors.clientBalance.newPaymentAmount, amountPaid); await page.clearInput(selectors.clientBalance.newDescription); await page.write(selectors.clientBalance.newDescription, 'Payment'); @@ -111,14 +120,8 @@ describe('Client balance path', () => { expect(message.text).toContain('Amount exceeded'); }); - it('should check the balance value is now -100', async() => { - let result = await page - .waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText'); - - expect(result).toContain('-€100.00'); - }); - it('should create a new payment that sets the balance back to the original negative value', async() => { + await page.closePopup(); await page.waitToClick(selectors.clientBalance.newPaymentButton); await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt'); await page.overwrite(selectors.clientBalance.newPaymentAmount, '-150'); From 2ca48f2ae00131d6044e8a92312f80d54b8057bc Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 10 Nov 2021 10:48:05 +0100 Subject: [PATCH 15/16] refactor(supplier): remove console.log --- modules/supplier/back/models/specs/supplier.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 9621549eb..c3c99e676 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -37,7 +37,6 @@ describe('loopback model Supplier', () => { .catch(e => { error = e; }); - console.log(error); expect(error).toBeDefined(); }); From d3ff60719c5732858f56236099193c77cc018983 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 10 Nov 2021 12:34:56 +0100 Subject: [PATCH 16/16] fix(last-entries): dateFrom -75 days --- modules/item/front/last-entries/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/front/last-entries/index.js b/modules/item/front/last-entries/index.js index a92ec4858..014761da9 100644 --- a/modules/item/front/last-entries/index.js +++ b/modules/item/front/last-entries/index.js @@ -6,7 +6,7 @@ class Controller extends Section { super($element, $); const from = new Date(); - from.setDate(from.getDate()); + from.setDate(from.getDate() - 75); from.setHours(0, 0, 0, 0); const to = new Date();