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