Skip to content

Commit

Permalink
⬆️ updated package dependencies
Browse files Browse the repository at this point in the history
🐛 fixed issue #213 (leftovers from the async migration)
  • Loading branch information
faburem committed Aug 19, 2024
2 parents c3c1fb2 + 48fefd0 commit c0f6bb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions imports/api/timecards/server/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -445,7 +445,7 @@ const sendToSiwapp = new ValidatedMethod({
invoiceJSON.data.relationships.items.data.push({
attributes: {
description: `${projectElement.name} (${resource})`,
quantity: timeInUserUnit(hours, meteorUser),
quantity: await timeInUserUnitAsync(hours, meteorUser),
unitary_cost: 0,
},
})
Expand Down
20 changes: 18 additions & 2 deletions imports/utils/periodHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
import isoWeek from 'dayjs/plugin/isoWeek'
import { getGlobalSetting, getUserSetting } from './frontend_helpers'
import { getUserSettingAsync } from './server_method_helpers'
import { getUserSettingAsync, getGlobalSettingAsync } from './server_method_helpers'

async function periodToDates(period) {
check(period, String)
Expand Down Expand Up @@ -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, timeInUserUnitAsync }
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "titra",
"version": "0.99.5",
"version": "0.99.9",
"private": true,
"scripts": {
"start": "meteor run"
Expand Down

0 comments on commit c0f6bb8

Please sign in to comment.