Started loading koala-production data, approve email invoices
This commit is contained in:
@@ -67,7 +67,8 @@
|
|||||||
(map #(assoc %
|
(map #(assoc %
|
||||||
:source-url (str "http://" (:data-bucket env)
|
:source-url (str "http://" (:data-bucket env)
|
||||||
".s3-website-us-east-1.amazonaws.com/"
|
".s3-website-us-east-1.amazonaws.com/"
|
||||||
s3-location))))]
|
s3-location)
|
||||||
|
:import-status :import-status/approved)))]
|
||||||
(log/info "Found imports" imports)
|
(log/info "Found imports" imports)
|
||||||
(invoices/import-uploaded-invoice {:user/role "admin"} imports ))
|
(invoices/import-uploaded-invoice {:user/role "admin"} imports ))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
|
|||||||
@@ -126,7 +126,7 @@
|
|||||||
(throw (ex-info (str "No vendor with the name " vendor-code " was found.")
|
(throw (ex-info (str "No vendor with the name " vendor-code " was found.")
|
||||||
{:vendor-code vendor-code})))))
|
{:vendor-code vendor-code})))))
|
||||||
|
|
||||||
(defn import->invoice [{:keys [invoice-number source-url customer-identifier account-number total date vendor-code text full-text client-override vendor-override location-override]} clients]
|
(defn import->invoice [{:keys [invoice-number source-url customer-identifier account-number total date vendor-code text full-text client-override vendor-override location-override import-status]} clients]
|
||||||
(let [[matching-client similarity] (cond
|
(let [[matching-client similarity] (cond
|
||||||
account-number (parse/best-match clients account-number 0.0)
|
account-number (parse/best-match clients account-number 0.0)
|
||||||
customer-identifier (parse/best-match clients customer-identifier)
|
customer-identifier (parse/best-match clients customer-identifier)
|
||||||
@@ -147,7 +147,7 @@
|
|||||||
:invoice/total (Double/parseDouble total)
|
:invoice/total (Double/parseDouble total)
|
||||||
:invoice/date (to-date date)
|
:invoice/date (to-date date)
|
||||||
:invoice/location matching-location
|
:invoice/location matching-location
|
||||||
:invoice/import-status :import-status/pending
|
:invoice/import-status (or import-status :import-status/pending)
|
||||||
:invoice/outstanding-balance (Double/parseDouble total)
|
:invoice/outstanding-balance (Double/parseDouble total)
|
||||||
:invoice/status :invoice-status/unpaid})))
|
:invoice/status :invoice-status/unpaid})))
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,12 @@
|
|||||||
([client location]
|
([client location]
|
||||||
(daily-results client location nil))
|
(daily-results client location nil))
|
||||||
([client location d]
|
([client location d]
|
||||||
(->> (search client location d)
|
(let [search-results (search client location d)
|
||||||
|
koala-production-ids (->> search-results
|
||||||
|
(filter #(= "koala-production" (:name (:source %))))
|
||||||
|
(map :id)
|
||||||
|
(into #{}))]
|
||||||
|
(->> search-results
|
||||||
(filter (fn [order]
|
(filter (fn [order]
|
||||||
;; sometimes orders stay open in square. At least one payment
|
;; sometimes orders stay open in square. At least one payment
|
||||||
;; is needed to import, in order to avoid importing orders in-progress.
|
;; is needed to import, in order to avoid importing orders in-progress.
|
||||||
@@ -201,12 +206,14 @@
|
|||||||
(not= #{"FAILED"}
|
(not= #{"FAILED"}
|
||||||
(set (map #(:status (:card_details %)) (:tenders order)))))))
|
(set (map #(:status (:card_details %)) (:tenders order)))))))
|
||||||
(filter (fn [order]
|
(filter (fn [order]
|
||||||
(and
|
(not= "Koala" (:name (:source order)))))
|
||||||
(not= "Koala" (:name (:source order)))
|
(filter (fn has-linked-koala-production? [order]
|
||||||
(not= "koala-production" (:name (:source order))))))
|
;; if a POS order is linked (via note) to a koala-production order, we want
|
||||||
(map #(order->sales-order client location %)))))
|
;; to keep the koala-production order, because it has taxes correct
|
||||||
|
(not (->> (:line_items order)
|
||||||
#_(daily-results)
|
(map :note)
|
||||||
|
(every? koala-production-ids)))))
|
||||||
|
(map #(order->sales-order client location %))))))
|
||||||
|
|
||||||
|
|
||||||
(defn retry
|
(defn retry
|
||||||
|
|||||||
Reference in New Issue
Block a user