Added a number asset to limit to a specific number of decimal cases if needed

This commit is contained in:
Joao Ramos
2023-12-14 17:20:36 +00:00
parent d57223bd01
commit 45cf2dc279
3 changed files with 19 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ import {errorMessages} from "@/constants/errors";
import moment from "moment";
import ShortUniqueId from "short-unique-id";
import {Payment} from "@/interfaces/paypal";
import { toFixedNumber } from "@/utils/number";
const db = getFirestore(app);
const auth = getAuth(app);
@@ -32,7 +32,7 @@ const managePaymentRecords = async (user: User, userId: string | undefined): Pro
corporate: userId,
agent: user.corporateInformation.referralAgent,
agentCommission: user.corporateInformation.payment!.commission,
agentValue: (user.corporateInformation.payment!.commission / 100) * user.corporateInformation.payment!.value,
agentValue: toFixedNumber((user.corporateInformation.payment!.commission / 100) * user.corporateInformation.payment!.value, 2),
currency: user.corporateInformation.payment!.currency,
value: user.corporateInformation.payment!.value,
isPaid: false,

View File

@@ -25,6 +25,7 @@ import Input from "@/components/Low/Input";
import ReactDatePicker from "react-datepicker";
import moment from "moment";
import PaymentAssetManager from "@/components/PaymentAssetManager";
import { toFixedNumber } from "@/utils/number";
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user;
@@ -89,7 +90,7 @@ const PaymentCreator = ({onClose, reload}: {onClose: () => void; reload: () => v
corporate: corporate?.id,
agent: referralAgent?.id,
agentCommission: commission,
agentValue: (commission / 100) * price,
agentValue: toFixedNumber((commission / 100) * price, 2),
currency,
value: price,
isPaid: false,
@@ -431,7 +432,7 @@ export default function PaymentRecord() {
header: "Amount",
cell: (info) => (
<span>
{info.getValue().toFixed(2)} {CURRENCIES.find((x) => x.currency === info.row.original.currency)?.label}
{toFixedNumber(info.getValue(), 2)} {CURRENCIES.find((x) => x.currency === info.row.original.currency)?.label}
</span>
),
}),
@@ -453,7 +454,7 @@ export default function PaymentRecord() {
header: "Commission Value",
cell: (info) => (
<span>
{info.getValue().toFixed(2)} {CURRENCIES.find((x) => x.currency === info.row.original.currency)?.label}
{toFixedNumber(info.getValue(), 2)} {CURRENCIES.find((x) => x.currency === info.row.original.currency)?.label}
</span>
),
}),