diff --git a/src/components/BalanceSummary/BalanceInfos.js b/src/components/BalanceSummary/BalanceInfos.js index 78dd2c6c..1435b3c9 100644 --- a/src/components/BalanceSummary/BalanceInfos.js +++ b/src/components/BalanceSummary/BalanceInfos.js @@ -46,7 +46,7 @@ export function BalanceSincePercent(props: BalanceSinceProps) { alwaysShowSign fontSize={7} /> - {t('time:since', { since: t(`time:${since}`) })} + {t(`time:since.${since}`)} ) } @@ -62,7 +62,7 @@ export function BalanceSinceDiff(props: Props) { val={totalBalance - sinceBalance} fontSize={7} /> - {t('time:since', { since: t(`time:${since}`) })} + {t(`time:since.${since}`)} ) } diff --git a/src/components/CalculateBalance.js b/src/components/CalculateBalance.js index 8c2a5de0..12875371 100644 --- a/src/components/CalculateBalance.js +++ b/src/components/CalculateBalance.js @@ -3,7 +3,7 @@ import { PureComponent } from 'react' import { connect } from 'react-redux' import moment from 'moment' -import first from 'lodash/first' +import find from 'lodash/find' import last from 'lodash/last' import type { MapStateToProps } from 'react-redux' @@ -30,10 +30,13 @@ function calculateBalance(props) { interval, }).map(e => ({ name: e.date, value: e.balance })) + const firstNonEmptyDay = find(allBalances, e => e.value) + const sinceBalance = firstNonEmptyDay ? firstNonEmptyDay.value : 0 + return { allBalances, totalBalance: last(allBalances).value, - sinceBalance: first(allBalances).value, + sinceBalance, } } diff --git a/static/i18n/en/time.yml b/static/i18n/en/time.yml index 2cf41275..ce60c898 100644 --- a/static/i18n/en/time.yml +++ b/static/i18n/en/time.yml @@ -3,4 +3,8 @@ week: Week month: Month year: Year -since: since one {{since}} +since: + day: since a day + week: since a week + month: since a month + year: since a year