Skip to content

Commit

Permalink
Merge pull request #836 from alexstotsky/tax-report-source-col
Browse files Browse the repository at this point in the history
(feature) Tax report source column
  • Loading branch information
ezewer authored Jul 24, 2024
2 parents 64c52f4 + 645f82a commit 7c25c6b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,21 @@
"movements": "Movements",
"cols": {
"currency": "Currency",
"source": "Source",
"amount": "Amount",
"dateAcquired": "Date Acquired ",
"dateSold": "Date Sold",
"proceeds": "Proceeds",
"cost": "Cost",
"gainOrLoss": "Gain or Loss"
},
"sources":{
"airdrop_on_wallet": "Airdrop on wallet",
"margin_funding_payment": "Margin funding payment",
"affiliate_rebate": "Affiliate rebate",
"staking_payment": "Staking payment",
"exchange": "Exchange"
},
"disclaimer": {
"title": "Disclaimer",
"message": "The tax reports generated by this app are for informational purposes only. We do not guarantee accuracy or completeness. Always consult a qualified tax advisor to ensure compliance with current tax laws and personalized advice. Your reliance on the generated reports is at your own risk."
Expand Down
19 changes: 18 additions & 1 deletion src/components/TaxReport/TaxReport.columns.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { mapSymbol } from 'state/symbols/utils'
import { formatAmount, fixedFloat } from 'ui/utils'
import { getCell, getCellState, getColumnWidth } from 'utils/columns'
import {
getCell,
getCellState,
getColumnWidth,
formatSourceType,
} from 'utils/columns'

export const getColumns = ({
t,
Expand All @@ -22,6 +27,18 @@ export const getColumns = ({
},
copyText: rowIndex => mapSymbol(entries[rowIndex].asset),
},
{
id: 'type',
width: getColumnWidth('type', columnsWidth),
name: 'taxreport.cols.source',
className: 'align-left',
renderer: (rowIndex) => {
if (isLoading || isNoData) return getCellState(isLoading, isNoData)
const { type } = entries[rowIndex]
return getCell(formatSourceType(type, t), t)
},
copyText: rowIndex => formatSourceType(entries[rowIndex].type, t),
},
{
id: 'amount',
width: getColumnWidth('amount', columnsWidth),
Expand Down
4 changes: 4 additions & 0 deletions src/utils/columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _head from 'lodash/head'
import _fill from 'lodash/fill'
import _floor from 'lodash/floor'
import _filter from 'lodash/filter'
import _toLower from 'lodash/toLower'
import _forEach from 'lodash/forEach'
import { Cell } from '@blueprintjs/table'
import { get, pick, isEqual } from '@bitfinex/lib-js-util-base'
Expand Down Expand Up @@ -671,6 +672,8 @@ export const formatSumUpValue = value => {
return parseFloat(value).toFixed(8).replace(/\d(?=(\d{3})+\.)/g, '$&,')
}

export const formatSourceType = (type, t) => t(`taxreport.sources.${_toLower(type)}`)

export const MIN_COLUMN_WIDTH = 125
export const WIDE_COLUMN_DEFAULT_WIDTH = 300
export const DEFAULT_CONTAINER_WIDTH = 1000
Expand Down Expand Up @@ -721,4 +724,5 @@ export default {
formatSumUpValue,
getTooltipContent,
getCalculatedColumnWidths,
formatSourceType,
}

0 comments on commit 7c25c6b

Please sign in to comment.