                                                     (:transaction-date trans-ref))
                                                  (= (:description %)
                                                     (:description trans-ref))))
-                                      first
-                                      :id))))
+                                      (map (juxt :id :transaction-date))
+                                      first))))
 
 (defn- resolve-image
-  [context model]
+  [model context]
   (assoc model :image-id (->> context
                               :images
                               (filter #(= (:original-filenamme %)
                                           (:image-id model)))
                               first)))
 
+(defn- create-attachment
+  [model storage]
+  (attachments/create storage model))
+
+(defn- rearrange-transaction-attributes
+  [attachment]
+  (assoc attachment :transaction-id (-> attachment :transaction-id first)
+                    :transaction-date (-> attachment :transaction-id second)))
+
 (defn- create-attachments
   [storage context attachments]
-  (mapv #(->> %
-              (resolve-transaction context)
-              (resolve-image context)
-              (attachments/create storage))
+  (mapv #(-> %
+             (resolve-transaction context)
+             rearrange-transaction-attributes
+             (resolve-image context)
+             (create-attachment storage)
+             throw-on-invalid)
         attachments))
 
 (defn- realize-attachments
-  [storage context]
+  [context storage]
   (update-in context [:attachments] #(create-attachments storage context %)))
 
 (defn- append-budget-items
-  [storage context items budget]
+  [budget storage context items]
   (assoc budget :items (->> items
-                            (map #(resolve-account context %))
+                            (map #(resolve-account % context))
                             (map #(assoc % :budget-id (:id budget)))
                             (mapv #(budgets/create-item storage %)))))
 
+(defn- create-budget
+  [model storage]
+  (budgets/create storage model))
+
 (defn- create-budgets
   [storage context budgets]
   (mapv (fn [attributes]
-          (->> attributes
-               (resolve-entity context)
-               (budgets/create storage)
-               (append-budget-items storage context (:items attributes))))
+          (-> attributes
+              (resolve-entity context)
+              (create-budget storage)
+              (append-budget-items storage context (:items attributes))))
         budgets))
 
 (defn- realize-budgets
-  [storage context]
+  [context storage]
   (update-in context [:budgets] #(create-budgets storage context %)))
+
+(defn- create-commodity
+  [model storage]
+  (commodities/create storage model))
 
 (defn- create-commodities
   [storage context commodities]
   (mapv (fn [attributes]
-          (->> attributes
-               (resolve-entity context)
-               (commodities/create storage)))
+          (-> attributes
+              (resolve-entity context)
+              (create-commodity storage)))
         commodities))
 
 (defn- realize-commodities
-  [storage context]
+  [context storage]
   (update-in context [:commodities] #(create-commodities storage context %)))
+
+(defn- create-price
+  [model storage]
+  (prices/create storage model))
 
 (defn- create-prices
   [storage context prices]
   (mapv (fn [attributes]
-          (->> attributes
-               (resolve-commodity context)
-               (prices/create storage)))
+          (-> attributes
+              (resolve-commodity context)
+              (create-price storage)))
         prices))
 
 (defn- realize-prices
-  [storage context]
+  [context storage]
   (update-in context [:prices] #(create-prices storage context %)))
+
+(defn- create-lot
+  [model storage]
+  (lots/create storage model))
 
 (defn- create-lots
   [storage context lots]
   (mapv (fn [attributes]
-          (->> attributes
-               (resolve-commodity context)
-               (resolve-account context)
-               (lots/create storage)))
+          (-> attributes
+              (resolve-commodity context)
+              (resolve-account context)
+              (create-lot storage)))
         lots))
 
 (defn- realize-lots
-  [storage context]
+  [context storage]
   (update-in context [:lots] #(create-lots storage context %)))
 
 (defn- find-lot
   [context attr]
   (let [{:keys [account-id
                 commodity-id
-                purchase-date]} (->> attr
-                                     (resolve-account context)
-                                     (resolve-commodity context))]
+                purchase-date]} (-> attr
+                                    (resolve-account context)
+                                    (resolve-commodity context))]
     (->> context
          :lots
          (filter #(and (= account-id (:account-id %))

       users))

(defn- realize-users
  [storage context]
  (update-in context [:users] #(create-users storage %)))

(defn- find-user

       first))

(defn- resolve-account
  [model context]
  (update-in model [:account-id] #(:id (find-account context %))))

(defn- coerce-amount
