merged
This commit is contained in:
@@ -70,13 +70,15 @@
|
||||
(drop 1)
|
||||
(filter (fn [[_ _ _ _ _ _ _ _ _ _ _ break-flag]]
|
||||
(= "Y" break-flag)))
|
||||
(map (fn [[vendor location-hint invoice-number ship-date invoice-total ]]
|
||||
(map (fn [[_ location-hint invoice-number ship-date invoice-total ]]
|
||||
(let [matching-client (and location-hint
|
||||
(parse/exact-match clients location-hint))]
|
||||
(parse/exact-match clients location-hint))
|
||||
location (parse/best-location-match matching-client location-hint location-hint )
|
||||
vendor (d/pull (d/db conn) '[:vendor/default-account] :vendor/general-produce)]
|
||||
(when-not matching-client
|
||||
(log/warn ::missing-client
|
||||
:client-hint location-hint))
|
||||
{:invoice/location (parse/best-location-match matching-client location-hint location-hint )
|
||||
{:invoice/location location
|
||||
:invoice/date (coerce/to-date (atime/parse ship-date atime/normal-date))
|
||||
:invoice/invoice-number invoice-number
|
||||
:invoice/total (Double/parseDouble invoice-total)
|
||||
@@ -86,7 +88,11 @@
|
||||
:invoice/import-status :import-status/imported
|
||||
:invoice/status :invoice-status/unpaid
|
||||
:invoice/client-identifier location-hint
|
||||
})))
|
||||
:invoice/expense-accounts [{:invoice-expense-account/account
|
||||
(-> vendor :vendor/default-account :db/id)
|
||||
:invoice-expense-account/location location
|
||||
:invoice-expense-account/amount (Math/abs (Double/parseDouble invoice-total))
|
||||
}]})))
|
||||
(filter :invoice/client)
|
||||
(into []))
|
||||
(catch Exception e
|
||||
@@ -228,11 +234,8 @@
|
||||
:client/locations])
|
||||
:where [?c :client/code]]
|
||||
(d/db conn)))]
|
||||
|
||||
|
||||
(log/info ::found-invoice-keys
|
||||
:keys keys )
|
||||
|
||||
(let [transaction (->> keys
|
||||
(mapcat (fn [k]
|
||||
(try
|
||||
@@ -249,12 +252,15 @@
|
||||
:invoice i)
|
||||
i))
|
||||
(mapv (fn [i]
|
||||
[:propose-invoice (assoc i :invoice/source-url invoice-url)]))))) (catch Exception e
|
||||
(log/error ::cant-load-file
|
||||
:key k
|
||||
:exception e)
|
||||
(mark-error k)
|
||||
[]))))
|
||||
(if (= :vendor/cintas (:invoice/vendor i))
|
||||
[:propose-invoice (assoc i :invoice/source-url invoice-url)]
|
||||
[:propose-invoice i]))))))
|
||||
(catch Exception e
|
||||
(log/error ::cant-load-file
|
||||
:key k
|
||||
:exception e)
|
||||
(mark-error k)
|
||||
[]))))
|
||||
(into []))]
|
||||
(audit-transact transaction {:user/name "sysco importer" :user/role "admin"})
|
||||
(log/info ::success
|
||||
|
||||
Reference in New Issue
Block a user