From c07beca6c2c35e271f4c6a59954589311be28d4f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 21 Jun 2019 09:43:47 +0200 Subject: [PATCH 01/16] round worker calendar holidays #1547 --- .../back/methods/worker-calendar/absences.js | 33 ++++++++----------- .../worker-calendar/specs/absences.spec.js | 8 ++--- modules/worker/back/models/department.json | 7 ---- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/modules/worker/back/methods/worker-calendar/absences.js b/modules/worker/back/methods/worker-calendar/absences.js index db7318024..0dc3d9af0 100644 --- a/modules/worker/back/methods/worker-calendar/absences.js +++ b/modules/worker/back/methods/worker-calendar/absences.js @@ -36,7 +36,7 @@ module.exports = Self => { } }); - Self.absences = async(ctx, workerFk, started, ended) => { + Self.absences = async(ctx, workerFk, yearStarted, yearEnded) => { const models = Self.app.models; const conn = Self.dataSource.connector; const myUserId = ctx.req.accessToken.userId; @@ -68,7 +68,7 @@ module.exports = Self => { }, where: { workerFk: workerFk, - dated: {between: [started, ended]} + dated: {between: [yearStarted, yearEnded]} } }); @@ -81,7 +81,7 @@ module.exports = Self => { }); // Get active contracts on current year - const year = started.getFullYear(); + const year = yearStarted.getFullYear(); const contracts = await models.WorkerLabour.find({ include: [{ relation: 'holidays', @@ -102,7 +102,7 @@ module.exports = Self => { relation: 'type' }], where: { - dated: {between: [started, ended]} + dated: {between: [yearStarted, yearEnded]} } } } @@ -112,7 +112,7 @@ module.exports = Self => { and: [ {workerFk: workerFk}, {or: [{ - ended: {gte: [started]} + ended: {gte: [yearStarted]} }, {ended: null}]} ], @@ -121,13 +121,7 @@ module.exports = Self => { // Get number of total holidays contracts.forEach(contract => { - let totalHolidays = contract.holidays().days; - - if (contract.started && contract.ended) - totalHolidays = getHolidaysByContract(started, contract); - - calendar.totalHolidays += totalHolidays; - + calendar.totalHolidays += getHolidaysByContract(contract, yearEnded); let holidayList = contract.workCenter().holidays(); for (let day of holidayList) { @@ -141,19 +135,18 @@ module.exports = Self => { return [calendar, absences, holidays]; }; - function getHolidaysByContract(started, contract) { + function getHolidaysByContract(contract, endOfYear) { const dayTimestamp = 1000 * 60 * 60 * 24; - const endedTime = contract.ended.getTime(); + + const started = contract.started; + const ended = contract.ended; const startedTime = started.getTime(); + const endedTime = ended && ended.getTime() || endOfYear; + const contractDays = Math.floor((endedTime - startedTime) / dayTimestamp); if (contractDays < 365) { - let holidays = contract.holidays().days * (contractDays + 1) / 365; - let integerPart = parseInt(holidays); - let decimalPart = holidays - integerPart; - let decimal = decimalPart >= 0.5 ? 0.5 : 0; - - holidays = integerPart + decimal; + let holidays = Math.round(2 * contract.holidays().days * (contractDays + 1) / 365) / 2; return holidays; } diff --git a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js b/modules/worker/back/methods/worker-calendar/specs/absences.spec.js index d5a89c9ab..5627c4303 100644 --- a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js +++ b/modules/worker/back/methods/worker-calendar/specs/absences.spec.js @@ -43,7 +43,7 @@ describe('Worker absences()', () => { expect(sixthType).toEqual('Holidays'); }); - it(`should fire the worker 106 on July and see he/she has 13.75`, async() => { + it(`should fire the worker 106 on July and see he/she has 14`, async() => { const firedWorker = await app.models.WorkerLabour.findById(106); const endedDate = new Date(); @@ -71,7 +71,7 @@ describe('Worker absences()', () => { let calendar = result[0]; let absences = result[1]; - expect(calendar.totalHolidays).toEqual(15.5); + expect(calendar.totalHolidays).toEqual(14); expect(calendar.holidaysEnjoyed).toEqual(5); let firstType = absences[0].absenceType().name; @@ -81,7 +81,7 @@ describe('Worker absences()', () => { expect(sixthType).toEqual('Holidays'); }); - it(`should fire the worker 106 on March and see he/she has 6.5`, async() => { + it(`should fire the worker 106 on March and see he/she has 7`, async() => { const firedWorker = await app.models.WorkerLabour.findById(106); const endedDate = new Date(); @@ -109,7 +109,7 @@ describe('Worker absences()', () => { let calendar = result[0]; let absences = result[1]; - expect(calendar.totalHolidays).toEqual(6.5); + expect(calendar.totalHolidays).toEqual(7); expect(calendar.holidaysEnjoyed).toEqual(5); let firstType = absences[0].absenceType().name; diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json index c89a6ac4e..0b978b56c 100644 --- a/modules/worker/back/models/department.json +++ b/modules/worker/back/models/department.json @@ -14,12 +14,5 @@ "name": { "type": "String" } - }, - "relations": { - "father": { - "type": "belongsTo", - "model": "Department", - "foreignKey": "fatherFk" - } } } From da7b9320d5d3cf30478b2d08ae6248f1f3abbbf1 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 26 Jun 2019 12:18:47 +0200 Subject: [PATCH 02/16] #1564 client.summary defaulting cantidad --- modules/client/back/models/defaulter.json | 3 +-- modules/client/front/summary/index.html | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/client/back/models/defaulter.json b/modules/client/back/models/defaulter.json index b002fcca6..8d50356f1 100644 --- a/modules/client/back/models/defaulter.json +++ b/modules/client/back/models/defaulter.json @@ -27,6 +27,5 @@ "model": "Client", "foreignKey": "clientFk" } - }, - "scope" : {"where": {"amount": {"gt": 0}}} + } } \ No newline at end of file diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html index f3fbc9753..37bee2814 100644 --- a/modules/client/front/summary/index.html +++ b/modules/client/front/summary/index.html @@ -186,7 +186,7 @@ info="Invoices minus payments"> From ee091fc86ae322d38e43a215b462f0cbdb976047 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 2 Jul 2019 12:15:46 +0200 Subject: [PATCH 03/16] fixed ticket.create change agency --- modules/ticket/front/create/card.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/create/card.html b/modules/ticket/front/create/card.html index 28e01827f..0629f460f 100644 --- a/modules/ticket/front/create/card.html +++ b/modules/ticket/front/create/card.html @@ -38,6 +38,6 @@ data="$ctrl._availableAgencies" label="Agency" show-field="agencyMode" - value-field="id" + value-field="agencyModeFk" field="$ctrl.ticket.agencyModeFk"> - + \ No newline at end of file From 8ecc88b5168864108704dfdcf19730019f7bb97e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 11 Jul 2019 09:53:16 +0200 Subject: [PATCH 04/16] hide download button for dms without a file attached #1590 --- modules/client/front/dms/index/index.html | 3 ++- modules/ticket/front/dms/index/index.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/client/front/dms/index/index.html b/modules/client/front/dms/index/index.html index 40f01c4e0..2cf6cdd4f 100644 --- a/modules/client/front/dms/index/index.html +++ b/modules/client/front/dms/index/index.html @@ -58,7 +58,8 @@ + href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}" + ng-show="document.hasFile"> diff --git a/modules/ticket/front/dms/index/index.html b/modules/ticket/front/dms/index/index.html index 9000ca91e..eb51710b6 100644 --- a/modules/ticket/front/dms/index/index.html +++ b/modules/ticket/front/dms/index/index.html @@ -58,7 +58,8 @@ + href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}" + ng-show="document.hasFile"> From 1b8a4079165f2f3de5a2de75fa8c7a175aaa2c48 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 11 Jul 2019 11:20:41 +0200 Subject: [PATCH 05/16] show expeditions fix --- modules/ticket/back/methods/expedition/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js index 3491a9b2d..3ff2fcb59 100644 --- a/modules/ticket/back/methods/expedition/filter.js +++ b/modules/ticket/back/methods/expedition/filter.js @@ -42,7 +42,7 @@ module.exports = Self => { LEFT JOIN vn.item i2 ON i2.id = e.itemFk INNER JOIN vn.item i1 ON i1.id = e.isBox LEFT JOIN vn.worker w ON w.id = e.workerFk - JOIN account.user u ON u.id = w.userFk + LEFT JOIN account.user u ON u.id = w.userFk `); stmt.merge(Self.buildSuffix(filter, 'e')); From 57a0a4113ae7494784601acd6cf5368afb4c744b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Thu, 11 Jul 2019 17:07:25 +0200 Subject: [PATCH 06/16] increased nginx file size limit --- front/nginx.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/front/nginx.conf b/front/nginx.conf index 84daf2ef2..9264f414a 100644 --- a/front/nginx.conf +++ b/front/nginx.conf @@ -16,6 +16,7 @@ server { listen [::]:80 default_server; server_name _; autoindex off; + client_max_body_size 50M root /salix/dist; error_page 404 = @notfound; From 597e271789cbcfcd2f0c12d60545c45c3fac1667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Thu, 11 Jul 2019 17:15:28 +0200 Subject: [PATCH 07/16] revert --- front/nginx.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/front/nginx.conf b/front/nginx.conf index 9264f414a..84daf2ef2 100644 --- a/front/nginx.conf +++ b/front/nginx.conf @@ -16,7 +16,6 @@ server { listen [::]:80 default_server; server_name _; autoindex off; - client_max_body_size 50M root /salix/dist; error_page 404 = @notfound; From 9d0b88cd57a16cc7d5c89694b88301f858ab786a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Thu, 11 Jul 2019 17:22:42 +0200 Subject: [PATCH 08/16] nginx --- front/nginx.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/front/nginx.conf b/front/nginx.conf index 84daf2ef2..cf429b153 100644 --- a/front/nginx.conf +++ b/front/nginx.conf @@ -16,6 +16,7 @@ server { listen [::]:80 default_server; server_name _; autoindex off; + client_max_body_size 50M; root /salix/dist; error_page 404 = @notfound; From 6634cdf0599df528ae5cad03a6d84a8ab1d3c803 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 12 Jul 2019 08:49:44 +0200 Subject: [PATCH 09/16] ticket.index show zone hour & minute. Show only tickets from today --- modules/ticket/back/methods/ticket/filter.js | 6 +++++- modules/ticket/front/index/index.html | 7 ++++++- modules/ticket/front/index/index.js | 11 +++++++++++ modules/ticket/front/index/locale/es.yml | 4 +++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 7bf4cf4de..a3c17ecc4 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -196,8 +196,12 @@ module.exports = Self => { ts.alertLevel as alertLevel, ts.code as alertLevelCode, u.nickname userNickname, - c.salesPersonFk + c.salesPersonFk, + z.hour zoneLanding, + HOUR(z.hour) zoneHour, + MINUTE(z.hour) zoneMinute FROM ticket t + LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN province p ON p.id = a.provinceFk LEFT JOIN warehouse w ON w.id = t.warehouseFk diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index a438d9359..fae2cf923 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -2,8 +2,9 @@ vn-id="model" url="/ticket/api/Tickets/filter" limit="20" + params="::$ctrl.params" data="tickets" - order="shipped DESC, clientFk" + order="shipped DESC, zoneHour ASC, zoneMinute ASC, clientFk" auto-load="false">
@@ -50,6 +51,8 @@ Agency Warehouse Invoice + Zone Hour + Zone Minute Total @@ -120,6 +123,8 @@ {{::ticket.agencyMode}} {{::ticket.warehouse}} {{::ticket.refFk | dashIfEmpty}} + {{::ticket.zoneLanding | dateTime: 'HH'}} + {{::ticket.zoneLanding | dateTime: 'mm'}} {{::ticket.total | currency: 'EUR': 2}} Date: Fri, 12 Jul 2019 09:06:19 +0200 Subject: [PATCH 10/16] ticket index show zone closure hour --- modules/ticket/front/index/index.html | 6 ++---- modules/ticket/front/index/locale/es.yml | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index fae2cf923..343c2e1d9 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -51,8 +51,7 @@ Agency Warehouse Invoice - Zone Hour - Zone Minute + Closure Total @@ -123,8 +122,7 @@ {{::ticket.agencyMode}} {{::ticket.warehouse}} {{::ticket.refFk | dashIfEmpty}} - {{::ticket.zoneLanding | dateTime: 'HH'}} - {{::ticket.zoneLanding | dateTime: 'mm'}} + {{::ticket.zoneLanding | dateTime: 'HH:mm'}} {{::ticket.total | currency: 'EUR': 2}} Date: Fri, 12 Jul 2019 09:39:59 +0200 Subject: [PATCH 11/16] changed closure field --- modules/ticket/front/index/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 343c2e1d9..bf8ccea49 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -51,7 +51,7 @@ Agency Warehouse Invoice - Closure + Closure Total From 29744c52f3c4b50739bb9ae986bb83694c62b227 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 12 Jul 2019 11:43:10 +0200 Subject: [PATCH 12/16] fixed ticket.index --- modules/ticket/front/index/index.html | 3 +-- modules/ticket/front/index/index.js | 26 +++++++++++++------------- modules/ticket/front/index/style.scss | 22 ++++++++++++++-------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index bf8ccea49..c6e864a86 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -2,7 +2,6 @@ vn-id="model" url="/ticket/api/Tickets/filter" limit="20" - params="::$ctrl.params" data="tickets" order="shipped DESC, zoneHour ASC, zoneMinute ASC, clientFk" auto-load="false"> @@ -13,7 +12,7 @@ { if (res.data) { this.filter = { @@ -42,7 +42,7 @@ export default class Controller { }; } }); - } + } */ setBalanceCreateDialog() { let data = this.$.tickets; diff --git a/modules/ticket/front/index/style.scss b/modules/ticket/front/index/style.scss index b5722b9b1..6a935c7f6 100644 --- a/modules/ticket/front/index/style.scss +++ b/modules/ticket/front/index/style.scss @@ -1,11 +1,17 @@ @import "variables"; -vn-ticket-index vn-icon-menu { - padding-top: 30px; - padding-left: 10px; - color: $color-main; - - li { - color: initial; +vn-ticket-index { + vn-icon-menu { + padding-top: 30px; + padding-left: 10px; + color: $color-main; + + li { + color: initial; + } } -} + + vn-searchbar { + width: 100% + } +} \ No newline at end of file From c4fcaeb908f56d9e2de8eff0c37d4ca998776988 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 12 Jul 2019 12:20:55 +0200 Subject: [PATCH 13/16] ticket.index filter by date if no filters were entered --- modules/ticket/front/index/index.js | 33 ++++++++--------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index b29a1fb08..e431db7ef 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -18,32 +18,8 @@ export default class Controller { this.$.balanceCreateDialog.show(); }, name: 'Payment on account...', always: true} ]; - - if (!$stateParams.q) { - const today = new Date(); - today.setHours(0, 0, 0, 0); - - const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 1); - tomorrow.setHours(23, 59, 59, 999); - - this.filter = { - from: today, - to: tomorrow - }; - } } - /* getScopeDays() { - this.$http.get(`/api/TicketConfigs/findOne`).then(res => { - if (res.data) { - this.filter = { - scopeDays: parseInt(res.data.scopeDays) - }; - } - }); - } */ - setBalanceCreateDialog() { let data = this.$.tickets; let description = []; @@ -79,6 +55,15 @@ export default class Controller { this.scopeDays = params.scopeDays; this.buildFilterDates(); params = Object.assign(params, {from: this.today, to: this.daysOnward}); + } else if (!params.from && !params.to) { + const today = new Date(); + today.setHours(0, 0, 0, 0); + + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + tomorrow.setHours(23, 59, 59, 999); + + params = Object.assign(params, {from: today, to: tomorrow}); } this.$.model.applyFilter(null, params); From 6b9286d1b0ad6eb76c31a9262b6ce228fed3ffcb Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 12 Jul 2019 12:32:02 +0200 Subject: [PATCH 14/16] fixed ticket.index --- modules/ticket/front/index/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index c6e864a86..5fe4bdfb6 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -12,7 +12,6 @@ Date: Fri, 12 Jul 2019 12:56:00 +0200 Subject: [PATCH 15/16] apply default filters --- modules/ticket/front/index/index.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index e431db7ef..95711dd0c 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -18,6 +18,20 @@ export default class Controller { this.$.balanceCreateDialog.show(); }, name: 'Payment on account...', always: true} ]; + + if (!$stateParams.q) + this.setDefaultFilter(); + } + + setDefaultFilter() { + const today = new Date(); + today.setHours(0, 0, 0, 0); + + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + tomorrow.setHours(23, 59, 59, 999); + + this.filter = {from: today, to: tomorrow}; } setBalanceCreateDialog() { @@ -55,17 +69,7 @@ export default class Controller { this.scopeDays = params.scopeDays; this.buildFilterDates(); params = Object.assign(params, {from: this.today, to: this.daysOnward}); - } else if (!params.from && !params.to) { - const today = new Date(); - today.setHours(0, 0, 0, 0); - - const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 1); - tomorrow.setHours(23, 59, 59, 999); - - params = Object.assign(params, {from: today, to: tomorrow}); } - this.$.model.applyFilter(null, params); } else this.$.model.clear(); From c21532e5f77eab824eaf4a395898706beef4e07a Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 12 Jul 2019 14:00:32 +0200 Subject: [PATCH 16/16] ticket.index filters --- modules/ticket/front/index/index.js | 41 ++++++++++------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 95711dd0c..9413400ce 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -18,20 +18,6 @@ export default class Controller { this.$.balanceCreateDialog.show(); }, name: 'Payment on account...', always: true} ]; - - if (!$stateParams.q) - this.setDefaultFilter(); - } - - setDefaultFilter() { - const today = new Date(); - today.setHours(0, 0, 0, 0); - - const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 1); - tomorrow.setHours(23, 59, 59, 999); - - this.filter = {from: today, to: tomorrow}; } setBalanceCreateDialog() { @@ -51,26 +37,27 @@ export default class Controller { this.$.balanceCreateDialog.description += description.join(', '); } - buildFilterDates() { - let today = new Date(); - this.today = today.setHours(0, 0, 0, 0); + getScopeDates(days) { + const today = new Date(); + today.setHours(0, 0, 0, 0); - let buildDate = new Date(today); - buildDate.setDate(today.getDate() + this.scopeDays); - buildDate.setHours(23, 59, 59, 999); + const daysOnward = new Date(today); + daysOnward.setDate(today.getDate() + days); + daysOnward.setHours(23, 59, 59, 999); - this.daysOnward = buildDate; + return {from: today, to: daysOnward}; } onSearch(params) { if (params) { + let newParams = params; if (params.scopeDays) { - params.scopeDays = parseInt(params.scopeDays); - this.scopeDays = params.scopeDays; - this.buildFilterDates(); - params = Object.assign(params, {from: this.today, to: this.daysOnward}); - } - this.$.model.applyFilter(null, params); + const scopeDates = this.getScopeDates(params.scopeDays); + Object.assign(newParams, scopeDates); + } else if (Object.entries(params).length == 0) + newParams = this.getScopeDates(1); + + this.$.model.applyFilter(null, newParams); } else this.$.model.clear(); }