unpaid and paid invoices use the same underlying page, now.
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
[io.forward/clojure-mail "1.0.7"]
|
[io.forward/clojure-mail "1.0.7"]
|
||||||
[ring/ring-json "0.4.0"
|
[ring/ring-json "0.4.0"
|
||||||
:exclusions [cheshire]]
|
:exclusions [cheshire]]
|
||||||
|
[com.cemerick/url "0.1.1"]
|
||||||
[amazonica "0.3.121"
|
[amazonica "0.3.121"
|
||||||
:exclusions [com.amazonaws/aws-java-sdk
|
:exclusions [com.amazonaws/aws-java-sdk
|
||||||
com.amazonaws/amazon-kinesis-client]]
|
com.amazonaws/amazon-kinesis-client]]
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.utils :refer [by]]
|
||||||
[venia.core :as v]
|
[venia.core :as v]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
|
[cemerick.url :refer [url]]
|
||||||
[goog.crypt.base64 :as b64]
|
[goog.crypt.base64 :as b64]
|
||||||
[clojure.string :as str]))
|
[clojure.string :as str]))
|
||||||
|
|
||||||
@@ -33,6 +34,9 @@
|
|||||||
:else
|
:else
|
||||||
{:db (assoc db/default-db
|
{:db (assoc db/default-db
|
||||||
:active-page handler
|
:active-page handler
|
||||||
|
:query-params (->> (:query (url (.-location js/window)))
|
||||||
|
(map (fn [[k v]] [(keyword k) v]))
|
||||||
|
(into {}))
|
||||||
:user token)
|
:user token)
|
||||||
:graphql {:token token
|
:graphql {:token token
|
||||||
:query-obj {:venia/queries [[:client
|
:query-obj {:venia/queries [[:client
|
||||||
@@ -106,11 +110,13 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::set-active-page
|
::set-active-page
|
||||||
(fn [{:keys [db]} [_ handler]]
|
(fn [{:keys [db]} [_ handler params]]
|
||||||
|
(println "PARAMS" params)
|
||||||
(if (and (not= :login handler) (not (:user db)))
|
(if (and (not= :login handler) (not (:user db)))
|
||||||
{:redirect "/login"
|
{:redirect "/login"
|
||||||
:db (assoc db :active-page :login)}
|
:db (assoc db :active-page :login)}
|
||||||
{:db (assoc db :active-page handler)})))
|
{:db (assoc db :active-page handler
|
||||||
|
:query-params params)})))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::imported-invoices
|
::imported-invoices
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
(:require [bidi.bidi :as bidi]
|
(:require [bidi.bidi :as bidi]
|
||||||
[pushy.core :as pushy]
|
[pushy.core :as pushy]
|
||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
|
[cemerick.url :refer [url]]
|
||||||
[re-frame.core :as re-frame]))
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
(defn- parse-url [url]
|
(defn- parse-url [url]
|
||||||
@@ -10,7 +11,9 @@
|
|||||||
|
|
||||||
(defn- dispatch-route [matched-route]
|
(defn- dispatch-route [matched-route]
|
||||||
(println "Matched route" matched-route)
|
(println "Matched route" matched-route)
|
||||||
(re-frame/dispatch [:auto-ap.events/set-active-page (:handler matched-route)]))
|
(re-frame/dispatch [:auto-ap.events/set-active-page (:handler matched-route) (->> (:query (url (.-location js/window)))
|
||||||
|
(map (fn [[k v]] [(keyword k) v]))
|
||||||
|
(into {}))]))
|
||||||
|
|
||||||
|
|
||||||
(def history (pushy/pushy dispatch-route parse-url))
|
(def history (pushy/pushy dispatch-route parse-url))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
(def routes ["/" {"" :index
|
(def routes ["/" {"" :index
|
||||||
"login/" :login
|
"login/" :login
|
||||||
"needs-activation/" :needs-activation
|
"needs-activation/" :needs-activation
|
||||||
|
"needs-activation" :needs-activation
|
||||||
"checks/" :checks
|
"checks/" :checks
|
||||||
"admin/" {"" :admin
|
"admin/" {"" :admin
|
||||||
"clients" :admin-clients
|
"clients" :admin-clients
|
||||||
|
|||||||
@@ -85,6 +85,11 @@
|
|||||||
(map (fn [[k v]] (assoc v :id k))
|
(map (fn [[k v]] (assoc v :id k))
|
||||||
expense-accounts)))
|
expense-accounts)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::query-params
|
||||||
|
(fn [db]
|
||||||
|
(:query-params db)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::chooseable-expense-accounts
|
::chooseable-expense-accounts
|
||||||
(fn [db]
|
(fn [db]
|
||||||
|
|||||||
@@ -19,15 +19,14 @@
|
|||||||
[auto-ap.views.pages.admin.users :refer [admin-users-page]]
|
[auto-ap.views.pages.admin.users :refer [admin-users-page]]
|
||||||
[auto-ap.views.pages.admin.yodlee :refer [admin-yodlee-page]]
|
[auto-ap.views.pages.admin.yodlee :refer [admin-yodlee-page]]
|
||||||
[auto-ap.entities.clients :as clients]
|
[auto-ap.entities.clients :as clients]
|
||||||
[auto-ap.views.pages :as pages]
|
|
||||||
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]))
|
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]))
|
||||||
|
|
||||||
(defmulti page (fn [active-page] active-page))
|
(defmulti page (fn [active-page] active-page))
|
||||||
(defmethod page :unpaid-invoices [_]
|
(defmethod page :unpaid-invoices [_]
|
||||||
(unpaid-invoices-page))
|
(unpaid-invoices-page {:status "unpaid"}))
|
||||||
|
|
||||||
(defmethod page :paid-invoices [_]
|
(defmethod page :paid-invoices [_]
|
||||||
(paid-invoices-page))
|
(unpaid-invoices-page {:status "paid"}))
|
||||||
|
|
||||||
(defmethod page :checks [_]
|
(defmethod page :checks [_]
|
||||||
(checks-page))
|
(checks-page))
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
(ns auto-ap.views.pages
|
|
||||||
(:require-macros [cljs.core.async.macros :refer [go]])
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[reagent.core :as reagent]
|
|
||||||
[auto-ap.subs :as subs]
|
|
||||||
[auto-ap.events :as events]
|
|
||||||
[auto-ap.views.pages.login :refer [login-page]]
|
|
||||||
[auto-ap.views.pages.index :refer [index-page]]
|
|
||||||
[auto-ap.views.pages.admin :refer [admin-page]]
|
|
||||||
[auto-ap.views.pages.needs-activation :refer [needs-activation-page]]
|
|
||||||
[auto-ap.views.pages.check :refer [check-page]]
|
|
||||||
[auto-ap.views.pages.admin.clients :refer [admin-clients-page]]
|
|
||||||
[auto-ap.views.pages.admin.yodlee :refer [admin-yodlee-page]]
|
|
||||||
[auto-ap.views.pages.admin.users :refer [admin-users-page]]
|
|
||||||
[auto-ap.views.pages.admin.vendors :refer [admin-vendors-page]]
|
|
||||||
[auto-ap.views.pages.admin.reminders :refer [admin-reminders-page]]
|
|
||||||
[auto-ap.views.pages.unpaid-invoices :refer [unpaid-invoices-page]]
|
|
||||||
[auto-ap.views.pages.checks :refer [checks-page]]
|
|
||||||
[auto-ap.views.pages.transactions :refer [transactions-page]]
|
|
||||||
[auto-ap.views.pages.new-invoice :refer [new-invoice-page]]
|
|
||||||
[auto-ap.views.pages.import-invoices :refer [import-invoices-page]]
|
|
||||||
[auto-ap.views.pages.admin.excel-import :refer [admin-excel-import-page]]
|
|
||||||
[auto-ap.views.pages.paid-invoices :refer [paid-invoices-page]]
|
|
||||||
[cljs.reader :as edn]
|
|
||||||
[cljsjs.dropzone :as dz]
|
|
||||||
[auto-ap.routes :as routes]
|
|
||||||
[bidi.bidi :as bidi]
|
|
||||||
[cljs-http.client :as http]
|
|
||||||
[cljs.core.async :refer [<!]]))
|
|
||||||
|
|
||||||
|
|
||||||
(defmulti active-page identity)
|
|
||||||
|
|
||||||
(defmethod active-page :login []
|
|
||||||
login-page)
|
|
||||||
|
|
||||||
(defmethod active-page :index []
|
|
||||||
index-page)
|
|
||||||
|
|
||||||
(defmethod active-page :admin []
|
|
||||||
[admin-page])
|
|
||||||
|
|
||||||
(defmethod active-page :needs-activation []
|
|
||||||
[needs-activation-page])
|
|
||||||
|
|
||||||
(defmethod active-page :check []
|
|
||||||
[check-page])
|
|
||||||
|
|
||||||
(defmethod active-page :admin-clients []
|
|
||||||
[admin-clients-page])
|
|
||||||
|
|
||||||
(defmethod active-page :admin-vendors []
|
|
||||||
[admin-vendors-page])
|
|
||||||
|
|
||||||
(defmethod active-page :admin-reminders []
|
|
||||||
[admin-reminders-page])
|
|
||||||
|
|
||||||
(defmethod active-page :admin-yodlee []
|
|
||||||
[admin-yodlee-page])
|
|
||||||
|
|
||||||
(defmethod active-page :admin-excel-import []
|
|
||||||
[admin-excel-import-page])
|
|
||||||
|
|
||||||
(defmethod active-page :admin-users []
|
|
||||||
[admin-users-page])
|
|
||||||
|
|
||||||
(defmethod active-page :unpaid-invoices []
|
|
||||||
[unpaid-invoices-page])
|
|
||||||
|
|
||||||
(defmethod active-page :paid-invoices []
|
|
||||||
[paid-invoices-page])
|
|
||||||
|
|
||||||
(defmethod active-page :checks []
|
|
||||||
[checks-page])
|
|
||||||
|
|
||||||
(defmethod active-page :transactions []
|
|
||||||
[transactions-page])
|
|
||||||
|
|
||||||
(defmethod active-page :invoices []
|
|
||||||
[(with-meta
|
|
||||||
(fn []
|
|
||||||
[:div
|
|
||||||
[:h1.title "All invoices"]])
|
|
||||||
{:component-did-mount (fn []
|
|
||||||
(go
|
|
||||||
(re-frame/dispatch [::events/received-invoices (:body (<! (http/get "/api/invoices")))])))})])
|
|
||||||
|
|
||||||
(defmethod active-page :import-invoices []
|
|
||||||
[import-invoices-page])
|
|
||||||
|
|
||||||
|
|
||||||
(defmethod active-page :new-invoice [] new-invoice-page)
|
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
(assoc-in [:status :loading] true)
|
(assoc-in [:status :loading] true)
|
||||||
(assoc-in [::params] params))
|
(assoc-in [::params] params))
|
||||||
:graphql {:token (-> cofx :db :user)
|
:graphql {:token (-> cofx :db :user)
|
||||||
:query-obj (invoice-table/query (doto (assoc params :imported true :status "unpaid") println))
|
:query-obj (invoice-table/query (doto (assoc params :imported true) println))
|
||||||
:on-success [::received]}}))
|
:on-success [::received]}}))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
@@ -614,7 +614,7 @@
|
|||||||
:step "0.01"}]]]]]
|
:step "0.01"}]]]]]
|
||||||
]))
|
]))
|
||||||
|
|
||||||
(defn edit-invoice-modal []
|
(defn edit-invoice-modal [{:keys [can-change-amount?]}]
|
||||||
(let [data @(re-frame/subscribe [::edit-invoice])
|
(let [data @(re-frame/subscribe [::edit-invoice])
|
||||||
change-event [::events/change-form [::edit-invoice]]
|
change-event [::events/change-form [::edit-invoice]]
|
||||||
locations (get-in @(re-frame/subscribe [::subs/clients-by-id]) [(:client-id data) :locations])
|
locations (get-in @(re-frame/subscribe [::subs/clients-by-id]) [(:client-id data) :locations])
|
||||||
@@ -659,12 +659,12 @@
|
|||||||
[bind-field
|
[bind-field
|
||||||
[:input.input {:type "number"
|
[:input.input {:type "number"
|
||||||
:field [:total]
|
:field [:total]
|
||||||
|
:disabled (if can-change-amount? "" "disabled")
|
||||||
:event change-event
|
:event change-event
|
||||||
:min min-total
|
:min min-total
|
||||||
:subscription data
|
:subscription data
|
||||||
:spec ::invoice/total
|
:spec ::invoice/total
|
||||||
:step "0.01"}]]]]]
|
:step "0.01"}]]]]]]))
|
||||||
]))
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::change-selected-vendor
|
::change-selected-vendor
|
||||||
@@ -702,15 +702,8 @@
|
|||||||
(re-frame/dispatch [::params-change (assoc params :invoice-number-like (.. x -target -value)) ])
|
(re-frame/dispatch [::params-change (assoc params :invoice-number-like (.. x -target -value)) ])
|
||||||
)} ]]]))
|
)} ]]]))
|
||||||
|
|
||||||
(def unpaid-invoices-content
|
(defn pay-button [{:keys [print-checks-shown? checked-invoices print-checks-loading?]}]
|
||||||
(with-meta
|
(let [current-client @(re-frame/subscribe [::subs/client])]
|
||||||
(fn [_]
|
|
||||||
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown? vendor-filter]} @(re-frame/subscribe [::invoice-page])
|
|
||||||
current-client @(re-frame/subscribe [::subs/client])
|
|
||||||
{check-results-shown? :shown? pdf-url :pdf-url} @(re-frame/subscribe [::check-results])]
|
|
||||||
[:div
|
|
||||||
[:h1.title "Unpaid invoices"]
|
|
||||||
|
|
||||||
[:div.is-pulled-right
|
[:div.is-pulled-right
|
||||||
[:button.button.is-danger {:on-click (dispatch-event [::new-invoice])} "New Invoice"]
|
[:button.button.is-danger {:on-click (dispatch-event [::new-invoice])} "New Invoice"]
|
||||||
(when current-client
|
(when current-client
|
||||||
@@ -720,7 +713,7 @@
|
|||||||
[:div.dropdown-trigger
|
[:div.dropdown-trigger
|
||||||
[:button.button.is-success {:aria-haspopup true
|
[:button.button.is-success {:aria-haspopup true
|
||||||
:on-click (dispatch-event [::print-checks-clicked ])
|
:on-click (dispatch-event [::print-checks-clicked ])
|
||||||
:disabled (if (seq checked)
|
:disabled (if (seq checked-invoices)
|
||||||
""
|
""
|
||||||
"disabled")
|
"disabled")
|
||||||
|
|
||||||
@@ -741,9 +734,22 @@
|
|||||||
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :debit])} "Debit from " name])))
|
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :debit])} "Debit from " name])))
|
||||||
^{:key "advanced-divider"} [:hr.dropdown-divider]
|
^{:key "advanced-divider"} [:hr.dropdown-divider]
|
||||||
|
|
||||||
(when (= 1 (count checked))
|
(when (= 1 (count checked-invoices))
|
||||||
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event [::handwrite-checks])} "Handwritten Check..."])
|
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event [::handwrite-checks])} "Handwritten Check..."])
|
||||||
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event [::advanced-print-checks])} "Advanced..."])]]])]
|
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event [::advanced-print-checks])} "Advanced..."])]]])]))
|
||||||
|
|
||||||
|
(defn unpaid-invoices-content [{:keys [status]}]
|
||||||
|
(r/create-class {:display-name "unpaid-invoices-content"
|
||||||
|
:reagent-render (fn [{:keys [status]}]
|
||||||
|
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown? vendor-filter]} @(re-frame/subscribe [::invoice-page])
|
||||||
|
current-client @(re-frame/subscribe [::subs/client])
|
||||||
|
{check-results-shown? :shown? pdf-url :pdf-url} @(re-frame/subscribe [::check-results])]
|
||||||
|
[:div
|
||||||
|
[:h1.title (str (str/capitalize status) " invoices")]
|
||||||
|
(when (= status "unpaid")
|
||||||
|
[pay-button {:print-checks-shown? print-checks-shown? :checked-invoices checked :print-checks-loading? print-checks-loading?}])
|
||||||
|
|
||||||
|
|
||||||
[invoice-table {:id :unpaid
|
[invoice-table {:id :unpaid
|
||||||
:params (re-frame/subscribe [::params])
|
:params (re-frame/subscribe [::params])
|
||||||
:invoice-page (re-frame/subscribe [::invoice-page])
|
:invoice-page (re-frame/subscribe [::invoice-page])
|
||||||
@@ -755,7 +761,7 @@
|
|||||||
(re-frame/dispatch [::void-invoice which]))
|
(re-frame/dispatch [::void-invoice which]))
|
||||||
:on-params-change (fn [params]
|
:on-params-change (fn [params]
|
||||||
(re-frame/dispatch [::params-change params]))
|
(re-frame/dispatch [::params-change params]))
|
||||||
:check-boxes true
|
:check-boxes (= status "unpaid")
|
||||||
:checked checked
|
:checked checked
|
||||||
:on-check-changed (fn [which]
|
:on-check-changed (fn [which]
|
||||||
(re-frame/dispatch [::toggle-check which]))
|
(re-frame/dispatch [::toggle-check which]))
|
||||||
@@ -763,7 +769,7 @@
|
|||||||
|
|
||||||
[print-checks-modal]
|
[print-checks-modal]
|
||||||
[new-invoice-modal]
|
[new-invoice-modal]
|
||||||
[edit-invoice-modal]
|
[edit-invoice-modal {:can-change-amount? (= status "unpaid")}]
|
||||||
[handwrite-checks-modal]
|
[handwrite-checks-modal]
|
||||||
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]
|
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]
|
||||||
(when check-results-shown?
|
(when check-results-shown?
|
||||||
@@ -781,9 +787,9 @@
|
|||||||
]))
|
]))
|
||||||
|
|
||||||
]))
|
]))
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
:component-will-mount #(re-frame/dispatch-sync [::params-change {:status status}]) }))
|
||||||
|
|
||||||
(defn unpaid-invoices-page []
|
(defn unpaid-invoices-page [{:keys [status]}]
|
||||||
[side-bar-layout {:side-bar [invoices-side-bar {}
|
[side-bar-layout {:side-bar [invoices-side-bar {}
|
||||||
^{:key "extra-filter"}
|
^{:key "extra-filter"}
|
||||||
[:div
|
[:div
|
||||||
@@ -791,10 +797,8 @@
|
|||||||
[:div [vendor-filter]]
|
[:div [vendor-filter]]
|
||||||
[:p.menu-label "Invoice #"]
|
[:p.menu-label "Invoice #"]
|
||||||
[:div
|
[:div
|
||||||
[invoice-number-filter]
|
[invoice-number-filter]]]]
|
||||||
]]
|
:main [unpaid-invoices-content {:status status}]
|
||||||
]
|
|
||||||
:main [unpaid-invoices-content]
|
|
||||||
:bottom [vendor-dialog {:vendor @(re-frame/subscribe [::subs/user-editing-vendor])
|
:bottom [vendor-dialog {:vendor @(re-frame/subscribe [::subs/user-editing-vendor])
|
||||||
:save-event [::events/save-vendor]
|
:save-event [::events/save-vendor]
|
||||||
:change-event [::events/change-nested-form-state [:user-editing-vendor]] :id :auto-ap.views.main/user-editing-vendor}]}])
|
:change-event [::events/change-nested-form-state [:user-editing-vendor]] :id :auto-ap.views.main/user-editing-vendor}]}])
|
||||||
|
|||||||
Reference in New Issue
Block a user