;; ;; $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)) (credit-note? (gncInvoiceGetIsCreditNote 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 '()) (coyname (gnc:company-info book gnc:*company-name*)) (coycontact (gnc:company-info book gnc:*company-contact*)) (coyaddr (gnc:company-info book gnc:*company-addy*)) (coyid (gnc:company-info book gnc:*company-id*)) (coyphone (gnc:company-info book gnc:*company-phone*)) (coyfax (gnc:company-info book gnc:*company-fax*)) (coyurl (gnc:company-info book gnc:*company-url*)) (coyemail (gnc:company-info book 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))) (< (gnc-transaction-get-date-posted t1) (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 (gncEntryGetDocQuantity entry credit-note?)) (discount (gncEntryGetInvDiscount entry)) (taxable? (gncEntryGetInvTaxable 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 taxable? ; Also check if the taxable flag is set (if (not (eq? taxtable '())) (begin ; presence of a tax table AND taxable flag means it's taxed (set! tax? #t)))))) ; 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)))) ?>