Always sort credit before payment before fee.
This commit is contained in:
parent
b8f95657da
commit
f297e876cc
1 changed files with 18 additions and 1 deletions
|
@ -283,6 +283,20 @@
|
|||
"Credit"))
|
||||
crs))
|
||||
|
||||
;; Sorting order number
|
||||
(define (balance-type->number t)
|
||||
(if (equal? t "Credit")
|
||||
0
|
||||
(if (equal? t "Payment")
|
||||
1
|
||||
2)))
|
||||
|
||||
;; Sorting on the same day
|
||||
(define (balance-type<? a b)
|
||||
(let ((an (balance-type->number a))
|
||||
(bn (balance-type->number b)))
|
||||
(< an bn)))
|
||||
|
||||
;; Returns a single credit/debit list of payments and fees
|
||||
;; calendar. The result is a list of lists:
|
||||
;; (list balance day amount currency message/comment czk-amount type-string)
|
||||
|
@ -293,7 +307,10 @@
|
|||
(all-unsorted (append mcal pmts crs))
|
||||
(all (sort all-unsorted
|
||||
(lambda (a b)
|
||||
(cal-day<? (car a) (car b))))))
|
||||
(if (cal-day=? (car a) (car b))
|
||||
(balance-type<? (list-ref a 5)
|
||||
(list-ref b 5))
|
||||
(cal-day<? (car a) (car b)))))))
|
||||
(let loop ((trs all)
|
||||
(rbls '())
|
||||
(bal 0))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue