Skip to content

Commit

Permalink
[PIMS-250] Ownership Percentages Infinite Repeat (#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarkowsky authored Oct 4, 2023
1 parent 3284ebb commit 37d5bc7
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ interface IRowProps {
const Row = (props: IRowProps) => {
const { row, index } = props;

const getPercentage = (numerator: string, denominator: string) => {
const value = (parseInt(numerator) / parseInt(denominator)) * 100;
// If it's a whole number, just return it. Otherwise, crop to 2 decimal places
return value % 1 === 0 ? value : value.toFixed(2);
};

return (
<TableRow
sx={{
backgroundColor: index % 2 === 0 ? 'white' : '#F2F2F2',
}}
>
<TableCell align="center" sx={{ width: '7em' }}>
{`${
(parseInt(row.interestFractionNumerator) / parseInt(row.interestFractionDenominator)) *
100
}%`}
{`${getPercentage(row.interestFractionNumerator, row.interestFractionDenominator)}%`}
</TableCell>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Box sx={{ margin: 1 }}>
Expand Down

0 comments on commit 37d5bc7

Please sign in to comment.