Adds bottom paginator, fixes ledger issue triggered by cash payment, defaults coding to 100 percent

This commit is contained in:
Bryce
2023-06-26 20:33:14 -07:00
parent 4d4678f6f7
commit b6fe435063
20 changed files with 153 additions and 125 deletions

View File

@@ -37,7 +37,7 @@
(-> je :journal-entry/date)]) (-> je :journal-entry/date)])
(defn upsert-ledger [db ledger-entry] (defn upsert-ledger [db ledger-entry]
(assert (:journal-entry/date ledger-entry) "Must at least provide date when updating ledger") (assert (:journal-entry/date ledger-entry) (format "Must at least provide date when updating ledger: %s" (pr-str ledger-entry)))
(assert (:journal-entry/client ledger-entry) "Must at least provide client when updating ledger") (assert (:journal-entry/client ledger-entry) "Must at least provide client when updating ledger")
;; TODO these are not always true ;; TODO these are not always true
;; (assert (every? :journal-entry-line/account (:journal-entry/line-items ledger-entry)) "must at least provide account when updating ledger") ;; (assert (every? :journal-entry-line/account (:journal-entry/line-items ledger-entry)) "must at least provide account when updating ledger")
@@ -60,8 +60,7 @@
(assoc :journal-entry-line/dirty true) (assoc :journal-entry-line/dirty true)
(assoc :journal-entry-line/client+account+location+date (assoc :journal-entry-line/client+account+location+date
(calc-client+account+location+date ledger-entry %))) (calc-client+account+location+date ledger-entry %)))
lis)))) lis)))))]]
)]]
extant-entry-exists? (into (map (fn [li] extant-entry-exists? (into (map (fn [li]
{:journal-entry-line/dirty true {:journal-entry-line/dirty true
:db/id li}) :db/id li})

View File

@@ -354,7 +354,7 @@
:payment/date (coerce/to-date (last (sort (map :invoice/date invoices)))) :payment/date (coerce/to-date (last (sort (map :invoice/date invoices))))
:payment/memo memo :payment/memo memo
:payment/status :payment-status/cleared) :payment/status :payment-status/cleared)
transaction {:db/id (str "transaction-" (:db/id vendor)) transaction [:upsert-transaction {:db/id (str "transaction-" (:db/id vendor))
:transaction/amount (- (:payment/amount base-payment)) :transaction/amount (- (:payment/amount base-payment))
:transaction/payment (str (:db/id vendor)) :transaction/payment (str (:db/id vendor))
:transaction/client (:db/id client) :transaction/client (:db/id client)
@@ -368,7 +368,7 @@
:transaction/approval-status :transaction-approval-status/approved :transaction/approval-status :transaction-approval-status/approved
:transaction/accounts [{:transaction-account/account (:db/id (a/get-account-by-numeric-code-and-sets 21000 ["default"])) :transaction/accounts [{:transaction-account/account (:db/id (a/get-account-by-numeric-code-and-sets 21000 ["default"]))
:transaction-account/location "A" :transaction-account/location "A"
:transaction-account/amount (Math/abs (:payment/amount base-payment))}]}] :transaction-account/amount (Math/abs (:payment/amount base-payment))}]}]]
(-> [] (-> []
(conj payment) (conj payment)
(conj transaction) (conj transaction)

View File

@@ -138,6 +138,24 @@
[:div.level-item c]) children)) [:div.level-item c]) children))
[:div.level-right action-buttons]]]))))])) [:div.level-right action-buttons]]]))))]))
(defn bottom-paginator [{:keys [start end count total action-buttons]}]
(let [children (r/children (r/current-component))]
[:> Consumer {}
(fn [consume]
(let [{:strs [on-params-change params]} (js->clj consume)]
(r/as-element (into
[:div {:style {:margin-bottom "1rem"}}
[:div.level
(into
[:div.level-left
[:div.level-item
[paginator {:start start :end end :count count :total total
:per-page (:per-page params)
:on-change on-params-change}]]
[:div.level-item
[sort-by-list {:sort (:sort params)
:on-change on-params-change}]]])]]))))]))
(defn table [{:keys [fullwidth class style]}] (defn table [{:keys [fullwidth class style]}]
(into (into

View File

@@ -286,8 +286,7 @@
[grid/sortable-header-cell {:sort-key "total" :sort-name "Total" :style {:width "8em"} :class "has-text-right"} "Total"] [grid/sortable-header-cell {:sort-key "total" :sort-name "Total" :style {:width "8em"} :class "has-text-right"} "Total"]
[grid/sortable-header-cell {:sort-key "outstanding-balance" :sort-name "Outstanding" :style {:width "10em"} :class "has-text-right"} "Outstanding"] [grid/sortable-header-cell {:sort-key "outstanding-balance" :sort-name "Outstanding" :style {:width "10em"} :class "has-text-right"} "Outstanding"]
[grid/header-cell {:style {:width "14rem" }}] [grid/header-cell {:style {:width "14rem"}}]]]
]]
[grid/body [grid/body
(for [{:keys [id] :as i} invoices] (for [{:keys [id] :as i} invoices]
@@ -298,4 +297,5 @@
(checkable-fn i) (checkable-fn i)
true) true)
:actions actions :actions actions
:overrides overrides}])]])])) :overrides overrides}])]])
[grid/bottom-paginator data]]))

