-
Notifications
You must be signed in to change notification settings - Fork 25
create export csv for cryptotax #263
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
db2ada3
create export csv for cryptotax
juddydev b1284af
fix IDs
juddydev bef845f
Merge branch 'main' of github.com:juddydev/xrpl-bithomp-explorer into…
juddydev 58f8767
update export csv for cryptotax
juddydev a35bfde
Merge branch 'main' of github.com:juddydev/xrpl-bithomp-explorer into…
juddydev 4205f55
update export csv cryptotax
juddydev 3487237
Merge branch 'main' into export-csv-cryptotax
ihomp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}` | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -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 }, | ||
|
|
@@ -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: '' } | ||
| ] | ||
| } | ||
| ], | ||
| [selectedCurrency] | ||
|
|
@@ -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() | ||
|
|
||
|
|
@@ -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 | ||
|
||
| 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) { | ||
|
|
@@ -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)}> | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.