mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
[new-owner-report] if Payment amount is negative, label "Refund"
and add logic to properly handle AP/AR negation rules
This commit is contained in:
parent
6e64a37839
commit
09d3e95379
@ -274,12 +274,14 @@
|
||||
(let ((inv (gncInvoiceGetInvoiceFromLot (xaccSplitGetLot split))))
|
||||
(gnc:make-html-text (invoice->anchor inv)))))))
|
||||
|
||||
(define (split->type-str split)
|
||||
(define (split->type-str split payable?)
|
||||
(let* ((txn (xaccSplitGetParent split))
|
||||
(amt (xaccSplitGetAmount split))
|
||||
(refund? (if payable? (< amt 0) (> amt 0)))
|
||||
(invoice (gncInvoiceGetInvoiceFromTxn txn)))
|
||||
(cond
|
||||
((txn-is-invoice? txn) (gncInvoiceGetTypeString invoice))
|
||||
((txn-is-payment? txn) (_ "Payment"))
|
||||
((txn-is-payment? txn) (if refund? (_ "Refund") (_ "Payment")))
|
||||
((txn-is-link? txn) (_ "Link"))
|
||||
(else (_ "Unknown")))))
|
||||
|
||||
@ -573,7 +575,7 @@
|
||||
(cons (make-link-data
|
||||
(qof-print-date (xaccTransGetDate lot-txn))
|
||||
(split->reference lot-split)
|
||||
(split->type-str lot-split)
|
||||
(split->type-str lot-split payable?)
|
||||
(splits->desc non-document)
|
||||
(gnc:make-html-text (split->anchor lot-split #t))
|
||||
(list->cell
|
||||
@ -600,7 +602,7 @@
|
||||
(cons (make-link-data
|
||||
(qof-print-date (xaccTransGetDate posting-txn))
|
||||
(split->reference posting-split)
|
||||
(split->type-str posting-split)
|
||||
(split->type-str posting-split payable?)
|
||||
(splits->desc (list posting-split))
|
||||
(gnc:make-html-text (split->anchor lot-split neg))
|
||||
(gnc:make-html-text (split->anchor posting-split neg))
|
||||
@ -689,7 +691,7 @@
|
||||
(make-link-data
|
||||
(qof-print-date (xaccTransGetDate (xaccSplitGetParent s)))
|
||||
(split->reference s)
|
||||
(split->type-str s)
|
||||
(split->type-str s payable?)
|
||||
(splits->desc (list s))
|
||||
(gnc:make-html-text (split->anchor s #f))
|
||||
(gnc:make-html-text (split->anchor s #f))
|
||||
@ -771,7 +773,7 @@
|
||||
(add-row
|
||||
table odd-row? used-columns date (gncInvoiceGetDateDue invoice)
|
||||
(split->reference split)
|
||||
(split->type-str split)
|
||||
(split->type-str split payable?)
|
||||
(splits->desc (list split))
|
||||
currency (+ total value)
|
||||
(and (>= orig-value 0) (amount->anchor split orig-value))
|
||||
@ -800,7 +802,7 @@
|
||||
(add-row
|
||||
table odd-row? used-columns date #f
|
||||
(split->reference split)
|
||||
(split->type-str split)
|
||||
(split->type-str split payable?)
|
||||
(splits->desc (xaccTransGetAPARAcctSplitList txn #t))
|
||||
currency (+ total value)
|
||||
(and (>= orig-value 0) (amount->anchor split orig-value))
|
||||
|
@ -274,25 +274,25 @@
|
||||
((sxpath `(// (table 3) // (tr 11) // *text*)) sxml))
|
||||
|
||||
;; tests for refund $120 to partially repay
|
||||
(test-equal "line 12"
|
||||
'("1980-06-28" "Payment" "-$148.25" "1980-06-30" "Payment"
|
||||
(test-equal "line 12 refund $120 to partially repay"
|
||||
'("1980-06-28" "Payment" "-$148.25" "1980-06-30" "Refund"
|
||||
"$160.00" "$50.00" "$50.00")
|
||||
((sxpath `(// (table 3) // (tr 12) // *text*)) sxml))
|
||||
(test-equal "line 13"
|
||||
'("1980-06-29" "Payment" "$120.00" "$120.00")
|
||||
(test-equal "line 13 refund $120 to partially repay"
|
||||
'("1980-06-29" "Refund" "$120.00" "$120.00")
|
||||
((sxpath `(// (table 3) // (tr 13) // *text*)) sxml))
|
||||
(test-equal "line 14"
|
||||
(test-equal "line 14 refund $120 to partially repay"
|
||||
'("Pre-Payment" "-$10.00")
|
||||
((sxpath `(// (table 3) // (tr 14) // *text*)) sxml))
|
||||
(test-equal "line 15"
|
||||
'("1980-06-29" "Payment" "-$28.25" "1980-06-28" "Payment"
|
||||
(test-equal "line 15 refund $120 to partially repay"
|
||||
'("1980-06-29" "Refund" "-$28.25" "1980-06-28" "Payment"
|
||||
"$120.00" "-$120.00" "-$120.00")
|
||||
((sxpath `(// (table 3) // (tr 15) // *text*)) sxml))
|
||||
(test-equal "line 16"
|
||||
'("1980-06-30" "Payment" "$21.75" "1980-06-28" "Payment"
|
||||
(test-equal "line 16 refund $120 to partially repay"
|
||||
'("1980-06-30" "Refund" "$21.75" "1980-06-28" "Payment"
|
||||
"$50.00" "-$40.00" "-$40.00")
|
||||
((sxpath `(// (table 3) // (tr 16) // *text*)) sxml))
|
||||
(test-equal "line 17"
|
||||
(test-equal "line 17 refund $120 to partially repay"
|
||||
'("Pre-Payment" "-$10.00")
|
||||
((sxpath `(// (table 3) // (tr 17) // *text*)) sxml))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user