This commit is contained in:
2024-05-26 20:22:13 -07:00
111 changed files with 10708 additions and 5015 deletions

View File

@@ -77,12 +77,10 @@
(and token
last-client-id
(not last-selected-clients))
[(js/parseInt last-client-id)]
{:selected [(js/parseInt last-client-id)]}
:else
nil)]
(cond
(= :login handler)
{:db (cond-> (assoc db/default-db
@@ -135,11 +133,11 @@
::received-initial
(fn [{:keys [db]} [_ {clients :client}]]
(let [only-one-client (when (= 1 (count clients))
(->> clients first :id))]
(->> clients first :id js/parseInt))]
(when only-one-client
(.setItem js/localStorage "last-client-id" only-one-client)
(.setItem js/localStorage "last-selected-clients"
(pr-str [(js/parseInt only-one-client)])))
(.stringify js/JSON (clj->js {:selected [only-one-client]}))))
{:db (cond-> (-> db
(assoc :clients (by :id clients))
(assoc :is-initial-loading? false)
@@ -149,7 +147,7 @@
(filter #(= % (:last-client-id db)))
first))))
only-one-client (assoc :last-client-id only-one-client
:selected-clients [only-one-client]))
:selected-clients {:selected [only-one-client]}))
:interval {:action :start
:id :refresh-clients
:frequency 600000

View File

@@ -222,9 +222,8 @@
(map r/as-element (r/children (r/current-component)))))
(defn cell [params]
(apply r/create-element "td" #js {:className (:class params)}
(map r/as-element (r/children (r/current-component))))
)
(apply r/create-element "td" #js {:className (:class params) :style (some-> (:style params) clj->js)}
(map r/as-element (r/children (r/current-component)))))
(defn body []
(let [children (r/children (r/current-component))

View File

@@ -177,7 +177,7 @@
"Home" ]
(when (p/can? @user {:subject :invoice-page})
[:a.navbar-item {:class [(active-when ap #{:unpaid-invoices :paid-invoices})]
:href (str (bidi/path-for ssr-routes/only-routes ::invoice-routes/unpaid-page) "?date-range=month")}
:href (str (bidi/path-for ssr-routes/only-routes ::invoice-routes/unpaid-page) "?date-range=year")}
"Invoices" ])
(when (p/can? @user {:subject :payment-page})
[:a.navbar-item {:class [(active-when ap = :payments)]

View File

@@ -21,6 +21,14 @@
[vimsical.re-frame.cofx.inject :as inject]
[auto-ap.status :as status]))
(re-frame/reg-sub
::client
:<- [::subs/clients]
:<- [::subs/client]
(fn [[ clients client]]
(or client
(first clients))))
(def pie-chart (r/adapt-react-class recharts/PieChart))
(def pie (r/adapt-react-class recharts/Pie))
(def bar-chart (r/adapt-react-class recharts/BarChart))
@@ -239,8 +247,8 @@
(re-frame/reg-event-fx
::mounted
[(re-frame/inject-cofx ::inject/sub [::subs/client])]
(fn [{:keys [db] ::subs/keys [client]} _]
[(re-frame/inject-cofx ::inject/sub [::client]) ]
(fn [{:keys [db] ::keys [client]} _]
(cond->
{:db (assoc db ::top-expense-categories nil
::cash-flow nil
@@ -302,14 +310,19 @@
[grid/cell {:class "has-text-right"} (->$ amount)]])]]]))
(defn home-content []
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)
(let [client @(re-frame/subscribe [::client])
client-id (-> client :id)
one-client (not (-> @(re-frame/subscribe [::subs/client]) :id))
chart-options @(re-frame/subscribe [::chart-options])
state @(re-frame/subscribe [::status/single ::page])]
^{:key client-id}
[side-bar-layout {:side-bar [:div]
:main [:div [:h1.title "Home"]
(if client-id
(if (= :loading (:state state))
(when one-client
[:h2.title.is-6 "Note: these reports are for "
(:name client) ". Please choose a specific customer for their report."])
(if (= :loading (:state state))
[:div.loader.is-loading.big.is-centered]
[:<>
@@ -350,17 +363,16 @@
(make-cash-flow-chart {:width 800 :height 500
:data (clj->js @(re-frame/subscribe [::cash-flow]))})
[cash-flow-grid]])
[:h2.title.is-6 "Please select a customer to see reports."])]}]))
[cash-flow-grid]])]}]))
(defn home-page []
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)]
(let [client-id (-> @(re-frame/subscribe [::client]) :id)]
(re-frame/dispatch [::mounted])
^{:key client-id} [home-content]))
(defn home-page-with-vendor []
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)
(let [client-id (-> @(re-frame/subscribe [::client]) :id)
user @(re-frame/subscribe [::subs/user])]
(re-frame/dispatch [::mounted])
(when (p/can? user {:subject :vendor

View File

@@ -1,25 +1,28 @@
(ns auto-ap.views.pages.transactions
(:require [auto-ap.effects.forward :as forward]
[auto-ap.forms :as forms]
[auto-ap.status :as status]
[auto-ap.subs :as subs]
[auto-ap.views.components.modal :as modal]
[auto-ap.views.components.layouts
:refer
[appearing-side-bar side-bar-layout]]
[auto-ap.views.components.modal :as modal]
[auto-ap.views.pages.data-page :as data-page]
[auto-ap.views.pages.transactions.common :refer [transaction-read data-params->query-params]]
[auto-ap.views.pages.transactions.bulk-updates :as bulk]
[auto-ap.views.pages.transactions.common :refer [data-params->query-params
transaction-read]]
[auto-ap.views.pages.transactions.form :as edit]
[auto-ap.views.pages.transactions.manual :as manual]
[auto-ap.views.pages.transactions.bulk-updates :as bulk]
[auto-ap.views.pages.transactions.side-bar :as side-bar]
[auto-ap.views.pages.transactions.table :as table]
[auto-ap.views.utils :refer [dispatch-event with-user date->str standard]]
[auto-ap.views.utils :refer [date->str dispatch-event standard
with-user]]
[auto-ap.views.utils :as u]
[cljs-time.core :as time]
[clojure.string :as str]
[re-frame.core :as re-frame]
[reagent.core :as reagent]
[vimsical.re-frame.fx.track :as track]
[auto-ap.status :as status]
[clojure.string :as str]))
[vimsical.re-frame.fx.track :as track]))
@@ -122,35 +125,38 @@
(re-frame/reg-event-fx
::mounted
(fn [{:keys [db]} _]
{:db (assoc-in db [::data-page/settled-filters ::page :date-range] {:start (date->str (time/plus (time/now) (time/months -1))
standard)})
::track/register {:id ::params
:subscription [::data-page/params ::page]
:event-fn (fn [params]
[::params-change params])}
::forward/register [{:id ::updated
:events #{::edit/edited}
:event-fn (fn [[_ edited-transaction]]
[::data-page/updated-entity ::page edited-transaction])}
{:id ::manual-import
:events #{::manual/import-completed}
:event-fn (fn [[_ result]]
[::status/info ::manual-import
(str "Successfully "
(str/join ", "
[(when-let [imported (:import-batch/imported result)]
(str "imported " imported))
(when-let [extant (:import-batch/extant result)]
(str "extant " extant))
(when-let [suppressed (:import-batch/suppressed result)]
(str "suppressed " suppressed))
(when-let [not-ready (:import-batch/not-ready result)]
(str "too early " not-ready))
(when-let [error (:validation-error result)]
(str "errored " error))])
" transactions."
(when (:sample-error result)
(str " Sample error: " (:info (:sample-error result)))))])}]}))
(let [db (if (:date-range (u/query-params))
db
(assoc-in db [::data-page/settled-filters ::page :date-range] {:start (date->str (time/plus (time/now) (time/months -1))
standard)}))]
{:db db
::track/register {:id ::params
:subscription [::data-page/params ::page]
:event-fn (fn [params]
[::params-change params])}
::forward/register [{:id ::updated
:events #{::edit/edited}
:event-fn (fn [[_ edited-transaction]]
[::data-page/updated-entity ::page edited-transaction])}
{:id ::manual-import
:events #{::manual/import-completed}
:event-fn (fn [[_ result]]
[::status/info ::manual-import
(str "Successfully "
(str/join ", "
[(when-let [imported (:import-batch/imported result)]
(str "imported " imported))
(when-let [extant (:import-batch/extant result)]
(str "extant " extant))
(when-let [suppressed (:import-batch/suppressed result)]
(str "suppressed " suppressed))
(when-let [not-ready (:import-batch/not-ready result)]
(str "too early " not-ready))
(when-let [error (:validation-error result)]
(str "errored " error))])
" transactions."
(when (:sample-error result)
(str " Sample error: " (:info (:sample-error result)))))])}]})))
(defn action-buttons []
(let [is-admin? @(re-frame/subscribe [::subs/is-admin?])

View File

@@ -9,6 +9,8 @@
:location
:approval-status
:check-number
:is-locked
[:matched-rule [:note :id]]
[:vendor [:name :id]]
[:accounts [:id :amount :location [:account [:name :id :location :numeric-code]]]]

View File

@@ -59,6 +59,12 @@
(fn [db]
(::table-params db)))
(defn lock-icon []
[:div {:style {:position "absolute" :width "1em" :height "1em" :left "-1.25rem" :background-color "#E0E0E0" :padding "5px" :box-sizing "content-box" :border-radius "999px" :display "flex" :justify-content "center" :align-content "center" :text-align "center"}}
[:div
[:i.fa.fa-lock {:style {:color "#333"}}]]])
(defn table [{:keys [data-page check-boxes? action-buttons]}]
(let [selected-client @(re-frame/subscribe [::subs/client])
{:keys [data params]} @(re-frame/subscribe [::data-page/page data-page])
@@ -85,9 +91,16 @@
^{:key id}
[grid/row {:class (:class i) :id id :entity i}
(when-not selected-client
[grid/cell {} (:name client)])
[grid/cell {:style {:overflow "visible" :position "relative" }}
(when (:is-locked i)
[lock-icon])
(:name client)])
#_[:td description-original]
[grid/cell {}
(when (and selected-client (:is-locked i))
[lock-icon])
(:name bank-account)]
[grid/cell {} (cond vendor
(:name vendor)
@@ -130,7 +143,7 @@
[:td (date->str (:date payment) pretty)]
[:td
[buttons/fa-icon {:icon "fa-external-link"
:href (str (bidi/path-for ssr-routes/only-routes ::payment-route/page)
:href (str (bidi/path-for ssr-routes/only-routes ::payment-route/all-page)
"?"
(url/map->query {:exact-match-id (:id payment)}))}]]])
(when expected-deposit