gnucash maint: [report-utilities] gnc:strify add invoice->str, refine owner->str
Christopher Lam
clam at code.gnucash.org
Sat Oct 26 23:15:43 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/eb929fd6 (commit)
from https://github.com/Gnucash/gnucash/commit/77855a7e (commit)
commit eb929fd6d3020a274562e9860e344239cc2645ce
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Oct 27 11:05:19 2019 +0800
[report-utilities] gnc:strify add invoice->str, refine owner->str
diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index 6daee5c9e..0def54b8f 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -1138,16 +1138,25 @@ flawed. see report-utilities.scm. please update reports.")
(format #f "[~a]"
(gnc:monetary->string mon)))
(define (owner->str owner)
- (define (fn s . rest) (format #f "[~a:~a]" s ((apply compose rest) owner)))
- (let ((t (gncOwnerGetType owner)))
- (cond
- ((eqv? t GNC-OWNER-NONE) "[None]")
- ((eqv? t GNC-OWNER-UNDEFINED) "[Undefined]")
- ((eqv? t GNC-OWNER-JOB) (fn "Job" owner->str gncOwnerGetEndOwner))
- ((eqv? t GNC-OWNER-CUSTOMER) (fn "Cust" gncCustomerGetName gncOwnerGetCustomer))
- ((eqv? t GNC-OWNER-VENDOR) (fn "Vend" gncVendorGetName gncOwnerGetVendor))
- ((eqv? t GNC-OWNER-EMPLOYEE) (fn "Emp" gncEmployeeGetName gncOwnerGetEmployee))
- (else (format #f "[unknown:~a]" owner)))))
+ (define owner-alist
+ (list (cons GNC-OWNER-NONE "None")
+ (cons GNC-OWNER-UNDEFINED "Undefined")
+ (cons GNC-OWNER-JOB "Job")
+ (cons GNC-OWNER-CUSTOMER "Cust")
+ (cons GNC-OWNER-VENDOR "Vend")
+ (cons GNC-OWNER-EMPLOYEE "Emp")))
+ (format #f "[~a:~a]"
+ (or (assv-ref owner-alist (gncOwnerGetType owner)) "Owner")
+ (gncOwnerGetName owner))))
+ (define (invoice->str inv)
+ (format #f "~a<Post:~a,Owner:~a,Notes:~a,Total:~a>"
+ (gncInvoiceGetTypeString inv)
+ (qof-print-date (gncInvoiceGetDatePosted inv))
+ (gncOwnerGetName (gncInvoiceGetOwner inv))
+ (gncInvoiceGetNotes inv)
+ (monetary->string (gnc:make-gnc-monetary
+ (gncInvoiceGetCurrency inv)
+ (gncInvoiceGetTotal inv)))))
(define (try proc)
;; Try proc with d as a parameter, catching exceptions to return
;; #f to the (or) evaluator below.
@@ -1177,6 +1186,7 @@ flawed. see report-utilities.scm. please update reports.")
(try monetary->string)
(try gnc-budget-get-name)
(try owner->str)
+ (try invoice->str)
(object->string d)))
(define (pair->num pair)
Summary of changes:
gnucash/report/report-system/report-utilities.scm | 30 +++++++++++++++--------
1 file changed, 20 insertions(+), 10 deletions(-)
More information about the gnucash-changes
mailing list