Fixes issue with General Produce import

This commit is contained in:
2023-04-27 19:27:49 -07:00
parent 56745c7244
commit 1fdbd72a50

View File

@@ -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
@@ -244,7 +250,9 @@
:invoice i)
i))
(mapv (fn [i]
[:propose-invoice (assoc i :invoice/source-url invoice-url)])))))
(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