Skip to content

create export csv for taxbit #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions pages/admin/pro/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const dateFormatters = {
const ss = pad(date.getUTCSeconds())

return `${mm}/${dd}/${yyyy} ${hh}:${min}:${ss}`
},
TaxBit: (timestamp) => {
// ISO format: YYYY-MM-DDTHH:MM:SS.000Z (same as Koinly)
return new Date(timestamp * 1000).toISOString()
}
}

Expand Down Expand Up @@ -118,9 +122,9 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
headers: [
{ label: 'Date', key: 'timestampExport' },
{ label: 'Sent Amount', key: 'sentAmount' },
{ label: 'Sent Currency', key: 'sentCurrency' },
{ label: 'Sent Currency', key: 'koinlySentCurrency' },
{ label: 'Received Amount', key: 'receivedAmount' },
{ label: 'Received Currency', key: 'receivedCurrency' },
{ label: 'Received Currency', key: 'koinlyReceivedCurrency' },
{ label: 'Fee Amount', key: 'txFeeNumber' },
{ label: 'Fee Currency', key: 'txFeeCurrencyCode' },
{ label: 'Net Worth Amount', key: 'amountInFiats.' + selectedCurrency },
Expand All @@ -145,6 +149,31 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
{ label: 'Description (Optional)', key: 'memo' },
{ label: 'TxHash (Optional)', key: 'hash' }
]
},
{
platform: 'TaxBit',
headers: [
{ label: 'timestamp', key: 'timestampExport' },
{ label: 'txid', key: 'hash' },
{ label: 'source_name', key: '' },
{ label: 'from_wallet_address', key: 'address' },
{ label: 'to_wallet_address', key: '' },
{ label: 'category', key: 'taxBitTxType' },
{ label: 'in_currency', key: 'receivedCurrency' },
{ label: 'in_amount', key: 'receivedAmount' },
{ label: 'in_currency_fiat', key: 'netWorthCurrency' },
{ label: 'in_amount_fiat', key: 'amountInFiats.' + selectedCurrency },
{ label: 'out_currency', key: 'sentCurrency' },
{ label: 'out_amount', key: 'sentAmount' },
{ label: 'out_currency_fiat', key: 'netWorthCurrency' },
{ label: 'out_amount_fiat', key: 'amountInFiats.' + selectedCurrency },
{ label: 'fee_currency', key: 'txFeeCurrencyCode' },
{ label: 'fee', key: 'txFeeNumber' },
{ label: 'fee_currency_fiat', key: selectedCurrency },
{ label: 'fee_fiat', key: 'txFeeInFiats.' + selectedCurrency },
{ label: 'memo', key: 'memo' },
{ label: 'status', key: '' }
]
}
],
[selectedCurrency]
Expand Down Expand Up @@ -324,10 +353,14 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
res.activities[i].timestampExport = new Date(res.activities[i].timestamp * 1000).toISOString()

res.activities[i].sentAmount = sending ? res.activities[i].amountNumber : ''
res.activities[i].sentCurrency = sending ? scvCurrency : ''
res.activities[i].sentCurrency = sending ? currency : ''

res.activities[i].receivedAmount = !sending ? res.activities[i].amountNumber : ''
res.activities[i].receivedCurrency = !sending ? scvCurrency : ''
res.activities[i].receivedCurrency = !sending ? currency : ''

// For Koinly platform
res.activities[i].koinlySentCurrency = sending ? scvCurrency : ''
res.activities[i].koinlyReceivedCurrency = !sending ? scvCurrency : ''

res.activities[i].netWorthCurrency = selectedCurrency.toUpperCase()

Expand All @@ -336,6 +369,9 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur

// For CoinLedger platform
res.activities[i].coinLedgerTxType = res.activities[i].amountNumber > 0 ? 'Deposit' : 'Withdrawal'

// For TaxBit platform
res.activities[i].taxBitTxType = res.activities[i].amountNumber > 0 ? 'Buy' : 'Sell'
}
setData(res) // last request data
if (options?.marker) {
Expand Down Expand Up @@ -524,7 +560,8 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
setValue={setPlatformCSVExport}
optionsList={[
{ value: 'Koinly', label: 'Koinly' },
{ value: 'CoinLedger', label: 'CoinLedger' }
{ value: 'CoinLedger', label: 'CoinLedger' },
{ value: 'TaxBit', label: 'TaxBit' }
]}
/>
<button className="dropdown-btn" onClick={() => setSortMenuOpen(!sortMenuOpen)}>
Expand Down