--- taxinvoice.scm-dist	2012-07-15 06:46:31.000000000 +1000
+++ taxinvoice.scm	2013-03-11 15:39:26.000000000 +1100
@@ -1,5 +1,6 @@
 
 ;; $Author: chris $ $Date: 2009/07/29 09:31:44 $ $Revision: 1.33 $
+;; Modified by Dmitry Smirnov <onlyjob@member.fsf.org>  14 Feb 2012
 ;;
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
@@ -87,7 +88,37 @@
 ;(define filespage    (N_ "Files"))
 (define displaypage  (N_ "Display"))
 (define generalpage  gnc:pagename-general)
+(define elementspage			(N_ "Elements"))
 ; option names 
+(define optname-col-date		(N_ "column: Date"))
+(define optname-col-taxrate		(N_ "column: Tax Rate"))
+(define optname-col-taxamount		(N_ "column: Tax Amount"))
+(define optname-col-units		(N_ "column: Units"))
+(define optname-col-netprice		(N_ "column: Net Price"))
+(define optname-col-totalprice		(N_ "column: Total Price"))
+(define optname-row-taxrate		(N_ "row: Tax Rate"))
+(define optname-row-taxamount		(N_ "row: Total Tax Amount"))
+(define optname-row-netprice		(N_ "row: Total Net Price"))
+(define optname-row-totalprice		(N_ "row: Total Price"))
+(define optname-row-address		(N_ "row: Bank Deposit Info"))
+(define optname-row-contact-top		(N_ "row: Contact at the top"))
+(define optname-row-contact-bottom	(N_ "row: Contact at the bottom"))
+(define optname-row-invoice-number	(N_ "row: Invoice Number"))
+(define optname-row-company-name	(N_ "row: Company Name"))
+(define optname-row-subtotals     	(N_ "row: Generic subtotals"))
+(define optname-report-currency		(N_ "Report Currency"))
+(define optname-invoice-number-text	(N_ "Invoice number text"))
+(define optname-to-text			(N_ "To text"))
+(define optname-ref-text		(N_ "Ref text"))
+(define optname-jobname-text		(N_ "Job Number text"))
+(define optname-jobnumber-text		(N_ "Job Name text"))
+(define optname-jobname-show		(N_ "Show Job name"))
+(define optname-jobnumber-show		(N_ "Show Job number"))
+(define optname-invnum-next-to-title	(N_ "Invoice number next to title"))
+(define optname-border-collapse		(N_ "table-border-collapse"))
+(define optname-border-color-th		(N_ "table-header-border-color"))
+(define optname-border-color-td		(N_ "table-cell-border-color"))
+(define optname-extra-css		(N_ "Embedded CSS"))
 (define optname-report-title   (N_ "Report title"))
 (define optname-invoice-number (N_ "Invoice number"))
 (define optname-template-file  (N_ "Template file"))
