forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accounting.d.ts
79 lines (62 loc) · 3.95 KB
/
accounting.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Type definitions for accounting.js 0.3.2
// Project: http://josscrowcroft.github.io/accounting.js/
// Definitions by: Sergey Gerasimov <https://github.com/gerich-home/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface IAccountingCurrencyFormat {
pos: string; // for positive values, eg. "$ 1.00"
neg?: string; // for negative values, eg. "$ (1.00)"
zero?: string; // for zero values, eg. "$ --"
}
interface IAccountingCurrencySettings<TFormat> {
symbol?: string; // default currency symbol is '$'
format?: TFormat; // controls output: %s = symbol, %v = value/number
decimal?: string; // decimal point separator
thousand?: string; // thousands separator
precision?: number // decimal places
}
interface IAccountingNumberSettings {
precision?: number; // default precision on numbers is 0
thousand?: string;
decimal?: string;
}
interface IAccountingSettings {
currency: IAccountingCurrencySettings<any>; // IAccountingCurrencySettings<string> or IAccountingCurrencySettings<IAccountingCurrencyFormat>
number: IAccountingNumberSettings;
}
interface IAccountingStatic {
// format any number into currency
formatMoney(number: number, symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string;
formatMoney(number: number, options: IAccountingCurrencySettings<string>): string;
formatMoney(number: number, options: IAccountingCurrencySettings<IAccountingCurrencyFormat>): string;
formatMoney(numbers: number[], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string[];
formatMoney(numbers: number[], options: IAccountingCurrencySettings<string>): string[];
formatMoney(numbers: number[], options: IAccountingCurrencySettings<IAccountingCurrencyFormat>): string[];
// generic case (any array of numbers)
formatMoney(numbers: any[], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): any[];
formatMoney(numbers: any[], options: IAccountingCurrencySettings<string>): any[];
formatMoney(numbers: any[], options: IAccountingCurrencySettings<IAccountingCurrencyFormat>): any[];
// format a list of values for column-display
formatColumn(numbers: number[], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string[];
formatColumn(numbers: number[], options: IAccountingCurrencySettings<string>): string[];
formatColumn(numbers: number[], options: IAccountingCurrencySettings<IAccountingCurrencyFormat>): string[];
formatColumn(numbers: number[][], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string[][];
formatColumn(numbers: number[][], options: IAccountingCurrencySettings<string>): string[][];
formatColumn(numbers: number[][], options: IAccountingCurrencySettings<IAccountingCurrencyFormat>): string[][];
// format a number with custom precision and localisation
formatNumber(number: number, precision?: number, thousand?: string, decimal?: string): string;
formatNumber(number: number, options: IAccountingNumberSettings): string;
formatNumber(number: number[], precision?: number, thousand?: string, decimal?: string): string[];
formatNumber(number: number[], options: IAccountingNumberSettings): string[];
formatNumber(number: any[], precision?: number, thousand?: string, decimal?: string): any[];
formatNumber(number: any[], options: IAccountingNumberSettings): any[];
// better rounding for floating point numbers
toFixed(number: number, precision?: number): string;
// get a value from any formatted number/currency string
unformat(string: string, decimal?: string): number;
// settings object that controls default parameters for library methods
settings: IAccountingSettings;
}
declare var accounting: IAccountingStatic;
declare module "accounting" {
export = accounting;
}