Merge branch 'maint-797852-bis' into maint #776

This commit is contained in:
Christopher Lam 2020-08-19 07:19:42 +08:00
commit 98c8b23351
9 changed files with 61 additions and 24 deletions

View File

@ -213,7 +213,7 @@ ownerreportCB (const char *location, const char *label,
GncOwner owner; GncOwner owner;
Account *acc; Account *acc;
GHashTable *query_ht; GHashTable *query_ht;
time64 enddate; time64 enddate = INT64_MAX;
gboolean show_report = TRUE; gboolean show_report = TRUE;
g_return_val_if_fail (location != NULL, FALSE); 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 */ /* Ok, let's run this report */
if (show_report) if (show_report)
{
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); gnc_business_call_owner_report (result->parent, &owner, acc);
}
g_hash_table_destroy (query_ht); g_hash_table_destroy (query_ht);
return show_report; return show_report;

View File

@ -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) 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; int id;
SCM args; SCM args;
@ -1171,9 +1179,13 @@ void gnc_business_call_owner_report (GtkWindow *parent, GncOwner *owner, Account
args = SCM_EOL; 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)); 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) if (acc)
{ {
swig_type_info * qtype = SWIG_TypeQuery("_p_Account"); swig_type_info * qtype = SWIG_TypeQuery("_p_Account");

View File

@ -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 (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); void gnc_invoice_window_sort (InvoiceWindow *iw, invoice_sort_type_t sort_code);
GtkWidget * gnc_invoice_window_create_summary_bar (InvoiceWindow *iw); GtkWidget * gnc_invoice_window_create_summary_bar (InvoiceWindow *iw);

View File

@ -94,7 +94,7 @@
(else (else
"")))) ""))))
(define (gnc:owner-report-text owner acc) (define* (gnc:owner-report-text owner acc #:optional date)
(let* ((end-owner (gncOwnerGetEndOwner owner)) (let* ((end-owner (gncOwnerGetEndOwner owner))
(type (gncOwnerGetType end-owner))) (type (gncOwnerGetType end-owner)))
(gnc-build-url (gnc-build-url
@ -105,6 +105,7 @@
((eqv? type GNC-OWNER-EMPLOYEE) "owner=e:") ((eqv? type GNC-OWNER-EMPLOYEE) "owner=e:")
(else "unknown-type=")) (else "unknown-type="))
(gncOwnerReturnGUID end-owner) (gncOwnerReturnGUID end-owner)
(if date (format #f "&enddate=~a" date) "")
(if (null? acc) "" (string-append "&acct=" (gncAccountGetGUID acc)))) (if (null? acc) "" (string-append "&acct=" (gncAccountGetGUID acc))))
""))) "")))

View File

@ -908,7 +908,13 @@
(let* ((invoice (gncInvoiceGetInvoiceFromTxn (let* ((invoice (gncInvoiceGetInvoiceFromTxn
(xaccSplitGetParent (car splits)))) (xaccSplitGetParent (car splits))))
(lot (gncInvoiceGetPostedLot invoice)) (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))) (bal (if receivable? bal (- bal)))
(date (if (eq? date-type 'postdate) (date (if (eq? date-type 'postdate)
(gncInvoiceGetDatePosted invoice) (gncInvoiceGetDatePosted invoice)

View File

@ -807,7 +807,7 @@ copying this report to a spreadsheet for use in a mail merge.")
(cons (cons
(gnc:make-html-text (gnc:make-html-text
(gnc:html-markup-anchor (gnc:html-markup-anchor
(gnc:owner-report-text owner account) (gnc:owner-report-text owner account report-date)
total)) total))
rest)))) rest))))

View File