@@ -136,6 +167,29 @@
       "a" "" (lambda () '()) 
       #f))        ;customers-only)) ;-- see above
 
+(add-option (gnc:make-currency-option		gnc:pagename-general	optname-report-currency		"b" "" (N_ "")))
+
+  ;; Elements page options
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-col-date		"a" (N_ "Display the date?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-col-units		"b" (N_ "Display the Units?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-col-netprice		"c" (N_ "Display the Net Price as a column?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-col-taxrate		"d" (N_ "Display the Tax Rate as a column?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-col-taxamount		"e" (N_ "Display the Tax Amount as a column?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-col-totalprice		"f" (N_ "Display the Total Price as a column?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-netprice		"g" (N_ "Display the Net Price as a subtotal row?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-taxrate		"h" (N_ "Display the Tax Rate as a subtotal row?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-taxamount		"i" (N_ "Display the Tax Amount as a subtotal row?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-totalprice		"j" (N_ "Display the Total Price as a subtotal row?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-subtotals		"k" (N_ "Display the generic subtotals row?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-contact-top		"l" (N_ "Display the contact at the top?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-contact-bottom	"m" (N_ "Display the contact at the bottom?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-address		"n" (N_ "Display bank deposit info? (use company address field)") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-invoice-number	"o" (N_ "Display the Invoice Number?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-row-company-name	"p" (N_ "Display the Company Name?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-invnum-next-to-title	"q" (N_ "Invoice Number next to title?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-jobname-show		"r" (N_ "Display Job name?") #t))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-jobnumber-show		"s" (N_ "Invoice Job number?") #f))
+
   ;; Display options
   (add-option (gnc:make-string-option displaypage optname-template-file "a" 
     (N_ "The file name of the eguile template part of this report.  This file should either be in your .gnucash directory, or else in its proper place within the GnuCash installation directories.")
@@ -145,27 +199,30 @@
     "taxinvoice.css"))
   (add-option (gnc:make-font-option 
                 displaypage optname-heading-font "c" 
-                (N_ "Font to use for the main heading") "Sans Bold 18"))
+                (N_ "Font to use for the main heading") "Bank Gothic Medium 22"))
   (add-option (gnc:make-font-option 
                 displaypage optname-text-font "d" 
-                (N_ "Font to use for everything else") "Sans 10"))
+                (N_ "Font to use for everything else") "Courier New 8"))
   (add-option (gnc:make-pixmap-option
                 displaypage optname-logofile "e" 
                 (N_ "Name of a file containing a logo to be used on the report") 
                 ""))
   (add-option (gnc:make-string-option
                 displaypage optname-logo-width "f" (N_ "Width of the logo in CSS format, e.g. 10% or 32px.  Leave blank to display the logo at its natural width.  The height of the logo will be scaled accordingly.") ""))
+(add-option (gnc:make-simple-boolean-option	displaypage	optname-border-collapse	"g" (N_ "Border-collapse?") #t))
+(add-option (gnc:make-string-option		displaypage	optname-border-color-th "h" "CSS color" (N_ "black")))
+(add-option (gnc:make-string-option		displaypage	optname-border-color-td "i" "CSS color" (N_ "black")))
 
   ;; Heading options
   (add-option (gnc:make-string-option
                 ; page / name / orderkey / tooltip / default
-                headingpage optname-report-title "a" "" (_ "Invoice")))
+                headingpage optname-report-title "a" "" (_ "Tax Invoice")))
   (add-option (gnc:make-string-option
                 headingpage optname-units "b" "" (_ "Units")))
   (add-option (gnc:make-string-option
                 headingpage optname-qty "c" "" (_ "Qty")))
   (add-option (gnc:make-string-option
-                headingpage optname-unit-price "d" "" (_ "Unit Price")))
+                headingpage optname-unit-price "d" "" (_ "Unit")))
   (add-option (gnc:make-string-option
                 headingpage optname-disc-rate "e" "" (_ "Discount Rate")))
   (add-option (gnc:make-string-option
@@ -173,25 +230,37 @@
   (add-option (gnc:make-string-option
                 headingpage optname-net-price "g" "" (_ "Net Price")))
   (add-option (gnc:make-string-option
-                headingpage optname-tax-rate "h" "" (_ "Tax Rate")))
+                headingpage optname-tax-rate "h" "" (_ "GST Rate")))
   (add-option (gnc:make-string-option
-                headingpage optname-tax-amount "i" "" (_ "Tax Amount")))
+                headingpage optname-tax-amount "i" "" (_ "GST Amount")))
   (add-option (gnc:make-string-option
                 headingpage optname-total-price "j" "" (_ "Total Price")))
   (add-option (gnc:make-string-option
                 headingpage2 optname-subtotal "a" "" (_ "Sub-total")))
   (add-option (gnc:make-string-option
-                headingpage2 optname-amount-due "b" "" (_ "Amount Due")))
+                headingpage2 optname-amount-due "b" "" (_ "Amount Due (inc GST)")))
   (add-option (gnc:make-string-option
                 headingpage2 optname-payment-recd "c" "" 
-                (_ "Payment received, thank you")))
+                (_ "Payment received, thank you.")))
+  (add-option (gnc:make-string-option	headingpage2	optname-invoice-number-text
+    "d" "" (N_ "Invoice #:")))
+  (add-option (gnc:make-string-option	headingpage2	optname-to-text
+    "e" "" (N_ "To:")))
+  (add-option (gnc:make-string-option	headingpage2	optname-ref-text
+    "f" "" (N_ "Reference:")))
+  (add-option (gnc:make-string-option	headingpage2	optname-jobnumber-text
+    "g" "" (N_ "Job number:")))
+  (add-option (gnc:make-string-option	headingpage2	optname-jobname-text
+    "h" "" (N_ "Engagement:")))
 
   (add-option (gnc:make-text-option
                 notespage optname-extra-notes "a"
                 (_ "Notes added at end of invoice -- may contain HTML markup") 
-                ""))
+                "Sincerely yours,<br><br><br><br>"))
                 ;(N_ "(Development version -- don't rely on the numbers on this report without double-checking them.<br>Change the 'Extra Notes' option to get rid of this message)")))
 
+  (add-option (gnc:make-text-option	notespage optname-extra-css "b"
+                (N_ "Embedded CSS")	"h1.coyname { text-align: right; margin-bottom: 0px ; font-size: 200%; } h2.invoice { text-align: left; margin-bottom: 0px ; font-size: 500%; }"))
   (gnc:options-set-default-section
     report-options generalpage)
 
