Skip to content

Commit

Permalink
Avoid line breaks between amount and unit in price and duration field…
Browse files Browse the repository at this point in the history
…s of report and invoice
  • Loading branch information
quafzi committed Feb 3, 2017
1 parent bdf7987 commit 382892a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/app/report/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const timesliceApi = require('src/api/timeslice')
const totalsView = require('./totals').view
const userSettings = require('src/app/setting').sections
userSettings.report = require('./settings')
const nbsp = '\u00a0'

const groupByActivity = `rows.reduce((result, row) => {
if (undefined === result[row.activity.id]) {
Expand Down Expand Up @@ -224,9 +225,9 @@ function getInvoiceParams (config, columns, rows) {
const tax = subtotal * parseFloat(config.taxRate) / 100
const grandTotal = subtotal + tax
params.totals = {
subtotal: { title: t('invoice.totals.subtotal'), value: subtotal.toFixed(2) + ' €' },
tax: { title: t('invoice.totals.tax'), value: tax.toFixed(2) + ' €' },
grand_total: { title: t('invoice.totals.grand_total'), value: grandTotal.toFixed(2) + ' €' }
subtotal: { title: t('invoice.totals.subtotal'), value: subtotal.toFixed(2) + nbsp + '€' },
tax: { title: t('invoice.totals.tax'), value: tax.toFixed(2) + nbsp + '€' },
grand_total: { title: t('invoice.totals.grand_total'), value: grandTotal.toFixed(2) + nbsp + '€' }
}
return params
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/report/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const m = require('src/lib/mithril')
const moment = require('moment')
const userSettings = require('src/app/setting').sections
const nbsp = '\u00a0'

function values (columns, item) {
const durationHours = moment.duration(item.duration, 'seconds').asHours()
Expand Down Expand Up @@ -32,10 +33,10 @@ function values (columns, item) {
} else {
switch (col) {
case 'duration':
value = durationHours.toFixed(2) + ' h'
value = durationHours.toFixed(2) + nbsp + 'h'
break
case 'price':
value = item.price.toFixed(2) + ' €'
value = item.price.toFixed(2) + nbsp + '€'
break
default:
value = item[col]
Expand Down
5 changes: 3 additions & 2 deletions src/app/report/totals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
const m = require('src/lib/mithril')
const moment = require('moment')
const t = require('src/lib/translation')
const nbsp = '\u00a0'

function view (scope) {
const total = scope.rows.reduce((sum, row) => sum + row.duration, 0)
const priceEnabled = (scope.columns.indexOf('price') > -1)
return m('tr.total', [
m('th', { colspan: scope.columns.length - (priceEnabled ? 2 : 1) }, t('report.table.totals.duration')),
m('td.duration.total', moment.duration(total, 'seconds').asHours().toFixed(2) + ' h'),
priceEnabled ? m('td.price.total', scope.rows.reduce((sum, row) => sum + row.price, 0).toFixed(2) + ' €') : null
m('td.duration.total', moment.duration(total, 'seconds').asHours().toFixed(2) + nbsp + 'h'),
priceEnabled ? m('td.price.total', scope.rows.reduce((sum, row) => sum + row.price, 0).toFixed(2) + nbsp + '€') : null
])
}

Expand Down

0 comments on commit 382892a

Please sign in to comment.