so many small tweaks due to the fact that the grid was slow.
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
[dk.ative/docjure "1.12.0"]
|
[dk.ative/docjure "1.12.0"]
|
||||||
[org.clojure/java.jdbc "0.7.3"]
|
[org.clojure/java.jdbc "0.7.3"]
|
||||||
[cljsjs/dropzone "4.3.0-0"]
|
[cljsjs/dropzone "4.3.0-0"]
|
||||||
[cljsjs/recharts "1.4.2-0"]
|
[cljsjs/recharts "1.4.2-0" :exclusions [cljsjs/react cljsjs/react-dom]]
|
||||||
[clj-fuzzy "0.4.1"]
|
[clj-fuzzy "0.4.1"]
|
||||||
[honeysql "0.9.2"]
|
[honeysql "0.9.2"]
|
||||||
[com.walmartlabs/lacinia "0.25.0"]
|
[com.walmartlabs/lacinia "0.25.0"]
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
[org.clojure/data.csv "0.1.4"]
|
[org.clojure/data.csv "0.1.4"]
|
||||||
[io.rkn/conformity "0.5.1"]
|
[io.rkn/conformity "0.5.1"]
|
||||||
[cider/piggieback "0.4.0"]
|
[cider/piggieback "0.4.0"]
|
||||||
|
|
||||||
[hiccup "1.0.5"]]
|
[hiccup "1.0.5"]]
|
||||||
:plugins [[lein-ring "0.9.7"]
|
:plugins [[lein-ring "0.9.7"]
|
||||||
[lein-cljsbuild "1.1.5"]]
|
[lein-cljsbuild "1.1.5"]]
|
||||||
@@ -119,9 +120,9 @@
|
|||||||
org.eclipse.jetty.websocket/websocket-servlet
|
org.eclipse.jetty.websocket/websocket-servlet
|
||||||
args4j]]]}
|
args4j]]]}
|
||||||
:provided {:dependencies [[org.clojure/clojurescript "1.10.339"]
|
:provided {:dependencies [[org.clojure/clojurescript "1.10.339"]
|
||||||
[reagent "1.0.0-alpha1" ]
|
[reagent "1.0.0-alpha2" ]
|
||||||
[cljsjs/react-datepicker "2.1.0-0"]
|
[cljsjs/react-datepicker "2.1.0-0" :exclusions [cljsjs/react cljsjs/react-dom]]
|
||||||
[cljsjs/react-transition-group "2.4.0-0"]
|
[cljsjs/react-transition-group "2.4.0-0" :exclusions [cljsjs/react cljsjs/react-dom]]
|
||||||
[re-frame "0.10.2"]
|
[re-frame "0.10.2"]
|
||||||
[re-frame-utils "0.1.0"]
|
[re-frame-utils "0.1.0"]
|
||||||
[com.andrewmcveigh/cljs-time "0.5.2"]]}}
|
[com.andrewmcveigh/cljs-time "0.5.2"]]}}
|
||||||
|
|||||||
@@ -17,8 +17,24 @@
|
|||||||
[clojure.tools.logging :as log]))
|
[clojure.tools.logging :as log]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn rough-match [client-id bank-account-id amount]
|
||||||
|
(if (and client-id bank-account-id amount)
|
||||||
|
(let [[matching-checks] (d-checks/get-graphql {:client-id client-id
|
||||||
|
:bank-account-id bank-account-id
|
||||||
|
:amount (- amount)
|
||||||
|
:status :payment-status/pending})]
|
||||||
|
(if (= 1 (count matching-checks))
|
||||||
|
(first matching-checks)
|
||||||
|
nil))
|
||||||
|
nil))
|
||||||
|
|
||||||
|
|
||||||
(defn transaction->payment [_ check-number client-id bank-account-id amount id]
|
(defn transaction->payment [_ check-number client-id bank-account-id amount id]
|
||||||
|
(log/info "Searching for a matching check for "
|
||||||
|
{:client-id client-id
|
||||||
|
:check-number check-number
|
||||||
|
:bank-account-id bank-account-id
|
||||||
|
:amount amount})
|
||||||
(cond (not (and client-id bank-account-id))
|
(cond (not (and client-id bank-account-id))
|
||||||
nil
|
nil
|
||||||
|
|
||||||
@@ -26,25 +42,17 @@
|
|||||||
nil
|
nil
|
||||||
|
|
||||||
check-number
|
check-number
|
||||||
(-> (d-checks/get-graphql {:client-id client-id
|
(or (-> (d-checks/get-graphql {:client-id client-id
|
||||||
:bank-account-id bank-account-id
|
:bank-account-id bank-account-id
|
||||||
:check-number check-number
|
:check-number check-number
|
||||||
:amount (- amount)
|
:amount (- amount)
|
||||||
:status :payment-status/pending})
|
:status :payment-status/pending})
|
||||||
first
|
first
|
||||||
first)
|
first)
|
||||||
|
(rough-match client-id bank-account-id amount))
|
||||||
(and client-id bank-account-id amount)
|
|
||||||
(let [[matching-checks] (d-checks/get-graphql {:client-id client-id
|
|
||||||
:bank-account-id bank-account-id
|
|
||||||
:amount (- amount)
|
|
||||||
:status :payment-status/pending})]
|
|
||||||
(if (= 1 (count matching-checks))
|
|
||||||
(first matching-checks)
|
|
||||||
nil))
|
|
||||||
|
|
||||||
:else
|
:else
|
||||||
nil))
|
(rough-match client-id bank-account-id amount)))
|
||||||
|
|
||||||
(defn extract-check-number [{{description-original :original} :description}]
|
(defn extract-check-number [{{description-original :original} :description}]
|
||||||
|
|
||||||
|
|||||||
@@ -161,10 +161,10 @@
|
|||||||
(fn [{:keys [query on-success on-error token variables query-obj owns-state]}]
|
(fn [{:keys [query on-success on-error token variables query-obj owns-state]}]
|
||||||
(go
|
(go
|
||||||
(when (:multi owns-state)
|
(when (:multi owns-state)
|
||||||
(re-frame/dispatch [::status/loading-multi (:multi owns-state) (:which owns-state)]))
|
(re-frame/dispatch-sync [::status/loading-multi (:multi owns-state) (:which owns-state)]))
|
||||||
|
|
||||||
(when (:single owns-state)
|
(when (:single owns-state)
|
||||||
(re-frame/dispatch [::status/loading (:single owns-state)]))
|
(re-frame/dispatch-sync [::status/loading (:single owns-state)]))
|
||||||
(let [headers (if token
|
(let [headers (if token
|
||||||
{"Authorization" (str "Token " token)}
|
{"Authorization" (str "Token " token)}
|
||||||
{})
|
{})
|
||||||
|
|||||||
@@ -119,13 +119,12 @@
|
|||||||
(mapv (fn [c]
|
(mapv (fn [c]
|
||||||
[:div.level-item c]) children))]]))))]))
|
[:div.level-item c]) children))]]))))]))
|
||||||
|
|
||||||
(defn table []
|
(defn table [{:keys [fullwidth]}]
|
||||||
(r/create-class {:reagent-render
|
|
||||||
(fn [{:keys [fullwidth]}]
|
(into
|
||||||
(into
|
[:table.table.compact.grid {:class (if fullwidth
|
||||||
[:table.table.compact.grid {:class (if fullwidth
|
["is-fullwidth"])}]
|
||||||
["is-fullwidth"])}]
|
(r/children (r/current-component))))
|
||||||
(r/children (r/current-component))))}))
|
|
||||||
|
|
||||||
(defn header []
|
(defn header []
|
||||||
(into
|
(into
|
||||||
@@ -138,13 +137,17 @@
|
|||||||
(r/children (r/current-component))))
|
(r/children (r/current-component))))
|
||||||
|
|
||||||
(defn row [{:keys [class]}]
|
(defn row [{:keys [class]}]
|
||||||
(into [:tr {:class class}]
|
(apply r/create-element "tr" #js {:className class}
|
||||||
(r/children (r/current-component))))
|
(map r/as-element (r/children (r/current-component)))))
|
||||||
|
|
||||||
|
(defn button-cell [params]
|
||||||
|
(apply r/create-element "td" #js {"style" #js {"overflow" "visible"}}
|
||||||
|
(map r/as-element (r/children (r/current-component)))))
|
||||||
|
|
||||||
(defn cell [params]
|
(defn cell [params]
|
||||||
[:td params
|
(apply r/create-element "td" #js {}
|
||||||
(into [:span.test ]
|
(map r/as-element (r/children (r/current-component))))
|
||||||
(r/children (r/current-component)))])
|
)
|
||||||
|
|
||||||
(defn body []
|
(defn body []
|
||||||
(let [children (r/children (r/current-component))]
|
(let [children (r/children (r/current-component))]
|
||||||
@@ -153,29 +156,28 @@
|
|||||||
(let [{:strs [column-count status]} (js->clj consume)]
|
(let [{:strs [column-count status]} (js->clj consume)]
|
||||||
(r/as-element
|
(r/as-element
|
||||||
(cond (= :loading (:state status))
|
(cond (= :loading (:state status))
|
||||||
[:tbody
|
^{:key "loading-body"}
|
||||||
(for [i (range 40)]
|
[:tbody.test
|
||||||
|
(for [i (range 20)]
|
||||||
^{:key i}
|
^{:key i}
|
||||||
[:tr
|
[:tr
|
||||||
(for [x (range column-count)]
|
(for [x (range column-count)]
|
||||||
^{:key x}
|
^{:key x}
|
||||||
[:td #_{:col-span column-count}
|
[:td #_{:col-span column-count}
|
||||||
[appearing {:visible? true
|
[:div
|
||||||
:timeout 1000
|
[:div.ph-item
|
||||||
:enter-class "appear"
|
[:div.ph-row
|
||||||
:exit-class "disappear"}
|
[:div.ph-col-12.big]]]]])])]
|
||||||
[:div.test
|
|
||||||
[:div.ph-item
|
|
||||||
[:div.ph-row
|
|
||||||
[:div.ph-col-12.big]]]]]])
|
|
||||||
])]
|
|
||||||
(= :error (:state status))
|
(= :error (:state status))
|
||||||
|
^{:key "error-body"}
|
||||||
[:tbody [:tr [:td.has-text-centered {:col-span column-count}
|
[:tbody [:tr [:td.has-text-centered {:col-span column-count}
|
||||||
"An unexpected error has occured. "
|
"An unexpected error has occured. "
|
||||||
(-> status :error first :message)
|
(-> status :error first :message)
|
||||||
" Please try refreshing the page."]]]
|
" Please try refreshing the page."]]]
|
||||||
:else
|
:else
|
||||||
(into [:tbody]
|
(into ^{:key "main-body"}
|
||||||
|
[:tbody]
|
||||||
|
|
||||||
children)))))]))
|
children)))))]))
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,8 @@
|
|||||||
:<- [::specific-table-params]
|
:<- [::specific-table-params]
|
||||||
:<- [::subs/query-params]
|
:<- [::subs/query-params]
|
||||||
(fn [[specific-table-params query-params]]
|
(fn [[specific-table-params query-params]]
|
||||||
(merge (select-keys query-params #{:start :sort}) specific-table-params )))
|
(update (merge (select-keys query-params #{:start :sort}) specific-table-params )
|
||||||
|
:sort seq)))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::params-changed
|
::params-changed
|
||||||
@@ -128,7 +129,7 @@
|
|||||||
|
|
||||||
[grid/cell {:class "has-text-right"} (nf total )]
|
[grid/cell {:class "has-text-right"} (nf total )]
|
||||||
[grid/cell {:class "has-text-right"} (nf outstanding-balance )]
|
[grid/cell {:class "has-text-right"} (nf outstanding-balance )]
|
||||||
[grid/cell {:style {:overflow "visible"}}
|
[grid/button-cell {}
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
(when (seq expense-accounts)
|
(when (seq expense-accounts)
|
||||||
[drop-down {:id [::expense-accounts id ]
|
[drop-down {:id [::expense-accounts id ]
|
||||||
@@ -188,9 +189,12 @@
|
|||||||
{:keys [sort]} @(re-frame/subscribe [::table-params])
|
{:keys [sort]} @(re-frame/subscribe [::table-params])
|
||||||
{:keys [invoices outstanding]} invoice-page
|
{:keys [invoices outstanding]} invoice-page
|
||||||
selected-client @(re-frame/subscribe [::subs/client])
|
selected-client @(re-frame/subscribe [::subs/client])
|
||||||
is-loading? (= :loading status)
|
is-loading? (= :loading (:state status))
|
||||||
is-sorted-by-vendor? (and (= "vendor" (:sort-key (first sort)))
|
is-sorted-by-vendor? (and (= "vendor" (:sort-key (first sort)))
|
||||||
(not is-loading?))
|
(not is-loading?)
|
||||||
|
(or (apply <= (map (comp :name :vendor) (:invoices invoice-page)))
|
||||||
|
(apply >= (map (comp :name :vendor) (:invoices invoice-page)))))
|
||||||
|
|
||||||
[invoice-groups] (if is-sorted-by-vendor?
|
[invoice-groups] (if is-sorted-by-vendor?
|
||||||
(reduce
|
(reduce
|
||||||
(fn [[acc last-vendor] invoice]
|
(fn [[acc last-vendor] invoice]
|
||||||
@@ -203,7 +207,9 @@
|
|||||||
[[] nil]
|
[[] nil]
|
||||||
(:invoices invoice-page))
|
(:invoices invoice-page))
|
||||||
[[(:invoices invoice-page)]])]
|
[[(:invoices invoice-page)]])]
|
||||||
|
^{:key (str @(re-frame/subscribe [::table-params]))}
|
||||||
[grid/grid {:on-params-change (fn [p]
|
[grid/grid {:on-params-change (fn [p]
|
||||||
|
|
||||||
(re-frame/dispatch [::params-changed p]))
|
(re-frame/dispatch [::params-changed p]))
|
||||||
:params @(re-frame/subscribe [::table-params])
|
:params @(re-frame/subscribe [::table-params])
|
||||||
:status status
|
:status status
|
||||||
@@ -242,7 +248,6 @@
|
|||||||
[row {:invoice i
|
[row {:invoice i
|
||||||
:check-boxes check-boxes
|
:check-boxes check-boxes
|
||||||
:checked checked
|
:checked checked
|
||||||
:on-check-changed on-check-changed
|
|
||||||
:selected-client selected-client
|
:selected-client selected-client
|
||||||
:overrides overrides
|
:overrides overrides
|
||||||
:expense-event expense-event}])]])]))
|
:expense-event expense-event}])]])]))
|
||||||
|
|||||||
@@ -49,13 +49,14 @@
|
|||||||
[:div.field.has-addons
|
[:div.field.has-addons
|
||||||
[:p.control
|
[:p.control
|
||||||
[:a.button.is-static "Force vendor"]]
|
[:a.button.is-static "Force vendor"]]
|
||||||
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
|
[:div.control {:style {:width "400px"}}
|
||||||
:match->text :name
|
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
|
||||||
:name "vendor"
|
:match->text :name
|
||||||
:type "typeahead"
|
:name "vendor"
|
||||||
:on-change (fn [v]
|
:type "typeahead"
|
||||||
(reset! vendor v))
|
:on-change (fn [v]
|
||||||
:value @vendor}]
|
(reset! vendor v))
|
||||||
|
:value @vendor}]]
|
||||||
]
|
]
|
||||||
[:div.tile.notification
|
[:div.tile.notification
|
||||||
|
|
||||||
|
|||||||
@@ -203,9 +203,10 @@
|
|||||||
|
|
||||||
|
|
||||||
{:db (cond-> db
|
{:db (cond-> db
|
||||||
(#{:create :add-and-print} command) (forms/start-form ::form {:client @(re-frame/subscribe [::subs/client])
|
(#{:create :add-and-print} command) (-> (forms/stop-form ::form )
|
||||||
:status :unpaid
|
(forms/start-form ::form {:client @(re-frame/subscribe [::subs/client])
|
||||||
:date (date->str (c/now) standard)})
|
:status :unpaid
|
||||||
|
:date (date->str (c/now) standard)}))
|
||||||
(= :edit command) (forms/stop-form ::form))
|
(= :edit command) (forms/stop-form ::form))
|
||||||
:dispatch-n (cond-> [(conj invoice-created invoice)]
|
:dispatch-n (cond-> [(conj invoice-created invoice)]
|
||||||
(= :add-and-print command) (conj (conj invoice-printed (:pdf-url (:add-and-print-invoice result)))))})))
|
(= :add-and-print command) (conj (conj invoice-printed (:pdf-url (:add-and-print-invoice result)))))})))
|
||||||
@@ -228,111 +229,112 @@
|
|||||||
min-total (if (= (:total (:original data)) (:outstanding-balance (:original data)))
|
min-total (if (= (:total (:original data)) (:outstanding-balance (:original data)))
|
||||||
nil
|
nil
|
||||||
(- (:total (:original data)) (:outstanding-balance (:original data))))]
|
(- (:total (:original data)) (:outstanding-balance (:original data))))]
|
||||||
^{:key id}
|
(with-meta
|
||||||
(form-inline (assoc params :title "New Invoice")
|
(form-inline (assoc params :title "New Invoice")
|
||||||
[:<>
|
[:<>
|
||||||
(when-not @(re-frame/subscribe [::subs/client])
|
(when-not @(re-frame/subscribe [::subs/client])
|
||||||
(field "Client"
|
(field "Client"
|
||||||
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
|
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
|
||||||
|
:match->text :name
|
||||||
|
:type "typeahead"
|
||||||
|
:auto-focus (if @(re-frame/subscribe [::subs/client]) false true)
|
||||||
|
:field [:client]
|
||||||
|
:disabled exists?
|
||||||
|
:spec ::invoice/client}]))
|
||||||
|
|
||||||
|
(field "Vendor"
|
||||||
|
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
|
||||||
:match->text :name
|
:match->text :name
|
||||||
:type "typeahead"
|
:type "typeahead"
|
||||||
:auto-focus (if @(re-frame/subscribe [::subs/client]) false true)
|
|
||||||
:field [:client]
|
|
||||||
:disabled exists?
|
:disabled exists?
|
||||||
:spec ::invoice/client}]))
|
:auto-focus (if @(re-frame/subscribe [::subs/client]) true false)
|
||||||
|
:field [:vendor]}])
|
||||||
|
|
||||||
(field "Vendor"
|
(field "Date"
|
||||||
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
|
[date-picker {:class-name "input"
|
||||||
:match->text :name
|
:class "input"
|
||||||
:type "typeahead"
|
:format-week-number (fn [] "")
|
||||||
:disabled exists?
|
:previous-month-button-label ""
|
||||||
:auto-focus (if @(re-frame/subscribe [::subs/client]) true false)
|
:placeholder "mm/dd/yyyy"
|
||||||
:field [:vendor]}])
|
:next-month-button-label ""
|
||||||
|
:next-month-label ""
|
||||||
|
:type "date"
|
||||||
|
:field [:date]
|
||||||
|
:spec ::invoice/date}])
|
||||||
|
|
||||||
(field "Date"
|
(field "Due (optional)"
|
||||||
[date-picker {:class-name "input"
|
[date-picker {:class-name "input"
|
||||||
:class "input"
|
:class "input"
|
||||||
:format-week-number (fn [] "")
|
:format-week-number (fn [] "")
|
||||||
:previous-month-button-label ""
|
:previous-month-button-label ""
|
||||||
:placeholder "mm/dd/yyyy"
|
:placeholder "mm/dd/yyyy"
|
||||||
:next-month-button-label ""
|
:next-month-button-label ""
|
||||||
:next-month-label ""
|
:next-month-label ""
|
||||||
:type "date"
|
:type "date"
|
||||||
:field [:date]
|
:field [:due]
|
||||||
:spec ::invoice/date}])
|
:spec ::invoice/due}])
|
||||||
|
|
||||||
(field "Due (optional)"
|
[:div.field
|
||||||
[date-picker {:class-name "input"
|
[:label.checkbox
|
||||||
:class "input"
|
(raw-field
|
||||||
:format-week-number (fn [] "")
|
[:input {:type "checkbox"
|
||||||
:previous-month-button-label ""
|
:field [:automatically-paid-when-due]
|
||||||
:placeholder "mm/dd/yyyy"
|
:spec ::invoice/automatically-paid-when-due}])
|
||||||
:next-month-button-label ""
|
" Mark as paid on due date"]]
|
||||||
:next-month-label ""
|
|
||||||
:type "date"
|
|
||||||
:field [:due]
|
|
||||||
:spec ::invoice/due}])
|
|
||||||
|
|
||||||
[:div.field
|
(field "Invoice #"
|
||||||
[:label.checkbox
|
[:input.input {:type "text"
|
||||||
(raw-field
|
:field [:invoice-number]
|
||||||
[:input {:type "checkbox"
|
:spec ::invoice/invoice-number}])
|
||||||
:field [:automatically-paid-when-due]
|
|
||||||
:spec ::invoice/automatically-paid-when-due}])
|
|
||||||
" Mark as paid on due date"]]
|
|
||||||
|
|
||||||
(field "Invoice #"
|
|
||||||
[:input.input {:type "text"
|
|
||||||
:field [:invoice-number]
|
|
||||||
:spec ::invoice/invoice-number}])
|
|
||||||
|
|
||||||
|
|
||||||
(field "Total"
|
(field "Total"
|
||||||
[money-field {:type "money"
|
[money-field {:type "money"
|
||||||
:field [:total]
|
:field [:total]
|
||||||
:disabled (if can-change-amount? "" "disabled")
|
:disabled (if can-change-amount? "" "disabled")
|
||||||
:min min-total
|
:min min-total
|
||||||
:spec ::invoice/total
|
:spec ::invoice/total
|
||||||
:step "0.01"}])
|
:step "0.01"}])
|
||||||
|
|
||||||
(field nil
|
(field nil
|
||||||
[expense-accounts-field {:type "expense-accounts"
|
[expense-accounts-field {:type "expense-accounts"
|
||||||
:descriptor "expense account"
|
:descriptor "expense account"
|
||||||
:locations (:locations (:client data))
|
:locations (:locations (:client data))
|
||||||
:max (:total data)
|
:max (:total data)
|
||||||
:client (or (:client data) @(re-frame/subscribe [::subs/client]))
|
:client (or (:client data) @(re-frame/subscribe [::subs/client]))
|
||||||
:field [:expense-accounts]}])
|
:field [:expense-accounts]}])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(error-notification)
|
(error-notification)
|
||||||
|
|
||||||
[:div.columns
|
[:div.columns
|
||||||
(when-not exists?
|
(when-not exists?
|
||||||
|
[:div.column
|
||||||
|
[drop-down {:header [:button.button.is-info.is-outlined.is-medium.is-fullwidth {:aria-haspopup true
|
||||||
|
:type "button"
|
||||||
|
:on-click (dispatch-event [::events/toggle-menu ::add-and-print-invoice ])
|
||||||
|
:disabled (if @(re-frame/subscribe [::can-submit])
|
||||||
|
""
|
||||||
|
"disabled")
|
||||||
|
|
||||||
|
:class (if false
|
||||||
|
"is-loading"
|
||||||
|
"")}
|
||||||
|
"Save & Pay "
|
||||||
|
[:span " "]
|
||||||
|
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
|
||||||
|
:class "is-fullwidth"
|
||||||
|
:id ::add-and-print-invoice}
|
||||||
|
[:div
|
||||||
|
(list
|
||||||
|
(for [{:keys [id number name type]} (->> (:bank-accounts (:client data)) (filter :visible) (sort-by :sort-order))]
|
||||||
|
(if (= :cash type)
|
||||||
|
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :cash])} "With cash"]
|
||||||
|
(list
|
||||||
|
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :check])} "Print checks from " name]
|
||||||
|
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :debit])} "Debit from " name]))))]]])
|
||||||
[:div.column
|
[:div.column
|
||||||
[drop-down {:header [:button.button.is-info.is-outlined.is-medium.is-fullwidth {:aria-haspopup true
|
|
||||||
:type "button"
|
|
||||||
:on-click (dispatch-event [::events/toggle-menu ::add-and-print-invoice ])
|
|
||||||
:disabled (if @(re-frame/subscribe [::can-submit])
|
|
||||||
""
|
|
||||||
"disabled")
|
|
||||||
|
|
||||||
:class (if false
|
(submit-button "Save")]]])
|
||||||
"is-loading"
|
{:key id}))])
|
||||||
"")}
|
|
||||||
"Save & Pay "
|
|
||||||
[:span " "]
|
|
||||||
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
|
|
||||||
:class "is-fullwidth"
|
|
||||||
:id ::add-and-print-invoice}
|
|
||||||
[:div
|
|
||||||
(list
|
|
||||||
(for [{:keys [id number name type]} (->> (:bank-accounts (:client data)) (filter :visible) (sort-by :sort-order))]
|
|
||||||
(if (= :cash type)
|
|
||||||
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :cash])} "With cash"]
|
|
||||||
(list
|
|
||||||
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :check])} "Print checks from " name]
|
|
||||||
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :debit])} "Debit from " name]))))]]])
|
|
||||||
[:div.column
|
|
||||||
|
|
||||||
(submit-button "Save")]]]))])
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
[grid/cell {} (date->str date) ]
|
[grid/cell {} (date->str date) ]
|
||||||
[grid/cell {:class "has-text-right"} (nf amount )]
|
[grid/cell {:class "has-text-right"} (nf amount )]
|
||||||
[grid/cell {} status]
|
[grid/cell {} status]
|
||||||
[grid/cell {:style {:overflow "visible"}}
|
[grid/button-cell {}
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
(when (seq invoices)
|
(when (seq invoices)
|
||||||
[drop-down {:id [::invoices id]
|
[drop-down {:id [::invoices id]
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
[grid/cell {} (date->str date) ]
|
[grid/cell {} (date->str date) ]
|
||||||
[grid/cell {:class "has-text-right"} (nf amount )]
|
[grid/cell {:class "has-text-right"} (nf amount )]
|
||||||
[grid/cell {} status]
|
[grid/cell {} status]
|
||||||
[grid/cell {:style {:overflow "visible"}}
|
[grid/button-cell {}
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
[drop-down {:id [::expense-accounts id ]
|
[drop-down {:id [::expense-accounts id ]
|
||||||
:header [buttons/sl-icon {:aria-haspopup true
|
:header [buttons/sl-icon {:aria-haspopup true
|
||||||
|
|||||||
@@ -97,6 +97,7 @@
|
|||||||
::params-change
|
::params-change
|
||||||
[with-user]
|
[with-user]
|
||||||
(fn [{:keys [user]} [_ params]]
|
(fn [{:keys [user]} [_ params]]
|
||||||
|
(println "REQUERY")
|
||||||
{:graphql {:token user
|
{:graphql {:token user
|
||||||
:owns-state {:single ::page}
|
:owns-state {:single ::page}
|
||||||
:query-obj (table/query params )
|
:query-obj (table/query params )
|
||||||
@@ -363,10 +364,21 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::invoice-updated
|
::invoice-updated
|
||||||
[(re-frame/path [::invoice-page :invoices])]
|
[(re-frame/path [::invoice-page :invoices])]
|
||||||
(fn [{:keys [db]} [_ [_ invoice]]]
|
(fn [{:keys [db]} [_ [_ invoice]]]
|
||||||
{:db (merge-by db :id invoice)}))
|
(let [by-id (by :id db )]
|
||||||
|
{:db (if (by-id (:id invoice))
|
||||||
|
(merge-by db :id invoice)
|
||||||
|
(into [invoice] db))})))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::invoice-edited
|
||||||
|
[(re-frame/path [::invoice-page :invoices])]
|
||||||
|
(fn [{:keys [db]} [_ invoice]]
|
||||||
|
(let [invoice (assoc invoice :class "live-added")]
|
||||||
|
(let [by-id (by :id db )]
|
||||||
|
{:db (if (by-id (:id invoice))
|
||||||
|
(merge-by db :id invoice)
|
||||||
|
(into [invoice] db))}))))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::expense-accounts-updated
|
::expense-accounts-updated
|
||||||
@@ -630,5 +642,5 @@
|
|||||||
[print-checks-modal]
|
[print-checks-modal]
|
||||||
[handwrite-checks-modal]
|
[handwrite-checks-modal]
|
||||||
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]]
|
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]]
|
||||||
:right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {:invoice-created [::invoice-updated]
|
:right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {:invoice-created [::invoice-edited]
|
||||||
:invoice-printed [::checks-printed]}]]}]))}))
|
:invoice-printed [::checks-printed]}]]}]))}))
|
||||||
|
|||||||
Reference in New Issue
Block a user