r18686 - gnucash/trunk/src/business/business-reports - Fix bug #564380 additionally for easy invoice and fancy invoice.

Geert Janssens gjanssens at code.gnucash.org
Fri Feb 19 12:03:06 EST 2010


Author: gjanssens
Date: 2010-02-19 12:03:06 -0500 (Fri, 19 Feb 2010)
New Revision: 18686
Trac: http://svn.gnucash.org/trac/changeset/18686

Modified:
   gnucash/trunk/src/business/business-reports/easy-invoice.scm
   gnucash/trunk/src/business/business-reports/fancy-invoice.scm
Log:
Fix bug #564380 additionally for easy invoice and fancy invoice.
Patch by Mike Evans.

Modified: gnucash/trunk/src/business/business-reports/easy-invoice.scm
===================================================================
--- gnucash/trunk/src/business/business-reports/easy-invoice.scm	2010-02-18 16:22:23 UTC (rev 18685)
+++ gnucash/trunk/src/business/business-reports/easy-invoice.scm	2010-02-19 17:03:06 UTC (rev 18686)
@@ -422,14 +422,29 @@
     (define (add-payment-row table used-columns split total-collector)
       (let* ((t (xaccSplitGetParent split))
 	     (currency (xaccTransGetCurrency t))
+	     (invoice (opt-val invoice-page invoice-name))
+	     (owner '())
 	     ;; XXX Need to know when to reverse the value
 	     (amt (gnc:make-gnc-monetary currency (xaccSplitGetValue split)))
 	     (payment-style "grand-total")
 	     (row '()))
 	
-	(total-collector 'add 
-			 (gnc:gnc-monetary-commodity amt)
-			 (gnc:gnc-monetary-amount amt))
+	; Update to fix bug 564380, payment on bill doubles bill. Mike Evans <mikee at saxicola.co.uk>
+	(if (not (null? invoice))
+	(begin
+	  (set! owner (gncInvoiceGetOwner invoice))
+	  (let ((type (gncOwnerGetType
+                       (gncOwnerGetEndOwner owner))))
+	    (cond
+	      ((eqv? type GNC-OWNER-CUSTOMER)
+	       (total-collector 'add 
+			  (gnc:gnc-monetary-commodity amt)
+			 (gnc:gnc-monetary-amount amt)))
+	      ((eqv? type GNC-OWNER-VENDOR)
+	       (total-collector 'add 
+			  (gnc:gnc-monetary-commodity amt)
+			 (gnc:gnc-monetary-amount (gnc:monetary-neg amt))))
+	      ))))
 
 	(if (date-col used-columns)
 	    (addto! row

Modified: gnucash/trunk/src/business/business-reports/fancy-invoice.scm
===================================================================
--- gnucash/trunk/src/business/business-reports/fancy-invoice.scm	2010-02-18 16:22:23 UTC (rev 18685)
+++ gnucash/trunk/src/business/business-reports/fancy-invoice.scm	2010-02-19 17:03:06 UTC (rev 18686)
@@ -439,15 +439,31 @@
     (define (add-payment-row table used-columns split total-collector)
       (let* ((t (xaccSplitGetParent split))
 	     (currency (xaccTransGetCurrency t))
+	     (invoice (opt-val invoice-page invoice-name))
+	     (owner '())
 	     ;; XXX Need to know when to reverse the value
 	     (amt (gnc:make-gnc-monetary currency (xaccSplitGetValue split)))
 	     (payment-style "grand-total")
 	     (row '()))
-	
-	(total-collector 'add 
-			 (gnc:gnc-monetary-commodity amt)
-			 (gnc:gnc-monetary-amount amt))
+	     
+	; Update to fix bug 564380, payment on bill doubles bill. Mike Evans <mikee at saxicola.co.uk>
+	(if (not (null? invoice))
+	(begin
+	  (set! owner (gncInvoiceGetOwner invoice))
+	  (let ((type (gncOwnerGetType
+                       (gncOwnerGetEndOwner owner))))
+	    (cond
+	      ((eqv? type GNC-OWNER-CUSTOMER)
+	       (total-collector 'add 
+			  (gnc:gnc-monetary-commodity amt)
+			 (gnc:gnc-monetary-amount amt)))
+	      ((eqv? type GNC-OWNER-VENDOR)
+	       (total-collector 'add 
+			  (gnc:gnc-monetary-commodity amt)
+			 (gnc:gnc-monetary-amount (gnc:monetary-neg amt))))
+	      ))))
 
+
 	(if (date-col used-columns)
 	    (addto! row
 		    (gnc-print-date (gnc-transaction-get-date-posted t))))



More information about the gnucash-changes mailing list