;; ;; $Author: chris $ $Date: 2009/07/23 10:42:08 $ $Revision: 1.33 $ ;; Modified by Dmitry Smirnov 16 Feb 2012 ;; ;; This file is a mixture of HTML and Guile -- ;; see eguile-gnc.scm for details. ;; ;; 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, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ;; 02111-1307 USA (define (display-report opt-invoice owner endowner ownertype) ;; Main function that creates the tax invoice report (let* (; invoice and company details (invoiceid (gncInvoiceGetID opt-invoice)) (book (gncInvoiceGetBook opt-invoice)) (postdate (gncInvoiceGetDatePosted opt-invoice)) (duedate (gncInvoiceGetDateDue opt-invoice)) (billingid (gncInvoiceGetBillingID opt-invoice)) (notes (gncInvoiceGetNotes opt-invoice)) (terms (gncInvoiceGetTerms opt-invoice)) (termsdesc (gncBillTermGetDescription terms)) (lot (gncInvoiceGetPostedLot opt-invoice)) (txn (gncInvoiceGetPostedTxn opt-invoice)) (currency (gncInvoiceGetCurrency opt-invoice)) (entries (gncInvoiceGetEntries opt-invoice)) (splits '()) (slots (qof-book-get-slots book)) (coyname (coy-info slots gnc:*company-name*)) (coycontact (coy-info slots gnc:*company-contact*)) (coyaddr (coy-info slots gnc:*company-addy*)) (coyid (coy-info slots gnc:*company-id*)) (coyphone (coy-info slots gnc:*company-phone*)) (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-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? (tax? #f) ; any taxable entries on this invoice? (taxtables? #t) ; are tax tables available in this version? (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? (tbl_cols 0)) ; number of columns for 'colspan' attributes ; load splits, if any (if (not (null? lot)) (set! splits (sort-list (gnc-lot-get-split-list lot) ; sort by date (lambda (s1 s2) (let ((t1 (xaccSplitGetParent s1)) (t2 (xaccSplitGetParent s2))) (< (car (gnc-transaction-get-date-posted t1)) (car (gnc-transaction-get-date-posted t2)))))))) ; pre-scan invoice entries to look for discounts and taxes (for entry in entries do (let ((action (gncEntryGetAction entry)) (qty (gncEntryGetQuantity entry)) (discount (gncEntryGetInvDiscount entry)) (taxtable (gncEntryGetInvTaxTable entry))) (if (not (string=? action "")) (set! units? #t)) (if (not (= (gnc-numeric-to-double qty) 1.0)) (set! qty? #t)) (if (not (gnc-numeric-zero-p discount)) (set! discount? #t)) ;(if taxable - no, this flag is redundant (if (not (eq? taxtable '())) (begin ; presence of a tax table means it's taxed (set! tax? #t) (let ((ttentries (gncTaxTableGetEntries taxtable))) (if (string-prefix? "#string ttentries)) ; error in SWIG binding -- disable display of tax details ; (see http://bugzilla.gnome.org/show_bug.cgi?id=573645) (set! taxtables? #f))))))) ; hack required until Swig is fixed ; pre-scan invoice splits to see if any payments have been made (for split in splits do (let* ((t (xaccSplitGetParent split))) (if (not (equal? t txn)) (set! payments? #t)))) ?> <?scm:d (_ "Invoice") ?> <?scm:d invoiceid ?>
style="width: " >

br coyaddr) ?>

br owneraddr) ?>

string (gnc:make-gnc-monetary currency disc)) ?> %

br notes) ?>

br opt-extra-notes) ?> " (_ "Tax Invoice") "")) (display (string-append "

" (_ "No invoice has been selected -- please use the Options menu to select one.") "

"))) (let* ((owner (gncInvoiceGetOwner opt-invoice)) (endowner (gncOwnerGetEndOwner owner)) (ownertype (gncOwnerGetType endowner))) (if (not (eqv? ownertype GNC-OWNER-CUSTOMER)) (begin (display (string-append "

" (_ "Tax Invoice") "

")) (display (string-append "

" (_ "This report is designed for customer (sales) invoices only. Please use the Options menu to select an Invoice, not a Bill or Expense Voucher.") "

"))) (display-report opt-invoice owner endowner ownertype)))) ?>