Rename format-name, add TODO.md

This commit is contained in:
Ben Sturmfels 2024-02-22 12:43:32 +11:00
parent 5f801c99f3
commit b4b42b72aa
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
4 changed files with 19 additions and 9 deletions

View file

@ -8,7 +8,7 @@ Run with:
Or use a reduced set of options (missing values will be replaced by "TODO" in the output): Or use a reduced set of options (missing values will be replaced by "TODO" in the output):
java -jar import-0.0.8-standalone.jar --csv 2023-12-27_Pay-Item-Details_2023-12-2.csv --period "December 2023" --total-fees 206.50 java -jar import-0.0.8-standalone.jar --csv 2023-12-27_Pay-Item-Details_2023-12-2.csv --date 2023-12-29 --period "December 2023" --total-fees 206.50
## Development ## Development
@ -16,6 +16,10 @@ Or use a reduced set of options (missing values will be replaced by "TODO" in th
The project is set up for development in Emacs and CIDER-mode. Open a source The project is set up for development in Emacs and CIDER-mode. Open a source
file and run `cider-jack-in`. file and run `cider-jack-in`.
You can run without building using:
clojure -M -m core --csv 2023-12-27_Pay-Item-Details_2023-12-2.csv --date 2023-12-29 --period "December 2023" --total-fees 206.50
## Build ## Build

10
TODO.md Normal file
View file

@ -0,0 +1,10 @@
# To-do
* Anatomise some payroll data for use as a test case
* Validation/error handling on CLI arguments - required options like csv, date, period
* Potentially move employee-name->entity-tag into config
* Potentially move cat->payroll-type into config
* Confirm it's "Withholding" in individual taxes and "Liability" in employer taxes
* Confirm extra NY-only insurance/asset postings in individual taxes
* Confirm lack of :Tax: in employer taxes eg. "US:Medicare", not "US:Tax:Medicare" as in individual taxes
* Confirm lack of :memo for Karen

View file

@ -10,9 +10,6 @@
[import :as import]) [import :as import])
(:gen-class)) (:gen-class))
;; TODO: Tests
;; TODO: Validation/error handling - required options like csv, date, period
(def cli-options (def cli-options
[[nil "--csv FILE" "Pay Item Details CSV report"] [[nil "--csv FILE" "Pay Item Details CSV report"]
[nil "--date DATE" "Date used for the transactions (YYYY-MM-DD)" [nil "--date DATE" "Date used for the transactions (YYYY-MM-DD)"

View file

@ -9,7 +9,7 @@
[clojure.java.io :as io] [clojure.java.io :as io]
[clojure.string :as str])) [clojure.string :as str]))
(defn- format-name (defn- employee-name->entity-tag
"Convert the name from the Pay Item Details report into an entity slug for Beancount." "Convert the name from the Pay Item Details report into an entity slug for Beancount."
[name] [name]
;; Should potentially be a lookup table in config. ;; Should potentially be a lookup table in config.
@ -29,7 +29,7 @@
(group-by (group-by
:name :name
(for [[_ name _ category type & totals] (csv/read-csv reader)] (for [[_ name _ category type & totals] (csv/read-csv reader)]
{:name (import/format-name name) {:name (employee-name->entity-tag name)
:category category :category category
:type type :type type
:amount (apply max (map bigdec (remove str/blank? totals)))}))))) :amount (apply max (map bigdec (remove str/blank? totals)))})))))
@ -142,9 +142,8 @@
[date period receipt-no invoice-no groups] [date period receipt-no invoice-no groups]
(for [[name records] groups] (for [[name records] groups]
(let [retirement-lines (filter #(= (:type %) "Retirement") records) (let [retirement-lines (filter #(= (:type %) "Retirement") records)
;; TODO: Have I got the liability/witholding right? Which is used in which report.
witholding-lines (filter #(= (:type %) "Withholding") records) witholding-lines (filter #(= (:type %) "Withholding") records)
;; TODO: We seem to add these extra expense/asset postings for ;; TODO: We seem to add these extra insurance/asset postings for
;; Karen (NY) only, but not for say Pono/Sage/Bradley (OR). Confirm ;; Karen (NY) only, but not for say Pono/Sage/Bradley (OR). Confirm
;; with Rosanne. ;; with Rosanne.
insurance-lines (filter #(and (= (:type %) "Withholding") insurance-lines (filter #(and (= (:type %) "Withholding")
@ -224,7 +223,7 @@
:meta (assoc-project :meta (assoc-project
name name
{:entity (first (str/split category #" ")) {:entity (first (str/split category #" "))
:memo name ; TODO: Karen doesn't have a memo in January 2024 :memo name
:payroll-type (str "US:" (cat->payroll-type category))})}) :payroll-type (str "US:" (cat->payroll-type category))})})
total-unemploy (->> unemploy-postings (map :amount) (reduce +)) total-unemploy (->> unemploy-postings (map :amount) (reduce +))
asset-postings [{:account "Assets:FR:Check2721" asset-postings [{:account "Assets:FR:Check2721"