mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Including brokerage fees in Money Out calculation (if not ignoring them) in advanced-portfolio.scm report and updating the "advanced" tests to reflect selling fees being included into the money out value
This commit is contained in:
parent
d214b2f05d
commit
df6c775617
@ -514,6 +514,7 @@ by preventing negative stock balances.<br/>")
|
||||
(trans-brokerage (gnc-numeric-zero))
|
||||
(trans-shares (gnc-numeric-zero))
|
||||
(shares-bought (gnc-numeric-zero))
|
||||
(shares-sold (gnc-numeric-zero))
|
||||
(trans-sold (gnc-numeric-zero))
|
||||
(trans-bought (gnc-numeric-zero))
|
||||
(trans-spinoff (gnc-numeric-zero))
|
||||
@ -570,8 +571,11 @@ by preventing negative stock balances.<br/>")
|
||||
(gnc-numeric-add trans-bought split-value commod-currency-frac GNC-RND-ROUND))
|
||||
(set! shares-bought
|
||||
(gnc-numeric-add shares-bought split-units units-denom GNC-RND-ROUND)))
|
||||
(set! trans-sold
|
||||
(gnc-numeric-sub trans-sold split-value commod-currency-frac GNC-RND-ROUND)))))
|
||||
(begin
|
||||
(set! trans-sold
|
||||
(gnc-numeric-sub trans-sold split-value commod-currency-frac GNC-RND-ROUND))
|
||||
(set! shares-sold
|
||||
(gnc-numeric-add shares-sold split-units units-denom GNC-RND-ROUND))))))
|
||||
|
||||
((split-account-type? s ACCT-TYPE-ASSET)
|
||||
;; If all the asset accounts mentioned in the transaction are siblings of each other
|
||||
@ -594,7 +598,8 @@ by preventing negative stock balances.<br/>")
|
||||
(gnc:debug "Income: " (gnc-numeric-to-string trans-income)
|
||||
" Brokerage: " (gnc-numeric-to-string trans-brokerage)
|
||||
" Shares traded: " (gnc-numeric-to-string trans-shares)
|
||||
" Shares bought: " (gnc-numeric-to-string shares-bought))
|
||||
" Shares bought: " (gnc-numeric-to-string shares-bought)
|
||||
" Shares sold " (gnc-numeric-to-string shares-sold))
|
||||
(gnc:debug " Value sold: " (gnc-numeric-to-string trans-sold)
|
||||
" Value purchased: " (gnc-numeric-to-string trans-bought)
|
||||
" Spinoff value " (gnc-numeric-to-string trans-spinoff)
|
||||
@ -626,6 +631,14 @@ by preventing negative stock balances.<br/>")
|
||||
(fees (gnc-numeric-mul trans-brokerage fee-frac commod-currency-frac GNC-RND-ROUND)))
|
||||
(set! trans-bought (gnc-numeric-add trans-bought fees commod-currency-frac GNC-RND-ROUND))))
|
||||
|
||||
;; Add brokerage fees to trans-sold if not ignoring them and there are any
|
||||
(if (and (not (eq? handle-brokerage-fees 'ignore-brokerage))
|
||||
(gnc-numeric-positive-p trans-brokerage)
|
||||
(gnc-numeric-positive-p trans-shares))
|
||||
(let* ((fee-frac (gnc-numeric-div shares-sold trans-shares GNC-DENOM-AUTO GNC-DENOM-REDUCE))
|
||||
(fees (gnc-numeric-mul trans-brokerage fee-frac commod-currency-frac GNC-RND-ROUND)))
|
||||
(set! trans-sold (gnc-numeric-add trans-sold fees commod-currency-frac GNC-RND-ROUND))))
|
||||
|
||||
;; Update the running total of the money in the DRP residual account. This is relevant
|
||||
;; if this is a reinvestment transaction (both income and purchase) and there seems to
|
||||
;; asset accounts used to hold excess income.
|
||||
|
@ -103,7 +103,7 @@
|
||||
(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"
|
||||
"$553.00" "$227.88" "-$232.88" "-$5.00" "-0.63%" "$4.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)))
|
||||
|
||||
@ -111,7 +111,7 @@
|
||||
(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"
|
||||
"$553.00" "$286.94" "-$291.94" "-$5.00" "-0.63%" "$4.00" "$10.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)))
|
||||
|
||||
@ -119,7 +119,7 @@
|
||||
(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"
|
||||
"$553.00" "$143.00" "-$148.00" "-$5.00" "-0.63%" "$4.00" "$10.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))))
|
||||
(teardown)))
|
||||
|
Loading…
Reference in New Issue
Block a user