Skip to content

Commit

Permalink
Merge pull request #10 from nikhilkuyya/build
Browse files Browse the repository at this point in the history
Build
  • Loading branch information
nikhilkuyya authored Nov 13, 2023
2 parents f11c6e9 + f36832f commit 7af3c03
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/filters/dineroCurrency.filter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Dinero from "dinero.js";

export function formatCurrencyWithDinero(value, factor = 10 ** 2) {
if (Number.isNaN(Number(value))) {
const newValue = Number(value);
if (Number.isNaN(newValue)) {
return "";
}
console.trace('formatCurrency', { value });
const amount = Number.parseFloat(value).toFixed(2) * factor;
console.trace('formatCurrency', { newValue });
const amount = Number.parseFloat(newValue).toFixed(2) * factor;
const dineroObject = Dinero({ amount: amount, currency: "INR" });
const dineroAmount = dineroObject.toRoundedUnit(2);
return Intl.NumberFormat("en-IN", { currency: "INR", style: "currency" }).format(dineroAmount);
Expand Down

0 comments on commit 7af3c03

Please sign in to comment.