 (def app-state (atom 
   {:screen :import
    :txs sample-txs 
+   :register-parts []
    :entry-parts empty-entry-parts}))
 
 (defn store-event [ev]

    (compare (Math/abs n2) (Math/abs n1))
    (compare n1 n2)))
    
(defn tx-tds [tx]
  (let [[from-part to-part :as parts] (sort-by :amount cmp-sign-abs (:parts tx))]
    (update-in 
      (if (single-row-tx? parts)
        [{:to-account (:account to-part)
          :from-account (:account from-part)
          :amount (fixpt->str (:amount to-part))
          :note (:note to-part)}]
        (vec
          (for [{:keys [account amount note]} parts
                :let [pos (pos? amount)]]
            {:amount (fixpt->str (if pos amount (- amount)))
             (if pos :to-account :from-account) account
             :note note})))
      [0] merge (select-keys tx [:date :description]))))

(defn fixpt->str [n]
  (.toFixed (/ n 100) 2))
  
(defn account-key->vec [account]
  (str/split (subs (str account) 1) "-"))

(defn account-vec->str [account]
  (str/join "." (map ucfirst account)))

(def account-key->str (comp account-vec->str account-key->vec))

(defn str->account [account]
  (keyword (str/join "-" (map #(.toLowerCase %) (str/split account ".")))))
