SHARE
TWEET

Untitled

a guest Jan 14th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. modified   gnucash/report/report-system/report-utilities.scm
  2. @@ -506,28 +506,26 @@ flawed. see report-utilities.scm. please update reports.")
  3.       (() (reverse result))
  4.  
  5.       ((date . rest)
  6. -       (match splits
  7. -
  8. -         ;; end of splits, but still has dates. pad with last-result
  9. -         ;; until end of dates.
  10. -         (() (lp '() rest (cons last-result result) last-result))
  11. -
  12. -         ((head . tail)
  13. -          (let ((next (and (pair? tail) (car tail))))
  14. -            (cond
  15. -
  16. -             ;; the next split is still before date.
  17. -             ((and next (< (split->date next) date))
  18. -              (lp tail dates result (split->elt head)))
  19. -
  20. -             ;; head split after date, accumulate previous result
  21. -             ((< date (split->date head))
  22. -              (lp splits rest (cons last-result result) last-result))
  23. -
  24. -             ;; head split before date, next split after date, or end.
  25. -             (else
  26. -              (let ((head-result (split->elt head)))
  27. -                (lp tail rest (cons head-result result) head-result)))))))))))
  28. +       (let ((before-date? (lambda (s) (< (split->date s) date)))
  29. +             (after-date? (lambda (s) (< date (split->date s)))))
  30. +         (match splits
  31. +
  32. +           ;; end of splits, but still has dates. pad with last-result
  33. +           ;; until end of dates.
  34. +           (() (lp '() rest (cons last-result result) last-result))
  35. +
  36. +           ;; the next split is still before date. walk to split.
  37. +           ((head (? before-date?) . _)
  38. +            (lp (cdr splits) dates result (split->elt head)))
  39. +
  40. +           ;; head split after date, accumulate previous result
  41. +           (((? after-date?) . _)
  42. +            (lp splits rest (cons last-result result) last-result))
  43. +
  44. +           ;; head split before date, next split after date, or end.
  45. +           ((head . tail)
  46. +            (let ((head-result (split->elt head)))
  47. +              (lp tail rest (cons head-result result) head-result)))))))))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top