Skip to content
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

(feature) Tax report source column #836

Merged
merged 6 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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,
}