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
"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)))
(def demo-options
@ -108,6 +108,4 @@
;; Print out text transactions
(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
;; as discussed in beancount/doc/Payroll.md.
insurance-records (filter (fn [{:keys [category type]}]
(and (= type "Withholding")
(str/starts-with? category "NY Disability"))) employee-records)
(and (= type "Withholding")
(str/starts-with? category "NY Disability"))) employee-records)
total-retirement (total retirement-records)
retirement-postings (for [{:keys [category amount]} retirement-records]
(if (= category "403b ER match")
@ -228,8 +228,8 @@
:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"}
:postings []}
liability-records (filter (fn [{:keys [category type]}]
(and (= type "Liability")
(not (str/includes? category "Unemploy")))) records)
(and (= type "Liability")
(not (str/includes? category "Unemploy")))) records)
liability-postings (for [{:keys [amount name category]} liability-records]
{:account "Expenses:Payroll:Tax"
:amount amount :currency "USD"
@ -242,8 +242,8 @@
:payroll-type (str/replace (cat->payroll-type category) "Tax:" "")})})
total-liabilities (total liability-records)
unemploy-records (filter (fn [{:keys [category type]}]
(and (= type "Liability")
(str/includes? category "Unemploy"))) records)
(and (= type "Liability")
(str/includes? category "Unemploy"))) records)
unemploy-postings (for [{:keys [amount name category]} unemploy-records]
{:account "Expenses:Payroll:Tax"
:amount amount :currency "USD"
@ -305,7 +305,6 @@
all-postings (concat liability-postings asset-postings)]
[(assoc template :postings all-postings)]))
(defn net-pay-ach-debit
"Return a transaction paying off net pay liabilities"
[date period receipt-no invoice-no projects records]
@ -350,12 +349,12 @@
:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"}
:postings []}
liability-records (filter (fn [{:keys [category type]}]
(and (= type "Liability")
(not (str/includes? category "Unemploy")))) records)
(and (= type "Liability")
(not (str/includes? category "Unemploy")))) records)
total-liabilities (total liability-records)
unemploy-records (filter (fn [{:keys [category type]}]
(and (= type "Liability")
(str/includes? category "Unemploy"))) records)
(and (= type "Liability")
(str/includes? category "Unemploy"))) records)
total-unemploy (total unemploy-records)
liability-postings [{:account "Liabilities:Payable:Accounts"
:amount (+ total-liabilities total-unemploy) :currency "USD"
@ -364,9 +363,9 @@
(for [[name employee-records] (group-by :name records)]
(let [witholding-records (filter #(= (:type %) "Withholding") employee-records)
insurance-records (filter (fn [{:keys [category type]}]
(and (= type "Withholding")
(str/starts-with? category "NY Disability")))
employee-records)]
(and (= type "Withholding")
(str/starts-with? category "NY Disability")))
employee-records)]
[{:account "Liabilities:Payable:Accounts"
:amount (total witholding-records) :currency "USD"
: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."
[tree]
(walk/postwalk #(cond
;; vector of digit chars to bigdec
(and (vector? %) (char? (first %))) (apply str %)
;; vector of chars to string
(and (vector? %) (char? (first %))) (apply str %)
;; posting amount to bigdec
(and (map? %) (contains? % :amount)) (dissoc (update % :amount bigdec) :_)
;; flatten quoted-tokens
(and (map? %) (contains? % :token)) (:token %)
;; drop :_ keys
(map? %) (dissoc % :_)
;; convert vector of :key/:value maps to a map
(and (vector? %) (map? (first %)) (contains? (first %) :key)) (kv->map %)
:else %)
;; vector of digit chars to bigdec
(and (vector? %) (char? (first %))) (apply str %)
;; vector of chars to string
(and (vector? %) (char? (first %))) (apply str %)
;; posting amount to bigdec
(and (map? %) (contains? % :amount)) (dissoc (update % :amount bigdec) :_)
;; flatten quoted-tokens
(and (map? %) (contains? % :token)) (:token %)
;; drop :_ keys
(map? %) (dissoc % :_)
;; convert vector of :key/:value maps to a map
(and (vector? %) (map? (first %)) (contains? (first %) :key)) (kv->map %)
:else %)
tree))
(defn parse

View file

@ -246,8 +246,7 @@
:amount 103.25M
:currency "USD"
: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))))
(deftest retirement
@ -390,5 +389,4 @@ DATE txn \"Paychex\" \"Monthly Payroll - PERIOD - Fee\"
(is (= actual expected))))
(comment
(t/run-all-tests)
)
(t/run-all-tests))