From 0dbb6a49ddfedc71bef10a80911cd332c5c96d41 Mon Sep 17 00:00:00 2001 From: Fabian Kromer Date: Thu, 1 Aug 2024 09:45:28 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9B=20fixed=20a=20bug=20in=20the?= =?UTF-8?q?=20Siwapp=20interface=20after=20async=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imports/api/timecards/server/methods.js | 6 +++--- imports/utils/periodHelpers.js | 20 ++++++++++++++++++-- package.json | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/imports/api/timecards/server/methods.js b/imports/api/timecards/server/methods.js index 1854769..453ea20 100644 --- a/imports/api/timecards/server/methods.js +++ b/imports/api/timecards/server/methods.js @@ -8,7 +8,7 @@ import Tasks from '../../tasks/tasks.js' import Projects from '../../projects/projects.js' import { t } from '../../../utils/i18n.js' import { emojify } from '../../../utils/frontend_helpers' -import { timeInUserUnit } from '../../../utils/periodHelpers.js' +import { timeInUserUnitAsync } from '../../../utils/periodHelpers.js' import { authenticationMixin, transactionLogMixin, @@ -441,11 +441,11 @@ const sendToSiwapp = new ValidatedMethod({ for await (const [project, resources] of projectMap.entries()) { const projectElement = await Projects.findOneAsync({ _id: project }) if (resources.size > 0) { - for (const [resource, hours] of resources) { + for (const [resource, hours] of resourcses) { invoiceJSON.data.relationships.items.data.push({ attributes: { description: `${projectElement.name} (${resource})`, - quantity: timeInUserUnit(hours, meteorUser), + quantity: await timeInUserUnitAsync(hours, meteorUser), unitary_cost: 0, }, }) diff --git a/imports/utils/periodHelpers.js b/imports/utils/periodHelpers.js index f20ec3a..1958cdc 100644 --- a/imports/utils/periodHelpers.js +++ b/imports/utils/periodHelpers.js @@ -1,7 +1,7 @@ import dayjs from 'dayjs' import utc from 'dayjs/plugin/utc' import isoWeek from 'dayjs/plugin/isoWeek' -import { getGlobalSetting, getUserSetting } from './frontend_helpers' +import { getGlobalSetting, getGlobalSettingAsync, getUserSetting } from './frontend_helpers' import { getUserSettingAsync } from './server_method_helpers' async function periodToDates(period) { @@ -66,4 +66,20 @@ function timeInUserUnit(time, meteorUser) { } return Number(time).toFixed(precision) } -export { periodToDates, timeInUserUnit } +async function timeInUserUnitAsync(time, meteorUser) { + const precision = meteorUser?.profile?.precision ? meteorUser.profile.precision : await getGlobalSettingAsync('precision') + if (meteorUser?.profile?.timeunit === 'd') { + let hoursToDays = await getGlobalSettingAsync('hoursToDays') + if (meteorUser?.profile?.hoursToDays) { + hoursToDays = meteorUser.profile.hoursToDays + } + const convertedTime = Number(time / hoursToDays).toFixed(precision) + return convertedTime !== Number(0).toFixed(precision) ? convertedTime : undefined + } + if (meteorUser?.profile?.timeunit === 'm') { + const convertedTime = Number(time * 60).toFixed(precision) + return convertedTime !== Number(0).toFixed(precision) ? convertedTime : undefined + } + return Number(time).toFixed(precision) +} +export { periodToDates, timeInUserUnit, timeInUserUnitAsyncs } diff --git a/package.json b/package.json index defb54f..438d035 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "titra", - "version": "0.99.4", + "version": "0.99.5", "private": true, "scripts": { "start": "meteor run" From aefc00cfdf705c9c81a88af28cd4ccbd6422e17c Mon Sep 17 00:00:00 2001 From: Fabian Kromer Date: Thu, 1 Aug 2024 09:53:56 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B=20fixed=20a=20type=20of=20the?= =?UTF-8?q?=20last=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imports/api/timecards/server/methods.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/api/timecards/server/methods.js b/imports/api/timecards/server/methods.js index 453ea20..06db45a 100644 --- a/imports/api/timecards/server/methods.js +++ b/imports/api/timecards/server/methods.js @@ -441,7 +441,7 @@ const sendToSiwapp = new ValidatedMethod({ for await (const [project, resources] of projectMap.entries()) { const projectElement = await Projects.findOneAsync({ _id: project }) if (resources.size > 0) { - for (const [resource, hours] of resourcses) { + for (const [resource, hours] of resources) { invoiceJSON.data.relationships.items.data.push({ attributes: { description: `${projectElement.name} (${resource})`, diff --git a/package.json b/package.json index 438d035..0d1ec72 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "titra", - "version": "0.99.5", + "version": "0.99.6", "private": true, "scripts": { "start": "meteor run" From af592615a009664d211ec392a10ac69eaf866822 Mon Sep 17 00:00:00 2001 From: Fabian Kromer Date: Thu, 1 Aug 2024 10:11:37 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20fixed=20another=20typo=20in?= =?UTF-8?q?=20the=20latest=20bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imports/utils/periodHelpers.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/utils/periodHelpers.js b/imports/utils/periodHelpers.js index 1958cdc..d78d3d9 100644 --- a/imports/utils/periodHelpers.js +++ b/imports/utils/periodHelpers.js @@ -82,4 +82,4 @@ async function timeInUserUnitAsync(time, meteorUser) { } return Number(time).toFixed(precision) } -export { periodToDates, timeInUserUnit, timeInUserUnitAsyncs } +export { periodToDates, timeInUserUnit, timeInUserUnitAsync } diff --git a/package.json b/package.json index 0d1ec72..fdb252d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "titra", - "version": "0.99.6", + "version": "0.99.7", "private": true, "scripts": { "start": "meteor run" From 48fefd0646175c956c2bac2aab2235d0a1657167 Mon Sep 17 00:00:00 2001 From: Fabian Kromer Date: Thu, 1 Aug 2024 10:35:38 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=9B=20additional=20bug=20fix=20for?= =?UTF-8?q?=20the=20Siwapp=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imports/utils/periodHelpers.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/utils/periodHelpers.js b/imports/utils/periodHelpers.js index d78d3d9..59ec259 100644 --- a/imports/utils/periodHelpers.js +++ b/imports/utils/periodHelpers.js @@ -1,8 +1,8 @@ import dayjs from 'dayjs' import utc from 'dayjs/plugin/utc' import isoWeek from 'dayjs/plugin/isoWeek' -import { getGlobalSetting, getGlobalSettingAsync, getUserSetting } from './frontend_helpers' -import { getUserSettingAsync } from './server_method_helpers' +import { getGlobalSetting, getUserSetting } from './frontend_helpers' +import { getUserSettingAsync, getGlobalSettingAsync } from './server_method_helpers' async function periodToDates(period) { check(period, String) diff --git a/package.json b/package.json index fdb252d..7094f73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "titra", - "version": "0.99.7", + "version": "0.99.8", "private": true, "scripts": { "start": "meteor run"