Skip to content

Commit 54e443e

Browse files
committed
fix: amount decimals csv
1 parent 483c0f9 commit 54e443e

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

utils/files.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
DEFAULT_PAYBUTTON_CSV_FILE_DELIMITER,
77
MAX_RECORDS_PER_FILE,
88
NETWORK_TICKERS,
9+
NETWORK_TICKERS_FROM_ID,
910
NetworkTickersType,
1011
PAYBUTTON_TRANSACTIONS_FILE_HEADERS,
1112
PRICE_API_DATE_FORMAT, RESPONSE_MESSAGES,
@@ -26,6 +27,7 @@ export interface TransactionFileData {
2627
currency: string
2728
address?: string
2829
notes: string
30+
newtworkId: number
2931
}
3032

3133
export interface FormattedTransactionFileData {
@@ -57,14 +59,15 @@ export const formatPaybuttonTransactionsFileData = (data: TransactionFileData):
5759
date,
5860
value,
5961
rate,
60-
currency
62+
newtworkId
6163
} = data
64+
const networkTicker = NETWORK_TICKERS_FROM_ID[newtworkId]
6265

6366
return {
6467
...data,
65-
amount: amount.toFixed(DECIMALS[currency]),
68+
amount: amount.toFixed(DECIMALS[networkTicker]),
6669
date: date.format(PRICE_API_DATE_FORMAT),
67-
value: value.toFixed(2),
70+
value: value.toFixed(DECIMALS[networkTicker]),
6871
rate: rate.toFixed(14)
6972
}
7073
}
@@ -141,6 +144,7 @@ export const collapseSmallPayments = (
141144
rate,
142145
currency,
143146
address: DEFAULT_MULTI_VALUES_LINE_LABEL,
147+
newtworkId: tempGroup[0].address.networkId,
144148
notes
145149
} as TransactionFileData)
146150

@@ -162,7 +166,8 @@ export const collapseSmallPayments = (
162166
rate,
163167
currency,
164168
address: address.address,
165-
notes
169+
notes,
170+
newtworkId: address.networkId
166171
} as TransactionFileData)
167172
totalPaymentsTreated += 1
168173
}
@@ -234,7 +239,8 @@ const getPaybuttonTransactionsFileData = (transactions: TransactionsWithPaybutto
234239
rate,
235240
currency,
236241
address: address.address,
237-
notes: ''
242+
notes: '',
243+
newtworkId: address.networkId
238244
})
239245
})
240246
return paymentsFileData

0 commit comments

Comments
 (0)