2024-02-20 03:19:23 +00:00
|
|
|
(ns core
|
2024-02-20 03:55:14 +00:00
|
|
|
(:require [import :as import]
|
2024-02-20 03:19:23 +00:00
|
|
|
[parse :refer [parse]]
|
|
|
|
[lambdaisland.deep-diff2 :as dd]))
|
|
|
|
|
2024-02-20 03:55:14 +00:00
|
|
|
;; TODO: Need some tests now it's working.
|
|
|
|
|
|
|
|
;; TODO: Where do the $25.81 fees come from?
|
|
|
|
|
|
|
|
;; TODO: Need a CLI to run it on a CSV file.
|
|
|
|
|
2024-02-20 03:19:23 +00:00
|
|
|
(defn sort-postings [transactions]
|
|
|
|
(for [t transactions]
|
|
|
|
(update t :postings
|
|
|
|
(fn [ps] (sort-by (juxt #(get-in % [:meta :entity]) :account :amount) (filter #(not (zero? (:amount %))) ps))))))
|
|
|
|
|
|
|
|
(comment
|
2024-02-20 03:55:14 +00:00
|
|
|
(require '[examples :as examples])
|
|
|
|
(def data (import/read-grouped-csv "/home/ben/Downloads/2023-12-27_Pay-Item-Details_2023-12-2.csv"))
|
2024-02-20 03:19:23 +00:00
|
|
|
(def imported
|
2024-02-20 03:55:14 +00:00
|
|
|
(concat [(import/import-monthly-payroll data)]
|
|
|
|
(import/import-individual-taxes data)))
|
2024-02-20 03:19:23 +00:00
|
|
|
|
2024-02-20 03:55:14 +00:00
|
|
|
(dd/pretty-print
|
|
|
|
(dd/diff
|
|
|
|
(sort-postings (parse examples/human))
|
|
|
|
(sort-postings imported)))
|
2024-02-20 03:19:23 +00:00
|
|
|
|
|
|
|
(doseq [i imported]
|
|
|
|
(println (import/render-transaction i)))
|
|
|
|
|
|
|
|
)
|