From a08c1971593781b23a097e0b81cac9b93140355b Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 19 Aug 2020 18:25:27 -0700 Subject: [PATCH] progress on bugs --- resources/public/css/main.css | 3 ++ src/clj/auto_ap/graphql/transactions.clj | 2 +- src/clj/auto_ap/rule_matching.clj | 6 ++-- src/cljs/auto_ap/views/components/grid.cljs | 9 ++--- .../views/components/invoice_table.cljs | 9 +++-- src/cljs/auto_ap/views/main.cljs | 35 ++----------------- .../auto_ap/views/pages/ledger/table.cljs | 8 ++--- .../auto_ap/views/pages/unpaid_invoices.cljs | 1 + 8 files changed, 26 insertions(+), 47 deletions(-) diff --git a/resources/public/css/main.css b/resources/public/css/main.css index 8fcdf801..88b01155 100644 --- a/resources/public/css/main.css +++ b/resources/public/css/main.css @@ -550,3 +550,6 @@ table.balance-sheet th.total { .table.table.grid thead tr:first-child>th:last-child { border-radius: 0px 4px 0px 0px !important; } +.table.grid.wrappable td {text-overflow: ""; overflow: visible; white-space: normal; } +.table.grid.wrappable td.expandable {text-overflow: ""; overflow: visible; white-space: normal; } +.table.grid.wrappable th.expandable {text-overflow: ""; overflow: visible; white-space: normal; } diff --git a/src/clj/auto_ap/graphql/transactions.clj b/src/clj/auto_ap/graphql/transactions.clj index 4cfe23b7..2217e1b4 100644 --- a/src/clj/auto_ap/graphql/transactions.clj +++ b/src/clj/auto_ap/graphql/transactions.clj @@ -150,7 +150,7 @@ conj [] transaction_ids) - transaction-rule (update (tr/get-by-id transaction_rule_id) :transaction-rule/description #(some-> % re-pattern))] + transaction-rule (update (tr/get-by-id transaction_rule_id) :transaction-rule/description #(some-> % rm/->pattern))] (doseq [transaction transactions] (when (not (rm/rule-applies? transaction transaction-rule)) (throw (ex-info "Transaction rule does not apply" {:validation-error "Transaction rule does not apply" diff --git a/src/clj/auto_ap/rule_matching.clj b/src/clj/auto_ap/rule_matching.clj index f25e4c0e..c4774cc7 100644 --- a/src/clj/auto_ap/rule_matching.clj +++ b/src/clj/auto_ap/rule_matching.clj @@ -13,6 +13,9 @@ [auto-ap.datomic.transaction-rules :as tr] [clojure.tools.logging :as log])) +(defn ->pattern [x] + (. java.util.regex.Pattern (compile x java.util.regex.Pattern/CASE_INSENSITIVE))) + (defn rule-applies? [transaction {:keys [:transaction-rule/description :transaction-rule/dom-gte :transaction-rule/dom-lte :transaction-rule/amount-gte :transaction-rule/amount-lte @@ -83,8 +86,7 @@ (recur rules))) []))) -(defn ->pattern [x] - (. java.util.regex.Pattern (compile x java.util.regex.Pattern/CASE_INSENSITIVE))) + (defn group-rules-by-priority [rules] (->> rules diff --git a/src/cljs/auto_ap/views/components/grid.cljs b/src/cljs/auto_ap/views/components/grid.cljs index 2bbea058..dbdfbe6b 100644 --- a/src/cljs/auto_ap/views/components/grid.cljs +++ b/src/cljs/auto_ap/views/components/grid.cljs @@ -121,11 +121,12 @@ (mapv (fn [c] [:div.level-item c]) children))]]))))])) -(defn table [{:keys [fullwidth]}] +(defn table [{:keys [fullwidth class]}] (into - [:table.table.compact.grid {:class (if fullwidth - ["is-fullwidth"])}] + [:table.table.compact.grid {:class (cond-> [] + fullwidth (conj "is-fullwidth") + class (into class))}] (r/children (r/current-component)))) (defn header [] @@ -172,7 +173,7 @@ (map r/as-element (r/children (r/current-component))))) (defn cell [params] - (apply r/create-element "td" #js {} + (apply r/create-element "td" #js {:className (:class params)} (map r/as-element (r/children (r/current-component)))) ) diff --git a/src/cljs/auto_ap/views/components/invoice_table.cljs b/src/cljs/auto_ap/views/components/invoice_table.cljs index bb6cb241..f6ea731c 100644 --- a/src/cljs/auto_ap/views/components/invoice_table.cljs +++ b/src/cljs/auto_ap/views/components/invoice_table.cljs @@ -91,8 +91,8 @@ (fn [{:keys [db]} [_ invoice]] {:db db})) -(defn row [{:keys [invoice check-boxes selected-client overrides expense-event actions]}] - (let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor checkable?] :as i} invoice +(defn row [{:keys [invoice check-boxes selected-client overrides checkable? expense-event actions]}] + (let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoice accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client]) account->name #(:name (accounts-by-id (:id %)))] [grid/row {:class (:class i) :id id :checkable? checkable? :entity invoice} @@ -179,7 +179,7 @@ [buttons/fa-icon {:icon "fa-undo" :event [::unvoid-invoice i]}])]]])) -(defn invoice-table [{:keys [id check-boxes overrides actions data-page]}] +(defn invoice-table [{:keys [id check-boxes overrides actions data-page checkable-fn]}] (let [selected-client @(re-frame/subscribe [::subs/client]) {:keys [data status table-params]} @(re-frame/subscribe [::data-page/page data-page]) @@ -235,5 +235,8 @@ ^{:key id} [row {:invoice i :selected-client selected-client + :checkable? (if checkable-fn + (checkable-fn i) + true) :actions actions :overrides overrides}])]])])) diff --git a/src/cljs/auto_ap/views/main.cljs b/src/cljs/auto_ap/views/main.cljs index 35c47b99..67e4f3c8 100644 --- a/src/cljs/auto_ap/views/main.cljs +++ b/src/cljs/auto_ap/views/main.cljs @@ -116,44 +116,13 @@ (defmethod page :admin-excel-import [_] [admin-excel-import-page]) -;; -;; ;;
-;; -;;
-;;
-;;

-;;
-;;
-;; -;;
(defn active-page [] (let [ap (re-frame/subscribe [::subs/active-page]) + current-client @(re-frame/subscribe [::subs/client]) is-loading? @(re-frame/subscribe [::subs/is-initial-loading?])] (if is-loading? [loading-layout] [:div - ^{:key @ap} [page @ap]]))) + ^{:key (str @ap "-" current-client)} [page @ap]]))) diff --git a/src/cljs/auto_ap/views/pages/ledger/table.cljs b/src/cljs/auto_ap/views/pages/ledger/table.cljs index 4b3f9fcb..623acb3f 100644 --- a/src/cljs/auto_ap/views/pages/ledger/table.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/table.cljs @@ -61,16 +61,16 @@ :status status :column-count (if selected-client 5 6)} [grid/controls ledger-page] - [grid/table {:fullwidth true} + [grid/table {:fullwidth true :class ["wrappable"]} [grid/header [grid/row {} (when-not selected-client [grid/sortable-header-cell {:sort-key "client" :sort-name "Client"} "Client"]) [grid/sortable-header-cell {:sort-key "vendor" :sort-name "Vendor"} "Vendor"] - [grid/sortable-header-cell {:sort-key "date" :sort-name "Date" :style {:width "15em"}} "Date"] + [grid/sortable-header-cell {:sort-key "date" :sort-name "Date" :style {:width "8em"}} "Date"] [grid/header-cell {} "Account"] - [grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "12em"}} "Debit"] - [grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "12em"}} "Credit"]]] + [grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Debit"] + [grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Credit"]]] [grid/body (for [{:keys [client vendor status date amount id line-items] :as i} (:journal-entries ledger-page)] ^{:key id} diff --git a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs index 43c52f46..3b15f249 100644 --- a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs @@ -186,6 +186,7 @@ [table/invoice-table {:id (:id page) :data-page :invoices :check-boxes (= status :unpaid) + :checkable-fn (fn [i] (not (:automatically-paid-when-due i))) :actions #{:edit :void :expense-accounts}}]])) (defn unpaid-invoices-page [params]