Add tests for ACH debit transactions
This commit is contained in:
parent
0a5f798aa4
commit
da22fc9339
1 changed files with 119 additions and 43 deletions
|
@ -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,28 +276,102 @@
|
|||
{: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"
|
||||
:desc "Monthly Payroll - PERIOD - Fee"
|
||||
:meta
|
||||
{:program "Conservancy:Payroll"
|
||||
:project "Conservancy"
|
||||
:receipt "TODO-FEES-RECEIPT"
|
||||
:invoice "TODO-FEES-INVOICE"
|
||||
:approval
|
||||
"Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
|
||||
:tax-implication "USA-Corporation"}
|
||||
:postings
|
||||
({:account "Expenses:Payroll:Fees"
|
||||
:amount 103.26M
|
||||
:currency "USD"
|
||||
:meta {:entity "Citizen-Jack"}}
|
||||
{:account "Expenses:Payroll:Fees"
|
||||
:amount 103.25M
|
||||
:currency "USD"
|
||||
:meta {:entity "Citizen-Jill"}}
|
||||
{:account "Assets:FR:Check2721" :amount -206.51M :currency "USD"})}
|
||||
:payee "Paychex"
|
||||
:desc "Monthly Payroll - PERIOD - Fee"
|
||||
:meta
|
||||
{:program "Conservancy:Payroll"
|
||||
:project "Conservancy"
|
||||
:receipt "TODO-FEES-RECEIPT"
|
||||
:invoice "TODO-FEES-INVOICE"
|
||||
:approval
|
||||
"Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"
|
||||
:tax-implication "USA-Corporation"}
|
||||
:postings
|
||||
({:account "Expenses:Payroll:Fees"
|
||||
:amount 103.26M
|
||||
:currency "USD"
|
||||
:meta {:entity "Citizen-Jack"}}
|
||||
{:account "Expenses:Payroll:Fees"
|
||||
:amount 103.25M
|
||||
:currency "USD"
|
||||
:meta {:entity "Citizen-Jill"}}
|
||||
{:account "Assets:FR:Check2721" :amount -206.51M :currency "USD"})}
|
||||
actual (import/render-transaction transaction)
|
||||
expected (str/triml "
|
||||
DATE txn \"Paychex\" \"Monthly Payroll - PERIOD - Fee\"
|
||||
|
|
Loading…
Reference in a new issue