ln-accounting 10.0.7 → 10.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/esplora/get_esplora_vout.js +0 -1
  3. package/package.json +23 -8
  4. package/report/get_accounting_report.js +4 -1
  5. package/.gitattributes +0 -1
  6. package/.tm_properties +0 -1
  7. package/.travis.yml +0 -15
  8. package/blockstream/get_blockstream_tx.js +0 -94
  9. package/blockstream/get_blockstream_vout.js +0 -80
  10. package/blockstream/index.js +0 -4
  11. package/test/blockstream/test_get_blockstream_tx.js +0 -111
  12. package/test/fiat/test_get_coincap_historic_rate.js +0 -86
  13. package/test/fiat/test_get_coindesk_historic_rate.js +0 -80
  14. package/test/fiat/test_get_coingecko_historic_rate.js +0 -89
  15. package/test/fiat/test_get_fiat_values.js +0 -74
  16. package/test/fiat/test_get_historic_rate.js +0 -77
  17. package/test/harmony/test_categorize_records.js +0 -156
  18. package/test/harmony/test_chain_fees_as_records.js +0 -40
  19. package/test/harmony/test_chain_receives_as_records.js +0 -73
  20. package/test/harmony/test_chain_sends_as_records.js +0 -55
  21. package/test/harmony/test_formatted_notes.js +0 -32
  22. package/test/harmony/test_forwards_as_records.js +0 -52
  23. package/test/harmony/test_harmonize.js +0 -24
  24. package/test/harmony/test_invoices_as_records.js +0 -77
  25. package/test/harmony/test_notes_for_chain_transaction.js +0 -43
  26. package/test/harmony/test_payments_as_records.js +0 -159
  27. package/test/harmony/test_records_with_fiat.js +0 -112
  28. package/test/records/test_get_all_invoices.js +0 -105
  29. package/test/records/test_get_all_payments.js +0 -274
  30. package/test/report/test_parse_amount.js +0 -57
