From c917663ad35a7b5b61dae289fbe7486802e0cbdf Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Thu, 4 Jul 2002 15:31:55 +0000 Subject: [PATCH] * business-core.scm: fix a typo * business-options.c: implement invoice option for the dialog * gncEntryLedgerLoad.c: fix a compiler warning * invoice.scm: make report visible; deal with no invoice; make invoice a visible option on the general page; deal with "printing" un-posted invoices. * receivables.scm: remove code I don't need git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7085 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 8 + src/business/business-core/business-core.scm | 2 +- .../business-gnome/business-options.c | 80 ++++++++- .../business-ledger/gncEntryLedgerLoad.c | 2 +- src/business/business-reports/invoice.scm | 169 ++++++++++-------- src/business/business-reports/receivables.scm | 3 - 6 files changed, 184 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea4700dca5..0d2bf52c76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,14 @@ * business-utils: pack into box FALSE, not TRUE * owner-report: put the company into the options dialog instead of hiding it. + + * business-core.scm: fix a typo + * business-options.c: implement invoice option for the dialog + * gncEntryLedgerLoad.c: fix a compiler warning + * invoice.scm: make report visible; deal with no invoice; make + invoice a visible option on the general page; deal with "printing" + un-posted invoices. + * receivables.scm: remove code I don't need 2002-07-03 Derek Atkins diff --git a/src/business/business-core/business-core.scm b/src/business/business-core/business-core.scm index 49f9949244..b9421d22d7 100644 --- a/src/business/business-core/business-core.scm +++ b/src/business/business-core/business-core.scm @@ -96,7 +96,7 @@ (else "")))) (define (gnc:entry-type-percent-p type-val) - (let ((type (gw:enum--val->sym type #f))) + (let ((type (gw:enum--val->sym type-val #f))) (equal? type 'gnc-amount-type-percent))) (define (gnc:owner-from-split split result-owner) diff --git a/src/business/business-gnome/business-options.c b/src/business/business-gnome/business-options.c index 6420a1b23c..a3346323ab 100644 --- a/src/business/business-gnome/business-options.c +++ b/src/business/business-gnome/business-options.c @@ -14,13 +14,15 @@ #include "gnc-ui-util.h" #include "gnc-engine-util.h" #include "option-util.h" +#include "gnc-general-search.h" #include "dialog-options.h" #include "business-options.h" #include "business-utils.h" +#include "dialog-invoice.h" static int -owner_changed_cb (GtkWidget *widget, gpointer data) +option_changed_cb (GtkWidget *widget, gpointer data) { GNCOption *option = data; @@ -56,7 +58,7 @@ create_owner_widget (GNCOption *option, GncOwnerType type, GtkWidget *hbox) gnc_option_set_widget (option, widget); gtk_signal_connect (GTK_OBJECT (widget), "changed", - GTK_SIGNAL_FUNC (owner_changed_cb), option); + GTK_SIGNAL_FUNC (option_changed_cb), option); return widget; } @@ -276,6 +278,79 @@ vendor_get_value (GNCOption *option, GtkWidget *widget) gh_eval_str("")); } +/********************************************************************/ +/* "Invoice" Option functions */ + + +static GtkWidget * +create_invoice_widget (GNCOption *option, GtkWidget *hbox) +{ + GtkWidget *widget; + + widget = gnc_general_search_new (GNC_INVOICE_MODULE_NAME, + _("Select..."), + gnc_invoice_search_select, + gnc_get_current_book ()); + + gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); + gnc_option_set_widget (option, widget); + gtk_signal_connect (GTK_OBJECT (widget), "changed", + GTK_SIGNAL_FUNC (option_changed_cb), option); + + return widget; +} + +/* Function to set the UI widget based upon the option */ +static GtkWidget * +invoice_set_widget (GNCOption *option, GtkBox *page_box, + GtkTooltips *tooltips, + char *name, char *documentation, + /* Return values */ + GtkWidget **enclosing, gboolean *packed) +{ + GtkWidget *value; + GtkWidget *label; + + *enclosing = gtk_hbox_new (FALSE, 5); + label = make_name_label (name); + gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0); + + value = create_invoice_widget (option, *enclosing); + + gnc_option_set_ui_value (option, FALSE); + + gtk_widget_show_all (*enclosing); + return value; +} + +/* Function to set the UI Value for a particular option */ +static gboolean +invoice_set_value (GNCOption *option, gboolean use_default, + GtkWidget *widget, SCM value) +{ + GncInvoice *invoice; + + if (!gw_wcp_p (value)) + scm_misc_error("business_options:invoice_set_value", + "Item is not a gw:wcp.", value); + + invoice = gw_wcp_get_ptr (value); + + widget = gnc_option_get_widget (option); + gnc_general_search_set_selected (GNC_GENERAL_SEARCH (widget), invoice); + return FALSE; +} + +/* Function to get the UI Value for a particular option */ +static SCM +invoice_get_value (GNCOption *option, GtkWidget *widget) +{ + GncInvoice *invoice; + + invoice = gnc_general_search_get_selected (GNC_GENERAL_SEARCH (widget)); + return gw_wcp_assimilate_ptr (invoice, gh_eval_str("")); +} + @@ -288,6 +363,7 @@ gnc_business_options_initialize (void) { "customer", customer_set_widget, customer_set_value, customer_get_value }, { "vendor", vendor_set_widget, vendor_set_value, vendor_get_value }, + { "invoice", invoice_set_widget, invoice_set_value, invoice_get_value }, { NULL } }; diff --git a/src/business/business-ledger/gncEntryLedgerLoad.c b/src/business/business-ledger/gncEntryLedgerLoad.c index d2349243f0..d71ee863c4 100644 --- a/src/business/business-ledger/gncEntryLedgerLoad.c +++ b/src/business/business-ledger/gncEntryLedgerLoad.c @@ -197,7 +197,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list) GncOwner *owner = gncInvoiceGetOwner (ledger->invoice); GncTaxTable *table = NULL; GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL; - gboolean taxincluded; + gboolean taxincluded = FALSE; gnc_numeric discount = gnc_numeric_zero (); owner = gncOwnerGetEndOwner (owner); diff --git a/src/business/business-reports/invoice.scm b/src/business/business-reports/invoice.scm index 9e28cabc22..91c47049e3 100644 --- a/src/business/business-reports/invoice.scm +++ b/src/business/business-reports/invoice.scm @@ -16,6 +16,9 @@ (gnc:module-load "gnucash/report/report-system" 0) (gnc:module-load "gnucash/business-gnome" 0) +(define invoice-page gnc:pagename-general) +(define invoice-name (N_ "Invoice Number")) + (define-macro (addto! alist element) `(set! ,alist (cons ,element ,alist))) @@ -196,7 +199,7 @@ (gnc:register-option gnc:*report-options* new-option)) (gnc:register-inv-option - (gnc:make-invoice-option "__reg" "invoice" "" "" + (gnc:make-invoice-option invoice-page invoice-name "x" "" (lambda () #f) #f)) (gnc:register-inv-option @@ -504,113 +507,133 @@ (let* ((document (gnc:make-html-document)) (table '()) (orders '()) - (invoice (opt-val "__reg" "invoice")) - (owner (gnc:invoice-get-owner invoice)) - (entries (gnc:invoice-get-entries invoice)) + (invoice (opt-val invoice-page invoice-name)) + (owner #f) + (entries #f) (references? (opt-val "Display" "References")) - (title (string-append (_ "Invoice #") (gnc:invoice-get-id invoice)))) + (title (_ "Invoice"))) (define (add-order o) (if (and references? (not (member o orders))) (addto! orders o))) - (set! table (make-entry-table entries - (gnc:report-options report-obj) - add-order)) + (if invoice + (begin + (set! owner (gnc:invoice-get-owner invoice)) + (set! entries (gnc:invoice-get-entries invoice)) + (set! title (string-append title " #" + (gnc:invoice-get-id invoice))))) (gnc:html-document-set-title! document title) - (gnc:html-table-set-style! - table "table" - 'attribute (list "border" 1) - 'attribute (list "cellspacing" 0) - 'attribute (list "cellpadding" 4)) + (if invoice + (begin + (set! table (make-entry-table entries + (gnc:report-options report-obj) + add-order)) - (gnc:html-document-add-object! - document - (make-myname-table (opt-val "Display" "Today Date Format"))) + (gnc:html-table-set-style! + table "table" + 'attribute (list "border" 1) + 'attribute (list "cellspacing" 0) + 'attribute (list "cellpadding" 4)) - (let ((date-table (make-date-table))) - (make-date-row! - date-table - (_ "Invoice Date") - (gnc:invoice-get-date-posted invoice)) - (make-date-row! - date-table - (_ "Due Date") - (gnc:invoice-get-date-due invoice)) - (gnc:html-document-add-object! document date-table)) + (gnc:html-document-add-object! + document + (make-myname-table (opt-val "Display" "Today Date Format"))) - (make-break! document) - (make-break! document) + (let ((date-table #f) + (post-date (gnc:invoice-get-date-posted invoice)) + (due-date (gnc:invoice-get-date-due invoice))) - (gnc:html-document-add-object! - document - (make-client-table owner orders)) - - (make-break! document) - (make-break! document) - - (if (opt-val "Display" "Billing ID") - (let ((billing-id (gnc:invoice-get-billing-id invoice))) - (if (and billing-id (> (string-length billing-id) 0)) - (begin + (if (not (equal? post-date (cons 0 0))) + (begin + (set! date-table (make-date-table)) + (make-date-row! date-table (_ "Invoice Date") post-date) + (make-date-row! date-table (_ "Due Date") due-date) + (gnc:html-document-add-object! document date-table)) (gnc:html-document-add-object! document (gnc:make-html-text - (string-append - (_ "Reference") ": " - (string-expand billing-id #\newline "
")))) - (make-break! document))))) + (N_ "Invoice in progress...."))))) - (if (opt-val "Display" "Invoice Terms") - (let* ((term (gnc:invoice-get-terms invoice)) - (terms (gnc:bill-term-get-description term))) - (if (and terms (> (string-length terms) 0)) - (gnc:html-document-add-object! - document - (gnc:make-html-text - (string-append - (_ "Terms") ": " - (string-expand terms #\newline "
"))))))) + (make-break! document) + (make-break! document) - (make-break! document) + (gnc:html-document-add-object! + document + (make-client-table owner orders)) - (gnc:html-document-add-object! document table) + (make-break! document) + (make-break! document) - (make-break! document) - (make-break! document) + (if (opt-val "Display" "Billing ID") + (let ((billing-id (gnc:invoice-get-billing-id invoice))) + (if (and billing-id (> (string-length billing-id) 0)) + (begin + (gnc:html-document-add-object! + document + (gnc:make-html-text + (string-append + (_ "Reference") ": " + (string-expand billing-id #\newline "
")))) + (make-break! document))))) + + (if (opt-val "Display" "Invoice Terms") + (let* ((term (gnc:invoice-get-terms invoice)) + (terms (gnc:bill-term-get-description term))) + (if (and terms (> (string-length terms) 0)) + (gnc:html-document-add-object! + document + (gnc:make-html-text + (string-append + (_ "Terms") ": " + (string-expand terms #\newline "
"))))))) + + (make-break! document) + + (gnc:html-document-add-object! document table) + + (make-break! document) + (make-break! document) + + (if (opt-val "Display" "Invoice Notes") + (let ((notes (gnc:invoice-get-notes invoice))) + (gnc:html-document-add-object! + document + (gnc:make-html-text + (string-expand notes #\newline "
"))))) + + (make-break! document) - (if (opt-val "Display" "Invoice Notes") - (let ((notes (gnc:invoice-get-notes invoice))) (gnc:html-document-add-object! document (gnc:make-html-text - (string-expand notes #\newline "
"))))) + (gnc:html-markup-br) + (string-expand (opt-val "Display" "Extra Notes") #\newline "
") + (gnc:html-markup-br)))) - (make-break! document) - - (gnc:html-document-add-object! - document - (gnc:make-html-text - (gnc:html-markup-br) - (string-expand (opt-val "Display" "Extra Notes") #\newline "
") - (gnc:html-markup-br))) + ; else + (gnc:html-document-add-object! + document + (gnc:make-html-text + (N_ "No Valid Invoice Selected")))) document)) (gnc:define-report 'version 1 - 'name (N_ "Invoice") + 'name (N_ "Print Invoice") + 'menu-path (list gnc:menuname-business-reports) 'options-generator options-generator 'renderer reg-renderer - 'in-menu? #f) + 'in-menu? #t) (define (gnc:invoice-report-create-internal invoice) - (let* ((options (gnc:make-report-options "Invoice")) - (invoice-op (gnc:lookup-option options "__reg" "invoice"))) + (let* ((options (gnc:make-report-options (N_ "Print Invoice"))) + (invoice-op (gnc:lookup-option options invoice-page invoice-name))) (gnc:option-set-value invoice-op invoice) - (gnc:make-report "Invoice" options))) + (gnc:make-report (N_ "Print Invoice") options))) (export gnc:invoice-report-create-internal) diff --git a/src/business/business-reports/receivables.scm b/src/business/business-reports/receivables.scm index c07229bd8e..f2f3b7b81c 100644 --- a/src/business/business-reports/receivables.scm +++ b/src/business/business-reports/receivables.scm @@ -43,9 +43,6 @@ (lambda (new-option) (gnc:register-option options new-option)))) -; (add-option -; (gnc:make-internal-option "__reg" this-acc #f)) - (add-option (gnc:make-account-list-limited-option acc-page this-acc