summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/amount.cc3
-rw-r--r--test/regress/2057.test12
2 files changed, 14 insertions, 1 deletions
diff --git a/src/amount.cc b/src/amount.cc
index 0527c979..079ce777 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -732,7 +732,8 @@ void amount_t::in_place_unreduce()
}
if (shifted) {
- if (("h" == comm->symbol() || "m" == comm->symbol()) && commodity_t::time_colon_by_default) {
+ if (comm && ("h" == comm->symbol() || "m" == comm->symbol())
+ && commodity_t::time_colon_by_default) {
double truncated = trunc(tmp.to_double());
double precision = tmp.to_double() - truncated;
tmp = truncated + (precision * (comm->smaller()->number() / 100.0));
diff --git a/test/regress/2057.test b/test/regress/2057.test
new file mode 100644
index 00000000..f691b350
--- /dev/null
+++ b/test/regress/2057.test
@@ -0,0 +1,12 @@
+C 1 "" = 1 $
+
+2021-01-01 Test
+ A $10
+ B
+
+test bal
+ 10 A
+ -10 B
+--------------------
+ 0
+end test