diff --git a/gnucash/gnome/business-urls.c b/gnucash/gnome/business-urls.c index ce1825ad14..e0283a4f37 100644 --- a/gnucash/gnome/business-urls.c +++ b/gnucash/gnome/business-urls.c @@ -213,7 +213,7 @@ ownerreportCB (const char *location, const char *label, GncOwner owner; Account *acc; GHashTable *query_ht; - time64 enddate; + time64 enddate = INT64_MAX; gboolean show_report = TRUE; g_return_val_if_fail (location != NULL, FALSE); @@ -293,7 +293,13 @@ ownerreportCB (const char *location, const char *label, /* Ok, let's run this report */ if (show_report) - gnc_business_call_owner_report (result->parent, &owner, acc); + { + if (enddate != INT64_MAX) + gnc_business_call_owner_report_with_enddate (result->parent, &owner, + acc, enddate); + else + gnc_business_call_owner_report (result->parent, &owner, acc); + } g_hash_table_destroy (query_ht); return show_report; diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c index 8eb5c0c056..95ee269d2d 100644 --- a/gnucash/gnome/dialog-invoice.c +++ b/gnucash/gnome/dialog-invoice.c @@ -1161,6 +1161,14 @@ void gnc_invoice_window_new_invoice_cb (GtkWindow *parent, gpointer data) } void gnc_business_call_owner_report (GtkWindow *parent, GncOwner *owner, Account *acc) +{ + gnc_business_call_owner_report_with_enddate (parent, owner, acc, INT64_MAX); +} + +void gnc_business_call_owner_report_with_enddate (GtkWindow *parent, + GncOwner *owner, + Account *acc, + time64 enddate) { int id; SCM args; @@ -1171,9 +1179,13 @@ void gnc_business_call_owner_report (GtkWindow *parent, GncOwner *owner, Account args = SCM_EOL; - func = scm_c_eval_string ("gnc:owner-report-create"); + func = scm_c_eval_string ("gnc:owner-report-create-with-enddate"); g_return_if_fail (scm_is_procedure (func)); + /* set the enddate */ + arg = (enddate != INT64_MAX) ? scm_from_int64 (enddate) : SCM_BOOL_F; + args = scm_cons (arg, args); + if (acc) { swig_type_info * qtype = SWIG_TypeQuery("_p_Account"); diff --git a/gnucash/gnome/dialog-invoice.h b/gnucash/gnome/dialog-invoice.h index 002e4af37d..7b70c0838a 100644 --- a/gnucash/gnome/dialog-invoice.h +++ b/gnucash/gnome/dialog-invoice.h @@ -67,6 +67,11 @@ GNCSearchWindow * gnc_invoice_search (GtkWindow *parent, GncInvoice *start, GncO void gnc_business_call_owner_report (GtkWindow* parent, GncOwner *owner, Account *acc); +void gnc_business_call_owner_report_with_enddate (GtkWindow* parent, + GncOwner *owner, + Account *acc, + time64 enddate); + void gnc_invoice_window_sort (InvoiceWindow *iw, invoice_sort_type_t sort_code); GtkWidget * gnc_invoice_window_create_summary_bar (InvoiceWindow *iw); diff --git a/gnucash/report/html-utilities.scm b/gnucash/report/html-utilities.scm index 5f44213d23..3967ec5be7 100644 --- a/gnucash/report/html-utilities.scm +++ b/gnucash/report/html-utilities.scm @@ -94,7 +94,7 @@ (else "")))) -(define (gnc:owner-report-text owner acc) +(define* (gnc:owner-report-text owner acc #:optional date) (let* ((end-owner (gncOwnerGetEndOwner owner)) (type (gncOwnerGetType end-owner))) (gnc-build-url @@ -105,6 +105,7 @@ ((eqv? type GNC-OWNER-EMPLOYEE) "owner=e:") (else "unknown-type=")) (gncOwnerReturnGUID end-owner) + (if date (format #f "&enddate=~a" date) "") (if (null? acc) "" (string-append "&acct=" (gncAccountGetGUID acc)))) ""))) diff --git a/gnucash/report/report-utilities.scm b/gnucash/report/report-utilities.scm index 1ceb1276d8..f5c2f256e3 100644 --- a/gnucash/report/report-utilities.scm +++ b/gnucash/report/report-utilities.scm @@ -908,7 +908,13 @@ (let* ((invoice (gncInvoiceGetInvoiceFromTxn (xaccSplitGetParent (car splits)))) (lot (gncInvoiceGetPostedLot invoice)) - (bal (gnc-lot-get-balance lot)) + (lot-splits (gnc-lot-get-split-list lot)) + (bal (fold + (lambda (a b) + (if (<= (xaccTransGetDate (xaccSplitGetParent a)) to-date) + (+ (xaccSplitGetAmount a) b) + b)) + 0 lot-splits)) (bal (if receivable? bal (- bal))) (date (if (eq? date-type 'postdate) (gncInvoiceGetDatePosted invoice) diff --git a/gnucash/report/reports/aging.scm b/gnucash/report/reports/aging.scm index ca9f5f31ec..3f364f8bc2 100644 --- a/gnucash/report/reports/aging.scm +++ b/gnucash/report/reports/aging.scm @@ -807,7 +807,7 @@ copying this report to a spreadsheet for use in a mail merge.") (cons (gnc:make-html-text (gnc:html-markup-anchor - (gnc:owner-report-text owner account) + (gnc:owner-report-text owner account report-date) total)) rest)))) diff --git a/gnucash/report/reports/reports.scm b/gnucash/report/reports/reports.scm index 67b2fe51ad..9154a927d2 100644 --- a/gnucash/report/reports/reports.scm +++ b/gnucash/report/reports/reports.scm @@ -38,6 +38,7 @@ (export gnc:payables-report-create) (export gnc:receivables-report-create) (export gnc:owner-report-create) +(export gnc:owner-report-create-with-enddate) (define report-dirs (list '(gnucash reports standard) ; prefix for standard reports included in gnucash @@ -48,7 +49,8 @@ ; and then load all reports found in the given prefixes (let* ((loc (gnc-locale-name)) (loc-spec (if (string-prefix? "de_DE" loc) 'de_DE 'us)) - (all-dirs (append report-dirs (list (list 'gnucash 'reports 'locale-specific loc-spec))))) + (all-dirs (append report-dirs + `((gnucash reports locale-specific ,loc-spec))))) (report-module-loader all-dirs)) (use-modules (gnucash engine)) @@ -86,3 +88,4 @@ (use-modules (gnucash reports standard new-owner-report)) (define gnc:owner-report-create owner-report-create) +(define gnc:owner-report-create-with-enddate owner-report-create-with-enddate) diff --git a/gnucash/report/reports/standard/new-aging.scm b/gnucash/report/reports/standard/new-aging.scm index c6f497749e..c9fbfa3978 100644 --- a/gnucash/report/reports/standard/new-aging.scm +++ b/gnucash/report/reports/standard/new-aging.scm @@ -230,7 +230,9 @@ exist but have no suitable transactions.")) (else (op-num (car aging1) (car aging2))))))))) ;; set default title - (gnc:html-document-set-title! document report-title) + (gnc:html-document-set-title! + document + (format #f "~a - ~a" report-title (qof-print-date report-date))) (cond ((null? accounts) @@ -309,7 +311,7 @@ exist but have no suitable transactions.")) "number-cell" (gnc:make-html-text (gnc:html-markup-anchor - (gnc:owner-report-text owner account) + (gnc:owner-report-text owner account report-date) (gnc:make-gnc-monetary comm aging-total))))) (options->address options receivable owner))))) (sort owners-and-aging sort-aging