* 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
This commit is contained in:
Derek Atkins 2002-07-04 15:31:55 +00:00
parent 49809dd904
commit c917663ad3
6 changed files with 184 additions and 80 deletions

View File

@ -11,6 +11,14 @@
* owner-report: put the company into the options dialog instead of * owner-report: put the company into the options dialog instead of
hiding it. 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 <derek@ihtfp.com> 2002-07-03 Derek Atkins <derek@ihtfp.com>
* moved receivable and payable aging reports to business-reports; * moved receivable and payable aging reports to business-reports;

View File

@ -96,7 +96,7 @@
(else "")))) (else ""))))
(define (gnc:entry-type-percent-p type-val) (define (gnc:entry-type-percent-p type-val)
(let ((type (gw:enum-<gnc:GncAmountType>-val->sym type #f))) (let ((type (gw:enum-<gnc:GncAmountType>-val->sym type-val #f)))
(equal? type 'gnc-amount-type-percent))) (equal? type 'gnc-amount-type-percent)))
(define (gnc:owner-from-split split result-owner) (define (gnc:owner-from-split split result-owner)

View File

@ -14,13 +14,15 @@
#include "gnc-ui-util.h" #include "gnc-ui-util.h"
#include "gnc-engine-util.h" #include "gnc-engine-util.h"
#include "option-util.h" #include "option-util.h"
#include "gnc-general-search.h"
#include "dialog-options.h" #include "dialog-options.h"
#include "business-options.h" #include "business-options.h"
#include "business-utils.h" #include "business-utils.h"
#include "dialog-invoice.h"
static int static int
owner_changed_cb (GtkWidget *widget, gpointer data) option_changed_cb (GtkWidget *widget, gpointer data)
{ {
GNCOption *option = data; GNCOption *option = data;
@ -56,7 +58,7 @@ create_owner_widget (GNCOption *option, GncOwnerType type, GtkWidget *hbox)
gnc_option_set_widget (option, widget); gnc_option_set_widget (option, widget);
gtk_signal_connect (GTK_OBJECT (widget), "changed", gtk_signal_connect (GTK_OBJECT (widget), "changed",
GTK_SIGNAL_FUNC (owner_changed_cb), option); GTK_SIGNAL_FUNC (option_changed_cb), option);
return widget; return widget;
} }
@ -276,6 +278,79 @@ vendor_get_value (GNCOption *option, GtkWidget *widget)
gh_eval_str("<gnc:GncVendor*>")); gh_eval_str("<gnc:GncVendor*>"));
} }
/********************************************************************/
/* "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("<gnc:GncInvoice*>"));
}
@ -288,6 +363,7 @@ gnc_business_options_initialize (void)
{ "customer", customer_set_widget, customer_set_value, { "customer", customer_set_widget, customer_set_value,
customer_get_value }, customer_get_value },
{ "vendor", vendor_set_widget, vendor_set_value, vendor_get_value }, { "vendor", vendor_set_widget, vendor_set_value, vendor_get_value },
{ "invoice", invoice_set_widget, invoice_set_value, invoice_get_value },
{ NULL } { NULL }
}; };

View File

@ -197,7 +197,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
GncOwner *owner = gncInvoiceGetOwner (ledger->invoice); GncOwner *owner = gncInvoiceGetOwner (ledger->invoice);
GncTaxTable *table = NULL; GncTaxTable *table = NULL;
GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL; GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL;
gboolean taxincluded; gboolean taxincluded = FALSE;
gnc_numeric discount = gnc_numeric_zero (); gnc_numeric discount = gnc_numeric_zero ();
owner = gncOwnerGetEndOwner (owner); owner = gncOwnerGetEndOwner (owner);

View File

@ -16,6 +16,9 @@
(gnc:module-load "gnucash/report/report-system" 0) (gnc:module-load "gnucash/report/report-system" 0)
(gnc:module-load "gnucash/business-gnome" 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) (define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist))) `(set! ,alist (cons ,element ,alist)))
@ -196,7 +199,7 @@
(gnc:register-option gnc:*report-options* new-option)) (gnc:register-option gnc:*report-options* new-option))
(gnc:register-inv-option (gnc:register-inv-option
(gnc:make-invoice-option "__reg" "invoice" "" "" (gnc:make-invoice-option invoice-page invoice-name "x" ""
(lambda () #f) #f)) (lambda () #f) #f))
(gnc:register-inv-option (gnc:register-inv-option
@ -504,22 +507,31 @@
(let* ((document (gnc:make-html-document)) (let* ((document (gnc:make-html-document))
(table '()) (table '())
(orders '()) (orders '())
(invoice (opt-val "__reg" "invoice")) (invoice (opt-val invoice-page invoice-name))
(owner (gnc:invoice-get-owner invoice)) (owner #f)
(entries (gnc:invoice-get-entries invoice)) (entries #f)
(references? (opt-val "Display" "References")) (references? (opt-val "Display" "References"))
(title (string-append (_ "Invoice #") (gnc:invoice-get-id invoice)))) (title (_ "Invoice")))
(define (add-order o) (define (add-order o)
(if (and references? (not (member o orders))) (if (and references? (not (member o orders)))
(addto! orders o))) (addto! orders o)))
(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)
(if invoice
(begin
(set! table (make-entry-table entries (set! table (make-entry-table entries
(gnc:report-options report-obj) (gnc:report-options report-obj)
add-order)) add-order))
(gnc:html-document-set-title! document title)
(gnc:html-table-set-style! (gnc:html-table-set-style!
table "table" table "table"
'attribute (list "border" 1) 'attribute (list "border" 1)
@ -530,16 +542,20 @@
document document
(make-myname-table (opt-val "Display" "Today Date Format"))) (make-myname-table (opt-val "Display" "Today Date Format")))
(let ((date-table (make-date-table))) (let ((date-table #f)
(make-date-row! (post-date (gnc:invoice-get-date-posted invoice))
date-table (due-date (gnc:invoice-get-date-due invoice)))
(_ "Invoice Date")
(gnc:invoice-get-date-posted invoice)) (if (not (equal? post-date (cons 0 0)))
(make-date-row! (begin
date-table (set! date-table (make-date-table))
(_ "Due Date") (make-date-row! date-table (_ "Invoice Date") post-date)
(gnc:invoice-get-date-due invoice)) (make-date-row! date-table (_ "Due Date") due-date)
(gnc:html-document-add-object! document date-table)) (gnc:html-document-add-object! document date-table))
(gnc:html-document-add-object!
document
(gnc:make-html-text
(N_ "Invoice in progress....")))))
(make-break! document) (make-break! document)
(make-break! document) (make-break! document)
@ -595,22 +611,29 @@
(gnc:make-html-text (gnc:make-html-text
(gnc:html-markup-br) (gnc:html-markup-br)
(string-expand (opt-val "Display" "Extra Notes") #\newline "<br>") (string-expand (opt-val "Display" "Extra Notes") #\newline "<br>")
(gnc:html-markup-br))) (gnc:html-markup-br))))
; else
(gnc:html-document-add-object!
document
(gnc:make-html-text
(N_ "No Valid Invoice Selected"))))
document)) document))
(gnc:define-report (gnc:define-report
'version 1 'version 1
'name (N_ "Invoice") 'name (N_ "Print Invoice")
'menu-path (list gnc:menuname-business-reports)
'options-generator options-generator 'options-generator options-generator
'renderer reg-renderer 'renderer reg-renderer
'in-menu? #f) 'in-menu? #t)
(define (gnc:invoice-report-create-internal invoice) (define (gnc:invoice-report-create-internal invoice)
(let* ((options (gnc:make-report-options "Invoice")) (let* ((options (gnc:make-report-options (N_ "Print Invoice")))
(invoice-op (gnc:lookup-option options "__reg" "invoice"))) (invoice-op (gnc:lookup-option options invoice-page invoice-name)))
(gnc:option-set-value invoice-op invoice) (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) (export gnc:invoice-report-create-internal)

View File

@ -43,9 +43,6 @@
(lambda (new-option) (lambda (new-option)
(gnc:register-option options new-option)))) (gnc:register-option options new-option))))
; (add-option
; (gnc:make-internal-option "__reg" this-acc #f))
(add-option (add-option
(gnc:make-account-list-limited-option (gnc:make-account-list-limited-option
acc-page this-acc acc-page this-acc