gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Sat Jun 15 23:58:15 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/96311762 (commit)
via https://github.com/Gnucash/gnucash/commit/b49aff32 (commit)
via https://github.com/Gnucash/gnucash/commit/a882afe6 (commit)
via https://github.com/Gnucash/gnucash/commit/c6890264 (commit)
from https://github.com/Gnucash/gnucash/commit/0b389fbd (commit)
commit 963117624ada76fe54ce5923ed16f5f459bf2342
Merge: 0b389fbdef b49aff3215
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 16 11:57:02 2024 +0800
Merge branch 'bug797796' into stable #1958
commit b49aff32151ea4eae3599df839eb06371a26497c
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 16 00:05:20 2024 +0800
[ifrs-cost-basis.scm] simplify monadic arithmetic
diff --git a/gnucash/report/reports/standard/ifrs-cost-basis.scm b/gnucash/report/reports/standard/ifrs-cost-basis.scm
index 4626425a8c..6cb3706058 100644
--- a/gnucash/report/reports/standard/ifrs-cost-basis.scm
+++ b/gnucash/report/reports/standard/ifrs-cost-basis.scm
@@ -140,13 +140,13 @@ the split action field to detect capitalized fees on stock activity")
(case-lambda
(() (error "M- needs at least 1 arg"))
((n) (and n (- n)))
- ((minuend head . tail) (M+ minuend (M- (fold M+ head tail))))))
+ ((head . tail) (M+ head (M- (apply M+ tail))))))
(define M/
(case-lambda
(() (error "M/ needs at least 1 arg"))
((n) (and n (not (zero? n)) (/ n)))
- ((divisor head . tail) (M* divisor (M/ (fold M* head tail))))))
+ ((head . tail) (M* head (M/ (apply M* tail))))))
(define-record-type :txn-info
(make-txn-info stock-amt stock-val proceeds-val
commit a882afe640c3daaee84a3246e18ace1d3622fd49
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 15 16:20:22 2024 +0800
[ifrs-cost-basis.scm] improve names for stock's associated account predicates
and utilitize unicode too
diff --git a/gnucash/report/reports/standard/ifrs-cost-basis.scm b/gnucash/report/reports/standard/ifrs-cost-basis.scm
index 9f14b64061..4626425a8c 100644
--- a/gnucash/report/reports/standard/ifrs-cost-basis.scm
+++ b/gnucash/report/reports/standard/ifrs-cost-basis.scm
@@ -160,53 +160,55 @@ the split action field to detect capitalized fees on stock activity")
(dividend-val get-dividend-val set-dividend-val!)
(capgains-val get-capgains-val set-capgains-val!))
-;; "bitfield" Nabc a=neg b=zero c=pos
-(define (N001 x) (if (number? x) (> x 0) #f))
-(define (N100 x) (if (number? x) (< x 0) #f))
-(define (N010 x) (if (number? x) (= x 0) #t))
-(define (N011 x) (if (number? x) (>= x 0) #t))
-(define (N110 x) (if (number? x) (<= x 0) #t))
-(define (N111 x) #t)
-;; N000 should be (not x) however we can accept a zero-amount split too
-(define (N000 x) (if (number? x) (= x 0) #t))
+;; these functions test the various account values/amounts' signs
+(define (Dr>0 x) (if (number? x) (> x 0) #f))
+(define (Cr>0 x) (if (number? x) (< x 0) #f))
+(define (Drâ¥0 x) (if (number? x) (>= x 0) #t))
+(define (Crâ¥0 x) (if (number? x) (<= x 0) #t))
+(define (DrCr x) #t)
+(define (.... x) (if (number? x) (= x 0) #t))
;; <-- bitfield masks to identify -> purchase?
;; <---- the transaction type -----> | sale?
-;; --stock-- cash cap exp divi capg | | narrative
-;; amt val fees fees
(define open-types
(list
- (list N001 N001 N100 N011 N000 N000 N000 #t #f "Open Long")
- (list N100 N100 N001 N011 N000 N000 N000 #t #f "Open Short")))
+ ;; --stock-- cash cap exp divi capg | | narrative
+ ;; amt val fees fees
+ (list Dr>0 Dr>0 Cr>0 Drâ¥0 .... .... .... #t #f "Open Long")
+ (list Cr>0 Cr>0 Dr>0 Drâ¥0 .... .... .... #t #f "Open Short")))
(define long-types
(list
- (list N001 N001 N100 N011 N000 N000 N000 #t #f "Buy")
- (list N100 N100 N011 N000 N011 N000 N111 #f #t "Sell")
- (list N000 N000 N001 N000 N011 N100 N000 #f #f "Dividend")
- (list N001 N001 N001 N011 N000 N100 N000 #t #f "Dividend reinvestment (w/ remainder)")
- (list N001 N001 N110 N011 N000 N100 N000 #t #f "Dividend reinvestment (w/o remainder)")
- (list N000 N100 N001 N011 N000 N000 N000 #t #f "Return of capital")
- (list N000 N100 N000 N011 N000 N001 N000 #t #f "Return of capital (reclassification)")
- (list N000 N001 N000 N000 N011 N100 N000 #t #f "Notional distribution (dividend)")
- (list N000 N001 N000 N000 N011 N000 N100 #t #f "Notional distribution (capital gain)")
- (list N001 N000 N110 N011 N000 N000 N000 #f #f "Stock split")
- (list N100 N000 N110 N011 N000 N000 N000 #f #f "Reverse split")
- (list N100 N100 N001 N000 N011 N000 N111 #f #t "Reverse split w/ cash in lieu for fractionals")))
+ ;; --stock-- cash cap exp divi capg | | narrative
+ ;; amt val fees fees
+ (list Dr>0 Dr>0 Cr>0 Drâ¥0 .... .... .... #t #f "Buy")
+ (list Cr>0 Cr>0 Drâ¥0 .... Drâ¥0 .... DrCr #f #t "Sell")
+ (list .... .... Dr>0 .... Drâ¥0 Cr>0 .... #f #f "Dividend")
+ (list Dr>0 Dr>0 Dr>0 Drâ¥0 .... Cr>0 .... #t #f "Dividend reinvestment (w/ remainder)")
+ (list Dr>0 Dr>0 Crâ¥0 Drâ¥0 .... Cr>0 .... #t #f "Dividend reinvestment (w/o remainder)")
+ (list .... Cr>0 Dr>0 Drâ¥0 .... .... .... #t #f "Return of capital")
+ (list .... Cr>0 .... Drâ¥0 .... Dr>0 .... #t #f "Return of capital (reclassification)")
+ (list .... Dr>0 .... .... Drâ¥0 Cr>0 .... #t #f "Notional distribution (dividend)")
+ (list .... Dr>0 .... .... Drâ¥0 .... Cr>0 #t #f "Notional distribution (capital gain)")
+ (list Dr>0 .... Crâ¥0 Drâ¥0 .... .... .... #f #f "Stock split")
+ (list Cr>0 .... Crâ¥0 Drâ¥0 .... .... .... #f #f "Reverse split")
+ (list Cr>0 Cr>0 Dr>0 .... Drâ¥0 .... DrCr #f #t "Reverse split w/ cash in lieu for fractionals")))
(define short-types
(list
- (list N100 N100 N001 N011 N000 N000 N000 #t #f "Short Sell")
- (list N001 N001 N110 N000 N011 N000 N111 #f #t "Cover Buy")
- (list N000 N000 N100 N000 N011 N001 N000 #f #f "Compensatory dividend")
- (list N000 N001 N100 N011 N000 N000 N000 #t #f "Compensatory return of capital")
- (list N000 N001 N000 N011 N000 N100 N000 #t #f "Compensatory return of capital (reclassification)")
- (list N000 N100 N000 N000 N011 N001 N000 #t #f "Compensatory notional distribution (dividend)")
- (list N000 N100 N000 N000 N011 N000 N001 #t #f "Compensatory notional distribution (capital gain)")
- (list N100 N000 N110 N011 N000 N000 N000 #f #f "Stock split")
- (list N001 N000 N110 N011 N000 N000 N000 #f #f "Reverse split")
- (list N001 N001 N100 N000 N011 N000 N111 #f #t "Reverse split w/ cash in lieu for fractionals")))
+ ;; --stock-- cash cap exp divi capg | | narrative
+ ;; amt val fees fees
+ (list Cr>0 Cr>0 Dr>0 Drâ¥0 .... .... .... #t #f "Short Sell")
+ (list Dr>0 Dr>0 Crâ¥0 .... Drâ¥0 .... DrCr #f #t "Cover Buy")
+ (list .... .... Cr>0 .... Drâ¥0 Dr>0 .... #f #f "Compensatory dividend")
+ (list .... Dr>0 Cr>0 Drâ¥0 .... .... .... #t #f "Compensatory return of capital")
+ (list .... Dr>0 .... Drâ¥0 .... Cr>0 .... #t #f "Compensatory return of capital (reclassification)")
+ (list .... Cr>0 .... .... Drâ¥0 Dr>0 .... #t #f "Compensatory notional distribution (dividend)")
+ (list .... Cr>0 .... .... Drâ¥0 .... Dr>0 #t #f "Compensatory notional distribution (capital gain)")
+ (list Cr>0 .... Crâ¥0 Drâ¥0 .... .... .... #f #f "Stock split")
+ (list Dr>0 .... Crâ¥0 Drâ¥0 .... .... .... #f #f "Reverse split")
+ (list Dr>0 Dr>0 Cr>0 .... Drâ¥0 .... DrCr #f #t "Reverse split w/ cash in lieu for fractionals")))
(define (cmp amt neg zero pos)
(cond ((< amt 0) neg)
commit c6890264fbaaba949fa55ac67844f2a6da8acf13
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 15 16:08:57 2024 +0800
[ifrs-cost-basis.scm] amend truth table as per bug 797796 comment 241
further amendments to match updated truth table
diff --git a/gnucash/report/reports/standard/ifrs-cost-basis.scm b/gnucash/report/reports/standard/ifrs-cost-basis.scm
index c137c73a7e..9f14b64061 100644
--- a/gnucash/report/reports/standard/ifrs-cost-basis.scm
+++ b/gnucash/report/reports/standard/ifrs-cost-basis.scm
@@ -187,8 +187,10 @@ the split action field to detect capitalized fees on stock activity")
(list N000 N000 N001 N000 N011 N100 N000 #f #f "Dividend")
(list N001 N001 N001 N011 N000 N100 N000 #t #f "Dividend reinvestment (w/ remainder)")
(list N001 N001 N110 N011 N000 N100 N000 #t #f "Dividend reinvestment (w/o remainder)")
- (list N000 N100 N001 N011 N000 N000 N000 #t #f "Return of Capital")
- (list N000 N001 N000 N000 N011 N100 N000 #t #f "Notional distribution")
+ (list N000 N100 N001 N011 N000 N000 N000 #t #f "Return of capital")
+ (list N000 N100 N000 N011 N000 N001 N000 #t #f "Return of capital (reclassification)")
+ (list N000 N001 N000 N000 N011 N100 N000 #t #f "Notional distribution (dividend)")
+ (list N000 N001 N000 N000 N011 N000 N100 #t #f "Notional distribution (capital gain)")
(list N001 N000 N110 N011 N000 N000 N000 #f #f "Stock split")
(list N100 N000 N110 N011 N000 N000 N000 #f #f "Reverse split")
(list N100 N100 N001 N000 N011 N000 N111 #f #t "Reverse split w/ cash in lieu for fractionals")))
@@ -199,7 +201,9 @@ the split action field to detect capitalized fees on stock activity")
(list N001 N001 N110 N000 N011 N000 N111 #f #t "Cover Buy")
(list N000 N000 N100 N000 N011 N001 N000 #f #f "Compensatory dividend")
(list N000 N001 N100 N011 N000 N000 N000 #t #f "Compensatory return of capital")
- (list N000 N100 N000 N000 N011 N001 N000 #t #f "Compensatory notional distribution")
+ (list N000 N001 N000 N011 N000 N100 N000 #t #f "Compensatory return of capital (reclassification)")
+ (list N000 N100 N000 N000 N011 N001 N000 #t #f "Compensatory notional distribution (dividend)")
+ (list N000 N100 N000 N000 N011 N000 N001 #t #f "Compensatory notional distribution (capital gain)")
(list N100 N000 N110 N011 N000 N000 N000 #f #f "Stock split")
(list N001 N000 N110 N011 N000 N000 N000 #f #f "Reverse split")
(list N001 N001 N100 N000 N011 N000 N111 #f #t "Reverse split w/ cash in lieu for fractionals")))
diff --git a/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm b/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
index 27539183aa..cfedbaf772 100644
--- a/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
+++ b/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
@@ -286,7 +286,7 @@
(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))
Summary of changes:
.../report/reports/standard/ifrs-cost-basis.scm | 72 ++++++++++++----------
.../reports/standard/test/test-ifrs-cost-basis.scm | 2 +-
2 files changed, 40 insertions(+), 34 deletions(-)
More information about the gnucash-changes
mailing list