begun on unpaid invoice match.
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which potential-payment-matches potential-autopay-invoices-matches potential-transaction-rule-matches]]
|
||||
(fn [db [_ which potential-payment-matches potential-autopay-invoices-matches potential-unpaid-invoices-matches potential-transaction-rule-matches]]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client which))])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id (:client which)])]
|
||||
(forms/start-form db ::form
|
||||
@@ -68,6 +68,7 @@
|
||||
(assoc :potential-payment-matches potential-payment-matches)
|
||||
(assoc :potential-transaction-rule-matches potential-transaction-rule-matches)
|
||||
(assoc :potential-autopay-invoices-matches potential-autopay-invoices-matches)
|
||||
(assoc :potential-unpaid-invoices-matches potential-unpaid-invoices-matches)
|
||||
(update :accounts expense-accounts-field/from-graphql accounts-by-id (:amount which) locations))))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
@@ -247,6 +248,30 @@
|
||||
"Match"]]]))]]))
|
||||
|
||||
|
||||
(defn potential-unpaid-invoices-matches-box [{:keys [potential-unpaid-invoices-matches] :as params}]
|
||||
(let [states @(re-frame/subscribe [::status/multi ::matching])]
|
||||
[:div
|
||||
[:div.notification.is-light.is-info "This transaction may match the following unpaid invoice(s)."]
|
||||
[:table.table.grid.is-fullwidth
|
||||
(list
|
||||
(for [invoices potential-unpaid-invoices-matches]
|
||||
^{:key (str invoices)}
|
||||
[:tr
|
||||
[:td {:style {:width "30%"}} (:name (:vendor (first invoices)))]
|
||||
[:td {:style {:overflow "visible" :width "60%"}} [:span.has-tooltip-arrow.has-tooltip-bottom {:data-tooltip (str/join "\n"
|
||||
(for [i invoices]
|
||||
(str (:invoice-number i) " (" (->$ (:total i)) ")"))
|
||||
)}
|
||||
(count invoices) " invoices" (if (> (count invoices) 1)
|
||||
(str " from " (date->str (:date (first invoices))) " - " (date->str (:date (last invoices))))
|
||||
(str " on " (date->str (:date (first invoices)))))]]
|
||||
[:td {:style {:width "6em"}}
|
||||
[:a.button.is-primary.is-small {:on-click (dispatch-event [::matching-unpaid-invoices (map :id invoices)])
|
||||
:class (status/class-for (get states [:unpaid-invoices (map :id invoices)]))
|
||||
:disabled (status/disabled-if-any states)}
|
||||
"Match"]]]))]]))
|
||||
|
||||
|
||||
(defonce ^js/React.Context current-tab-context ( react/createContext "default"))
|
||||
(def ^js/React.Provider CurrentTabProvider (. current-tab-context -Provider))
|
||||
#_(println "Provider is" Provider)
|
||||
@@ -267,7 +292,7 @@
|
||||
(into [:div]
|
||||
(->> (r/children (r/current-component))
|
||||
(filter identity)
|
||||
(filter #(= (doto (:key (second %)) println) current-tab-v) )
|
||||
(filter #(= (:key (second %)) current-tab-v) )
|
||||
first
|
||||
(drop 2)))]))))))
|
||||
|
||||
@@ -340,10 +365,17 @@
|
||||
|
||||
(when
|
||||
(and (seq (:potential-autopay-invoices-matches data))
|
||||
#_(not is-already-matched?)
|
||||
is-admin?)
|
||||
[tab {:title "Autopay Invoices" :key :autopay-invoices}
|
||||
[potential-autopay-invoices-matches-box {:potential-autopay-invoices-matches (:potential-autopay-invoices-matches data)}]])
|
||||
|
||||
(when
|
||||
(and (seq (:potential-unpaid-invoices-matches data))
|
||||
(not is-already-matched?)
|
||||
is-admin?)
|
||||
[tab {:title "Autopay invoices" :key :autopay-invoices}
|
||||
[potential-autopay-invoices-matches-box {:potential-autopay-invoices-matches (:potential-autopay-invoices-matches data)}]])
|
||||
[tab {:title "Unpaid Invoices" :key :unpaid-invoices}
|
||||
[potential-unpaid-invoices-matches-box {:potential-unpaid-invoices-matches (:potential-unpaid-invoices-matches data)}]])
|
||||
|
||||
(when
|
||||
(and (seq (:potential-payment-matches data))
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
::editing-matches-found
|
||||
(fn [{:keys [db]} [_ which matches]]
|
||||
{:dispatch
|
||||
[::edit/editing which (:potential-payment-matches matches) (:potential-autopay-invoices-matches matches) (:potential-transaction-rule-matches matches)]}))
|
||||
[::edit/editing which (:potential-payment-matches matches) (:potential-autopay-invoices-matches matches) (:potential-unpaid-invoices-matches matches) (:potential-transaction-rule-matches matches)]}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::editing-matches-failed
|
||||
@@ -41,6 +41,9 @@
|
||||
{:transaction_id (:id which)}
|
||||
[:id :memo :check-number [:vendor [:name]]]]}
|
||||
{:query/data [:potential-autopay-invoices-matches
|
||||
{:transaction_id (:id which)}
|
||||
[:id :invoice-number :total :date :scheduled-payment [:vendor [:name]]]]}
|
||||
{:query/data [:potential-unpaid-invoices-matches
|
||||
{:transaction_id (:id which)}
|
||||
[:id :invoice-number :total :date :scheduled-payment [:vendor [:name]]]]}]
|
||||
(when @(re-frame/subscribe [::subs/is-admin?])
|
||||
|
||||
Reference in New Issue
Block a user