Apply cljfmt

This commit is contained in:
Ben Sturmfels 2025-02-10 12:53:33 +11:00
parent ea57f67f7c
commit 2cebde781c
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
4 changed files with 30 additions and 35 deletions

View file

@ -43,7 +43,7 @@
(defn unmatched-employees (defn unmatched-employees
"Identify any mismatches between employees in the pay run and --project employee allocations." "Identify any mismatches between employees in the pay run and --project employee allocations."
[records projects] [records projects]
(set/difference (set (keys projects)) (->> records (map :name) set))) (set/difference (set (keys projects)) (->> records (map :name) set)))
(def demo-options (def demo-options
@ -108,6 +108,4 @@
;; Print out text transactions ;; Print out text transactions
(doseq [i imported] (doseq [i imported]
(println (import/render-transaction i))) (println (import/render-transaction i))))
)

View file

@ -180,8 +180,8 @@
;; We add these extra disability insurance/asset postings for NY only ;; We add these extra disability insurance/asset postings for NY only
;; as discussed in beancount/doc/Payroll.md. ;; as discussed in beancount/doc/Payroll.md.
insurance-records (filter (fn [{:keys [category type]}] insurance-records (filter (fn [{:keys [category type]}]
(and (= type "Withholding") (and (= type "Withholding")
(str/starts-with? category "NY Disability"))) employee-records) (str/starts-with? category "NY Disability"))) employee-records)
total-retirement (total retirement-records) total-retirement (total retirement-records)
retirement-postings (for [{:keys [category amount]} retirement-records] retirement-postings (for [{:keys [category amount]} retirement-records]
(if (= category "403b ER match") (if (= category "403b ER match")
@ -228,8 +228,8 @@
:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"} :approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"}
:postings []} :postings []}
liability-records (filter (fn [{:keys [category type]}] liability-records (filter (fn [{:keys [category type]}]
(and (= type "Liability") (and (= type "Liability")
(not (str/includes? category "Unemploy")))) records) (not (str/includes? category "Unemploy")))) records)
liability-postings (for [{:keys [amount name category]} liability-records] liability-postings (for [{:keys [amount name category]} liability-records]
{:account "Expenses:Payroll:Tax" {:account "Expenses:Payroll:Tax"
:amount amount :currency "USD" :amount amount :currency "USD"
@ -242,8 +242,8 @@
:payroll-type (str/replace (cat->payroll-type category) "Tax:" "")})}) :payroll-type (str/replace (cat->payroll-type category) "Tax:" "")})})
total-liabilities (total liability-records) total-liabilities (total liability-records)
unemploy-records (filter (fn [{:keys [category type]}] unemploy-records (filter (fn [{:keys [category type]}]
(and (= type "Liability") (and (= type "Liability")
(str/includes? category "Unemploy"))) records) (str/includes? category "Unemploy"))) records)
unemploy-postings (for [{:keys [amount name category]} unemploy-records] unemploy-postings (for [{:keys [amount name category]} unemploy-records]
{:account "Expenses:Payroll:Tax" {:account "Expenses:Payroll:Tax"
:amount amount :currency "USD" :amount amount :currency "USD"
@ -305,7 +305,6 @@
all-postings (concat liability-postings asset-postings)] all-postings (concat liability-postings asset-postings)]
[(assoc template :postings all-postings)])) [(assoc template :postings all-postings)]))
(defn net-pay-ach-debit (defn net-pay-ach-debit
"Return a transaction paying off net pay liabilities" "Return a transaction paying off net pay liabilities"
[date period receipt-no invoice-no projects records] [date period receipt-no invoice-no projects records]
@ -350,12 +349,12 @@
:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"} :approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"}
:postings []} :postings []}
liability-records (filter (fn [{:keys [category type]}] liability-records (filter (fn [{:keys [category type]}]
(and (= type "Liability") (and (= type "Liability")
(not (str/includes? category "Unemploy")))) records) (not (str/includes? category "Unemploy")))) records)
total-liabilities (total liability-records) total-liabilities (total liability-records)
unemploy-records (filter (fn [{:keys [category type]}] unemploy-records (filter (fn [{:keys [category type]}]
(and (= type "Liability") (and (= type "Liability")
(str/includes? category "Unemploy"))) records) (str/includes? category "Unemploy"))) records)
total-unemploy (total unemploy-records) total-unemploy (total unemploy-records)
liability-postings [{:account "Liabilities:Payable:Accounts" liability-postings [{:account "Liabilities:Payable:Accounts"
:amount (+ total-liabilities total-unemploy) :currency "USD" :amount (+ total-liabilities total-unemploy) :currency "USD"
@ -364,9 +363,9 @@
(for [[name employee-records] (group-by :name records)] (for [[name employee-records] (group-by :name records)]
(let [witholding-records (filter #(= (:type %) "Withholding") employee-records) (let [witholding-records (filter #(= (:type %) "Withholding") employee-records)
insurance-records (filter (fn [{:keys [category type]}] insurance-records (filter (fn [{:keys [category type]}]
(and (= type "Withholding") (and (= type "Withholding")
(str/starts-with? category "NY Disability"))) (str/starts-with? category "NY Disability")))
employee-records)] employee-records)]
[{:account "Liabilities:Payable:Accounts" [{:account "Liabilities:Payable:Accounts"
:amount (total witholding-records) :currency "USD" :amount (total witholding-records) :currency "USD"
:meta (assoc-project projects name {:entity name})} :meta (assoc-project projects name {:entity name})}

View file

@ -63,19 +63,19 @@
"Reformat the parse tree into a similar data structure as used during import." "Reformat the parse tree into a similar data structure as used during import."
[tree] [tree]
(walk/postwalk #(cond (walk/postwalk #(cond
;; vector of digit chars to bigdec ;; vector of digit chars to bigdec
(and (vector? %) (char? (first %))) (apply str %) (and (vector? %) (char? (first %))) (apply str %)
;; vector of chars to string ;; vector of chars to string
(and (vector? %) (char? (first %))) (apply str %) (and (vector? %) (char? (first %))) (apply str %)
;; posting amount to bigdec ;; posting amount to bigdec
(and (map? %) (contains? % :amount)) (dissoc (update % :amount bigdec) :_) (and (map? %) (contains? % :amount)) (dissoc (update % :amount bigdec) :_)
;; flatten quoted-tokens ;; flatten quoted-tokens
(and (map? %) (contains? % :token)) (:token %) (and (map? %) (contains? % :token)) (:token %)
;; drop :_ keys ;; drop :_ keys
(map? %) (dissoc % :_) (map? %) (dissoc % :_)
;; convert vector of :key/:value maps to a map ;; convert vector of :key/:value maps to a map
(and (vector? %) (map? (first %)) (contains? (first %) :key)) (kv->map %) (and (vector? %) (map? (first %)) (contains? (first %) :key)) (kv->map %)
:else %) :else %)
tree)) tree))
(defn parse (defn parse

View file

@ -246,8 +246,7 @@
:amount 103.25M :amount 103.25M
:currency "USD" :currency "USD"
:meta {:entity "Citizen-Jill"}} :meta {:entity "Citizen-Jill"}}
{:account "Assets:FR:Check2721" :amount -206.51 :currency "USD"})}] {:account "Assets:FR:Check2721" :amount -206.51 :currency "USD"})}]]
]
(is (= actual expected)))) (is (= actual expected))))
(deftest retirement (deftest retirement
@ -390,5 +389,4 @@ DATE txn \"Paychex\" \"Monthly Payroll - PERIOD - Fee\"
(is (= actual expected)))) (is (= actual expected))))
(comment (comment
(t/run-all-tests) (t/run-all-tests))
)