Fixes issue with General Produce import
This commit is contained in:
@@ -70,13 +70,15 @@
|
|||||||
(drop 1)
|
(drop 1)
|
||||||
(filter (fn [[_ _ _ _ _ _ _ _ _ _ _ break-flag]]
|
(filter (fn [[_ _ _ _ _ _ _ _ _ _ _ break-flag]]
|
||||||
(= "Y" 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
|
(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
|
(when-not matching-client
|
||||||
(log/warn ::missing-client
|
(log/warn ::missing-client
|
||||||
:client-hint location-hint))
|
: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/date (coerce/to-date (atime/parse ship-date atime/normal-date))
|
||||||
:invoice/invoice-number invoice-number
|
:invoice/invoice-number invoice-number
|
||||||
:invoice/total (Double/parseDouble invoice-total)
|
:invoice/total (Double/parseDouble invoice-total)
|
||||||
@@ -86,7 +88,11 @@
|
|||||||
:invoice/import-status :import-status/imported
|
:invoice/import-status :import-status/imported
|
||||||
:invoice/status :invoice-status/unpaid
|
:invoice/status :invoice-status/unpaid
|
||||||
:invoice/client-identifier location-hint
|
: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)
|
(filter :invoice/client)
|
||||||
(into []))
|
(into []))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
@@ -244,7 +250,9 @@
|
|||||||
:invoice i)
|
:invoice i)
|
||||||
i))
|
i))
|
||||||
(mapv (fn [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
|
(catch Exception e
|
||||||
(log/error ::cant-load-file
|
(log/error ::cant-load-file
|
||||||
:key k
|
:key k
|
||||||
|
|||||||
Reference in New Issue
Block a user