gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sat Sep 8 18:09:13 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/7e56a44f (commit)
via https://github.com/Gnucash/gnucash/commit/b05082a0 (commit)
via https://github.com/Gnucash/gnucash/commit/40cbcc11 (commit)
via https://github.com/Gnucash/gnucash/commit/5811f7bf (commit)
via https://github.com/Gnucash/gnucash/commit/0afec128 (commit)
via https://github.com/Gnucash/gnucash/commit/41b0e4eb (commit)
via https://github.com/Gnucash/gnucash/commit/62c9b4e0 (commit)
via https://github.com/Gnucash/gnucash/commit/e0b26628 (commit)
via https://github.com/Gnucash/gnucash/commit/900cd366 (commit)
via https://github.com/Gnucash/gnucash/commit/f1ff608e (commit)
via https://github.com/Gnucash/gnucash/commit/a30a5864 (commit)
via https://github.com/Gnucash/gnucash/commit/b75de5de (commit)
via https://github.com/Gnucash/gnucash/commit/dae877ca (commit)
via https://github.com/Gnucash/gnucash/commit/a0c5be2c (commit)
via https://github.com/Gnucash/gnucash/commit/15b62eea (commit)
via https://github.com/Gnucash/gnucash/commit/74ebac46 (commit)
via https://github.com/Gnucash/gnucash/commit/bfde5a17 (commit)
via https://github.com/Gnucash/gnucash/commit/7ef4c005 (commit)
via https://github.com/Gnucash/gnucash/commit/d6071020 (commit)
via https://github.com/Gnucash/gnucash/commit/996b94b1 (commit)
via https://github.com/Gnucash/gnucash/commit/ba000f71 (commit)
via https://github.com/Gnucash/gnucash/commit/0198a8b8 (commit)
via https://github.com/Gnucash/gnucash/commit/12253f3c (commit)
via https://github.com/Gnucash/gnucash/commit/30f14191 (commit)
via https://github.com/Gnucash/gnucash/commit/0f505d13 (commit)
via https://github.com/Gnucash/gnucash/commit/1afacb97 (commit)
via https://github.com/Gnucash/gnucash/commit/cf3ccb9f (commit)
via https://github.com/Gnucash/gnucash/commit/5467c475 (commit)
via https://github.com/Gnucash/gnucash/commit/874ed6ab (commit)
from https://github.com/Gnucash/gnucash/commit/1a7c5b9a (commit)
commit 7e56a44f6644232f5b0bb8422c285b8578f7de83
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Sep 8 15:08:39 2018 -0700
Remove deleted files from POTFILES.in
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9f051b9..8e327ea 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -416,8 +416,6 @@ gnucash/report/business-reports/balsheet-eg.eguile.scm
gnucash/report/business-reports/balsheet-eg.scm
gnucash/report/business-reports/business-reports.scm
gnucash/report/business-reports/customer-summary.scm
-gnucash/report/business-reports/easy-invoice.scm
-gnucash/report/business-reports/fancy-invoice.scm
gnucash/report/business-reports/invoice.scm
gnucash/report/business-reports/job-report.scm
gnucash/report/business-reports/owner-report.scm
commit b05082a09d916bec87e8608f16f5ba8f164bcc5d
Merge: 1a7c5b9 40cbcc1
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Sep 8 14:43:33 2018 -0700
Merge Chris Lam's consolidated invoice report into maint.
commit 40cbcc11425ec961cd724182978d063aaff242fa
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jun 15 23:10:46 2018 +0800
[invoice] move add-subtotal-row to simplify
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 123825b..38d0421 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -424,19 +424,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
monetary)
monetary))))
- (define (add-subtotal-row table used-columns
- subtotal subtotal-style subtotal-label)
- (let ((subtotal-mon (gnc:make-gnc-monetary currency subtotal)))
-
- (gnc:html-table-append-row/markup!
- table subtotal-style
- (list (gnc:make-html-table-cell/markup
- "total-label-cell" subtotal-label)
- (gnc:make-html-table-cell/size/markup
- 1 (max 3 (num-columns-required used-columns))
- "total-number-cell"
- (display-subtotal subtotal-mon used-columns))))))
-
(define (add-payment-row table used-columns split total-collector reverse-payments?)
(let* ((t (xaccSplitGetParent split))
(currency (xaccTransGetCurrency t))
@@ -526,6 +513,16 @@ for styling the invoice. Please see the exported report for the CSS class names.
(gnc:make-gnc-monetary
currency (gncEntryGetDocValue entry #t cust-doc? credit-note?)))))))
+ (define (add-subtotal-row subtotal subtotal-style subtotal-label)
+ (gnc:html-table-append-row/markup!
+ table subtotal-style
+ (list (gnc:make-html-table-cell/markup
+ "total-label-cell" subtotal-label)
+ (gnc:make-html-table-cell/size/markup
+ 1 (max 3 (num-columns-required used-columns))
+ "total-number-cell"
+ (display-subtotal (gnc:make-gnc-monetary currency subtotal) used-columns)))))
+
(gnc:html-table-set-col-headers! table
(make-heading-list used-columns))
@@ -548,7 +545,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(not odd-row?))))
(if display-subtotal?
- (add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
+ (add-subtotal-row (gncInvoiceGetTotalSubtotal invoice)
"grand-total" (_ "Net Price")))
(if display-all-taxes
@@ -556,15 +553,15 @@ for styling the invoice. Please see the exported report for the CSS class names.
(lambda (parm)
(let ((value (cdr parm))
(acct (car parm)))
- (add-subtotal-row table used-columns value
+ (add-subtotal-row value
"grand-total" (xaccAccountGetName acct))))
(gncInvoiceGetTotalTaxList invoice))
;; nope, just show the total tax.
- (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
+ (add-subtotal-row (gncInvoiceGetTotalTax invoice)
"grand-total" (_ "Tax")))
- (add-subtotal-row table used-columns (gncInvoiceGetTotal invoice)
+ (add-subtotal-row (gncInvoiceGetTotal invoice)
"grand-total" (_ "Total Price"))
(total-collector 'add currency (gncInvoiceGetTotal invoice))
@@ -584,7 +581,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
reverse-payments?)))
splits)))
- (add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
+ (add-subtotal-row (cadr (total-collector 'getpair currency #f))
"grand-total" (_ "Amount Due")))
(begin
commit 5811f7bfc204d99bfdae98ac6da721181065f569
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jun 15 23:08:09 2018 +0800
[invoice] move add-entry-row to simplify
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 7b73bb2..123825b 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -109,63 +109,6 @@
(string-append (gnc:default-html-gnc-numeric-renderer numeric #f) " " (_ "%"))
(gnc:make-gnc-monetary currency numeric)))
-(define (add-entry-row table currency entry column-vector row-style cust-doc? credit-note?)
- (let* ((entry-value (gnc:make-gnc-monetary
- currency (gncEntryGetDocValue entry #t cust-doc? credit-note?)))
- (entry-tax-value (gnc:make-gnc-monetary
- currency (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
-
- (gnc:html-table-append-row/markup!
- table row-style
- (append
- (addif (date-col column-vector)
- (qof-print-date (gncEntryGetDate entry)))
-
- (addif (description-col column-vector)
- (gncEntryGetDescription entry))
-
- (addif (action-col column-vector)
- (gncEntryGetAction entry))
-
- (addif (quantity-col column-vector)
- (gnc:make-html-table-cell/markup "number-cell"
- (gncEntryGetDocQuantity entry credit-note?)))
-
- (addif (price-col column-vector)
- (gnc:make-html-table-cell/markup "number-cell"
- (gnc:make-gnc-monetary
- currency (if cust-doc?
- (gncEntryGetInvPrice entry)
- (gncEntryGetBillPrice entry)))))
-
- (addif (discount-col column-vector)
- (if cust-doc?
- (gnc:make-html-table-cell/markup
- "number-cell"
- (monetary-or-percent (gncEntryGetInvDiscount entry)
- currency
- (gncEntryGetInvDiscountType entry)))
- ""))
-
- (addif (tax-col column-vector)
- (if (if cust-doc?
- (and (gncEntryGetInvTaxable entry)
- (gncEntryGetInvTaxTable entry))
- (and (gncEntryGetBillTaxable entry)
- (gncEntryGetBillTaxTable entry)))
- ;; Translators: This "T" is displayed in the taxable column, if this entry contains tax
- (_ "T") ""))
-
- (addif (taxvalue-col column-vector)
- (gnc:make-html-table-cell/markup
- "number-cell"
- entry-tax-value))
-
- (addif (value-col column-vector)
- (gnc:make-html-table-cell/markup
- "number-cell"
- entry-value))))))
-
(define layout-key-list
(list (cons 'client (list (cons 'text "Client details")
(cons 'tip "Client name and address")))
@@ -527,6 +470,62 @@ for styling the invoice. Please see the exported report for the CSS class names.
(used-columns (build-column-used options))
(entries (gncInvoiceGetEntries invoice)))
+ (define (add-entry-row entry row-style)
+ (gnc:html-table-append-row/markup!
+ table row-style
+ (append
+ (addif (date-col used-columns)
+ (qof-print-date (gncEntryGetDate entry)))
+
+ (addif (description-col used-columns)
+ (gncEntryGetDescription entry))
+
+ (addif (action-col used-columns)
+ (gncEntryGetAction entry))
+
+ (addif (quantity-col used-columns)
+ (gnc:make-html-table-cell/markup
+ "number-cell"
+ (gncEntryGetDocQuantity entry credit-note?)))
+
+ (addif (price-col used-columns)
+ (gnc:make-html-table-cell/markup
+ "number-cell"
+ (gnc:make-gnc-monetary
+ currency (if cust-doc?
+ (gncEntryGetInvPrice entry)
+ (gncEntryGetBillPrice entry)))))
+
+ (addif (discount-col used-columns)
+ (if cust-doc?
+ (gnc:make-html-table-cell/markup
+ "number-cell"
+ (monetary-or-percent (gncEntryGetInvDiscount entry)
+ currency
+ (gncEntryGetInvDiscountType entry)))
+ ""))
+
+ (addif (tax-col used-columns)
+ (if (if cust-doc?
+ (and (gncEntryGetInvTaxable entry)
+ (gncEntryGetInvTaxTable entry))
+ (and (gncEntryGetBillTaxable entry)
+ (gncEntryGetBillTaxTable entry)))
+ ;; Translators: This "T" is displayed in the taxable column, if this entry contains tax
+ (_ "T") ""))
+
+ (addif (taxvalue-col used-columns)
+ (gnc:make-html-table-cell/markup
+ "number-cell"
+ (gnc:make-gnc-monetary
+ currency (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
+
+ (addif (value-col used-columns)
+ (gnc:make-html-table-cell/markup
+ "number-cell"
+ (gnc:make-gnc-monetary
+ currency (gncEntryGetDocValue entry #t cust-doc? credit-note?)))))))
+
(gnc:html-table-set-col-headers! table
(make-heading-list used-columns))
@@ -590,12 +589,8 @@ for styling the invoice. Please see the exported report for the CSS class names.
(begin
- (add-entry-row table
- currency
- (car entries)
- used-columns
- (if odd-row? "normal-row" "alternate-row")
- cust-doc? credit-note?)
+ (add-entry-row (car entries)
+ (if odd-row? "normal-row" "alternate-row"))
(do-rows-with-subtotals (cdr entries)
(not odd-row?)
commit 0afec1288ed5cd5d6f6100970f711a932eb851a8
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jun 15 22:37:51 2018 +0800
[invoice] improve num-columns-used
This will never be perfect because Date/Description/Total can be
switched on/off. But it is simpler.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 4d914e5..7b73bb2 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -64,41 +64,24 @@
(define (value-col columns-used)
(vector-ref columns-used 8))
-(define columns-used-size 9)
-
(define (num-columns-required columns-used)
;; count number of columns where (vector-ref columns-used col) is #t
- (count identity
- (map (lambda (col)
- (vector-ref columns-used col))
- (iota columns-used-size))))
+ (count identity (vector->list columns-used)))
(define (build-column-used options)
(define (opt-val section name)
(gnc:option-value
(gnc:lookup-option options section name)))
-
- (define (make-set-col col-vector)
- (let ((col 0))
- (lambda (used? index)
- (if used?
- (begin
- (vector-set! col-vector index col)
- (set! col (1+ col)))
- (vector-set! col-vector index #f)))))
-
- (let* ((col-vector (make-vector columns-used-size #f))
- (set-col (make-set-col col-vector)))
- (set-col (opt-val "Display Columns" "Date") 0)
- (set-col (opt-val "Display Columns" "Description") 1)
- (set-col (opt-val "Display Columns" "Action") 2)
- (set-col (opt-val "Display Columns" "Quantity") 3)
- (set-col (opt-val "Display Columns" "Price") 4)
- (set-col (opt-val "Display Columns" "Discount") 5)
- (set-col (opt-val "Display Columns" "Taxable") 6)
- (set-col (opt-val "Display Columns" "Tax Amount") 7)
- (set-col (opt-val "Display Columns" "Total") 8)
- col-vector))
+ (vector
+ (opt-val "Display Columns" "Date")
+ (opt-val "Display Columns" "Description")
+ (opt-val "Display Columns" "Action")
+ (opt-val "Display Columns" "Quantity")
+ (opt-val "Display Columns" "Price")
+ (opt-val "Display Columns" "Discount")
+ (opt-val "Display Columns" "Taxable")
+ (opt-val "Display Columns" "Tax Amount")
+ (opt-val "Display Columns" "Total")))
(define (make-heading-list column-vector)
(append
@@ -390,10 +373,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(N_ "Display") (N_ "Individual Taxes")
"o" (N_ "Display all the individual taxes?") #f))
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Totals")
- "p" (N_ "Display the totals?") #t))
+ (gnc:register-inv-option (gnc:make-internal-option "Display" "Totals" #t))
(gnc:register-inv-option
(gnc:make-simple-boolean-option
@@ -491,11 +471,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
(currency (gncInvoiceGetCurrency invoice))
(reverse-payments? (not (gncInvoiceAmountPositive invoice))))
- (define (colspan monetary used-columns)
- (or (value-col used-columns)
- (taxvalue-col used-columns)
- (price-col used-columns)))
-
(define (display-subtotal monetary used-columns)
(if (value-col used-columns)
monetary
@@ -515,7 +490,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(list (gnc:make-html-table-cell/markup
"total-label-cell" subtotal-label)
(gnc:make-html-table-cell/size/markup
- 1 (colspan subtotal-mon used-columns)
+ 1 (max 3 (num-columns-required used-columns))
"total-number-cell"
(display-subtotal subtotal-mon used-columns))))))
@@ -542,7 +517,9 @@ for styling the invoice. Please see the exported report for the CSS class names.
(_ "Payment, thank you"))
(list (gnc:make-html-table-cell/size/markup
- 1 (colspan currency used-columns)
+ 1 (- (max 3 (num-columns-required used-columns))
+ (if (date-col used-columns) 1 0)
+ (if (description-col used-columns) 1 0))
"total-number-cell"
(display-subtotal amt used-columns)))))))
commit 41b0e4eb453a56de6d68101d40f7e8d7cb6155e3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jun 15 15:35:14 2018 +0800
[invoice] simplify single-use functions
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 22a5b32..4d914e5 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -611,9 +611,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
(add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
"grand-total" (_ "Amount Due")))
- ;;
- ;; End of BEGIN -- now here's the code to handle all the entries!
- ;;
(begin
(add-entry-row table
@@ -665,7 +662,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(begin
(gnc:html-table-append-row! invoice-details-table
(list
- (_ "Reference")
+ (_ "Reference:")
(gnc:make-html-div/markup
"div-align-right"
(multiline-to-html-text billing-id))))
@@ -677,7 +674,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(if (and terms (not (string-null? terms)))
(gnc:html-table-append-row! invoice-details-table
(list
- (_ "Terms")
+ (_ "Terms:")
(gnc:make-html-div/markup
"div-align-right"
(multiline-to-html-text terms)))))))
@@ -687,12 +684,12 @@ for styling the invoice. Please see the exported report for the CSS class names.
(not (string-null? jobnumber)))
(begin
(gnc:html-table-append-row! invoice-details-table
- (list (_ "Job number")
+ (list (_ "Job number:")
(gnc:make-html-div/markup
"div-align-right"
jobnumber)))
(gnc:html-table-append-row! invoice-details-table
- (list (_ "Job name")
+ (list (_ "Job name:")
(gnc:make-html-div/markup
"div-align-right"
jobname)))))
@@ -794,8 +791,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(opt-val (lambda (section name) (gnc:option-value (gnc:lookup-option options section name))))
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
(references? (opt-val "Display" "References"))
- (custom-title (opt-val gnc:pagename-general "Custom Title"))
- (title-string (lambda (title custom-title) (if (string-null? custom-title) title custom-title))))
+ (custom-title (opt-val gnc:pagename-general "Custom Title")))
(if (null? invoice)
(gnc:html-document-add-object! document
@@ -805,8 +801,8 @@ for styling the invoice. Please see the exported report for the CSS class names.
(owner (gncInvoiceGetOwner invoice))
(type (gncInvoiceGetType invoice))
(orders (if references? (delete-duplicates (map gncEntryGetOrder (gncInvoiceGetEntries invoice))) '()))
- (cust-doc? (memq type (list GNC-INVOICE-CUST-INVOICE GNC-INVOICE-CUST-CREDIT-NOTE)))
- (credit-note? (memq type (list GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE GNC-INVOICE-EMPL-CREDIT-NOTE)))
+ (cust-doc? (memv type (list GNC-INVOICE-CUST-INVOICE GNC-INVOICE-CUST-CREDIT-NOTE)))
+ (credit-note? (memv type (list GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE GNC-INVOICE-EMPL-CREDIT-NOTE)))
(default-title (case type
((GNC-INVOICE-VEND-INVOICE)
(_ "Bill"))
@@ -816,7 +812,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
(_ "Credit Note"))
(else
(_ "Invoice"))))
- (title (title-string default-title custom-title))
+ (title (if (string-null? custom-title) default-title custom-title))
(invoice-title (format #f (_"~a #~a") title (gncInvoiceGetID invoice)))
(layout-lookup-table (list (cons 'none #f)
(cons 'picture (gnc:make-html-div/markup
commit 62c9b4e02b8b344a04028bc49f342e77e932a274
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 10 20:03:26 2018 +0800
[invoice] [CSS] remove styles and replace with CSS
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 5a51161..22a5b32 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -35,8 +35,15 @@
(define (addif pred . data) (if pred data '()))
-(define base-css ".align-right { float: right; text-align: right }
-.entries-table > table { width: 100% }")
+(define base-css "/* advanced users only */
+.div-align-right { float: right; }
+.div-align-right .maybe-align-right { text-align: right }
+.entries-table * { border-width: 1px; border-style:solid; border-collapse: collapse}
+.entries-table > table { width: 100% }
+.company-table > table * { padding: 0px; }
+.client-table > table * { padding: 0px; }
+.invoice-details-table > table * { padding: 0px; }
+")
(define (date-col columns-used)
(vector-ref columns-used 0))
@@ -546,11 +553,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
(gnc:html-table-set-col-headers! table
(make-heading-list used-columns))
- (gnc:html-table-set-style! table "table"
- 'attribute (list "border" 1)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 4))
-
(let do-rows-with-subtotals ((entries entries)
(odd-row? #t)
(num-entries 0))
@@ -638,11 +640,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
(jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice)))))
- (gnc:html-table-set-style! invoice-details-table "table"
- 'attribute (list "align" "right")
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 1))
-
(if (gncInvoiceIsPosted invoice)
(begin
@@ -669,7 +666,9 @@ for styling the invoice. Please see the exported report for the CSS class names.
(gnc:html-table-append-row! invoice-details-table
(list
(_ "Reference")
- (multiline-to-html-text billing-id)))
+ (gnc:make-html-div/markup
+ "div-align-right"
+ (multiline-to-html-text billing-id))))
(gnc:html-table-append-row! invoice-details-table '())))))
(if (opt-val "Display" "Billing Terms")
@@ -679,7 +678,9 @@ for styling the invoice. Please see the exported report for the CSS class names.
(gnc:html-table-append-row! invoice-details-table
(list
(_ "Terms")
- (multiline-to-html-text terms))))))
+ (gnc:make-html-div/markup
+ "div-align-right"
+ (multiline-to-html-text terms)))))))
;; Add job number and name to invoice if requested and if it exists
(if (and (opt-val "Display" "Job Details")
@@ -687,10 +688,14 @@ for styling the invoice. Please see the exported report for the CSS class names.
(begin
(gnc:html-table-append-row! invoice-details-table
(list (_ "Job number")
- jobnumber))
+ (gnc:make-html-div/markup
+ "div-align-right"
+ jobnumber)))
(gnc:html-table-append-row! invoice-details-table
(list (_ "Job name")
- jobname))))
+ (gnc:make-html-div/markup
+ "div-align-right"
+ jobname)))))
invoice-details-table))
(define (make-img img-url)
@@ -701,21 +706,17 @@ for styling the invoice. Please see the exported report for the CSS class names.
(define (make-client-table owner orders)
;; this is a single-column table.
(let ((table (gnc:make-html-table)))
- (gnc:html-table-set-style! table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0))
(gnc:html-table-append-row! table
(list
- (gnc:make-html-span/markup
- "client-name"
+ (gnc:make-html-div/markup
+ "maybe-align-right client-name"
(gnc:owner-get-name-dep owner))))
(gnc:html-table-append-row! table
(list
- (gnc:make-html-span/markup
- "client-address"
+ (gnc:make-html-div/markup
+ "maybe-align-right client-address"
(multiline-to-html-text
(gnc:owner-get-address-dep owner)))))
@@ -734,8 +735,10 @@ for styling the invoice. Please see the exported report for the CSS class names.
(define (make-date-row label date date-format)
(list
(string-append label ":")
- (strftime date-format
- (localtime date))))
+ (gnc:make-html-div/markup
+ "div-align-right"
+ (strftime date-format
+ (localtime date)))))
(define (make-company-table book)
;; single-column table. my name, address, and printdate
@@ -748,39 +751,40 @@ for styling the invoice. Please see the exported report for the CSS class names.
(url (gnc:company-info book gnc:*company-url*))
(taxid (gnc:company-info book gnc:*company-id*)))
- (gnc:html-table-set-style! table "table"
- 'attribute (list "border" 0)
- 'attribute (list "valign" "top")
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0))
-
(if (and name (not (string-null? name)))
- (gnc:html-table-append-row! table (gnc:make-html-div/markup
- "align-right company-name" name)))
+ (gnc:html-table-append-row! table (list
+ (gnc:make-html-div/markup
+ "maybe-align-right company-name" name))))
(if (and addy (not (string-null? addy)))
- (gnc:html-table-append-row! table (gnc:make-html-div/markup
- "align-right company-address" (multiline-to-html-text addy))))
+ (gnc:html-table-append-row! table (list
+ (gnc:make-html-div/markup
+ "maybe-align-right company-address" (multiline-to-html-text addy)))))
(if (and phone (not (string-null? phone)))
- (gnc:html-table-append-row! table (gnc:make-html-div/markup
- "align-right company-phone" phone)))
+ (gnc:html-table-append-row! table (list
+ (gnc:make-html-div/markup
+ "maybe-align-right company-phone" phone))))
(if (and fax (not (string-null? fax)))
- (gnc:html-table-append-row! table (gnc:make-html-div/markup
- "align-right company-fax" fax)))
+ (gnc:html-table-append-row! table (list
+ (gnc:make-html-div/markup
+ "maybe-align-right company-fax" fax))))
(if (and email (not (string-null? email)))
- (gnc:html-table-append-row! table (gnc:make-html-div/markup
- "align-right company-email" email)))
+ (gnc:html-table-append-row! table (list
+ (gnc:make-html-div/markup
+ "maybe-align-right company-email" email))))
(if (and url (not (string-null? url)))
- (gnc:html-table-append-row! table (gnc:make-html-div/markup
- "align-right company-url" url)))
+ (gnc:html-table-append-row! table (list
+ (gnc:make-html-div/markup
+ "maybe-align-right company-url" url))))
(if (and taxid (not (string-null? taxid)))
- (gnc:html-table-append-row! table (gnc:make-html-div/markup
- "align-right company-tax-id" taxid)))
+ (gnc:html-table-append-row! table (list
+ (gnc:make-html-div/markup
+ "maybe-align-right company-tax-id" taxid))))
table))
@@ -848,19 +852,19 @@ for styling the invoice. Please see the exported report for the CSS class names.
(gnc:html-table-append-row! main-table
(list (layout-lookup "Row 1 Left")
(gnc:make-html-div/markup
- "align-right"
+ "div-align-right"
(layout-lookup "Row 1 Right"))))
(gnc:html-table-append-row! main-table
(list (layout-lookup "Row 2 Left")
(gnc:make-html-div/markup
- "align-right"
+ "div-align-right"
(layout-lookup "Row 2 Right"))))
(gnc:html-table-append-row! main-table
(list (layout-lookup "Row 3 Left")
(gnc:make-html-div/markup
- "align-right"
+ "div-align-right"
(layout-lookup "Row 3 Right"))))
(gnc:html-table-append-row! main-table
commit e0b26628f88d73779557c9c52c3c3e95f804acd3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 9 17:28:07 2018 +0800
[test-invoice] all variants share same options and html structure
Therefore test-invoice variants now all share the same tests.
diff --git a/gnucash/report/business-reports/test/test-invoice.scm b/gnucash/report/business-reports/test/test-invoice.scm
index 638dfab..ba37588 100644
--- a/gnucash/report/business-reports/test/test-invoice.scm
+++ b/gnucash/report/business-reports/test/test-invoice.scm
@@ -45,8 +45,11 @@
(inv-tests 'fancy-invoice)
(test-end "test-invoice.scm"))
-(define (sxml-main-get-row-col sxml row col)
- (sxml->table-row-col sxml 3 row col))
+(define (sxml-get-row-col classname sxml row col)
+ (sxml->table-row-col
+ ((sxpath `(// (div (@ (equal? (class ,classname))))))
+ sxml)
+ 1 row col))
(define (set-option! options section name value)
(let ((option (gnc:lookup-option options section name)))
@@ -192,27 +195,15 @@
(for-each
(lambda (disp-col-name)
(set-option! options "Display Columns" disp-col-name setting))
- (case variant
- ((invoice fancy-invoice easy-invoice)
- '("Date" "Description" "Action" "Quantity" "Price" "Discount"
+ '("Date" "Description" "Action" "Quantity" "Price" "Discount"
"Taxable" "Tax Amount" "Total"))
- (else '())))
(for-each
(lambda (disp-col-name)
(set-option! options "Display" disp-col-name setting))
- (case variant
- ((invoice)
- '("My Company" "My Company ID" "Due Date"
- "Individual Taxes" "Totals" "Subtotal" "References" "Billing Terms"
- "Billing ID" "Invoice Notes" "Payments" "Job Details"))
- ((fancy-invoice)
- '("Individual Taxes" "Totals" "References" "Billing Terms"
- "Billing ID" "Invoice Notes" "Payments"))
- ((easy-invoice)
- '("My Company" "My Company ID" "Due Date"
- "Individual Taxes" "Totals" "Subtotal" "References"
- "Billing Terms" "Billing ID" "Invoice Notes"
- "Payments"))))
+ '("My Company" "My Company ID" "Due Date"
+ "Individual Taxes" "Totals" "Subtotal" "References"
+ "Billing Terms" "Billing ID" "Invoice Notes"
+ "Payments" "Job Details"))
options))
;; entry-1 2 widgets of $3 = $6
@@ -231,20 +222,16 @@
(sxml (options->sxml options "inv-1 simple entry")))
(test-equal "inv-1 simple entry amounts are correct"
'("$6.00" "$6.00" "$6.00" "$6.00")
- (sxml-main-get-row-col sxml #f -1))
+ (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.00" "0.00 %" "T" "$0.00" "$6.00")
- (cdr (sxml-main-get-row-col sxml 1 #f)))
- (unless (eq? variant 'fancy-invoice)
- (test-equal "inv-1 cust-name is correct"
- '("cust-1-name")
- ((sxpath '(// (table 2) // tbody // tr // td // *text*))
- sxml)))
+ (cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
+ (test-equal "inv-1 cust-name is correct"
+ '("cust-1-name")
+ (sxml-get-row-col "client-table" sxml 1 1))
(test-assert "inv-1-billing-id is in invoice body"
(member
- (case variant
- ((invoice fancy-invoice) "Reference:\xa0inv-1-billing-id")
- ((easy-invoice) "Billing ID:\xa0inv-1-billing-id"))
+ "inv-1-billing-id"
((sxpath '(// body // *text*)) sxml)))
(test-assert "inv-1 inv-notes is in invoice body"
(member
@@ -256,16 +243,11 @@
(let* ((options (default-testing-options inv-1 #f))
(sxml (options->sxml options "inv-1 simple entry sparse")))
(test-equal "inv-1 sparse simple entry headers are correct"
- (case variant
- ((invoice) '("Net Price" "Tax" "Total Price" "Amount Due"))
- ((fancy-invoice) '("Net Price" "Tax" "Total\xa0Price" "Amount\xa0Due"))
- ((easy-invoice) '("Tax" "Total Price" "Amount Due")))
- (sxml-main-get-row-col sxml #f 1))
+ '("Tax" "Total Price" "Amount Due")
+ (sxml-get-row-col "entries-table" sxml #f 1))
(test-equal "inv-1 sparse simple entry amounts are correct"
- (case variant
- ((invoice fancy-invoice) '("$6.00" "$0.00" "$6.00" "$6.00"))
- ((easy-invoice) '("$0.00" "$6.00" "$6.00")))
- (sxml-main-get-row-col sxml #f -1)))
+ '("$0.00" "$6.00" "$6.00")
+ (sxml-get-row-col "entries-table" sxml #f -1)))
(test-end "inv-1 simple entry, sparse options")
(test-begin "inv-2")
@@ -294,29 +276,25 @@
(sxml (options->sxml options "inv-2 simple entry")))
(test-equal "inv-2 simple entry amounts are correct"
'("$6.00" "$6.00" "$6.00" "$6.00")
- (sxml-main-get-row-col sxml #f -1))
+ (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.00" "0.00 %" "T" "$0.00" "$6.00")
- (cdr (sxml-main-get-row-col sxml 1 #f)))
- (unless (eq? variant 'fancy-invoice)
- (test-equal "inv-2 cust-name is correct"
- '("cust-1-name")
- ((sxpath '(// (table 2) // tbody // tr // td // *text*))
- sxml)))
+ (cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
+ (test-equal "inv-2 cust-name is correct"
+ '("cust-1-name")
+ (sxml-get-row-col "client-table" sxml 1 1))
(test-assert "inv-2 inv-notes is in invoice body"
(member
"inv-2-notes"
((sxpath '(// body // *text*)) sxml)))
- (when (eq? variant 'invoice)
- (test-assert "inv-2 jobnumber is in invoice body"
- (member
- "Job number:\xa0job-1-id"
- ((sxpath '(// body // *text*)) sxml)))
- (test-assert "inv-2 jobname is in invoice body"
- (member
- "Job name:\xa0job-1-name"
- ((sxpath '(// body // *text*)) sxml))))
- )
+ (test-assert "inv-2 jobnumber is in invoice body"
+ (member
+ "job-1-id"
+ ((sxpath '(// body // *text*)) sxml)))
+ (test-assert "inv-2 jobname is in invoice body"
+ (member
+ "job-1-name"
+ ((sxpath '(// body // *text*)) sxml))))
(test-end "inv-2")
(test-begin "inv-3")
@@ -334,15 +312,13 @@
(sxml (options->sxml options "inv-3 simple entry")))
(test-equal "inv-3 simple entry amounts are correct"
'("$6.00" "$6.00" "$6.00" "$6.00")
- (sxml-main-get-row-col sxml #f -1))
+ (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.00" "T" "$0.00" "$6.00")
- (cdr (sxml-main-get-row-col sxml 1 #f)))
- (unless (eq? variant 'fancy-invoice)
- (test-equal "inv-3 vend-name is correct"
- '("vend-1-name")
- ((sxpath '(// (table 2) // tbody // tr // td // *text*))
- sxml)))
+ (cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
+ (test-equal "inv-3 vend-name is correct"
+ '("vend-1-name")
+ (sxml-get-row-col "client-table" sxml 1 1))
(test-assert "inv-3 inv-notes is in invoice body"
(member
"inv-3-notes"
@@ -365,15 +341,13 @@
(sxml (options->sxml options "inv-4 simple entry")))
(test-equal "inv-4 simple entry amounts are correct"
'("$6.00" "$6.00" "$6.00" "$6.00")
- (sxml->table-row-col sxml 3 #f -1))
+ (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.00" "T" "$0.00" "$6.00")
- (cdr (sxml->table-row-col sxml 3 1 #f)))
- (unless (eq? variant 'fancy-invoice)
- (test-equal "inv-4 vend-name is correct"
- '("emp-1-name" "emp-1-name") ;FIXME: why is this duplicated????
- ((sxpath '(// (table 2) // tbody // tr // td // *text*))
- sxml)))
+ (cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
+ (test-equal "inv-4 vend-name is correct"
+ '("emp-1-name")
+ (sxml-get-row-col "client-table" sxml 1 1))
(test-assert "inv-4 inv-notes is in invoice body"
(member
"inv-4-notes"
@@ -395,15 +369,13 @@
(sxml (options->sxml options "inv-5 simple entry")))
(test-equal "inv-5 simple entry amounts are correct"
'("$6.00" "$6.00" "$6.00" "$6.00")
- (sxml-main-get-row-col sxml #f -1))
+ (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.00" "0.00 %" "T" "$0.00" "$6.00")
- (cdr (sxml-main-get-row-col sxml 1 #f)))
- (unless (eq? variant 'fancy-invoice)
- (test-equal "inv-5 cust-name is correct"
- '("cust-1-name")
- ((sxpath '(// (table 2) // tbody // tr // td // *text*))
- sxml))))
+ (cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
+ (test-equal "inv-5 cust-name is correct"
+ '("cust-1-name")
+ (sxml-get-row-col "client-table" sxml 1 1)))
(test-end "inv-5 simple entry")
(test-begin "inv-6")
@@ -420,15 +392,13 @@
(sxml (options->sxml options "inv-6 simple entry")))
(test-equal "inv-6 simple entry amounts are correct"
'("$6.00" "$6.00" "$6.00" "$6.00")
- (sxml-main-get-row-col sxml #f -1))
+ (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.00" "T" "$0.00" "$6.00")
- (cdr (sxml-main-get-row-col sxml 1 #f)))
- (unless (eq? variant 'fancy-invoice)
- (test-equal "inv-6 vend-name is correct"
- '("vend-1-name")
- ((sxpath '(// (table 2) // tbody // tr // td // *text*))
- sxml)))
+ (cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
+ (test-equal "inv-6 vend-name is correct"
+ '("vend-1-name")
+ (sxml-get-row-col "client-table" sxml 1 1))
(test-assert "inv-6 inv-3-notes is in invoice body"
(member
"inv-3-notes"
@@ -450,15 +420,13 @@
(sxml (options->sxml options "inv-7 simple entry")))
(test-equal "inv-7 simple entry amounts are correct"
'("$6.00" "$6.00" "$6.00" "$6.00")
- (sxml-main-get-row-col sxml #f -1))
+ (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.00" "T" "$0.00" "$6.00")
- (cdr (sxml-main-get-row-col sxml 1 #f)))
- (unless (eq? variant 'fancy-invoice)
- (test-equal "inv-7 vend-name is correct"
- '("emp-1-name" "emp-1-name") ;FIXME: why is this duplicated????
- ((sxpath '(// (table 2) // tbody // tr // td // *text*))
- sxml)))
+ (cdr (sxml-get-row-col "entries-table" sxml 1 #f)))
+ (test-equal "inv-7 vend-name is correct"
+ '("emp-1-name")
+ (sxml-get-row-col "client-table" sxml 1 1))
(test-assert "inv-7 inv-4-notes is in invoice body"
(member
"inv-4-notes"
@@ -558,34 +526,23 @@
(sxml (options->sxml options "inv-8 combinatorics")))
(test-assert "inv-8 billterm-desc is in invoice body"
(member
- "Terms:\xa0billterm-desc"
+ "billterm-desc"
((sxpath '(// body // *text*)) sxml)))
(test-assert "inv-8 gncOrder reference is in invoice body"
(member
- "REF:\xa0order-ref"
+ "REF order-ref"
((sxpath '(// body // *text*)) sxml)))
- (case variant
- ((invoice)
- (test-equal "inv-8 invoice date is in invoice body"
- '("Invoice Date:\xa0")
- (sxml->table-row-col sxml 2 1 1))
- (test-equal "inv-8 due date is in invoice body"
- '("Due Date:\xa0")
- (sxml->table-row-col sxml 2 2 1)))
- ((easy-invoice)
- (test-equal "inv-8 invoice date is in invoice body"
- '("Date:\xa0")
- (sxml->table-row-col sxml 3 1 1))
- (test-equal "inv-8 invoice date is in invoice body"
- '("Due:\xa0")
- (sxml->table-row-col sxml 3 2 1))))
+ (test-equal "inv-8 invoice date is in invoice body"
+ '("Date:")
+ (sxml-get-row-col "invoice-details-table" sxml 1 1))
+ (test-equal "inv-8 due date is in invoice body"
+ '("Due Date:")
+ (sxml-get-row-col "invoice-details-table" sxml 2 1))
(test-equal "inv-8 combo amounts are correct"
'("$2,133.25" "$2,061.96" "$2,133.25" "$2,061.96" "$2,133.25" "$2,133.25"
"$1,851.95" "$1,859.30" "$16,368.17" "$1,111.01" "$17,479.18"
"-$17,479.18" "$0.00")
- (if (eq? variant 'fancy-invoice)
- (sxml->table-row-col sxml 3 #f -1)
- (sxml->table-row-col sxml 4 #f -1)))
+ (sxml-get-row-col "entries-table" sxml #f -1))
(test-assert "inv-8 is fully paid up!"
(gncInvoiceIsPaid inv-8))))
(test-end "combinations of gncEntry options")))
commit 900cd3666786ace6255fed03b46d9a02b598d28f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 10 11:05:40 2018 +0800
[invoice] add toggle for invoice title
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index f26b8b0..5a51161 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -332,6 +332,11 @@ for styling the invoice. Please see the exported report for the CSS class names.
(gnc:register-inv-option
(gnc:make-simple-boolean-option
+ (N_ "Display") (N_ "Title")
+ "a" (N_ "Display invoice title and invoice ID?") #t))
+
+ (gnc:register-inv-option
+ (gnc:make-simple-boolean-option
(N_ "Display") (N_ "Due Date")
"c" (N_ "Display due date?") #t))
@@ -834,10 +839,11 @@ for styling the invoice. Please see the exported report for the CSS class names.
(let ((main-table (gnc:make-html-table)))
- (gnc:html-table-append-row! main-table
- (gnc:make-html-table-cell/size
- 1 2 (gnc:make-html-div/markup
- "invoice-title" invoice-title)))
+ (if (opt-val "Display" "Title")
+ (gnc:html-table-append-row! main-table
+ (gnc:make-html-table-cell/size
+ 1 2 (gnc:make-html-div/markup
+ "invoice-title" invoice-title))))
(gnc:html-table-append-row! main-table
(list (layout-lookup "Row 1 Left")
commit f1ff608e3ce7a2cae8fd29898eca708c3a3ddf31
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 10 10:37:20 2018 +0800
[invoice] enable displaying a picture eg company logo in layout
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 4e1fdc8..f26b8b0 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -189,6 +189,9 @@
(cons 'today (list (cons 'text "Today's date")
(cons 'tip "Today's date")))
+ (cons 'picture (list (cons 'text "Picture")
+ (cons 'tip "Picture")))
+
(cons 'none (list (cons 'text "(empty)")
(cons 'tip "Empty space")))))
@@ -273,6 +276,11 @@ for styling the invoice. Please see the exported report for the CSS class names.
(keylist-get-info variant-list variant 'css)))
(gnc:register-inv-option
+ (gnc:make-pixmap-option
+ (N_ "Layout") (N_ "Picture Location") "zy" "Location for Picture"
+ ""))
+
+ (gnc:register-inv-option
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Date")
"b" (N_ "Display the date?") #t))
@@ -680,6 +688,11 @@ for styling the invoice. Please see the exported report for the CSS class names.
jobname))))
invoice-details-table))
+(define (make-img img-url)
+ ;; just an image
+ (gnc:make-html-text
+ (gnc:html-markup-img img-url)))
+
(define (make-client-table owner orders)
;; this is a single-column table.
(let ((table (gnc:make-html-table)))
@@ -797,6 +810,9 @@ for styling the invoice. Please see the exported report for the CSS class names.
(title (title-string default-title custom-title))
(invoice-title (format #f (_"~a #~a") title (gncInvoiceGetID invoice)))
(layout-lookup-table (list (cons 'none #f)
+ (cons 'picture (gnc:make-html-div/markup
+ "picture"
+ (make-img (opt-val "Layout" "Picture Location"))))
(cons 'invoice (gnc:make-html-div/markup
"invoice-details-table"
(make-invoice-details-table
commit a30a58641d22a4b98fcd12ca7ae2ca9e83ef57f3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 10 09:53:23 2018 +0800
[invoice] change do-rows-with-subtotals to named let
This function is only defined once, and use named-let which imho is
neater because it defines the init values explicitly.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 0ada398..4e1fdc8 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -526,86 +526,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
"total-number-cell"
(display-subtotal amt used-columns)))))))
- (define (do-rows-with-subtotals entries
- table
- used-columns
- width
- odd-row?
- num-entries)
- (if (null? entries)
-
- ;; all entries done, add subtotals
- (let ((total-collector (gnc:make-commodity-collector)))
-
- ;; minimum number of entries- replicating fancy-invoice option
- (let loop ((num-entries-left (- (opt-val "Display" "Minimum # of entries" ) num-entries))
- (odd-row? odd-row?))
- (when (positive? num-entries-left)
- (gnc:html-table-append-row/markup!
- table (if odd-row? "normal-row" "alternate-row")
- (gnc:html-make-empty-cells (num-columns-required used-columns)))
- (loop (1- num-entries-left)
- (not odd-row?))))
-
- (if display-subtotal?
- (add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
- "grand-total" (_ "Net Price")))
-
- (if display-all-taxes
- (for-each
- (lambda (parm)
- (let ((value (cdr parm))
- (acct (car parm)))
- (add-subtotal-row table used-columns value
- "grand-total" (xaccAccountGetName acct))))
- (gncInvoiceGetTotalTaxList invoice))
-
- ;; nope, just show the total tax.
- (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
- "grand-total" (_ "Tax")))
-
- (add-subtotal-row table used-columns (gncInvoiceGetTotal invoice)
- "grand-total" (_ "Total Price"))
-
- (total-collector 'add currency (gncInvoiceGetTotal invoice))
-
- (if (and show-payments (not (null? lot)))
- (let ((splits (sort-list!
- (gnc-lot-get-split-list lot)
- (lambda (s1 s2)
- (let ((t1 (xaccSplitGetParent s1))
- (t2 (xaccSplitGetParent s2)))
- (< (xaccTransOrder t1 t2) 0))))))
- (for-each
- (lambda (split)
- (if (not (equal? (xaccSplitGetParent split) txn))
- (add-payment-row table used-columns
- split total-collector
- reverse-payments?)))
- splits)))
-
- (add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
- "grand-total" (_ "Amount Due")))
-
- ;;
- ;; End of BEGIN -- now here's the code to handle all the entries!
- ;;
- (begin
-
- (add-entry-row table
- currency
- (car entries)
- used-columns
- (if odd-row? "normal-row" "alternate-row")
- cust-doc? credit-note?)
-
- (do-rows-with-subtotals (cdr entries)
- table
- used-columns
- width
- (not odd-row?)
- (1+ num-entries)))))
-
(let* ((table (gnc:make-html-table))
(used-columns (build-column-used options))
(entries (gncInvoiceGetEntries invoice)))
@@ -618,12 +538,80 @@ for styling the invoice. Please see the exported report for the CSS class names.
'attribute (list "cellspacing" 0)
'attribute (list "cellpadding" 4))
- (do-rows-with-subtotals entries
- table
- used-columns
- width
- #t
- 0)
+ (let do-rows-with-subtotals ((entries entries)
+ (odd-row? #t)
+ (num-entries 0))
+ (if (null? entries)
+
+ ;; all entries done, add subtotals
+ (let ((total-collector (gnc:make-commodity-collector)))
+
+ ;; minimum number of entries- replicating fancy-invoice option
+ (let loop ((num-entries-left (- (opt-val "Display" "Minimum # of entries" ) num-entries))
+ (odd-row? odd-row?))
+ (when (positive? num-entries-left)
+ (gnc:html-table-append-row/markup!
+ table (if odd-row? "normal-row" "alternate-row")
+ (gnc:html-make-empty-cells (num-columns-required used-columns)))
+ (loop (1- num-entries-left)
+ (not odd-row?))))
+
+ (if display-subtotal?
+ (add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
+ "grand-total" (_ "Net Price")))
+
+ (if display-all-taxes
+ (for-each
+ (lambda (parm)
+ (let ((value (cdr parm))
+ (acct (car parm)))
+ (add-subtotal-row table used-columns value
+ "grand-total" (xaccAccountGetName acct))))
+ (gncInvoiceGetTotalTaxList invoice))
+
+ ;; nope, just show the total tax.
+ (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
+ "grand-total" (_ "Tax")))
+
+ (add-subtotal-row table used-columns (gncInvoiceGetTotal invoice)
+ "grand-total" (_ "Total Price"))
+
+ (total-collector 'add currency (gncInvoiceGetTotal invoice))
+
+ (if (and show-payments (not (null? lot)))
+ (let ((splits (sort-list!
+ (gnc-lot-get-split-list lot)
+ (lambda (s1 s2)
+ (let ((t1 (xaccSplitGetParent s1))
+ (t2 (xaccSplitGetParent s2)))
+ (< (xaccTransOrder t1 t2) 0))))))
+ (for-each
+ (lambda (split)
+ (if (not (equal? (xaccSplitGetParent split) txn))
+ (add-payment-row table used-columns
+ split total-collector
+ reverse-payments?)))
+ splits)))
+
+ (add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
+ "grand-total" (_ "Amount Due")))
+
+ ;;
+ ;; End of BEGIN -- now here's the code to handle all the entries!
+ ;;
+ (begin
+
+ (add-entry-row table
+ currency
+ (car entries)
+ used-columns
+ (if odd-row? "normal-row" "alternate-row")
+ cust-doc? credit-note?)
+
+ (do-rows-with-subtotals (cdr entries)
+ (not odd-row?)
+ (1+ num-entries)))))
+
table)))
(define (make-invoice-details-table invoice options)
commit b75de5de1f7de0c40cc638dd4595d3e267b979bc
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 10 10:17:14 2018 +0800
[invoice] refinements
1. disable Display/My Company toggle - this is now in Layout
2. streamline internal functions to reduce number of definitions
3. company-details now right-align and add more fields.
fields can be hidden via CSS. no need for further display options.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 45ac2b9..0ada398 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -174,9 +174,7 @@
(addif (value-col column-vector)
(gnc:make-html-table-cell/markup
"number-cell"
- entry-value))))
-
- (cons entry-value entry-tax-value)))
+ entry-value))))))
(define layout-key-list
(list (cons 'client (list (cons 'text "Client details")
@@ -319,15 +317,10 @@ for styling the invoice. Please see the exported report for the CSS class names.
(N_ "Display Columns") (N_ "Total")
"n" (N_ "Display the entry's value?") #t))
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "My Company")
- "a" (N_ "Display my company name and address?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "My Company ID")
- "b" (N_ "Display my company ID?") #f))
+ ;; company details can now be toggled via Layout tab
+ ;; and IMHO company-tax-id should be rendered if present
+ (gnc:register-inv-option (gnc:make-internal-option "Display" "My Company" #f))
+ (gnc:register-inv-option (gnc:make-internal-option "Display" "My Company ID" #f))
(gnc:register-inv-option
(gnc:make-simple-boolean-option
@@ -476,8 +469,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
(lot (gncInvoiceGetPostedLot invoice))
(txn (gncInvoiceGetPostedTxn invoice))
(currency (gncInvoiceGetCurrency invoice))
- (jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
- (jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(reverse-payments? (not (gncInvoiceAmountPositive invoice))))
(define (colspan monetary used-columns)
@@ -617,7 +608,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
(let* ((table (gnc:make-html-table))
(used-columns (build-column-used options))
- (width (num-columns-required used-columns))
(entries (gncInvoiceGetEntries invoice)))
(gnc:html-table-set-col-headers! table
@@ -636,7 +626,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
0)
table)))
-(define (make-invoice-details-table invoice options display-due-date?)
+(define (make-invoice-details-table invoice options)
;; dual-column. invoice date/due, billingID, terms, job name/number
(define (opt-val section name)
(gnc:option-value
@@ -654,16 +644,15 @@ for styling the invoice. Please see the exported report for the CSS class names.
(if (gncInvoiceIsPosted invoice)
- (let ((post-date (gncInvoiceGetDatePosted invoice))
- (due-date (gncInvoiceGetDateDue invoice)))
+ (begin
(gnc:html-table-append-row!
invoice-details-table
- (make-date-row (_ "Date") post-date date-format))
+ (make-date-row (_ "Date") (gncInvoiceGetDatePosted invoice) date-format))
- (if display-due-date?
+ (if (opt-val "Display" "Due Date")
(gnc:html-table-append-row!
invoice-details-table
- (make-date-row (_ "Due Date") due-date date-format))))
+ (make-date-row (_ "Due Date") (gncInvoiceGetDateDue invoice) date-format))))
(gnc:html-table-append-row! invoice-details-table
(gnc:make-html-table-cell/size
@@ -742,11 +731,15 @@ for styling the invoice. Please see the exported report for the CSS class names.
(strftime date-format
(localtime date))))
-(define (make-company-table book date-format display-tax-id?)
+(define (make-company-table book)
;; single-column table. my name, address, and printdate
(let* ((table (gnc:make-html-table))
(name (gnc:company-info book gnc:*company-name*))
(addy (gnc:company-info book gnc:*company-addy*))
+ (phone (gnc:company-info book gnc:*company-phone*))
+ (fax (gnc:company-info book gnc:*company-fax*))
+ (email (gnc:company-info book gnc:*company-email*))
+ (url (gnc:company-info book gnc:*company-url*))
(taxid (gnc:company-info book gnc:*company-id*)))
(gnc:html-table-set-style! table "table"
@@ -756,13 +749,32 @@ for styling the invoice. Please see the exported report for the CSS class names.
'attribute (list "cellpadding" 0))
(if (and name (not (string-null? name)))
- (gnc:html-table-append-row! table (list (gnc:make-html-div/markup "company-name" name))))
+ (gnc:html-table-append-row! table (gnc:make-html-div/markup
+ "align-right company-name" name)))
(if (and addy (not (string-null? addy)))
- (gnc:html-table-append-row! table (list (gnc:make-html-div/markup "company-address" (multiline-to-html-text addy)))))
+ (gnc:html-table-append-row! table (gnc:make-html-div/markup
+ "align-right company-address" (multiline-to-html-text addy))))
+
+ (if (and phone (not (string-null? phone)))
+ (gnc:html-table-append-row! table (gnc:make-html-div/markup
+ "align-right company-phone" phone)))
- (if (and display-tax-id? taxid (not (string-null? taxid)))
- (gnc:html-table-append-row! table (list (gnc:make-html-div/markup "company-tax-id" taxid))))
+ (if (and fax (not (string-null? fax)))
+ (gnc:html-table-append-row! table (gnc:make-html-div/markup
+ "align-right company-fax" fax)))
+
+ (if (and email (not (string-null? email)))
+ (gnc:html-table-append-row! table (gnc:make-html-div/markup
+ "align-right company-email" email)))
+
+ (if (and url (not (string-null? url)))
+ (gnc:html-table-append-row! table (gnc:make-html-div/markup
+ "align-right company-url" url)))
+
+ (if (and taxid (not (string-null? taxid)))
+ (gnc:html-table-append-row! table (gnc:make-html-div/markup
+ "align-right company-tax-id" taxid)))
table))
@@ -773,9 +785,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
(references? (opt-val "Display" "References"))
(custom-title (opt-val gnc:pagename-general "Custom Title"))
- (company-table? (opt-val "Display" "My Company"))
- (display-tax-id? (opt-val "Display" "My Company ID"))
- (display-due-date? (opt-val "Display" "Due Date"))
(title-string (lambda (title custom-title) (if (string-null? custom-title) title custom-title))))
(if (null? invoice)
@@ -783,7 +792,6 @@ for styling the invoice. Please see the exported report for the CSS class names.
(gnc:make-html-text
(_ "No valid invoice selected. Click on the Options button and select the invoice to use.")))
(let* ((book (gncInvoiceGetBook invoice))
- (date-format (gnc:options-fancy-date book))
(owner (gncInvoiceGetOwner invoice))
(type (gncInvoiceGetType invoice))
(orders (if references? (delete-duplicates (map gncEntryGetOrder (gncInvoiceGetEntries invoice))) '()))
@@ -800,21 +808,17 @@ for styling the invoice. Please see the exported report for the CSS class names.
(_ "Invoice"))))
(title (title-string default-title custom-title))
(invoice-title (format #f (_"~a #~a") title (gncInvoiceGetID invoice)))
- (entry-table (make-entry-table invoice
- (gnc:report-options report-obj)
- cust-doc? credit-note?))
-
(layout-lookup-table (list (cons 'none #f)
(cons 'invoice (gnc:make-html-div/markup
"invoice-details-table"
(make-invoice-details-table
- invoice options display-due-date?)))
+ invoice options)))
(cons 'client (gnc:make-html-div/markup
"client-table"
(make-client-table owner orders)))
(cons 'company (gnc:make-html-div/markup
"company-table"
- (make-company-table book date-format display-tax-id?)))
+ (make-company-table book)))
(cons 'today (gnc:make-html-div/markup
"invoice-print-date"
(qof-print-date (current-time))))))
@@ -852,7 +856,9 @@ for styling the invoice. Please see the exported report for the CSS class names.
(gnc:html-table-append-row! main-table
(gnc:make-html-table-cell/size
1 2 (gnc:make-html-div/markup
- "entries-table" entry-table)))
+ "entries-table"
+ (make-entry-table invoice options
+ cust-doc? credit-note?))))
(if (opt-val "Display" "Invoice Notes")
(let ((notes (gncInvoiceGetNotes invoice)))
@@ -930,17 +936,13 @@ for styling the invoice. Please see the exported report for the CSS class names.
(define (gnc:easy-invoice-report-create-internal invoice)
(let* ((options (gnc:make-report-options easy-invoice-guid))
(invoice-op (gnc:lookup-option options gnc:pagename-general gnc:optname-invoice-number)))
-
(gnc:option-set-value invoice-op invoice)
(gnc:make-report easy-invoice-guid options)))
-
(export gnc:easy-invoice-report-create-internal)
(define (gnc:fancy-invoice-report-create-internal invoice)
(let* ((options (gnc:make-report-options fancy-invoice-guid))
(invoice-op (gnc:lookup-option options gnc:pagename-general gnc:optname-invoice-number)))
-
(gnc:option-set-value invoice-op invoice)
(gnc:make-report fancy-invoice-guid options)))
-
(export gnc:fancy-invoice-report-create-internal)
commit dae877cacf747e324d7dbc70470665e64a5f544c
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jul 22 11:59:37 2018 +0800
[invoice] now supports customized layout
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 088d744..45ac2b9 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -178,6 +178,67 @@
(cons entry-value entry-tax-value)))
+(define layout-key-list
+ (list (cons 'client (list (cons 'text "Client details")
+ (cons 'tip "Client name and address")))
+
+ (cons 'company (list (cons 'text "Company details")
+ (cons 'tip "Company name, address and tax-ID")))
+
+ (cons 'invoice (list (cons 'text "Invoice details")
+ (cons 'tip "Invoice date, due date, billing ID, terms, job details")))
+
+ (cons 'today (list (cons 'text "Today's date")
+ (cons 'tip "Today's date")))
+
+ (cons 'none (list (cons 'text "(empty)")
+ (cons 'tip "Empty space")))))
+
+(define variant-list
+ (list
+ (cons 'invoice (list (cons '1a 'none)
+ (cons '1b 'invoice)
+ (cons '2a 'client)
+ (cons '2b 'company)
+ (cons '3a 'none)
+ (cons '3b 'today)
+ (cons 'css base-css)))
+
+ (cons 'easy-invoice (list (cons '1a 'none)
+ (cons '1b 'invoice)
+ (cons '2a 'client)
+ (cons '2b 'company)
+ (cons '3a 'none)
+ (cons '3b 'today)
+ (cons 'css (string-append base-css "
+.invoice-in-progress { color:red }
+.invoice-title { font-weight: bold; text-decoration: underline }
+.main-table > table { margin: auto }
+.invoice-details-table > table { display: block; }
+.invoice-notes { margin-top: 20px }
+.entries-table > table { min-width: 600px }"))))
+
+ (cons 'fancy-invoice (list (cons '1a 'company)
+ (cons '1b 'invoice)
+ (cons '2a 'client)
+ (cons '2b 'company)
+ (cons '3a 'none)
+ (cons '3b 'none)
+ (cons 'css (string-append base-css "
+.company-name {font-size: x-large; }
+.client-name {font-size: x-large; }"))))))
+
+(define (keylist-get-info keylist key info)
+ (cdr (assq info (cdr (assq key keylist)))))
+
+(define (keylist->vectorlist keylist)
+ (map
+ (lambda (item)
+ (vector
+ (car item)
+ (keylist-get-info keylist (car item) 'text)
+ (keylist-get-info keylist (car item) 'tip)))
+ keylist))
(define (multiline-to-html-text str)
;; simple function - splits string containing #\newline into
@@ -190,7 +251,7 @@
(loop (cdr list-of-substrings)
(cons* (gnc:html-markup-br) (car list-of-substrings) result)))))
-(define (options-generator css-default)
+(define (options-generator variant)
(define gnc:*report-options* (gnc:new-options))
@@ -208,9 +269,10 @@
""))
(gnc:register-inv-option
- (gnc:make-internal-option
- "General" "CSS"
- css-default))
+ (gnc:make-text-option
+ (N_ "Layout") (N_ "CSS") "zz" "CSS code. This field specifies the CSS code
+for styling the invoice. Please see the exported report for the CSS class names."
+ (keylist-get-info variant-list variant 'css)))
(gnc:register-inv-option
(gnc:make-simple-boolean-option
@@ -278,10 +340,37 @@
"d" (N_ "Display the subtotals?") #t))
(gnc:register-inv-option
+ (gnc:make-complex-boolean-option
+ (N_ "Display") (N_ "Payable to")
+ "ua1" (N_ "Display the Payable to: information.") #f #f
+ (lambda (x)
+ (gnc-option-db-set-option-selectable-by-name
+ gnc:*report-options* "Display" "Payable to string" x))))
+
+ (gnc:register-inv-option
+ (gnc:make-text-option
+ (N_ "Display") (N_ "Payable to string")
+ "ua2" (N_ "The phrase for specifying to whom payments should be made.")
+ (_ "Please make all checks payable to")))
+
+ (gnc:register-inv-option
+ (gnc:make-complex-boolean-option
+ (N_ "Display") (N_ "Company contact")
+ "ub1" (N_ "Display the Company contact information.") #f #f
+ (lambda (x) (gnc-option-db-set-option-selectable-by-name
+ gnc:*report-options* "Display" "Company contact string" x))))
+
+ (gnc:register-inv-option
+ (gnc:make-text-option
+ (N_ "Display") (N_ "Company contact string")
+ "ub2" (N_ "The phrase used to introduce the company contact.")
+ (_ "Please direct all enquiries to")))
+
+ (gnc:register-inv-option
(gnc:make-number-range-option
(N_ "Display") (N_ "Minimum # of entries")
- "zz" (N_ "The minimum number of invoice entries to display.") 0
- 4 23 0 1))
+ "zz" (N_ "The minimum number of invoice entries to display.") 1
+ 0 23 0 1))
(gnc:register-inv-option
(gnc:make-simple-boolean-option
@@ -329,6 +418,48 @@
"u" (N_ "Extra notes to put on the invoice.")
(_ "Thank you for your patronage!")))
+ (gnc:register-inv-option
+ (gnc:make-multichoice-option
+ (N_ "Layout") (N_ "Row 1 Left")
+ "1a" "1st row, left"
+ (keylist-get-info variant-list variant '1a)
+ (keylist->vectorlist layout-key-list)))
+
+ (gnc:register-inv-option
+ (gnc:make-multichoice-option
+ (N_ "Layout") (N_ "Row 1 Right")
+ "1b" "1st row, right"
+ (keylist-get-info variant-list variant '1b)
+ (keylist->vectorlist layout-key-list)))
+
+ (gnc:register-inv-option
+ (gnc:make-multichoice-option
+ (N_ "Layout") (N_ "Row 2 Left")
+ "2a" "2nd row, left"
+ (keylist-get-info variant-list variant '2a)
+ (keylist->vectorlist layout-key-list)))
+
+ (gnc:register-inv-option
+ (gnc:make-multichoice-option
+ (N_ "Layout") (N_ "Row 2 Right")
+ "2b" "2nd row, right"
+ (keylist-get-info variant-list variant '2b)
+ (keylist->vectorlist layout-key-list)))
+
+ (gnc:register-inv-option
+ (gnc:make-multichoice-option
+ (N_ "Layout") (N_ "Row 3 Left")
+ "3a" "3rd row, left"
+ (keylist-get-info variant-list variant '3a)
+ (keylist->vectorlist layout-key-list)))
+
+ (gnc:register-inv-option
+ (gnc:make-multichoice-option
+ (N_ "Layout") (N_ "Row 3 Right")
+ "3b" "3rd row, right"
+ (keylist-get-info variant-list variant '3b)
+ (keylist->vectorlist layout-key-list)))
+
(gnc:options-set-default-section gnc:*report-options* "General")
gnc:*report-options*)
@@ -582,8 +713,16 @@
(gnc:html-table-append-row! table
(list
- (multiline-to-html-text
- (gnc:owner-get-name-and-address-dep owner))))
+ (gnc:make-html-span/markup
+ "client-name"
+ (gnc:owner-get-name-dep owner))))
+
+ (gnc:html-table-append-row! table
+ (list
+ (gnc:make-html-span/markup
+ "client-address"
+ (multiline-to-html-text
+ (gnc:owner-get-address-dep owner)))))
(for-each
(lambda (order)
@@ -603,7 +742,7 @@
(strftime date-format
(localtime date))))
-(define (make-myname-table book date-format display-tax-id?)
+(define (make-company-table book date-format display-tax-id?)
;; single-column table. my name, address, and printdate
(let* ((table (gnc:make-html-table))
(name (gnc:company-info book gnc:*company-name*))
@@ -612,21 +751,18 @@
(gnc:html-table-set-style! table "table"
'attribute (list "border" 0)
- 'attribute (list "align" "right")
'attribute (list "valign" "top")
'attribute (list "cellspacing" 0)
'attribute (list "cellpadding" 0))
(if (and name (not (string-null? name)))
- (gnc:html-table-append-row! table (list name)))
+ (gnc:html-table-append-row! table (list (gnc:make-html-div/markup "company-name" name))))
(if (and addy (not (string-null? addy)))
- (gnc:html-table-append-row! table (list (multiline-to-html-text addy))))
+ (gnc:html-table-append-row! table (list (gnc:make-html-div/markup "company-address" (multiline-to-html-text addy)))))
(if (and display-tax-id? taxid (not (string-null? taxid)))
- (gnc:html-table-append-row! table (list (multiline-to-html-text taxid))))
-
- (gnc:html-table-append-row! table (list (qof-print-date (current-time))))
+ (gnc:html-table-append-row! table (list (gnc:make-html-div/markup "company-tax-id" taxid))))
table))
@@ -666,11 +802,27 @@
(invoice-title (format #f (_"~a #~a") title (gncInvoiceGetID invoice)))
(entry-table (make-entry-table invoice
(gnc:report-options report-obj)
- cust-doc? credit-note?)))
+ cust-doc? credit-note?))
+
+ (layout-lookup-table (list (cons 'none #f)
+ (cons 'invoice (gnc:make-html-div/markup
+ "invoice-details-table"
+ (make-invoice-details-table
+ invoice options display-due-date?)))
+ (cons 'client (gnc:make-html-div/markup
+ "client-table"
+ (make-client-table owner orders)))
+ (cons 'company (gnc:make-html-div/markup
+ "company-table"
+ (make-company-table book date-format display-tax-id?)))
+ (cons 'today (gnc:make-html-div/markup
+ "invoice-print-date"
+ (qof-print-date (current-time))))))
+ (layout-lookup (lambda (loc) (cdr (assq (opt-val "Layout" loc) layout-lookup-table)))))
(gnc:html-document-set-title! document invoice-title)
- (gnc:html-document-set-style-text! document (opt-val "General" "CSS"))
+ (gnc:html-document-set-style-text! document (opt-val "Layout" "CSS"))
(let ((main-table (gnc:make-html-table)))
@@ -680,19 +832,22 @@
"invoice-title" invoice-title)))
(gnc:html-table-append-row! main-table
- (list #f
+ (list (layout-lookup "Row 1 Left")
(gnc:make-html-div/markup
- "invoice-details-table"
- (make-invoice-details-table invoice options display-due-date?))))
+ "align-right"
+ (layout-lookup "Row 1 Right"))))
(gnc:html-table-append-row! main-table
- (list (gnc:make-html-div/markup
- "client-table"
- (make-client-table owner orders))
+ (list (layout-lookup "Row 2 Left")
+ (gnc:make-html-div/markup
+ "align-right"
+ (layout-lookup "Row 2 Right"))))
- (and company-table?
- (gnc:make-html-div/markup
- "company-table" (make-myname-table book date-format display-tax-id?)))))
+ (gnc:html-table-append-row! main-table
+ (list (layout-lookup "Row 3 Left")
+ (gnc:make-html-div/markup
+ "align-right"
+ (layout-lookup "Row 3 Right"))))
(gnc:html-table-append-row! main-table
(gnc:make-html-table-cell/size
@@ -707,6 +862,28 @@
"invoice-notes"
(multiline-to-html-text notes))))))
+ (if (opt-val "Display" "Payable to")
+ (let* ((name (gnc:company-info book gnc:*company-name*))
+ (name-str (opt-val "Display" "Payable to string")))
+ (if (and name (not (string-null? name)))
+ (gnc:html-table-append-row!
+ main-table
+ (gnc:make-html-div/markup
+ "invoice-footer-payable-to"
+ (multiline-to-html-text
+ (string-append name-str ": " name)))))))
+
+ (if (opt-val "Display" "Company contact")
+ (let* ((contact (gnc:company-info book gnc:*company-contact*))
+ (contact-str (opt-val "Display" "Company contact string")))
+ (if (and contact (not (string-null? contact)))
+ (gnc:html-table-append-row!
+ main-table
+ (gnc:make-html-div/markup
+ "invoice-footer-company-contact"
+ (multiline-to-html-text
+ (string-append contact-str ": " contact)))))))
+
(gnc:html-table-append-row! main-table
(gnc:make-html-table-cell/size
1 2 (gnc:make-html-div/markup
@@ -721,23 +898,32 @@
(define invoice-report-guid "5123a759ceb9483abf2182d01c140e8d")
(define easy-invoice-guid "67112f318bef4fc496bdc27d106bbda4")
+(define fancy-invoice-guid "3ce293441e894423a2425d7a22dd1ac6")
(gnc:define-report
'version 1
'name (N_ "Printable Invoice")
'report-guid invoice-report-guid
'menu-path (list gnc:menuname-business-reports)
- 'options-generator (lambda () (options-generator easy-invoice-css))
+ 'options-generator (lambda () (options-generator 'invoice))
'renderer reg-renderer
'in-menu? #t)
-#;
(gnc:define-report
'version 1
'name (N_ "Easy Invoice")
'report-guid easy-invoice-guid
'menu-path (list gnc:menuname-business-reports)
- 'options-generator (lambda () (options-generator easy-invoice-css))
+ 'options-generator (lambda () (options-generator 'easy-invoice))
+ 'renderer reg-renderer
+ 'in-menu? #t)
+
+(gnc:define-report
+ 'version 1
+ 'name (N_ "Fancy Invoice")
+ 'report-guid fancy-invoice-guid
+ 'menu-path (list gnc:menuname-business-reports)
+ 'options-generator (lambda () (options-generator 'fancy-invoice))
'renderer reg-renderer
'in-menu? #t)
@@ -749,3 +935,12 @@
(gnc:make-report easy-invoice-guid options)))
(export gnc:easy-invoice-report-create-internal)
+
+(define (gnc:fancy-invoice-report-create-internal invoice)
+ (let* ((options (gnc:make-report-options fancy-invoice-guid))
+ (invoice-op (gnc:lookup-option options gnc:pagename-general gnc:optname-invoice-number)))
+
+ (gnc:option-set-value invoice-op invoice)
+ (gnc:make-report fancy-invoice-guid options)))
+
+(export gnc:fancy-invoice-report-create-internal)
commit a0c5be2c81694e6c2746b49ab6f11be3b8f9d12a
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 9 14:38:33 2018 +0800
[business-reports] delete redundant [fancy|easy]-invoice
diff --git a/gnucash/report/business-reports/CMakeLists.txt b/gnucash/report/business-reports/CMakeLists.txt
index c4c5017..7d63798 100644
--- a/gnucash/report/business-reports/CMakeLists.txt
+++ b/gnucash/report/business-reports/CMakeLists.txt
@@ -3,8 +3,6 @@ add_subdirectory (test)
set (business_reports_SCHEME
aging.scm
customer-summary.scm
- easy-invoice.scm
- fancy-invoice.scm
taxinvoice.scm
receipt.scm
invoice.scm
diff --git a/gnucash/report/business-reports/business-reports.scm b/gnucash/report/business-reports/business-reports.scm
index 03d7cd3..ffc54ee 100644
--- a/gnucash/report/business-reports/business-reports.scm
+++ b/gnucash/report/business-reports/business-reports.scm
@@ -110,9 +110,7 @@
0
))
-(use-modules (gnucash report fancy-invoice))
(use-modules (gnucash report invoice))
-(use-modules (gnucash report easy-invoice))
(use-modules (gnucash report taxinvoice))
(use-modules (gnucash report receipt))
(use-modules (gnucash report owner-report))
diff --git a/gnucash/report/business-reports/easy-invoice.scm b/gnucash/report/business-reports/easy-invoice.scm
deleted file mode 100644
index a2497a5..0000000
--- a/gnucash/report/business-reports/easy-invoice.scm
+++ /dev/null
@@ -1,811 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; -*-scheme-*-
-;; easy-invoice.scm -- an easily configured Invoice Report,
-;; used to print a GncInvoice
-;;
-;; Created by: James Strandboge <jstrand1 at rochester.rr.com>
-;;
-;; Based on invoice.scm by Derek Atkins <warlord at MIT.EDU>
-;;
-;; stylesheet-header.scm : stylesheet with nicer layout
-;; Copyright 2000 Bill Gribble <grib at gnumatic.com>
-;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2 of
-;; the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, contact:
-;;
-;; Free Software Foundation Voice: +1-617-542-5942
-;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
-;; Boston, MA 02110-1301, USA gnu at gnu.org
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define-module (gnucash report easy-invoice))
-
-(use-modules (srfi srfi-1))
-(use-modules (gnucash gnc-module))
-(use-modules (gnucash gettext))
-(use-modules (gnucash utilities))
-
-(gnc:module-load "gnucash/report/report-system" 0)
-(use-modules (gnucash report standard-reports))
-(use-modules (gnucash report business-reports))
-
-(define (date-col columns-used)
- (vector-ref columns-used 0))
-(define (description-col columns-used)
- (vector-ref columns-used 1))
-(define (action-col columns-used)
- (vector-ref columns-used 2))
-(define (quantity-col columns-used)
- (vector-ref columns-used 3))
-(define (price-col columns-used)
- (vector-ref columns-used 4))
-(define (discount-col columns-used)
- (vector-ref columns-used 5))
-(define (tax-col columns-used)
- (vector-ref columns-used 6))
-(define (taxvalue-col columns-used)
- (vector-ref columns-used 7))
-(define (value-col columns-used)
- (vector-ref columns-used 8))
-
-(define columns-used-size 9)
-
-(define (num-columns-required columns-used)
- (do ((i 0 (+ i 1))
- (col-req 0 col-req))
- ((>= i columns-used-size) col-req)
- (if (vector-ref columns-used i)
- (set! col-req (+ col-req 1)))))
-
-(define (build-column-used options)
- (define (opt-val section name)
- (gnc:option-value
- (gnc:lookup-option options section name)))
- (define (make-set-col col-vector)
- (let ((col 0))
- (lambda (used? index)
- (if used?
- (begin
- (vector-set! col-vector index col)
- (set! col (+ col 1)))
- (vector-set! col-vector index #f)))))
-
- (let* ((col-vector (make-vector columns-used-size #f))
- (set-col (make-set-col col-vector)))
- (set-col (opt-val "Display Columns" "Date") 0)
- (set-col (opt-val "Display Columns" "Description") 1)
- (set-col (opt-val "Display Columns" "Action") 2)
- (set-col (opt-val "Display Columns" "Quantity") 3)
- (set-col (opt-val "Display Columns" "Price") 4)
- (set-col (opt-val "Display Columns" "Discount") 5)
- (set-col (opt-val "Display Columns" "Taxable") 6)
- (set-col (opt-val "Display Columns" "Tax Amount") 7)
- (set-col (opt-val "Display Columns" "Total") 8)
- col-vector))
-
-(define (make-heading-list column-vector)
-
- (let ((heading-list '()))
- (if (date-col column-vector)
- (addto! heading-list (_ "Date")))
- (if (description-col column-vector)
- (addto! heading-list (_ "Description")))
- (if (action-col column-vector)
- (addto! heading-list (_ "Action")))
- (if (quantity-col column-vector)
- (addto! heading-list (_ "Quantity")))
- (if (price-col column-vector)
- (addto! heading-list (_ "Unit Price")))
- (if (discount-col column-vector)
- (addto! heading-list (_ "Discount")))
- (if (tax-col column-vector)
- (addto! heading-list (_ "Taxable")))
- (if (taxvalue-col column-vector)
- (addto! heading-list (_ "Tax Amount")))
- (if (value-col column-vector)
- (addto! heading-list (_ "Total")))
- (reverse heading-list)))
-
-(define (monetary-or-percent numeric currency entry-type)
- (if (gnc:entry-type-percent-p entry-type)
- (string-append (gnc:default-html-gnc-numeric-renderer numeric #f) " " (_ "%"))
- (gnc:make-gnc-monetary currency numeric)))
-
-(define (add-entry-row table currency entry column-vector row-style cust-doc? credit-note?)
- (let* ((row-contents '())
- (entry-value (gnc:make-gnc-monetary
- currency
- (gncEntryGetDocValue entry #t cust-doc? credit-note?)))
- (entry-tax-value (gnc:make-gnc-monetary
- currency
- (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
-
- (if (date-col column-vector)
- (addto! row-contents
- (qof-print-date (gncEntryGetDate entry))))
-
- (if (description-col column-vector)
- (addto! row-contents
- (gncEntryGetDescription entry)))
-
- (if (action-col column-vector)
- (addto! row-contents
- (gncEntryGetAction entry)))
-
- (if (quantity-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- (gncEntryGetDocQuantity entry credit-note?))))
-
- (if (price-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- (gnc:make-gnc-monetary
- currency (if cust-doc? (gncEntryGetInvPrice entry)
- (gncEntryGetBillPrice entry))))))
-
- (if (discount-col column-vector)
- (addto! row-contents
- (if cust-doc?
- (gnc:make-html-table-cell/markup
- "number-cell"
- (monetary-or-percent (gncEntryGetInvDiscount entry)
- currency
- (gncEntryGetInvDiscountType entry)))
- "")))
-
- (if (tax-col column-vector)
- (addto! row-contents
- (if (if cust-doc?
- (and (gncEntryGetInvTaxable entry)
- (gncEntryGetInvTaxTable entry))
- (and (gncEntryGetBillTaxable entry)
- (gncEntryGetBillTaxTable entry)))
- ;; Translators: This "T" is displayed in the taxable column, if this entry contains tax
- (_ "T") "")))
-
- (if (taxvalue-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- entry-tax-value)))
-
- (if (value-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- entry-value)))
-
- (gnc:html-table-append-row/markup! table row-style
- (reverse row-contents))
-
- (cons entry-value entry-tax-value)))
-
-(define (options-generator)
-
- (define gnc:*report-options* (gnc:new-options))
-
- (define (gnc:register-inv-option new-option)
- (gnc:register-option gnc:*report-options* new-option))
-
- (gnc:register-inv-option
- (gnc:make-invoice-option gnc:pagename-general gnc:optname-invoice-number "x" ""
- (lambda () '()) #f))
-
- (gnc:register-inv-option
- (gnc:make-string-option
- gnc:pagename-general (N_ "Custom Title")
- "z" (N_ "A custom string to replace Invoice, Bill or Expense Voucher.")
- ""))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Date")
- "b" (N_ "Display the date?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Description")
- "d" (N_ "Display the description?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Action")
- "g" (N_ "Display the action?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Quantity")
- "ha" (N_ "Display the quantity of items?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Price")
- "hb" (N_ "Display the price per item?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Discount")
- "k" (N_ "Display the entry's discount?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Taxable")
- "l" (N_ "Display the entry's taxable status?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Tax Amount")
- "m" (N_ "Display each entry's total total tax?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Total")
- "n" (N_ "Display the entry's value?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "My Company")
- "oa" (N_ "Display my company name and address?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "My Company ID")
- "ob" (N_ "Display my company ID?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Due Date")
- "oc" (N_ "Display due date?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Individual Taxes")
- "od" (N_ "Display all the individual taxes?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Totals")
- "pa" (N_ "Display the totals?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Subtotal")
- "pb" (N_ "Display the subtotals?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "References")
- "s" (N_ "Display the invoice references?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Billing Terms")
- "t" (N_ "Display the invoice billing terms?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Billing ID")
- "ta" (N_ "Display the billing id?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Invoice Notes")
- "tb" (N_ "Display the invoice notes?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Payments")
- "tc" (N_ "Display the payments applied to this invoice?") #f))
-
- (gnc:register-inv-option
- (gnc:make-number-range-option
- (N_ "Display") (N_ "Invoice Width")
- "u" (N_ "The minimum width of the invoice.") 600
- 100 1600 0 10))
-
- (gnc:register-inv-option
- (gnc:make-text-option
- (N_ "Text") (N_ "Extra Notes")
- "v" (N_ "Extra notes to put on the invoice (simple HTML is accepted).")
- (_ "Thank you for your patronage!")))
-
- (gnc:options-set-default-section gnc:*report-options* "General")
-
- gnc:*report-options*)
-
-
-(define (make-entry-table invoice options add-order cust-doc? credit-note?)
- (define (opt-val section name)
- (gnc:option-value
- (gnc:lookup-option options section name)))
-
- (let ((show-payments (opt-val "Display" "Payments"))
- (display-all-taxes (opt-val "Display" "Individual Taxes"))
- (lot (gncInvoiceGetPostedLot invoice))
- (txn (gncInvoiceGetPostedTxn invoice))
- (currency (gncInvoiceGetCurrency invoice))
- (reverse-payments? (not (gncInvoiceAmountPositive invoice))))
-
- (define (colspan monetary used-columns)
- (cond
- ((value-col used-columns) (value-col used-columns))
- ((taxvalue-col used-columns) (taxvalue-col used-columns))
- (else (price-col used-columns))))
-
- (define (display-subtotal monetary used-columns)
- (if (value-col used-columns)
- monetary
- (let ((amt (gnc:gnc-monetary-amount monetary)))
- (if amt
- (if (gnc-numeric-negative-p amt)
- (gnc:monetary-neg monetary)
- monetary)
- monetary))))
-
- (define (add-subtotal-row table used-columns
- subtotal subtotal-style subtotal-label)
- (let ((subtotal-mon (gnc:make-gnc-monetary currency subtotal)))
-
- (gnc:html-table-append-row/markup!
- table
- subtotal-style
- (append (cons (gnc:make-html-table-cell/markup
- "total-label-cell" subtotal-label)
- '())
- (list (gnc:make-html-table-cell/size/markup
- 1 (colspan subtotal-mon used-columns)
- "total-number-cell"
- (display-subtotal subtotal-mon used-columns)))))))
-
- (define (add-payment-row table used-columns split total-collector reverse-payments?)
- (let* ((t (xaccSplitGetParent split))
- (currency (xaccTransGetCurrency t))
- ;; Depending on the document type, the payments may need to be sign-reversed
- (amt (gnc:make-gnc-monetary currency
- (if reverse-payments?
- (gnc-numeric-neg(xaccSplitGetValue split))
- (xaccSplitGetValue split))))
- (payment-style "grand-total")
- (row '()))
-
- (total-collector 'add
- (gnc:gnc-monetary-commodity amt)
- (gnc:gnc-monetary-amount amt))
-
- (if (date-col used-columns)
- (addto! row
- (qof-print-date (xaccTransGetDate t))))
-
- (if (description-col used-columns)
- (addto! row (_ "Payment, thank you")))
-
- (gnc:html-table-append-row/markup!
- table
- payment-style
- (append (reverse row)
- (list (gnc:make-html-table-cell/size/markup
- 1 (colspan currency used-columns)
- "total-number-cell"
- (display-subtotal amt used-columns)))))))
-
- (define (do-rows-with-subtotals entries
- table
- used-columns
- width
- odd-row?)
- (if (null? entries)
- (let ((total-collector (gnc:make-commodity-collector)))
-
- ; jamie
- (if (opt-val "Display" "Subtotal")
- (add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
- "grand-total" (_ "Net Price")))
-
- (if display-all-taxes
- (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
- (for-each
- (lambda (parm)
- (let* ((value (cdr parm))
- (acct (car parm))
- (name (xaccAccountGetName acct)))
- (add-subtotal-row table used-columns value
- "grand-total" name)))
- acct-val-list))
-
- ; nope, just show the total tax.
- (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
- "grand-total" (_ "Tax")))
-
- (add-subtotal-row table used-columns (gncInvoiceGetTotal invoice)
- "grand-total" (_ "Total Price"))
-
- (total-collector 'add currency (gncInvoiceGetTotal invoice))
- (if (and show-payments (not (null? lot)))
- (let ((splits (sort-list!
- (gnc-lot-get-split-list lot)
- (lambda (s1 s2)
- (let ((t1 (xaccSplitGetParent s1))
- (t2 (xaccSplitGetParent s2)))
- (< (xaccTransOrder t1 t2) 0))))))
- (for-each
- (lambda (split)
- (if (not (equal? (xaccSplitGetParent split) txn))
- (add-payment-row table used-columns
- split total-collector
- reverse-payments?)))
- splits)))
-
- (add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
- "grand-total" (_ "Amount Due")))
-
- ;;
- ;; End of BEGIN -- now here's the code to handle all the entries!
- ;;
- (let* ((current (car entries))
- (current-row-style (if odd-row? "normal-row" "alternate-row"))
- (rest (cdr entries))
- (next (if (null? rest) #f
- (car rest)))
- (entry-values (add-entry-row table
- currency
- current
- used-columns
- current-row-style
- cust-doc? credit-note?)))
-
- (let ((order (gncEntryGetOrder current)))
- (if (not (null? order)) (add-order order)))
-
- (do-rows-with-subtotals rest
- table
- used-columns
- width
- (not odd-row?)))))
-
- (let* ((table (gnc:make-html-table))
- (used-columns (build-column-used options))
- (width (num-columns-required used-columns))
- (entries (gncInvoiceGetEntries invoice)))
-
- (gnc:html-table-set-col-headers!
- table
- (make-heading-list used-columns))
-
- (do-rows-with-subtotals entries
- table
- used-columns
- width
- #t)
- table)))
-
-(define (string-expand string character replace-string)
- (define (car-line chars)
- (take-while (lambda (c) (not (eqv? c character))) chars))
- (define (cdr-line chars)
- (let ((rest (drop-while (lambda (c) (not (eqv? c character))) chars)))
- (if (null? rest)
- '()
- (cdr rest))))
- (define (line-helper chars)
- (if (null? chars)
- ""
- (let ((first (car-line chars))
- (rest (cdr-line chars)))
- (string-append (list->string first)
- (if (null? rest) "" replace-string)
- (line-helper rest)))))
- (line-helper (string->list string)))
-
-(define (make-client-table owner orders)
- (let ((table (gnc:make-html-table)))
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0))
- (gnc:html-table-append-row!
- table
- (list
- (string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
- (gnc:html-table-append-row!
- table
- (list "<br/>"))
- (for-each
- (lambda (order)
- (let* ((reference (gncOrderGetReference order)))
- (if (and reference (> (string-length reference) 0))
- (gnc:html-table-append-row!
- table
- (list
- ;; This string is supposed to be an abbrev. for "Reference"?
- (string-append (_ "REF") ": " reference))))))
- orders)
- (gnc:html-table-set-last-row-style!
- table "td"
- 'attribute (list "valign" "top"))
- table))
-
-(define (make-date-row! table label date date-format)
- (gnc:html-table-append-row!
- table
- (list
- (string-append label ": ")
- (string-expand (strftime date-format
- (localtime date))
- #\space " "))))
-
-(define (make-date-table)
- (let ((table (gnc:make-html-table)))
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellpadding" 0))
- (gnc:html-table-set-last-row-style!
- table "td"
- 'attribute (list "valign" "top"))
- table))
-
-(define (make-myname-table book)
- (let* ((table (gnc:make-html-table))
- (name (gnc:company-info book gnc:*company-name*))
- (addy (gnc:company-info book gnc:*company-addy*)))
-
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "width" "100%")
- 'attribute (list "align" "right")
- 'attribute (list "valign" "top")
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0))
- (gnc:html-table-append-row! table
- (list (if name (string-append "<div align='right'>" name "</div>") "")))
-
- ; this is pretty strange. If addy is set, then make caddy <div>addy</div>,
- ; then when adding the row to the table, we actually add several rows by expanding
- ; caddy (the <div> is already set for the first in list and </dev> for last because
- ; of addy)
- (if (and addy (> (string-length addy) 0))
- (let ((caddy (string-append "<div align='right'>" addy "</div>")))
- (gnc:html-table-append-row! table (list (string-expand caddy
- #\newline "</td></tr><tr><td><div align='right'>")))))
- table))
-
-(define (add-html! document htmlstring)
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (N_ htmlstring))))
-
-(define (make-break! document)
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (gnc:html-markup-br))))
-
-(define (reg-renderer report-obj)
- (define (opt-val section name)
- (gnc:option-value
- (gnc:lookup-option (gnc:report-options report-obj) section name)))
-
- (define (title-string title custom-title)
- (if (not (equal? "" custom-title))
- (string-expand custom-title
- #\space " ")
- title))
-
- (let* ((document (gnc:make-html-document))
- (table '())
- (orders '())
- (invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
- (owner '())
- (references? (opt-val "Display" "References"))
- (default-title (_ "Invoice"))
- (custom-title (opt-val gnc:pagename-general "Custom Title"))
- (title "")
- (cust-doc? #f)
- (credit-note? #f))
-
- (define (add-order o)
- (if (and references? (not (member o orders)))
- (addto! orders o)))
-
- (if (not (null? invoice))
- (begin
- (set! owner (gncInvoiceGetOwner invoice))
- (let ((type (gncInvoiceGetType invoice)))
- (cond
- ((eqv? type GNC-INVOICE-CUST-INVOICE)
- (set! cust-doc? #t))
- ((eqv? type GNC-INVOICE-VEND-INVOICE)
- (set! default-title (_ "Bill")))
- ((eqv? type GNC-INVOICE-EMPL-INVOICE)
- (set! default-title (_ "Expense Voucher")))
- ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
- (begin
- (set! cust-doc? #t)
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
- (begin
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
- (begin
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))))
- (set! title (format #f (_"~a #~a") (title-string default-title custom-title)
- (gncInvoiceGetID invoice)))))
-
- ; (gnc:html-document-set-title! document title)
-
- ; framing table
- (add-html! document "<center><table width='")
- (add-html! document (opt-val "Display" "Invoice Width"))
- (add-html! document "' cellpadding='0' cellspacing='0'>")
-
- (add-html! document "<tr><td align='left'>")
-
- (if (not (null? invoice))
- (let* ((book (gncInvoiceGetBook invoice))
- (date-format (gnc:options-fancy-date book)))
-
- ; invoice number and ID String table
- (add-html! document "<table width='100%'><tr>")
- (add-html! document "<td align='left'>")
- (add-html! document "<b><u>")
- (add-html! document title)
- ;; (add-html! document (format #f (_ "Invoice #~a")
- ;; (gncInvoiceGetID invoice)))
- (add-html! document "</u></b></td>")
- (add-html! document "<td align='right'>")
-
- (if (opt-val "Display" "My Company ID")
- (let* ((taxid (gnc:company-info book gnc:*company-id*)))
- (if (and taxid (> (string-length taxid) 0))
- (begin
- (add-html! document taxid)
- (add-html! document " ")))
- )
- )
- (add-html! document "</td>")
- (add-html! document "</tr></table>")
-
- (make-break! document)
- (make-break! document)
-
- ; add the client and company name table
- (let ((book (gncInvoiceGetBook invoice)))
- (set! table (make-entry-table invoice
- (gnc:report-options report-obj)
- add-order cust-doc? credit-note?))
-
- (add-html! document "<table width='100%'><tr>")
- (add-html! document "<td align='left' valign='top'>")
- (gnc:html-document-add-object!
- document
- (make-client-table owner orders))
- (add-html! document "</td>")
- (if (opt-val "Display" "My Company")
- (begin
- (add-html! document "<td align='right' valign='top'>")
- (gnc:html-document-add-object!
- document
- (make-myname-table book))
- (add-html! document "</td>")))
- (add-html! document "</tr></table>")
- )
-
- ;; add the date
- (if (gncInvoiceIsPosted invoice)
- (let ((date-table #f)
- (post-date (gncInvoiceGetDatePosted invoice))
- (due-date (gncInvoiceGetDateDue invoice)))
- (set! date-table (make-date-table))
- (make-date-row! date-table (_ "Date") post-date date-format)
- (if (opt-val "Display" "Due Date")
- (make-date-row! date-table (_ "Due") due-date date-format))
- (gnc:html-document-add-object! document date-table))
- (add-html! document
- (string-append "<font color='red'>"
- (_ "INVOICE NOT POSTED")
- "</font>")))
-
- (make-break! document)
-
- (if (opt-val "Display" "Billing ID")
- (let ((billing-id (gncInvoiceGetBillingID invoice)))
- (if (and billing-id (> (string-length billing-id) 0))
- (begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Billing ID") ": "
- (string-expand billing-id #\newline "<br/>"))))
- (make-break! document)))))
-
- (if (opt-val "Display" "Billing Terms")
- (let* ((term (gncInvoiceGetTerms invoice))
- (terms (gncBillTermGetDescription term)))
- (if (and terms (> (string-length terms) 0))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Terms") ": "
- (string-expand terms #\newline "<br/>")))))))
-
- (make-break! document)
-
- ; add the main table
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "width" "100%")
- 'attribute (list "border" 1)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 4))
- (gnc:html-document-add-object! document table)
-
- (make-break! document)
- (make-break! document)
-
- (if (opt-val "Display" "Invoice Notes")
- (begin
- (let ((notes (gncInvoiceGetNotes invoice)))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-expand notes #\newline "<br/>"))))
- (make-break! document)
- (make-break! document)))
-
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-expand (opt-val "Text" "Extra Notes") #\newline "<br/>")
- ))
-
- ; close the framing table
- (add-html! document "</td></tr></table></center>"))
-
- ; else (if invoice
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (_ "No valid invoice selected. Click on the Options button and select the invoice to use."))))
-
- document))
-
-(define easy-invoice-guid "67112f318bef4fc496bdc27d106bbda4")
-
-(gnc:define-report
- 'version 1
- 'name (N_ "Easy Invoice")
- 'report-guid easy-invoice-guid
- 'menu-path (list gnc:menuname-business-reports)
- 'options-generator options-generator
- 'renderer reg-renderer
- 'in-menu? #t)
-
-(define (gnc:easy-invoice-report-create-internal invoice)
- (let* ((options (gnc:make-report-options easy-invoice-guid))
- (invoice-op (gnc:lookup-option options gnc:pagename-general gnc:optname-invoice-number)))
-
- (gnc:option-set-value invoice-op invoice)
- (gnc:make-report easy-invoice-guid options)))
-
-(export gnc:easy-invoice-report-create-internal)
diff --git a/gnucash/report/business-reports/fancy-invoice.scm b/gnucash/report/business-reports/fancy-invoice.scm
deleted file mode 100644
index edba6aa..0000000
--- a/gnucash/report/business-reports/fancy-invoice.scm
+++ /dev/null
@@ -1,943 +0,0 @@
-;; -*-scheme-*-
-;; fancy-invoice.scm -- a Fancy Invoice Report, used to print a GncInvoice
-;;
-;; Created by: Derek Atkins <warlord at MIT.EDU>
-;; Copyright (c) 2003 Derek Atkins <warlord at MIT.EDU>
-;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2 of
-;; the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, contact:
-;;
-;; Free Software Foundation Voice: +1-617-542-5942
-;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
-;; Boston, MA 02110-1301, USA gnu at gnu.org
-
-
-;; Fancy Invoice customized from "invoice.scm"
-;; Customized by: Oliver Jones <gnucash at oliverstech dot com>
-;;
-;; WARNING: customizations are hard-coded, some translations might be
-;; broken and it won't work for bills/expense vouchers
-;;
-;; Customizations are marked with "oli-custom".
-;;
-;; Hint: you may set your default options here until a way to save report
-;; options will be implemented.
-;;
-;; You will need to upgrade to gtkhtml-1.1 for the latest features or
-;; it won't look right. gtkhtml doesn't have support for table
-;; colgroup, tbody, thead and rules tags yet. When it will, the
-;; invoice will look even better.
-;;
-;; This is a quick and dirty hack. The proper way to do this (when I
-;; or someone else will have time) is to have the user supply an HTML
-;; template. The most common used templates will be distributed with
-;; gnucash.
-
-;; Modified to use settable options instead of the hard coded ones.
-;; modified by Brian Dolbec <dol-sen at telus dot net> Feb. 6, 2006
-
-(define-module (gnucash report fancy-invoice))
-
-(use-modules (srfi srfi-1))
-(use-modules (gnucash gnc-module))
-(use-modules (gnucash gettext))
-(use-modules (gnucash utilities))
-
-(gnc:module-load "gnucash/report/report-system" 0)
-(use-modules (gnucash report standard-reports))
-(use-modules (gnucash report business-reports))
-
-(define (date-col columns-used)
- (vector-ref columns-used 0))
-(define (description-col columns-used)
- (vector-ref columns-used 1))
-(define (action-col columns-used)
- (vector-ref columns-used 2))
-(define (quantity-col columns-used)
- (vector-ref columns-used 3))
-(define (price-col columns-used)
- (vector-ref columns-used 4))
-(define (discount-col columns-used)
- (vector-ref columns-used 5))
-(define (tax-col columns-used)
- (vector-ref columns-used 6))
-(define (taxvalue-col columns-used)
- (vector-ref columns-used 7))
-(define (value-col columns-used)
- (vector-ref columns-used 8))
-
-(define columns-used-size 9)
-
-(define (num-columns-required columns-used)
- (do ((i 0 (+ i 1))
- (col-req 0 col-req))
- ((>= i columns-used-size) col-req)
- (if (vector-ref columns-used i)
- (set! col-req (+ col-req 1)))))
-
-(define (build-column-used options)
- (define (opt-val section name)
- (gnc:option-value
- (gnc:lookup-option options section name)))
- (define (make-set-col col-vector)
- (let ((col 0))
- (lambda (used? index)
- (if used?
- (begin
- (vector-set! col-vector index col)
- (set! col (+ col 1)))
- (vector-set! col-vector index #f)))))
-
- (let* ((col-vector (make-vector columns-used-size #f))
- (set-col (make-set-col col-vector)))
- (set-col (opt-val "Display Columns" "Date") 0)
- (set-col (opt-val "Display Columns" "Description") 1)
- (set-col (opt-val "Display Columns" "Action") 2)
- (set-col (opt-val "Display Columns" "Quantity") 3)
- (set-col (opt-val "Display Columns" "Price") 4)
- (set-col (opt-val "Display Columns" "Discount") 5)
- (set-col (opt-val "Display Columns" "Taxable") 6)
- (set-col (opt-val "Display Columns" "Tax Amount") 7)
- (set-col (opt-val "Display Columns" "Total") 8)
- col-vector))
-
-(define (make-heading-list column-vector)
-
- (let ((heading-list '()))
- (if (date-col column-vector)
- (addto! heading-list (_ "Date")))
- (if (description-col column-vector)
- (addto! heading-list (_ "Description")))
- (if (action-col column-vector)
- (addto! heading-list (_ "Charge Type")))
- (if (quantity-col column-vector)
- (addto! heading-list (_ "Quantity")))
- (if (price-col column-vector)
- (addto! heading-list (string-expand (_ "Unit Price") #\space " ")))
- (if (discount-col column-vector)
- (addto! heading-list (_ "Discount")))
- (if (tax-col column-vector)
- (addto! heading-list (_ "Taxable")))
- (if (taxvalue-col column-vector)
- (addto! heading-list (_ "Tax Amount")))
- (if (value-col column-vector)
- (addto! heading-list (_ "Total")))
- (reverse heading-list)))
-
-
-(define (monetary-or-percent numeric currency entry-type)
- (if (gnc:entry-type-percent-p entry-type)
- ;; oli-custom - make a string instead of a table
- (string-append (gnc:default-html-gnc-numeric-renderer numeric #f) " " (_ "%"))
- (gnc:make-gnc-monetary currency numeric)))
-
-(define (add-entry-row table currency entry column-vector row-style cust-doc? credit-note?)
- (let* ((row-contents '())
- (entry-value (gnc:make-gnc-monetary
- currency
- (gncEntryGetDocValue entry #t cust-doc? credit-note?)))
- (entry-tax-value (gnc:make-gnc-monetary
- currency
- (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
-
- (if (date-col column-vector)
- (addto! row-contents
- (qof-print-date (gncEntryGetDate entry))))
-
- (if (description-col column-vector)
- (addto! row-contents
- (gncEntryGetDescription entry)))
-
- (if (action-col column-vector)
- (addto! row-contents
- (gncEntryGetAction entry)))
-
- (if (quantity-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- (gncEntryGetDocQuantity entry credit-note?))))
-
- (if (price-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- (gnc:make-gnc-monetary
- currency (if cust-doc? (gncEntryGetInvPrice entry)
- (gncEntryGetBillPrice entry))))))
-
- (if (discount-col column-vector)
- (addto! row-contents
- (if cust-doc?
- (gnc:make-html-table-cell/markup
- "number-cell"
- (monetary-or-percent (gncEntryGetInvDiscount entry)
- currency
- (gncEntryGetInvDiscountType entry)))
- "")))
-
- (if (tax-col column-vector)
- (addto! row-contents
- (if (if cust-doc?
- (and (gncEntryGetInvTaxable entry)
- (gncEntryGetInvTaxTable entry))
- (and (gncEntryGetBillTaxable entry)
- (gncEntryGetBillTaxTable entry)))
- ;; Translators: This "T" is displayed in the taxable column, if this entry contains tax
- (_ "T") "")))
-
- (if (taxvalue-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- entry-tax-value)))
-
- (if (value-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- entry-value)))
-
- (gnc:html-table-append-row/markup! table row-style
- (reverse row-contents))
-
- (cons entry-value entry-tax-value)))
-
-;; oli-custom - here you can set your default options
-
-(define (options-generator)
-
- (define gnc:*report-options* (gnc:new-options))
-
- (define (gnc:register-inv-option new-option)
- (gnc:register-option gnc:*report-options* new-option))
-
- (gnc:register-inv-option
- (gnc:make-invoice-option gnc:pagename-general gnc:optname-invoice-number "x" ""
- (lambda () '()) #f))
-
- (gnc:register-inv-option
- (gnc:make-string-option
- gnc:pagename-general (N_ "Custom Title")
- "z" (N_ "A custom string to replace Invoice, Bill or Expense Voucher.")
- ""))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Date")
- "b" (N_ "Display the date?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Description")
- "d" (N_ "Display the description?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Action")
- "g" (N_ "Display the action?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Quantity")
- "ha" (N_ "Display the quantity of items?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Price")
- "hb" (N_ "Display the price per item?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Discount")
- "k" (N_ "Display the entry's discount?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Taxable")
- "l" (N_ "Display the entry's taxable status?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Tax Amount")
- "m" (N_ "Display each entry's total total tax?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Total")
- "n" (N_ "Display the entry's value?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Individual Taxes")
- "o" (N_ "Display all the individual taxes?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Totals")
- "p" (N_ "Display the totals?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "References")
- "s" (N_ "Display the invoice references?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Billing Terms")
- "t" (N_ "Display the invoice billing terms?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Billing ID")
- "ta" (N_ "Display the billing id?") #t))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Invoice Notes")
- "tb" (N_ "Display the invoice notes?") #f))
-
- (gnc:register-inv-option
- (gnc:make-simple-boolean-option
- (N_ "Display") (N_ "Payments")
- "tc" (N_ "Display the payments applied to this invoice?") #f))
-
- (gnc:register-inv-option
- (gnc:make-number-range-option
- (N_ "Display") (N_ "Minimum # of entries")
- "u" (N_ "The minimum number of invoice entries to display.") 23
- 4 23 0 1))
-
- (gnc:register-inv-option
- (gnc:make-text-option
- (N_ "Display") (N_ "Extra Notes")
- "u" (N_ "Extra notes to put on the invoice.")
- (_ "Thank you for your patronage!")))
-
- (gnc:register-inv-option
- (gnc:make-complex-boolean-option
- (N_ "Display") (N_ "Payable to")
- "ua1" (N_ "Display the Payable to: information.") #t #f
- (lambda (x) (gnc-option-db-set-option-selectable-by-name
- gnc:*report-options* "Display" "Payable to string" x))))
-
- (gnc:register-inv-option
- (gnc:make-text-option
- (N_ "Display") (N_ "Payable to string")
- "ua2" (N_ "The phrase for specifying to whom payments should be made.")
- (_ "Make all cheques Payable to")))
-
- (gnc:register-inv-option
- (gnc:make-complex-boolean-option
- (N_ "Display") (N_ "Company contact")
- "ub1" (N_ "Display the Company contact information.") #t #f
- (lambda (x) (gnc-option-db-set-option-selectable-by-name
- gnc:*report-options* "Display" "Company contact string" x))))
-
- (gnc:register-inv-option
- (gnc:make-text-option
- (N_ "Display") (N_ "Company contact string")
- "ub2" (N_ "The phrase used to introduce the company contact.")
- (_ "Direct all inquiries to")))
-
- (gnc:options-set-default-section gnc:*report-options* "General")
-
- gnc:*report-options*)
-
-
-(define (make-entry-table invoice options add-order cust-doc? credit-note?)
- (define (opt-val section name)
- (gnc:option-value
- (gnc:lookup-option options section name)))
-
- (let ((show-payments (opt-val "Display" "Payments"))
- (display-all-taxes (opt-val "Display" "Individual Taxes"))
- (lot (gncInvoiceGetPostedLot invoice))
- (txn (gncInvoiceGetPostedTxn invoice))
- (currency (gncInvoiceGetCurrency invoice))
- (reverse-payments? (not (gncInvoiceAmountPositive invoice)))
- (entries-added 0))
-
- (define (colspan monetary used-columns)
- (cond
- ((value-col used-columns) (value-col used-columns))
- ((taxvalue-col used-columns) (taxvalue-col used-columns))
- (else (price-col used-columns))))
-
- (define (display-subtotal monetary used-columns)
- (if (value-col used-columns)
- monetary
- (let ((amt (gnc:gnc-monetary-amount monetary)))
- (if amt
- (if (gnc-numeric-negative-p amt)
- (gnc:monetary-neg monetary)
- monetary)
- monetary))))
-
- (define (get-empty-row colcount)
- (define row-contents '())
- (do ((i 1 (+ i 1)))
- ((> i colcount))
- (addto! row-contents (gnc:make-html-table-cell)) ;;do stuff here
- )
- row-contents
- )
-
- (define (add-subtotal-row table used-columns
- subtotal subtotal-style subtotal-label)
- (let ((subtotal-mon (gnc:make-gnc-monetary currency subtotal)))
-
- (gnc:html-table-append-row/markup!
- table
- subtotal-style
- (append (cons (gnc:make-html-table-cell/markup
- "total-label-cell" subtotal-label)
- '())
- (list (gnc:make-html-table-cell/size/markup
- 1 (colspan subtotal-mon used-columns)
- "total-number-cell"
- (display-subtotal subtotal-mon used-columns)))))))
-
- (define (add-payment-row table used-columns split total-collector reverse-payments?)
- (let* ((t (xaccSplitGetParent split))
- (currency (xaccTransGetCurrency t))
- (invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
- (owner '())
- ;; Depending on the document type, the payments may need to be sign-reversed
- (amt (gnc:make-gnc-monetary currency
- (if reverse-payments?
- (gnc-numeric-neg(xaccSplitGetValue split))
- (xaccSplitGetValue split))))
- (payment-style "grand-total")
- (row '()))
-
- (total-collector 'add
- (gnc:gnc-monetary-commodity amt)
- (gnc:gnc-monetary-amount amt))
-
- (if (date-col used-columns)
- (addto! row
- (qof-print-date (xaccTransGetDate t))))
-
- (if (description-col used-columns)
- (addto! row (_ "Payment, thank you")))
-
- (gnc:html-table-append-row/markup!
- table
- payment-style
- (append (reverse row)
- (list (gnc:make-html-table-cell/size/markup
- 1 (colspan currency used-columns)
- "total-number-cell"
- (display-subtotal amt used-columns)))))))
-
- (define (do-rows-with-subtotals entries
- table
- used-columns
- width
- odd-row?)
- (if (null? entries)
- (let ((total-collector (gnc:make-commodity-collector)))
-
- ;; oli-custom - modified to have a minimum of entries per table,
- ;; currently defaults to 24
- ;; also, doesn't count payment rows and stuff
- (do ((entries-added entries-added (+ entries-added 1))
- (odd-row? odd-row? (not odd-row?)))
- ((> entries-added (opt-val "Display" "Minimum # of entries" )))
- (gnc:html-table-append-row/markup!
- table (if odd-row? "normal-row" "alternate-row")
- (get-empty-row (num-columns-required used-columns)))
- )
-
- (add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
- "grand-total" (_ "Net Price"))
-
- (if display-all-taxes
- (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
- (for-each
- (lambda (parm)
- (let* ((value (cdr parm))
- (acct (car parm))
- (name (xaccAccountGetName acct)))
- (add-subtotal-row table used-columns value
- "grand-total" (string-expand
- name #\space " "))))
- acct-val-list))
-
- ; nope, just show the total tax.
- (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
- "grand-total" (_ "Tax")))
-
- (add-subtotal-row table used-columns (gncInvoiceGetTotal invoice)
- "grand-total" (string-expand (_ "Total Price")
- #\space " "))
-
- (total-collector 'add currency (gncInvoiceGetTotal invoice))
- (if (and show-payments (not (null? lot)))
- (let ((splits (sort-list!
- (gnc-lot-get-split-list lot)
- (lambda (s1 s2)
- (let ((t1 (xaccSplitGetParent s1))
- (t2 (xaccSplitGetParent s2)))
- (< (xaccTransOrder t1 t2) 0))))))
- (for-each
- (lambda (split)
- (if (not (equal? (xaccSplitGetParent split) txn))
- (add-payment-row table used-columns
- split total-collector
- reverse-payments?)))
- splits)))
-
- (add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
- "grand-total" (string-expand (_ "Amount Due")
- #\space " ")))
-
- ;;
- ;; End of BEGIN -- now here's the code to handle all the entries!
- ;;
- (let* ((current (car entries))
- (current-row-style (if odd-row? "normal-row" "alternate-row"))
- (rest (cdr entries))
- (next (if (null? rest) #f
- (car rest)))
- (entry-values (add-entry-row table
- currency
- current
- used-columns
- current-row-style
- cust-doc? credit-note?)))
-
- (let ((order (gncEntryGetOrder current)))
- (if (not (null? order)) (add-order order)))
-
- (set! entries-added (+ entries-added 1))
-
- (do-rows-with-subtotals rest
- table
- used-columns
- width
- (not odd-row?)))))
-
- (let* ((table (gnc:make-html-table))
- (used-columns (build-column-used options))
- (width (num-columns-required used-columns))
- (entries (gncInvoiceGetEntries invoice)))
-
- (gnc:html-table-set-col-headers!
- table
- (make-heading-list used-columns))
-
- (do-rows-with-subtotals entries
- table
- used-columns
- width
- #t)
- table)))
-
-(define (string-expand string character replace-string)
- (define (car-line chars)
- (take-while (lambda (c) (not (eqv? c character))) chars))
- (define (cdr-line chars)
- (let ((rest (drop-while (lambda (c) (not (eqv? c character))) chars)))
- (if (null? rest)
- '()
- (cdr rest))))
- (define (line-helper chars)
- (if (null? chars)
- ""
- (let ((first (car-line chars))
- (rest (cdr-line chars)))
- (string-append (list->string first)
- (if (null? rest) "" replace-string)
- (line-helper rest)))))
- (line-helper (string->list string)))
-
-(define (make-client-table owner orders)
- (let ((table (gnc:make-html-table))
- (name-cell (gnc:make-html-table-cell)))
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0))
- (gnc:html-table-cell-append-objects!
- name-cell (gnc:owner-get-name-dep owner))
- (gnc:html-table-cell-set-style!
- name-cell "td"
- 'font-size "+2")
- (gnc:html-table-append-row! table (list name-cell "" "")) ;;Bert: had a newline and a "<br/>"
- (gnc:html-table-append-row!
- table
- (list
- (string-expand (gnc:owner-get-address-dep owner) #\newline "<br/>")))
- (gnc:html-table-append-row!
- table
- (list "<br/>"))
- (for-each
- (lambda (order)
- (let* ((reference (gncOrderGetReference order)))
- (if (and reference (> (string-length reference) 0))
- (gnc:html-table-append-row!
- table
- (list
- (string-append (_ "REF") ": " reference))))))
- orders)
- (gnc:html-table-set-last-row-style!
- table "td"
- 'attribute (list "valign" "top"))
- table))
-
-(define (make-date-row! table label date date-format)
- (gnc:html-table-append-row!
- table
- (list
- (string-append label ": ")
- ;; oli-custom - modified to display a custom format
- ;; for the invoice date/due date fields
- ;; I could have taken the format from the report options, but... ;)
- (string-expand (strftime (gnc-default-strftime-date-format)
- (gnc-localtime date))
- #\space " ")
- ;;(string-expand (qof-print-date date) #\space " ")
- )))
-
-(define (make-date-table)
- (let ((table (gnc:make-html-table)))
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellpadding" 0))
- (gnc:html-table-set-last-row-style!
- table "td"
- 'attribute (list "valign" "top"))
- table))
-
-(define (make-myname-table book title)
- (let* ((table (gnc:make-html-table))
- (name (gnc:company-info book gnc:*company-name*))
- ;; (contact (gnc:company-info book gnc:*company-contact*))
- (addy (gnc:company-info book gnc:*company-addy*))
- (id (gnc:company-info book gnc:*company-id*))
- (phone (gnc:company-info book gnc:*company-phone*))
- (fax (gnc:company-info book gnc:*company-fax*))
- (url (gnc:company-info book gnc:*company-url*))
- (invoice-cell (gnc:make-html-table-cell))
- (name-cell (gnc:make-html-table-cell))
-
- )
- ;; oli-custom - modified the name table to increase the
- ;; font size of the company name
- ;; and add an "INVOICE" title to the upper right, also,
- ;; put some contact information in the middle
- ;; FIXME: "INVOICE" should be translated and support bills/expense vouchers
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0)
- 'attribute (list "width" "100%"))
- (gnc:html-table-cell-append-objects!
- invoice-cell title)
- (gnc:html-table-cell-set-style!
- invoice-cell "td"
- 'font-size "+2")
- (gnc:html-table-cell-append-objects!
- name-cell (if name name ""))
- (gnc:html-table-cell-set-style!
- name-cell "td"
- 'font-size "+2")
- (gnc:html-table-append-row! table (list name-cell (gnc:make-html-table-cell) invoice-cell)) ;;(gnc:make-html-table-cell) was ""
- (gnc:html-table-set-col-style!
- table 1 "td"
- 'attribute (list "align" "center")
- 'attribute (list "width" "33%"))
- (gnc:html-table-set-col-style!
- table 2 "td"
- 'attribute (list "align" "right")
- 'attribute (list "width" "33%"))
- (gnc:html-table-append-row!
- table (list (string-expand (string-append (if addy addy "") (if id (string-append "\n" id) "")) #\newline "<br/>")
- (string-expand
- (string-append (if phone
- (string-append (_ "Phone:") " " phone)
- "")
- (if fax (string-append (if phone "\n" "")
- (_ "Fax:") " " fax)
- ""))
- #\newline "<br/>" )
- (if url (string-append (_ "Web:") " " url) "")))
-
- ;; oli-custom - I didn't want today's date on the invoice.
- ;; The invoice already has a date.
- ;; Today's date can be in the email, fax or letter accompanying the invoice.
- ;; (gnc:html-table-append-row! table (list
- ;; (strftime
- ;; date-format
- ;; (gnc-localtime (gnc:get-today)))))
- table))
-
-(define (make-break! document)
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (gnc:html-markup-br))))
-
-(define (reg-renderer report-obj)
- (define (opt-val section name)
- (gnc:option-value
- (gnc:lookup-option (gnc:report-options report-obj) section name)))
-
- (define (title-string title custom-title)
- (if (not (equal? "" custom-title))
- (string-expand custom-title
- #\space " ")
- title))
-
- (let* ((document (gnc:make-html-document))
- (table '())
- (orders '())
- (invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
- (owner '())
- (references? (opt-val "Display" "References"))
- (default-title (_ "Invoice"))
- (custom-title (opt-val gnc:pagename-general "Custom Title"))
- (cust-doc? #f)
- (credit-note? #f))
-
-
- (define (add-order o)
- (if (and references? (not (member o orders)))
- (addto! orders o)))
-
- (if (not (null? invoice))
- (begin
- (set! owner (gncInvoiceGetOwner invoice))
- (let ((type (gncInvoiceGetType invoice)))
- (cond
- ((eqv? type GNC-INVOICE-CUST-INVOICE)
- (set! cust-doc? #t))
- ((eqv? type GNC-INVOICE-VEND-INVOICE)
- (set! default-title (_ "Bill")))
- ((eqv? type GNC-INVOICE-EMPL-INVOICE)
- (set! default-title (_ "Expense Voucher")))
- ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
- (begin
- (set! cust-doc? #t)
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
- (begin
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
- (begin
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))))
- ))
-
- ;; oli-custom - title redundant, "Invoice" moved to myname-table,
- ;; invoice number moved below
- ;;(gnc:html-document-set-title! document title)
-
-
- (if (not (null? invoice))
- (let* ((book (gncInvoiceGetBook invoice))
- (date-object #f)
- (date-format (gnc:options-fancy-date book))
- (helper-table (gnc:make-html-table))
- (title (title-string default-title custom-title)))
-
- (set! table (make-entry-table invoice
- (gnc:report-options report-obj)
- add-order cust-doc? credit-note?))
-
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 1)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 4)
- ;; oli-custom - make table as wide as possible
- ;; works fine with simple style sheet templates,
- ;; doesn't work quite right with fancy ones
- ;; probably supplying the style sheet with a wide image
- ;; for the header (even if transparent/white) would fix it
- 'attribute (list "width" "100%"))
-
- ;; oli-custom - make the description column big
- ;; 50% or 60%, depending on whether the first column is
- ;; displayed or not
- ;; should actually be something more complicated,
- ;; it's a really ugly hack right now :)
- (gnc:html-table-set-col-style!
- table (if (opt-val "Display Columns" "Date") 1 0) "td"
- 'attribute (list "width" (if (opt-val "Display Columns" "Date")
- "50%" "60%")))
-
- (gnc:html-document-add-object!
- document (make-myname-table
- book title))
-
- (make-break! document)
- (make-break! document)
- (make-break! document)
-
- ;; oli-custom - client table and table with invoice
- ;; number/date/due date both inserted into a table
- (gnc:html-table-set-style!
- helper-table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0)
- 'attribute (list "width" "100%"))
-
- (set! date-object
- (if (gncInvoiceIsPosted invoice)
- (let ((date-table #f)
- (post-date (gncInvoiceGetDatePosted invoice))
- (due-date (gncInvoiceGetDateDue invoice)))
- (set! date-table (make-date-table))
- (gnc:html-table-append-row!
- ;; Translators: ~a below is "Invoice" or "Bill" or even the
- ;; custom title from the options. The next column contains
- ;; the number of the document.
- date-table (list (format #f (_ "~a #") title) (gncInvoiceGetID invoice)))
- ;; Translators: The first ~a below is "Invoice" or
- ;; "Bill" or even the custom title from the
- ;; options. This string sucks for i18n, but I don't
- ;; have a better solution right now without breaking
- ;; other people's invoices.
- (make-date-row! date-table (format #f (_ "~a Date") title) post-date date-format)
- (make-date-row! date-table (_ "Due Date") due-date date-format)
- date-table)
- (gnc:make-html-text
- (string-append title "<br/>"
- (_ "Invoice in progress...")))))
-
- (gnc:html-table-append-row!
- helper-table
- (list (make-client-table owner orders) date-object))
-
- (gnc:html-table-set-col-style!
- helper-table 0 "td"
- 'attribute (list "valign" "top"))
-
- (gnc:html-table-set-col-style!
- helper-table 1 "td"
- 'attribute (list "valign" "top")
- 'attribute (list "align" "right")
- ;; oli-custom - "squeeze" the date table,
- ;; or else it's spaced out
- 'attribute (list "width" "1%"))
-
- (gnc:html-document-add-object!
- document
- helper-table)
-
- (make-break! document)
-
- (if (opt-val "Display" "Billing ID")
- (let ((billing-id (gncInvoiceGetBillingID invoice)))
- (if (and billing-id (> (string-length billing-id) 0))
- (begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Reference") ": "
- (string-expand billing-id #\newline "<br/>"))))
- (make-break! document)))))
-
- (if (opt-val "Display" "Billing Terms")
- (let* ((term (gncInvoiceGetTerms invoice))
- (terms (gncBillTermGetDescription term)))
- (if (and terms (> (string-length terms) 0))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Terms") ": "
- (string-expand terms #\newline "<br/>")))))))
-
- (make-break! document)
-
- (gnc:html-document-add-object! document table)
-
- (make-break! document)
- (make-break! document)
-
- (if (opt-val "Display" "Invoice Notes")
- (let ((notes (gncInvoiceGetNotes invoice)))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-expand notes #\newline "<br/>")))))
-
- (make-break! document)
-
- (if (opt-val "Display" "Payable to")
- (let* ((name (gnc:company-info book gnc:*company-name*))
- (name-str (opt-val "Display" "Payable to string")))
- (if (and name (> (string-length name) 0))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append name-str ": "
- (string-expand name #\newline "<br/>")))))))
-
- (make-break! document)
-
- (if (opt-val "Display" "Company contact")
- (let* ((contact (gnc:company-info book gnc:*company-contact*))
- (contact-str (opt-val "Display" "Company contact string")))
- (if (and contact (> (string-length contact) 0))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append contact-str ": "
- (string-expand contact #\newline "<br/>")))))))
-
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (gnc:html-markup-br)
- (string-expand (opt-val "Display" "Extra Notes") #\newline "<br/>")
- (gnc:html-markup-br))))
-
- ; else
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (_ "No valid invoice selected. Click on the Options button and select the invoice to use."))))
-
- document))
-
-(define fancy-invoice-guid "3ce293441e894423a2425d7a22dd1ac6")
-
-(gnc:define-report
- 'version 1
- 'name (N_ "Fancy Invoice")
- 'report-guid fancy-invoice-guid
- 'menu-path (list gnc:menuname-business-reports)
- 'options-generator options-generator
- 'renderer reg-renderer
- 'in-menu? #t)
-
-(define (gnc:fancy-invoice-report-create-internal invoice)
- (let* ((options (gnc:make-report-options fancy-invoice-guid))
- (invoice-op (gnc:lookup-option options gnc:pagename-general gnc:optname-invoice-number)))
-
- (gnc:option-set-value invoice-op invoice)
- (gnc:make-report fancy-invoice-guid options)))
-
-(export gnc:fancy-invoice-report-create-internal)
commit 15b62eea6c4faf4da4ad49bc244b11ec7f6ccb8c
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 9 10:33:24 2018 +0800
[invoice+fancy-invoice] add option minimum # entries
This is to enable compatibility with fancy-invoice feature.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index e9ffc7b..088d744 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -278,6 +278,12 @@
"d" (N_ "Display the subtotals?") #t))
(gnc:register-inv-option
+ (gnc:make-number-range-option
+ (N_ "Display") (N_ "Minimum # of entries")
+ "zz" (N_ "The minimum number of invoice entries to display.") 0
+ 4 23 0 1))
+
+ (gnc:register-inv-option
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Individual Taxes")
"o" (N_ "Display all the individual taxes?") #f))
@@ -402,12 +408,23 @@
table
used-columns
width
- odd-row?)
+ odd-row?
+ num-entries)
(if (null? entries)
;; all entries done, add subtotals
(let ((total-collector (gnc:make-commodity-collector)))
+ ;; minimum number of entries- replicating fancy-invoice option
+ (let loop ((num-entries-left (- (opt-val "Display" "Minimum # of entries" ) num-entries))
+ (odd-row? odd-row?))
+ (when (positive? num-entries-left)
+ (gnc:html-table-append-row/markup!
+ table (if odd-row? "normal-row" "alternate-row")
+ (gnc:html-make-empty-cells (num-columns-required used-columns)))
+ (loop (1- num-entries-left)
+ (not odd-row?))))
+
(if display-subtotal?
(add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
"grand-total" (_ "Net Price")))
@@ -464,7 +481,8 @@
table
used-columns
width
- (not odd-row?)))))
+ (not odd-row?)
+ (1+ num-entries)))))
(let* ((table (gnc:make-html-table))
(used-columns (build-column-used options))
@@ -483,7 +501,8 @@
table
used-columns
width
- #t)
+ #t
+ 0)
table)))
(define (make-invoice-details-table invoice options display-due-date?)
commit 74ebac461b3a1a60459225b6887d50e1f94886a1
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 9 00:46:38 2018 +0800
[invoice+easy-invoice] invoice.scm can generate easy-invoice
invoice.scm can now mimic easy-invoice.scm reports, including a
greater number of options.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 8c37d8f..e9ffc7b 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -190,7 +190,7 @@
(loop (cdr list-of-substrings)
(cons* (gnc:html-markup-br) (car list-of-substrings) result)))))
-(define (options-generator)
+(define (options-generator css-default)
(define gnc:*report-options* (gnc:new-options))
@@ -208,6 +208,11 @@
""))
(gnc:register-inv-option
+ (gnc:make-internal-option
+ "General" "CSS"
+ css-default))
+
+ (gnc:register-inv-option
(gnc:make-simple-boolean-option
(N_ "Display Columns") (N_ "Date")
"b" (N_ "Display the date?") #t))
@@ -254,6 +259,26 @@
(gnc:register-inv-option
(gnc:make-simple-boolean-option
+ (N_ "Display") (N_ "My Company")
+ "a" (N_ "Display my company name and address?") #f))
+
+ (gnc:register-inv-option
+ (gnc:make-simple-boolean-option
+ (N_ "Display") (N_ "My Company ID")
+ "b" (N_ "Display my company ID?") #f))
+
+ (gnc:register-inv-option
+ (gnc:make-simple-boolean-option
+ (N_ "Display") (N_ "Due Date")
+ "c" (N_ "Display due date?") #t))
+
+ (gnc:register-inv-option
+ (gnc:make-simple-boolean-option
+ (N_ "Display") (N_ "Subtotal")
+ "d" (N_ "Display the subtotals?") #t))
+
+ (gnc:register-inv-option
+ (gnc:make-simple-boolean-option
(N_ "Display") (N_ "Individual Taxes")
"o" (N_ "Display all the individual taxes?") #f))
@@ -310,6 +335,7 @@
(let ((show-payments (opt-val "Display" "Payments"))
(display-all-taxes (opt-val "Display" "Individual Taxes"))
+ (display-subtotal? (opt-val "Display" "Subtotal"))
(lot (gncInvoiceGetPostedLot invoice))
(txn (gncInvoiceGetPostedTxn invoice))
(currency (gncInvoiceGetCurrency invoice))
@@ -382,8 +408,9 @@
;; all entries done, add subtotals
(let ((total-collector (gnc:make-commodity-collector)))
- (add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
- "grand-total" (_ "Net Price"))
+ (if display-subtotal?
+ (add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
+ "grand-total" (_ "Net Price")))
(if display-all-taxes
(for-each
@@ -459,7 +486,7 @@
#t)
table)))
-(define (make-invoice-details-table invoice options)
+(define (make-invoice-details-table invoice options display-due-date?)
;; dual-column. invoice date/due, billingID, terms, job name/number
(define (opt-val section name)
(gnc:option-value
@@ -483,9 +510,10 @@
invoice-details-table
(make-date-row (_ "Date") post-date date-format))
- (gnc:html-table-append-row!
- invoice-details-table
- (make-date-row (_ "Due Date") due-date date-format)))
+ (if display-due-date?
+ (gnc:html-table-append-row!
+ invoice-details-table
+ (make-date-row (_ "Due Date") due-date date-format))))
(gnc:html-table-append-row! invoice-details-table
(gnc:make-html-table-cell/size
@@ -556,11 +584,12 @@
(strftime date-format
(localtime date))))
-(define (make-myname-table book date-format)
+(define (make-myname-table book date-format display-tax-id?)
;; single-column table. my name, address, and printdate
(let* ((table (gnc:make-html-table))
(name (gnc:company-info book gnc:*company-name*))
- (addy (gnc:company-info book gnc:*company-addy*)))
+ (addy (gnc:company-info book gnc:*company-addy*))
+ (taxid (gnc:company-info book gnc:*company-id*)))
(gnc:html-table-set-style! table "table"
'attribute (list "border" 0)
@@ -575,6 +604,9 @@
(if (and addy (not (string-null? addy)))
(gnc:html-table-append-row! table (list (multiline-to-html-text addy))))
+ (if (and display-tax-id? taxid (not (string-null? taxid)))
+ (gnc:html-table-append-row! table (list (multiline-to-html-text taxid))))
+
(gnc:html-table-append-row! table (list (qof-print-date (current-time))))
table))
@@ -586,6 +618,9 @@
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
(references? (opt-val "Display" "References"))
(custom-title (opt-val gnc:pagename-general "Custom Title"))
+ (company-table? (opt-val "Display" "My Company"))
+ (display-tax-id? (opt-val "Display" "My Company ID"))
+ (display-due-date? (opt-val "Display" "Due Date"))
(title-string (lambda (title custom-title) (if (string-null? custom-title) title custom-title))))
(if (null? invoice)
@@ -609,30 +644,36 @@
(else
(_ "Invoice"))))
(title (title-string default-title custom-title))
+ (invoice-title (format #f (_"~a #~a") title (gncInvoiceGetID invoice)))
(entry-table (make-entry-table invoice
(gnc:report-options report-obj)
cust-doc? credit-note?)))
- (gnc:html-document-set-title! document (format #f (_"~a #~a") title
- (gncInvoiceGetID invoice)))
+ (gnc:html-document-set-title! document invoice-title)
- (gnc:html-document-set-style-text! document invoice-css)
+ (gnc:html-document-set-style-text! document (opt-val "General" "CSS"))
(let ((main-table (gnc:make-html-table)))
(gnc:html-table-append-row! main-table
+ (gnc:make-html-table-cell/size
+ 1 2 (gnc:make-html-div/markup
+ "invoice-title" invoice-title)))
+
+ (gnc:html-table-append-row! main-table
(list #f
(gnc:make-html-div/markup
"invoice-details-table"
- (make-invoice-details-table invoice options))))
+ (make-invoice-details-table invoice options display-due-date?))))
(gnc:html-table-append-row! main-table
(list (gnc:make-html-div/markup
"client-table"
(make-client-table owner orders))
- (gnc:make-html-div/markup
- "company-table" (make-myname-table book date-format))))
+ (and company-table?
+ (gnc:make-html-div/markup
+ "company-table" (make-myname-table book date-format display-tax-id?)))))
(gnc:html-table-append-row! main-table
(gnc:make-html-table-cell/size
@@ -660,12 +701,32 @@
document))
(define invoice-report-guid "5123a759ceb9483abf2182d01c140e8d")
+(define easy-invoice-guid "67112f318bef4fc496bdc27d106bbda4")
(gnc:define-report
'version 1
'name (N_ "Printable Invoice")
'report-guid invoice-report-guid
'menu-path (list gnc:menuname-business-reports)
- 'options-generator options-generator
+ 'options-generator (lambda () (options-generator easy-invoice-css))
'renderer reg-renderer
'in-menu? #t)
+
+#;
+(gnc:define-report
+ 'version 1
+ 'name (N_ "Easy Invoice")
+ 'report-guid easy-invoice-guid
+ 'menu-path (list gnc:menuname-business-reports)
+ 'options-generator (lambda () (options-generator easy-invoice-css))
+ 'renderer reg-renderer
+ 'in-menu? #t)
+
+(define (gnc:easy-invoice-report-create-internal invoice)
+ (let* ((options (gnc:make-report-options easy-invoice-guid))
+ (invoice-op (gnc:lookup-option options gnc:pagename-general gnc:optname-invoice-number)))
+
+ (gnc:option-set-value invoice-op invoice)
+ (gnc:make-report easy-invoice-guid options)))
+
+(export gnc:easy-invoice-report-create-internal)
diff --git a/gnucash/report/business-reports/test/test-invoice.scm b/gnucash/report/business-reports/test/test-invoice.scm
index 976b267..638dfab 100644
--- a/gnucash/report/business-reports/test/test-invoice.scm
+++ b/gnucash/report/business-reports/test/test-invoice.scm
@@ -202,7 +202,8 @@
(set-option! options "Display" disp-col-name setting))
(case variant
((invoice)
- '("Individual Taxes" "Totals" "References" "Billing Terms"
+ '("My Company" "My Company ID" "Due Date"
+ "Individual Taxes" "Totals" "Subtotal" "References" "Billing Terms"
"Billing ID" "Invoice Notes" "Payments" "Job Details"))
((fancy-invoice)
'("Individual Taxes" "Totals" "References" "Billing Terms"
commit bfde5a17f7e15a53c6ab31c54a91c665e72fbd65
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jun 8 23:10:46 2018 +0800
[invoice] add classes for invoice headers
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index d317c10..8c37d8f 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -489,8 +489,10 @@
(gnc:html-table-append-row! invoice-details-table
(gnc:make-html-table-cell/size
- 1 2 (gnc:make-html-text
- (_ "Invoice in progress...")))))
+ 1 2 (gnc:make-html-span/markup
+ "invoice-in-progress"
+ (gnc:make-html-text
+ (_ "Invoice in progress..."))))))
(if (opt-val "Display" "Billing ID")
(let ((billing-id (gncInvoiceGetBillingID invoice)))
commit 7ef4c00579bce385d1e31863136805f16f1d330e
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jun 8 22:33:45 2018 +0800
[easy-invoice] Display/Charge Type rename back to Display/Action
This report had renamed "Action" to "Charge Type". For consistency,
let's rename it back, and add migration path in options.scm for
saved-options. 2 fewer strings for translation.
diff --git a/gnucash/report/business-reports/easy-invoice.scm b/gnucash/report/business-reports/easy-invoice.scm
index 3d7db5b..a2497a5 100644
--- a/gnucash/report/business-reports/easy-invoice.scm
+++ b/gnucash/report/business-reports/easy-invoice.scm
@@ -84,7 +84,7 @@
(set-col (make-set-col col-vector)))
(set-col (opt-val "Display Columns" "Date") 0)
(set-col (opt-val "Display Columns" "Description") 1)
- (set-col (opt-val "Display Columns" "Charge Type") 2)
+ (set-col (opt-val "Display Columns" "Action") 2)
(set-col (opt-val "Display Columns" "Quantity") 3)
(set-col (opt-val "Display Columns" "Price") 4)
(set-col (opt-val "Display Columns" "Discount") 5)
@@ -101,7 +101,7 @@
(if (description-col column-vector)
(addto! heading-list (_ "Description")))
(if (action-col column-vector)
- (addto! heading-list (_ "Charge Type")))
+ (addto! heading-list (_ "Action")))
(if (quantity-col column-vector)
(addto! heading-list (_ "Quantity")))
(if (price-col column-vector)
@@ -222,8 +222,8 @@
(gnc:register-inv-option
(gnc:make-simple-boolean-option
- (N_ "Display Columns") (N_ "Charge Type")
- "g" (N_ "Display the charge type?") #t))
+ (N_ "Display Columns") (N_ "Action")
+ "g" (N_ "Display the action?") #t))
(gnc:register-inv-option
(gnc:make-simple-boolean-option
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 9429fa4..d317c10 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -100,7 +100,7 @@
(addif (description-col column-vector)
(_ "Description"))
(addif (action-col column-vector)
- (_ "Charge Type"))
+ (_ "Action"))
(addif (quantity-col column-vector)
(_ "Quantity"))
(addif (price-col column-vector)
diff --git a/gnucash/report/business-reports/test/test-invoice.scm b/gnucash/report/business-reports/test/test-invoice.scm
index 52159d6..976b267 100644
--- a/gnucash/report/business-reports/test/test-invoice.scm
+++ b/gnucash/report/business-reports/test/test-invoice.scm
@@ -193,12 +193,10 @@
(lambda (disp-col-name)
(set-option! options "Display Columns" disp-col-name setting))
(case variant
- ((invoice fancy-invoice)
+ ((invoice fancy-invoice easy-invoice)
'("Date" "Description" "Action" "Quantity" "Price" "Discount"
"Taxable" "Tax Amount" "Total"))
- ((easy-invoice)
- '("Date" "Description" "Charge Type" "Quantity"
- "Price" "Discount" "Taxable" "Tax Amount" "Total"))))
+ (else '())))
(for-each
(lambda (disp-col-name)
(set-option! options "Display" disp-col-name setting))
diff --git a/libgnucash/app-utils/options.scm b/libgnucash/app-utils/options.scm
index f460f95..0568edd 100644
--- a/libgnucash/app-utils/options.scm
+++ b/libgnucash/app-utils/options.scm
@@ -1717,6 +1717,7 @@
"Show zero balance items?" (cons #f "Show zero balance items")
"Sign Reverses?" (cons #f "Sign Reverses")
"To" (cons #f "End Date")
+ "Charge Type" (cons #f "Action") ;easy-invoice.scm, renamed June 2018
"Use Full Account Name?" (cons #f "Use Full Account Name")
"Use Full Other Account Name?" (cons #f "Use Full Other Account Name")
"Void Transactions?" (cons "Filter" "Void Transactions")
commit d6071020e15978675fd224d8bd2f919829263f69
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jun 4 23:15:50 2018 +0800
[invoice] more refactoring
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 8bce6aa..9429fa4 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -120,10 +120,10 @@
(gnc:make-gnc-monetary currency numeric)))
(define (add-entry-row table currency entry column-vector row-style cust-doc? credit-note?)
- (let* ((entry-value (gnc:make-gnc-monetary currency
- (gncEntryGetDocValue entry #t cust-doc? credit-note?)))
- (entry-tax-value (gnc:make-gnc-monetary currency
- (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
+ (let* ((entry-value (gnc:make-gnc-monetary
+ currency (gncEntryGetDocValue entry #t cust-doc? credit-note?)))
+ (entry-tax-value (gnc:make-gnc-monetary
+ currency (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
(gnc:html-table-append-row/markup!
table row-style
@@ -178,6 +178,18 @@
(cons entry-value entry-tax-value)))
+
+(define (multiline-to-html-text str)
+ ;; simple function - splits string containing #\newline into
+ ;; substrings, and convert to a gnc:make-html-text construct which
+ ;; adds gnc:html-markup-br after each substring.
+ (let loop ((list-of-substrings (string-split str #\newline))
+ (result '()))
+ (if (null? list-of-substrings)
+ (apply gnc:make-html-text (if (null? result) '() (reverse (cdr result))))
+ (loop (cdr list-of-substrings)
+ (cons* (gnc:html-markup-br) (car list-of-substrings) result)))))
+
(define (options-generator)
(define gnc:*report-options* (gnc:new-options))
@@ -290,6 +302,7 @@
gnc:*report-options*)
+
(define (make-entry-table invoice options cust-doc? credit-note?)
(define (opt-val section name)
(gnc:option-value
@@ -299,16 +312,15 @@
(display-all-taxes (opt-val "Display" "Individual Taxes"))
(lot (gncInvoiceGetPostedLot invoice))
(txn (gncInvoiceGetPostedTxn invoice))
- (job? (opt-val "Display" "Job Details"))
(currency (gncInvoiceGetCurrency invoice))
(jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(reverse-payments? (not (gncInvoiceAmountPositive invoice))))
(define (colspan monetary used-columns)
- (or (value-col used-columns)
- (taxvalue-col used-columns)
- (price-col used-columns)))
+ (or (value-col used-columns)
+ (taxvalue-col used-columns)
+ (price-col used-columns)))
(define (display-subtotal monetary used-columns)
(if (value-col used-columns)
@@ -435,6 +447,11 @@
(gnc:html-table-set-col-headers! table
(make-heading-list used-columns))
+ (gnc:html-table-set-style! table "table"
+ 'attribute (list "border" 1)
+ 'attribute (list "cellspacing" 0)
+ 'attribute (list "cellpadding" 4))
+
(do-rows-with-subtotals entries
table
used-columns
@@ -442,78 +459,72 @@
#t)
table)))
-(define (multiline-to-html-text str)
-;; simple function - splits string containing #\newline into
-;; substrings, and convert to a gnc:make-html-text construct which
-;; adds gnc:html-markup-br after each substring.
- (let loop ((list-of-substrings (string-split str #\newline))
- (result '()))
- (if (null? list-of-substrings)
- (apply gnc:make-html-text (if (null? result) '() (reverse (cdr result))))
- (loop (cdr list-of-substrings)
- (cons* (gnc:html-markup-br) (car list-of-substrings) result)))))
-
-(define (make-invoice-details-table invoice billing-id? billing-terms? job?)
+(define (make-invoice-details-table invoice options)
+ ;; dual-column. invoice date/due, billingID, terms, job name/number
+ (define (opt-val section name)
+ (gnc:option-value
+ (gnc:lookup-option options section name)))
(let* ((invoice-details-table (gnc:make-html-table))
(book (gncInvoiceGetBook invoice))
(date-format (gnc:options-fancy-date book))
- (jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
- (jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice)))))
+ (jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
+ (jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice)))))
(gnc:html-table-set-style! invoice-details-table "table"
- 'attribute (list "class" "date-table")
'attribute (list "align" "right")
'attribute (list "cellspacing" 0)
'attribute (list "cellpadding" 1))
(if (gncInvoiceIsPosted invoice)
+
(let ((post-date (gncInvoiceGetDatePosted invoice))
(due-date (gncInvoiceGetDateDue invoice)))
- (make-date-row! invoice-details-table (_ "Date") post-date date-format)
- (make-date-row! invoice-details-table (_ "Due Date") due-date date-format))
+ (gnc:html-table-append-row!
+ invoice-details-table
+ (make-date-row (_ "Date") post-date date-format))
+
+ (gnc:html-table-append-row!
+ invoice-details-table
+ (make-date-row (_ "Due Date") due-date date-format)))
+
(gnc:html-table-append-row! invoice-details-table
- (gnc:make-html-text
- (_ "Invoice in progress..."))))
+ (gnc:make-html-table-cell/size
+ 1 2 (gnc:make-html-text
+ (_ "Invoice in progress...")))))
- (if billing-id?
+ (if (opt-val "Display" "Billing ID")
(let ((billing-id (gncInvoiceGetBillingID invoice)))
(if (and billing-id (not (string-null? billing-id)))
(begin
(gnc:html-table-append-row! invoice-details-table
(list
(_ "Reference")
- billing-id))
+ (multiline-to-html-text billing-id)))
(gnc:html-table-append-row! invoice-details-table '())))))
- (if billing-terms?
+ (if (opt-val "Display" "Billing Terms")
(let* ((term (gncInvoiceGetTerms invoice))
(terms (gncBillTermGetDescription term)))
(if (and terms (not (string-null? terms)))
- (begin
- (gnc:html-table-append-row! invoice-details-table
- (list
- (_ "Terms")
- terms))
- (gnc:html-table-append-row! invoice-details-table '())))))
+ (gnc:html-table-append-row! invoice-details-table
+ (list
+ (_ "Terms")
+ (multiline-to-html-text terms))))))
;; Add job number and name to invoice if requested and if it exists
- (if (and job?
+ (if (and (opt-val "Display" "Job Details")
(not (string-null? jobnumber)))
(begin
(gnc:html-table-append-row! invoice-details-table
- (list
- (_ "Job number")
- jobnumber))
- (gnc:html-table-append-row! invoice-details-table '())
+ (list (_ "Job number")
+ jobnumber))
(gnc:html-table-append-row! invoice-details-table
- (list
- (_ "Job name")
- jobname))
- (gnc:html-table-append-row! invoice-details-table '())
- (gnc:html-table-append-row! invoice-details-table '())))
+ (list (_ "Job name")
+ jobname))))
invoice-details-table))
(define (make-client-table owner orders)
+ ;; this is a single-column table.
(let ((table (gnc:make-html-table)))
(gnc:html-table-set-style! table "table"
'attribute (list "border" 0)
@@ -522,34 +533,29 @@
(gnc:html-table-append-row! table
(list
- (multiline-to-html-text (gnc:owner-get-name-and-address-dep owner))))
-
- (gnc:html-table-append-row! table
- (list
- (gnc:make-html-text
- (gnc:html-markup-br))))
+ (multiline-to-html-text
+ (gnc:owner-get-name-and-address-dep owner))))
(for-each
(lambda (order)
(let ((reference (gncOrderGetReference order)))
(if (and reference (not (string-null? reference)))
(gnc:html-table-append-row! table
- (list
- (string-append (_ "REF") ": " reference))))))
+ (list (string-append
+ (_ "REF") " "
+ reference))))))
orders)
- (gnc:html-table-set-last-row-style! table "td"
- 'attribute (list "valign" "top"))
table))
-(define (make-date-row! table label date date-format)
- (gnc:html-table-append-row! table
- (list
- (string-append label ": ")
- (strftime date-format
- (localtime date)))))
+(define (make-date-row label date date-format)
+ (list
+ (string-append label ":")
+ (strftime date-format
+ (localtime date))))
(define (make-myname-table book date-format)
+ ;; single-column table. my name, address, and printdate
(let* ((table (gnc:make-html-table))
(name (gnc:company-info book gnc:*company-name*))
(addy (gnc:company-info book gnc:*company-addy*)))
@@ -561,52 +567,36 @@
'attribute (list "cellspacing" 0)
'attribute (list "cellpadding" 0))
- (gnc:html-table-append-row! table (list (or name "")))
+ (if (and name (not (string-null? name)))
+ (gnc:html-table-append-row! table (list name)))
- (gnc:html-table-append-row! table (list (multiline-to-html-text (or addy ""))))
+ (if (and addy (not (string-null? addy)))
+ (gnc:html-table-append-row! table (list (multiline-to-html-text addy))))
(gnc:html-table-append-row! table (list (qof-print-date (current-time))))
table))
-(define (make-break! document)
- (gnc:html-document-add-object! document
- (gnc:make-html-text
- (gnc:html-markup-br))))
-
(define (reg-renderer report-obj)
- (define (opt-val section name)
- (gnc:option-value
- (gnc:lookup-option (gnc:report-options report-obj) section name)))
-
- (define (title-string title custom-title)
- (if (not (string-null? custom-title))
- custom-title
- title))
-
(let* ((document (gnc:make-html-document))
+ (options (gnc:report-options report-obj))
+ (opt-val (lambda (section name) (gnc:option-value (gnc:lookup-option options section name))))
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
(references? (opt-val "Display" "References"))
- (job? (opt-val "Display" "Job Details"))
- (billing-id? (opt-val "Display" "Billing ID"))
- (billing-terms? (opt-val "Display" "Billing Terms"))
- (book (gncInvoiceGetBook invoice))
- (date-format (gnc:options-fancy-date book))
- (custom-title (opt-val gnc:pagename-general "Custom Title")))
+ (custom-title (opt-val gnc:pagename-general "Custom Title"))
+ (title-string (lambda (title custom-title) (if (string-null? custom-title) title custom-title))))
(if (null? invoice)
-
(gnc:html-document-add-object! document
(gnc:make-html-text
(_ "No valid invoice selected. Click on the Options button and select the invoice to use.")))
-
(let* ((book (gncInvoiceGetBook invoice))
+ (date-format (gnc:options-fancy-date book))
(owner (gncInvoiceGetOwner invoice))
(type (gncInvoiceGetType invoice))
(orders (if references? (delete-duplicates (map gncEntryGetOrder (gncInvoiceGetEntries invoice))) '()))
(cust-doc? (memq type (list GNC-INVOICE-CUST-INVOICE GNC-INVOICE-CUST-CREDIT-NOTE)))
- (credit-note? (memq type (list GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE
- GNC-INVOICE-EMPL-CREDIT-NOTE)))
+ (credit-note? (memq type (list GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE GNC-INVOICE-EMPL-CREDIT-NOTE)))
(default-title (case type
((GNC-INVOICE-VEND-INVOICE)
(_ "Bill"))
@@ -617,9 +607,9 @@
(else
(_ "Invoice"))))
(title (title-string default-title custom-title))
- (table (make-entry-table invoice
- (gnc:report-options report-obj)
- cust-doc? credit-note?)))
+ (entry-table (make-entry-table invoice
+ (gnc:report-options report-obj)
+ cust-doc? credit-note?)))
(gnc:html-document-set-title! document (format #f (_"~a #~a") title
(gncInvoiceGetID invoice)))
@@ -629,40 +619,41 @@
(let ((main-table (gnc:make-html-table)))
(gnc:html-table-append-row! main-table
- (list "BLABLA"
- (make-invoice-details-table
- invoice billing-id?
- billing-terms? job?)))
+ (list #f
+ (gnc:make-html-div/markup
+ "invoice-details-table"
+ (make-invoice-details-table invoice options))))
(gnc:html-table-append-row! main-table
- (list (make-client-table owner orders)
- (make-myname-table book date-format)))
+ (list (gnc:make-html-div/markup
+ "client-table"
+ (make-client-table owner orders))
- ;; entries-table
- (gnc:html-table-set-style! table "table"
- 'attribute (list "class" "entries-table")
- 'attribute (list "border" 1)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 4))
+ (gnc:make-html-div/markup
+ "company-table" (make-myname-table book date-format))))
(gnc:html-table-append-row! main-table
- (gnc:make-html-table-cell/size 1 2 table))
+ (gnc:make-html-table-cell/size
+ 1 2 (gnc:make-html-div/markup
+ "entries-table" entry-table)))
+
+ (if (opt-val "Display" "Invoice Notes")
+ (let ((notes (gncInvoiceGetNotes invoice)))
+ (gnc:html-table-append-row! main-table
+ (gnc:make-html-table-cell/size
+ 1 2 (gnc:make-html-div/markup
+ "invoice-notes"
+ (multiline-to-html-text notes))))))
- (gnc:html-document-add-object! document main-table))
-
- (make-break! document)
- (make-break! document)
-
- (if (opt-val "Display" "Invoice Notes")
- (let ((notes (gncInvoiceGetNotes invoice)))
- (gnc:html-document-add-object! document
- (multiline-to-html-text notes))))
-
- (make-break! document)
-
- (gnc:html-document-add-object! document
- (multiline-to-html-text
- (opt-val "Display" "Extra Notes")))))
+ (gnc:html-table-append-row! main-table
+ (gnc:make-html-table-cell/size
+ 1 2 (gnc:make-html-div/markup
+ "invoice-notes"
+ (multiline-to-html-text
+ (opt-val "Display" "Extra Notes")))))
+
+ (gnc:html-document-add-object! document (gnc:make-html-div/markup
+ "main-table" main-table)))))
document))
commit 996b94b1efad7e2388fd848321e80695ec5fd9aa
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jun 4 20:54:15 2018 +0800
[invoice] move invoice-details-table to its own function
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 9cab23a..8bce6aa 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -453,6 +453,66 @@
(loop (cdr list-of-substrings)
(cons* (gnc:html-markup-br) (car list-of-substrings) result)))))
+(define (make-invoice-details-table invoice billing-id? billing-terms? job?)
+ (let* ((invoice-details-table (gnc:make-html-table))
+ (book (gncInvoiceGetBook invoice))
+ (date-format (gnc:options-fancy-date book))
+ (jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
+ (jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice)))))
+
+ (gnc:html-table-set-style! invoice-details-table "table"
+ 'attribute (list "class" "date-table")
+ 'attribute (list "align" "right")
+ 'attribute (list "cellspacing" 0)
+ 'attribute (list "cellpadding" 1))
+
+ (if (gncInvoiceIsPosted invoice)
+ (let ((post-date (gncInvoiceGetDatePosted invoice))
+ (due-date (gncInvoiceGetDateDue invoice)))
+ (make-date-row! invoice-details-table (_ "Date") post-date date-format)
+ (make-date-row! invoice-details-table (_ "Due Date") due-date date-format))
+ (gnc:html-table-append-row! invoice-details-table
+ (gnc:make-html-text
+ (_ "Invoice in progress..."))))
+
+ (if billing-id?
+ (let ((billing-id (gncInvoiceGetBillingID invoice)))
+ (if (and billing-id (not (string-null? billing-id)))
+ (begin
+ (gnc:html-table-append-row! invoice-details-table
+ (list
+ (_ "Reference")
+ billing-id))
+ (gnc:html-table-append-row! invoice-details-table '())))))
+
+ (if billing-terms?
+ (let* ((term (gncInvoiceGetTerms invoice))
+ (terms (gncBillTermGetDescription term)))
+ (if (and terms (not (string-null? terms)))
+ (begin
+ (gnc:html-table-append-row! invoice-details-table
+ (list
+ (_ "Terms")
+ terms))
+ (gnc:html-table-append-row! invoice-details-table '())))))
+
+ ;; Add job number and name to invoice if requested and if it exists
+ (if (and job?
+ (not (string-null? jobnumber)))
+ (begin
+ (gnc:html-table-append-row! invoice-details-table
+ (list
+ (_ "Job number")
+ jobnumber))
+ (gnc:html-table-append-row! invoice-details-table '())
+ (gnc:html-table-append-row! invoice-details-table
+ (list
+ (_ "Job name")
+ jobname))
+ (gnc:html-table-append-row! invoice-details-table '())
+ (gnc:html-table-append-row! invoice-details-table '())))
+ invoice-details-table))
+
(define (make-client-table owner orders)
(let ((table (gnc:make-html-table)))
(gnc:html-table-set-style! table "table"
@@ -489,17 +549,6 @@
(strftime date-format
(localtime date)))))
-(define (make-date-table)
- (let ((table (gnc:make-html-table)))
- (gnc:html-table-set-style! table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellpadding" 0))
-
- (gnc:html-table-set-last-row-style! table "td"
- 'attribute (list "valign" "top"))
-
- table))
-
(define (make-myname-table book date-format)
(let* ((table (gnc:make-html-table))
(name (gnc:company-info book gnc:*company-name*))
@@ -539,8 +588,10 @@
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
(references? (opt-val "Display" "References"))
(job? (opt-val "Display" "Job Details"))
- (jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
- (jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
+ (billing-id? (opt-val "Display" "Billing ID"))
+ (billing-terms? (opt-val "Display" "Billing Terms"))
+ (book (gncInvoiceGetBook invoice))
+ (date-format (gnc:options-fancy-date book))
(custom-title (opt-val gnc:pagename-general "Custom Title")))
(if (null? invoice)
@@ -550,7 +601,6 @@
(_ "No valid invoice selected. Click on the Options button and select the invoice to use.")))
(let* ((book (gncInvoiceGetBook invoice))
- (date-format (gnc:options-fancy-date book))
(owner (gncInvoiceGetOwner invoice))
(type (gncInvoiceGetType invoice))
(orders (if references? (delete-duplicates (map gncEntryGetOrder (gncInvoiceGetEntries invoice))) '()))
@@ -576,76 +626,29 @@
(gnc:html-document-set-style-text! document invoice-css)
- (gnc:html-table-set-style! table "table"
- 'attribute (list "border" 1)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 4))
+ (let ((main-table (gnc:make-html-table)))
- (gnc:html-document-add-object! document
- (make-myname-table book date-format))
-
- (if (gncInvoiceIsPosted invoice)
- (let ((date-table (make-date-table))
- (post-date (gncInvoiceGetDatePosted invoice))
- (due-date (gncInvoiceGetDateDue invoice)))
- (make-date-row! date-table (string-append title " " (_ "Date")) post-date date-format)
- (make-date-row! date-table (_ "Due Date") due-date date-format)
- (gnc:html-document-add-object! document date-table))
- (gnc:html-document-add-object! document
- (gnc:make-html-text
- (_ "Invoice in progress..."))))
+ (gnc:html-table-append-row! main-table
+ (list "BLABLA"
+ (make-invoice-details-table
+ invoice billing-id?
+ billing-terms? job?)))
- (make-break! document)
- (make-break! document)
+ (gnc:html-table-append-row! main-table
+ (list (make-client-table owner orders)
+ (make-myname-table book date-format)))
- (gnc:html-document-add-object! document
- (make-client-table owner orders))
+ ;; entries-table
+ (gnc:html-table-set-style! table "table"
+ 'attribute (list "class" "entries-table")
+ 'attribute (list "border" 1)
+ 'attribute (list "cellspacing" 0)
+ 'attribute (list "cellpadding" 4))
- (make-break! document)
- (make-break! document)
+ (gnc:html-table-append-row! main-table
+ (gnc:make-html-table-cell/size 1 2 table))
- (if (opt-val "Display" "Billing ID")
- (let ((billing-id (gncInvoiceGetBillingID invoice)))
- (if (and billing-id (not (string-null? billing-id)))
- (begin
- (gnc:html-document-add-object! document
- (multiline-to-html-text
- (string-append
- (_ "Reference") ": "
- billing-id)))
- (make-break! document)))))
-
- (if (opt-val "Display" "Billing Terms")
- (let* ((term (gncInvoiceGetTerms invoice))
- (terms (gncBillTermGetDescription term)))
- (if (and terms (not (string-null? terms)))
- (begin
- (gnc:html-document-add-object! document
- (multiline-to-html-text
- (string-append
- (_ "Terms") ": "
- terms)))
- (make-break! document)))))
-
- ;; Add job number and name to invoice if requested and if it exists
- (if (and job?
- (not (string-null? jobnumber)))
- (begin
- (gnc:html-document-add-object! document
- (multiline-to-html-text
- (string-append
- (_ "Job number") ": "
- jobnumber)))
- (make-break! document)
- (gnc:html-document-add-object! document
- (multiline-to-html-text
- (string-append
- (_ "Job name") ": "
- jobname)))
- (make-break! document)
- (make-break! document)))
-
- (gnc:html-document-add-object! document table)
+ (gnc:html-document-add-object! document main-table))
(make-break! document)
(make-break! document)
commit ba000f71bf9a81c6b234543a02c31fcc972e3d81
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jun 4 13:58:00 2018 +0800
[invoice] enable CSS class
This commit will enables "class" attribute in the various html-table
objects. The CSS string can be specified, eg.
.entries-table tr, .entries-table td { etc }
.date-table tr { etc }
to provide styling etc.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 7463957..9cab23a 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -35,6 +35,9 @@
(define (addif pred . data) (if pred data '()))
+(define base-css ".align-right { float: right; text-align: right }
+.entries-table > table { width: 100% }")
+
(define (date-col columns-used)
(vector-ref columns-used 0))
(define (description-col columns-used)
@@ -571,6 +574,8 @@
(gnc:html-document-set-title! document (format #f (_"~a #~a") title
(gncInvoiceGetID invoice)))
+ (gnc:html-document-set-style-text! document invoice-css)
+
(gnc:html-table-set-style! table "table"
'attribute (list "border" 1)
'attribute (list "cellspacing" 0)
commit 0198a8b831135360fab6040c526b4339e0349ac3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 3 15:27:56 2018 +0800
[invoice] convert string-expand to sanitize html strings.
string-expand was converting #\newline to <br/>. convert it to
generate a gnc:make-html-text object with substrings and
gnc:html-markup-br tags.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 511ccaa..7463957 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -439,16 +439,16 @@
#t)
table)))
-(define (string-expand string character replace-string)
- (with-output-to-string
- (lambda ()
- (string-for-each
- (lambda (c)
- (display
- (if (eqv? c character)
- replace-string
- c)))
- string))))
+(define (multiline-to-html-text str)
+;; simple function - splits string containing #\newline into
+;; substrings, and convert to a gnc:make-html-text construct which
+;; adds gnc:html-markup-br after each substring.
+ (let loop ((list-of-substrings (string-split str #\newline))
+ (result '()))
+ (if (null? list-of-substrings)
+ (apply gnc:make-html-text (if (null? result) '() (reverse (cdr result))))
+ (loop (cdr list-of-substrings)
+ (cons* (gnc:html-markup-br) (car list-of-substrings) result)))))
(define (make-client-table owner orders)
(let ((table (gnc:make-html-table)))
@@ -459,7 +459,7 @@
(gnc:html-table-append-row! table
(list
- (string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
+ (multiline-to-html-text (gnc:owner-get-name-and-address-dep owner))))
(gnc:html-table-append-row! table
(list
@@ -483,9 +483,8 @@
(gnc:html-table-append-row! table
(list
(string-append label ": ")
- (string-expand (strftime date-format
- (localtime date))
- #\space " "))))
+ (strftime date-format
+ (localtime date)))))
(define (make-date-table)
(let ((table (gnc:make-html-table)))
@@ -512,8 +511,8 @@
(gnc:html-table-append-row! table (list (or name "")))
- (gnc:html-table-append-row! table (list (string-expand (or addy "")
- #\newline "<br/>")))
+ (gnc:html-table-append-row! table (list (multiline-to-html-text (or addy ""))))
+
(gnc:html-table-append-row! table (list (qof-print-date (current-time))))
table))
@@ -530,8 +529,7 @@
(define (title-string title custom-title)
(if (not (string-null? custom-title))
- (string-expand custom-title
- #\space " ")
+ custom-title
title))
(let* ((document (gnc:make-html-document))
@@ -606,10 +604,10 @@
(if (and billing-id (not (string-null? billing-id)))
(begin
(gnc:html-document-add-object! document
- (gnc:make-html-text
+ (multiline-to-html-text
(string-append
(_ "Reference") ": "
- (string-expand billing-id #\newline "<br/>"))))
+ billing-id)))
(make-break! document)))))
(if (opt-val "Display" "Billing Terms")
@@ -618,10 +616,10 @@
(if (and terms (not (string-null? terms)))
(begin
(gnc:html-document-add-object! document
- (gnc:make-html-text
+ (multiline-to-html-text
(string-append
(_ "Terms") ": "
- (string-expand terms #\newline "<br/>"))))
+ terms)))
(make-break! document)))))
;; Add job number and name to invoice if requested and if it exists
@@ -629,16 +627,16 @@
(not (string-null? jobnumber)))
(begin
(gnc:html-document-add-object! document
- (gnc:make-html-text
+ (multiline-to-html-text
(string-append
(_ "Job number") ": "
- (string-expand jobnumber #\newline "<br/>"))))
+ jobnumber)))
(make-break! document)
(gnc:html-document-add-object! document
- (gnc:make-html-text
+ (multiline-to-html-text
(string-append
(_ "Job name") ": "
- (string-expand jobname #\newline "<br/>"))))
+ jobname)))
(make-break! document)
(make-break! document)))
@@ -650,16 +648,13 @@
(if (opt-val "Display" "Invoice Notes")
(let ((notes (gncInvoiceGetNotes invoice)))
(gnc:html-document-add-object! document
- (gnc:make-html-text
- (string-expand notes #\newline "<br/>")))))
+ (multiline-to-html-text notes))))
(make-break! document)
(gnc:html-document-add-object! document
- (gnc:make-html-text
- (gnc:html-markup-br)
- (string-expand (opt-val "Display" "Extra Notes") #\newline "<br/>")
- (gnc:html-markup-br)))))
+ (multiline-to-html-text
+ (opt-val "Display" "Extra Notes")))))
document))
commit 12253f3c38a6e81167b4f7f03d71cca2841efca6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 3 14:14:32 2018 +0800
[invoice] simplify num-columns-required to use SRFI-1
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 336472b..511ccaa 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -57,11 +57,11 @@
(define columns-used-size 9)
(define (num-columns-required columns-used)
- (do ((i 0 (1+ i))
- (col-req 0 col-req))
- ((>= i columns-used-size) col-req)
- (if (vector-ref columns-used i)
- (set! col-req (1+ col-req)))))
+ ;; count number of columns where (vector-ref columns-used col) is #t
+ (count identity
+ (map (lambda (col)
+ (vector-ref columns-used col))
+ (iota columns-used-size))))
(define (build-column-used options)
(define (opt-val section name)
commit 30f14191e604b7364ed89689da22c48f3e565034
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 3 14:53:35 2018 +0800
[invoice] *untabify*
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index ddd6940..336472b 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -119,7 +119,7 @@
(define (add-entry-row table currency entry column-vector row-style cust-doc? credit-note?)
(let* ((entry-value (gnc:make-gnc-monetary currency
(gncEntryGetDocValue entry #t cust-doc? credit-note?)))
- (entry-tax-value (gnc:make-gnc-monetary currency
+ (entry-tax-value (gnc:make-gnc-monetary currency
(gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
(gnc:html-table-append-row/markup!
@@ -184,7 +184,7 @@
(gnc:register-inv-option
(gnc:make-invoice-option gnc:pagename-general gnc:optname-invoice-number "x" ""
- (lambda () '()) #f))
+ (lambda () '()) #f))
(gnc:register-inv-option
(gnc:make-string-option
@@ -293,14 +293,14 @@
(gnc:lookup-option options section name)))
(let ((show-payments (opt-val "Display" "Payments"))
- (display-all-taxes (opt-val "Display" "Individual Taxes"))
- (lot (gncInvoiceGetPostedLot invoice))
- (txn (gncInvoiceGetPostedTxn invoice))
+ (display-all-taxes (opt-val "Display" "Individual Taxes"))
+ (lot (gncInvoiceGetPostedLot invoice))
+ (txn (gncInvoiceGetPostedTxn invoice))
(job? (opt-val "Display" "Job Details"))
- (currency (gncInvoiceGetCurrency invoice))
+ (currency (gncInvoiceGetCurrency invoice))
(jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
- (reverse-payments? (not (gncInvoiceAmountPositive invoice))))
+ (reverse-payments? (not (gncInvoiceAmountPositive invoice))))
(define (colspan monetary used-columns)
(or (value-col used-columns)
@@ -309,13 +309,13 @@
(define (display-subtotal monetary used-columns)
(if (value-col used-columns)
- monetary
- (let ((amt (gnc:gnc-monetary-amount monetary)))
- (if amt
- (if (negative? amt)
- (gnc:monetary-neg monetary)
- monetary)
- monetary))))
+ monetary
+ (let ((amt (gnc:gnc-monetary-amount monetary)))
+ (if amt
+ (if (negative? amt)
+ (gnc:monetary-neg monetary)
+ monetary)
+ monetary))))
(define (add-subtotal-row table used-columns
subtotal subtotal-style subtotal-label)
@@ -332,19 +332,19 @@
(define (add-payment-row table used-columns split total-collector reverse-payments?)
(let* ((t (xaccSplitGetParent split))
- (currency (xaccTransGetCurrency t))
- ;; Depending on the document type, the payments may need to be sign-reversed
- (amt (gnc:make-gnc-monetary currency
+ (currency (xaccTransGetCurrency t))
+ ;; Depending on the document type, the payments may need to be sign-reversed
+ (amt (gnc:make-gnc-monetary currency
(if reverse-payments?
(- (xaccSplitGetValue split))
(xaccSplitGetValue split)))))
- (total-collector 'add
+ (total-collector 'add
(gnc:gnc-monetary-commodity amt)
(gnc:gnc-monetary-amount amt))
- (gnc:html-table-append-row/markup!
- table "grand-total"
+ (gnc:html-table-append-row/markup!
+ table "grand-total"
(append
(addif (date-col used-columns)
(qof-print-date (xaccTransGetDate t)))
@@ -358,10 +358,10 @@
(display-subtotal amt used-columns)))))))
(define (do-rows-with-subtotals entries
- table
- used-columns
- width
- odd-row?)
+ table
+ used-columns
+ width
+ odd-row?)
(if (null? entries)
;; all entries done, add subtotals
@@ -388,28 +388,28 @@
(total-collector 'add currency (gncInvoiceGetTotal invoice))
- (if (and show-payments (not (null? lot)))
- (let ((splits (sort-list!
- (gnc-lot-get-split-list lot)
- (lambda (s1 s2)
- (let ((t1 (xaccSplitGetParent s1))
- (t2 (xaccSplitGetParent s2)))
- (< (xaccTransOrder t1 t2) 0))))))
- (for-each
- (lambda (split)
- (if (not (equal? (xaccSplitGetParent split) txn))
- (add-payment-row table used-columns
- split total-collector
- reverse-payments?)))
- splits)))
-
- (add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
- "grand-total" (_ "Amount Due")))
-
- ;;
- ;; End of BEGIN -- now here's the code to handle all the entries!
- ;;
- (begin
+ (if (and show-payments (not (null? lot)))
+ (let ((splits (sort-list!
+ (gnc-lot-get-split-list lot)
+ (lambda (s1 s2)
+ (let ((t1 (xaccSplitGetParent s1))
+ (t2 (xaccSplitGetParent s2)))
+ (< (xaccTransOrder t1 t2) 0))))))
+ (for-each
+ (lambda (split)
+ (if (not (equal? (xaccSplitGetParent split) txn))
+ (add-payment-row table used-columns
+ split total-collector
+ reverse-payments?)))
+ splits)))
+
+ (add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
+ "grand-total" (_ "Amount Due")))
+
+ ;;
+ ;; End of BEGIN -- now here's the code to handle all the entries!
+ ;;
+ (begin
(add-entry-row table
currency
@@ -418,25 +418,25 @@
(if odd-row? "normal-row" "alternate-row")
cust-doc? credit-note?)
- (do-rows-with-subtotals (cdr entries)
- table
- used-columns
- width
- (not odd-row?)))))
+ (do-rows-with-subtotals (cdr entries)
+ table
+ used-columns
+ width
+ (not odd-row?)))))
(let* ((table (gnc:make-html-table))
- (used-columns (build-column-used options))
- (width (num-columns-required used-columns))
- (entries (gncInvoiceGetEntries invoice)))
+ (used-columns (build-column-used options))
+ (width (num-columns-required used-columns))
+ (entries (gncInvoiceGetEntries invoice)))
(gnc:html-table-set-col-headers! table
(make-heading-list used-columns))
(do-rows-with-subtotals entries
- table
- used-columns
- width
- #t)
+ table
+ used-columns
+ width
+ #t)
table)))
(define (string-expand string character replace-string)
@@ -469,8 +469,8 @@
(for-each
(lambda (order)
(let ((reference (gncOrderGetReference order)))
- (if (and reference (not (string-null? reference)))
- (gnc:html-table-append-row! table
+ (if (and reference (not (string-null? reference)))
+ (gnc:html-table-append-row! table
(list
(string-append (_ "REF") ": " reference))))))
orders)
@@ -500,8 +500,8 @@
(define (make-myname-table book date-format)
(let* ((table (gnc:make-html-table))
- (name (gnc:company-info book gnc:*company-name*))
- (addy (gnc:company-info book gnc:*company-addy*)))
+ (name (gnc:company-info book gnc:*company-name*))
+ (addy (gnc:company-info book gnc:*company-addy*)))
(gnc:html-table-set-style! table "table"
'attribute (list "border" 0)
@@ -530,17 +530,17 @@
(define (title-string title custom-title)
(if (not (string-null? custom-title))
- (string-expand custom-title
- #\space " ")
- title))
+ (string-expand custom-title
+ #\space " ")
+ title))
(let* ((document (gnc:make-html-document))
- (invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
- (references? (opt-val "Display" "References"))
+ (invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
+ (references? (opt-val "Display" "References"))
(job? (opt-val "Display" "Job Details"))
(jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
- (custom-title (opt-val gnc:pagename-general "Custom Title")))
+ (custom-title (opt-val gnc:pagename-general "Custom Title")))
(if (null? invoice)
@@ -569,7 +569,7 @@
(table (make-entry-table invoice
(gnc:report-options report-obj)
cust-doc? credit-note?)))
-
+
(gnc:html-document-set-title! document (format #f (_"~a #~a") title
(gncInvoiceGetID invoice)))
@@ -641,7 +641,7 @@
(string-expand jobname #\newline "<br/>"))))
(make-break! document)
(make-break! document)))
-
+
(gnc:html-document-add-object! document table)
(make-break! document)
commit 0f505d13890dea3f6555d8b51e71e263d61ce56f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 3 14:15:03 2018 +0800
[invoice] entry-values are unused. remove and simplify.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index a3eeb49..ddd6940 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -409,17 +409,16 @@
;;
;; End of BEGIN -- now here's the code to handle all the entries!
;;
- (let* ((current (car entries))
- (current-row-style (if odd-row? "normal-row" "alternate-row"))
- (rest (cdr entries))
- (entry-values (add-entry-row table
- currency
- current
- used-columns
- current-row-style
- cust-doc? credit-note?)))
-
- (do-rows-with-subtotals rest
+ (begin
+
+ (add-entry-row table
+ currency
+ (car entries)
+ used-columns
+ (if odd-row? "normal-row" "alternate-row")
+ cust-doc? credit-note?)
+
+ (do-rows-with-subtotals (cdr entries)
table
used-columns
width
commit 1afacb97ba7b6305fd19228b7a3369e62007611f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 2 22:35:09 2018 +0800
[invoice] refactor gncOrder handling
Previously the function addorder was being passed as an argument to
add gncOrder references to a list, for later displaying in
report. This commit will simplify it - instead of passing a function
to make-entry-table, the report will query invoice orders directly
when needed.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 35f5b9d..a3eeb49 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -287,7 +287,7 @@
gnc:*report-options*)
-(define (make-entry-table invoice options add-order cust-doc? credit-note?)
+(define (make-entry-table invoice options cust-doc? credit-note?)
(define (opt-val section name)
(gnc:option-value
(gnc:lookup-option options section name)))
@@ -419,9 +419,6 @@
current-row-style
cust-doc? credit-note?)))
- (let ((order (gncEntryGetOrder current)))
- (if (not (null? order)) (add-order order)))
-
(do-rows-with-subtotals rest
table
used-columns
@@ -539,7 +536,6 @@
title))
(let* ((document (gnc:make-html-document))
- (orders '())
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
(references? (opt-val "Display" "References"))
(job? (opt-val "Display" "Job Details"))
@@ -547,10 +543,6 @@
(jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(custom-title (opt-val gnc:pagename-general "Custom Title")))
- (define (add-order o)
- (if (and references? (not (member o orders)))
- (addto! orders o)))
-
(if (null? invoice)
(gnc:html-document-add-object! document
@@ -565,7 +557,6 @@
(cust-doc? (memq type (list GNC-INVOICE-CUST-INVOICE GNC-INVOICE-CUST-CREDIT-NOTE)))
(credit-note? (memq type (list GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE
GNC-INVOICE-EMPL-CREDIT-NOTE)))
-
(default-title (case type
((GNC-INVOICE-VEND-INVOICE)
(_ "Bill"))
@@ -578,7 +569,7 @@
(title (title-string default-title custom-title))
(table (make-entry-table invoice
(gnc:report-options report-obj)
- add-order cust-doc? credit-note?)))
+ cust-doc? credit-note?)))
(gnc:html-document-set-title! document (format #f (_"~a #~a") title
(gncInvoiceGetID invoice)))
@@ -607,6 +598,7 @@
(gnc:html-document-add-object! document
(make-client-table owner orders))
+
(make-break! document)
(make-break! document)
commit cf3ccb9f1e75d9ad4c95e3a44e448892cc0d4c91
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 2 22:04:55 2018 +0800
[invoice] more mucho refactoring, no functional change.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index f75019d..35f5b9d 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -57,11 +57,11 @@
(define columns-used-size 9)
(define (num-columns-required columns-used)
- (do ((i 0 (+ i 1))
+ (do ((i 0 (1+ i))
(col-req 0 col-req))
((>= i columns-used-size) col-req)
(if (vector-ref columns-used i)
- (set! col-req (+ col-req 1)))))
+ (set! col-req (1+ col-req)))))
(define (build-column-used options)
(define (opt-val section name)
@@ -322,14 +322,13 @@
(let ((subtotal-mon (gnc:make-gnc-monetary currency subtotal)))
(gnc:html-table-append-row/markup!
- table
- subtotal-style
- (cons (gnc:make-html-table-cell/markup
+ table subtotal-style
+ (list (gnc:make-html-table-cell/markup
"total-label-cell" subtotal-label)
- (list (gnc:make-html-table-cell/size/markup
- 1 (colspan subtotal-mon used-columns)
- "total-number-cell"
- (display-subtotal subtotal-mon used-columns)))))))
+ (gnc:make-html-table-cell/size/markup
+ 1 (colspan subtotal-mon used-columns)
+ "total-number-cell"
+ (display-subtotal subtotal-mon used-columns))))))
(define (add-payment-row table used-columns split total-collector reverse-payments?)
(let* ((t (xaccSplitGetParent split))
@@ -338,29 +337,25 @@
(amt (gnc:make-gnc-monetary currency
(if reverse-payments?
(- (xaccSplitGetValue split))
- (xaccSplitGetValue split))))
- (payment-style "grand-total")
- (row '()))
+ (xaccSplitGetValue split)))))
(total-collector 'add
(gnc:gnc-monetary-commodity amt)
(gnc:gnc-monetary-amount amt))
- (if (date-col used-columns)
- (addto! row
- (qof-print-date (xaccTransGetDate t))))
+ (gnc:html-table-append-row/markup!
+ table "grand-total"
+ (append
+ (addif (date-col used-columns)
+ (qof-print-date (xaccTransGetDate t)))
- (if (description-col used-columns)
- (addto! row (_ "Payment, thank you")))
+ (addif (description-col used-columns)
+ (_ "Payment, thank you"))
- (gnc:html-table-append-row/markup!
- table
- payment-style
- (append (reverse row)
- (list (gnc:make-html-table-cell/size/markup
- 1 (colspan currency used-columns)
- "total-number-cell"
- (display-subtotal amt used-columns)))))))
+ (list (gnc:make-html-table-cell/size/markup
+ 1 (colspan currency used-columns)
+ "total-number-cell"
+ (display-subtotal amt used-columns)))))))
(define (do-rows-with-subtotals entries
table
@@ -417,7 +412,6 @@
(let* ((current (car entries))
(current-row-style (if odd-row? "normal-row" "alternate-row"))
(rest (cdr entries))
- (next (and (pair? rest) (car rest)))
(entry-values (add-entry-row table
currency
current
@@ -439,9 +433,8 @@
(width (num-columns-required used-columns))
(entries (gncInvoiceGetEntries invoice)))
- (gnc:html-table-set-col-headers!
- table
- (make-heading-list used-columns))
+ (gnc:html-table-set-col-headers! table
+ (make-heading-list used-columns))
(do-rows-with-subtotals entries
table
@@ -473,11 +466,13 @@
(string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
(gnc:html-table-append-row! table
- (list "<br/>"))
+ (list
+ (gnc:make-html-text
+ (gnc:html-markup-br))))
(for-each
(lambda (order)
- (let* ((reference (gncOrderGetReference order)))
+ (let ((reference (gncOrderGetReference order)))
(if (and reference (not (string-null? reference)))
(gnc:html-table-append-row! table
(list
@@ -544,19 +539,13 @@
title))
(let* ((document (gnc:make-html-document))
- (table '())
(orders '())
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
- (owner '())
(references? (opt-val "Display" "References"))
- (default-title (_ "Invoice"))
(job? (opt-val "Display" "Job Details"))
(jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
- (custom-title (opt-val gnc:pagename-general "Custom Title"))
- (title "")
- (cust-doc? #f)
- (credit-note? #f))
+ (custom-title (opt-val gnc:pagename-general "Custom Title")))
(define (add-order o)
(if (and references? (not (member o orders)))
@@ -571,119 +560,96 @@
(let* ((book (gncInvoiceGetBook invoice))
(date-format (gnc:options-fancy-date book))
(owner (gncInvoiceGetOwner invoice))
- (type (gncInvoiceGetType invoice)))
-
- (cond
- ((eqv? type GNC-INVOICE-CUST-INVOICE)
- (set! cust-doc? #t))
- ((eqv? type GNC-INVOICE-VEND-INVOICE)
- (set! default-title (_ "Bill")))
- ((eqv? type GNC-INVOICE-EMPL-INVOICE)
- (set! default-title (_ "Expense Voucher")))
- ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
- (begin
- (set! cust-doc? #t)
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
- (begin
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
- (begin
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note")))))
-
- (set! title (title-string default-title custom-title))
+ (type (gncInvoiceGetType invoice))
+ (orders (if references? (delete-duplicates (map gncEntryGetOrder (gncInvoiceGetEntries invoice))) '()))
+ (cust-doc? (memq type (list GNC-INVOICE-CUST-INVOICE GNC-INVOICE-CUST-CREDIT-NOTE)))
+ (credit-note? (memq type (list GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE
+ GNC-INVOICE-EMPL-CREDIT-NOTE)))
+
+ (default-title (case type
+ ((GNC-INVOICE-VEND-INVOICE)
+ (_ "Bill"))
+ ((GNC-INVOICE-EMPL-INVOICE)
+ (_ "Expense Voucher"))
+ ((GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE GNC-INVOICE-EMPL-CREDIT-NOTE)
+ (_ "Credit Note"))
+ (else
+ (_ "Invoice"))))
+ (title (title-string default-title custom-title))
+ (table (make-entry-table invoice
+ (gnc:report-options report-obj)
+ add-order cust-doc? credit-note?)))
(gnc:html-document-set-title! document (format #f (_"~a #~a") title
(gncInvoiceGetID invoice)))
- (set! table (make-entry-table invoice
- (gnc:report-options report-obj)
- add-order cust-doc? credit-note?))
-
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 1)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 4))
+ (gnc:html-table-set-style! table "table"
+ 'attribute (list "border" 1)
+ 'attribute (list "cellspacing" 0)
+ 'attribute (list "cellpadding" 4))
- (gnc:html-document-add-object!
- document
- (make-myname-table book date-format))
+ (gnc:html-document-add-object! document
+ (make-myname-table book date-format))
(if (gncInvoiceIsPosted invoice)
- (let ((date-table #f)
+ (let ((date-table (make-date-table))
(post-date (gncInvoiceGetDatePosted invoice))
(due-date (gncInvoiceGetDateDue invoice)))
- (set! date-table (make-date-table))
(make-date-row! date-table (string-append title " " (_ "Date")) post-date date-format)
(make-date-row! date-table (_ "Due Date") due-date date-format)
(gnc:html-document-add-object! document date-table))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (_ "Invoice in progress..."))))
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (_ "Invoice in progress..."))))
(make-break! document)
(make-break! document)
- (gnc:html-document-add-object!
- document
- (make-client-table owner orders))
-
+ (gnc:html-document-add-object! document
+ (make-client-table owner orders))
(make-break! document)
(make-break! document)
(if (opt-val "Display" "Billing ID")
(let ((billing-id (gncInvoiceGetBillingID invoice)))
- (if (and billing-id (> (string-length billing-id) 0))
+ (if (and billing-id (not (string-null? billing-id)))
(begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Reference") ": "
- (string-expand billing-id #\newline "<br/>"))))
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (string-append
+ (_ "Reference") ": "
+ (string-expand billing-id #\newline "<br/>"))))
(make-break! document)))))
(if (opt-val "Display" "Billing Terms")
(let* ((term (gncInvoiceGetTerms invoice))
(terms (gncBillTermGetDescription term)))
- (if (and terms (> (string-length terms) 0))
+ (if (and terms (not (string-null? terms)))
(begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Terms") ": "
- (string-expand terms #\newline "<br/>"))))
- (make-break! document))
- )))
-
- ;(make-break! document)
-
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (string-append
+ (_ "Terms") ": "
+ (string-expand terms #\newline "<br/>"))))
+ (make-break! document)))))
+
;; Add job number and name to invoice if requested and if it exists
- (if job?
- (if (not(string=? jobnumber "" ))
- (begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Job number") ": "
- (string-expand jobnumber #\newline "<br/>"))))
- (make-break! document)
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Job name") ": "
- (string-expand jobname #\newline "<br/>"))))
- (make-break! document)
- (make-break! document)
- )))
+ (if (and job?
+ (not (string-null? jobnumber)))
+ (begin
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (string-append
+ (_ "Job number") ": "
+ (string-expand jobnumber #\newline "<br/>"))))
+ (make-break! document)
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (string-append
+ (_ "Job name") ": "
+ (string-expand jobname #\newline "<br/>"))))
+ (make-break! document)
+ (make-break! document)))
(gnc:html-document-add-object! document table)
@@ -692,19 +658,17 @@
(if (opt-val "Display" "Invoice Notes")
(let ((notes (gncInvoiceGetNotes invoice)))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-expand notes #\newline "<br/>")))))
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (string-expand notes #\newline "<br/>")))))
(make-break! document)
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (gnc:html-markup-br)
- (string-expand (opt-val "Display" "Extra Notes") #\newline "<br/>")
- (gnc:html-markup-br)))))
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (gnc:html-markup-br)
+ (string-expand (opt-val "Display" "Extra Notes") #\newline "<br/>")
+ (gnc:html-markup-br)))))
document))
commit 5467c47598a5e09054e1e9bff99b2014a9befd6d
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 2 21:02:00 2018 +0800
[invoice] mucho refactoring. no functional change.
Refactor to use SRFI constructs, simplify logic, add comments. No
functional change.
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index d846247..f75019d 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -33,6 +33,8 @@
(use-modules (gnucash report standard-reports))
(use-modules (gnucash report business-reports))
+(define (addif pred . data) (if pred data '()))
+
(define (date-col columns-used)
(vector-ref columns-used 0))
(define (description-col columns-used)
@@ -65,13 +67,14 @@
(define (opt-val section name)
(gnc:option-value
(gnc:lookup-option options section name)))
+
(define (make-set-col col-vector)
(let ((col 0))
(lambda (used? index)
(if used?
(begin
(vector-set! col-vector index col)
- (set! col (+ col 1)))
+ (set! col (1+ col)))
(vector-set! col-vector index #f)))))
(let* ((col-vector (make-vector columns-used-size #f))
@@ -88,28 +91,25 @@
col-vector))
(define (make-heading-list column-vector)
-
- (let ((heading-list '()))
- (if (date-col column-vector)
- (addto! heading-list (_ "Date")))
- (if (description-col column-vector)
- (addto! heading-list (_ "Description")))
- (if (action-col column-vector)
- (addto! heading-list (_ "Charge Type")))
- (if (quantity-col column-vector)
- (addto! heading-list (_ "Quantity")))
- (if (price-col column-vector)
- (addto! heading-list (_ "Unit Price")))
- (if (discount-col column-vector)
- (addto! heading-list (_ "Discount")))
- (if (tax-col column-vector)
- (addto! heading-list (_ "Taxable")))
- (if (taxvalue-col column-vector)
- (addto! heading-list (_ "Tax Amount")))
- (if (value-col column-vector)
- (addto! heading-list (_ "Total")))
- (reverse heading-list)))
-
+ (append
+ (addif (date-col column-vector)
+ (_ "Date"))
+ (addif (description-col column-vector)
+ (_ "Description"))
+ (addif (action-col column-vector)
+ (_ "Charge Type"))
+ (addif (quantity-col column-vector)
+ (_ "Quantity"))
+ (addif (price-col column-vector)
+ (_ "Unit Price"))
+ (addif (discount-col column-vector)
+ (_ "Discount"))
+ (addif (tax-col column-vector)
+ (_ "Taxable"))
+ (addif (taxvalue-col column-vector)
+ (_ "Tax Amount"))
+ (addif (value-col column-vector)
+ (_ "Total"))))
(define (monetary-or-percent numeric currency entry-type)
(if (gnc:entry-type-percent-p entry-type)
@@ -117,74 +117,61 @@
(gnc:make-gnc-monetary currency numeric)))
(define (add-entry-row table currency entry column-vector row-style cust-doc? credit-note?)
- (let* ((row-contents '())
- (entry-value (gnc:make-gnc-monetary
- currency
- (gncEntryGetDocValue entry #t cust-doc? credit-note?)))
- (entry-tax-value (gnc:make-gnc-monetary
- currency
- (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
-
- (if (date-col column-vector)
- (addto! row-contents
- (qof-print-date (gncEntryGetDate entry))))
-
- (if (description-col column-vector)
- (addto! row-contents
- (gncEntryGetDescription entry)))
-
- (if (action-col column-vector)
- (addto! row-contents
- (gncEntryGetAction entry)))
-
- (if (quantity-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- (gncEntryGetDocQuantity entry credit-note?))))
-
- (if (price-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- (gnc:make-gnc-monetary
- currency (if cust-doc? (gncEntryGetInvPrice entry)
- (gncEntryGetBillPrice entry))))))
-
- (if (discount-col column-vector)
- (addto! row-contents
- (if cust-doc?
- (gnc:make-html-table-cell/markup
- "number-cell"
- (monetary-or-percent (gncEntryGetInvDiscount entry)
- currency
- (gncEntryGetInvDiscountType entry)))
- "")))
-
- (if (tax-col column-vector)
- (addto! row-contents
- (if (if cust-doc?
- (and (gncEntryGetInvTaxable entry)
- (gncEntryGetInvTaxTable entry))
- (and (gncEntryGetBillTaxable entry)
- (gncEntryGetBillTaxTable entry)))
- ;; Translators: This "T" is displayed in the taxable column, if this entry contains tax
- (_ "T") "")))
-
- (if (taxvalue-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- entry-tax-value)))
-
- (if (value-col column-vector)
- (addto! row-contents
- (gnc:make-html-table-cell/markup
- "number-cell"
- entry-value)))
-
- (gnc:html-table-append-row/markup! table row-style
- (reverse row-contents))
+ (let* ((entry-value (gnc:make-gnc-monetary currency
+ (gncEntryGetDocValue entry #t cust-doc? credit-note?)))
+ (entry-tax-value (gnc:make-gnc-monetary currency
+ (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))))
+
+ (gnc:html-table-append-row/markup!
+ table row-style
+ (append
+ (addif (date-col column-vector)
+ (qof-print-date (gncEntryGetDate entry)))
+
+ (addif (description-col column-vector)
+ (gncEntryGetDescription entry))
+
+ (addif (action-col column-vector)
+ (gncEntryGetAction entry))
+
+ (addif (quantity-col column-vector)
+ (gnc:make-html-table-cell/markup "number-cell"
+ (gncEntryGetDocQuantity entry credit-note?)))
+
+ (addif (price-col column-vector)
+ (gnc:make-html-table-cell/markup "number-cell"
+ (gnc:make-gnc-monetary
+ currency (if cust-doc?
+ (gncEntryGetInvPrice entry)
+ (gncEntryGetBillPrice entry)))))
+
+ (addif (discount-col column-vector)
+ (if cust-doc?
+ (gnc:make-html-table-cell/markup
+ "number-cell"
+ (monetary-or-percent (gncEntryGetInvDiscount entry)
+ currency
+ (gncEntryGetInvDiscountType entry)))
+ ""))
+
+ (addif (tax-col column-vector)
+ (if (if cust-doc?
+ (and (gncEntryGetInvTaxable entry)
+ (gncEntryGetInvTaxTable entry))
+ (and (gncEntryGetBillTaxable entry)
+ (gncEntryGetBillTaxTable entry)))
+ ;; Translators: This "T" is displayed in the taxable column, if this entry contains tax
+ (_ "T") ""))
+
+ (addif (taxvalue-col column-vector)
+ (gnc:make-html-table-cell/markup
+ "number-cell"
+ entry-tax-value))
+
+ (addif (value-col column-vector)
+ (gnc:make-html-table-cell/markup
+ "number-cell"
+ entry-value))))
(cons entry-value entry-tax-value)))
@@ -300,7 +287,6 @@
gnc:*report-options*)
-
(define (make-entry-table invoice options add-order cust-doc? credit-note?)
(define (opt-val section name)
(gnc:option-value
@@ -317,17 +303,16 @@
(reverse-payments? (not (gncInvoiceAmountPositive invoice))))
(define (colspan monetary used-columns)
- (cond
- ((value-col used-columns) (value-col used-columns))
- ((taxvalue-col used-columns) (taxvalue-col used-columns))
- (else (price-col used-columns))))
+ (or (value-col used-columns)
+ (taxvalue-col used-columns)
+ (price-col used-columns)))
(define (display-subtotal monetary used-columns)
(if (value-col used-columns)
monetary
(let ((amt (gnc:gnc-monetary-amount monetary)))
(if amt
- (if (gnc-numeric-negative-p amt)
+ (if (negative? amt)
(gnc:monetary-neg monetary)
monetary)
monetary))))
@@ -339,13 +324,12 @@
(gnc:html-table-append-row/markup!
table
subtotal-style
- (append (cons (gnc:make-html-table-cell/markup
- "total-label-cell" subtotal-label)
- '())
- (list (gnc:make-html-table-cell/size/markup
- 1 (colspan subtotal-mon used-columns)
- "total-number-cell"
- (display-subtotal subtotal-mon used-columns)))))))
+ (cons (gnc:make-html-table-cell/markup
+ "total-label-cell" subtotal-label)
+ (list (gnc:make-html-table-cell/size/markup
+ 1 (colspan subtotal-mon used-columns)
+ "total-number-cell"
+ (display-subtotal subtotal-mon used-columns)))))))
(define (add-payment-row table used-columns split total-collector reverse-payments?)
(let* ((t (xaccSplitGetParent split))
@@ -353,7 +337,7 @@
;; Depending on the document type, the payments may need to be sign-reversed
(amt (gnc:make-gnc-monetary currency
(if reverse-payments?
- (gnc-numeric-neg(xaccSplitGetValue split))
+ (- (xaccSplitGetValue split))
(xaccSplitGetValue split))))
(payment-style "grand-total")
(row '()))
@@ -384,23 +368,23 @@
width
odd-row?)
(if (null? entries)
+
+ ;; all entries done, add subtotals
(let ((total-collector (gnc:make-commodity-collector)))
(add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
"grand-total" (_ "Net Price"))
(if display-all-taxes
- (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
- (for-each
- (lambda (parm)
- (let* ((value (cdr parm))
- (acct (car parm))
- (name (xaccAccountGetName acct)))
- (add-subtotal-row table used-columns value
- "grand-total" name)))
- acct-val-list))
-
- ; nope, just show the total tax.
+ (for-each
+ (lambda (parm)
+ (let ((value (cdr parm))
+ (acct (car parm)))
+ (add-subtotal-row table used-columns value
+ "grand-total" (xaccAccountGetName acct))))
+ (gncInvoiceGetTotalTaxList invoice))
+
+ ;; nope, just show the total tax.
(add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
"grand-total" (_ "Tax")))
@@ -408,6 +392,7 @@
"grand-total" (_ "Total Price"))
(total-collector 'add currency (gncInvoiceGetTotal invoice))
+
(if (and show-payments (not (null? lot)))
(let ((splits (sort-list!
(gnc-lot-get-split-list lot)
@@ -432,8 +417,7 @@
(let* ((current (car entries))
(current-row-style (if odd-row? "normal-row" "alternate-row"))
(rest (cdr entries))
- (next (if (null? rest) #f
- (car rest)))
+ (next (and (pair? rest) (car rest)))
(entry-values (add-entry-row table
currency
current
@@ -467,70 +451,60 @@
table)))
(define (string-expand string character replace-string)
- (define (car-line chars)
- (take-while (lambda (c) (not (eqv? c character))) chars))
- (define (cdr-line chars)
- (let ((rest (drop-while (lambda (c) (not (eqv? c character))) chars)))
- (if (null? rest)
- '()
- (cdr rest))))
- (define (line-helper chars)
- (if (null? chars)
- ""
- (let ((first (car-line chars))
- (rest (cdr-line chars)))
- (string-append (list->string first)
- (if (null? rest) "" replace-string)
- (line-helper rest)))))
- (line-helper (string->list string)))
+ (with-output-to-string
+ (lambda ()
+ (string-for-each
+ (lambda (c)
+ (display
+ (if (eqv? c character)
+ replace-string
+ c)))
+ string))))
(define (make-client-table owner orders)
(let ((table (gnc:make-html-table)))
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0))
- (gnc:html-table-append-row!
- table
- (list
- (string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
- (gnc:html-table-append-row!
- table
- (list "<br/>"))
+ (gnc:html-table-set-style! table "table"
+ 'attribute (list "border" 0)
+ 'attribute (list "cellspacing" 0)
+ 'attribute (list "cellpadding" 0))
+
+ (gnc:html-table-append-row! table
+ (list
+ (string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
+
+ (gnc:html-table-append-row! table
+ (list "<br/>"))
+
(for-each
(lambda (order)
(let* ((reference (gncOrderGetReference order)))
- (if (and reference (> (string-length reference) 0))
- (gnc:html-table-append-row!
- table
- (list
- (string-append (_ "REF") ": " reference))))))
+ (if (and reference (not (string-null? reference)))
+ (gnc:html-table-append-row! table
+ (list
+ (string-append (_ "REF") ": " reference))))))
orders)
- (gnc:html-table-set-last-row-style!
- table "td"
- 'attribute (list "valign" "top"))
+
+ (gnc:html-table-set-last-row-style! table "td"
+ 'attribute (list "valign" "top"))
table))
(define (make-date-row! table label date date-format)
- (gnc:html-table-append-row!
- table
- (list
- (string-append label ": ")
- (string-expand (strftime date-format
- (localtime date))
- #\space " ")
- )))
+ (gnc:html-table-append-row! table
+ (list
+ (string-append label ": ")
+ (string-expand (strftime date-format
+ (localtime date))
+ #\space " "))))
(define (make-date-table)
(let ((table (gnc:make-html-table)))
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "cellpadding" 0))
- (gnc:html-table-set-last-row-style!
- table "td"
- 'attribute (list "valign" "top"))
+ (gnc:html-table-set-style! table "table"
+ 'attribute (list "border" 0)
+ 'attribute (list "cellpadding" 0))
+
+ (gnc:html-table-set-last-row-style! table "td"
+ 'attribute (list "valign" "top"))
+
table))
(define (make-myname-table book date-format)
@@ -538,28 +512,25 @@
(name (gnc:company-info book gnc:*company-name*))
(addy (gnc:company-info book gnc:*company-addy*)))
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 0)
- 'attribute (list "align" "right")
- 'attribute (list "valign" "top")
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 0))
- (gnc:html-table-append-row! table (list (if name name "")))
- (gnc:html-table-append-row! table (list (string-expand
- (if addy addy "")
- #\newline "<br/>")))
- (gnc:html-table-append-row! table (list
- (strftime
- date-format
- (gnc-localtime (gnc:get-today)))))
+ (gnc:html-table-set-style! table "table"
+ 'attribute (list "border" 0)
+ 'attribute (list "align" "right")
+ 'attribute (list "valign" "top")
+ 'attribute (list "cellspacing" 0)
+ 'attribute (list "cellpadding" 0))
+
+ (gnc:html-table-append-row! table (list (or name "")))
+
+ (gnc:html-table-append-row! table (list (string-expand (or addy "")
+ #\newline "<br/>")))
+ (gnc:html-table-append-row! table (list (qof-print-date (current-time))))
+
table))
(define (make-break! document)
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (gnc:html-markup-br))))
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (gnc:html-markup-br))))
(define (reg-renderer report-obj)
(define (opt-val section name)
@@ -567,7 +538,7 @@
(gnc:lookup-option (gnc:report-options report-obj) section name)))
(define (title-string title custom-title)
- (if (not (equal? "" custom-title))
+ (if (not (string-null? custom-title))
(string-expand custom-title
#\space " ")
title))
@@ -591,53 +562,56 @@
(if (and references? (not (member o orders)))
(addto! orders o)))
- (if (not (null? invoice))
- (begin
- (set! owner (gncInvoiceGetOwner invoice))
- (let ((type (gncInvoiceGetType invoice)))
- (cond
- ((eqv? type GNC-INVOICE-CUST-INVOICE)
- (set! cust-doc? #t))
- ((eqv? type GNC-INVOICE-VEND-INVOICE)
- (set! default-title (_ "Bill")))
- ((eqv? type GNC-INVOICE-EMPL-INVOICE)
- (set! default-title (_ "Expense Voucher")))
- ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
- (begin
- (set! cust-doc? #t)
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
- (begin
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
- (begin
- (set! credit-note? #t)
- (set! default-title (_ "Credit Note"))))))
-
- (set! title (title-string default-title custom-title))))
-
- (gnc:html-document-set-title! document (format #f (_"~a #~a") title
- (gncInvoiceGetID invoice)))
+ (if (null? invoice)
+
+ (gnc:html-document-add-object! document
+ (gnc:make-html-text
+ (_ "No valid invoice selected. Click on the Options button and select the invoice to use.")))
+
+ (let* ((book (gncInvoiceGetBook invoice))
+ (date-format (gnc:options-fancy-date book))
+ (owner (gncInvoiceGetOwner invoice))
+ (type (gncInvoiceGetType invoice)))
+
+ (cond
+ ((eqv? type GNC-INVOICE-CUST-INVOICE)
+ (set! cust-doc? #t))
+ ((eqv? type GNC-INVOICE-VEND-INVOICE)
+ (set! default-title (_ "Bill")))
+ ((eqv? type GNC-INVOICE-EMPL-INVOICE)
+ (set! default-title (_ "Expense Voucher")))
+ ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
+ (begin
+ (set! cust-doc? #t)
+ (set! credit-note? #t)
+ (set! default-title (_ "Credit Note"))))
+ ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
+ (begin
+ (set! credit-note? #t)
+ (set! default-title (_ "Credit Note"))))
+ ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
+ (begin
+ (set! credit-note? #t)
+ (set! default-title (_ "Credit Note")))))
- (if (not (null? invoice))
- (let* ((book (gncInvoiceGetBook invoice))
- (date-format (gnc:options-fancy-date book)))
+ (set! title (title-string default-title custom-title))
+
+ (gnc:html-document-set-title! document (format #f (_"~a #~a") title
+ (gncInvoiceGetID invoice)))
- (set! table (make-entry-table invoice
- (gnc:report-options report-obj)
- add-order cust-doc? credit-note?))
+ (set! table (make-entry-table invoice
+ (gnc:report-options report-obj)
+ add-order cust-doc? credit-note?))
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "border" 1)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 4))
+ (gnc:html-table-set-style!
+ table "table"
+ 'attribute (list "border" 1)
+ 'attribute (list "cellspacing" 0)
+ 'attribute (list "cellpadding" 4))
- (gnc:html-document-add-object!
- document
- (make-myname-table book date-format))
+ (gnc:html-document-add-object!
+ document
+ (make-myname-table book date-format))
(if (gncInvoiceIsPosted invoice)
(let ((date-table #f)
@@ -652,40 +626,40 @@
(gnc:make-html-text
(_ "Invoice in progress..."))))
- (make-break! document)
- (make-break! document)
-
- (gnc:html-document-add-object!
- document
- (make-client-table owner orders))
-
- (make-break! document)
- (make-break! document)
-
- (if (opt-val "Display" "Billing ID")
- (let ((billing-id (gncInvoiceGetBillingID invoice)))
- (if (and billing-id (> (string-length billing-id) 0))
- (begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Reference") ": "
- (string-expand billing-id #\newline "<br/>"))))
- (make-break! document)))))
-
- (if (opt-val "Display" "Billing Terms")
- (let* ((term (gncInvoiceGetTerms invoice))
- (terms (gncBillTermGetDescription term)))
- (if (and terms (> (string-length terms) 0))
- (begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
+ (make-break! document)
+ (make-break! document)
+
+ (gnc:html-document-add-object!
+ document
+ (make-client-table owner orders))
+
+ (make-break! document)
+ (make-break! document)
+
+ (if (opt-val "Display" "Billing ID")
+ (let ((billing-id (gncInvoiceGetBillingID invoice)))
+ (if (and billing-id (> (string-length billing-id) 0))
+ (begin
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-append
+ (_ "Reference") ": "
+ (string-expand billing-id #\newline "<br/>"))))
+ (make-break! document)))))
+
+ (if (opt-val "Display" "Billing Terms")
+ (let* ((term (gncInvoiceGetTerms invoice))
+ (terms (gncBillTermGetDescription term)))
+ (if (and terms (> (string-length terms) 0))
+ (begin
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-append
(_ "Terms") ": "
(string-expand terms #\newline "<br/>"))))
- (make-break! document))
+ (make-break! document))
)))
;(make-break! document)
@@ -711,32 +685,26 @@
(make-break! document)
)))
- (gnc:html-document-add-object! document table)
-
- (make-break! document)
- (make-break! document)
-
- (if (opt-val "Display" "Invoice Notes")
- (let ((notes (gncInvoiceGetNotes invoice)))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-expand notes #\newline "<br/>")))))
-
- (make-break! document)
-
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (gnc:html-markup-br)
- (string-expand (opt-val "Display" "Extra Notes") #\newline "<br/>")
- (gnc:html-markup-br))))
-
- ; else
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (_ "No valid invoice selected. Click on the Options button and select the invoice to use."))))
+ (gnc:html-document-add-object! document table)
+
+ (make-break! document)
+ (make-break! document)
+
+ (if (opt-val "Display" "Invoice Notes")
+ (let ((notes (gncInvoiceGetNotes invoice)))
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-expand notes #\newline "<br/>")))))
+
+ (make-break! document)
+
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (gnc:html-markup-br)
+ (string-expand (opt-val "Display" "Extra Notes") #\newline "<br/>")
+ (gnc:html-markup-br)))))
document))
commit 874ed6ab0af81e7ab35c0808774eaf4924f4a4f8
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 2 17:05:39 2018 +0800
[invoice] *reindent*
diff --git a/gnucash/report/business-reports/easy-invoice.scm b/gnucash/report/business-reports/easy-invoice.scm
index 351efc7..3d7db5b 100644
--- a/gnucash/report/business-reports/easy-invoice.scm
+++ b/gnucash/report/business-reports/easy-invoice.scm
@@ -154,7 +154,7 @@
"number-cell"
(gnc:make-gnc-monetary
currency (if cust-doc? (gncEntryGetInvPrice entry)
- (gncEntryGetBillPrice entry))))))
+ (gncEntryGetBillPrice entry))))))
(if (discount-col column-vector)
(addto! row-contents
@@ -319,8 +319,8 @@
(gnc:register-inv-option
(gnc:make-text-option
(N_ "Text") (N_ "Extra Notes")
- "v" (N_ "Extra notes to put on the invoice (simple HTML is accepted).")
- (_ "Thank you for your patronage!")))
+ "v" (N_ "Extra notes to put on the invoice (simple HTML is accepted).")
+ (_ "Thank you for your patronage!")))
(gnc:options-set-default-section gnc:*report-options* "General")
@@ -360,12 +360,12 @@
(let ((subtotal-mon (gnc:make-gnc-monetary currency subtotal)))
(gnc:html-table-append-row/markup!
- table
- subtotal-style
- (append (cons (gnc:make-html-table-cell/markup
+ table
+ subtotal-style
+ (append (cons (gnc:make-html-table-cell/markup
"total-label-cell" subtotal-label)
- '())
- (list (gnc:make-html-table-cell/size/markup
+ '())
+ (list (gnc:make-html-table-cell/size/markup
1 (colspan subtotal-mon used-columns)
"total-number-cell"
(display-subtotal subtotal-mon used-columns)))))))
@@ -375,15 +375,15 @@
(currency (xaccTransGetCurrency t))
;; Depending on the document type, the payments may need to be sign-reversed
(amt (gnc:make-gnc-monetary currency
- (if reverse-payments?
- (gnc-numeric-neg(xaccSplitGetValue split))
- (xaccSplitGetValue split))))
+ (if reverse-payments?
+ (gnc-numeric-neg(xaccSplitGetValue split))
+ (xaccSplitGetValue split))))
(payment-style "grand-total")
(row '()))
(total-collector 'add
- (gnc:gnc-monetary-commodity amt)
- (gnc:gnc-monetary-amount amt))
+ (gnc:gnc-monetary-commodity amt)
+ (gnc:gnc-monetary-amount amt))
(if (date-col used-columns)
(addto! row
@@ -409,25 +409,25 @@
(if (null? entries)
(let ((total-collector (gnc:make-commodity-collector)))
- ; jamie
+ ; jamie
(if (opt-val "Display" "Subtotal")
(add-subtotal-row table used-columns (gncInvoiceGetTotalSubtotal invoice)
"grand-total" (_ "Net Price")))
(if display-all-taxes
- (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
- (for-each
- (lambda (parm)
- (let* ((value (cdr parm))
- (acct (car parm))
- (name (xaccAccountGetName acct)))
- (add-subtotal-row table used-columns value
- "grand-total" name)))
- acct-val-list))
-
- ; nope, just show the total tax.
- (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
- "grand-total" (_ "Tax")))
+ (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
+ (for-each
+ (lambda (parm)
+ (let* ((value (cdr parm))
+ (acct (car parm))
+ (name (xaccAccountGetName acct)))
+ (add-subtotal-row table used-columns value
+ "grand-total" name)))
+ acct-val-list))
+
+ ; nope, just show the total tax.
+ (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
+ "grand-total" (_ "Tax")))
(add-subtotal-row table used-columns (gncInvoiceGetTotal invoice)
"grand-total" (_ "Total Price"))
@@ -545,7 +545,7 @@
(string-append label ": ")
(string-expand (strftime date-format
(localtime date))
- #\space " "))))
+ #\space " "))))
(define (make-date-table)
(let ((table (gnc:make-html-table)))
@@ -572,23 +572,23 @@
'attribute (list "cellspacing" 0)
'attribute (list "cellpadding" 0))
(gnc:html-table-append-row! table
- (list (if name (string-append "<div align='right'>" name "</div>") "")))
+ (list (if name (string-append "<div align='right'>" name "</div>") "")))
- ; this is pretty strange. If addy is set, then make caddy <div>addy</div>,
- ; then when adding the row to the table, we actually add several rows by expanding
- ; caddy (the <div> is already set for the first in list and </dev> for last because
- ; of addy)
+ ; this is pretty strange. If addy is set, then make caddy <div>addy</div>,
+ ; then when adding the row to the table, we actually add several rows by expanding
+ ; caddy (the <div> is already set for the first in list and </dev> for last because
+ ; of addy)
(if (and addy (> (string-length addy) 0))
- (let ((caddy (string-append "<div align='right'>" addy "</div>")))
- (gnc:html-table-append-row! table (list (string-expand caddy
- #\newline "</td></tr><tr><td><div align='right'>")))))
+ (let ((caddy (string-append "<div align='right'>" addy "</div>")))
+ (gnc:html-table-append-row! table (list (string-expand caddy
+ #\newline "</td></tr><tr><td><div align='right'>")))))
table))
(define (add-html! document htmlstring)
(gnc:html-document-add-object!
document
- (gnc:make-html-text
- (N_ htmlstring))))
+ (gnc:make-html-text
+ (N_ htmlstring))))
(define (make-break! document)
(gnc:html-document-add-object!
@@ -628,31 +628,31 @@
(set! owner (gncInvoiceGetOwner invoice))
(let ((type (gncInvoiceGetType invoice)))
(cond
- ((eqv? type GNC-INVOICE-CUST-INVOICE)
- (set! cust-doc? #t))
- ((eqv? type GNC-INVOICE-VEND-INVOICE)
- (set! default-title (_ "Bill")))
- ((eqv? type GNC-INVOICE-EMPL-INVOICE)
- (set! default-title (_ "Expense Voucher")))
- ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-CUST-INVOICE)
+ (set! cust-doc? #t))
+ ((eqv? type GNC-INVOICE-VEND-INVOICE)
+ (set! default-title (_ "Bill")))
+ ((eqv? type GNC-INVOICE-EMPL-INVOICE)
+ (set! default-title (_ "Expense Voucher")))
+ ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
+ (begin
(set! cust-doc? #t)
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
+ (begin
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
+ (begin
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))))
(set! title (format #f (_"~a #~a") (title-string default-title custom-title)
- (gncInvoiceGetID invoice)))))
+ (gncInvoiceGetID invoice)))))
-; (gnc:html-document-set-title! document title)
+ ; (gnc:html-document-set-title! document title)
- ; framing table
+ ; framing table
(add-html! document "<center><table width='")
(add-html! document (opt-val "Display" "Invoice Width"))
(add-html! document "' cellpadding='0' cellspacing='0'>")
@@ -660,133 +660,133 @@
(add-html! document "<tr><td align='left'>")
(if (not (null? invoice))
- (let* ((book (gncInvoiceGetBook invoice))
- (date-format (gnc:options-fancy-date book)))
-
- ; invoice number and ID String table
- (add-html! document "<table width='100%'><tr>")
- (add-html! document "<td align='left'>")
- (add-html! document "<b><u>")
- (add-html! document title)
-;; (add-html! document (format #f (_ "Invoice #~a")
-;; (gncInvoiceGetID invoice)))
- (add-html! document "</u></b></td>")
- (add-html! document "<td align='right'>")
-
- (if (opt-val "Display" "My Company ID")
- (let* ((taxid (gnc:company-info book gnc:*company-id*)))
- (if (and taxid (> (string-length taxid) 0))
- (begin
- (add-html! document taxid)
- (add-html! document " ")))
- )
- )
- (add-html! document "</td>")
- (add-html! document "</tr></table>")
-
- (make-break! document)
- (make-break! document)
-
- ; add the client and company name table
- (let ((book (gncInvoiceGetBook invoice)))
- (set! table (make-entry-table invoice
- (gnc:report-options report-obj)
- add-order cust-doc? credit-note?))
+ (let* ((book (gncInvoiceGetBook invoice))
+ (date-format (gnc:options-fancy-date book)))
+ ; invoice number and ID String table
(add-html! document "<table width='100%'><tr>")
- (add-html! document "<td align='left' valign='top'>")
- (gnc:html-document-add-object!
- document
- (make-client-table owner orders))
+ (add-html! document "<td align='left'>")
+ (add-html! document "<b><u>")
+ (add-html! document title)
+ ;; (add-html! document (format #f (_ "Invoice #~a")
+ ;; (gncInvoiceGetID invoice)))
+ (add-html! document "</u></b></td>")
+ (add-html! document "<td align='right'>")
+
+ (if (opt-val "Display" "My Company ID")
+ (let* ((taxid (gnc:company-info book gnc:*company-id*)))
+ (if (and taxid (> (string-length taxid) 0))
+ (begin
+ (add-html! document taxid)
+ (add-html! document " ")))
+ )
+ )
(add-html! document "</td>")
- (if (opt-val "Display" "My Company")
- (begin
- (add-html! document "<td align='right' valign='top'>")
- (gnc:html-document-add-object!
- document
- (make-myname-table book))
- (add-html! document "</td>")))
(add-html! document "</tr></table>")
- )
-
- ;; add the date
- (if (gncInvoiceIsPosted invoice)
- (let ((date-table #f)
- (post-date (gncInvoiceGetDatePosted invoice))
- (due-date (gncInvoiceGetDateDue invoice)))
- (set! date-table (make-date-table))
- (make-date-row! date-table (_ "Date") post-date date-format)
- (if (opt-val "Display" "Due Date")
- (make-date-row! date-table (_ "Due") due-date date-format))
- (gnc:html-document-add-object! document date-table))
- (add-html! document
- (string-append "<font color='red'>"
- (_ "INVOICE NOT POSTED")
- "</font>")))
-
- (make-break! document)
-
- (if (opt-val "Display" "Billing ID")
- (let ((billing-id (gncInvoiceGetBillingID invoice)))
- (if (and billing-id (> (string-length billing-id) 0))
- (begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Billing ID") ": "
- (string-expand billing-id #\newline "<br/>"))))
- (make-break! document)))))
-
- (if (opt-val "Display" "Billing Terms")
- (let* ((term (gncInvoiceGetTerms invoice))
- (terms (gncBillTermGetDescription term)))
- (if (and terms (> (string-length terms) 0))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Terms") ": "
- (string-expand terms #\newline "<br/>")))))))
-
- (make-break! document)
-
- ; add the main table
- (gnc:html-table-set-style!
- table "table"
- 'attribute (list "width" "100%")
- 'attribute (list "border" 1)
- 'attribute (list "cellspacing" 0)
- 'attribute (list "cellpadding" 4))
- (gnc:html-document-add-object! document table)
-
- (make-break! document)
- (make-break! document)
-
- (if (opt-val "Display" "Invoice Notes")
- (begin
- (let ((notes (gncInvoiceGetNotes invoice)))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-expand notes #\newline "<br/>"))))
- (make-break! document)
- (make-break! document)))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
+ (make-break! document)
+ (make-break! document)
+
+ ; add the client and company name table
+ (let ((book (gncInvoiceGetBook invoice)))
+ (set! table (make-entry-table invoice
+ (gnc:report-options report-obj)
+ add-order cust-doc? credit-note?))
+
+ (add-html! document "<table width='100%'><tr>")
+ (add-html! document "<td align='left' valign='top'>")
+ (gnc:html-document-add-object!
+ document
+ (make-client-table owner orders))
+ (add-html! document "</td>")
+ (if (opt-val "Display" "My Company")
+ (begin
+ (add-html! document "<td align='right' valign='top'>")
+ (gnc:html-document-add-object!
+ document
+ (make-myname-table book))
+ (add-html! document "</td>")))
+ (add-html! document "</tr></table>")
+ )
+
+ ;; add the date
+ (if (gncInvoiceIsPosted invoice)
+ (let ((date-table #f)
+ (post-date (gncInvoiceGetDatePosted invoice))
+ (due-date (gncInvoiceGetDateDue invoice)))
+ (set! date-table (make-date-table))
+ (make-date-row! date-table (_ "Date") post-date date-format)
+ (if (opt-val "Display" "Due Date")
+ (make-date-row! date-table (_ "Due") due-date date-format))
+ (gnc:html-document-add-object! document date-table))
+ (add-html! document
+ (string-append "<font color='red'>"
+ (_ "INVOICE NOT POSTED")
+ "</font>")))
+
+ (make-break! document)
+
+ (if (opt-val "Display" "Billing ID")
+ (let ((billing-id (gncInvoiceGetBillingID invoice)))
+ (if (and billing-id (> (string-length billing-id) 0))
+ (begin
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-append
+ (_ "Billing ID") ": "
+ (string-expand billing-id #\newline "<br/>"))))
+ (make-break! document)))))
+
+ (if (opt-val "Display" "Billing Terms")
+ (let* ((term (gncInvoiceGetTerms invoice))
+ (terms (gncBillTermGetDescription term)))
+ (if (and terms (> (string-length terms) 0))
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-append
+ (_ "Terms") ": "
+ (string-expand terms #\newline "<br/>")))))))
+
+ (make-break! document)
+
+ ; add the main table
+ (gnc:html-table-set-style!
+ table "table"
+ 'attribute (list "width" "100%")
+ 'attribute (list "border" 1)
+ 'attribute (list "cellspacing" 0)
+ 'attribute (list "cellpadding" 4))
+ (gnc:html-document-add-object! document table)
+
+ (make-break! document)
+ (make-break! document)
+
+ (if (opt-val "Display" "Invoice Notes")
+ (begin
+ (let ((notes (gncInvoiceGetNotes invoice)))
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-expand notes #\newline "<br/>"))))
+ (make-break! document)
+ (make-break! document)))
+
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
(string-expand (opt-val "Text" "Extra Notes") #\newline "<br/>")
- ))
+ ))
- ; close the framing table
- (add-html! document "</td></tr></table></center>"))
+ ; close the framing table
+ (add-html! document "</td></tr></table></center>"))
- ; else (if invoice
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (_ "No valid invoice selected. Click on the Options button and select the invoice to use."))))
+ ; else (if invoice
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (_ "No valid invoice selected. Click on the Options button and select the invoice to use."))))
document))
diff --git a/gnucash/report/business-reports/fancy-invoice.scm b/gnucash/report/business-reports/fancy-invoice.scm
index 3e47430..edba6aa 100644
--- a/gnucash/report/business-reports/fancy-invoice.scm
+++ b/gnucash/report/business-reports/fancy-invoice.scm
@@ -321,15 +321,15 @@
(gnc:register-inv-option
(gnc:make-text-option
(N_ "Display") (N_ "Extra Notes")
- "u" (N_ "Extra notes to put on the invoice.")
- (_ "Thank you for your patronage!")))
+ "u" (N_ "Extra notes to put on the invoice.")
+ (_ "Thank you for your patronage!")))
(gnc:register-inv-option
(gnc:make-complex-boolean-option
(N_ "Display") (N_ "Payable to")
- "ua1" (N_ "Display the Payable to: information.") #t #f
- (lambda (x) (gnc-option-db-set-option-selectable-by-name
- gnc:*report-options* "Display" "Payable to string" x))))
+ "ua1" (N_ "Display the Payable to: information.") #t #f
+ (lambda (x) (gnc-option-db-set-option-selectable-by-name
+ gnc:*report-options* "Display" "Payable to string" x))))
(gnc:register-inv-option
(gnc:make-text-option
@@ -340,9 +340,9 @@
(gnc:register-inv-option
(gnc:make-complex-boolean-option
(N_ "Display") (N_ "Company contact")
- "ub1" (N_ "Display the Company contact information.") #t #f
- (lambda (x) (gnc-option-db-set-option-selectable-by-name
- gnc:*report-options* "Display" "Company contact string" x))))
+ "ub1" (N_ "Display the Company contact information.") #t #f
+ (lambda (x) (gnc-option-db-set-option-selectable-by-name
+ gnc:*report-options* "Display" "Company contact string" x))))
(gnc:register-inv-option
(gnc:make-text-option
@@ -387,7 +387,7 @@
(define (get-empty-row colcount)
(define row-contents '())
(do ((i 1 (+ i 1)))
- ((> i colcount))
+ ((> i colcount))
(addto! row-contents (gnc:make-html-table-cell)) ;;do stuff here
)
row-contents
@@ -398,12 +398,12 @@
(let ((subtotal-mon (gnc:make-gnc-monetary currency subtotal)))
(gnc:html-table-append-row/markup!
- table
- subtotal-style
- (append (cons (gnc:make-html-table-cell/markup
+ table
+ subtotal-style
+ (append (cons (gnc:make-html-table-cell/markup
"total-label-cell" subtotal-label)
- '())
- (list (gnc:make-html-table-cell/size/markup
+ '())
+ (list (gnc:make-html-table-cell/size/markup
1 (colspan subtotal-mon used-columns)
"total-number-cell"
(display-subtotal subtotal-mon used-columns)))))))
@@ -415,15 +415,15 @@
(owner '())
;; Depending on the document type, the payments may need to be sign-reversed
(amt (gnc:make-gnc-monetary currency
- (if reverse-payments?
- (gnc-numeric-neg(xaccSplitGetValue split))
- (xaccSplitGetValue split))))
+ (if reverse-payments?
+ (gnc-numeric-neg(xaccSplitGetValue split))
+ (xaccSplitGetValue split))))
(payment-style "grand-total")
(row '()))
(total-collector 'add
- (gnc:gnc-monetary-commodity amt)
- (gnc:gnc-monetary-amount amt))
+ (gnc:gnc-monetary-commodity amt)
+ (gnc:gnc-monetary-amount amt))
(if (date-col used-columns)
(addto! row
@@ -447,14 +447,14 @@
width
odd-row?)
(if (null? entries)
- (let ((total-collector (gnc:make-commodity-collector)))
+ (let ((total-collector (gnc:make-commodity-collector)))
;; oli-custom - modified to have a minimum of entries per table,
;; currently defaults to 24
;; also, doesn't count payment rows and stuff
(do ((entries-added entries-added (+ entries-added 1))
(odd-row? odd-row? (not odd-row?)))
- ((> entries-added (opt-val "Display" "Minimum # of entries" )))
+ ((> entries-added (opt-val "Display" "Minimum # of entries" )))
(gnc:html-table-append-row/markup!
table (if odd-row? "normal-row" "alternate-row")
(get-empty-row (num-columns-required used-columns)))
@@ -464,24 +464,24 @@
"grand-total" (_ "Net Price"))
(if display-all-taxes
- (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
- (for-each
- (lambda (parm)
- (let* ((value (cdr parm))
- (acct (car parm))
- (name (xaccAccountGetName acct)))
- (add-subtotal-row table used-columns value
- "grand-total" (string-expand
- name #\space " "))))
- acct-val-list))
-
- ; nope, just show the total tax.
- (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
- "grand-total" (_ "Tax")))
+ (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
+ (for-each
+ (lambda (parm)
+ (let* ((value (cdr parm))
+ (acct (car parm))
+ (name (xaccAccountGetName acct)))
+ (add-subtotal-row table used-columns value
+ "grand-total" (string-expand
+ name #\space " "))))
+ acct-val-list))
+
+ ; nope, just show the total tax.
+ (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
+ "grand-total" (_ "Tax")))
(add-subtotal-row table used-columns (gncInvoiceGetTotal invoice)
"grand-total" (string-expand (_ "Total Price")
- #\space " "))
+ #\space " "))
(total-collector 'add currency (gncInvoiceGetTotal invoice))
(if (and show-payments (not (null? lot)))
@@ -501,7 +501,7 @@
(add-subtotal-row table used-columns (cadr (total-collector 'getpair currency #f))
"grand-total" (string-expand (_ "Amount Due")
- #\space " ")))
+ #\space " ")))
;;
;; End of BEGIN -- now here's the code to handle all the entries!
@@ -626,7 +626,7 @@
(define (make-myname-table book title)
(let* ((table (gnc:make-html-table))
(name (gnc:company-info book gnc:*company-name*))
-;; (contact (gnc:company-info book gnc:*company-contact*))
+ ;; (contact (gnc:company-info book gnc:*company-contact*))
(addy (gnc:company-info book gnc:*company-addy*))
(id (gnc:company-info book gnc:*company-id*))
(phone (gnc:company-info book gnc:*company-phone*))
@@ -635,7 +635,7 @@
(invoice-cell (gnc:make-html-table-cell))
(name-cell (gnc:make-html-table-cell))
- )
+ )
;; oli-custom - modified the name table to increase the
;; font size of the company name
;; and add an "INVOICE" title to the upper right, also,
@@ -648,24 +648,24 @@
'attribute (list "cellpadding" 0)
'attribute (list "width" "100%"))
(gnc:html-table-cell-append-objects!
- invoice-cell title)
+ invoice-cell title)
(gnc:html-table-cell-set-style!
- invoice-cell "td"
- 'font-size "+2")
+ invoice-cell "td"
+ 'font-size "+2")
(gnc:html-table-cell-append-objects!
- name-cell (if name name ""))
+ name-cell (if name name ""))
(gnc:html-table-cell-set-style!
- name-cell "td"
- 'font-size "+2")
+ name-cell "td"
+ 'font-size "+2")
(gnc:html-table-append-row! table (list name-cell (gnc:make-html-table-cell) invoice-cell)) ;;(gnc:make-html-table-cell) was ""
(gnc:html-table-set-col-style!
- table 1 "td"
- 'attribute (list "align" "center")
- 'attribute (list "width" "33%"))
+ table 1 "td"
+ 'attribute (list "align" "center")
+ 'attribute (list "width" "33%"))
(gnc:html-table-set-col-style!
- table 2 "td"
- 'attribute (list "align" "right")
- 'attribute (list "width" "33%"))
+ table 2 "td"
+ 'attribute (list "align" "right")
+ 'attribute (list "width" "33%"))
(gnc:html-table-append-row!
table (list (string-expand (string-append (if addy addy "") (if id (string-append "\n" id) "")) #\newline "<br/>")
(string-expand
@@ -678,13 +678,13 @@
#\newline "<br/>" )
(if url (string-append (_ "Web:") " " url) "")))
-;; oli-custom - I didn't want today's date on the invoice.
-;; The invoice already has a date.
-;; Today's date can be in the email, fax or letter accompanying the invoice.
-;; (gnc:html-table-append-row! table (list
-;; (strftime
-;; date-format
-;; (gnc-localtime (gnc:get-today)))))
+ ;; oli-custom - I didn't want today's date on the invoice.
+ ;; The invoice already has a date.
+ ;; Today's date can be in the email, fax or letter accompanying the invoice.
+ ;; (gnc:html-table-append-row! table (list
+ ;; (strftime
+ ;; date-format
+ ;; (gnc-localtime (gnc:get-today)))))
table))
(define (make-break! document)
@@ -725,23 +725,23 @@
(set! owner (gncInvoiceGetOwner invoice))
(let ((type (gncInvoiceGetType invoice)))
(cond
- ((eqv? type GNC-INVOICE-CUST-INVOICE)
- (set! cust-doc? #t))
- ((eqv? type GNC-INVOICE-VEND-INVOICE)
- (set! default-title (_ "Bill")))
- ((eqv? type GNC-INVOICE-EMPL-INVOICE)
- (set! default-title (_ "Expense Voucher")))
- ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-CUST-INVOICE)
+ (set! cust-doc? #t))
+ ((eqv? type GNC-INVOICE-VEND-INVOICE)
+ (set! default-title (_ "Bill")))
+ ((eqv? type GNC-INVOICE-EMPL-INVOICE)
+ (set! default-title (_ "Expense Voucher")))
+ ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
+ (begin
(set! cust-doc? #t)
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
+ (begin
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
+ (begin
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))))
))
@@ -758,7 +758,7 @@
(helper-table (gnc:make-html-table))
(title (title-string default-title custom-title)))
- (set! table (make-entry-table invoice
+ (set! table (make-entry-table invoice
(gnc:report-options report-obj)
add-order cust-doc? credit-note?))
@@ -808,10 +808,10 @@
(due-date (gncInvoiceGetDateDue invoice)))
(set! date-table (make-date-table))
(gnc:html-table-append-row!
- ;; Translators: ~a below is "Invoice" or "Bill" or even the
- ;; custom title from the options. The next column contains
- ;; the number of the document.
- date-table (list (format #f (_ "~a #") title) (gncInvoiceGetID invoice)))
+ ;; Translators: ~a below is "Invoice" or "Bill" or even the
+ ;; custom title from the options. The next column contains
+ ;; the number of the document.
+ date-table (list (format #f (_ "~a #") title) (gncInvoiceGetID invoice)))
;; Translators: The first ~a below is "Invoice" or
;; "Bill" or even the custom title from the
;; options. This string sucks for i18n, but I don't
@@ -825,20 +825,20 @@
(_ "Invoice in progress...")))))
(gnc:html-table-append-row!
- helper-table
- (list (make-client-table owner orders) date-object))
+ helper-table
+ (list (make-client-table owner orders) date-object))
(gnc:html-table-set-col-style!
- helper-table 0 "td"
- 'attribute (list "valign" "top"))
+ helper-table 0 "td"
+ 'attribute (list "valign" "top"))
(gnc:html-table-set-col-style!
- helper-table 1 "td"
- 'attribute (list "valign" "top")
- 'attribute (list "align" "right")
- ;; oli-custom - "squeeze" the date table,
- ;; or else it's spaced out
- 'attribute (list "width" "1%"))
+ helper-table 1 "td"
+ 'attribute (list "valign" "top")
+ 'attribute (list "align" "right")
+ ;; oli-custom - "squeeze" the date table,
+ ;; or else it's spaced out
+ 'attribute (list "width" "1%"))
(gnc:html-document-add-object!
document
@@ -889,11 +889,11 @@
(let* ((name (gnc:company-info book gnc:*company-name*))
(name-str (opt-val "Display" "Payable to string")))
(if (and name (> (string-length name) 0))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append name-str ": "
- (string-expand name #\newline "<br/>")))))))
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-append name-str ": "
+ (string-expand name #\newline "<br/>")))))))
(make-break! document)
@@ -901,11 +901,11 @@
(let* ((contact (gnc:company-info book gnc:*company-contact*))
(contact-str (opt-val "Display" "Company contact string")))
(if (and contact (> (string-length contact) 0))
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append contact-str ": "
- (string-expand contact #\newline "<br/>")))))))
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-append contact-str ": "
+ (string-expand contact #\newline "<br/>")))))))
(gnc:html-document-add-object!
document
@@ -914,7 +914,7 @@
(string-expand (opt-val "Display" "Extra Notes") #\newline "<br/>")
(gnc:html-markup-br))))
- ; else
+ ; else
(gnc:html-document-add-object!
document
(gnc:make-html-text
diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 2109115..d846247 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -289,13 +289,12 @@
(gnc:make-simple-boolean-option
(N_ "Display") (N_ "Job Details")
"td" (N_ "Display the job name for this invoice?") #f))
-
-
+
(gnc:register-inv-option
(gnc:make-text-option
(N_ "Display") (N_ "Extra Notes")
- "u" (N_ "Extra notes to put on the invoice.")
- (_ "Thank you for your patronage!")))
+ "u" (N_ "Extra notes to put on the invoice.")
+ (_ "Thank you for your patronage!")))
(gnc:options-set-default-section gnc:*report-options* "General")
@@ -338,12 +337,12 @@
(let ((subtotal-mon (gnc:make-gnc-monetary currency subtotal)))
(gnc:html-table-append-row/markup!
- table
- subtotal-style
- (append (cons (gnc:make-html-table-cell/markup
+ table
+ subtotal-style
+ (append (cons (gnc:make-html-table-cell/markup
"total-label-cell" subtotal-label)
- '())
- (list (gnc:make-html-table-cell/size/markup
+ '())
+ (list (gnc:make-html-table-cell/size/markup
1 (colspan subtotal-mon used-columns)
"total-number-cell"
(display-subtotal subtotal-mon used-columns)))))))
@@ -353,15 +352,15 @@
(currency (xaccTransGetCurrency t))
;; Depending on the document type, the payments may need to be sign-reversed
(amt (gnc:make-gnc-monetary currency
- (if reverse-payments?
- (gnc-numeric-neg(xaccSplitGetValue split))
- (xaccSplitGetValue split))))
+ (if reverse-payments?
+ (gnc-numeric-neg(xaccSplitGetValue split))
+ (xaccSplitGetValue split))))
(payment-style "grand-total")
(row '()))
(total-collector 'add
- (gnc:gnc-monetary-commodity amt)
- (gnc:gnc-monetary-amount amt))
+ (gnc:gnc-monetary-commodity amt)
+ (gnc:gnc-monetary-amount amt))
(if (date-col used-columns)
(addto! row
@@ -391,19 +390,19 @@
"grand-total" (_ "Net Price"))
(if display-all-taxes
- (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
- (for-each
- (lambda (parm)
- (let* ((value (cdr parm))
- (acct (car parm))
- (name (xaccAccountGetName acct)))
- (add-subtotal-row table used-columns value
- "grand-total" name)))
- acct-val-list))
-
- ; nope, just show the total tax.
- (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
- "grand-total" (_ "Tax")))
+ (let ((acct-val-list (gncInvoiceGetTotalTaxList invoice)))
+ (for-each
+ (lambda (parm)
+ (let* ((value (cdr parm))
+ (acct (car parm))
+ (name (xaccAccountGetName acct)))
+ (add-subtotal-row table used-columns value
+ "grand-total" name)))
+ acct-val-list))
+
+ ; nope, just show the total tax.
+ (add-subtotal-row table used-columns (gncInvoiceGetTotalTax invoice)
+ "grand-total" (_ "Tax")))
(add-subtotal-row table used-columns (gncInvoiceGetTotal invoice)
"grand-total" (_ "Total Price"))
@@ -520,7 +519,7 @@
(string-append label ": ")
(string-expand (strftime date-format
(localtime date))
- #\space " ")
+ #\space " ")
)))
(define (make-date-table)
@@ -580,9 +579,9 @@
(owner '())
(references? (opt-val "Display" "References"))
(default-title (_ "Invoice"))
- (job? (opt-val "Display" "Job Details"))
- (jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
- (jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
+ (job? (opt-val "Display" "Job Details"))
+ (jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
+ (jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(custom-title (opt-val gnc:pagename-general "Custom Title"))
(title "")
(cust-doc? #f)
@@ -597,30 +596,30 @@
(set! owner (gncInvoiceGetOwner invoice))
(let ((type (gncInvoiceGetType invoice)))
(cond
- ((eqv? type GNC-INVOICE-CUST-INVOICE)
- (set! cust-doc? #t))
- ((eqv? type GNC-INVOICE-VEND-INVOICE)
- (set! default-title (_ "Bill")))
- ((eqv? type GNC-INVOICE-EMPL-INVOICE)
- (set! default-title (_ "Expense Voucher")))
- ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-CUST-INVOICE)
+ (set! cust-doc? #t))
+ ((eqv? type GNC-INVOICE-VEND-INVOICE)
+ (set! default-title (_ "Bill")))
+ ((eqv? type GNC-INVOICE-EMPL-INVOICE)
+ (set! default-title (_ "Expense Voucher")))
+ ((eqv? type GNC-INVOICE-CUST-CREDIT-NOTE)
+ (begin
(set! cust-doc? #t)
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-VEND-CREDIT-NOTE)
+ (begin
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))
- ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
- (begin
+ ((eqv? type GNC-INVOICE-EMPL-CREDIT-NOTE)
+ (begin
(set! credit-note? #t)
(set! default-title (_ "Credit Note"))))))
- (set! title (title-string default-title custom-title))))
+ (set! title (title-string default-title custom-title))))
(gnc:html-document-set-title! document (format #f (_"~a #~a") title
- (gncInvoiceGetID invoice)))
+ (gncInvoiceGetID invoice)))
(if (not (null? invoice))
(let* ((book (gncInvoiceGetBook invoice))
@@ -684,34 +683,34 @@
document
(gnc:make-html-text
(string-append
- (_ "Terms") ": "
- (string-expand terms #\newline "<br/>"))))
+ (_ "Terms") ": "
+ (string-expand terms #\newline "<br/>"))))
(make-break! document))
- )))
-
- ;(make-break! document)
-
- ;; Add job number and name to invoice if requested and if it exists
- (if job?
- (if (not(string=? jobnumber "" ))
- (begin
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Job number") ": "
- (string-expand jobnumber #\newline "<br/>"))))
- (make-break! document)
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
- (string-append
- (_ "Job name") ": "
- (string-expand jobname #\newline "<br/>"))))
- (make-break! document)
- (make-break! document)
- )))
-
+ )))
+
+ ;(make-break! document)
+
+ ;; Add job number and name to invoice if requested and if it exists
+ (if job?
+ (if (not(string=? jobnumber "" ))
+ (begin
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-append
+ (_ "Job number") ": "
+ (string-expand jobnumber #\newline "<br/>"))))
+ (make-break! document)
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
+ (string-append
+ (_ "Job name") ": "
+ (string-expand jobname #\newline "<br/>"))))
+ (make-break! document)
+ (make-break! document)
+ )))
+
(gnc:html-document-add-object! document table)
(make-break! document)
@@ -733,7 +732,7 @@
(string-expand (opt-val "Display" "Extra Notes") #\newline "<br/>")
(gnc:html-markup-br))))
- ; else
+ ; else
(gnc:html-document-add-object!
document
(gnc:make-html-text
Summary of changes:
gnucash/report/business-reports/CMakeLists.txt | 2 -
.../report/business-reports/business-reports.scm | 2 -
gnucash/report/business-reports/easy-invoice.scm | 811 -------------
gnucash/report/business-reports/fancy-invoice.scm | 943 ---------------
gnucash/report/business-reports/invoice.scm | 1254 +++++++++++---------
.../report/business-reports/test/test-invoice.scm | 178 ++-
libgnucash/app-utils/options.scm | 1 +
po/POTFILES.in | 2 -
8 files changed, 782 insertions(+), 2411 deletions(-)
delete mode 100644 gnucash/report/business-reports/easy-invoice.scm
delete mode 100644 gnucash/report/business-reports/fancy-invoice.scm
More information about the gnucash-changes
mailing list