Skip to content

Commit 5b4a92e

Browse files
juddydevihomp
andauthored
create export csv for cryptotax (#263)
* create export csv for cryptotax * fix IDs * update export csv for cryptotax * update export csv cryptotax --------- Co-authored-by: Viacheslav Bakshaev <[email protected]>
1 parent d2e821e commit 5b4a92e

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

pages/admin/pro/history.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ const dateFormatters = {
9292
const { mm, dd, yyyy, hh, min } = timePieces(timestamp)
9393
return `${mm}/${dd}/${yyyy} ${hh}:${min}`
9494
},
95+
CryptoTax: (timestamp) => {
96+
// Format: YYYY-MM-DD HH:mm:ss
97+
const { yyyy, mm, dd, hh, min, ss } = timePieces(timestamp)
98+
return `${yyyy}-${mm}-${dd} ${hh}:${min}:${ss}`
99+
},
95100
BlockPit: (timestamp) => {
96101
// Format: DD.MM.YYYY HH:MM:SS in UTC
97102
const { dd, mm, yyyy, hh, min, ss } = timePieces(timestamp)
@@ -137,6 +142,28 @@ const processDataForExport = (activities, platform) => {
137142
processedActivity.type = sending ? 'Sell' : 'Buy'
138143
} else if (platform === 'TokenTax') {
139144
processedActivity.type = sending ? 'Withdrawal' : 'Deposit'
145+
} else if (platform === 'CryptoTax') {
146+
processedActivity.type = !sending
147+
? 'buy'
148+
: Math.abs(activity.amountNumber) <= activity.txFeeNumber
149+
? 'fee'
150+
: 'sell'
151+
152+
processedActivity.cryptoTaxFeeCurrencyCode = processedActivity.txFeeCurrencyCode
153+
processedActivity.cryptoTaxFeeNumber = processedActivity.txFeeNumber
154+
155+
if (processedActivity.type === 'buy') {
156+
processedActivity.baseCurrency = processedActivity.receivedCurrency
157+
processedActivity.baseAmount = processedActivity.receivedAmount
158+
} else {
159+
processedActivity.baseCurrency = processedActivity.sentCurrency
160+
processedActivity.baseAmount = processedActivity.sentAmount
161+
// don't include this fee amount in the fee column for type 'fee'
162+
if (processedActivity.type === 'fee') {
163+
processedActivity.cryptoTaxFeeCurrencyCode = ''
164+
processedActivity.cryptoTaxFeeNumber = ''
165+
}
166+
}
140167
} else if (platform === 'BlockPit') {
141168
processedActivity.type = sending
142169
? 'Withdrawal'
@@ -164,7 +191,8 @@ const platformList = [
164191
{ value: 'CoinTracking', label: 'CoinTracking' },
165192
{ value: 'TaxBit', label: 'TaxBit' },
166193
{ value: 'TokenTax', label: 'TokenTax' },
167-
{ value: 'BlockPit', label: 'BlockPit' }
194+
{ value: 'BlockPit', label: 'BlockPit' },
195+
{ value: 'CryptoTax', label: 'CryptoTax' }
168196
]
169197

170198
export default function History({ queryAddress, selectedCurrency, setSelectedCurrency }) {
@@ -287,6 +315,26 @@ export default function History({ queryAddress, selectedCurrency, setSelectedCur
287315
{ label: 'Date', key: 'timestampExport' }
288316
]
289317
},
318+
{
319+
platform: 'CryptoTax',
320+
headers: [
321+
{ label: 'Timestamp (UTC)', key: 'timestampExport' },
322+
{ label: 'Type', key: 'type' },
323+
{ label: 'Base Currency', key: 'baseCurrency' },
324+
{ label: 'Base Amount', key: 'baseAmount' },
325+
{ label: 'Quote Currency (Optional)', key: '' },
326+
{ label: 'Quote Amount (Optional)', key: '' },
327+
{ label: 'Fee Currency (Optional)', key: 'cryptoTaxFeeCurrencyCode' },
328+
{ label: 'Fee Amount (Optional)', key: 'cryptoTaxFeeNumber' },
329+
{ label: 'From (Optional)', key: 'counterparty' },
330+
{ label: 'To (Optional)', key: 'address' },
331+
{ label: 'Blockchain (Optional)', key: '' },
332+
{ label: 'ID (Optional)', key: 'hash' },
333+
{ label: 'Description (Optional)', key: 'memo' },
334+
{ label: 'Reference Price Per Unit (Optional)', key: '' },
335+
{ label: 'Reference Price Currency (Optional)', key: '' }
336+
]
337+
},
290338
{
291339
platform: 'BlockPit',
292340
headers: [

0 commit comments

Comments
 (0)