MCPcopy
hub / github.com/frappe/erpnext / flt

Function flt

banking/src/lib/numbers.ts:127–148  ·  view source on GitHub ↗
(value?: number | string | null, decimals?: number, number_format?: string, rounding_method?: string)

Source from the content-addressed store, hash-verified

125}
126
127export const flt = (value?: number | string | null, decimals?: number, number_format?: string, rounding_method?: string) => {
128 if (value === undefined || value === null || value === "") return 0
129
130 if (typeof value !== "number") {
131 value = value + "";
132
133 // strip currency symbol if exists
134 if (value.indexOf(" ") != -1) {
135 // using slice(1).join(" ") because space could also be a group separator
136 const parts = value.split(" ");
137 value = isNaN(parseFloat(parts[0])) ? parts.slice(parts.length - 1).join(" ") : value;
138 }
139
140 value = strip_number_groups(value, number_format);
141
142 value = parseFloat(value as string);
143 if (isNaN(value)) value = 0;
144 }
145
146 if (decimals != null) return _round(value, decimals, rounding_method);
147 return value;
148}
149
150function strip_number_groups(v: string, number_format?: string) {
151 if (!number_format) number_format = get_number_format();

Callers 15

OpeningBalanceFunction · 0.90
ClosingBalanceFunction · 0.90
DifferenceFunction · 0.90
ClosingBalancesListFunction · 0.90
DifferenceButtonFunction · 0.90
BankEntryFormFunction · 0.90
EntriesFunction · 0.90
onAddDifferenceClickedFunction · 0.90
SummaryFunction · 0.90
StatementDetailsFunction · 0.90
StatementImportLogFunction · 0.90

Calls 2

strip_number_groupsFunction · 0.85
_roundFunction · 0.85