Bug 798352 - Decimal Precision when Entering Mutual Fund Transaction

Let xaccParseAmount parse up to 12 decimal places instead of 8.
This commit is contained in:
John Ralls
2021-12-09 15:55:37 -08:00
parent ececd1ff93
commit 95b973f792

View File

@@ -2061,6 +2061,14 @@ multiplier (int num_decimals)
{
switch (num_decimals)
{
case 12:
return 1000000000000;
case 11:
return 100000000000;
case 10:
return 10000000000;
case 9:
return 1000000000;
case 8:
return 100000000;
case 7:
@@ -2077,6 +2085,8 @@ multiplier (int num_decimals)
return 100;
case 1:
return 10;
case 0:
return 1;
default:
PERR("bad fraction length");
g_assert_not_reached();
@@ -2374,10 +2384,10 @@ xaccParseAmountExtended (const char * in_str, gboolean monetary,
len = strlen(out_str);
if (len > 8)
if (len > 12)
{
out_str[8] = '\0';
len = 8;
out_str[12] = '\0';
len = 12;
}
if (sscanf (out_str, QOF_SCANF_LLD, &fraction) < 1)
@@ -2392,7 +2402,7 @@ xaccParseAmountExtended (const char * in_str, gboolean monetary,
}
else if (monetary && auto_decimal_enabled && !got_decimal)
{
if ((auto_decimal_places > 0) && (auto_decimal_places < 9))
if ((auto_decimal_places > 0) && (auto_decimal_places <= 12))
{
denom = multiplier(auto_decimal_places);