Skip to content

Commit a50046b

Browse files
committed
feat(config): adds currency code as config option
1 parent 01a96f5 commit a50046b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ In case you want to use multiple mite accounts please open up a [change request]
7878

7979
## Advanced Configuration Options
8080

81+
- `currency`
82+
defines the currency used for displaying money values
8183
- `customersColumns`
8284
defines the default columns to be used when running `mite customers list`.
8385
- `listColumns`

source/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const usersCommand = require('./lib/commands/users');
1919
nconf.file(configFilename);
2020

2121
nconf.defaults({
22+
currency: '€',
2223
applicationName: `mite-cli/${pkg.version}`,
2324
customersColumns: customersCommand.columns.default,
2425
listColumns: listCommand.columns.default,

source/lib/formater.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ const chalk = require('chalk');
44

55
const { USER_ROLES, BUDGET_TYPE } = require('./constants');
66

7-
// @TODO use currency from getAccount endpoint
8-
const DEFAULT_CURRENCY = '€';
9-
107
module.exports = {
118
BUDGET_TYPE: BUDGET_TYPE,
12-
CURRENCY: DEFAULT_CURRENCY,
139

1410
note(
1511
note,
@@ -90,15 +86,18 @@ module.exports = {
9086
},
9187

9288
budget(type, value) {
89+
// @TODO resolve circular dependency
90+
const config = require('./../config');
91+
const CURRENCY = config.get().currency;
9392
switch(type) {
9493
case BUDGET_TYPE.MINUTES_PER_MONTH:
9594
return this.minutesToDuration(value) + ' h/m';
9695
case BUDGET_TYPE.MINUTES:
9796
return this.minutesToDuration(value) + ' h';
9897
case BUDGET_TYPE.CENTS:
99-
return this.price(value / 100) + ' ' + this.CURRENCY;
98+
return this.price(value / 100) + ' ' + CURRENCY;
10099
case BUDGET_TYPE.CENTS_PER_MONTH:
101-
return this.price(value / 100) + ' ' + this.CURRENCY + '/m';
100+
return this.price(value / 100) + ' ' + CURRENCY + '/m';
102101
default:
103102
throw new Error(`Unknown budget format type: "${type}"`);
104103
}

0 commit comments

Comments
 (0)