diff --git a/.gitignore b/.gitignore index f40ad1d..8b9798a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/src/examples.clj +/private/ /.cpcache/ /target/ /.nrepl-port diff --git a/README.md b/README.md index 7e9e7bd..da61be6 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,19 @@ intricate Beancount bookkeeping data. ## Usage -Run with: +See a demo with: - java -jar import-0.0.8-standalone.jar --csv resources/example-paychex-pay-item-details.csv --date 2023-12-29 --period 'December 2023' --total-fees 206.50 --pay-receipt-no rt:19462/674660 --pay-invoice-no rt:19403/675431 --fees-receipt-no rt:19459/675387 --fees-invoice-no rt:19459/674887 --retirement-receipt-no rt:19403/676724 --retirement-invoice-no rt:19403/675431 + java -jar import-x.x.x-standalone.jar --demo -Or simpler (missing options will be replaced by "TODO" in the output): +Provide your own payroll data with: - java -jar import-0.0.8-standalone.jar --csv resources/example-paychex-pay-item-details.csv --total-fees 206.50 + java -jar import-x.x.x-standalone.jar --csv resources/example-paychex-pay-item-details.csv --total-fees 206.50 + +In the above, various values such as the date, time period covered and +receipt/invoice values will be replace with "TODO" placeholders. You can +alternatively provide any/all of these explicitly: + + java -jar import-x.x.x-standalone.jar --csv resources/example-paychex-pay-item-details.csv --date 2023-12-29 --period 'December 2023' --total-fees 206.50 --pay-receipt-no rt:19462/674660 --pay-invoice-no rt:19403/675431 --fees-receipt-no rt:19459/675387 --fees-invoice-no rt:19459/674887 --retirement-receipt-no rt:19403/676724 --retirement-invoice-no rt:19403/675431 You can test the output in Beancount by adding the following header entries to define the accounts: diff --git a/build.clj b/build.clj index df2a795..a313f8c 100644 --- a/build.clj +++ b/build.clj @@ -14,7 +14,9 @@ (defn uber [_] (clean nil) - (b/copy-dir {:src-dirs ["src"] + (b/copy-dir {:src-dirs ["src" "resources"] + :target-dir class-dir}) + (b/copy-dir {:src-dirs ["src" "resources"] :target-dir class-dir}) (b/compile-clj {:basis @basis :ns-compile '[core] diff --git a/deps.edn b/deps.edn index bb96f00..8663d9e 100644 --- a/deps.edn +++ b/deps.edn @@ -1,4 +1,4 @@ -{:paths ["src" "resources"] +{:paths ["src" "resources" "private"] ;; Private is not include in the build :deps { org.clojure/clojure {:mvn/version "1.11.1"} org.clojure/data.csv {:mvn/version "1.0.1"} diff --git a/src/core.clj b/src/core.clj index e47b7fd..0b4d91c 100644 --- a/src/core.clj +++ b/src/core.clj @@ -3,7 +3,8 @@ (ns core "Beancount importer for Paychex Pay Item Details report." - (:require [clojure.set :as set] + (:require [clojure.java.io :as io] + [clojure.set :as set] [clojure.string :as str] [clojure.tools.cli :refer [parse-opts]] [import :as import]) @@ -37,6 +38,7 @@ :parse-fn #(str/split % #":") :default {} :assoc-fn (fn [m k [name proj]] (assoc-in m [k name] proj))] + [nil "--demo" "Produce demo output based made-up payroll data. Useful for documentation."] ["-h" "--help"]]) (defn unmatched-employees @@ -44,9 +46,15 @@ [records projects] (set/difference (set (keys projects)) (->> records (map :name) set))) +(def demo-options + {:csv (io/resource "example-paychex-pay-item-details.csv") + :date "2024-01-01" + :period "January 2024" + :total-fees 66.67M}) + (defn -main [& args] (let [{:keys [options errors summary]} (parse-opts args cli-options) - {:keys [date period pay-receipt-no pay-invoice-no total-fees fees-receipt-no fees-invoice-no retirement-receipt-no retirement-invoice-no project]} options] + options (if (:demo options) (merge options demo-options) options)] (when (:help options) (println summary) (System/exit 0)) @@ -55,12 +63,14 @@ (str "The following errors occurred while parsing your command:\n\n" (str/join \newline errors))) (System/exit 1)) - (let [records (import/read-csv (:csv options)) + (let [{:keys [date period pay-receipt-no pay-invoice-no total-fees project]} options + {:keys [fees-receipt-no fees-invoice-no retirement-receipt-no retirement-invoice-no]} options + records (import/read-csv (:csv options)) imported (concat (import/net-pay date period pay-invoice-no project records) (import/individual-taxes date period pay-invoice-no retirement-invoice-no project records) (import/employer-taxes date period pay-invoice-no project records) - (import/net-pay-ach-debit date period pay-receipt-no pay-invoice-no {} records) - (import/taxes-ach-debit date period pay-receipt-no pay-invoice-no {} records) + (import/net-pay-ach-debit date period pay-receipt-no pay-invoice-no project records) + (import/taxes-ach-debit date period pay-receipt-no pay-invoice-no project records) (import/fees date period fees-receipt-no fees-invoice-no total-fees project records) (import/retirement date period retirement-receipt-no retirement-invoice-no records)) unmatched (unmatched-employees records project)]