post from gnucash@oliverstech.com

Derek Atkins warlord at MIT.EDU
Sat Jun 14 15:51:56 CDT 2003


Yep, this made it through already.  You should check the www interface
before forwarding it on ;)

-derek

linas at linas.org (Linas Vepstas) writes:

> From: gnucash-patches-owner at lists.gnucash.org
> Subject: gnucash-patches post from gnucash at oliverstech.com requires approval
> To: gnucash-patches-owner at lists.gnucash.org
> 
> As list administrator, your authorization is requested for the
> following mailing list posting:
> 
>     List:    gnucash-patches at lists.gnucash.org
>     From:    gnucash at oliverstech.com
>     Subject: Customized invoice.scm
>     Reason:  Post by non-member to a members-only list
> 
> At your convenience, visit:
> 
>     https://lists.gnucash.org/mailman/admindb/gnucash-patches
>         
> to approve or deny the request.
> 
> X-Original-To: gnucash-patches at gnucash.org
> From: Oliver Jones <gnucash at oliverstech.com>
> To: gnucash-patches at gnucash.org
> Subject: Customized invoice.scm
> Organization: Olivers Technology Inc.
> 
> 
> Hello,
> 
> I have customized invoice.scm for my company, to make the print-out look a 
> bit more professional. By popular demand I am making the changes public. Be 
> aware that some translations might be broken, the title will still be 
> "invoice" even for bills/expense vouchers, and most changes are hard-coded in.
> 
> This quick and dirty hack was made due to the need to have something now. The 
> proper way to do it is to have the user supply an HTML template. That will 
> happen when time will permit.
> 
> No animals were harmed during the development of this patch, even though the 
> urge to hit something when things don't work can be quite big. :)
> 
> -- 
> Oliver Jones, General Manager
> Olivers Technology Inc.
> Cell: (403) 714-8783
> Web: http://oliverstech.com
> 
> --- gnucash-1.8.4/src/business/business-reports/invoice.scm	Sun May 25 18:48:31 2003
> +++ invoice.scm	Fri Jun 13 18:16:49 2003
> @@ -3,6 +3,23 @@
>  ;;
>  ;; Created by:  Derek Atkins <warlord at MIT.EDU>
>  ;;
> +;; 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.
>  
>  (define-module (gnucash report invoice))
>  
> @@ -98,7 +115,7 @@
>      (if (quantity-col column-vector)
>  	(addto! heading-list (_ "Quantity")))
>      (if (price-col column-vector)
> -	(addto! heading-list (_ "Unit Price")))
> +	(addto! heading-list (string-expand (_ "Unit Price") #\space "&nbsp;")))
>      (if (discount-col column-vector)
>  	(addto! heading-list (_ "Discount")))
>      (if (tax-col column-vector)
> @@ -121,23 +138,11 @@
>         (hash-set! hash acct (if ref (gnc:numeric-add-fixed ref val) val))))
>     values))
>  
> -
>  (define (monetary-or-percent numeric currency entry-type)
>    (if (gnc:entry-type-percent-p entry-type)
> -      (let ((table (gnc:make-html-table)))
> -	(gnc:html-table-set-style!
> -	 table "table"
> -	 'attribute (list "border" 0)
> -	 'attribute (list "cellspacing" 1)
> -	 'attribute (list "cellpadding" 0))
> -	(gnc:html-table-append-row!
> -	 table
> -	 (list numeric (_ "%")))
> -	(set-last-row-style!
> -	 table "td"
> -	 'attribute (list "valign" "top"))
> -	table)
> -      (gnc:make-gnc-monetary currency numeric)))      
> +      ;; 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 invoice?)
>    (let* ((row-contents '())
> @@ -210,6 +215,8 @@
>      
>      (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))
> @@ -224,7 +231,7 @@
>    (gnc:register-inv-option
>     (gnc:make-simple-boolean-option
>      (N_ "Display Columns") (N_ "Date")
> -    "b" (N_ "Display the date?") #t))
> +    "b" (N_ "Display the date?") #f))
>  
>    (gnc:register-inv-option
>     (gnc:make-simple-boolean-option
> @@ -234,7 +241,7 @@
>    (gnc:register-inv-option
>     (gnc:make-simple-boolean-option
>      (N_ "Display Columns") (N_ "Action")
> -    "g" (N_ "Display the action?") #t))
> +    "g" (N_ "Display the action?") #f))
>  
>    (gnc:register-inv-option
>     (gnc:make-simple-boolean-option
> @@ -249,12 +256,12 @@
>    (gnc:register-inv-option
>     (gnc:make-simple-boolean-option
>      (N_ "Display Columns") (N_ "Discount")
> -    "k" (N_ "Display the entry's discount") #t))
> +    "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") #t))
> +    "l" (N_ "Display the entry's taxable status") #f))
>  
>    (gnc:register-inv-option
>     (gnc:make-simple-boolean-option
> @@ -269,7 +276,7 @@
>    (gnc:register-inv-option
>     (gnc:make-simple-boolean-option
>      (N_ "Display") (N_ "Individual Taxes")
> -    "o" (N_ "Display all the individual taxes?") #f))
> +    "o" (N_ "Display all the individual taxes?") #t))
>  
>    (gnc:register-inv-option
>     (gnc:make-simple-boolean-option
> @@ -305,7 +312,9 @@
>     (gnc:make-text-option
>      (N_ "Display") (N_ "Extra Notes")
>       "u" (N_ "Extra notes to put on the invoice")
> -     "Thank you for your patronage"))
> +     ;; oli-custom - Extra notes to add on each invoice, invoice-independent
> +     ;; yes, I was too lazy to (get-company-name) ;)
> +     "Make all cheques payable to: Company Name Inc.\nDirect all inquiries to: Mr. Accounting Contact"))
>  
>    (gnc:register-inv-option
>     (gnc:make-string-option
> @@ -326,7 +335,8 @@
>  	(display-all-taxes (opt-val "Display" "Individual Taxes"))
>  	(lot (gnc:invoice-get-posted-lot invoice))
>  	(txn (gnc:invoice-get-posted-txn invoice))
> -	(currency (gnc:invoice-get-currency invoice)))
> +	(currency (gnc:invoice-get-currency invoice))
> +	(entries-added 0))
>  
>      (define (colspan monetary used-columns)
>        (cond
> @@ -353,11 +363,13 @@
>  		    (gnc:html-table-append-row/markup! 
>  		     table
>  		     subtotal-style
> -		     (append (cons (gnc:make-html-table-cell/markup
> +		     ;; oli-custom modified to colspan the subtotal labels instead of the data fields
> +		     (append (cons (gnc:make-html-table-cell/size/markup
> +				    0 (colspan currency used-columns)
>  				    "total-label-cell" subtotal-label)
>  				   '())
> -			     (list (gnc:make-html-table-cell/size/markup
> -				    1 (colspan currency used-columns)
> +			     (list (gnc:make-html-table-cell/markup
> +				    ;; 1 (colspan currency used-columns)
>  				    "total-number-cell"
>  				    (display-subtotal currency used-columns))))))
>  		  currency-totals)))
> @@ -401,6 +413,14 @@
>  				    acct-hash)
>        (if (null? entries)
>  	  (begin
> +	    ;; oli-custom - modified to have a minimum of entries per table, currently at 24
> +	    ;; currently doesn't count payment rows and stuff
> +	    (do ((entries-added entries-added (+ entries-added 1))
> +		 (odd-row? odd-row? (not odd-row?)))
> +		;; oli-custom - here you put the minimum number of rows minus one
> +		((> entries-added 23))
> +		(gnc:html-table-append-row/markup! table (if odd-row? "normal-row" "alternate-row") (string->list (make-string (num-columns-required used-columns) #\space)))
> +		)
>  	    (add-subtotal-row table used-columns value-collector
>  			      "grand-total" (_ "Subtotal"))
>  
> @@ -412,7 +432,7 @@
>  			 (name (gnc:account-get-name acct)))
>  		     (collector 'add commodity value)
>  		     (add-subtotal-row table used-columns collector
> -				       "grand-total" name)))
> +				       "grand-total" (string-expand name #\space "&nbsp;"))))
>  		 acct-hash)
>  
>  		; nope, just show the total tax.
> @@ -434,7 +454,7 @@
>  		   splits)))
>  
>  	    (add-subtotal-row table used-columns total-collector
> -			      "grand-total" (_ "Amount Due")))
> +			      "grand-total" (string-expand (_ "Amount Due") #\space "&nbsp;")))
>  
>  	  ;;
>  	  ;; End of BEGIN -- now here's the code to handle all the entries!
> @@ -472,6 +492,8 @@
>  	    (let ((order (gnc:entry-get-order current)))
>  	      (if order (add-order order)))
>  
> +	    (set! entries-added (+ entries-added 1))
> +	    
>  	    (do-rows-with-subtotals rest
>  				    table
>  				    used-columns
> @@ -522,6 +544,7 @@
>    (line-helper (string->list string)))
>  
>  (define (make-client-table owner orders)
> +;; oli-custom - FIXME: font for client company name should be at least size +1.
>    (let ((table (gnc:make-html-table)))
>      (gnc:html-table-set-style!
>       table "table"
> @@ -554,7 +577,11 @@
>     table
>     (list
>      (string-append label ":&nbsp;")
> -    (string-expand (gnc:print-date date) #\space "&nbsp;"))))
> +    ;; 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 "%B %e, %Y" (localtime (car date))) #\space "&nbsp;")
> +    ;;(string-expand (gnc:print-date date) #\space "&nbsp;")
> +    )))
>  
>  (define (make-date-table)
>    (let ((table (gnc:make-html-table)))
> @@ -575,23 +602,48 @@
>  			      (list gnc:*business-label* gnc:*company-name*))))
>  	 (addy (gnc:kvp-frame-get-slot-path
>  		slots (append gnc:*kvp-option-path*
> -			      (list gnc:*business-label* gnc:*company-addy*)))))
> -
> +			      (list gnc:*business-label* gnc:*company-addy*))))
> +	 (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 "align" "right")
> -     'attribute (list "valign" "top")
>       'attribute (list "cellspacing" 0)
> -     'attribute (list "cellpadding" 0))
> -    (gnc:html-table-append-row! table (list (if name name "")))
> +     'attribute (list "cellpadding" 0)
> +     'attribute (list "width" "100%"))
> +    (gnc:html-table-cell-append-objects!
> +	invoice-cell "INVOICE")
> +    (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 "" invoice-cell))
> +    (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
>  					     (if addy addy "")
> -					     #\newline "<br>")))
> -    (gnc:html-table-append-row! table (list
> -				       (strftime
> -					date-format
> -					(localtime (car (gnc:get-today))))))
> +					     #\newline "<br>") "Phone: (111) 222-3333<br>Web: http://companysite.com" ""))
> +;; 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
> +;;					(localtime (car (gnc:get-today))))))
>      table))
>  
>  (define (make-break! document)
> @@ -633,11 +685,13 @@
>  	       (set! title (_ "Expense Voucher")))))
>  	  (set! title (string-append title " #"
>  				     (gnc:invoice-get-id invoice)))))
> -
> -    (gnc:html-document-set-title! document title)
> +    ;; oli-custom - title redundant, "Invoice" moved to myname-table, invoice number moved below
> +    ;;(gnc:html-document-set-title! document title)
>  
>      (if invoice
> -	(let ((book (gnc:invoice-get-book invoice)))
> +	(let ((book (gnc:invoice-get-book invoice))
> +	      (date-object #f)
> +	      (helper-table (gnc:make-html-table)))
>  	  (set! table (make-entry-table invoice
>  					(gnc:report-options report-obj)
>  					add-order invoice?))
> @@ -646,35 +700,68 @@
>  	   table "table"
>  	   'attribute (list "border" 1)
>  	   'attribute (list "cellspacing" 0)
> -	   'attribute (list "cellpadding" 4))
> +	   '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 (opt-val "Display" "Today Date Format")))
> +	  (gnc:html-document-add-object! document (make-myname-table book (opt-val "Display" "Today Date Format")))
> +
> +	  (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%"))
>  
> -	  (let ((date-table #f)
> +	  (set! date-object (let ((date-table #f)
>  		(post-date (gnc:invoice-get-date-posted invoice))
>  		(due-date (gnc:invoice-get-date-due invoice)))
>  
>  	    (if (not (equal? post-date (cons 0 0)))
>  		(begin
>  		  (set! date-table (make-date-table))
> -		  (make-date-row! date-table (_ "Invoice Date") post-date)
> -		  (make-date-row! date-table (_ "Due Date") due-date)
> -		  (gnc:html-document-add-object! document date-table))
> -		(gnc:html-document-add-object!
> -		 document
> -		 (gnc:make-html-text
> -		  (N_ "Invoice in progress....")))))
> -
> -	  (make-break! document)
> -	  (make-break! document)
> +		  ;; oli-custom - moved invoice number here
> +		  (gnc:html-table-append-row! date-table (list "Invoice&nbsp;#&nbsp;" (gnc:invoice-get-id invoice)))
> +		  (make-date-row! date-table (_ "Invoice&nbsp;Date") post-date)
> +		  (make-date-row! date-table (_ "Due&nbsp;Date") due-date)
> +		  date-table)
> +		(gnc:make-html-text
> +		  ;; oli-custom - FIXME: I have a feeling I broke a translation by not using string-expand for &nbsp;
> +		  (string-append title (N_ "<br>Invoice&nbsp;in&nbsp;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
> -	   (make-client-table owner orders))
> +	   helper-table)
>  
> -	  (make-break! document)
>  	  (make-break! document)
>  
>  	  (if (opt-val "Display" "Billing ID")
> 
> 
> Subject: confirm ce6e300e7fbed8b3c2e1f4d9f0420ec7deae4354
> From: gnucash-patches-request at lists.gnucash.org
> 
> If you reply to this message, keeping the Subject: header intact,
> Mailman will discard the held message.  Do this if the message is
> spam.  If you reply to this message and include an Approved: header
> with the list password in it, the message will be approved for posting
> to the list.  The Approved: header can also appear in the first line
> of the body of the reply.
> 
> 
> ----------
> 
> 
> -- 
> pub  1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas at linas.org>
> PGP Key fingerprint = 8305 2521 6000 0B5E 8984  3F54 64A9 9A82 0104 5933
> _______________________________________________
> gnucash-patches mailing list
> gnucash-patches at lists.gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-patches

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-patches mailing list