diff --git a/src/clj/auto_ap/ssr/ledger.clj b/src/clj/auto_ap/ssr/ledger.clj index f7244110..f7ad516c 100644 --- a/src/clj/auto_ap/ssr/ledger.clj +++ b/src/clj/auto_ap/ssr/ledger.clj @@ -109,13 +109,6 @@ :headers {"hx-retarget" (format "#entity-table tr[data-id=\"%d\"]" (:db/id invoice))})) - - - - - - - (defn wrap-ensure-bank-account-belongs [handler] (fn [{:keys [query-params client] :as request}] (let [bank-account-belongs? (get (set (map :db/id (:client/bank-accounts client))) diff --git a/src/clj/auto_ap/ssr/ledger/common.clj b/src/clj/auto_ap/ssr/ledger/common.clj index 1430a9ee..80a871d2 100644 --- a/src/clj/auto_ap/ssr/ledger/common.clj +++ b/src/clj/auto_ap/ssr/ledger/common.clj @@ -261,11 +261,18 @@ (:sort args) (add-sorter-fields {"client" ['[?e :journal-entry/client ?c] '[?c :client/name ?sort-client]] "date" ['[?e :journal-entry/date ?sort-date]] - "vendor" ['[?e :journal-entry/vendor ?v] - '[?v :vendor/name ?sort-vendor]] + "vendor" '[(or-join [?e ?sort-vendor] + (and + [?e :journal-entry/vendor ?v] + [?v :vendor/name ?sort-vendor]) + (and [(missing? $ ?e :journal-entry/vendor)] + [(ground "") ?sort-vendor]))] "amount" ['[?e :journal-entry/amount ?sort-amount]] "external-id" ['[?e :journal-entry/external-id ?sort-external-id]] - "source" ['[?e :journal-entry/source ?sort-source]]} + "source" '[(or-join [?e ?sort-source] + [?e :journal-entry/source ?sort-source] + (and [(missing? $ ?e :journal-entry/source)] + [(ground "") ?sort-source]))]} args) true @@ -275,6 +282,19 @@ (apply-sort-4 (assoc query-params :default-asc? true)) (apply-pagination query-params)))) +#_(def args [#{17592307337299 17592292122045 17592289631589 17592235074859 17592186046478 17592319685078 17592193806897 17592295112116 17592316081817 17592291296031 17592291325248 17592291325326 17592302069144 17592238708423 17592186046520 17592281881509 17592249973733 17592280134939 17592291325864 17592233076577 17592311319316 17592236113837 17592278756108 17592219675333 17592250777772 17592244691558 17592291325954 17592264489873 17592275987623 17592260775415 17592304348426 17592234806481 17592235922068 17592186046404 17592276037255 17592273679867 17592284920305 17592307423188 17592203465691 17592288587524 17592290322936 17592318464910 17592242514773 17592258866422 17592250210567 17592186046363 17592195665346 17592314717884 17592186046409 17592235305451 17592186046491 17592232886797 17592244761680 17592258011361 17592204394806 17592235810873 17592253249909 17592186046366 17592305954256 17592235068158 17592271573602 17592277469850 17592186046428 17592232555238 17592319682127 17592318378434 17592289178758 17592232886729 17592186046397 17592296909432 17592186046465 17592186046356 17592305974115 17592265120447 17592232886793 17592246196802 17592232577980 17592264560519 17592234448526 17592221275294 17592291326043 17592242874891 17592309876310 17592291620408 17592310930535 17592232958090 17592234851859 17592243928280 17592236461666 17592234230520 17592186046373 17592186046472 17592241193003 17592186109023 17592302053757 17592233431334 17592258246710 17592186046437 17592247419073 17592186046456 17592186046513 17592196580407 17592247419185 17592232808650 17592303606847 17592250176578 17592271576404 17592308748208 17592311010407 17592250777854 17592275995130 17592238607837 17592291325452 17592186046385 17592294315344 17592238708558 17592291273963 17592247425545 17592233431814 17592236868871 17592186046371 17592318051737 17592186046400 17592186046380 17592236349303 17592186046415 17592285467793 17592245006804 17592186046394 17592236868866 17592302264486 17592233144301 17592249936256 17592232886786 17592296909452 17592219470393 17592232545948 17592317200386 17592235068155 17592234700485 17592244691542 17592257647588 17592296909449 17592186046499 17592186046378 17592275995135 17592286618015 17592186046447 17592291326115 17592262632255 17592186046422 17592232577988 17592250210564 17592300854983 17592291325766 17592245184339 17592304773809 17592235003983} #inst "2023-10-11T07:00:00.000-00:00" nil]) + +#_(dc/q '{:find [ ?sort-vendor (count ?e)], +:in [$ [?clients ?start ?end]], +:where [[(iol-ion.query/scan-ledger $ ?clients ?start ?end) + [[?e _ ?sort-default] ...]] + #_(not [?e :journal-entry/vendor]) + [(missing? $ ?e :journal-entry/vendor)] + [(ground "ih") ?sort-vendor]]} +(dc/db conn) +args +) + (def default-read '[:journal-entry/amount :journal-entry/alternate-description @@ -453,10 +473,12 @@ :break-table (fn [request entity] (cond (= (-> request :query-params :sort first :name) "Vendor") - (-> entity :journal-entry/vendor :vendor/name) + (or (-> entity :journal-entry/vendor :vendor/name) + "No vendor") (= (-> request :query-params :sort first :name) "Source") - (-> entity :journal-entry/source) + (or (-> entity :journal-entry/source) + "No external source") :else nil)) :headers [{:key "client" diff --git a/src/clj/auto_ap/ssr/ledger/report_table.clj b/src/clj/auto_ap/ssr/ledger/report_table.clj index 3bad82c7..ce18abd8 100644 --- a/src/clj/auto_ap/ssr/ledger/report_table.clj +++ b/src/clj/auto_ap/ssr/ledger/report_table.clj @@ -1,6 +1,8 @@ (ns auto-ap.ssr.ledger.report-table (:require [auto-ap.ssr.components :as com] + [auto-ap.time :as atime] + [clj-time.coerce :as coerce] [clojure.string :as str] [hiccup.util :as hu] [iol-ion.query :as query])) @@ -19,20 +21,22 @@ (= :percent (:format c)) (format "%%%.1f" (if (query/dollars-0? (:value c)) 0.0 - (:value c))) + (* 100.0 (or (:value c) 0.0)))) :else (str (:value c))) cell-contents (if (:filters c) - (com/link {:hx-get (hu/url investigate-url - (cond-> {} - (:numeric-code (:filters c)) (assoc :numeric-code (into [] (:numeric-code (:filters c)))) - ;; TODO - #_#_(:date-range (:filters c)) (assoc :end-date (atime/unparse-local (:date-range (:filters c)) - atime/normal-date)) - (:client-id (:filters c)) (assoc :client-id (:client-id (:filters c)))) - )} - cell-contents) + (do + (println (:filters c)) + (com/link {:hx-get (hu/url investigate-url + (cond-> {} + (:numeric-code (:filters c)) (assoc :numeric-code (into [] (:numeric-code (:filters c)))) + (inst? (:date-range (:filters c))) (assoc :end-date (atime/unparse-local (coerce/to-date-time (:date-range (:filters c))) atime/normal-date)) + (:end (:date-range (:filters c))) (assoc :end-date (atime/unparse-local (coerce/to-date-time (:end (:date-range (:filters c)))) atime/normal-date)) + (:start (:date-range (:filters c))) (assoc :start-date (atime/unparse-local (coerce/to-date-time (:start (:date-range (:filters c)))) atime/normal-date)) + (:client-id (:filters c)) (assoc :client-id (:client-id (:filters c)))) + )} + cell-contents)) cell-contents)] [:td.px-4.py-2 (cond-> {:style (cond-> {:width (str width "em")} diff --git a/src/cljc/auto_ap/ledger/reports.cljc b/src/cljc/auto_ap/ledger/reports.cljc index 199b026e..ed8f25f6 100644 --- a/src/cljc/auto_ap/ledger/reports.cljc +++ b/src/cljc/auto_ap/ledger/reports.cljc @@ -260,8 +260,6 @@ (defn filter-period [pnl-data period] (-> pnl-data (update :data (fn [data] - #_(println "THE PERIOD IS" period - (take 3 ((group-by :period data) period))) ((group-by :period data) period))) (update :filters (fn [f] (assoc f :date-range period))))) @@ -500,10 +498,6 @@ this-name-exists? (->> (:data p) (filter (comp #{name} :name)) seq)] - (if ( = 40000 numeric-code) - (do (println "TEST HERE" numeric-code) - (clojure.pprint/pprint pnl-data)) - ) (merge (if this-name-exists? {:format :dollar