@@ -222,6 +291,29 @@
                                       (opt-value displaypage optname-text-font)))
          (opt-logofile              (opt-value displaypage  optname-logofile)) 
          (opt-logo-width            (opt-value displaypage  optname-logo-width)) 
+         (opt-col-date              (opt-value elementspage  optname-col-date))
+         (opt-col-taxrate           (opt-value elementspage  optname-col-taxrate))
+         (opt-col-taxamount         (opt-value elementspage  optname-col-taxamount))
+         (opt-col-netprice          (opt-value elementspage  optname-col-netprice))
+         (opt-col-totalprice        (opt-value elementspage  optname-col-totalprice))
+         (opt-row-taxrate           (opt-value elementspage  optname-row-taxrate))
+         (opt-row-taxamount         (opt-value elementspage  optname-row-taxamount))
+         (opt-row-netprice          (opt-value elementspage  optname-row-netprice))
+         (opt-row-totalprice        (opt-value elementspage  optname-row-totalprice))
+         (opt-row-subtotals         (opt-value elementspage  optname-row-subtotals))
+         (opt-col-units             (opt-value elementspage  optname-col-units))
+         (opt-row-contact-top       (opt-value elementspage  optname-row-contact-top))
+         (opt-row-contact-bottom    (opt-value elementspage  optname-row-contact-bottom))
+         (opt-row-address           (opt-value elementspage  optname-row-address))
+         (opt-row-invoice-number    (opt-value elementspage  optname-row-invoice-number))
+         (opt-row-company-name      (opt-value elementspage  optname-row-company-name))
+         (opt-invnum-next-to-title  (opt-value elementspage  optname-invnum-next-to-title))
+         (opt-jobname-show          (opt-value elementspage  optname-jobname-show))
+         (opt-jobnumber-show        (opt-value elementspage  optname-jobnumber-show))
+         (opt-report-currency       (opt-value gnc:pagename-general optname-report-currency))
+         (opt-css-border-collapse   (if (opt-value displaypage optname-border-collapse) "border-collapse:collapse;"))
+         (opt-css-border-color-th   (opt-value displaypage optname-border-color-th))
+         (opt-css-border-color-td   (opt-value displaypage optname-border-color-td))
          (opt-report-title          (opt-value headingpage  optname-report-title))
          (opt-units-heading         (opt-value headingpage  optname-units))
          (opt-qty-heading           (opt-value headingpage  optname-qty))
@@ -235,6 +327,12 @@
          (opt-subtotal-heading      (opt-value headingpage2 optname-subtotal))
          (opt-amount-due-heading    (opt-value headingpage2 optname-amount-due))
          (opt-payment-recd-heading  (opt-value headingpage2 optname-payment-recd))
