Skip to content

Commit d2e821e

Browse files
juddydevihomp
andauthored
add export csv blockpit (#262)
* add export csv blockpit * fix IDs * update export csv for blockpit * update export csv blockpit --------- Co-authored-by: Viacheslav Bakshaev <[email protected]>
1 parent f30a2f4 commit d2e821e

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

pages/admin/pro/history.js

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ const dateFormatters = {
9191
// Format: MM/DD/YY HH:MM
9292
const { mm, dd, yyyy, hh, min } = timePieces(timestamp)
9393
return `${mm}/${dd}/${yyyy} ${hh}:${min}`
94+
},
95+
BlockPit: (timestamp) => {
96+
// Format: DD.MM.YYYY HH:MM:SS in UTC
97+
const { dd, mm, yyyy, hh, min, ss } = timePieces(timestamp)
98+
return `${dd}.${mm}.${yyyy} ${hh}:${min}:${ss}`
9499
}
95100
}
96101

@@ -132,6 +137,21 @@ const processDataForExport = (activities, platform) => {
132137
processedActivity.type = sending ? 'Sell' : 'Buy'
133138
} else if (platform === 'TokenTax') {
134139
processedActivity.type = sending ? 'Withdrawal' : 'Deposit'
140+
} else if (platform === 'BlockPit') {
141+
processedActivity.type = sending
142+
? 'Withdrawal'
143+
: Math.abs(activity.amountNumber) <= activity.txFeeNumber
144+
? 'Fee'
145+
: 'Deposit'
146+
// don't include this fee amount in the fee column for type 'fee'
147+
if (processedActivity.type === 'Fee') {
148+
processedActivity.sentAmount = processedActivity.txFeeNumber
149+
processedActivity.sentCurrency = processedActivity.txFeeCurrencyCode
150+
processedActivity.txFeeCurrencyCode = ''
151+
processedActivity.txFeeNumber = ''
152+
processedActivity.receivedAmount = ''
153+
processedActivity.receivedCurrency = ''
154+
}
135155
}
136156

137157
return processedActivity
@@ -143,7 +163,8 @@ const platformList = [
143163
{ value: 'CoinLedger', label: 'CoinLedger' },
144164
{ value: 'CoinTracking', label: 'CoinTracking' },
145165
{ value: 'TaxBit', label: 'TaxBit' },
146-
{ value: 'TokenTax', label: 'TokenTax' }
166+
{ value: 'TokenTax', label: 'TokenTax' },
167+
{ value: 'BlockPit', label: 'BlockPit' }
147168
]
148169

149170
export default function History({ queryAddress, selectedCurrency, setSelectedCurrency }) {
@@ -265,6 +286,22 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
265286
{ label: 'Comment', key: 'memo' },
266287
{ label: 'Date', key: 'timestampExport' }
267288
]
289+
},
290+
{
291+
platform: 'BlockPit',
292+
headers: [
293+
{ label: 'Date (UTC)', key: 'timestampExport' },
294+
{ label: 'Integration Name', key: 'platform' },
295+
{ label: 'Label', key: 'type' },
296+
{ label: 'Outgoing Asset', key: 'sentCurrency' },
297+
{ label: 'Outgoing Amount', key: 'sentAmount' },
298+
{ label: 'Incoming Asset', key: 'receivedCurrency' },
299+
{ label: 'Incoming Amount', key: 'receivedAmount' },
300+
{ label: 'Fee Asset (optional)', key: 'txFeeCurrencyCode' },
301+
{ label: 'Fee Amount (optional)', key: 'txFeeNumber' },
302+
{ label: 'Comment (optional)', key: 'memo' },
303+
{ label: 'Trx. ID (optional)', key: 'hash' }
304+
]
268305
}
269306
],
270307
[selectedCurrency]
@@ -635,6 +672,7 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
635672
}
636673
filename={'export ' + platformCSVExport + ' ' + new Date().toISOString() + '.csv'}
637674
className={'button-action' + (!(activities?.length > 0) ? ' disabled' : '')}
675+
uFEFF={platformCSVExport === 'BlockPit' ? false : undefined}
638676
>
639677
<DownloadIcon /> CSV for {platformCSVExport}
640678
</CSVLink>
@@ -774,4 +812,4 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
774812
</div>
775813
</>
776814
)
777-
}
815+
}

0 commit comments

Comments
 (0)