improvements for payment finding

This commit is contained in:
2021-04-27 21:46:45 -07:00
parent ec236ae979
commit 4c764ed927
6 changed files with 45 additions and 10 deletions

View File

@@ -130,6 +130,11 @@
'[(<= ?date ?end-date)]]}
:args [(c/to-date (:end (:date-range args)))]})
(:payment-type args)
(merge-query {:query {:in '[?payment-type]
:where ['[?e :payment/type ?payment-type]]}
:args [(:payment-type args)]})
check-number-like
(merge-query {:query {:in '[?check-number-like]
:where ['[?e :payment/check-number ?check-number-like]]}

View File

@@ -634,6 +634,7 @@
:payment_page {:type '(list :payment_page)
:args {:client_id {:type :id}
:vendor_id {:type :id}
:payment_type {:type :payment_type}
:exact_match_id {:type :id}
:date_range {:type :date_range}
:amount_lte {:type :money}

View File

@@ -9,7 +9,7 @@
[auto-ap.datomic.vendors :as d-vendors]
[auto-ap.graphql.utils
:refer
[->graphql <-graphql assert-can-see-client]]
[->graphql <-graphql assert-can-see-client enum->keyword]]
[auto-ap.numeric :refer [num->words]]
[auto-ap.time :refer [iso-date local-now parse]]
[auto-ap.utils :refer [by dollars-0?]]
@@ -353,7 +353,7 @@
(defn get-payment-page [context args value]
(let [args (assoc args :id (:id context))
[payments checks-count] (d-checks/get-graphql (<-graphql args))]
[payments checks-count] (d-checks/get-graphql (update (<-graphql args) :payment-type enum->keyword "payment-type"))]
[{:payments (->> payments
(map (fn [payment]

View File

@@ -8,12 +8,14 @@
[auto-ap.graphql.utils :refer [->graphql <-graphql assert-admin]]
[auto-ap.routes.utils :refer [wrap-secure]]
[clojure.tools.logging :as log]
[auto-ap.logging :refer [error-event info-event warn-event]]
[clj-time.coerce :as coerce :refer [to-date]]
[clj-time.core :as time]
[compojure.core :refer [context defroutes GET wrap-routes]]
[datomic.api :as d]
[ring.middleware.json :refer [wrap-json-response]]
[venia.core :as venia]))
[venia.core :as venia]
[yang.time :refer [time-it]]))
(defroutes routes
(wrap-routes
@@ -125,14 +127,19 @@
(assert-admin identity)
(map <-graphql (d-vendors/get-graphql {})))
(GET "/ledger/export" {:keys [query-params identity]}
(log/info "exporting for " (query-params "client-code"))
(assert-admin identity)
(transduce (comp
(map #(update % :journal-entry/date to-date))
(map <-graphql))
conj
(list)
(first (d-ledger/get-graphql {:count Integer/MAX_VALUE
:client-code (query-params "client-code")}))))
(let [[result time] (time-it (transduce (comp
(map #(update % :journal-entry/date to-date))
(map <-graphql))
conj
(list)
(first (d-ledger/get-graphql {:count Integer/MAX_VALUE
:client-code (query-params "client-code")}))))]
(info-event "Export completed"
{:time (:time time)
:errors (seq (:errors result))})
result))
(GET "/accounts/export" {:keys [query-params identity]}
(assert-admin identity)

View File

@@ -38,6 +38,7 @@
:sort (:sort params)
:client-id (:id @(re-frame/subscribe [::subs/client]))
:vendor-id (:id (:vendor params))
:payment-type (:payment-type params)
:exact-match-id (some-> (:exact-match-id params) str)
:date-range (:date-range params)
:amount-gte (:amount-gte (:amount-range params))

View File

@@ -45,6 +45,27 @@
:value @(re-frame/subscribe [::data-page/filter data-page :invoice-number])
:on-change (dispatch-value-change [::data-page/filter-changed data-page :invoice-number])} ]]]
[:p.menu-label "Payment Type"]
[:div.field.has-addons
[:p.control [:a.button.is-small {:on-click
(dispatch-event [::data-page/filter-changed data-page :payment-type :cash])
:class (when (= :cash @(re-frame/subscribe [::data-page/filter data-page :payment-type]))
["is-selected" "is-success"])}
"Cash" ]]
[:p.control [:a.button.is-small {:on-click
(dispatch-event [::data-page/filter-changed data-page :payment-type :check])
:class (when (= :check @(re-frame/subscribe [::data-page/filter data-page :payment-type]))
["is-selected" "is-success"])}
"Check" ]]
[:p.control [:a.button.is-small {:on-click
(dispatch-event [::data-page/filter-changed data-page :payment-type :debit])
:class (when (= :debit @(re-frame/subscribe [::data-page/filter data-page :payment-type]))
["is-selected" "is-success"])}
"Debit"]]
[:p.control [:a.button.is-small {:on-click
(dispatch-event [::data-page/filter-changed data-page :payment-type nil])}
"All"]]]
(when-let [exact-match-id @(re-frame/subscribe [::data-page/filter data-page :exact-match-id])]
[:div
[:p.menu-label "Specific Payment"]