Skip to content

Commit 02cb1b4

Browse files
committed
Merge Sherlock's 'Bug 799652' into stable.
2 parents 8ca65ef + 0e041af commit 02cb1b4

File tree

5 files changed

+41
-40
lines changed

5 files changed

+41
-40
lines changed

gnucash/report/reports/standard/test/test-balsheet-pnl.scm

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331
'("#200.00" "$340.00" "30. FUNDS" "$14,424.52" "$106,709.00" "$106,709.00")
332332
(sxml->table-row-col sxml 1 3 6))
333333
(test-equal "show-rates enabled"
334-
'("1. FUNDS" "$480 + 85/104" "#1.00" "$1.7000")
334+
'("1. FUNDS" "$480 + 85/104" "#1.00" "$1.70")
335335
(sxml->table-row-col sxml 2 #f #f)))
336336

337337
;;make-multilevel
@@ -467,7 +467,7 @@
467467
(list "-#600.00" "-$1,020.00" "-$250.00" "-$250.00")
468468
(sxml->table-row-col sxml 1 2 6))
469469
(test-equal "show-rates enabled"
470-
(list "#1.00" "$1.7000")
470+
(list "#1.00" "$1.70")
471471
(sxml->table-row-col sxml 2 #f #f)))
472472

473473
;;make-multilevel
@@ -523,16 +523,16 @@
523523
"$6,870.00" "$0.00" "$100.00" "$4,000.00" "$2,000.00" "$2,000.00"
524524
"10. FUNDS " "$130.00" "$130.00" "#100.00 " "$100,000.00" "$113,100.00"
525525
"$9,500.00" "$9,500.00" "$500.00" "$9,000.00" "$9,500.00" "$103,600.00"
526-
"$0.00" "$0.00" "$103,600.00" "$113,100.00" "#1.00 $1.3000"
527-
"1. FUNDS $200.0000")
526+
"$0.00" "$0.00" "$103,600.00" "$113,100.00" "#1.00 $1.30"
527+
"1. FUNDS $200.00")
528528
(sxml->table-row-col sxml 1 #f 2))
529529
(test-equal "bal-1/1/71"
530530
'("01/01/71" "$116,006.33" "$116,006.33" "$4,709.00" "$2,000.00"
531531
"$2,609.00" "$0.00" "$100.00" "$11,000.30" "$2,000.00" "$9,000.30"
532532
"30. FUNDS " "$297.03" "$297.03" "#200.00 " "$100,000.00" "$116,006.33"
533533
"$9,500.00" "$9,500.00" "$500.00" "$9,000.00" "$9,500.00" "$103,600.00"
534534
"$2,906.33" "$0.00" "$106,506.33" "$116,006.33" "#1.00 $1 + 49/101"
535-
"1. FUNDS $300.0100")
535+
"1. FUNDS $300.01")
536536
(sxml->table-row-col sxml 1 #f 3))
537537
(test-equal "bal-1/1/72"
538538
'("01/01/72" "$117,437.00" "$117,437.00" "$4,709.00" "$2,000.00"
@@ -564,7 +564,7 @@
564564
"$1,190.00" "$1,190.00" "#700.00 " "$100,000.00" "$122,743.52"
565565
"$9,500.00" "$9,500.00" "$500.00" "$9,000.00" "$9,500.00"
566566
"$103,600.00" "$8,373.52" "$1,270.00" "$113,243.52" "$122,743.52"
567-
"#1.00 $1.7000" "1. FUNDS $480 + 85/104")
567+
"#1.00 $1.70" "1. FUNDS $480 + 85/104")
568568
(sxml->table-row-col sxml 1 #f 2)))))
569569

570570
(define (multicol-pnl-tests)
@@ -602,15 +602,15 @@
602602
"multicol-pnl-halfyear")))
603603
(test-equal "pnl-1/80"
604604
'("01/01/80" " to 01/31/80" "$1,100.00" "$250.00" "$850.00" "#500.00 "
605-
"$1,100.00" "#1.00 $1.7000")
605+
"$1,100.00" "#1.00 $1.70")
606606
(sxml->table-row-col sxml 1 #f 2))
607607
(test-equal "pnl-2/80"
608608
'("02/01/80" " to 02/29/80" "$170.00" "$0.00" "$170.00" "#100.00 "
609-
"$170.00" "#1.00 $1.7000")
609+
"$170.00" "#1.00 $1.70")
610610
(sxml->table-row-col sxml 1 #f 3))
611611
(test-equal "pnl-3/80"
612612
'("03/01/80" " to 03/31/80" "$0.00" "$0.00" "$0.00" "#0.00 "
613-
"$0.00" "#1.00 $1.7000")
613+
"$0.00" "#1.00 $1.70")
614614
(sxml->table-row-col sxml 1 #f 4)))
615615

616616
(set-option! multi-bs-options "General" "Period order is most recent first" #t)
@@ -624,26 +624,26 @@
624624
(let ((sxml (options->sxml multicol-balsheet-uuid multi-bs-options
625625
"multicol pnl weighted-average")))
626626
(test-equal "weighted average exchange-rate"
627-
'("#1.00 $1.4990" "1. FUNDS $235 + 3/7")
627+
'("#1.00 $1.499" "1. FUNDS $235 + 3/7")
628628
(sxml->table-row-col sxml 1 -2 -1)))
629629

630630
(set-option! multi-bs-options "Commodities" "Price Source" 'average-cost)
631631
(let ((sxml (options->sxml multicol-balsheet-uuid multi-bs-options
632632
"multicol pnl average-cost")))
633633
(test-equal "average-cost exchange-rate"
634-
'("#1.00 $1.4550" "1. FUNDS $203 + 1/3")
634+
'("#1.00 $1.455" "1. FUNDS $203 + 1/3")
635635
(sxml->table-row-col sxml 1 -2 -1)))
636636

637637
(set-option! multi-bs-options "Commodities" "Price Source" 'pricedb-nearest)
638638
(let ((sxml (options->sxml multicol-balsheet-uuid multi-bs-options
639639
"multicol pnl pricedb-nearest")))
640640
(test-equal "pricedb-nearest exchange-rate"
641-
'("#1.00 $1.7000" "1. FUNDS $480 + 85/104")
641+
'("#1.00 $1.70" "1. FUNDS $480 + 85/104")
642642
(sxml->table-row-col sxml 1 -2 -1)))
643643

644644
(set-option! multi-bs-options "Commodities" "Price Source" 'pricedb-latest)
645645
(let ((sxml (options->sxml multicol-balsheet-uuid multi-bs-options
646646
"multicol pnl pricedb-latest")))
647647
(test-equal "pricedb-latest exchange-rate"
648-
'("#1.00 $1.7000" "1. FUNDS $480 + 85/104")
648+
'("#1.00 $1.70" "1. FUNDS $480 + 85/104")
649649
(sxml->table-row-col sxml 1 -2 -1)))))

gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -262,98 +262,97 @@
262262
(let ((sxml (options->sxml uuid options "latest")))
263263
(test-equal "BUY 100 SPY"
264264
'("07/01/19" "Buy SPY" "100. SPY" "100. SPY" "Open Long" "CAD"
265-
"C$1.0000" "C$20,000.00" "C$9.95" "C$20,000.00" "C$9.95"
265+
"C$1.00" "C$20,000.00" "C$9.95" "C$20,000.00" "C$9.95"
266266
"C$20,009.95" "C$0.00" "C$0.00" "C$0.00")
267267
(sxml->table-row-col sxml 1 1 #f))
268268

269269
(test-equal "BUY 50 SPY"
270-
'("12/11/19" "Buy SPY" "50. SPY" "150. SPY" "Buy" "CAD" "C$1.0000"
270+
'("12/11/19" "Buy SPY" "50. SPY" "150. SPY" "Buy" "CAD" "C$1.00"
271271
"C$16,000.00" "C$9.95" "C$16,000.00" "C$9.95" "C$36,019.90"
272272
"C$200.10" "C$0.00" "C$0.00" "C$0.00")
273273
(sxml->table-row-col sxml 1 2 #f))
274274

275275
(test-equal "Sell 75 SPY"
276-
'("03/18/20" "Sell SPY" "-75. SPY" "75. SPY" "Sell" "CAD" "C$1.0000"
276+
'("03/18/20" "Sell SPY" "-75. SPY" "75. SPY" "Sell" "CAD" "C$1.00"
277277
"C$12,000.00" "C$9.95" "C$12,000.00" "C$9.95" "C$18,009.95"
278278
"C$240.13" "C$18,009.95" "C$11,990.05" "-C$6,019.90"
279279
"-C$6,009.95" "-C$6,009.95" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
280280
(sxml->table-row-col sxml 1 3 #f))
281281

282282
(test-equal "BUY 250 SPY"
283-
'("04/01/20" "Buy SPY" "250. SPY" "325. SPY" "Buy" "CAD" "C$1.0000"
283+
'("04/01/20" "Buy SPY" "250. SPY" "325. SPY" "Buy" "CAD" "C$1.00"
284284
"C$42,000.00" "C$9.95" "C$42,000.00" "C$9.95" "C$60,019.90"
285285
"C$240.13" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
286286
(sxml->table-row-col sxml 1 4 #f))
287287

288288
(test-equal "Return Capital $2500"
289289
'("04/16/20" "Return of Capital" "0. SPY" "325. SPY" "Return of capital"
290-
"CAD" "C$1.0000" "-C$2,500.00" "-C$2,500.00" "C$57,519.90"
290+
"CAD" "C$1.00" "-C$2,500.00" "-C$2,500.00" "C$57,519.90"
291291
"C$184.68" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
292292
(sxml->table-row-col sxml 1 5 #f))
293293

294294
(test-equal "BUY 125 SPY"
295-
'("05/02/20" "Buy spy" "125. SPY" "450. SPY" "Buy" "CAD" "C$1.0000"
295+
'("05/02/20" "Buy spy" "125. SPY" "450. SPY" "Buy" "CAD" "C$1.00"
296296
"C$47,500.00" "C$0.00" "C$47,500.00" "C$0.00" "C$105,019.90"
297297
"C$176.98" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
298298
(sxml->table-row-col sxml 1 6 #f))
299299

300300
(test-equal "2:1 split"
301301
' ("05/11/20" "stock split" "450. SPY" "900. SPY" "Stock split"
302-
"CAD" "C$1.0000" "C$105,019.90" "C$233.38" "-C$6,009.95"
302+
"CAD" "C$1.00" "C$105,019.90" "C$233.38" "-C$6,009.95"
303303
"-C$6,019.90" "-C$6,019.90")
304304
(sxml->table-row-col sxml 1 7 #f))
305305

306306
(test-equal "sell 135 SPY"
307-
'("05/21/20" "Sell SPY" "-135. SPY" "765. SPY" "Sell" "CAD" "C$1.0000"
307+
'("05/21/20" "Sell SPY" "-135. SPY" "765. SPY" "Sell" "CAD" "C$1.00"
308308
"C$21,500.00" "C$9.95" "C$21,500.00" "C$9.95" "C$89,266.92"
309309
"C$116.69" "C$15,752.98" "C$21,490.05" "C$5,737.06"
310310
"C$5,747.02" "C$5,747.02" "-C$262.94" "-C$282.84" "-C$282.84")
311311
(sxml->table-row-col sxml 1 8 #f))
312312

313313
(test-equal "BUY 150 SPY"
314-
'("06/03/20" "Buy spy" "150. SPY" "915. SPY" "Buy" "CAD" "C$1.0000"
314+
'("06/03/20" "Buy spy" "150. SPY" "915. SPY" "Buy" "CAD" "C$1.00"
315315
"C$21,000.00" "C$0.00" "C$21,000.00" "C$0.00" "C$110,266.92"
316316
"C$116.69" "-C$262.94" "-C$282.84" "-C$282.84")
317317
(sxml->table-row-col sxml 1 9 #f))
318318

319319
(test-equal "sell 915 SPY close long"
320320
'("06/10/20" "Sell SPY" "-915. SPY" "0. SPY" "Sell" "CAD"
321-
"C$1.0000" "C$128,100.00" "C$9.95" "C$128,100.00" "C$9.95"
321+
"C$1.00" "C$128,100.00" "C$9.95" "C$128,100.00" "C$9.95"
322322
"C$0.00" "C$120.51" "C$110,266.92" "C$128,090.05" "C$17,823.14"
323323
"C$17,833.08" "C$17,833.08" "C$17,570.15" "C$17,540.30" "C$17,540.30")
324324
(sxml->table-row-col sxml 1 10 #f))
325325

326326
(test-equal "short-sell 85 SPY"
327327
'("06/10/20" "Sell SPY Short" "-85. SPY" "-85. SPY" "Open Short"
328-
"CAD" "C$1.0000" "-C$11,900.00" "C$9.95" "-C$11,900.00" "C$9.95"
328+
"CAD" "C$1.00" "-C$11,900.00" "C$9.95" "-C$11,900.00" "C$9.95"
329329
"-C$11,890.05" "C$17,570.15" "C$17,540.30" "C$17,540.30")
330330
(sxml->table-row-col sxml 1 11 #f))
331331

332332
(test-equal "short-sell 65 SPY"
333333
'("06/15/20" "Sell SPY Short" "-65. SPY" "-150. SPY" "Short Sell"
334-
"CAD" "C$1.0000" "-C$11,050.00" "C$9.95" "-C$11,050.00" "C$9.95"
334+
"CAD" "C$1.00" "-C$11,050.00" "C$9.95" "-C$11,050.00" "C$9.95"
335335
"-C$22,930.10" "C$139.88" "C$17,570.15" "C$17,540.30" "C$17,540.30")
336336
(sxml->table-row-col sxml 1 12 #f))
337337

338338
(test-equal "buy 50 SPY short"
339339
'("06/18/20" "Buy SPY Close Short" "50. SPY" "-100. SPY" "Cover Buy"
340-
"CAD" "C$1.0000" "-C$5,000.00" "C$9.95" "-C$5,000.00" "C$9.95"
340+
"CAD" "C$1.00" "-C$5,000.00" "C$9.95" "-C$5,000.00" "C$9.95"
341341
"-C$15,286.73" "C$152.87" "-C$7,643.37" "-C$5,009.95" "C$2,633.42"
342342
"C$2,643.37" "C$2,643.37" "C$20,213.52" "C$20,173.72" "C$20,173.72")
343343
(sxml->table-row-col sxml 1 13 #f))
344344

345345
(test-equal "BUY 100 SPY close short"
346346
'("06/20/20" "Buy SPY Close Short" "100. SPY" "0. SPY" "Cover Buy"
347-
"CAD" "C$1.0000" "-C$8,000.00" "C$4.98" "-C$8,000.00" "C$4.98"
347+
"CAD" "C$1.00" "-C$8,000.00" "C$4.98" "-C$8,000.00" "C$4.98"
348348
"C$0.00" "C$152.87" "-C$15,286.73" "-C$8,004.98" "C$7,281.75"
349349
"C$7,286.73" "C$7,286.73" "C$27,500.25" "C$27,455.47" "C$27,455.47")
350350
(sxml->table-row-col sxml 1 14 #f))
351351

352352
(test-equal "BUY 100 SPY"
353353
'("06/21/20" "Buy SPY" "100. SPY" "100. SPY" "Open Long" "CAD"
354-
"C$1.0000" "C$8,000.00" "C$4.98" "C$8,000.00" "C$4.98"
354+
"C$1.00" "C$8,000.00" "C$4.98" "C$8,000.00" "C$4.98"
355355
"C$8,004.98" "C$27,500.25" "C$27,455.47" "C$27,455.47")
356356
(sxml->table-row-col sxml 1 15 #f))))
357357
(gnc-clear-current-session)))
358358

359-

gnucash/report/reports/standard/test/test-invoice.scm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
'("$6.00" "$6.00" "$6.00" "$6.00")
9898
(sxml-get-row-col "entries-table" sxml #f -1))
9999
(test-equal "inv-1 simple entry details are correct"
100-
'("entry-1-desc" "entry-1-action" "2.00" "$3.0000" "0.00 %" "T" "$0.00" "$6.00")
100+
'("entry-1-desc" "entry-1-action" "2.00" "$3.00" "0.00 %" "T" "$0.00" "$6.00")
101101
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
102102
(test-equal "inv-1 cust-name is correct"
103103
'("cust-1-name")
@@ -130,7 +130,7 @@
130130
'("$6.00" "$6.00" "$6.00" "$6.00")
131131
(sxml-get-row-col "entries-table" sxml #f -1))
132132
(test-equal "inv-2 simple entry details are correct"
133-
'("entry-inv-2-desc" "entry-inv-2-action" "2.00" "$3.0000" "0.00 %" "T" "$0.00" "$6.00")
133+
'("entry-inv-2-desc" "entry-inv-2-action" "2.00" "$3.00" "0.00 %" "T" "$0.00" "$6.00")
134134
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
135135
(test-equal "inv-2 cust-name is correct"
136136
'("cust-1-name")
@@ -156,7 +156,7 @@
156156
'("$6.00" "$6.00" "$6.00" "$6.00")
157157
(sxml-get-row-col "entries-table" sxml #f -1))
158158
(test-equal "inv-3 simple entry details are correct"
159-
'("entry-inv-3-desc" "entry-inv-3-action" "2.00" "$3.0000" "T" "$0.00" "$6.00")
159+
'("entry-inv-3-desc" "entry-inv-3-action" "2.00" "$3.00" "T" "$0.00" "$6.00")
160160
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
161161
(test-equal "inv-3 vend-name is correct"
162162
'("vend-1-name")
@@ -174,7 +174,7 @@
174174
'("$6.00" "$6.00" "$6.00" "$6.00")
175175
(sxml-get-row-col "entries-table" sxml #f -1))
176176
(test-equal "inv-4 simple entry details are correct"
177-
'("entry-inv-4-desc" "entry-inv-4-action" "2.00" "$3.0000" "T" "$0.00" "$6.00")
177+
'("entry-inv-4-desc" "entry-inv-4-action" "2.00" "$3.00" "T" "$0.00" "$6.00")
178178
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
179179
(test-equal "inv-4 vend-name is correct"
180180
'("emp-1-name")
@@ -192,7 +192,7 @@
192192
'("$6.00" "$6.00" "$6.00" "$6.00")
193193
(sxml-get-row-col "entries-table" sxml #f -1))
194194
(test-equal "inv-5 simple entry details are correct"
195-
'("entry-5-desc" "entry-5-action" "2.00" "$3.0000" "0.00 %" "T" "$0.00" "$6.00")
195+
'("entry-5-desc" "entry-5-action" "2.00" "$3.00" "0.00 %" "T" "$0.00" "$6.00")
196196
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
197197
(test-equal "inv-5 cust-name is correct"
198198
'("cust-1-name")
@@ -206,7 +206,7 @@
206206
'("$6.00" "$6.00" "$6.00" "$6.00")
207207
(sxml-get-row-col "entries-table" sxml #f -1))
208208
(test-equal "inv-6 simple entry details are correct"
209-
'("entry-inv-6-desc" "entry-inv-6-action" "2.00" "$3.0000" "T" "$0.00" "$6.00")
209+
'("entry-inv-6-desc" "entry-inv-6-action" "2.00" "$3.00" "T" "$0.00" "$6.00")
210210
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
211211
(test-equal "inv-6 vend-name is correct"
212212
'("vend-1-name")
@@ -224,7 +224,7 @@
224224
'("$6.00" "$6.00" "$6.00" "$6.00")
225225
(sxml-get-row-col "entries-table" sxml #f -1))
226226
(test-equal "inv-7 simple entry details are correct"
227-
'("entry-inv-7-desc" "entry-inv-7-action" "2.00" "$3.0000" "T" "$0.00" "$6.00")
227+
'("entry-inv-7-desc" "entry-inv-7-action" "2.00" "$3.00" "T" "$0.00" "$6.00")
228228
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
229229
(test-equal "inv-7 vend-name is correct"
230230
'("emp-1-name")

gnucash/report/reports/standard/test/test-portfolios.scm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@
8585
(options (gnc:make-report-options advanced-uuid)))
8686
(let ((sxml (options->sxml advanced-uuid options "basic average")))
8787
(test-equal "advanced: average basis"
88-
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.0000" "$484.88" "$252.00" "$800.00"
88+
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.00" "$484.88" "$252.00" "$800.00"
8989
"$543.00" "$227.88" "-$232.88" "-$5.00" "-0.63%" "$4.00"
9090
"$10.00" "-$1.00" "-0.13%")
9191
(sxml->table-row-col sxml 1 1 #f)))
9292

9393
(set-option! options "General" "Basis calculation method" 'fifo-basis)
9494
(let ((sxml (options->sxml advanced-uuid options "basic fifo")))
9595
(test-equal "advanced: fifo basis"
96-
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.0000" "$543.94" "$252.00" "$800.00"
96+
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.00" "$543.94" "$252.00" "$800.00"
9797
"$543.00" "$286.94" "-$291.94" "-$5.00" "-0.63%" "$4.00" "$10.00"
9898
"-$1.00" "-0.13%")
9999
(sxml->table-row-col sxml 1 1 #f)))
100100

101101
(set-option! options "General" "Basis calculation method" 'filo-basis)
102102
(let ((sxml (options->sxml advanced-uuid options "basic filo")))
103103
(test-equal "advanced: filo basis"
104-
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.0000" "$400.00" "$252.00" "$800.00"
104+
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.00" "$400.00" "$252.00" "$800.00"
105105
"$543.00" "$143.00" "-$148.00" "-$5.00" "-0.63%" "$4.00" "$10.00"
106106
"-$1.00" "-0.13%")
107107
(sxml->table-row-col sxml 1 1 #f))))

libgnucash/app-utils/gnc-ui-util.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,8 +1031,10 @@ gnc_price_print_info (const gnc_commodity *curr, gboolean use_symbol)
10311031
if (info.commodity)
10321032
{
10331033
int frac = gnc_commodity_get_fraction (curr);
1034-
guint8 decplaces = 2;
1034+
guint8 decplaces = 0;
10351035
while (frac != 1 && (frac % 10) == 0 && (frac /= 10)) ++decplaces;
1036+
if (force)
1037+
decplaces += 2;
10361038
info.max_decimal_places = decplaces;
10371039
info.min_decimal_places = decplaces;
10381040
}

0 commit comments

Comments
 (0)