Bug 799652 - Invoice price decimal places

Bug 799652 - Invoice price decimal places

The "+ 2 places" should only be applied when force decimal is enabled.

Update gnc-ui-util.cpp

Update test-balsheet-pnl.scm

Update test-ifrs-cost-basis.scm

Update test-invoice.scm
pull/2121/head
Sherlock 8 months ago
parent ea179831a0
commit 0e041af555

@ -331,7 +331,7 @@
'("#200.00" "$340.00" "30. FUNDS" "$14,424.52" "$106,709.00" "$106,709.00")
(sxml->table-row-col sxml 1 3 6))
(test-equal "show-rates enabled"
'("1. FUNDS" "$480 + 85/104" "#1.00" "$1.7000")
'("1. FUNDS" "$480 + 85/104" "#1.00" "$1.70")
(sxml->table-row-col sxml 2 #f #f)))
;;make-multilevel
@ -467,7 +467,7 @@
(list "-#600.00" "-$1,020.00" "-$250.00" "-$250.00")
(sxml->table-row-col sxml 1 2 6))
(test-equal "show-rates enabled"
(list "#1.00" "$1.7000")
(list "#1.00" "$1.70")
(sxml->table-row-col sxml 2 #f #f)))
;;make-multilevel
@ -523,8 +523,8 @@
"$6,870.00" "$0.00" "$100.00" "$4,000.00" "$2,000.00" "$2,000.00"
"10. FUNDS " "$130.00" "$130.00" "#100.00 " "$100,000.00" "$113,100.00"
"$9,500.00" "$9,500.00" "$500.00" "$9,000.00" "$9,500.00" "$103,600.00"
"$0.00" "$0.00" "$103,600.00" "$113,100.00" "#1.00 $1.3000"
"1. FUNDS $200.0000")
"$0.00" "$0.00" "$103,600.00" "$113,100.00" "#1.00 $1.30"
"1. FUNDS $200.00")
(sxml->table-row-col sxml 1 #f 2))
(test-equal "bal-1/1/71"
'("01/01/71" "$116,006.33" "$116,006.33" "$4,709.00" "$2,000.00"
@ -532,7 +532,7 @@
"30. FUNDS " "$297.03" "$297.03" "#200.00 " "$100,000.00" "$116,006.33"
"$9,500.00" "$9,500.00" "$500.00" "$9,000.00" "$9,500.00" "$103,600.00"
"$2,906.33" "$0.00" "$106,506.33" "$116,006.33" "#1.00 $1 + 49/101"
"1. FUNDS $300.0100")
"1. FUNDS $300.01")
(sxml->table-row-col sxml 1 #f 3))
(test-equal "bal-1/1/72"
'("01/01/72" "$117,437.00" "$117,437.00" "$4,709.00" "$2,000.00"
@ -564,7 +564,7 @@
"$1,190.00" "$1,190.00" "#700.00 " "$100,000.00" "$122,743.52"
"$9,500.00" "$9,500.00" "$500.00" "$9,000.00" "$9,500.00"
"$103,600.00" "$8,373.52" "$1,270.00" "$113,243.52" "$122,743.52"
"#1.00 $1.7000" "1. FUNDS $480 + 85/104")
"#1.00 $1.70" "1. FUNDS $480 + 85/104")
(sxml->table-row-col sxml 1 #f 2)))))
(define (multicol-pnl-tests)
@ -602,15 +602,15 @@
"multicol-pnl-halfyear")))
(test-equal "pnl-1/80"
'("01/01/80" " to 01/31/80" "$1,100.00" "$250.00" "$850.00" "#500.00 "
"$1,100.00" "#1.00 $1.7000")
"$1,100.00" "#1.00 $1.70")
(sxml->table-row-col sxml 1 #f 2))
(test-equal "pnl-2/80"
'("02/01/80" " to 02/29/80" "$170.00" "$0.00" "$170.00" "#100.00 "
"$170.00" "#1.00 $1.7000")
"$170.00" "#1.00 $1.70")
(sxml->table-row-col sxml 1 #f 3))
(test-equal "pnl-3/80"
'("03/01/80" " to 03/31/80" "$0.00" "$0.00" "$0.00" "#0.00 "
"$0.00" "#1.00 $1.7000")
"$0.00" "#1.00 $1.70")
(sxml->table-row-col sxml 1 #f 4)))
(set-option! multi-bs-options "General" "Period order is most recent first" #t)
@ -624,26 +624,26 @@
(let ((sxml (options->sxml multicol-balsheet-uuid multi-bs-options
"multicol pnl weighted-average")))
(test-equal "weighted average exchange-rate"
'("#1.00 $1.4990" "1. FUNDS $235 + 3/7")
'("#1.00 $1.499" "1. FUNDS $235 + 3/7")
(sxml->table-row-col sxml 1 -2 -1)))
(set-option! multi-bs-options "Commodities" "Price Source" 'average-cost)
(let ((sxml (options->sxml multicol-balsheet-uuid multi-bs-options
"multicol pnl average-cost")))
(test-equal "average-cost exchange-rate"
'("#1.00 $1.4550" "1. FUNDS $203 + 1/3")
'("#1.00 $1.455" "1. FUNDS $203 + 1/3")
(sxml->table-row-col sxml 1 -2 -1)))
(set-option! multi-bs-options "Commodities" "Price Source" 'pricedb-nearest)
(let ((sxml (options->sxml multicol-balsheet-uuid multi-bs-options
"multicol pnl pricedb-nearest")))
(test-equal "pricedb-nearest exchange-rate"
'("#1.00 $1.7000" "1. FUNDS $480 + 85/104")
'("#1.00 $1.70" "1. FUNDS $480 + 85/104")
(sxml->table-row-col sxml 1 -2 -1)))
(set-option! multi-bs-options "Commodities" "Price Source" 'pricedb-latest)
(let ((sxml (options->sxml multicol-balsheet-uuid multi-bs-options
"multicol pnl pricedb-latest")))
(test-equal "pricedb-latest exchange-rate"
'("#1.00 $1.7000" "1. FUNDS $480 + 85/104")
'("#1.00 $1.70" "1. FUNDS $480 + 85/104")
(sxml->table-row-col sxml 1 -2 -1)))))

@ -262,98 +262,97 @@
(let ((sxml (options->sxml uuid options "latest")))
(test-equal "BUY 100 SPY"
'("07/01/19" "Buy SPY" "100. SPY" "100. SPY" "Open Long" "CAD"
"C$1.0000" "C$20,000.00" "C$9.95" "C$20,000.00" "C$9.95"
"C$1.00" "C$20,000.00" "C$9.95" "C$20,000.00" "C$9.95"
"C$20,009.95" "C$0.00" "C$0.00" "C$0.00")
(sxml->table-row-col sxml 1 1 #f))
(test-equal "BUY 50 SPY"
'("12/11/19" "Buy SPY" "50. SPY" "150. SPY" "Buy" "CAD" "C$1.0000"
'("12/11/19" "Buy SPY" "50. SPY" "150. SPY" "Buy" "CAD" "C$1.00"
"C$16,000.00" "C$9.95" "C$16,000.00" "C$9.95" "C$36,019.90"
"C$200.10" "C$0.00" "C$0.00" "C$0.00")
(sxml->table-row-col sxml 1 2 #f))
(test-equal "Sell 75 SPY"
'("03/18/20" "Sell SPY" "-75. SPY" "75. SPY" "Sell" "CAD" "C$1.0000"
'("03/18/20" "Sell SPY" "-75. SPY" "75. SPY" "Sell" "CAD" "C$1.00"
"C$12,000.00" "C$9.95" "C$12,000.00" "C$9.95" "C$18,009.95"
"C$240.13" "C$18,009.95" "C$11,990.05" "-C$6,019.90"
"-C$6,009.95" "-C$6,009.95" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
(sxml->table-row-col sxml 1 3 #f))
(test-equal "BUY 250 SPY"
'("04/01/20" "Buy SPY" "250. SPY" "325. SPY" "Buy" "CAD" "C$1.0000"
'("04/01/20" "Buy SPY" "250. SPY" "325. SPY" "Buy" "CAD" "C$1.00"
"C$42,000.00" "C$9.95" "C$42,000.00" "C$9.95" "C$60,019.90"
"C$240.13" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
(sxml->table-row-col sxml 1 4 #f))
(test-equal "Return Capital $2500"
'("04/16/20" "Return of Capital" "0. SPY" "325. SPY" "Return of capital"
"CAD" "C$1.0000" "-C$2,500.00" "-C$2,500.00" "C$57,519.90"
"CAD" "C$1.00" "-C$2,500.00" "-C$2,500.00" "C$57,519.90"
"C$184.68" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
(sxml->table-row-col sxml 1 5 #f))
(test-equal "BUY 125 SPY"
'("05/02/20" "Buy spy" "125. SPY" "450. SPY" "Buy" "CAD" "C$1.0000"
'("05/02/20" "Buy spy" "125. SPY" "450. SPY" "Buy" "CAD" "C$1.00"
"C$47,500.00" "C$0.00" "C$47,500.00" "C$0.00" "C$105,019.90"
"C$176.98" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
(sxml->table-row-col sxml 1 6 #f))
(test-equal "2:1 split"
' ("05/11/20" "stock split" "450. SPY" "900. SPY" "Stock split"
"CAD" "C$1.0000" "C$105,019.90" "C$233.38" "-C$6,009.95"
"CAD" "C$1.00" "C$105,019.90" "C$233.38" "-C$6,009.95"
"-C$6,019.90" "-C$6,019.90")
(sxml->table-row-col sxml 1 7 #f))
(test-equal "sell 135 SPY"
'("05/21/20" "Sell SPY" "-135. SPY" "765. SPY" "Sell" "CAD" "C$1.0000"
'("05/21/20" "Sell SPY" "-135. SPY" "765. SPY" "Sell" "CAD" "C$1.00"
"C$21,500.00" "C$9.95" "C$21,500.00" "C$9.95" "C$89,266.92"
"C$116.69" "C$15,752.98" "C$21,490.05" "C$5,737.06"
"C$5,747.02" "C$5,747.02" "-C$262.94" "-C$282.84" "-C$282.84")
(sxml->table-row-col sxml 1 8 #f))
(test-equal "BUY 150 SPY"
'("06/03/20" "Buy spy" "150. SPY" "915. SPY" "Buy" "CAD" "C$1.0000"
'("06/03/20" "Buy spy" "150. SPY" "915. SPY" "Buy" "CAD" "C$1.00"
"C$21,000.00" "C$0.00" "C$21,000.00" "C$0.00" "C$110,266.92"
"C$116.69" "-C$262.94" "-C$282.84" "-C$282.84")
(sxml->table-row-col sxml 1 9 #f))
(test-equal "sell 915 SPY close long"
'("06/10/20" "Sell SPY" "-915. SPY" "0. SPY" "Sell" "CAD"
"C$1.0000" "C$128,100.00" "C$9.95" "C$128,100.00" "C$9.95"
"C$1.00" "C$128,100.00" "C$9.95" "C$128,100.00" "C$9.95"
"C$0.00" "C$120.51" "C$110,266.92" "C$128,090.05" "C$17,823.14"
"C$17,833.08" "C$17,833.08" "C$17,570.15" "C$17,540.30" "C$17,540.30")
(sxml->table-row-col sxml 1 10 #f))
(test-equal "short-sell 85 SPY"
'("06/10/20" "Sell SPY Short" "-85. SPY" "-85. SPY" "Open Short"
"CAD" "C$1.0000" "-C$11,900.00" "C$9.95" "-C$11,900.00" "C$9.95"
"CAD" "C$1.00" "-C$11,900.00" "C$9.95" "-C$11,900.00" "C$9.95"
"-C$11,890.05" "C$17,570.15" "C$17,540.30" "C$17,540.30")
(sxml->table-row-col sxml 1 11 #f))
(test-equal "short-sell 65 SPY"
'("06/15/20" "Sell SPY Short" "-65. SPY" "-150. SPY" "Short Sell"
"CAD" "C$1.0000" "-C$11,050.00" "C$9.95" "-C$11,050.00" "C$9.95"
"CAD" "C$1.00" "-C$11,050.00" "C$9.95" "-C$11,050.00" "C$9.95"
"-C$22,930.10" "C$139.88" "C$17,570.15" "C$17,540.30" "C$17,540.30")
(sxml->table-row-col sxml 1 12 #f))
(test-equal "buy 50 SPY short"
'("06/18/20" "Buy SPY Close Short" "50. SPY" "-100. SPY" "Cover Buy"
"CAD" "C$1.0000" "-C$5,000.00" "C$9.95" "-C$5,000.00" "C$9.95"
"CAD" "C$1.00" "-C$5,000.00" "C$9.95" "-C$5,000.00" "C$9.95"
"-C$15,286.73" "C$152.87" "-C$7,643.37" "-C$5,009.95" "C$2,633.42"
"C$2,643.37" "C$2,643.37" "C$20,213.52" "C$20,173.72" "C$20,173.72")
(sxml->table-row-col sxml 1 13 #f))
(test-equal "BUY 100 SPY close short"
'("06/20/20" "Buy SPY Close Short" "100. SPY" "0. SPY" "Cover Buy"
"CAD" "C$1.0000" "-C$8,000.00" "C$4.98" "-C$8,000.00" "C$4.98"
"CAD" "C$1.00" "-C$8,000.00" "C$4.98" "-C$8,000.00" "C$4.98"
"C$0.00" "C$152.87" "-C$15,286.73" "-C$8,004.98" "C$7,281.75"
"C$7,286.73" "C$7,286.73" "C$27,500.25" "C$27,455.47" "C$27,455.47")
(sxml->table-row-col sxml 1 14 #f))
(test-equal "BUY 100 SPY"
'("06/21/20" "Buy SPY" "100. SPY" "100. SPY" "Open Long" "CAD"
"C$1.0000" "C$8,000.00" "C$4.98" "C$8,000.00" "C$4.98"
"C$1.00" "C$8,000.00" "C$4.98" "C$8,000.00" "C$4.98"
"C$8,004.98" "C$27,500.25" "C$27,455.47" "C$27,455.47")
(sxml->table-row-col sxml 1 15 #f))))
(gnc-clear-current-session)))

@ -97,7 +97,7 @@
'("$6.00" "$6.00" "$6.00" "$6.00")
(sxml-get-row-col "entries-table" sxml #f -1))
(test-equal "inv-1 simple entry details are correct"
'("entry-1-desc" "entry-1-action" "2.00" "$3.0000" "0.00 %" "T" "$0.00" "$6.00")
'("entry-1-desc" "entry-1-action" "2.00" "$3.00" "0.00 %" "T" "$0.00" "$6.00")
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
(test-equal "inv-1 cust-name is correct"
'("cust-1-name")
@ -130,7 +130,7 @@
'("$6.00" "$6.00" "$6.00" "$6.00")
(sxml-get-row-col "entries-table" sxml #f -1))
(test-equal "inv-2 simple entry details are correct"
'("entry-inv-2-desc" "entry-inv-2-action" "2.00" "$3.0000" "0.00 %" "T" "$0.00" "$6.00")
'("entry-inv-2-desc" "entry-inv-2-action" "2.00" "$3.00" "0.00 %" "T" "$0.00" "$6.00")
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
(test-equal "inv-2 cust-name is correct"
'("cust-1-name")
@ -156,7 +156,7 @@
'("$6.00" "$6.00" "$6.00" "$6.00")
(sxml-get-row-col "entries-table" sxml #f -1))
(test-equal "inv-3 simple entry details are correct"
'("entry-inv-3-desc" "entry-inv-3-action" "2.00" "$3.0000" "T" "$0.00" "$6.00")
'("entry-inv-3-desc" "entry-inv-3-action" "2.00" "$3.00" "T" "$0.00" "$6.00")
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
(test-equal "inv-3 vend-name is correct"
'("vend-1-name")
@ -174,7 +174,7 @@
'("$6.00" "$6.00" "$6.00" "$6.00")
(sxml-get-row-col "entries-table" sxml #f -1))
(test-equal "inv-4 simple entry details are correct"
'("entry-inv-4-desc" "entry-inv-4-action" "2.00" "$3.0000" "T" "$0.00" "$6.00")
'("entry-inv-4-desc" "entry-inv-4-action" "2.00" "$3.00" "T" "$0.00" "$6.00")
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
(test-equal "inv-4 vend-name is correct"
'("emp-1-name")
@ -192,7 +192,7 @@
'("$6.00" "$6.00" "$6.00" "$6.00")
(sxml-get-row-col "entries-table" sxml #f -1))
(test-equal "inv-5 simple entry details are correct"
'("entry-5-desc" "entry-5-action" "2.00" "$3.0000" "0.00 %" "T" "$0.00" "$6.00")
'("entry-5-desc" "entry-5-action" "2.00" "$3.00" "0.00 %" "T" "$0.00" "$6.00")
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
(test-equal "inv-5 cust-name is correct"
'("cust-1-name")
@ -206,7 +206,7 @@
'("$6.00" "$6.00" "$6.00" "$6.00")
(sxml-get-row-col "entries-table" sxml #f -1))
(test-equal "inv-6 simple entry details are correct"
'("entry-inv-6-desc" "entry-inv-6-action" "2.00" "$3.0000" "T" "$0.00" "$6.00")
'("entry-inv-6-desc" "entry-inv-6-action" "2.00" "$3.00" "T" "$0.00" "$6.00")
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
(test-equal "inv-6 vend-name is correct"
'("vend-1-name")
@ -224,7 +224,7 @@
'("$6.00" "$6.00" "$6.00" "$6.00")
(sxml-get-row-col "entries-table" sxml #f -1))
(test-equal "inv-7 simple entry details are correct"
'("entry-inv-7-desc" "entry-inv-7-action" "2.00" "$3.0000" "T" "$0.00" "$6.00")
'("entry-inv-7-desc" "entry-inv-7-action" "2.00" "$3.00" "T" "$0.00" "$6.00")
(cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
(test-equal "inv-7 vend-name is correct"
'("emp-1-name")

@ -85,7 +85,7 @@
(options (gnc:make-report-options advanced-uuid)))
(let ((sxml (options->sxml advanced-uuid options "basic average")))
(test-equal "advanced: average basis"
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.0000" "$484.88" "$252.00" "$800.00"
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.00" "$484.88" "$252.00" "$800.00"
"$543.00" "$227.88" "-$232.88" "-$5.00" "-0.63%" "$4.00"
"$10.00" "-$1.00" "-0.13%")
(sxml->table-row-col sxml 1 1 #f)))
@ -93,7 +93,7 @@
(set-option! options "General" "Basis calculation method" 'fifo-basis)
(let ((sxml (options->sxml advanced-uuid options "basic fifo")))
(test-equal "advanced: fifo basis"
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.0000" "$543.94" "$252.00" "$800.00"
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.00" "$543.94" "$252.00" "$800.00"
"$543.00" "$286.94" "-$291.94" "-$5.00" "-0.63%" "$4.00" "$10.00"
"-$1.00" "-0.13%")
(sxml->table-row-col sxml 1 1 #f)))
@ -101,7 +101,7 @@
(set-option! options "General" "Basis calculation method" 'filo-basis)
(let ((sxml (options->sxml advanced-uuid options "basic filo")))
(test-equal "advanced: filo basis"
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.0000" "$400.00" "$252.00" "$800.00"
'("AAPL" "AAPL" "NASDAQ" "42.00" "$6.00" "$400.00" "$252.00" "$800.00"
"$543.00" "$143.00" "-$148.00" "-$5.00" "-0.63%" "$4.00" "$10.00"
"-$1.00" "-0.13%")
(sxml->table-row-col sxml 1 1 #f))))

@ -1031,8 +1031,10 @@ gnc_price_print_info (const gnc_commodity *curr, gboolean use_symbol)
if (info.commodity)
{
int frac = gnc_commodity_get_fraction (curr);
guint8 decplaces = 2;
guint8 decplaces = 0;
while (frac != 1 && (frac % 10) == 0 && (frac /= 10)) ++decplaces;
if (force)
decplaces += 2;
info.max_decimal_places = decplaces;
info.min_decimal_places = decplaces;
}

Loading…
Cancel
Save