View File

@@ -32,4 +32,5 @@
[grid/cell {} location] [grid/cell {} location]
[grid/cell {} [grid/cell {}
[buttons/fa-icon {:event [::account-form/editing account [::edit-completed]] [buttons/fa-icon {:event [::account-form/editing account [::edit-completed]]
:icon "fa-pencil"}]]])]]]])) :icon "fa-pencil"}]]])]]
[grid/bottom-paginator data]]]))

View File

@@ -95,8 +95,7 @@
[grid/header-cell {} "Locations"] [grid/header-cell {} "Locations"]
[grid/header-cell {} "Status"] [grid/header-cell {} "Status"]
[grid/header-cell {} "Email"] [grid/header-cell {} "Email"]
[grid/header-cell {:style {:width (action-cell-width 2)}}]] [grid/header-cell {:style {:width (action-cell-width 2)}}]]]
]
[grid/body [grid/body
(for [{:keys [id name email square-integration-status locked-until code locations bank-accounts]} (:data data)] (for [{:keys [id name email square-integration-status locked-until code locations bank-accounts]} (:data data)]
^{:key (str name "-" id)} ^{:key (str name "-" id)}
@@ -120,4 +119,5 @@
:class (status/class-for (get states id)) :class (status/class-for (get states id))
:icon :fa-dollar}] :icon :fa-dollar}]
[buttons/fa-icon {:href (bidi/path-for routes/routes :admin-specific-client :id id) [buttons/fa-icon {:href (bidi/path-for routes/routes :admin-specific-client :id id)
:icon :fa-pencil}]]]])]]])) :icon :fa-pencil}]]]])]]
[grid/bottom-paginator data]]))

View File

@@ -73,8 +73,8 @@
[buttons/fa-icon {:href (str (bidi/path-for routes/routes :transactions) [buttons/fa-icon {:href (str (bidi/path-for routes/routes :transactions)
"?" "?"
(url/map->query {:import-batch-id id})) (url/map->query {:import-batch-id id}))
:icon "fa-external-link"}]] :icon "fa-external-link"}]]])]]
])]]])) [grid/bottom-paginator data]]))
(defn table [] (defn table []
(r/create-class {:component-will-unmount (dispatch-event [::unmounted]) (r/create-class {:component-will-unmount (dispatch-event [::unmounted])

View File

@@ -62,9 +62,9 @@
[grid/cell {} name] [grid/cell {} name]
[grid/cell {} status] [grid/cell {} status]
[grid/button-cell {} [grid/button-cell {}]])]]
]
])]]])) [grid/bottom-paginator data]]))
(defn table [] (defn table []
(r/create-class {:component-will-unmount (dispatch-event [::unmounted]) (r/create-class {:component-will-unmount (dispatch-event [::unmounted])

View File

@@ -79,4 +79,5 @@
[:div.buttons [:div.buttons
(when is-admin? (when is-admin?
[buttons/fa-icon {:event [::delete-requested (:id c)] [buttons/fa-icon {:event [::delete-requested (:id c)]
:icon "fa-times"}])]]])]]])) :icon "fa-times"}])]]])]]
[grid/bottom-paginator data]]))

View File

@@ -143,7 +143,8 @@
[:div.buttons [:div.buttons
[buttons/fa-icon {:event [::run-clicked r] :icon :fa-play :class (status/class-for (get states (:id r)))}] [buttons/fa-icon {:event [::run-clicked r] :icon :fa-play :class (status/class-for (get states (:id r)))}]
[buttons/sl-icon {:event [::request-delete r] :icon :icon-bin-2}] [buttons/sl-icon {:event [::request-delete r] :icon :icon-bin-2}]
[buttons/fa-icon {:event [::form/editing r] :icon :fa-pencil}]]]])]]])) [buttons/fa-icon {:event [::form/editing r] :icon :fa-pencil}]]]])]]
[grid/bottom-paginator data]]))
(defn table [] (defn table []
(r/create-class {:component-will-unmount (dispatch-event [::unmounted]) (r/create-class {:component-will-unmount (dispatch-event [::unmounted])

View File

@@ -51,4 +51,5 @@
[grid/cell {} (str/join ", " (map :name clients))] [grid/cell {} (str/join ", " (map :name clients))]
[grid/cell {} [grid/cell {}
[buttons/fa-icon {:event [::form/editing c] [buttons/fa-icon {:event [::form/editing c]
:icon "fa-pencil"}]]])]]])) :icon "fa-pencil"}]]])]]
]))

