mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 10:20:18 -06:00
[report-utilities] simplify gnc:payment-txn->payment-info
store lot splits in a separate identifier
This commit is contained in:
parent
d1997c59bc
commit
074729bf19
@ -1006,28 +1006,26 @@ query instead.")
|
||||
(lp rest invoices (+ overpayment (xaccSplitGetAmount split))
|
||||
opposing-splits))
|
||||
((split . rest)
|
||||
(let ((lot (xaccSplitGetLot split)))
|
||||
(define (equal-to-split? s) (equal? s split))
|
||||
(let* ((lot (xaccSplitGetLot split))
|
||||
(lot-all-splits (gnc-lot-get-split-list lot)))
|
||||
(define split=? (cut equal? <> split))
|
||||
(match (gncInvoiceGetInvoiceFromLot lot)
|
||||
(() (let lp1 ((lot-splits (gnc-lot-get-split-list lot))
|
||||
(() (let lp1 ((lot-splits lot-all-splits)
|
||||
(overpayment overpayment)
|
||||
(opposing-splits opposing-splits))
|
||||
(match lot-splits
|
||||
(() (lp rest invoices overpayment opposing-splits))
|
||||
(((? equal-to-split?) . tail)
|
||||
(lp1 tail overpayment opposing-splits))
|
||||
(((? split=?) . tail) (lp1 tail overpayment opposing-splits))
|
||||
((s . tail)
|
||||
(let* ((s-lot (xaccSplitGetLot s))
|
||||
(sum
|
||||
(let* ((lot-bal (gnc-lot-get-balance lot))
|
||||
(lot-bal (if (sign-equal? lot-bal (xaccSplitGetAmount s))
|
||||
0 lot-bal))
|
||||
(derived? (not (zero? lot-bal)))
|
||||
(partial-amount
|
||||
(fold
|
||||
(lambda (a b)
|
||||
(if (equal? s a) b (+ b (xaccSplitGetAmount a))))
|
||||
0 (gnc-lot-get-split-list s-lot)))
|
||||
(lot-bal (gnc-lot-get-balance s-lot))
|
||||
(lot-bal (if (sign-equal? lot-bal (xaccSplitGetAmount s))
|
||||
0 lot-bal))
|
||||
(partial-amount (- sum lot-bal))
|
||||
(derived? (not (zero? lot-bal))))
|
||||
(- lot-bal) lot-all-splits)))
|
||||
(lp1 tail (+ overpayment partial-amount)
|
||||
(cons (list s partial-amount derived?)
|
||||
opposing-splits)))))))
|
||||
|
Loading…
Reference in New Issue
Block a user