Fix :dev alias deps, ungroup employer-taxes data, avoid "super" lingo
This commit is contained in:
parent
909aaff0bb
commit
5f801c99f3
3 changed files with 45 additions and 47 deletions
2
deps.edn
2
deps.edn
|
@ -3,7 +3,7 @@
|
||||||
org.clojure/data.csv {:mvn/version "1.0.1"}
|
org.clojure/data.csv {:mvn/version "1.0.1"}
|
||||||
org.clojure/tools.cli {:mvn/version "1.1.230"}}
|
org.clojure/tools.cli {:mvn/version "1.1.230"}}
|
||||||
:aliases
|
:aliases
|
||||||
{:dev {:deps {lambdaisland/deep-diff2 {:mvn/version "2.10.211"}}}
|
{:dev {:extra-deps {lambdaisland/deep-diff2 {:mvn/version "2.10.211"}}}
|
||||||
;; Run with clj -T:build function-in-build
|
;; Run with clj -T:build function-in-build
|
||||||
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"}}
|
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"}}
|
||||||
:ns-default build}}}
|
:ns-default build}}}
|
||||||
|
|
|
@ -141,7 +141,7 @@
|
||||||
"Return a transaction of expenses/witholding for each employee."
|
"Return a transaction of expenses/witholding for each employee."
|
||||||
[date period receipt-no invoice-no groups]
|
[date period receipt-no invoice-no groups]
|
||||||
(for [[name records] groups]
|
(for [[name records] groups]
|
||||||
(let [super-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.
|
;; 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 expense/asset postings for
|
||||||
|
@ -149,23 +149,23 @@
|
||||||
;; with Rosanne.
|
;; with Rosanne.
|
||||||
insurance-lines (filter #(and (= (:type %) "Withholding")
|
insurance-lines (filter #(and (= (:type %) "Withholding")
|
||||||
(str/starts-with? (:category %) "NY Disability")) records)
|
(str/starts-with? (:category %) "NY Disability")) records)
|
||||||
total-super (->> super-lines
|
total-retirement (->> retirement-lines
|
||||||
(map :amount)
|
(map :amount)
|
||||||
(apply +))
|
(apply +))
|
||||||
super-postings (for [{:keys [category amount]} super-lines]
|
retirement-postings (for [{:keys [category amount]} retirement-lines]
|
||||||
(if (= category "403b ER match")
|
(if (= category "403b ER match")
|
||||||
{:account "Expenses:Payroll:Salary"
|
{:account "Expenses:Payroll:Salary"
|
||||||
:amount amount
|
:amount amount
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:payroll-type "US:403b:Match"
|
:meta {:payroll-type "US:403b:Match"
|
||||||
:invoice invoice-no}}
|
:invoice invoice-no}}
|
||||||
{:account "Expenses:Payroll:Salary"
|
{:account "Expenses:Payroll:Salary"
|
||||||
:amount amount
|
:amount amount
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:payroll-type "US:403b:Employee"
|
:meta {:payroll-type "US:403b:Employee"
|
||||||
:invoice invoice-no}}))
|
:invoice invoice-no}}))
|
||||||
liability-postings [{:account "Liabilities:Payable:Accounts"
|
liability-postings [{:account "Liabilities:Payable:Accounts"
|
||||||
:amount (- total-super)
|
:amount (- total-retirement)
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:invoice invoice-no}}]
|
:meta {:invoice invoice-no}}]
|
||||||
withholding-postings (for [{:keys [category amount]} witholding-lines]
|
withholding-postings (for [{:keys [category amount]} witholding-lines]
|
||||||
|
@ -192,7 +192,7 @@
|
||||||
:receipt receipt-no
|
:receipt receipt-no
|
||||||
:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"})
|
:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"})
|
||||||
:postings (concat
|
:postings (concat
|
||||||
super-postings
|
retirement-postings
|
||||||
liability-postings
|
liability-postings
|
||||||
withholding-postings
|
withholding-postings
|
||||||
withholding-asset-postings
|
withholding-asset-postings
|
||||||
|
@ -202,34 +202,30 @@
|
||||||
(defn employer-taxes
|
(defn employer-taxes
|
||||||
"Return an employer taxes transaction."
|
"Return an employer taxes transaction."
|
||||||
[date period receipt-no groups]
|
[date period receipt-no groups]
|
||||||
(let [liability-postings (apply concat
|
(let [ungrouped (concat (vals groups)) ; Grouping by employee not useful here
|
||||||
(for [[name records] groups]
|
liability-lines (filter #(and (= (:type %) "Liability")
|
||||||
(let [liability-lines (filter #(and (= (:type %) "Liability")
|
(not (str/includes? (:category %) "Unemploy"))) ungrouped)
|
||||||
(not (str/includes? (:category %) "Unemploy"))) records)]
|
liability-postings (for [{:keys [category amount]} liability-lines]
|
||||||
(for [{:keys [category amount]} liability-lines]
|
{:account "Expenses:Payroll:Tax"
|
||||||
{:account "Expenses:Payroll:Tax"
|
:amount amount
|
||||||
:amount amount
|
:currency "USD"
|
||||||
:currency "USD"
|
;; TODO: Check lack of ":Tax:" with Rosanne.
|
||||||
;; TODO: Check lack of ":Tax:" with Rosanne.
|
:meta (assoc-project
|
||||||
:meta (assoc-project
|
name
|
||||||
name
|
{:entity name
|
||||||
{:entity name
|
:payroll-type (str/replace (cat->payroll-type category) "Tax:" "")})})
|
||||||
:payroll-type (str/replace (cat->payroll-type category) "Tax:" "")})}))))
|
|
||||||
total-liabilities (->> liability-postings (map :amount) (reduce +))
|
total-liabilities (->> liability-postings (map :amount) (reduce +))
|
||||||
unemploy-postings (apply concat
|
unemploy-lines (filter #(and (= (:type %) "Liability")
|
||||||
(for [[name records] groups]
|
(str/includes? (:category %) "Unemploy")) ungrouped)
|
||||||
(let [unemploy-lines (filter #(and (= (:type %) "Liability")
|
unemploy-postings (for [{:keys [amount category]} unemploy-lines]
|
||||||
(str/includes? (:category %) "Unemploy")) records)]
|
{:account "Expenses:Payroll:Tax"
|
||||||
(for [{:keys [amount category]} unemploy-lines]
|
:amount amount
|
||||||
{:account "Expenses:Payroll:Tax"
|
:currency "USD"
|
||||||
:amount amount
|
:meta (assoc-project
|
||||||
:currency "USD"
|
name
|
||||||
:meta (assoc-project
|
{:entity (first (str/split category #" "))
|
||||||
name
|
:memo name ; TODO: Karen doesn't have a memo in January 2024
|
||||||
{:entity (first (str/split category #" "))
|
:payroll-type (str "US:" (cat->payroll-type category))})})
|
||||||
;; TODO: Karen doesn't have a memo in January 2024
|
|
||||||
:memo name
|
|
||||||
: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"
|
||||||
:amount (- (+ total-liabilities total-unemploy))
|
:amount (- (+ total-liabilities total-unemploy))
|
||||||
|
|
|
@ -87,7 +87,9 @@
|
||||||
(defn parse
|
(defn parse
|
||||||
"Parse a Beancount transaction into an intermediate data structure.
|
"Parse a Beancount transaction into an intermediate data structure.
|
||||||
Used in development to compare a hand-written Beancount import side-by-side
|
Used in development to compare a hand-written Beancount import side-by-side
|
||||||
with an automatically generated import."
|
with an automatically generated import using deep-diff2. We can't directly
|
||||||
|
compare the text output because the ordering and spacing is too hard to get to
|
||||||
|
match exactly."
|
||||||
[text]
|
[text]
|
||||||
(let [tree (s/conform ::transactions (conj (vec text) \newline))]
|
(let [tree (s/conform ::transactions (conj (vec text) \newline))]
|
||||||
(convert-parse-tree tree)))
|
(convert-parse-tree tree)))
|
||||||
|
|
Loading…
Reference in a new issue