Support rename of "Liability" to "Liability Expense" on recent CSVs
This commit is contained in:
parent
8c1dd97a8c
commit
5b8951c0f0
4 changed files with 71 additions and 33 deletions
28
resources/example-paychex-pay-item-details-2025.csv
Normal file
28
resources/example-paychex-pay-item-details-2025.csv
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,403b EE Pretax,Retirement,,,,,,1000,,,,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Exp Reimb Non Tax,Reimbursement,,,,,50,,,,,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Fed Income Tax,Withholding,,,,,,,,470.22,,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Fed Unemploy,Liability Expense,,,,,,,,,0,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Medicare,Withholding,,,,,,,,88,,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Medicare,Liability Expense,,,,,,,,,88,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Net Pay,Net Pay,,,,,,,,,,,4184.49
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Salary,Earnings,6068.99,,0,,,,,,,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Social Security,Withholding,,,,,,,,376.28,,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,Social Security,Liability Expense,,,,,,,,,376.28,,
|
||||||
|
Example Co Inc,"Citizen, Jack A",1,TN Unemploy,Liability Expense,,,,,,,,,0,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,403b EE Pretax,Retirement,,,,,,820,,,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Exp Reimb Non Tax,Reimbursement,,,,,50,,,,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Fed Income Tax,Withholding,,,,,,,,681.01,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Fed Unemploy,Liability Expense,,,,,,,,,0,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Medicare,Liability Expense,,,,,,,,,99.28,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Medicare,Withholding,,,,,,,,99.29,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Net Pay,Net Pay,,,,,,,,,,,4397.39
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,OR Disability PFL,Withholding,,,,,,,,41.08,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,OR Disability PFL,Liability Expense,,,,,,,,,0,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,OR EE Work Bene,Withholding,,,,,,,,0,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,OR ER Work Bene,Liability Expense,,,,,,,,,0,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,OR Income Tax,Withholding,,,,,,,,427.8,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,OR TRANS STT,Withholding,,,,,,,,6.03,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,OR Unemploy,Liability Expense,,,,,,,,,0,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Salary,Earnings,6847.12,,0,,,,,,,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Social Security,Liability Expense,,,,,,,,,424.52,,
|
||||||
|
Example Co Inc,"Citizen, Jill B",2,Social Security,Withholding,,,,,,,,424.52,,,
|
||||||
|
|
|
@ -228,7 +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")
|
;; CSV originally used "Liability", but changed to "Liability Expe
|
||||||
|
(and (contains? #{"Liability" "Liability Expense"} type)
|
||||||
(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"
|
||||||
|
|
@ -242,7 +243,7 @@
|
||||||
: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 (contains? #{"Liability" "Liability Expense"} type)
|
||||||
(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"
|
||||||
|
|
@ -349,11 +350,11 @@
|
||||||
: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 (contains? #{"Liability" "Liability Expense"} type)
|
||||||
(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 (contains? #{"Liability" "Liability Expense"} type)
|
||||||
(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"
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,19 @@
|
||||||
(:require [import]
|
(:require [import]
|
||||||
[clojure.java.io]
|
[clojure.java.io]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.test :as t :refer [deftest is]]))
|
[clojure.test :as t :refer [deftest is are]]))
|
||||||
|
|
||||||
|
|
||||||
|
(def paychex-csv-2024 (->> "example-paychex-pay-item-details-2024.csv"
|
||||||
|
clojure.java.io/resource
|
||||||
|
import/read-csv))
|
||||||
|
|
||||||
|
(def paychex-csv-2025 (->> "example-paychex-pay-item-details-2025.csv"
|
||||||
|
clojure.java.io/resource
|
||||||
|
import/read-csv))
|
||||||
|
|
||||||
(deftest net-pay
|
(deftest net-pay
|
||||||
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
|
(let [expected '[{:date "DATE"
|
||||||
actual (import/net-pay "DATE" "PERIOD" "TODO-PAY-INVOICE" {} records)
|
|
||||||
expected '[{:date "DATE"
|
|
||||||
:desc "Monthly Payroll - PERIOD - Net Pay"
|
:desc "Monthly Payroll - PERIOD - Net Pay"
|
||||||
:meta
|
:meta
|
||||||
{:program "Conservancy:Payroll"
|
{:program "Conservancy:Payroll"
|
||||||
|
|
@ -53,12 +60,12 @@
|
||||||
:amount -50M
|
:amount -50M
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:entity "Citizen-Jill" :tax-implication "Reimbursement"}})}]]
|
:meta {:entity "Citizen-Jill" :tax-implication "Reimbursement"}})}]]
|
||||||
(is (= actual expected))))
|
(are [records] (= expected (import/net-pay "DATE" "PERIOD" "TODO-PAY-INVOICE" {} records))
|
||||||
|
paychex-csv-2024
|
||||||
|
paychex-csv-2025)))
|
||||||
|
|
||||||
(deftest individual-taxes
|
(deftest individual-taxes
|
||||||
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
|
(let [expected '({:date "DATE"
|
||||||
actual (import/individual-taxes "DATE" "PERIOD" "TODO-PAY-INVOICE" "TODO-RETIREMENT-INVOICE" {} records)
|
|
||||||
expected '({:date "DATE"
|
|
||||||
:desc "Monthly Payroll - PERIOD - TAXES - Citizen-Jack"
|
:desc "Monthly Payroll - PERIOD - TAXES - Citizen-Jack"
|
||||||
:meta
|
:meta
|
||||||
{:project "Conservancy"
|
{:project "Conservancy"
|
||||||
|
|
@ -148,12 +155,12 @@
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:tax-implication "W2"}}
|
:meta {:tax-implication "W2"}}
|
||||||
{:account "Liabilities:Payable:Accounts" :amount 0M :currency "USD"})})]
|
{:account "Liabilities:Payable:Accounts" :amount 0M :currency "USD"})})]
|
||||||
(is (= actual expected))))
|
(are [records] (= expected (import/individual-taxes "DATE" "PERIOD" "TODO-PAY-INVOICE" "TODO-RETIREMENT-INVOICE" {} records))
|
||||||
|
paychex-csv-2024
|
||||||
|
paychex-csv-2025)))
|
||||||
|
|
||||||
(deftest employer-taxes
|
(deftest employer-taxes
|
||||||
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
|
(let [expected '[{:date "DATE"
|
||||||
actual (import/employer-taxes "DATE" "PERIOD" "TODO-PAY-INVOICE" {} records)
|
|
||||||
expected '[{:date "DATE"
|
|
||||||
:desc "Monthly Payroll - PERIOD - TAXES - Employer"
|
:desc "Monthly Payroll - PERIOD - TAXES - Employer"
|
||||||
:meta
|
:meta
|
||||||
{:program "Conservancy:Payroll"
|
{:program "Conservancy:Payroll"
|
||||||
|
|
@ -219,14 +226,14 @@
|
||||||
:amount -988.08M
|
:amount -988.08M
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:entity "Paychex" :tax-implication "Tax-Payment"}})}]]
|
:meta {:entity "Paychex" :tax-implication "Tax-Payment"}})}]]
|
||||||
(is (= actual expected))))
|
(are [records] (= expected (import/employer-taxes "DATE" "PERIOD" "TODO-PAY-INVOICE" {} records))
|
||||||
|
paychex-csv-2024
|
||||||
|
paychex-csv-2025)))
|
||||||
|
|
||||||
;; TODO: Add 2 x ACH credit tests
|
;; TODO: Add 2 x ACH credit tests
|
||||||
|
|
||||||
(deftest fees
|
(deftest fees
|
||||||
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
|
(let [expected '[{:date "DATE"
|
||||||
actual (import/fees "DATE" "PERIOD" "TODO-FEES-RECEIPT" "TODO-FEES-INVOICE" 206.51 {} records)
|
|
||||||
expected '[{:date "DATE"
|
|
||||||
:payee "Paychex"
|
:payee "Paychex"
|
||||||
:desc "Monthly Payroll - PERIOD - Fee"
|
:desc "Monthly Payroll - PERIOD - Fee"
|
||||||
:meta
|
:meta
|
||||||
|
|
@ -247,12 +254,12 @@
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:entity "Citizen-Jill"}}
|
:meta {:entity "Citizen-Jill"}}
|
||||||
{:account "Assets:Citizens:Check1273" :amount -206.51 :currency "USD"})}]]
|
{:account "Assets:Citizens:Check1273" :amount -206.51 :currency "USD"})}]]
|
||||||
(is (= actual expected))))
|
(are [records] (= expected (import/fees "DATE" "PERIOD" "TODO-FEES-RECEIPT" "TODO-FEES-INVOICE" 206.51 {} records))
|
||||||
|
paychex-csv-2024
|
||||||
|
paychex-csv-2025)))
|
||||||
|
|
||||||
(deftest retirement
|
(deftest retirement
|
||||||
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
|
(let [expected '[{:date "DATE"
|
||||||
actual (import/retirement "DATE" "PERIOD" "TODO-RETIREMENT-RECEIPT" "TODO-RETIREMENT-INVOICE" records)
|
|
||||||
expected '[{:date "DATE"
|
|
||||||
:desc
|
:desc
|
||||||
"ASCENSUS TRUST RET PLAN - ACH DEBIT - Vanguard 403(b) - PERIOD"
|
"ASCENSUS TRUST RET PLAN - ACH DEBIT - Vanguard 403(b) - PERIOD"
|
||||||
:meta
|
:meta
|
||||||
|
|
@ -273,12 +280,12 @@
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:entity "Citizen-Jill"}}
|
:meta {:entity "Citizen-Jill"}}
|
||||||
{:account "Assets:Citizens:Check1273" :amount -1820M :currency "USD"})}]]
|
{:account "Assets:Citizens:Check1273" :amount -1820M :currency "USD"})}]]
|
||||||
(is (= actual expected))))
|
(are [records] (= expected (import/retirement "DATE" "PERIOD" "TODO-RETIREMENT-RECEIPT" "TODO-RETIREMENT-INVOICE" records))
|
||||||
|
paychex-csv-2024
|
||||||
|
paychex-csv-2025)))
|
||||||
|
|
||||||
(deftest net-pay-ach-debit
|
(deftest net-pay-ach-debit
|
||||||
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
|
(let [expected [{:date "DATE"
|
||||||
actual (import/net-pay-ach-debit "DATE" "PERIOD" "TODO-PAY-RECEIPT" "TODO-PAY-INVOICE" {} records)
|
|
||||||
expected [{:date "DATE"
|
|
||||||
:desc "Monthly Payroll - PERIOD - Net Pay - ACH debit"
|
:desc "Monthly Payroll - PERIOD - Net Pay - ACH debit"
|
||||||
:meta {:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
|
:meta {:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
|
||||||
:invoice "TODO-PAY-INVOICE"
|
:invoice "TODO-PAY-INVOICE"
|
||||||
|
|
@ -311,12 +318,12 @@
|
||||||
:amount -100M
|
:amount -100M
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:entity "Paychex" :tax-implication "Reimbursement"}}]}]]
|
:meta {:entity "Paychex" :tax-implication "Reimbursement"}}]}]]
|
||||||
(is (= actual expected))))
|
(are [records] (= expected (import/net-pay-ach-debit "DATE" "PERIOD" "TODO-PAY-RECEIPT" "TODO-PAY-INVOICE" {} records))
|
||||||
|
paychex-csv-2024
|
||||||
|
paychex-csv-2025)))
|
||||||
|
|
||||||
(deftest taxes-ach-debit
|
(deftest taxes-ach-debit
|
||||||
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
|
(let [expected [{:date "DATE"
|
||||||
actual (import/taxes-ach-debit "DATE" "PERIOD" "TODO-PAY-RECEIPT" "TODO-PAY-INVOICE" {} records)
|
|
||||||
expected [{:date "DATE"
|
|
||||||
:desc "Monthly Payroll - PERIOD - TAXES - ACH debit"
|
:desc "Monthly Payroll - PERIOD - TAXES - ACH debit"
|
||||||
:meta {:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
|
:meta {:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
|
||||||
:invoice "TODO-PAY-INVOICE"
|
:invoice "TODO-PAY-INVOICE"
|
||||||
|
|
@ -347,7 +354,9 @@
|
||||||
:amount -3602.31M
|
:amount -3602.31M
|
||||||
:currency "USD"
|
:currency "USD"
|
||||||
:meta {:entity "Paychex" :tax-implication "Tax-Payment"}}]}]]
|
:meta {:entity "Paychex" :tax-implication "Tax-Payment"}}]}]]
|
||||||
(is (= actual expected))))
|
(are [records] (= expected (import/taxes-ach-debit "DATE" "PERIOD" "TODO-PAY-RECEIPT" "TODO-PAY-INVOICE" {} records))
|
||||||
|
paychex-csv-2024
|
||||||
|
paychex-csv-2025)))
|
||||||
|
|
||||||
(deftest render-transaction
|
(deftest render-transaction
|
||||||
(let [transaction '{:date "DATE"
|
(let [transaction '{:date "DATE"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue