Added support for currency in the CSV
This commit is contained in:
@@ -486,8 +486,7 @@ export default function PaymentRecord() {
|
|||||||
case 'amount': {
|
case 'amount': {
|
||||||
const value = info.getValue();
|
const value = info.getValue();
|
||||||
const numberValue = toFixedNumber(value, 2)
|
const numberValue = toFixedNumber(value, 2)
|
||||||
const currency = CURRENCIES.find((x) => x.currency === info.row.original.currency)?.label
|
return { value: numberValue }
|
||||||
return { value: `${numberValue} ${currency}` };
|
|
||||||
}
|
}
|
||||||
case 'date': {
|
case 'date': {
|
||||||
const value = info.getValue();
|
const value = info.getValue();
|
||||||
@@ -501,6 +500,11 @@ export default function PaymentRecord() {
|
|||||||
value: user?.corporateInformation.companyInformation.name || user?.name,
|
value: user?.corporateInformation.companyInformation.name || user?.name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
case 'currency': {
|
||||||
|
return {
|
||||||
|
value: info.row.original.currency,
|
||||||
|
};
|
||||||
|
}
|
||||||
case 'isPaid':
|
case 'isPaid':
|
||||||
case 'corporateId':
|
case 'corporateId':
|
||||||
default: {
|
default: {
|
||||||
@@ -550,7 +554,9 @@ export default function PaymentRecord() {
|
|||||||
id: "amount",
|
id: "amount",
|
||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
const { value } = columHelperValue(info.column.id, info);
|
const { value } = columHelperValue(info.column.id, info);
|
||||||
return <span>{value}</span>;
|
const currency = CURRENCIES.find((x) => x.currency === info.row.original.currency)?.label
|
||||||
|
const finalValue = `${value} ${currency}`;
|
||||||
|
return <span>{finalValue}</span>;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor("agent", {
|
columnHelper.accessor("agent", {
|
||||||
@@ -580,7 +586,9 @@ export default function PaymentRecord() {
|
|||||||
id: "agentValue",
|
id: "agentValue",
|
||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
const { value } = columHelperValue(info.column.id, info);
|
const { value } = columHelperValue(info.column.id, info);
|
||||||
return <span>{value}</span>;
|
const currency = CURRENCIES.find((x) => x.currency === info.row.original.currency)?.label
|
||||||
|
const finalValue = `${value} ${currency}`;
|
||||||
|
return <span>{finalValue}</span>;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor("isPaid", {
|
columnHelper.accessor("isPaid", {
|
||||||
@@ -678,7 +686,6 @@ export default function PaymentRecord() {
|
|||||||
const data = whitelistedColumns.map((data) => ({
|
const data = whitelistedColumns.map((data) => ({
|
||||||
key: data.column.columnDef.id,
|
key: data.column.columnDef.id,
|
||||||
label: data.column.columnDef.header,
|
label: data.column.columnDef.header,
|
||||||
index: data.index,
|
|
||||||
})) as SimpleCSVColumn[];
|
})) as SimpleCSVColumn[];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -689,11 +696,18 @@ export default function PaymentRecord() {
|
|||||||
|
|
||||||
const { rows } = table.getRowModel();
|
const { rows } = table.getRowModel();
|
||||||
|
|
||||||
|
const finalColumns = [
|
||||||
|
...columns,
|
||||||
|
{
|
||||||
|
key: 'currency',
|
||||||
|
label: 'Currency',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
columns,
|
columns: finalColumns,
|
||||||
rows: rows.map((row) => {
|
rows: rows.map((row) => {
|
||||||
return columns.reduce((accm, { key, index }) => {
|
return finalColumns.reduce((accm, { key }) => {
|
||||||
const { value } = columHelperValue(key, {
|
const { value } = columHelperValue(key, {
|
||||||
row,
|
row,
|
||||||
getValue: () => row.getValue(key),
|
getValue: () => row.getValue(key),
|
||||||
|
|||||||
Reference in New Issue
Block a user