(ns auto-ap.import.intuit-test
  (:require [auto-ap.import.intuit :as sut]
            [clojure.test :as t]))

(def base-transaction {:Memo/Description "this is a description"
                       :Amount "45.23"
                       :Date "2021-10-11"})

(t/deftest intuit->transaction
  (t/testing "Should parse dates"
    (t/is (= #inst "2021-01-01T00:00:00-08:00" (:transaction/date (sut/intuit->transaction (assoc base-transaction :Date "2021-01-01")))))
    (t/is (= #inst "2021-06-01T00:00:00-07:00" (:transaction/date (sut/intuit->transaction (assoc base-transaction :Date "2021-06-01")))))))


(t/deftest intuits->transactions
  (t/testing "should give unique ids to duplicates"
    (t/is (= ["2021-10-11T00:00:00.000-07:00-123-this is a description-45.23-0-345"
              "2021-10-11T00:00:00.000-07:00-123-this is a description-45.23-1-345"] (map :transaction/raw-id (sut/intuits->transactions [base-transaction base-transaction]
                                                                                                   123
                                                                                                   345))))))
