payroll-import/test/parse_test.clj

43 lines
1.7 KiB
Clojure
Raw Normal View History

(ns parse-test
(:require [parse]
[clojure.string :as str]
[clojure.test :refer [deftest is]]))
(deftest test-parse
(let [transaction (str/triml "
DATE txn \"Paychex\" \"Monthly Payroll - PERIOD - Fee\"
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\"
Expenses:Payroll:Fees 103.26 USD
entity: \"Citizen-Jack\"
Expenses:Payroll:Fees 103.25 USD
entity: \"Citizen-Jill\"
Assets:FR:Check2721 -206.51 USD
")
expected '[{: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"})}]]
(is (= (parse/parse transaction) expected))))