diff --git a/pages/admin/pro/history.js b/pages/admin/pro/history.js index cce33ed3..401da4c1 100644 --- a/pages/admin/pro/history.js +++ b/pages/admin/pro/history.js @@ -83,6 +83,11 @@ const dateFormatters = { // Format: dd.mm.yyyy HH:MM:SS in UTC const { dd, mm, yyyy, hh, min, ss } = timePieces(timestamp) return `${dd}.${mm}.${yyyy} ${hh}:${min}:${ss}` + }, + CryptoTax: (timestamp) => { + // Format: YYYY-MM-DD HH:mm:ss + const { yyyy, mm, dd, hh, min, ss } = timePieces(timestamp) + return `${yyyy}-${mm}-${dd} ${hh}:${min}:${ss}` } } @@ -116,6 +121,12 @@ const processDataForExport = (activities, platform) => { : Math.abs(activity.amountNumber) <= activity.txFeeNumber ? 'Other Fee' : 'Deposit' + } else if (platform === 'CryptoTax') { + processedActivity.cryptoTaxTxType = !sending + ? 'buy' + : Math.abs(activity.amountNumber) <= activity.txFeeNumber + ? 'fee' + : 'sell' } return processedActivity @@ -200,6 +211,26 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur { label: 'Sell Value in Account Currency', key: '' }, { label: 'Liquidity pool', key: '' } ] + }, + { + platform: 'CryptoTax', + headers: [ + { label: 'Timestamp (UTC)', key: 'timestampExport' }, + { label: 'Type', key: 'type' }, + { 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: 'counterparty' }, + { label: 'To (Optional)', key: 'address' }, + { 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: '' } + ] } ], [selectedCurrency] @@ -375,6 +406,23 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur //sanitize memos for CSV res.activities[i].memo = res.activities[i].memo?.replace(/"/g, "'") || '' + + // For CryptoTax platform + 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) { @@ -564,7 +612,8 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur optionsList={[ { value: 'Koinly', label: 'Koinly' }, { value: 'CoinLedger', label: 'CoinLedger' }, - { value: 'CoinTracking', label: 'CoinTracking' } + { value: 'CoinTracking', label: 'CoinTracking' }, + { value: 'CryptoTax', label: 'CryptoTax' } ]} />