Add tests for ACH debit transactions

This commit is contained in:
Ben Sturmfels 2024-03-15 13:51:04 +11:00
parent 0a5f798aa4
commit da22fc9339
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -8,14 +8,14 @@
[clojure.test :as t :refer [deftest is]])) [clojure.test :as t :refer [deftest is]]))
(deftest net-pay (deftest net-pay
(let [data (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv")) (let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
actual (import/net-pay "DATE" "PERIOD" "TODO-PAY-RECEIPT" {} data) actual (import/net-pay "DATE" "PERIOD" "TODO-PAY-INVOICE" {} records)
expected '[{:date "DATE" expected '[{:date "DATE"
:desc "Monthly Payroll - PERIOD - Net Pay" :desc "Monthly Payroll - PERIOD - Net Pay"
:meta :meta
{:program "Conservancy:Payroll" {:program "Conservancy:Payroll"
:project "Conservancy" :project "Conservancy"
:receipt "TODO-PAY-RECEIPT" :invoice "TODO-PAY-INVOICE"
:approval :approval
"Financial/Employment-Records/memo-re-board-approval-of-payroll.txt" "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
:tax-implication "W2" :tax-implication "W2"
@ -25,7 +25,7 @@
:amount 4134.49M :amount 4134.49M
:currency "USD" :currency "USD"
:meta {:entity "Citizen-Jack"}} :meta {:entity "Citizen-Jack"}}
{:account "Assets:FR:Check2721" {:account "Liabilities:Payable:Accounts"
:amount -4134.49M :amount -4134.49M
:currency "USD" :currency "USD"
:meta {:entity "Citizen-Jack"}} :meta {:entity "Citizen-Jack"}}
@ -33,7 +33,7 @@
:amount 50M :amount 50M
:currency "USD" :currency "USD"
:meta {:entity "Citizen-Jack" :payroll-type "US:Reimbursement"}} :meta {:entity "Citizen-Jack" :payroll-type "US:Reimbursement"}}
{:account "Assets:FR:Check2721" {:account "Liabilities:Payable:Accounts"
:amount -50M :amount -50M
:currency "USD" :currency "USD"
:meta {:entity "Citizen-Jack" :tax-implication "Reimbursement"}} :meta {:entity "Citizen-Jack" :tax-implication "Reimbursement"}}
@ -41,7 +41,7 @@
:amount 4347.39M :amount 4347.39M
:currency "USD" :currency "USD"
:meta {:entity "Citizen-Jill"}} :meta {:entity "Citizen-Jill"}}
{:account "Assets:FR:Check2721" {:account "Liabilities:Payable:Accounts"
:amount -4347.39M :amount -4347.39M
:currency "USD" :currency "USD"
:meta {:entity "Citizen-Jill"}} :meta {:entity "Citizen-Jill"}}
@ -49,22 +49,22 @@
:amount 50M :amount 50M
:currency "USD" :currency "USD"
:meta {:entity "Citizen-Jill" :payroll-type "US:Reimbursement"}} :meta {:entity "Citizen-Jill" :payroll-type "US:Reimbursement"}}
{:account "Assets:FR:Check2721" {:account "Liabilities:Payable:Accounts"
: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)))) (is (= actual expected))))
(deftest individual-taxes (deftest individual-taxes
(let [data (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv")) (let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
actual (import/individual-taxes "DATE" "PERIOD" "TODO-PAY-RECEIPT" "TODO-RETIREMENT-INVOICE" {} data) actual (import/individual-taxes "DATE" "PERIOD" "TODO-PAY-INVOICE" "TODO-RETIREMENT-INVOICE" {} records)
expected '({:date "DATE" expected '({:date "DATE"
:desc "Monthly Payroll - PERIOD - TAXES - Citizen-Jack" :desc "Monthly Payroll - PERIOD - TAXES - Citizen-Jack"
:meta :meta
{:project "Conservancy" {:project "Conservancy"
:program "Conservancy:Payroll" :program "Conservancy:Payroll"
:entity "Citizen-Jack" :entity "Citizen-Jack"
:receipt "TODO-PAY-RECEIPT" :invoice "TODO-PAY-INVOICE"
:approval :approval
"Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"} "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"}
:postings :postings
@ -90,18 +90,18 @@
:amount 376.28M :amount 376.28M
:currency "USD" :currency "USD"
:meta {:payroll-type "US:Tax:SocialSecurity"}} :meta {:payroll-type "US:Tax:SocialSecurity"}}
{:account "Assets:FR:Check2721" {:account "Liabilities:Payable:Accounts"
:amount -934.50M :amount -934.50M
:currency "USD" :currency "USD"
:meta {:tax-implication "W2"}} :meta {:tax-implication "W2"}}
{:account "Assets:FR:Check2721" :amount 0M :currency "USD"})} {:account "Liabilities:Payable:Accounts" :amount 0M :currency "USD"})}
{:date "DATE" {:date "DATE"
:desc "Monthly Payroll - PERIOD - TAXES - Citizen-Jill" :desc "Monthly Payroll - PERIOD - TAXES - Citizen-Jill"
:meta :meta
{:project "Conservancy" {:project "Conservancy"
:program "Conservancy:Payroll" :program "Conservancy:Payroll"
:entity "Citizen-Jill" :entity "Citizen-Jill"
:receipt "TODO-PAY-RECEIPT" :invoice "TODO-PAY-INVOICE"
:approval :approval
"Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"} "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"}
:postings :postings
@ -143,22 +143,22 @@
:amount 424.52M :amount 424.52M
:currency "USD" :currency "USD"
:meta {:payroll-type "US:Tax:SocialSecurity"}} :meta {:payroll-type "US:Tax:SocialSecurity"}}
{:account "Assets:FR:Check2721" {:account "Liabilities:Payable:Accounts"
:amount -1679.73M :amount -1679.73M
:currency "USD" :currency "USD"
:meta {:tax-implication "W2"}} :meta {:tax-implication "W2"}}
{:account "Assets:FR:Check2721" :amount 0M :currency "USD"})})] {:account "Liabilities:Payable:Accounts" :amount 0M :currency "USD"})})]
(is (= actual expected)))) (is (= actual expected))))
(deftest employer-taxes (deftest employer-taxes
(let [data (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv")) (let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
actual (import/employer-taxes "DATE" "PERIOD" "TODO-PAY-RECEIPT" {} data) actual (import/employer-taxes "DATE" "PERIOD" "TODO-PAY-INVOICE" {} records)
expected '[{:date "DATE" expected '[{:date "DATE"
:desc "Monthly Payroll - PERIOD - TAXES - Employer" :desc "Monthly Payroll - PERIOD - TAXES - Employer"
:meta :meta
{:program "Conservancy:Payroll" {:program "Conservancy:Payroll"
:project "Conservancy" :project "Conservancy"
:receipt "TODO-PAY-RECEIPT" :invoice "TODO-PAY-INVOICE"
:approval :approval
"Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"} "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"}
:postings :postings
@ -215,15 +215,17 @@
{:entity "OR" {:entity "OR"
:memo "Citizen-Jill" :memo "Citizen-Jill"
:payroll-type "US:OR:Unemployment"}} :payroll-type "US:OR:Unemployment"}}
{:account "Assets:FR:Check2721" {:account "Liabilities:Payable:Accounts"
: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)))) (is (= actual expected))))
;; TODO: Add 2 x ACH credit tests
(deftest fees (deftest fees
(let [data (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv")) (let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
actual (import/fees "DATE" "PERIOD" "TODO-FEES-RECEIPT" "TODO-FEES-INVOICE" 206.51 {} data) actual (import/fees "DATE" "PERIOD" "TODO-FEES-RECEIPT" "TODO-FEES-INVOICE" 206.51 {} records)
expected '[{:date "DATE" expected '[{:date "DATE"
:payee "Paychex" :payee "Paychex"
:desc "Monthly Payroll - PERIOD - Fee" :desc "Monthly Payroll - PERIOD - Fee"
@ -249,8 +251,8 @@
(is (= actual expected)))) (is (= actual expected))))
(deftest retirement (deftest retirement
(let [data (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv")) (let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
actual (import/retirement "DATE" "PERIOD" "TODO-RETIREMENT-RECEIPT" "TODO-RETIREMENT-INVOICE" data) actual (import/retirement "DATE" "PERIOD" "TODO-RETIREMENT-RECEIPT" "TODO-RETIREMENT-INVOICE" records)
expected '[{:date "DATE" 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"
@ -274,6 +276,80 @@
{:account "Assets:FR:Check1345" :amount -1820M :currency "USD"})}]] {:account "Assets:FR:Check1345" :amount -1820M :currency "USD"})}]]
(is (= actual expected)))) (is (= actual expected))))
(deftest net-pay-ach-debit
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
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"
:meta {:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
:invoice "TODO-PAY-INVOICE"
:payroll-type "US:General"
:program "Conservancy:Payroll"
:project "Conservancy"
:receipt "TODO-PAY-RECEIPT"
:tax-implication "W2"}
:postings [{:account "Liabilities:Payable:Accounts"
:amount 4134.49M
:currency "USD"
:meta {:entity "Citizen-Jack"}}
{:account "Liabilities:Payable:Accounts"
:amount 50M
:currency "USD"
:meta {:entity "Citizen-Jack"}}
{:account "Liabilities:Payable:Accounts"
:amount 4347.39M
:currency "USD"
:meta {:entity "Citizen-Jill"}}
{:account "Liabilities:Payable:Accounts"
:amount 50M
:currency "USD"
:meta {:entity "Citizen-Jill"}}
{:account "Assets:FR:Check2721"
:amount -8481.88M
:currency "USD"
:meta {:entity "Paychex" :tax-implication "W2"}}
{:account "Assets:FR:Check2721"
:amount -100M
:currency "USD"
:meta {:entity "Paychex" :tax-implication "Reimbursement"}}]}]]
(is (= actual expected))))
(deftest taxes-ach-debit
(let [records (import/read-csv (clojure.java.io/resource "example-paychex-pay-item-details.csv"))
actual (import/taxes-ach-debit "DATE" "PERIOD" "TODO-PAY-RECEIPT" "TODO-PAY-INVOICE" {} records)
expected [{:date "DATE"
:desc "Monthly Payroll - PERIOD - TAXES - ACH debit"
:meta {:approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
:invoice "TODO-PAY-INVOICE"
:program "Conservancy:Payroll"
:project "Conservancy"
:receipt "TODO-PAY-RECEIPT"}
:postings [{:account "Liabilities:Payable:Accounts"
:amount 934.50M
:currency "USD"
:meta {:entity "Citizen-Jack"}}
{:account "Liabilities:Payable:Accounts"
:amount 0M
:currency "USD"
:meta {:entity "Citizen-Jack"}}
{:account "Liabilities:Payable:Accounts"
:amount 1679.73M
:currency "USD"
:meta {:entity "Citizen-Jill"}}
{:account "Liabilities:Payable:Accounts"
:amount 0M
:currency "USD"
:meta {:entity "Citizen-Jill"}}
{:account "Liabilities:Payable:Accounts"
:amount 988.08M
:currency "USD"
:meta {:entity "Paychex"}}
{:account "Assets:FR:Check2721"
:amount -3602.31M
:currency "USD"
:meta {:entity "Paychex" :tax-implication "Tax-Payment"}}]}]]
(is (= actual expected))))
(deftest render-transaction (deftest render-transaction
(let [transaction '{:date "DATE" (let [transaction '{:date "DATE"
:payee "Paychex" :payee "Paychex"