@ -38,6 +38,7 @@
(export gnc:payables-report-create) (export gnc:payables-report-create)
(export gnc:receivables-report-create) (export gnc:receivables-report-create)
(export gnc:owner-report-create) (export gnc:owner-report-create)
(export gnc:owner-report-create-with-enddate)
(define report-dirs (list (define report-dirs (list
'(gnucash reports standard) ; prefix for standard reports included in gnucash '(gnucash reports standard) ; prefix for standard reports included in gnucash
@ -48,7 +49,8 @@
; and then load all reports found in the given prefixes ; and then load all reports found in the given prefixes
(let* ((loc (gnc-locale-name)) (let* ((loc (gnc-locale-name))
(loc-spec (if (string-prefix? "de_DE" loc) 'de_DE 'us)) (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)) (report-module-loader all-dirs))
(use-modules (gnucash engine)) (use-modules (gnucash engine))
@ -86,3 +88,4 @@
(use-modules (gnucash reports standard new-owner-report)) (use-modules (gnucash reports standard new-owner-report))
(define gnc:owner-report-create owner-report-create) (define gnc:owner-report-create owner-report-create)
(define gnc:owner-report-create-with-enddate owner-report-create-with-enddate)

View File

@ -230,7 +230,9 @@ exist but have no suitable transactions."))
(else (op-num (car aging1) (car aging2))))))))) (else (op-num (car aging1) (car aging2)))))))))
;; set default title ;; 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 (cond
((null? accounts) ((null? accounts)
@ -309,7 +311,7 @@ exist but have no suitable transactions."))
"number-cell" "number-cell"
(gnc:make-html-text (gnc:make-html-text
(gnc:html-markup-anchor (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))))) (gnc:make-gnc-monetary comm aging-total)))))
(options->address options receivable owner))))) (options->address options receivable owner)))))
(sort owners-and-aging sort-aging<?)) (sort owners-and-aging sort-aging<?))

View File

@ -29,6 +29,7 @@
(define-module (gnucash reports standard new-owner-report)) (define-module (gnucash reports standard new-owner-report))
(use-modules (srfi srfi-1)) (use-modules (srfi srfi-1))
(use-modules (srfi srfi-2))
(use-modules (srfi srfi-8)) (use-modules (srfi srfi-8))
(use-modules (srfi srfi-9)) (use-modules (srfi srfi-9))
(use-modules (srfi srfi-11)) ;for let-values (use-modules (srfi srfi-11)) ;for let-values
@ -1193,28 +1194,28 @@ invoices and amounts.")))))
'in-menu? #t) 'in-menu? #t)
(define (owner-report-create-internal report-guid owner owner-type) (define (owner-report-create-internal report-guid owner owner-type enddate)
(let* ((options (gnc:make-report-options report-guid)) (let* ((options (gnc:make-report-options report-guid))
(owner-op (gnc:lookup-option options owner-page (owner-string owner-type)))) (owner-op (gnc:lookup-option options owner-page (owner-string owner-type)))
(date-op (gnc:lookup-option options gnc:pagename-general optname-to-date)))
(gnc:option-set-value owner-op owner) (gnc:option-set-value owner-op owner)
(when enddate
(gnc:option-set-value date-op (cons 'absolute enddate)))
(gnc:make-report report-guid options))) (gnc:make-report report-guid options)))
(define (owner-report-create owner account) (define (owner-report-create-with-enddate owner account enddate)
;; note account isn't actually used ;; note account isn't actually used
(let ((type (gncOwnerGetType (gncOwnerGetEndOwner owner)))) (define guid-alist
(cond (list (cons GNC-OWNER-CUSTOMER customer-report-guid)
((eqv? type GNC-OWNER-CUSTOMER) (cons GNC-OWNER-VENDOR vendor-report-guid)
;; Not sure whether to pass type, or to use the guid in the report function (cons GNC-OWNER-EMPLOYEE employee-report-guid)))
(owner-report-create-internal customer-report-guid owner type)) (and-let* ((type (gncOwnerGetType (gncOwnerGetEndOwner owner)))
(guid (assv-ref guid-alist type)))
(owner-report-create-internal guid owner type enddate)))
((eqv? type GNC-OWNER-VENDOR) (define (owner-report-create owner account)
(owner-report-create-internal vendor-report-guid owner type)) (owner-report-create-with-enddate owner account #f))
((eqv? type GNC-OWNER-EMPLOYEE)
(owner-report-create-internal employee-report-guid owner type))
(else #f))))
(define (gnc:owner-report-create-internal (define (gnc:owner-report-create-internal
account split query journal? double? title debit-string credit-string) account split query journal? double? title debit-string credit-string)
@ -1229,3 +1230,4 @@ invoices and amounts.")))))
(gnc:register-report-hook ACCT-TYPE-RECEIVABLE #t gnc:owner-report-create-internal) (gnc:register-report-hook ACCT-TYPE-RECEIVABLE #t gnc:owner-report-create-internal)
(gnc:register-report-hook ACCT-TYPE-PAYABLE #t gnc:owner-report-create-internal) (gnc:register-report-hook ACCT-TYPE-PAYABLE #t gnc:owner-report-create-internal)
(export owner-report-create) (export owner-report-create)
(export owner-report-create-with-enddate)