@@ -1,74 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const {rejects} = require('node:assert').strict;
3
- const test = require('node:test');
4
-
5
- const {getFiatValues} = require('./../../fiat/');
6
-
7
- const date = new Date().toISOString();
8
-
9
- const tests = [
10
- {
11
- args: {},
12
- description: 'Currency code is required',
13
- error: [400, 'ExpectedCurrencyToGetFiatValues'],
14
- },
15
- {
16
- args: {currency: 'BTC'},
17
- description: 'Dates are required',
18
- error: [400, 'ExpectedDatesToGetFiatValues'],
19
- },
20
- {
21
- args: {currency: 'BTC', dates: [date]},
22
- description: 'Fiat type is required',
23
- error: [400, 'ExpectedFiatTypeToGetFiatValues'],
24
- },
25
- {
26
- args: {currency: 'BTC', dates: [date], fiat: 'USD'},
27
- description: 'Rate method or request function is required',
28
- error: [400, 'ExpectedRateMethodOrRequestMethodToGetFiat'],
29
- },
30
- {
31
- args: {
32
- currency: 'BTC',
33
- dates: [date],
34
- fiat: 'USD',
35
- rate: ({}, cbk) => cbk(['err']),
36
- },
37
- description: 'Rate method errors are passed back',
38
- error: ['err'],
39
- },
40
- {
41
- args: {
42
- currency: 'BTC',
43
- dates: [date],
44
- fiat: 'USD',
45
- rate: ({}, cbk) => cbk(null, {cents: 123456}),
46
- },
47
- description: 'Get historic fiat rates',
48
- expected: {rates: [{date, cents: 123456}]},
49
- },
50
- {
51
- args: {
52
- currency: 'BTC',
53
- dates: [date, date],
54
- fiat: 'USD',
55
- rate: ({}, cbk) => cbk(null, {cents: 123456}),
56
- },
57
- description: 'Get historic fiat rates when the rate is already got',
58
- expected: {rates: [{date, cents: 123456}, {date, cents: 123456}]},
59
- },
60
- ];
61
-
62
- tests.forEach(({args, description, error, expected}) => {
63
- return test(description, async () => {
64
- if (!!error) {
65
- await rejects(getFiatValues(args), error, 'Got expected error');
66
- } else {
67
- const {rates} = await getFiatValues(args);
68
-
69
- deepEqual(rates, expected.rates, 'Rates returned');
70
- }
71
-
72
- return;
73
- });
74
- });
@@ -1,77 +0,0 @@
1
- const {equal} = require('node:assert').strict;
2
- const {rejects} = require('node:assert').strict;
3
- const test = require('node:test');
4
-
5
- const getHistoricRate = require('./../../fiat/get_historic_rate');
6
-
7
- const date = new Date().toISOString();
8
-
9
- const api = ({}, cbk) => {
10
- return cbk(null, null, {market_data: {current_price: {usd: 12.34}}});
11
- };
12
-
13
- const makeArgs = overrides => {
14
- const args = {
15
- date: new Date().toISOString(),
16
- currency: 'BTC',
17
- fiat: 'USD',
18
- rates: {},
19
- request: ({qs}, cbk) => api({qs}, cbk),
20
- };
21
-
22
- Object.keys(overrides).forEach(k => args[k] = overrides[k]);
23
-
24
- return args;
25
- };
26
-
27
- const tests = [
28
- {
29
- args: makeArgs({currency: undefined}),
30
- description: 'A currency code is required',
31
- error: [400, 'ExpectedCurrencyToGetHistoricRate'],
32
- },
33
- {
34
- args: makeArgs({date: undefined}),
35
- description: 'A date is required',
36
- error: [400, 'ExpectedDateToGetHistoricRate'],
37
- },
38
- {
39
- args: makeArgs({fiat: undefined}),
40
- description: 'A fiat type is required to get historic rate',
41
- error: [400, 'ExpectedFiatToGetHistoricRate'],
42
- },
43
- {
44
- args: makeArgs({rates: undefined}),
45
- description: 'Past rates are required to get historic rate',
46
- error: [400, 'ExpectedRatesToGetHistoricRate'],
47
- },
48
- {
49
- args: makeArgs({request: undefined}),
50
- description: 'A request function is required to get historic rate',
51
- error: [400, 'ExpectedRequestFunctionToGetHistoricRate'],
52
- },
53
- {
54
- args: makeArgs({provider: 'provider'}),
55
- description: 'A known rate provider is required to get historic rate',
56
- error: [400, 'ExpectedKnownRateProviderToGetHistoricRate'],
57
- },
58
- {
59
- args: makeArgs({}),
60
- description: 'Get historic fiat rates',
61
- expected: {cents: 1234},
62
- },
63
- ];
64
-
65
- tests.forEach(({args, description, error, expected}) => {
66
- return test(description, async () => {
67
- if (!!error) {
68
- await rejects(getHistoricRate(args), error, 'Gote expected error');
69
- } else {
70
- const {cents} = await getHistoricRate(args);
71
-
72
- equal(cents, expected.cents, 'Rate returned');
73
- }
74
-
75
- return;
76
- });
77
- });
@@ -1,156 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const {equal} = require('node:assert').strict;
3
- const test = require('node:test');
4
- const {throws} = require('node:assert').strict;
5
-
6
- const {categorizeRecords} = require('./../../harmony');
7
-
8
- const tests = [
9
- {
10
- args: {
11
- records: [
12
- {
13
- amount: 1,
14
- asset: 'BTC',
15
- category: 'payments',
16
- created_at: '2019-07-19T03:31:39.916Z',
17
- external_id: 'external_id',
18
- from_id: 'from_id',
19
- id: 'id',
20
- notes: 'notes',
21
- to_id: 'to_id',
22
- type: 'spend',
23
- },
24
- {
25
- amount: 1,
26
- asset: 'BTC',
27
- category: 'payments',
28
- created_at: '2019-07-20T03:31:39.916Z',
29
- external_id: 'external_id',
30
- from_id: 'from_id',
31
- id: 'id',
32
- notes: 'notes',
33
- to_id: 'to_id',
34
- type: 'spend',
35
- },
36
- ],
37
- },
38
- description: 'Categorize records',
39
- expected: {
40
- payments: [
41
- {
42
- amount: 1,
43
- asset: 'BTC',
44
- category: 'payments',
45
- created_at: '2019-07-19T03:31:39.916Z',
46
- external_id: 'external_id',
47
- from_id: 'from_id',
48
- id: 'id',
49
- notes: 'notes',
50
- to_id: 'to_id',
51
- type: 'spend',
52
- },
53
- {
54
- amount: 1,
55
- asset: 'BTC',
56
- category: 'payments',
57
- created_at: '2019-07-20T03:31:39.916Z',
58
- external_id: 'external_id',
59
- from_id: 'from_id',
60
- id: 'id',
61
- notes: 'notes',
62
- to_id: 'to_id',
63
- type: 'spend',
64
- },
65
- ],
66
- payments_csv: [
67
- '"Amount","Asset","Date & Time","Fiat Amount","From ID","Network ID","Notes","To ID","Transaction ID","Type"',
68
- '1,"BTC","2019-07-19T03:31:39.916Z",,"from_id","external_id","notes","to_id","id","spend"',
69
- '1,"BTC","2019-07-20T03:31:39.916Z",,"from_id","external_id","notes","to_id","id","spend"',
70
- ].join('\n'),
71
- },
72
- }, {
73
- args: {
74
- records: [
75
- {
76
- amount: 1,
77
- asset: 'BTC',
78
- category: 'payments',
79
- created_at: '2019-07-21T03:31:39.916Z',
80
- external_id: 'external_id',
81
- from_id: 'from_id',
82
- id: 'id',
83
- notes: 'notes',
84
- to_id: 'to_id',
85
- type: 'spend',
86
- },
87
- {
88
- amount: 1,
89
- asset: 'BTC',
90
- category: 'payments',
91
- created_at: '2019-07-20T03:31:39.916Z',
92
- external_id: 'external_id',
93
- from_id: 'from_id',
94
- id: 'id',
95
- notes: 'notes',
96
- to_id: 'to_id',
97
- type: 'spend',
98
- },
99
- ],
100
- },
101
- description: 'Categorize records out of order',
102
- expected: {
103
- payments: [
104
- {
105
- amount: 1,
106
- asset: 'BTC',
107
- category: 'payments',
108
- created_at: '2019-07-20T03:31:39.916Z',
109
- external_id: 'external_id',
110
- from_id: 'from_id',
111
- id: 'id',
112
- notes: 'notes',
113
- to_id: 'to_id',
114
- type: 'spend',
115
- },
116
- {
117
- amount: 1,
118
- asset: 'BTC',
119
- category: 'payments',
120
- created_at: '2019-07-21T03:31:39.916Z',
121
- external_id: 'external_id',
122
- from_id: 'from_id',
123
- id: 'id',
124
- notes: 'notes',
125
- to_id: 'to_id',
126
- type: 'spend',
127
- },
128
- ],
129
- payments_csv: [
130
- '"Amount","Asset","Date & Time","Fiat Amount","From ID","Network ID","Notes","To ID","Transaction ID","Type"',
131
- '1,"BTC","2019-07-20T03:31:39.916Z",,"from_id","external_id","notes","to_id","id","spend"',
132
- '1,"BTC","2019-07-21T03:31:39.916Z",,"from_id","external_id","notes","to_id","id","spend"',
133
- ].join('\n'),
134
- },
135
- },
136
- {
137
- args: {},
138
- description: 'Records are required',
139
- error: 'ExpectedRecordsArrayToCategorize',
140
- },
141
- ];
142
-
143
- tests.forEach(({args, description, error, expected}) => {
144
- return test(description, (t, end) => {
145
- if (!!error) {
146
- throws(() => categorizeRecords(args), new Error(error), 'Got error');
147
- } else {
148
- const categorized = categorizeRecords(args);
149
-
150
- deepEqual(categorized.payments, expected.payments, 'Categorized');
151
- equal(categorized.payments_csv, expected.payments_csv, 'Categorize csv');
152
- }
153
-
154
- return end();
155
- });
156
- });
@@ -1,40 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const {chainFeesAsRecords} = require('./../../harmony');
5
-
6
- const date = new Date().toISOString();
7
-
8
- const tests = [
9
- {
10
- args: {
11
- transactions: [{
12
- created_at: date,
13
- fee: 1,
14
- id: 'id',
15
- is_outgoing: true,
16
- }]
17
- },
18
- description: 'Chain fees as records',
19
- expected: {
20
- records: [{
21
- amount: -1,
22
- category: 'chain_fees',
23
- created_at: date,
24
- id: 'id:fee',
25
- notes: '[Chain Fee]',
26
- type: 'fee:network',
27
- }],
28
- },
29
- },
30
- ];
31
-
32
- tests.forEach(({args, description, expected}) => {
33
- return test(description, (t, end) => {
34
- const {records} = chainFeesAsRecords(args);
35
-
36
- deepEqual(records, expected.records, 'Fees formatted as records');
37
-
38
- return end();
39
- });
40
- });
@@ -1,73 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
- const {throws} = require('node:assert').strict;
4
-
5
- const {chainReceivesAsRecords} = require('./../../harmony');
6
-
7
- const date = new Date().toISOString();
8
-
9
- const tests = [
10
- {
11
- args: {
12
- channel_transaction_ids: ['funding_tx'],
13
- transactions: [
14
- {
15
- created_at: new Date().toISOString(),
16
- id: 'funding_tx',
17
- is_confirmed: true,
18
- is_outgoing: true,
19
- output_addresses: ['out_address'],
20
- tokens: 1,
21
- },
22
- {
23
- created_at: date,
24
- id: 'id',
25
- is_confirmed: true,
26
- is_outgoing: false,
27
- output_addresses: ['address'],
28
- tokens: 1,
29
- },
30
- ]
31
- },
32
- description: 'Chain receives as records',
33
- expected: {
34
- records: [{
35
- amount: 1,
36
- category: 'chain_receives',
37
- created_at: date,
38
- id: 'id',
39
- notes: 'Outputs to address',
40
- type: 'transfer:deposit',
41
- }],
42
- },
43
- },
44
- {
45
- args: null,
46
- description: 'Arguments expected',
47
- error: 'ExpectedArgumentsToMapReceiveRecords',
48
- },
49
- {
50
- args: {},
51
- description: 'Channel transaction ids array expected',
52
- error: 'ExpectedChannelTransactionIdsArrayToMapReceiveRecords',
53
- },
54
- {
55
- args: {channel_transaction_ids: []},
56
- description: 'Transaction info array expected',
57
- error: 'ExpectedTransactionsArrayToMapToReceiveRecords',
58
- },
59
- ];
60
-
61
- tests.forEach(({args, description, error, expected}) => {
62
- return test(description, (t, end) => {
63
- if (!!error) {
64
- throws(() => chainReceivesAsRecords(args), new Error(error), 'Got err');
65
- } else {
66
- const {records} = chainReceivesAsRecords(args);
67
-
68
- deepEqual(records, expected.records, 'Fees formatted as records');
69
- }
70
-
71
- return end();
72
- });
73
- });
@@ -1,55 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const {chainSendsAsRecords} = require('./../../harmony');
5
-
6
- const date = new Date().toISOString();
7
-
8
- const tests = [
9
- {
10
- args: {
11
- channel_transaction_ids: ['funding_tx'],
12
- transactions: [
13
- {
14
- created_at: new Date().toISOString(),
15
- fee: 1,
16
- id: 'funding_tx',
17
- is_confirmed: true,
18
- is_outgoing: true,
19
- output_addresses: ['out_address'],
20
- tokens: 2,
21
- },
22
- {
23
- created_at: date,
24
- fee: 1,
25
- id: 'id',
26
- is_confirmed: true,
27
- is_outgoing: true,
28
- output_addresses: ['address'],
29
- tokens: 2,
30
- },
31
- ]
32
- },
33
- description: 'Chain sends as records',
34
- expected: {
35
- records: [{
36
- amount: -1,
37
- category: 'chain_sends',
38
- created_at: date,
39
- id: 'id',
40
- notes: 'Outputs to address',
41
- type: 'transfer:withdraw',
42
- }],
43
- },
44
- },
45
- ];
46
-
47
- tests.forEach(({args, description, expected}) => {
48
- return test(description, (t, end) => {
49
- const {records} = chainSendsAsRecords(args);
50
-
51
- deepEqual(records, expected.records, 'Fees formatted as records');
52
-
53
- return end();
54
- });
55
- });
@@ -1,32 +0,0 @@
1
- const {equal} = require('node:assert').strict;
2
- const test = require('node:test');
3
- const {throws} = require('node:assert').strict;
4
-
5
- const formattedNotes = require('./../../harmony/formatted_notes');
6
-
7
- const tests = [
8
- {
9
- args: {notes: 'notes'},
10
- description: 'Notes formatted',
11
- expected: {notes: 'notes'},
12
- },
13
- {
14
- args: {notes: ''},
15
- description: 'Empty notes formatted',
16
- expected: {notes: ''},
17
- },
18
- ];
19
-
20
- tests.forEach(({args, description, error, expected}) => {
21
- return test(description, (t, end) => {
22
- if (!!error) {
23
- throws(() => formattedNotes(args), new Error(error), 'Got error');
24
- } else {
25
- const {notes} = formattedNotes(args);
26
-
27
- equal(notes, expected.notes, 'Got formatted notes');
28
- }
29
-
30
- return end();
31
- });
32
- });
@@ -1,52 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
- const {throws} = require('node:assert').strict;
4
-
5
- const {forwardsAsRecords} = require('./../../harmony');
6
-
7
- const date = new Date().toISOString();
8
-
9
- const tests = [
10
- {
11
- args: {
12
- forwards: [{
13
- created_at: date,
14
- fee: 1,
15
- incoming_channel: 'incoming',
16
- outgoing_channel: 'outgoing',
17
- tokens: 2,
18
- }]
19
- },
20
- description: 'Forwards as records',
21
- expected: {
22
- records: [{
23
- amount: 1,
24
- category: 'forwards',
25
- created_at: date,
26
- from_id: 'incoming',
27
- notes: '2',
28
- to_id: 'outgoing',
29
- type: 'income',
30
- }],
31
- },
32
- },
33
- {
34
- args: {},
35
- description: 'Array of forwards required',
36
- error: 'ExpectedArrayOfForwardsToFormatAsAccountingRecords',
37
- },
38
- ];
39
-
40
- tests.forEach(({args, description, error, expected}) => {
41
- return test(description, (t, end) => {
42
- if (!!error) {
43
- throws(() => forwardsAsRecords(args), new Error(error), 'Got error');
44
- } else {
45
- const {records} = forwardsAsRecords(args);
46
-
47
- deepEqual(records, expected.records, 'Forwards formatted as records');
48
- }
49
-
50
- return end();
51
- });
52
- });
@@ -1,24 +0,0 @@
1
- const test = require('node:test');
2
- const {throws} = require('node:assert').strict;
3
-
4
- const {harmonize} = require('./../../harmony');
5
-
6
- const tests = [
7
- {
8
- args: {},
9
- description: 'Records are required',
10
- error: 'ExpectedRecordsToConvertToHarmonyFormat',
11
- },
12
- ];
13
-
14
- tests.forEach(({args, description, error}) => {
15
- return test(description, (t, end) => {
16
- if (!!error) {
17
- throws(() => harmonize(args), new Error(error), 'Got error');
18
- } else {
19
- harmonize(args);
20
- }
21
-
22
- return end();
23
- });
24
- });
@@ -1,77 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
- const {throws} = require('node:assert').strict;
4
-
5
- const {invoicesAsRecords} = require('./../../harmony');
6
-
7
- const date = new Date().toISOString();
8
-
9
- const tests = [
10
- {
11
- args: {
12
- invoices: [{
13
- confirmed_at: date,
14
- created_at: date,
15
- description: 'description',
16
- id: 'id',
17
- is_confirmed: true,
18
- payments: [],
19
- received: 1,
20
- }],
21
- },
22
- description: 'Invoices as records',
23
- expected: {
24
- records: [{
25
- amount: 1,
26
- category: 'invoices',
27
- created_at: date,
28
- id: 'id',
29
- notes: 'description',
30
- type: 'income',
31
- }],
32
- },
33
- },
34
- {
35
- args: {
36
- invoices: [{
37
- confirmed_at: date,
38
- created_at: date,
39
- description: '',
40
- id: 'id',
41
- is_confirmed: true,
42
- payments: [{messages: [{type: '5482373484'}]}],
43
- received: 1,
44
- }],
45
- },
46
- description: 'Push payment is represented',
47
- expected: {
48
- records: [{
49
- amount: 1,
50
- category: 'invoices',
51
- created_at: date,
52
- id: 'id',
53
- notes: '[Push Payment]',
54
- type: 'income',
55
- }],
56
- },
57
- },
58
- {
59
- args: {},
60
- description: 'Expects array of invoices',
61
- error: 'ExpectedArrayOfInvoicesToMapToAccountingRecords',
62
- }
63
- ];
64
-
65
- tests.forEach(({args, description, error, expected}) => {
66
- return test(description, (t, end) => {
67
- if (!!error) {
68
- throws(() => invoicesAsRecords(args), new Error(error), 'Got error');
69
- } else {
70
- const {records} = invoicesAsRecords(args);
71
-
72
- deepEqual(records, expected.records, 'Forwards formatted as records');
73
- }
74
-
75
- return end();
76
- });
77
- });