+         (opt-invoice-number-text   (opt-value headingpage2 optname-invoice-number-text))
+         (opt-to-text		    (opt-value headingpage2 optname-to-text))
+         (opt-ref-text		    (opt-value headingpage2 optname-ref-text))
+         (opt-jobnumber-text	    (opt-value headingpage2 optname-jobnumber-text))
+         (opt-jobname-text	    (opt-value headingpage2 optname-jobname-text))
+         (opt-extra-css             (opt-value notespage    optname-extra-css)) 
          (opt-extra-notes           (opt-value notespage    optname-extra-notes)) 
          (css? #t) ;(and (defined? 'gnc-html-engine-supports-css) (gnc-html-engine-supports-css)))
          (html #f))
--- taxinvoice.eguile.scm-dist	2012-07-15 06:46:31.000000000 +1000
+++ taxinvoice.eguile.scm	2013-03-11 16:59:13.000000000 +1100
@@ -7,8 +7,10 @@
 ;; taxinvoice.eguile.scm  0.03
 ;; GnuCash report template called from taxinvoice.scm 0.02
 ;; (c) 2009 Chris Dennis chris@starsoftanalysis.co.uk
+;;  ©  2012 Dmitry Smirnov <onlyjob@member.fsf.org>
 ;;
 ;; $Author: chris $ $Date: 2009/07/23 10:42:08 $ $Revision: 1.33 $
+;; Modified by Dmitry Smirnov <onlyjob@member.fsf.org>  14 Feb 2012
 ;;
 ;; This file is a mixture of HTML and Guile --
 ;; see eguile-gnc.scm for details.
@@ -43,7 +45,7 @@
            (txn        (gncInvoiceGetPostedTxn  opt-invoice))
            (currency   (gncInvoiceGetCurrency   opt-invoice))
            (entries    (gncInvoiceGetEntries    opt-invoice))
-           (splits     '()) 
+           (splits     '());'
            (slots      (qof-book-get-slots book))
            (coyname    (coy-info slots gnc:*company-name*))
            (coycontact (coy-info slots gnc:*company-contact*))
@@ -53,7 +55,10 @@
            (coyfax     (coy-info slots gnc:*company-fax*))
            (coyurl     (coy-info slots gnc:*company-url*))
            (coyemail   (coy-info slots gnc:*company-email*))
-           (owneraddr  (gnc:owner-get-name-and-address-dep owner))
+           (owneraddr  (gnc:owner-get-address-dep owner))
+           (ownername  (gnc:owner-get-name-dep owner))
+           (jobnumber  (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner  opt-invoice))))
+           (jobname    (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner  opt-invoice))))
            (billcontact (gncAddressGetName (gnc:owner-get-address owner)))
            ; flags and counters
            (discount?  #f) ; any discounts on this invoice?
@@ -62,8 +67,7 @@
            (payments?  #f) ; have any payments been made on this invoice?
            (units?     #f) ; does any row specify units?
            (qty?       #f) ; does any row have qty <> 1?
-           (spancols1  2)  ; for total line
-           (spancols2  2)) ; for subtotal line
+           (tbl_cols   0)) ; number of columns for 'colspan' attributes
 
       ; load splits, if any
       (if (not (null? lot))
@@ -120,12 +124,19 @@
   }
   table { /* table does not inherit font */
     <?scm:d opt-text-font ?>
+    <?scm:d opt-css-border-collapse ?>
   }
+  table[border="1"] th {
+    border-color:<?scm:d opt-css-border-color-th ?>;
+  }
+  table[border="1"] td {
+    border-color:<?scm:d opt-css-border-color-td ?>;
+  }
+
   h1.coyname {
     <?scm:d opt-heading-font ?>
-    /* font-size: 141%; */
-    text-align: left;
   }
+  <?scm:d opt-extra-css ?>
 </style>
 <?scm )) ?>
 
@@ -137,36 +148,42 @@
 <!-- company info -->
 <table class="coytable" border="0" width="100%">
 <tr valign="top" style="vertical-align: top">
+  <td align="left" rowspan="3" width="25%">
+   <h2 class="invoice"><?scm:d opt-report-title ?><?scm (if opt-invnum-next-to-title (begin ?><?scm:d (nbsp opt-invoice-number-text) ?><?scm:d invoiceid ?><?scm )) ?></h2>
+  </td>
+
   <?scm (if (access? opt-logofile R_OK) (begin ?>
-    <td align="left">
+    <td align="left" rowspan="2">
       <img align="left" src="<?scm:d (make-file-url opt-logofile) ?>" alt="logo" class="logo"
         <?scm (if opt-logo-width (begin ?>
           style="width: <?scm:d opt-logo-width ?>"
         <?scm )) ?>
         >
     </td>
+  <?scm ) (begin ?>
+   <td rowspan="2">&nbsp;</td>
   <?scm )) ?>
-  <td align="left">
-    <h1 class="coyname"><?scm:d (or coyname (_ "Company Name")) ?></h1>
-  </td>
-  <td align="right"><h2 class="invoice"><?scm:d opt-report-title ?></h2></td>
-</tr>
-</table>
-<table border="0" width="100%">
-<tr valign="top">
-  <td align="left">
-    <?scm (if coycontact (begin ?>
-      <strong><?scm:d coycontact ?></strong><br>
-    <?scm )) ?>
-    <?scm (if coyaddr (begin ?>
-      <?scm:d (nl->br coyaddr) ?><br>
-    <?scm )) ?>
+  <td align="right"> <h1 class="coyname"><?scm:d (or coyname (_ "Company Name")) ?></h1>
     <?scm (if coyid (begin ?>
       <strong><?scm:d coyid ?></strong><br>
-    <?scm )) ?>
-  </td>
+    <?scm )) ?> </td>
+
+</tr>
+<tr valign="top">
   <td align="right">
     <table border="0">
+      <?scm (if (and opt-row-contact-top coycontact) (begin ?>
+        <tr>
+          <th colspan="2" align="right"><?scm:d coycontact ?></th>
+        </tr>
+      <?scm )) ?>
+      <?scm (if coyurl (begin ?>
+        <tr>
+          <td align="right">&nbsp;</td>
+          <td align="right"><p><?scm:d coyurl ?></p></td>
+        </tr>
+      <?scm )) ?>
+
       <?scm (if coyphone (begin ?>
         <tr>
           <td align="right"><?scm:d (_ "Phone") ?>:&nbsp;</td>
@@ -185,12 +202,6 @@
           <td align="right"><?scm:d coyemail ?></td>
         </tr>
       <?scm )) ?>
