From fdf285dd5f15806e377126d29090167fbd335946 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 4 Apr 2022 10:31:28 +0200 Subject: [PATCH 1/5] fix(worker_timeControl): corrected db procedure --- .../10450-april/00-timeControl_getError.sql | 73 +++++++++++++++++++ e2e/paths/03-worker/04_time_control.spec.js | 4 +- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 db/changes/10450-april/00-timeControl_getError.sql diff --git a/db/changes/10450-april/00-timeControl_getError.sql b/db/changes/10450-april/00-timeControl_getError.sql new file mode 100644 index 0000000000..0caf8ab620 --- /dev/null +++ b/db/changes/10450-april/00-timeControl_getError.sql @@ -0,0 +1,73 @@ +DROP PROCEDURE IF EXISTS vn.timeControl_getError; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN +/* + * @param vDatedFrom + * @param vDatedTo + * @table tmp.`user`(userFk) + * Fichadas incorrectas de las cuales no se puede calcular horas trabajadas + * @return tmp.timeControlError (id) + */ + DECLARE vDayMaxTime INTEGER; + + SET @journeyCounter := 0; + SET @lastUserFk := NULL; + + SELECT dayMaxTime INTO vDayMaxTime + FROM workerTimeControlConfig LIMIT 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; + CREATE TEMPORARY TABLE tmp.timeControl + (INDEX(id), INDEX(journeyCounter)) + ENGINE = MEMORY + SELECT sub.id, + sub.direction, + sub.timed, + IF(sub.direction = 'in' OR @hasOut OR sub.userFk <> @lastUserFk, @journeyCounter := @journeyCounter + 1, @journeyCounter) journeyCounter, + @lastUserFk := sub.userFk workerFk, + IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE) + FROM ( + SELECT DISTINCT wtc.id, + wtc.direction, + wtc.timed, + wtc.userFk + FROM workerTimeControl wtc + JOIN tmp.`user` w ON w.userFk = wtc.userFk + WHERE wtc.timed BETWEEN DATE_SUB(vDatedFrom, INTERVAL 1 DAY) AND DATE_ADD(vDatedTo, INTERVAL 1 DAY) + ORDER BY wtc.userFk, wtc.timed + ) sub; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; + CREATE TEMPORARY TABLE tmp.timeControlAux + (INDEX(id), INDEX(journeyCounter)) + ENGINE = MEMORY + SELECT * FROM tmp.timeControl; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError; + CREATE TEMPORARY TABLE tmp.timeControlError + (INDEX(id)) + ENGINE = MEMORY + SELECT id + FROM tmp.timeControlAux tca + JOIN (SELECT journeyCounter, + UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork, + SUM(direction = 'in') totalIn, + SUM(direction = 'out') totalOut, + timed + FROM tmp.timeControl + GROUP BY journeyCounter + HAVING COUNT(*) MOD 2 = 1 + OR totalIn <> 1 + OR totalOut <> 1 + OR timeWork >= vDayMaxTime + )sub ON sub.journeyCounter = tca.journeyCounter + WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; + +END$$ +DELIMITER ; diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js index 137d94c742..5709e6207c 100644 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ b/e2e/paths/03-worker/04_time_control.spec.js @@ -99,8 +99,8 @@ describe('Worker time control path', () => { expect(result).toEqual(scanTime); }); - // 3736 check proc vn.timeControl_calculate - xit(`should check Hank Pym worked 6:40 hours`, async() => { + + it(`should check Hank Pym worked 6:40 hours`, async() => { await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '06:40 h.'); }); }); From ade5e9256dc87d80d71a440040e881620159ca67 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 5 Apr 2022 15:21:20 +0200 Subject: [PATCH 2/5] feat(client_search-panel): add zone and province --- .../methods/client/getPostCodeFromZone.js | 38 +++++++++++++++++++ modules/client/back/models/client.js | 1 + modules/client/front/main/index.js | 17 ++++++++- modules/client/front/search-panel/index.html | 16 ++++++++ modules/zone/back/models/zone-geo.json | 12 ++++++ modules/zone/back/models/zone.json | 14 ++++++- 6 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 modules/client/back/methods/client/getPostCodeFromZone.js diff --git a/modules/client/back/methods/client/getPostCodeFromZone.js b/modules/client/back/methods/client/getPostCodeFromZone.js new file mode 100644 index 0000000000..79d8de3575 --- /dev/null +++ b/modules/client/back/methods/client/getPostCodeFromZone.js @@ -0,0 +1,38 @@ +module.exports = Self => { + Self.remoteMethod('getPostCodeFromZone', { + description: 'CHANGEEEEEEEEEEEEEEE', + accessType: 'READ', + accepts: [{ + arg: 'zoneId', + type: 'number', + required: true, + description: 'zone id' + }], + returns: { + type: 'number', + root: true + }, + http: { + path: `/getPostCodeFromZone`, + verb: 'GET' + } + }); + + Self.getPostCodeFromZone = async(zoneId, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const query = ` + SELECT p.code + FROM postCode p + JOIN zoneIncluded z ON z.geoFk = p.geoFk + WHERE z.zoneFk = ?`; + const postCodes = await Self.rawSql(query, [zoneId], myOptions); + const postCodeIds = []; + postCodes.map(postCode => postCodeIds.push(postCode.code)); + console.log(postCodeIds); + return postCodeIds; + }; +}; diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 9ec45f58dd..9785703d3a 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -30,6 +30,7 @@ module.exports = Self => { require('../methods/client/consumption')(Self); require('../methods/client/createReceipt')(Self); require('../methods/client/updatePortfolio')(Self); + require('../methods/client/getPostCodeFromZone')(Self); // Validations diff --git a/modules/client/front/main/index.js b/modules/client/front/main/index.js index 61cde8b22c..04f3572614 100644 --- a/modules/client/front/main/index.js +++ b/modules/client/front/main/index.js @@ -2,7 +2,7 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Client extends ModuleMain { - exprBuilder(param, value) { + async exprBuilder(param, value) { switch (param) { case 'search': return /^\d+$/.test(value) @@ -15,6 +15,10 @@ export default class Client extends ModuleMain { {mobile: value} ] }; + case 'zoneFk': + await this.getPostCodesFromZone(value); + console.log(this.postCodeIds); + return {postcode: {inq: this.postCodeIds}}; case 'name': case 'socialName': case 'city': @@ -23,10 +27,21 @@ export default class Client extends ModuleMain { case 'id': case 'fi': case 'postcode': + case 'provinceFk': case 'salesPersonFk': return {[param]: value}; } } + + async getPostCodesFromZone(zoneId) { + const params = { + zoneId: zoneId + }; + this.$http.get('Clients/getPostCodeFromZone', {params}) + .then(res => { + this.postCodeIds = res.data; + }); + } } ngModule.vnComponent('vnClient', { diff --git a/modules/client/front/search-panel/index.html b/modules/client/front/search-panel/index.html index 9caf4185bb..a02f93882f 100644 --- a/modules/client/front/search-panel/index.html +++ b/modules/client/front/search-panel/index.html @@ -50,6 +50,22 @@ ng-model="filter.postcode"> + + + + + + Date: Wed, 6 Apr 2022 12:29:00 +0200 Subject: [PATCH 3/5] feat(client_search-panel): filter by province --- db/dump/fixtures.sql | 8 ++-- .../methods/client/getPostCodeFromZone.js | 38 ------------------- modules/client/back/models/client.js | 1 - modules/client/front/main/index.js | 16 +------- modules/client/front/search-panel/index.html | 7 ---- modules/zone/back/models/zone-geo.json | 12 ------ modules/zone/back/models/zone.json | 5 --- 7 files changed, 5 insertions(+), 82 deletions(-) delete mode 100644 modules/client/back/methods/client/getPostCodeFromZone.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index e8302b1a2f..5bd89ebd25 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -292,10 +292,10 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`) VALUES (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), + (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'), (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Silla', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'), (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'), diff --git a/modules/client/back/methods/client/getPostCodeFromZone.js b/modules/client/back/methods/client/getPostCodeFromZone.js deleted file mode 100644 index 79d8de3575..0000000000 --- a/modules/client/back/methods/client/getPostCodeFromZone.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getPostCodeFromZone', { - description: 'CHANGEEEEEEEEEEEEEEE', - accessType: 'READ', - accepts: [{ - arg: 'zoneId', - type: 'number', - required: true, - description: 'zone id' - }], - returns: { - type: 'number', - root: true - }, - http: { - path: `/getPostCodeFromZone`, - verb: 'GET' - } - }); - - Self.getPostCodeFromZone = async(zoneId, options) => { - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - const query = ` - SELECT p.code - FROM postCode p - JOIN zoneIncluded z ON z.geoFk = p.geoFk - WHERE z.zoneFk = ?`; - const postCodes = await Self.rawSql(query, [zoneId], myOptions); - const postCodeIds = []; - postCodes.map(postCode => postCodeIds.push(postCode.code)); - console.log(postCodeIds); - return postCodeIds; - }; -}; diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 9785703d3a..9ec45f58dd 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -30,7 +30,6 @@ module.exports = Self => { require('../methods/client/consumption')(Self); require('../methods/client/createReceipt')(Self); require('../methods/client/updatePortfolio')(Self); - require('../methods/client/getPostCodeFromZone')(Self); // Validations diff --git a/modules/client/front/main/index.js b/modules/client/front/main/index.js index 04f3572614..1069d3487e 100644 --- a/modules/client/front/main/index.js +++ b/modules/client/front/main/index.js @@ -2,7 +2,7 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Client extends ModuleMain { - async exprBuilder(param, value) { + exprBuilder(param, value) { switch (param) { case 'search': return /^\d+$/.test(value) @@ -15,10 +15,6 @@ export default class Client extends ModuleMain { {mobile: value} ] }; - case 'zoneFk': - await this.getPostCodesFromZone(value); - console.log(this.postCodeIds); - return {postcode: {inq: this.postCodeIds}}; case 'name': case 'socialName': case 'city': @@ -32,16 +28,6 @@ export default class Client extends ModuleMain { return {[param]: value}; } } - - async getPostCodesFromZone(zoneId) { - const params = { - zoneId: zoneId - }; - this.$http.get('Clients/getPostCodeFromZone', {params}) - .then(res => { - this.postCodeIds = res.data; - }); - } } ngModule.vnComponent('vnClient', { diff --git a/modules/client/front/search-panel/index.html b/modules/client/front/search-panel/index.html index a02f93882f..234cb6f53e 100644 --- a/modules/client/front/search-panel/index.html +++ b/modules/client/front/search-panel/index.html @@ -58,13 +58,6 @@ value-field="id" label="Province"> - - Date: Wed, 6 Apr 2022 12:38:49 +0200 Subject: [PATCH 4/5] remove relation --- modules/zone/back/models/zone.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json index 6bdb1b5b54..1e97c1bad4 100644 --- a/modules/zone/back/models/zone.json +++ b/modules/zone/back/models/zone.json @@ -67,11 +67,6 @@ "type": "hasMany", "model": "ZoneClosure", "foreignKey": "zoneFk" - }, - "provinces": { - "type": "hasMany", - "model": "Province", - "foreignKey": "zoneFk" - } + } } } \ No newline at end of file From 4350ea0af52d7e97ed9f352aeb83220137bc2634 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 7 Apr 2022 08:32:31 +0200 Subject: [PATCH 5/5] refactor: changed default date to tomorrow --- modules/client/front/balance/create/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 591af2839e..454e5e44d9 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -6,8 +6,11 @@ class Controller extends Dialog { super($element, $, $transclude); this.vnReport = vnReport; + + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); this.receipt = { - payed: new Date() + payed: tomorrow }; }