View File

@@ -32,4 +32,5 @@
[grid/cell {} (-> v :default-account :name)] [grid/cell {} (-> v :default-account :name)]
[grid/cell {} [grid/cell {}
[buttons/fa-icon {:event [::vendor-dialog/started v] [buttons/fa-icon {:event [::vendor-dialog/started v]
:icon "fa-pencil"}]]])]]])) :icon "fa-pencil"}]]])]]
[grid/bottom-paginator data]]))

View File

@@ -130,4 +130,5 @@
:class (status/class-for (get statuses (:id c))) :class (status/class-for (get statuses (:id c)))
:icon "fa-refresh"}] :icon "fa-refresh"}]
[buttons/fa-icon {:event [::delete-requested (:id c)] [buttons/fa-icon {:event [::delete-requested (:id c)]
:icon "fa-times"}]])]])]]])) :icon "fa-times"}]])]])]]
]))

View File

@@ -116,5 +116,7 @@
^{:key id} ^{:key id}
[ledger-row {:row i [ledger-row {:row i
:selected-client selected-client :selected-client selected-client
:bank-accounts-by-id bank-accounts-by-id}])]]])) :bank-accounts-by-id bank-accounts-by-id}])]]
[grid/bottom-paginator data]
#_[grid/controls (assoc data :action-buttons action-buttons)]]))

View File

@@ -129,4 +129,5 @@
^{:key (:id check)} ^{:key (:id check)}
[row {:check check [row {:check check
:selected-client selected-client :selected-client selected-client
:states states}])]]])) :states states}])]]
[grid/bottom-paginator data]]))

View File

@@ -85,4 +85,5 @@
(for [sales-order (:data data)] (for [sales-order (:data data)]
^{:key (:id sales-order)} ^{:key (:id sales-order)}
[row {:sales-order sales-order [row {:sales-order sales-order
:selected-client selected-client}])]]])) :selected-client selected-client}])]]
[grid/bottom-paginator data]]))

View File

@@ -114,8 +114,7 @@
:column-count (if selected-client 7 8)} :column-count (if selected-client 7 8)}
[grid/controls data [grid/controls data
[:div.level-item [:div.level-item
[:div.tag "Total: " (nf (:sales-order-total data))] [:div.tag "Total: " (nf (:sales-order-total data))]]
]
[:div.level-item [:div.level-item
[:div.tag " Tax: " (nf (:sales-order-tax data))]]] [:div.tag " Tax: " (nf (:sales-order-tax data))]]]
[grid/table {:fullwidth true} [grid/table {:fullwidth true}
@@ -136,4 +135,5 @@
(for [sales-order (:data data)] (for [sales-order (:data data)]
^{:key (:id sales-order)} ^{:key (:id sales-order)}
[row {:sales-order sales-order [row {:sales-order sales-order
:selected-client selected-client}])]]])) :selected-client selected-client}])]]
[grid/bottom-paginator data]]))

View File

@@ -57,10 +57,10 @@
[grid/header-cell {:style {:width (action-cell-width (if [grid/header-cell {:style {:width (action-cell-width (if
is-admin? is-admin?
2 2
1))}}] 1))}}]]]
]]
[grid/body [grid/body
(for [i (:data data)] (for [i (:data data)]
^{:key (:id i)} ^{:key (:id i)}
[row {:row i :is-admin? is-admin? :data-page data-page}])]]]])) [row {:row i :is-admin? is-admin? :data-page data-page}])]]
[grid/bottom-paginator data]]]))

View File

@@ -153,5 +153,5 @@
:on-click (dispatch-event [::code-selected checked] )} :on-click (dispatch-event [::code-selected checked] )}
:close-event [::status/completed ::code-selected]}] :close-event [::status/completed ::code-selected]}]
:db (-> db :db (-> db
(forms/start-form ::form {:accounts [] (forms/start-form ::form {:accounts [{:amount-percentage 100.0 }]
:client @(re-frame/subscribe [::subs/client (:client-id params)])}))}))) :client @(re-frame/subscribe [::subs/client (:client-id params)])}))})))

View File

@@ -145,4 +145,5 @@
[buttons/fa-icon {:icon "fa-external-link" [buttons/fa-icon {:icon "fa-external-link"
:href (str (bidi/path-for routes/routes :expected-deposits) :href (str (bidi/path-for routes/routes :expected-deposits)
"?" "?"
(url/map->query {:exact-match-id (:id expected-deposit)}))}]]])]]]]])]]])]]])) (url/map->query {:exact-match-id (:id expected-deposit)}))}]]])]]]]])]]])]]
[grid/bottom-paginator data]]))