-      <?scm (if coyurl (begin ?>
-        <tr>
-          <td align="right"><?scm:d (_ "Website") ?>:&nbsp;</td>
-          <td align="right"><?scm:d coyurl ?></td>
-        </tr>
-      <?scm )) ?>
     </table>
 </tr>    
 </table>
@@ -199,79 +210,103 @@
 <table border="0" width="100%">
 <tr valign="top">
   <!-- customer info -->
+  <th align="right" width="1%"><?scm:d opt-to-text ?></th>
   <td align="left">
-    <?scm (if (not (string=? billcontact "")) (begin ?>
-      <strong>Attn: <?scm:d billcontact ?></strong><br>
+    <?scm (if (and opt-row-company-name (not (string=? ownername ""))) (begin ?>
+        <?scm:d ownername ?><br>
     <?scm )) ?>
     <?scm (if (not (string=? owneraddr "")) (begin ?>
-      <strong><?scm:d (nl->br owneraddr) ?></strong>
+      <?scm:d (nl->br owneraddr) ?>
     <?scm )) ?>
   </td>
   <!-- invoice number etc. -->
   <td align="right">
     <table border="0">
+      <?scm (if opt-row-invoice-number (begin ?>
       <tr>
-        <td align="right" class="invnum"><big><strong><?scm:d (nbsp (_ "Invoice Number")) ?>:</strong></big>&nbsp;</td>
+        <td align="right" class="invnum"><big><strong><?scm:d (nbsp opt-invoice-number-text) ?></strong></big></td>
         <td align="right" class="invnum"><big><strong><?scm:d invoiceid ?></strong></big></td>
       </tr>
+      <?scm )) ?>
       <?scm (if (equal? postdate (cons 0 0)) (begin ?>
         <tr>
            <td colspan="2" align="right"><?scm:d (_ "Invoice in progress...") ?></td>
         </tr>
       <?scm ) (begin ?>
         <tr>
-           <td align="right"><?scm:d (nbsp (_ "Invoice Date")) ?>:&nbsp;</td>
+           <td align="right"><?scm:d (nbsp (_ "Invoice Date")) ?>:</td>
            <td align="right"><?scm:d (gnc-print-date postdate) ?></td>
         </tr>
         <tr>
-           <td align="right"><?scm:d (nbsp (_ "Due Date")) ?>:&nbsp;</td>
+           <td align="right"><?scm:d (nbsp (_ "Due Date")) ?>:</td>
            <td align="right"><?scm:d (gnc-print-date duedate) ?></td>
         </tr>
+        <?scm (if (not (string=? billingid "")) (begin ?>
+          <tr>
+            <td align="right"><?scm:d opt-ref-text ?></td>
+            <td align="right"><?scm:d billingid ?></td>
+          </tr>
+        <?scm )) ?>
+        <?scm (if (and opt-jobname-show (not (string=? jobname ""))) (begin ?>
+          <tr>
+            <td align="right"><?scm:d opt-jobname-text ?></td>
+            <td align="right"><?scm:d jobname ?></td>
+          </tr>
+        <?scm )) ?>
+        <?scm (if (and opt-jobnumber-show (not (string=? jobnumber ""))) (begin ?>
+          <tr>
+            <td align="right"><?scm:d opt-jobnumber-text ?></td>
+            <td align="right"><?scm:d jobnumber ?></td>
+          </tr>
+        <?scm )) ?>
       <?scm )) ?>
       <?scm (if (not (string=? termsdesc "")) (begin ?>
-        <tr><td colspan="2" align="right"><?scm:d termsdesc ?></td></tr>
+          <tr>
+            <td align="right">Terms:</td>
+            <td align="right"><?scm:d termsdesc ?></td>
+          </tr>
       <?scm )) ?>
     </table>
   </td>
 </tr>
-<?scm (if (not (string=? billingid "")) (begin ?>
-  <tr>
-    <td>Your ref: <?scm:d billingid ?></td>
-  </tr>
-<?scm )) ?>
 </table>
 
 <!-- invoice lines table -->
 <p>
 <table border="1" width="100%" cellpadding="4" class="entries"> 
   <thead>
-    <tr bgcolor="#ccc" valign="bottom">
+    <tr bgcolor="#dcf0f7" valign="bottom">
+      <?scm (if opt-col-date (begin ?>
       <th align="center" ><?scm:d (_ "Date") ?></th>
+      <?scm (set! tbl_cols (+ tbl_cols 1)) )) ?>
       <th align="left" width="80%"><?scm:d (_ "Description") ?></th>
-      <?scm (if units? (begin ?>
+      <?scm (set! tbl_cols (+ tbl_cols 1)) ?>
+      <?scm (if (and units? opt-col-units) (begin ?>
         <th align="left"><?scm:d opt-units-heading ?></th>
-        <?scm (set! spancols1 (+ spancols1 1)) 
-              (set! spancols2 (+ spancols2 1)))) ?>
+      <?scm (set! tbl_cols (+ tbl_cols 1)) )) ?>
       <?scm (if (or units? qty?) (begin ?>
         <th align="right"><?scm:d opt-qty-heading ?></th>
-        <?scm (set! spancols1 (+ spancols1 1)) 
-              (set! spancols2 (+ spancols2 1)))) ?>
+      <?scm (set! tbl_cols (+ tbl_cols 1)) )) ?>
       <?scm (if (or units? qty? discount?) (begin ?>
         <th align="right"><?scm:d opt-unit-price-heading ?></th>
-        <?scm (set! spancols1 (+ spancols1 1)) 
-              (set! spancols2 (+ spancols2 1)))) ?>
+      <?scm (set! tbl_cols (+ tbl_cols 1)) )) ?>
       <?scm (if discount? (begin ?>
         <th align="right"><?scm:d opt-disc-rate-heading ?></th>
         <th align="right"><?scm:d opt-disc-amount-heading ?></th>
-        <?scm (set! spancols1 (+ spancols1 2)) 
-              (set! spancols2 (+ spancols2 1)))) ?>
+      <?scm (set! tbl_cols (+ tbl_cols 2)) )) ?>
       <?scm (if (and tax? taxtables?) (begin ?>
+        <?scm (if opt-col-netprice (begin ?>
         <th align="right"><?scm:d opt-net-price-heading ?></th>
+        <?scm (set! tbl_cols (+ tbl_cols 1)) ))?>
+        <?scm (if opt-col-taxrate (begin ?>
         <th align="right"><?scm:d opt-tax-rate-heading ?></th>
+        <?scm (set! tbl_cols (+ tbl_cols 1)) )) ?>
+	<?scm (if opt-col-taxamount (begin ?>
         <th align="right"><?scm:d opt-tax-amount-heading ?></th>
-        <?scm (set! spancols1 (+ spancols1 3))
-              (set! spancols2 (+ spancols2 0)))) ?>
-      <th align="right"><?scm:d opt-total-price-heading ?></th>
+      <?scm (set! tbl_cols (+ tbl_cols 1)) )))) ?>
+      <?scm (if opt-col-totalprice (begin ?>
+        <th align="right"><?scm:d opt-total-price-heading ?></th>
+      <?scm (set! tbl_cols (+ tbl_cols 1)) )) ?>
     </tr>
   </thead>
 
