Merge branch 'bug797766' into stable

pull/2070/head
John Ralls 11 months ago
commit acfc8e6ec9

@ -243,7 +243,7 @@
(list "$2,000.00")
(sxml->table-row-col sxml 1 11 4))
(test-equal "multilevel. funds = $14,424.52"
(list "30 FUNDS" "$14,424.52" "$14,424.52")
(list "30. FUNDS" "$14,424.52" "$14,424.52")
(sxml->table-row-col sxml 1 12 3))
(test-equal "multilevel. total broker = $16,424.52"
(list "$16,424.52")
@ -275,10 +275,10 @@
(set-option! balance-sheet-options "Display" "Parent account subtotals" 'f)
(let ((sxml (options->sxml balance-sheet-uuid balance-sheet-options "balsheet-recursive")))
(test-equal "recursive. root = $760+14424.52+106709"
'("#200.00" "$340.00" "30 FUNDS" "$14,424.52" "$106,709.00" "$106,709.00")
'("#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 "recursive. assets = $760+14424.52+106709"
'("#200.00" "$340.00" "30 FUNDS" "$14,424.52" "$106,709.00" "$106,709.00")
'("#200.00" "$340.00" "30. FUNDS" "$14,424.52" "$106,709.00" "$106,709.00")
(sxml->table-row-col sxml 1 4 5))
(test-equal "recursive. bank1 = $4,709.00"
(list "$4,709.00")
@ -296,10 +296,10 @@
(list "$100.00")
(sxml->table-row-col sxml 1 9 3))
(test-equal "recursive. broker = $14424.52+$2000.00"
'("30 FUNDS" "$14,424.52" "$2,000.00" "$2,000.00")
'("30. FUNDS" "$14,424.52" "$2,000.00" "$2,000.00")
(sxml->table-row-col sxml 1 10 4))
(test-equal "recursive. funds = $14424.52"
'("30 FUNDS" "$14,424.52" "$14,424.52")
'("30. FUNDS" "$14,424.52" "$14,424.52")
(sxml->table-row-col sxml 1 11 3))
(test-equal "recursive. foreign = $340.00"
(list "#200.00" "$340.00")
@ -328,10 +328,10 @@
(set-option! balance-sheet-options "Commodities" "Show Exchange Rates" #t)
(let ((sxml (options->sxml balance-sheet-uuid balance-sheet-options "balsheet-enable show-fcur show-rates")))
(test-equal "show-fcur enabled"
'("#200.00" "$340.00" "30 FUNDS" "$14,424.52" "$106,709.00" "$106,709.00")
'("#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.7000")
(sxml->table-row-col sxml 2 #f #f)))
;;make-multilevel
@ -503,10 +503,10 @@
"Retained Earnings" "Total For Equity" "Total For Liability and Equity")
(sxml->table-row-col sxml 1 #f 1))
(test-equal "default balances"
'("#200.00" "$106,709.00" "30 FUNDS" "#200.00" "$106,709.00" "30 FUNDS"
'("#200.00" "$106,709.00" "30. FUNDS" "#200.00" "$106,709.00" "30. FUNDS"
"$4,709.00" "$2,000.00" "$2,609.00" "$0.00" "$100.00" "$2,000.00"
"30 FUNDS" "$2,000.00" "30 FUNDS" "#200.00" "#200.00" "$100,000.00"
"30 FUNDS" "#200.00" "$106,709.00" "$9,500.00" "$9,500.00" "$500.00"
"30. FUNDS" "$2,000.00" "30. FUNDS" "#200.00" "#200.00" "$100,000.00"
"30. FUNDS" "#200.00" "$106,709.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"
"#0.00" "$113,100.00" "#0.00")
(sxml->table-row-col sxml 1 #f 2))
@ -521,26 +521,26 @@
(test-equal "bal-1/1/70"
'("01/01/70" "$113,100.00" "$113,100.00" "$8,970.00" "$2,000.00"
"$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"
"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")
"1. FUNDS $200.0000")
(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"
"$2,609.00" "$0.00" "$100.00" "$11,000.30" "$2,000.00" "$9,000.30"
"30 FUNDS " "$297.03" "$297.03" "#200.00 " "$100,000.00" "$116,006.33"
"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.0100")
(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"
"$2,609.00" "$0.00" "$100.00" "$12,396.63" "$2,000.00" "$10,396.63"
"30 FUNDS " "$331.37" "$331.37" "#200.00 " "$100,000.00" "$117,437.00"
"30. FUNDS " "$331.37" "$331.37" "#200.00 " "$100,000.00" "$117,437.00"
"$9,500.00" "$9,500.00" "$500.00" "$9,000.00" "$9,500.00" "$103,600.00"
"$4,337.00" "$0.00" "$107,937.00" "$117,437.00" "#1.00 $1 + 67/102"
"1 FUNDS $346 + 56/101")
"1. FUNDS $346 + 56/101")
(sxml->table-row-col sxml 1 #f 4)))
(set-option! multi-bs-options "General" "Period order is most recent first" #t)
@ -560,11 +560,11 @@
"multicol-balsheet-retained")))
(test-equal "bal-1/3/80"
'("$122,743.52" "$122,743.52" "$5,129.00" "$2,000.00" "$3,029.00"
"$0.00" "$100.00" "$16,424.52" "$2,000.00" "$14,424.52" "30 FUNDS "
"$0.00" "$100.00" "$16,424.52" "$2,000.00" "$14,424.52" "30. FUNDS "
"$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.7000" "1. FUNDS $480 + 85/104")
(sxml->table-row-col sxml 1 #f 2)))))
(define (multicol-pnl-tests)
@ -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.4990" "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.4550" "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.7000" "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.7000" "1. FUNDS $480 + 85/104")
(sxml->table-row-col sxml 1 -2 -1)))))

@ -261,96 +261,96 @@
(let ((sxml (options->sxml uuid options "latest")))
(test-equal "BUY 100 SPY"
'("07/01/19" "Buy SPY" "100 SPY" "100 SPY" "Open Long" "CAD"
'("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$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.0000"
"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.0000"
"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.0000"
"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"
'("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"
"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.0000"
"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"
' ("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"
"-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.0000"
"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.0000"
"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"
'("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$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"
'("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"
"-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"
'("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"
"-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"
'("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"
"-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"
'("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"
"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"
'("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$8,004.98" "C$27,500.25" "C$27,455.47" "C$27,455.47")
(sxml->table-row-col sxml 1 15 #f))))

@ -1290,8 +1290,7 @@ PrintAmountInternal(char* buf, gnc_numeric val, const GNCPrintAmountInfo *info)
info->max_decimal_places, buf, temp_buf);
}
if (num_decimal_places > 0)
strcat (buf, temp_buf);
strcat (buf, temp_buf);
}
return strlen(buf);

Loading…
Cancel
Save