Skip to content

Commit

Permalink
DIG-27962 viser valuta før sum for engelsk locale
Browse files Browse the repository at this point in the history
  • Loading branch information
Eivind Wikheim committed Oct 26, 2017
1 parent ed7f411 commit be3b470
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/util/format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import amountFormatter from 'nfe-amount-formatter';
import {currencyPostfix} from './types';
import { currencyAffixNOK } from './types';

const getWeightedSumOfDigits = (accountNumber) => {
const weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1];
Expand Down Expand Up @@ -27,10 +27,8 @@ export function accountFormatter(accountNumber) {
}

export function balanceWithCurrency(balance = '', locale, currencyCode) {
if (currencyCode && currencyCode !== "NOK") {
return `${amountFormatter(balance, locale)} ${currencyCode}`;
}

return `${amountFormatter(balance, locale)} ${currencyPostfix[locale]}`;
const amount = amountFormatter(balance, locale);
const currencyAffix = (currencyCode && currencyCode !== "NOK")? currencyCode : currencyAffixNOK[locale];
return (locale === 'en')? `${currencyAffix} ${amount}` : `${amount} ${currencyAffix}`;
}

2 changes: 1 addition & 1 deletion src/util/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const nb = 'nb';
export const en = 'en';
export const nn = 'nn';

export const currencyPostfix = {
export const currencyAffixNOK = {
[nb]: 'kr',
[nn]: 'kr',
[en]: 'NOK'
Expand Down

0 comments on commit be3b470

Please sign in to comment.