Skip to content
Merged
Changes from 2 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
75 changes: 70 additions & 5 deletions pages/admin/pro/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ const dateFormatters = {
const ss = pad(date.getUTCSeconds())

return `${mm}/${dd}/${yyyy} ${hh}:${min}:${ss}`
},
CryptoTax: (timestamp) => {
// Format: YYYY-MM-DD HH:mm:ss
const date = new Date(timestamp * 1000)

const pad = (n) => n.toString().padStart(2, '0')

const yyyy = date.getUTCFullYear()
const mm = pad(date.getUTCMonth() + 1)
const dd = pad(date.getUTCDate())

const hh = pad(date.getUTCHours())
const min = pad(date.getUTCMinutes())
const ss = pad(date.getUTCSeconds())

return `${yyyy}-${mm}-${dd} ${hh}:${min}:${ss}`
}
}

Expand Down Expand Up @@ -118,9 +134,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 +161,26 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
{ label: 'Description (Optional)', key: 'memo' },
{ label: 'TxHash (Optional)', key: 'hash' }
]
},
{
platform: 'CryptoTax',
headers: [
{ label: 'Timestamp (UTC)', key: 'timestampExport' },
{ label: 'Type', key: 'cryptoTaxTxType' },
{ label: 'Base Currency', key: 'baseCurrency' },
{ label: 'Base Amount', key: 'baseAmount' },
{ label: 'Quote Currency (Optional)', key: '' },
{ label: 'Quote Amount (Optional)', key: '' },
{ label: 'Fee Currency (Optional)', key: 'cryptoTaxFeeCurrencyCode' },
{ label: 'Fee Amount (Optional)', key: 'cryptoTaxFeeNumber' },
{ label: 'From (Optional)', key: '' },
{ label: 'To (Optional)', key: '' },
{ label: 'Blockchain (Optional)', key: '' },
{ label: 'ID (Optional)', key: 'hash' },
{ label: 'Description (Optional)', key: 'memo' },
{ label: 'Reference Price Per Unit (Optional)', key: '' },
{ label: 'Reference Price Currency (Optional)', key: '' }
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header configuration includes fields with empty key values. Consider providing explicit key names or removing these entries if they are not meant to map to data properties.

Suggested change
{ label: 'Quote Currency (Optional)', key: '' },
{ label: 'Quote Amount (Optional)', key: '' },
{ label: 'Fee Currency (Optional)', key: 'cryptoTaxFeeCurrencyCode' },
{ label: 'Fee Amount (Optional)', key: 'cryptoTaxFeeNumber' },
{ label: 'From (Optional)', key: '' },
{ label: 'To (Optional)', key: '' },
{ label: 'Blockchain (Optional)', key: '' },
{ label: 'ID (Optional)', key: 'hash' },
{ label: 'Description (Optional)', key: 'memo' },
{ label: 'Reference Price Per Unit (Optional)', key: '' },
{ label: 'Reference Price Currency (Optional)', key: '' }
// { label: 'Quote Currency (Optional)', key: '' }, // Removed as it does not map to any data property
// { label: 'Quote Amount (Optional)', key: '' }, // Removed as it does not map to any data property
{ label: 'Fee Currency (Optional)', key: 'cryptoTaxFeeCurrencyCode' },
{ label: 'Fee Amount (Optional)', key: 'cryptoTaxFeeNumber' },
// { label: 'From (Optional)', key: '' }, // Removed as it does not map to any data property
// { label: 'To (Optional)', key: '' }, // Removed as it does not map to any data property
// { label: 'Blockchain (Optional)', key: '' }, // Removed as it does not map to any data property
{ label: 'ID (Optional)', key: 'hash' },
{ label: 'Description (Optional)', key: 'memo' },
// { label: 'Reference Price Per Unit (Optional)', key: '' }, // Removed as it does not map to any data property
// { label: 'Reference Price Currency (Optional)', key: '' } // Removed as it does not map to any data property

Copilot uses AI. Check for mistakes.
]
}
],
[selectedCurrency]
Expand Down Expand Up @@ -324,10 +360,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 +376,30 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur

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

// For CryptoTax platform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it's specific for a platform, we shouldn't do it for everyone.
The code needs to be moved into the processDataForExport function

res.activities[i].cryptoTaxTxType =
res.activities[i].amountNumber > 0
? 'buy'
: Math.abs(res.activities[i].amountNumber) <= res.activities[i].txFeeNumber
? 'fee'
: 'sell'

res.activities[i].cryptoTaxFeeCurrencyCode = res.activities[i].txFeeCurrencyCode
res.activities[i].cryptoTaxFeeNumber = res.activities[i].txFeeNumber

if (res.activities[i].cryptoTaxTxType === 'buy') {
res.activities[i].baseCurrency = res.activities[i].receivedCurrency
res.activities[i].baseAmount = res.activities[i].receivedAmount
} else {
res.activities[i].baseCurrency = res.activities[i].sentCurrency
res.activities[i].baseAmount = res.activities[i].sentAmount
// don't include this fee amount in the fee column for type 'fee'
if (res.activities[i].cryptoTaxTxType === 'fee') {
res.activities[i].cryptoTaxFeeCurrencyCode = ''
res.activities[i].cryptoTaxFeeNumber = ''
}
}
}
setData(res) // last request data
if (options?.marker) {
Expand Down Expand Up @@ -524,7 +588,8 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
setValue={setPlatformCSVExport}
optionsList={[
{ value: 'Koinly', label: 'Koinly' },
{ value: 'CoinLedger', label: 'CoinLedger' }
{ value: 'CoinLedger', label: 'CoinLedger' },
{ value: 'CryptoTax', label: 'CryptoTax' }
]}
/>
<button className="dropdown-btn" onClick={() => setSortMenuOpen(!sortMenuOpen)}>
Expand Down