lots of QOL improvements.

This commit is contained in:
Bryce Covert
2020-07-31 18:26:57 -07:00
parent 98f0d40313
commit be9c789003
15 changed files with 302 additions and 282 deletions

View File

@@ -64,6 +64,9 @@
(defn parse-vendor-id [{:keys [vendor]}]
(:db/id vendor))
(defn parse-automatically-paid-when-due [{:keys [vendor client-id]}]
(boolean ((set (map :db/id (:vendor/automatically-paid-when-due vendor))) client-id)))
(defn parse-amount [i]
(try
(Double/parseDouble (str/replace (or (second
@@ -121,6 +124,7 @@
(map (parse-or-error :client-id #(parse-client % all-clients)))
(map (parse-or-error :vendor #(parse-vendor % all-vendors)))
(map (parse-or-error :vendor-id #(parse-vendor-id %)))
(map (parse-or-error :automatically-paid-when-due #(parse-automatically-paid-when-due %)))
(map (parse-or-error :account-id parse-account-numeric-code))
(map (parse-or-error :invoice-number parse-invoice-number))
(map (parse-or-error :total parse-amount))
@@ -131,13 +135,14 @@
(defn invoice-rows->transaction [rows]
(->> rows
(mapcat (fn [{:keys [vendor-id total client-id amount date invoice-number default-location account-id check vendor]}]
(mapcat (fn [{:keys [vendor-id total client-id amount date invoice-number default-location account-id check vendor automatically-paid-when-due]}]
(let [invoice (cond->
#:invoice {:db/id (.toString (java.util.UUID/randomUUID))
:vendor vendor-id
:client client-id
:default-location default-location
:import-status :import-status/imported
:automatically-paid-when-due automatically-paid-when-due
#_#_:default-expense-account default-expense-account
:total total
:outstanding-balance (if (= "Cash" check)
@@ -245,7 +250,8 @@
". "
(.toString e))
{:args [ invoice-number matching-vendor (:db/id matching-client)]})))
))]
))
automatically-paid-for (set (map :db/id (:vendor/automatically-paid-when-due matching-vendor)))]
(cond
(not (and matching-location matching-client))
@@ -259,6 +265,7 @@
:invoice/client-identifier customer-identifier
:invoice/vendor (:db/id matching-vendor)
:invoice/invoice-number invoice-number
:invoice/automatically-paid-when-due (boolean (automatically-paid-for (:db/id matching-client)))
:invoice/total (Double/parseDouble total)
:invoice/date (to-date date)
:invoice/import-status :import-status/pending