Files
bigcapital/packages/server/src/services/FinancialStatements/utils.ts
2024-02-21 14:55:06 +02:00

31 lines
705 B
TypeScript

import { kebabCase } from 'lodash';
import { ITableRow } from '@/interfaces';
export const formatNumber = (balance, { noCents, divideOn1000 }): string => {
let formattedBalance: number = parseFloat(balance);
if (noCents) {
formattedBalance = parseInt(formattedBalance, 10);
}
if (divideOn1000) {
formattedBalance /= 1000;
}
return formattedBalance;
};
export const tableClassNames = (rows: ITableRow[]) => {
return rows.map((row) => {
const classNames =
row?.rowTypes?.map((rowType) => `row-type--${kebabCase(rowType)}`) || [];
if (row.id) {
classNames.push(`row-id--${kebabCase(row.id)}`);
}
return {
...row,
classNames,
};
});
};