Started loading koala-production data, approve email invoices

This commit is contained in:
2022-04-28 21:18:24 -07:00
parent e0c4de3630
commit 523afd9d37
3 changed files with 26 additions and 18 deletions

View File

@@ -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