[PATCH] stylesheet-fancy.scm and a new 'Easy' Invoice for Gnucash 1.8.9

James Strandboge jamie at tpptraining.com
Tue Jun 15 11:48:25 EDT 2004


Hi,

First off, I'd like to say thanks to everyone involved in gnucash
development.  Gnucash is indispensable for me and my clients.

I'd also like to mention that this is my first attempt at scheme and
wanted to say that it was a lot easier to do real work than I thought it
would be.  After reading through the code and playing with
stylesheet-plain.scm, stylesheet-fancy.scm and invoice.scm for a while,
I was able to create the bulk of my 'easy-invoice.scm' in a few hours. 
Hopefully, I will have an opportunity to contribute more to the project
in the future.

Now to the patches...

stylesheet-fancy_1.8.9.patch is a small patch to the 'Technicolor'
stylesheet (stylesheet-fancy.scm) that:

1.  allows the user to configure via stylesheet preferences the
alignment of the 'Heading Banner'.  It can be either Left, Center or
Right

2. centers the entire report on the page.  This is useful for printing
and presentations.

3.  only displays the 'Logo' column if 'Logo' is defined in the
stylesheet preferences.  This ensures that the report is centered
precisely when 'Logo' is not defined.

I find this updated stylesheet very useful, but it may be more
appropriate to just have this be a separate 3rd stylesheet.


easy-invoice.scm is a new invoice based on invoice.scm.  Its named 'Easy
Invoice' because it is easily configurable, but I am not entirely
satisfied with the name, and would be more than happy to change it.  :) 
The main features of this invoice (beyond those found in invoice.scm) is
that it supports options for displaying My Company (data from
File/Properties), invoice width, and an added 'ID String'.


business-reports_1.8.9.patch is simply a patch to add easy-invoice.scm
to the list of business reports, and a comment on how to make
easy-invoice.scm the default invoice (ie for when you click 'Print' from
the 'View Invoice' dialog).  Hopefully this invoice will be as useful to
other people as it is to our company.

Thanks, 

Jamie Strandboge

-- 
Targeted Performance Partners, LLC
Web: http://www.tpptraining.com
E-mail: jamie at tpptraining.com
Tel: (585) 271-8370
Fax: (585) 271-8373
-------------- next part --------------
--- ./stylesheet-fancy.scm.orig	Fri May 14 08:15:53 2004
+++ ./stylesheet-fancy.scm	Tue May 18 23:23:57 2004
@@ -69,9 +69,24 @@
       (N_ "Heading Banner") "b" (N_ "Banner for top of report.")
       ""))
     (opt-register
+     (gnc:make-multichoice-option
+      (N_ "Images")
+      (N_ "Heading Alignment") "c" (N_ "Banner for top of report.")
+      'left
+      (list (vector 'left
+                     (N_ "Left")
+                     (N_ "Align the banner to the left"))
+            (vector 'center
+                     (N_ "Center")
+                     (N_ "Align the banner in the center"))
+            (vector 'right
+                     (N_ "Right")
+                     (N_ "Align the banner to the right"))
+            )))
+    (opt-register
      (gnc:make-pixmap-option
       (N_ "Images")
-      (N_ "Logo") "c" (N_ "Company logo image.")
+      (N_ "Logo") "d" (N_ "Company logo image.")
       ""))
 
     (opt-register
@@ -184,9 +199,15 @@
 	 (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
 	 (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
 	 (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
+         (align (gnc:value->string(opt-val (N_ "Images") (N_ "Heading Alignment"))))
 	 (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
 	 (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
-	 (border (opt-val (N_ "Tables") (N_ "Table border width"))))
+	 (border (opt-val (N_ "Tables") (N_ "Table border width")))
+         (headcolumn 0))
+
+    ; center the document without elements inheriting anything
+    (gnc:html-document-add-object! ssdoc
+       (gnc:make-html-text "<center>"))
 
     (gnc:html-document-set-style! 
      ssdoc "body" 
@@ -266,8 +287,14 @@
        'attribute (list "border" 0)
        'inheritable? #f)
 
+      ; set the header column to be the 2nd when we have a logo
+      ; do this so that when logo is not present, the document
+      ; is perfectly centered
+      (if (and logopixmap (> (string-length logopixmap) 0))
+        (set! headcolumn 1))
+
       (gnc:html-table-set-cell! 
-       t 1 1
+       t 1 headcolumn
        (if show-preparer? 
 	   ;; title plus preparer info 
 	   (gnc:make-html-text
@@ -289,21 +316,32 @@
 	    (gnc:html-markup-b 
 	     (gnc:html-document-title doc)))))
       
-      (gnc:html-table-set-cell!
-       t 0 0
-       (gnc:make-html-text
-	(gnc:html-markup-img logopixmap)))
+      ; only setup an image if we specified one
+      (if (and logopixmap (> (string-length logopixmap) 0))
+        (begin
+          (gnc:html-table-set-cell!
+            t 0 0
+            (gnc:make-html-text
+	      (gnc:html-markup-img logopixmap)))))
       
-      (gnc:html-table-set-cell!
-       t 0 1
-       (gnc:make-html-text
-	(gnc:html-markup-img headpixmap)))
+      (if (and headpixmap (> (string-length headpixmap) 0))
+        (begin
+          (gnc:html-table-set-cell!
+            t 0 headcolumn
+            (gnc:make-html-text 
+               (string-append 
+                 "<div align=\"" align "\">"
+                 "<img src=\"" headpixmap "\">"
+                 "</div>")))
+        )
+        (gnc:html-table-set-cell!
+          t 0 headcolumn
+          (gnc:make-html-text "&nbsp;")))
       
       (apply 
        gnc:html-table-set-cell! 
-       t 2 1
+       t 2 headcolumn
        (gnc:html-document-objects doc))
-      
       (gnc:html-document-add-object! ssdoc t))
     ssdoc))
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: easy-invoice.scm
Type: text/x-scheme
Size: 27446 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20040615/11b5b3f5/easy-invoice.bin
-------------- next part --------------
--- ./business-reports.scm.orig	Fri May 14 08:17:09 2004
+++ ./business-reports.scm	Tue May 18 22:01:59 2004
@@ -84,11 +84,14 @@
 
 (use-modules (gnucash report fancy-invoice))
 (use-modules (gnucash report invoice))
+(use-modules (gnucash report easy-invoice))
 (use-modules (gnucash report owner-report))
 (use-modules (gnucash report payables))
 (use-modules (gnucash report receivables))
 
 (define gnc:invoice-report-create gnc:invoice-report-create-internal)
+; make easy-invoice the default
+;(define gnc:invoice-report-create gnc:easy-invoice-report-create-internal)
 
 (export gnc:invoice-report-create gnc:owner-report-create
 	gnc:customer-anchor-text gnc:job-anchor-text gnc:vendor-anchor-text


More information about the gnucash-devel mailing list