@@ -280,6 +315,8 @@
       (let ((tax-total (gnc:make-commodity-collector))
             (sub-total (gnc:make-commodity-collector))
             (dsc-total (gnc:make-commodity-collector))
+	    ; TODO figure out a way not to hard code this
+            (taxrate-val (_ "10%"))
             (inv-total (gnc:make-commodity-collector)))
         (for entry in entries do
             (let ((qty       (gncEntryGetQuantity entry))
@@ -293,19 +330,25 @@
                   (acc       (gncEntryGetInvAccount entry))
                   (taxable   (gncEntryGetInvTaxable entry))
                   (taxtable  (gncEntryGetInvTaxTable entry)))
+              (sub-total 'add currency rval)
               (inv-total 'add currency rval)
               (inv-total 'add currency rtaxval)
               (tax-total 'add currency rtaxval)
-              (sub-total 'add currency rval)
-              (dsc-total 'add currency rdiscval)
+	      ; TODO figure out a way to fix this so it works
+              ;( set! taxrate-val (taxrate taxable taxtable currency))
+              (dsc-total 'add currency rdiscval);'
     ?>
     <tr valign="top">
-      <td align="center"><?scm:d (gnc-print-date (gncEntryGetDate entry)) ?></td>
+      <?scm (if opt-col-date (begin ?>
+      <td align="center"><?scm:d (nbsp (gnc-print-date (gncEntryGetDate entry))) ?></td>
+      <?scm )) ?>
       <td align="left"><?scm:d (gncEntryGetDescription entry) ?></td>
       <!-- td align="left">< ?scm:d (gncEntryGetNotes entry) ?></td -->
+      <?scm (if opt-col-units (begin ?>
       <?scm (if units? (begin ?>
         <td align="left"><?scm:d action ?></td>
       <?scm )) ?>
+      <?scm )) ?>
       <?scm (if (or units? qty?) (begin ?>
         <td align="right"><?scm:d (fmtnumeric qty) ?></td>
       <?scm )) ?>
@@ -321,32 +364,98 @@
         <td align="right"><?scm:d (fmtmoney currency rdiscval) ?></td>
       <?scm )) ?>
       <?scm (if (and tax? taxtables?) (begin ?>
-        <td align="right"><?scm:d (fmtmoney currency rval) ?></td>
-        <td align="right"><?scm (taxrate taxable taxtable currency) ?></td>  
-        <td align="right"><?scm:d (fmtmoney currency rtaxval) ?></td>
+        <?scm (if opt-col-netprice (begin ?>
+          <td align="right"><?scm:d (fmtmoney currency rval) ?></td>
+        <?scm )) ?>
+        <?scm (if opt-col-taxrate (begin ?>
+          <td align="right"><?scm (taxrate taxable taxtable currency) ?></td>  
+        <?scm )) ?>
+        <?scm (if opt-col-taxamount (begin ?>
+          <td align="right"><?scm:d (fmtmoney currency rtaxval) ?></td>
+        <?scm )) ?>
       <?scm )) ?>
       <!-- TO DO: need an option about whether to display the tax-inclusive total? -->
+      <!-- WORKAROUND: Can now select whether to display net price, total price, both, or neither. -->
+        <?scm (if opt-col-totalprice (begin ?>
       <td align="right"><?scm:d (fmtmoney currency (gnc-numeric-add rval rtaxval GNC-DENOM-AUTO GNC-RND-ROUND)) ?></td>
+        <?scm )) ?>
     </tr>
     <?scm )) ?>
 
-    <!-- display subtotals row -->
-    <?scm (if (or tax? discount? payments?) (begin ?>
+    <!-- insert blank row -->
+    <tr>
+    <?scm (let lp ((x (- tbl_cols 1))) (begin ?>
+     <td>&nbsp;</td>
+    <?scm ) (if (positive? x) (lp (- x 1)) x)) ?>
+    </tr>
+
+    <!-- generic subtotals row -->
+    <?scm (if (and (or tax? discount? payments?) opt-row-subtotals) (begin ?>
       <tr valign="top"> 
-        <td align="left" class="subtotal" colspan="<?scm:d spancols2 ?>"><strong><?scm:d opt-subtotal-heading ?></strong></td>
+        <td align="left" class="subtotal" colspan="<?scm:d 
+        (- tbl_cols (if (and tax? taxtables? opt-col-taxrate) 1 0)
+                    (if (and tax? taxtables? opt-col-taxamount) 1 0)
+                    (if (and tax? taxtables? opt-col-netprice) 1 0)
+                    (if (and tax? taxtables? opt-col-totalprice) 1 0)
+                    (if (and discount?) 1 0)
+        ) ?>"><?scm:d opt-subtotal-heading ?></td>
         <?scm (if discount? (begin ?>
-          <td align="right" class="subtotal"><strong><?scm (display-comm-coll-total dsc-total #f) ?></strong></td>
+          <td align="right" class="subtotal"><?scm (display-comm-coll-total dsc-total #f) ?></td>
         <?scm )) ?>
         <?scm (if (and tax? taxtables?) (begin ?>
-          <td align="right" class="subtotal"><strong><?scm (display-comm-coll-total sub-total #f) ?></strong></td>
+          <?scm (if opt-col-netprice (begin ?>
+          <td align="right" class="subtotal"><?scm (display-comm-coll-total sub-total #f) ?></td>
+          <?scm )) ?>
+          <?scm (if opt-col-taxrate (begin ?>
           <td>&nbsp;</td>
-          <td align="right" class="subtotal"><strong><?scm (display-comm-coll-total tax-total #f) ?></strong></td>
+          <?scm )) ?>
+          <?scm (if opt-col-taxamount (begin ?>
+          <td align="right" class="subtotal"><?scm (display-comm-coll-total tax-total #f) ?></td>
+          <?scm )) ?>
+        <?scm )) ?>
+        <?scm (if opt-col-totalprice (begin ?>
+          <td align="right" class="subtotal"><?scm (display-comm-coll-total inv-total #f) ?></td>
         <?scm )) ?>
-        <td align="right" class="subtotal"><strong><?scm (display-comm-coll-total inv-total #f) ?></strong></td>
       </tr>
     <?scm )) ?>
 
-    <!-- payments -->
+    <!-- net price subtotal row -->
+    <?scm (if opt-row-netprice (begin ?>
+    <tr valign="top">
+      <td align="left" class="total" colspan="<?scm:d (- tbl_cols 1) ?>">
+        <?scm:d opt-net-price-heading ?></td>
+      <td align="right" class="total"><?scm (display-comm-coll-total sub-total #f) ?></td>  
+    </tr>
+    <?scm )) ?>
+
+    <!-- tax rate subtotal row -->
+    <?scm (if (and tax? taxtables? opt-row-taxrate) (begin ?>
+    <tr valign="top">
+      <td align="left" class="subtotal" colspan="<?scm:d (- tbl_cols 1) ?>">
+        <?scm:d opt-tax-rate-heading ?></td>
+      <td align="right" class="subtotal"><?scm:d taxrate-val ?></td>  
+    </tr>
+    <?scm )) ?>
+
+    <!-- tax amount subtotal row -->
+    <?scm (if opt-row-taxamount (begin ?>
+    <tr valign="top">
+      <td align="left" class="subtotal" colspan="<?scm:d (- tbl_cols 1) ?>">
+        <?scm:d opt-tax-amount-heading ?></td>
+      <td align="right" class="subtotal"><?scm (display-comm-coll-total tax-total #f) ?></td>  
+    </tr>
+    <?scm )) ?>
+
+    <!-- total amount subtotal row -->
+    <?scm (if opt-row-totalprice (begin ?>
+    <tr valign="top">
+      <td align="left" class="total" colspan="<?scm:d (- tbl_cols 1) ?>">
+        <?scm:d opt-total-price-heading ?></td>
+      <td align="right" class="total"><?scm (display-comm-coll-total inv-total #f) ?></td>  
+    </tr>
+    <?scm )) ?>
+
+    <!-- payments row -->
     <?scm 
       (if payments? 
         (for split in splits do
@@ -356,25 +465,40 @@
                       (a (xaccSplitGetValue    split))) 
                   (inv-total 'add c a) 
     ?>
-    <tr valign="top">
+    <tr valign="top" bgcolor="#f9f6f4">
+      <?scm (if opt-col-date (begin ?>
       <td align="center"><?scm:d (gnc-print-date (gnc-transaction-get-date-posted t)) ?></td>
-      <td align="left" colspan="<?scm:d (- spancols1 1) ?>"><?scm:d opt-payment-recd-heading ?></td> 
+      <?scm )) ?>
+      <td align="left" colspan="<?scm:d (- tbl_cols (if opt-col-date 2 1)) ?>"><?scm:d opt-payment-recd-heading ?></td>
       <td align="right"><?scm:d (fmtmoney c a) ?></td>
     </tr>
     <?scm ))))) ?>
 
     <!-- total row -->
-    <tr valign="top">
-      <td align="left" class="total" colspan="<?scm:d spancols1 ?>"><strong><?scm:d opt-amount-due-heading ?></strong></td>
-      <td align="right" class="total"><strong><?scm (display-comm-coll-total inv-total #f) ?></strong></td>
+    <tr valign="top" bgcolor="#dcf0f7">
+      <td align="left" class="total" colspan="<?scm:d (- tbl_cols 1) ?>">
+        <?scm:d opt-amount-due-heading ?><?scm (if (not (string=? (gnc-commodity-get-mnemonic opt-report-currency) "")) (begin ?>,
+        <?scm:d (gnc-commodity-get-mnemonic opt-report-currency) ?><?scm )) ?></td>
+      <td align="right" class="total"><?scm (display-comm-coll-total inv-total #f) ?></td>
     </tr>
 
   </tbody>
   <?scm ) ?> <!-- end of (let) surrounding table body -->
 </table>
  
-<p><?scm:d (nl->br notes) ?>
+<p>&nbsp;</p>
+<p><?scm:d (nl->br notes) ?>&nbsp;</p>
+<p>&nbsp;</p>
+<p><?scm (if (and opt-row-address coyaddr) (begin ?>
+      <?scm:d (nl->br coyaddr) ?>
+    <?scm )) ?>
+</p>
+<p>&nbsp;</p>
 <p><?scm:d (nl->br opt-extra-notes) ?>
+<?scm (if (and opt-row-contact-bottom coycontact) (begin ?>
+   <?scm:d coycontact ?>
+<?scm )) ?>
+</p>
 
 <?scm )) ; end of display-report function
     
--- taxinvoice.css-dist	2012-07-15 06:46:31.000000000 +1000
+++ taxinvoice.css	2013-03-11 16:52:36.000000000 +1100
@@ -35,7 +35,7 @@
     empty-cells: show;
   }
   table.entries th {
-    background: #ccc;
+ /*   background: #ccc; */
     font-weight: bold;
     padding: 0.2em 0.4em;
   }
@@ -47,10 +47,10 @@
     font-weight: bold;
   }
   td.subtotal {
-    font-weight: bold;
+    /* font-weight: bold; */
   }
   td.total {
-    font-size: 110%;
+    font-size: 120%;
     font-weight: bold;
   }
   table.coytable td, table.coytable tr {
