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