renamed company to client.
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
|
||||
(def default-db
|
||||
{:user (.getItem js/localStorage "jwt")
|
||||
:company {:name "Campbell Brewing Company"}
|
||||
:companies []
|
||||
:client {:name "Campbell Brewing Company"}
|
||||
:clients []
|
||||
:invoices {:pending #{}
|
||||
:unpaid #{}}
|
||||
:status {:loading false}
|
||||
:new-invoice {}
|
||||
:menu {:company {:active? false}
|
||||
:menu {:client {:active? false}
|
||||
:account {:active? false}}
|
||||
})
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
:active-page handler
|
||||
:user token)
|
||||
:graphql {:token token
|
||||
:query-obj {:venia/queries [[:company
|
||||
:query-obj {:venia/queries [[:client
|
||||
|
||||
[:id :name :locations [:bank-accounts [:id :number :check-number :name :type] ]
|
||||
[:address [:street1 :street2 :city :state :zip]]]]
|
||||
@@ -59,7 +59,7 @@
|
||||
::logged-in
|
||||
(fn [{:keys [db]} [_ token user]]
|
||||
{:graphql {:token token
|
||||
:query-obj {:venia/queries [[:company
|
||||
:query-obj {:venia/queries [[:client
|
||||
[:id :name [:bank-accounts [:id :number :check-number :name :type]]]]
|
||||
[:vendor
|
||||
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
||||
@@ -69,15 +69,15 @@
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::received-initial
|
||||
(fn [db [_ {companies :company vendors :vendor :as x}]]
|
||||
(fn [db [_ {clients :client vendors :vendor :as x}]]
|
||||
(-> db
|
||||
(assoc :companies (by :id companies) )
|
||||
(assoc :clients (by :id clients) )
|
||||
(assoc :vendors (by :id vendors) ))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::swap-company
|
||||
(fn [db [_ company]]
|
||||
(assoc db :company (:id company))))
|
||||
::swap-client
|
||||
(fn [db [_ client]]
|
||||
(assoc db :client (:id client))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::change-form
|
||||
@@ -123,8 +123,8 @@
|
||||
{:db (assoc-in (:db cofx) [:status :loading] true)
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
:query-obj {:venia/queries [[:invoice
|
||||
{:imported false :company_id (:id @(re-frame/subscribe [::subs/company]))}
|
||||
[:id :total :invoice-number :date [:vendor [:name :id]] [:company [:name :id]]]]]}
|
||||
{:imported false :client_id (:id @(re-frame/subscribe [::subs/client]))}
|
||||
[:id :total :invoice-number :date [:vendor [:name :id]] [:client [:name :id]]]]]}
|
||||
|
||||
:on-success [::received-invoices :pending]}}))
|
||||
|
||||
@@ -134,8 +134,8 @@
|
||||
{:db (assoc-in (:db cofx) [:status :loading] true)
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
:query-obj {:venia/queries [[:invoice
|
||||
{:imported true :company_id (:id @(re-frame/subscribe [::subs/company]))}
|
||||
[:id :total :invoice-number :date [:vendor [:name :id]] [:company [:name :id]]]]]}
|
||||
{:imported true :client_id (:id @(re-frame/subscribe [::subs/client]))}
|
||||
[:id :total :invoice-number :date [:vendor [:name :id]] [:client [:name :id]]]]]}
|
||||
:on-success [::received-invoices :unpaid]}}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
@@ -146,7 +146,7 @@
|
||||
(re-frame/reg-event-fx
|
||||
::logout
|
||||
(fn [{:keys [db]} [_]]
|
||||
{:db (assoc db :user nil :menu {:company {:active? false}
|
||||
{:db (assoc db :user nil :menu {:client {:active? false}
|
||||
:account {:active? false}})
|
||||
:redirect (bidi/path-for routes/routes :login)
|
||||
:set-local-storage ["jwt" nil]}))
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
(ns auto-ap.events.admin.companies
|
||||
(ns auto-ap.events.admin.clients
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.db :as db]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.routes :as routes]
|
||||
[auto-ap.effects :as effects]
|
||||
[auto-ap.entities.companies :as entity]
|
||||
[auto-ap.entities.clients :as entity]
|
||||
[bidi.bidi :as bidi]))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::edit
|
||||
(fn [{:keys [db]} [_ company-id]]
|
||||
{:dispatch [::events/modal-status :auto-ap.views.pages.admin.companies/edit {:visible? true}]
|
||||
:db (assoc-in db [:admin :company]
|
||||
(get (:companies db) company-id))}))
|
||||
(fn [{:keys [db]} [_ client-id]]
|
||||
{:dispatch [::events/modal-status :auto-ap.views.pages.admin.clients/edit {:visible? true}]
|
||||
:db (assoc-in db [:admin :client]
|
||||
(get (:clients db) client-id))}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save
|
||||
(fn [{:keys [db]} _]
|
||||
(let [edited-company (-> (get-in db [:admin :company])
|
||||
(let [edited-client (-> (get-in db [:admin :clients])
|
||||
(dissoc :location))]
|
||||
|
||||
{:db (assoc-in db [:admin :company :saving?] true)
|
||||
{:db (assoc-in db [:admin :client :saving?] true)
|
||||
:http {:method :put
|
||||
:token (:user db)
|
||||
:body (pr-str edited-company)
|
||||
:body (pr-str edited-client)
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/companies/" (:id edited-company))
|
||||
:uri (str "/api/clients/" (:id edited-client))
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save-complete
|
||||
(fn [{:keys [db]} [_ company]]
|
||||
{:dispatch [::events/modal-completed :auto-ap.views.pages.admin.companies/edit]
|
||||
(fn [{:keys [db]} [_ client]]
|
||||
{:dispatch [::events/modal-completed :auto-ap.views.pages.admin.clients/edit]
|
||||
:db (-> db
|
||||
|
||||
(assoc-in [:admin :company] nil)
|
||||
(assoc-in [:companies (:id company)] company))}))
|
||||
(assoc-in [:admin :clients] nil)
|
||||
(assoc-in [:clients (:id client)] client))}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::save-error
|
||||
(fn [db [_ company]]
|
||||
(fn [db [_ client]]
|
||||
(-> db
|
||||
(assoc-in [:admin :company :saving?] false)
|
||||
(assoc-in [:admin :company :error] true))))
|
||||
(assoc-in [:admin :client :saving?] false)
|
||||
(assoc-in [:admin :client :error] true))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::change
|
||||
(fn [db [_ path value]]
|
||||
(assoc-in db (concat [:admin :company] path)
|
||||
(assoc-in db (concat [:admin :client] path)
|
||||
value)))
|
||||
@@ -99,8 +99,8 @@
|
||||
(-> db
|
||||
(update-in [:admin :vendor :relationships] #(conj (or % [])
|
||||
{:account-number (get-in db [:admin :vendor :new-relationship-account-number])
|
||||
:company-id (get-in db [:admin :vendor :new-relationship-company])}))
|
||||
(update-in [:admin :vendor] dissoc :new-relationship-account-number :new-relationship-company))))
|
||||
:client-id (get-in db [:admin :vendor :new-relationship-client])}))
|
||||
(update-in [:admin :vendor] dissoc :new-relationship-account-number :new-relationship-client))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::remove-relationship
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[clojure.spec.alpha :as s]
|
||||
[cljs-time.core :as c]
|
||||
[goog.string :as gstring]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.clients :as clients]
|
||||
[auto-ap.entities.invoice :as invoice]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.expense-accounts :as expense-accounts]
|
||||
@@ -40,7 +40,7 @@
|
||||
[:vendor [:name :id]]
|
||||
[:expense_accounts [:amount :id :location :expense_account_id
|
||||
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
||||
[:company [:name :id :locations]]
|
||||
[:client [:name :id :locations]]
|
||||
[:checks [:amount [:check [:amount :s3_url :check_number ]]]]
|
||||
]]}]}
|
||||
:on-success [::expense-accounts-updated]}})))
|
||||
@@ -62,7 +62,7 @@
|
||||
(re-frame/reg-event-db
|
||||
::add-expense-account-split
|
||||
(fn [db _]
|
||||
(let [{{{:keys [locations]} :company} :invoice} @(re-frame/subscribe [::change-expense-accounts])]
|
||||
(let [{{{:keys [locations]} :client} :invoice} @(re-frame/subscribe [::change-expense-accounts])]
|
||||
(update-in db [::change-expense-accounts :invoice :expense-accounts]
|
||||
conj {:amount 0 :expense-account-id nil :location (first locations)}))))
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"needs-activation/" :needs-activation
|
||||
"checks/" :checks
|
||||
"admin/" {"" :admin
|
||||
"companies" :admin-companies
|
||||
"clients" :admin-clients
|
||||
"users" :admin-users
|
||||
"reminders" :admin-reminders
|
||||
"vendors" :admin-vendors
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
[goog.crypt.base64 :as base64]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::company
|
||||
::client
|
||||
(fn [db]
|
||||
(get (:companies db) (:company db))))
|
||||
(get (:clients db) (:client db))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::companies
|
||||
::clients
|
||||
(fn [db]
|
||||
(when (:user db)
|
||||
(vals (:companies db)))))
|
||||
(vals (:clients db)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::companies-by-id
|
||||
::clients-by-id
|
||||
(fn [db]
|
||||
(when (:user db)
|
||||
(:companies db))))
|
||||
(:clients db))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::menu
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[cljs-time.core :as c]
|
||||
[goog.string :as gstring]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.clients :as client]
|
||||
[auto-ap.entities.invoice :as invoice]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.expense-accounts :as expense-accounts]
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
|
||||
(defn change-expense-accounts-modal [{:keys [updated-event]}]
|
||||
(let [{{:keys [expense-accounts total ] :or {expense-accounts [] total 0} {:keys [locations]} :company} :invoice :as data} @(re-frame/subscribe [::change-expense-accounts])
|
||||
(let [{{:keys [expense-accounts total ] :or {expense-accounts [] total 0} {:keys [locations]} :client} :invoice :as data} @(re-frame/subscribe [::change-expense-accounts])
|
||||
multi-location? (> (count locations) 1)
|
||||
change-event [::events/change-form [::change-expense-accounts]]
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
(defn query [params]
|
||||
{:venia/queries [[:invoice_page
|
||||
(assoc params
|
||||
:client-id (:id @(re-frame/subscribe [::subs/company])))
|
||||
:client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||
[[:invoices [:id :total :outstanding-balance :invoice-number :date
|
||||
[:vendor [:name :id]]
|
||||
[:expense_accounts [:amount :id :expense_account_id :location
|
||||
@@ -59,7 +59,7 @@
|
||||
(let [state (reagent/atom (or @params {}))
|
||||
visible-checks @(re-frame/subscribe [::visible-checks])
|
||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||
selected-company @(re-frame/subscribe [::subs/company])
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
opc (fn [p]
|
||||
(swap! state merge p)
|
||||
(on-params-change p))]
|
||||
@@ -68,8 +68,8 @@
|
||||
{:keys [invoices start end count total]} @invoice-page
|
||||
visible-checks @(re-frame/subscribe [::visible-checks])
|
||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||
selected-company @(re-frame/subscribe [::subs/company])
|
||||
percentage-size (if selected-company "%50%" "33%")
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "%50%" "33%")
|
||||
]
|
||||
[:div
|
||||
[paginator {:start start :end end :count count :total total
|
||||
@@ -83,7 +83,7 @@
|
||||
(when check-boxes
|
||||
[:th {:style {"width" "20px"}}])
|
||||
|
||||
(when-not selected-company
|
||||
(when-not selected-client
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "client"
|
||||
@@ -149,7 +149,7 @@
|
||||
"")
|
||||
:on-change (fn [x e] (when on-check-changed
|
||||
(on-check-changed id)))} ]])
|
||||
(when-not selected-company
|
||||
(when-not selected-client
|
||||
[:td (:name client)])
|
||||
[:td (:name vendor)]
|
||||
[:td invoice-number]
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
(defn vendor-dialog [{:keys [vendor save-event change-event id] {:keys [name]} :vendor}]
|
||||
(println (s/explain ::entity/vendor vendor) )
|
||||
(let [companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]
|
||||
(let [clients-by-id @(re-frame/subscribe [::subs/clients-by-id])]
|
||||
[action-modal {:id id
|
||||
:title [:span (if (:id vendor)
|
||||
(str "Edit " (or name "<vendor>"))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.utils :refer [active-when= login-url dispatch-event]]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.clients :as clients]
|
||||
[auto-ap.views.pages :as pages]
|
||||
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]))
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
:unpaid-invoices :left-panel
|
||||
:paid-invoices :left-panel
|
||||
:admin :admin-left-panel
|
||||
:admin-companies :admin-left-panel
|
||||
:admin-clients :admin-left-panel
|
||||
:admin-users :admin-left-panel
|
||||
:admin-excel-import :admin-left-panel
|
||||
:admin-vendors :admin-left-panel
|
||||
@@ -52,8 +52,8 @@
|
||||
(defmulti layout page->layout)
|
||||
|
||||
(defmethod layout :admin-left-panel [ap]
|
||||
(let [company (re-frame/subscribe [::subs/company])
|
||||
companies (re-frame/subscribe [::subs/companies])
|
||||
(let [client (re-frame/subscribe [::subs/client])
|
||||
clients (re-frame/subscribe [::subs/clients])
|
||||
menu (re-frame/subscribe [::subs/menu])]
|
||||
|
||||
[:div
|
||||
@@ -82,11 +82,11 @@
|
||||
[:p.menu-label "Setup"]
|
||||
[:ul.menu-list
|
||||
[:li.menu-item
|
||||
[:a {:href (bidi/path-for routes/routes :admin-companies) , :class (str "item" (active-when= ap :admin-companies))}
|
||||
[:a {:href (bidi/path-for routes/routes :admin-clients) , :class (str "item" (active-when= ap :admin-clients))}
|
||||
[:span {:class "icon"}
|
||||
[:i {:class "fa fa-star-o"}]]
|
||||
|
||||
[:span {:class "name"} "Companies"]]]
|
||||
[:span {:class "name"} "Clients"]]]
|
||||
[:li.menu-item
|
||||
[:a {:href (bidi/path-for routes/routes :admin-vendors) , :class (str "item" (active-when= ap :admin-vendors))}
|
||||
[:span {:class "icon"}
|
||||
@@ -129,7 +129,7 @@
|
||||
[:a {:class "button is-danger is-block is-bold" :href (bidi/path-for routes/routes :index)}
|
||||
[:span {:class "compose"} "Back"]]]]]
|
||||
[:div {:class "column messages hero is-fullheight", :id "message-feed"}
|
||||
^{:key (str "active-page-" (:name @company))}
|
||||
^{:key (str "active-page-" (:name @client))}
|
||||
[:div.inbox-messages
|
||||
[pages/active-page ap]]]]
|
||||
[:footer {:class "footer"}
|
||||
@@ -143,8 +143,8 @@
|
||||
[:div#dz-hidden]]))
|
||||
|
||||
(defmethod layout :left-panel [ap]
|
||||
(let [company (re-frame/subscribe [::subs/company])
|
||||
companies (re-frame/subscribe [::subs/companies])
|
||||
(let [client (re-frame/subscribe [::subs/client])
|
||||
clients (re-frame/subscribe [::subs/clients])
|
||||
menu (re-frame/subscribe [::subs/menu])]
|
||||
[:div
|
||||
[:nav {:class "navbar has-shadow"}
|
||||
@@ -153,20 +153,20 @@
|
||||
[:a {:class "navbar-item", :href "../"}
|
||||
[:img {:src "/img/logo.png"}]]]
|
||||
[:div {:id "navMenu", :class "navbar-menu "
|
||||
:on-click (fn [] (re-frame/dispatch [::events/toggle-menu :company]))}
|
||||
:on-click (fn [] (re-frame/dispatch [::events/toggle-menu :client]))}
|
||||
[:div.navbar-start
|
||||
[:div { :class (str "navbar-item has-dropdown " (when (get-in @menu [:company :active?]) "is-active"))}
|
||||
[:a {:class "navbar-link login"} "Company: " (if @company (:name @company)
|
||||
[:div { :class (str "navbar-item has-dropdown " (when (get-in @menu [:client :active?]) "is-active"))}
|
||||
[:a {:class "navbar-link login"} "Client: " (if @client (:name @client)
|
||||
"All")]
|
||||
[:div {:class "navbar-dropdown"}
|
||||
[:a {:class "navbar-item"
|
||||
:on-click (fn [] (re-frame/dispatch [::events/swap-company nil]))
|
||||
:on-click (fn [] (re-frame/dispatch [::events/swap-client nil]))
|
||||
} "All"]
|
||||
[:hr {:class "navbar-divider"}]
|
||||
(for [{:keys [name id] :as company} @companies]
|
||||
(for [{:keys [name id] :as client} @clients]
|
||||
^{:key id }
|
||||
[:a {:class "navbar-item"
|
||||
:on-click (fn [] (re-frame/dispatch [::events/swap-company company]))
|
||||
:on-click (fn [] (re-frame/dispatch [::events/swap-client client]))
|
||||
} name])]]]]
|
||||
[:div {:class "navbar-burger burger", :data-target "navMenu"}
|
||||
[:span]
|
||||
@@ -226,7 +226,7 @@
|
||||
[:span {:class "compose"} "New Vendor"]]]]]
|
||||
|
||||
[:div {:class "column messages hero is-fullheight", :id "message-feed"}
|
||||
^{:key (str "active-page-" (:name @company))}
|
||||
^{:key (str "active-page-" (:name @client))}
|
||||
[:div.inbox-messages
|
||||
[pages/active-page ap]]]]
|
||||
[:footer {:class "footer"}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
[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.companies :refer [admin-companies-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]]
|
||||
@@ -46,8 +46,8 @@
|
||||
(defmethod active-page :check []
|
||||
[check-page])
|
||||
|
||||
(defmethod active-page :admin-companies []
|
||||
[admin-companies-page])
|
||||
(defmethod active-page :admin-clients []
|
||||
[admin-clients-page])
|
||||
|
||||
(defmethod active-page :admin-vendors []
|
||||
[admin-vendors-page])
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
(ns auto-ap.views.pages.admin.companies
|
||||
(ns auto-ap.views.pages.admin.clients
|
||||
(: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.entities.companies :as entity]
|
||||
[auto-ap.entities.clients :as entity]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field]]
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
@@ -14,105 +14,105 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::edit
|
||||
(fn [{:keys [db]} [_ company-id]]
|
||||
{:dispatch [::events/modal-status :auto-ap.views.pages.admin.companies/edit {:visible? true}]
|
||||
:db (assoc-in db [:admin :company]
|
||||
(get (:companies db) company-id))}))
|
||||
(fn [{:keys [db]} [_ client-id]]
|
||||
{:dispatch [::events/modal-status :auto-ap.views.pages.admin.clients/edit {:visible? true}]
|
||||
:db (assoc-in db [:admin :client]
|
||||
(get (:clients db) client-id))}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save
|
||||
(fn [{:keys [db]} _]
|
||||
(let [edited-company (-> (get-in db [:admin :company])
|
||||
(let [edited-client (-> (get-in db [:admin :client])
|
||||
(dissoc :location)
|
||||
(dissoc :new-account))]
|
||||
|
||||
{:db (assoc-in db [:admin :company :saving?] true)
|
||||
{:db (assoc-in db [:admin :client :saving?] true)
|
||||
:http {:method :put
|
||||
:token (:user db)
|
||||
:body (pr-str edited-company)
|
||||
:body (pr-str edited-client)
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/companies/" (:id edited-company))
|
||||
:uri (str "/api/clients/" (:id edited-client))
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save-complete
|
||||
(fn [{:keys [db]} [_ company]]
|
||||
{:dispatch [::events/modal-completed :auto-ap.views.pages.admin.companies/edit]
|
||||
(fn [{:keys [db]} [_ client]]
|
||||
{:dispatch [::events/modal-completed :auto-ap.views.pages.admin.clients/edit]
|
||||
:db (-> db
|
||||
|
||||
(assoc-in [:admin :company] nil)
|
||||
(assoc-in [:companies (:id company)] company))}))
|
||||
(assoc-in [:admin :client] nil)
|
||||
(assoc-in [:clients (:id client)] client))}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::save-error
|
||||
(fn [db [_ company]]
|
||||
(fn [db [_ client]]
|
||||
(-> db
|
||||
(assoc-in [:admin :company :saving?] false)
|
||||
(assoc-in [:admin :company :error] true))))
|
||||
(assoc-in [:admin :client :saving?] false)
|
||||
(assoc-in [:admin :client :error] true))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::change
|
||||
(fn [db [_ path value]]
|
||||
(assoc-in db (concat [:admin :company] path)
|
||||
(assoc-in db (concat [:admin :client] path)
|
||||
value)))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::add-location
|
||||
(fn [{:keys [db]} _]
|
||||
(let [company (:company @(re-frame/subscribe [::subs/admin]))]
|
||||
(let [client (:client @(re-frame/subscribe [::subs/admin]))]
|
||||
{:db (-> db
|
||||
(update-in [:admin :company :locations] conj (:location company))
|
||||
(update-in [:admin :company] dissoc :location))})))
|
||||
(update-in [:admin :client :locations] conj (:location client))
|
||||
(update-in [:admin :client] dissoc :location))})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::add-new-bank-account
|
||||
(fn [{:keys [db]} _]
|
||||
(let [company (:company @(re-frame/subscribe [::subs/admin]))
|
||||
new-bank-account (:new-account company)
|
||||
(let [client (:client @(re-frame/subscribe [::subs/admin]))
|
||||
new-bank-account (:new-account client)
|
||||
new-bank-account (-> new-bank-account
|
||||
(update :check-number #(if (seq %) (js/parseInt %) nil))
|
||||
(update :yodlee-account-id #(if (seq %) (js/parseInt %) nil))
|
||||
(assoc :is-new? true))]
|
||||
{:db (-> db
|
||||
(update-in [:admin :company :new-bank-accounts] (fn [bank-accounts]
|
||||
(update-in [:admin :client :new-bank-accounts] (fn [bank-accounts]
|
||||
(conj bank-accounts new-bank-account)))
|
||||
(update-in [:admin :company] dissoc :new-account))})))
|
||||
(update-in [:admin :client] dissoc :new-account))})))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::remove-new-bank-account
|
||||
(fn [db [_ index]]
|
||||
(update-in db [:admin :company :new-bank-accounts]
|
||||
(update-in db [:admin :client :new-bank-accounts]
|
||||
(fn [bas]
|
||||
(vec (concat (take index bas)
|
||||
(drop (inc index) bas)))))))
|
||||
|
||||
(defn companies-table []
|
||||
(let [companies (re-frame/subscribe [::subs/companies])
|
||||
editing-company (:company @(re-frame/subscribe [::subs/admin]))]
|
||||
(defn clients-table []
|
||||
(let [clients (re-frame/subscribe [::subs/clients])
|
||||
editing-client (:client @(re-frame/subscribe [::subs/admin]))]
|
||||
[:table {:class "table", :style {:width "100%"}}
|
||||
[:thead
|
||||
[:tr
|
||||
[:th "Name"]
|
||||
[:th "Email"]]]
|
||||
[:tbody (for [{:keys [id name email] :as c} @companies]
|
||||
[:tbody (for [{:keys [id name email] :as c} @clients]
|
||||
^{:key (str name "-" id )}
|
||||
[:tr {:on-click (fn [] (re-frame/dispatch [::edit id]))
|
||||
:style {"cursor" "pointer"}}
|
||||
[:td name]
|
||||
[:td email]])]]))
|
||||
|
||||
(defn admin-companies-page []
|
||||
(defn admin-clients-page []
|
||||
[:div
|
||||
(let [companies (re-frame/subscribe [::subs/companies])
|
||||
editing-company (:company @(re-frame/subscribe [::subs/admin]))]
|
||||
(let [clients (re-frame/subscribe [::subs/clients])
|
||||
editing-client (:client @(re-frame/subscribe [::subs/admin]))]
|
||||
|
||||
[:div
|
||||
[:h1.title "Companies"]
|
||||
[companies-table]
|
||||
[:h1.title "Clients"]
|
||||
[clients-table]
|
||||
|
||||
[action-modal {:id ::edit
|
||||
:title (str "Edit " (:name editing-company))
|
||||
:title (str "Edit " (:name editing-client))
|
||||
:action-text "Save"
|
||||
:save-event [::save]}
|
||||
[horizontal-field
|
||||
@@ -123,7 +123,7 @@
|
||||
:field :name
|
||||
:spec ::entity/name
|
||||
:event ::change
|
||||
:subscription editing-company}]]]]
|
||||
:subscription editing-client}]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Email"]
|
||||
@@ -133,7 +133,7 @@
|
||||
:field :email
|
||||
:spec ::entity/name
|
||||
:event ::change
|
||||
:subscription editing-company}]]]]
|
||||
:subscription editing-client}]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Locations"]
|
||||
@@ -144,16 +144,16 @@
|
||||
[:input.input {:type "text"
|
||||
:field :location
|
||||
:event ::change
|
||||
:subscription editing-company}]]]
|
||||
:subscription editing-client}]]]
|
||||
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-location])} "Add"]]]
|
||||
[:ul
|
||||
(for [location (:locations editing-company)]
|
||||
(for [location (:locations editing-client)]
|
||||
^{:key location} [:li location ])]]]
|
||||
[:h2.subtitle "Address"]
|
||||
|
||||
[address-field {:field [:address]
|
||||
:event ::change
|
||||
:subscription editing-company}]
|
||||
:subscription editing-client}]
|
||||
[:h2.subtitle "Add account"]
|
||||
|
||||
[horizontal-field
|
||||
@@ -165,7 +165,7 @@
|
||||
:type "text"
|
||||
:field [:new-account :bank-name]
|
||||
:event ::change
|
||||
:subscription editing-company}]]]
|
||||
:subscription editing-client}]]]
|
||||
[:div.control
|
||||
|
||||
[bind-field
|
||||
@@ -173,7 +173,7 @@
|
||||
:type "text"
|
||||
:field [:new-account :routing]
|
||||
:event ::change
|
||||
:subscription editing-company}]]]
|
||||
:subscription editing-client}]]]
|
||||
[:div.control
|
||||
|
||||
[bind-field
|
||||
@@ -181,7 +181,7 @@
|
||||
:type "text"
|
||||
:field [:new-account :bank-code]
|
||||
:event ::change
|
||||
:subscription editing-company}]]]]
|
||||
:subscription editing-client}]]]]
|
||||
[horizontal-field
|
||||
[:label.label "Account"]
|
||||
[:div.control
|
||||
@@ -190,21 +190,21 @@
|
||||
:type "text"
|
||||
:field [:new-account :name]
|
||||
:event ::change
|
||||
:subscription editing-company}]]]
|
||||
:subscription editing-client}]]]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:placeholder "Acct #"
|
||||
:type "text"
|
||||
:field [:new-account :number]
|
||||
:event ::change
|
||||
:subscription editing-company}]]]
|
||||
:subscription editing-client}]]]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:placeholder "Check #"
|
||||
:type "text"
|
||||
:field [:new-account :check-number]
|
||||
:event ::change
|
||||
:subscription editing-company}]]]]
|
||||
:subscription editing-client}]]]]
|
||||
[horizontal-field
|
||||
[:label.label "Yodlee Account"]
|
||||
[:div.control
|
||||
@@ -213,7 +213,7 @@
|
||||
:type "text"
|
||||
:field [:new-account :yodlee-account-id]
|
||||
:event ::change
|
||||
:subscription editing-company}]]]
|
||||
:subscription editing-client}]]]
|
||||
[:div.control
|
||||
[:button.button.is-primary.is-pulled-right {:on-click (dispatch-event [::add-new-bank-account])} "Add"]]]
|
||||
|
||||
@@ -225,9 +225,9 @@
|
||||
[:div.control
|
||||
[:ul
|
||||
|
||||
(for [{:keys [name number check-number id]} (:bank-accounts editing-company)]
|
||||
(for [{:keys [name number check-number id]} (:bank-accounts editing-client)]
|
||||
^{:key id} [:li name])
|
||||
(for [[index {:keys [name number check-number]}] (map vector (range) (:new-bank-accounts editing-company))]
|
||||
(for [[index {:keys [name number check-number]}] (map vector (range) (:new-bank-accounts editing-client))]
|
||||
^{:key index} [:li [:strong "* " name] [:button.button {:on-click (dispatch-event [::remove-new-bank-account index])} [:span.icon [:i.fa.fa-times]]]])]]]
|
||||
|
||||
(when (:saving? editing-company) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]])])
|
||||
(when (:saving? editing-client) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]])])
|
||||
@@ -4,8 +4,8 @@
|
||||
[reagent.core :as reagent]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as all-events]
|
||||
[auto-ap.events.admin.companies :as events]
|
||||
[auto-ap.entities.companies :as entity]
|
||||
[auto-ap.events.admin.clients :as events]
|
||||
[auto-ap.entities.clients :as entity]
|
||||
|
||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field dispatch-event]]
|
||||
@@ -182,17 +182,17 @@
|
||||
[:thead
|
||||
[:th "Date"]
|
||||
[:th "Invoice #"]
|
||||
[:th "Company"]
|
||||
[:th "Client"]
|
||||
[:th "Vendor"]
|
||||
[:th "Amount"]
|
||||
[:th "Errors"]]
|
||||
|
||||
(for [{:keys [raw-date invoice-number company vendor-name amount] row-errors :errors} (take 100 errors)]
|
||||
^{:key (str raw-date invoice-number company vendor-name amount)}
|
||||
(for [{:keys [raw-date invoice-number client vendor-name amount] row-errors :errors} (take 100 errors)]
|
||||
^{:key (str raw-date invoice-number client vendor-name amount)}
|
||||
[:tr
|
||||
[:td raw-date]
|
||||
[:td invoice-number]
|
||||
[:td company]
|
||||
[:td client]
|
||||
[:td vendor-name]
|
||||
[:td amount]
|
||||
[:td (map (fn [{:keys [info]}] ^{:key info} [:p info]) row-errors)]])]])])])
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[clojure.string :as str]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.entities.companies :as entity]
|
||||
[auto-ap.entities.clients :as entity]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field dispatch-event]]
|
||||
[auto-ap.views.components.modal :refer [modal action-modal]]
|
||||
@@ -55,14 +55,14 @@
|
||||
(dissoc db ::editing))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::add-company
|
||||
::add-client
|
||||
(fn [db [_ d]]
|
||||
(let [company (get @(re-frame/subscribe [::subs/companies-by-id])
|
||||
(get-in db [::editing :adding-company]))]
|
||||
(update-in db [::editing :user :clients] conj company))))
|
||||
(let [client (get @(re-frame/subscribe [::subs/clients-by-id])
|
||||
(get-in db [::editing :adding-client]))]
|
||||
(update-in db [::editing :user :clients] conj client))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::remove-company
|
||||
::remove-client
|
||||
(fn [db [_ d]]
|
||||
(update-in db [::editing :user :clients] #(filter (fn [c] (not= (:id c) d)) %))))
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
(with-meta
|
||||
(fn []
|
||||
[:div
|
||||
(let [companies (re-frame/subscribe [::users])
|
||||
(let [clients (re-frame/subscribe [::users])
|
||||
editing @(re-frame/subscribe [::editing])]
|
||||
[:div
|
||||
[:h1.title "Users"]
|
||||
@@ -160,20 +160,20 @@
|
||||
[:div.select
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:field [:adding-company]
|
||||
:field [:adding-client]
|
||||
:event ::change
|
||||
:subscription editing}
|
||||
[:option]
|
||||
(let [used-companies (set (map :id (:clients (:user editing))))]
|
||||
(for [{:keys [id name]} @(re-frame/subscribe [::subs/companies])
|
||||
:when (not (used-companies id))]
|
||||
(let [used-clients (set (map :id (:clients (:user editing))))]
|
||||
(for [{:keys [id name]} @(re-frame/subscribe [::subs/clients])
|
||||
:when (not (used-clients id))]
|
||||
^{:key id} [:option {:value id} name]))]]]]
|
||||
[:p.control
|
||||
[:button.button.is-primary {:on-click (dispatch-event [::add-company])} "Add"]]]
|
||||
[:button.button.is-primary {:on-click (dispatch-event [::add-client])} "Add"]]]
|
||||
|
||||
[:ul
|
||||
(for [{:keys [id name]} (:clients (:user editing))]
|
||||
^{:key id} [:li name [:a.icon {:on-click (dispatch-event [::remove-company id])} [:i.fa.fa-times ]]])]]])]])])
|
||||
^{:key id} [:li name [:a.icon {:on-click (dispatch-event [::remove-client id])} [:i.fa.fa-times ]]])]]])]])])
|
||||
{:component-will-mount #(re-frame/dispatch-sync [::users-mounted {}]) }))
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
[reagent.core :as reagent]
|
||||
[clojure.string :as str]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events.admin.companies :as events]
|
||||
[auto-ap.entities.companies :as entity]
|
||||
[auto-ap.events.admin.clients :as events]
|
||||
[auto-ap.entities.clients :as entity]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field]]
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
(defn check-page []
|
||||
(let [checks @(re-frame/subscribe [::checks])]
|
||||
[:div
|
||||
(for [{:keys [vendor-name paid-to company check date amount memo]} checks
|
||||
(for [{:keys [vendor-name paid-to client check date amount memo]} checks
|
||||
|
||||
|
||||
:let [amount (gstring/format "--%.2f--" amount)]]
|
||||
[:div
|
||||
[:div.columns
|
||||
(let [{:keys [name address1 city state zip bank]} company]
|
||||
(let [{:keys [name address1 city state zip bank]} client]
|
||||
(list
|
||||
[:div.column.is-4
|
||||
[:p name]
|
||||
@@ -76,7 +76,7 @@
|
||||
[:div.columns
|
||||
[:div.column.is-2 ]
|
||||
[:div.column.is-10 {:style {"font-family" "MICR" "font-size" "20pt"}}
|
||||
(str "c" check "c a" (:acct-number (:bank company)) "a 10302c")]]
|
||||
(str "c" check "c a" (:acct-number (:bank client)) "a 10302c")]]
|
||||
|
||||
|
||||
[:div.columns
|
||||
@@ -94,7 +94,7 @@
|
||||
[:div.columns
|
||||
[:div.column]
|
||||
[:div.column.is-10
|
||||
(let [{:keys [name address1 city state zip bank]} company]
|
||||
(let [{:keys [name address1 city state zip bank]} client]
|
||||
(list
|
||||
[:p name]
|
||||
[:p address1]
|
||||
@@ -154,7 +154,7 @@
|
||||
[:div.column.is-5
|
||||
[:p check]
|
||||
[:p vendor-name]
|
||||
[:p (:name (:bank company))]
|
||||
[:p (:name (:bank client))]
|
||||
[:p paid-to]
|
||||
[:p amount]
|
||||
[:p date]]]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns auto-ap.views.pages.checks
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.clients :as client]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[reagent.core :as reagent]
|
||||
[goog.string :as gstring]
|
||||
@@ -35,7 +35,7 @@
|
||||
(assoc-in [::params] params))
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
:query-obj {:venia/queries [[:payment_page
|
||||
(assoc params :client-id (:id @(re-frame/subscribe [::subs/company])))
|
||||
(assoc params :client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||
[[:payments [:id :status :amount :type :check_number :s3_url :date [:vendor [:name :id]] [:client [:name :id]]]]
|
||||
:total
|
||||
:start
|
||||
@@ -80,15 +80,15 @@
|
||||
|
||||
(defn check-table [{:keys [id payment-page status on-params-change vendors params check-boxes checked on-check-changed expense-event]}]
|
||||
(let [state (reagent/atom (or @params {}))
|
||||
selected-company @(re-frame/subscribe [::subs/company])
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
opc (fn [p]
|
||||
(swap! state merge p)
|
||||
(on-params-change p))]
|
||||
(fn [{:keys [id payment-page status on-params-change vendors checked]}]
|
||||
(let [{:keys [sort-by asc]} @state
|
||||
{:keys [payments start end count total]} @payment-page
|
||||
selected-company @(re-frame/subscribe [::subs/company])
|
||||
percentage-size (if selected-company "50%" "33%")]
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "50%" "33%")]
|
||||
[:div
|
||||
[paginator {:start start :end end :count count :total total
|
||||
:on-change (fn [p ]
|
||||
@@ -100,7 +100,7 @@
|
||||
[:tr
|
||||
|
||||
|
||||
(when-not selected-company
|
||||
(when-not selected-client
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "client"
|
||||
@@ -151,7 +151,7 @@
|
||||
^{:key id}
|
||||
[:tr {:class (:class i)}
|
||||
|
||||
(when-not selected-company
|
||||
(when-not selected-client
|
||||
[:td (:name client)])
|
||||
[:td (:name vendor)]
|
||||
[:td (cond
|
||||
@@ -176,7 +176,7 @@
|
||||
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [current-company @(re-frame/subscribe [::subs/company])]
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])]
|
||||
[:div
|
||||
[:h1.title "Checks"]
|
||||
[check-table {:id :payments
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
[reagent.core :as reagent]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.clients :as client]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||
[cljsjs.dropzone :as dropzone]
|
||||
[cljs.reader :as edn]))
|
||||
(def dropzone
|
||||
(let [company (re-frame/subscribe [::subs/company])
|
||||
(let [client (re-frame/subscribe [::subs/client])
|
||||
token (re-frame/subscribe [::subs/token])]
|
||||
(with-meta
|
||||
(fn []
|
||||
@@ -28,8 +28,8 @@
|
||||
:paramName "file"
|
||||
:headers {"Authorization" (str "Token " @token)}
|
||||
:url (str "/api/invoices/upload"
|
||||
(when-let [company-name (-> @company :id)]
|
||||
(str "?company=" company-name)))
|
||||
(when-let [client-name (-> @client :id)]
|
||||
(str "?client=" client-name)))
|
||||
:previewsContainer "#dz-hidden"
|
||||
:previewTemplate "<div class='dz-hidden-preview'></div>"})))})))
|
||||
|
||||
@@ -72,8 +72,8 @@
|
||||
{:http {:method :post
|
||||
:token (-> cofx :db :user)
|
||||
:uri (str "/api/invoices/reject"
|
||||
(when-let [company-id (:id @(re-frame/subscribe [::subs/company]))]
|
||||
(str "?company=" company-id)))
|
||||
(when-let [client-id (:id @(re-frame/subscribe [::subs/client]))]
|
||||
(str "?client=" client-id)))
|
||||
:on-success on-success
|
||||
}}))
|
||||
|
||||
@@ -83,8 +83,8 @@
|
||||
{:http {:method :post
|
||||
:token (-> cofx :db :user)
|
||||
:uri (str "/api/invoices/approve"
|
||||
(when-let [company-id (:id @(re-frame/subscribe [::subs/company]))]
|
||||
(str "?company=" company-id)))
|
||||
(when-let [client-id (:id @(re-frame/subscribe [::subs/client]))]
|
||||
(str "?client=" client-id)))
|
||||
:on-success on-success
|
||||
}}))
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
[:div.control
|
||||
[:input.input {:type "text"
|
||||
:placeholder "Brown Chicken Brown Cow"
|
||||
:value (:company @form-data)
|
||||
:value (:client @form-data)
|
||||
:on-change (fn [e]
|
||||
(re-frame/dispatch [::events/change-form-state
|
||||
[:new-invoice :company]
|
||||
[:new-invoice :client]
|
||||
(.. e -target -value)]))}]]]
|
||||
[:div.field
|
||||
[:label.label "Invoice #"]
|
||||
@@ -61,7 +61,7 @@
|
||||
(.. e -target -value)]))}]]]
|
||||
[:div.control
|
||||
[:submit.button.is-large.is-primary {
|
||||
:disabled (if (and (:total @form-data) (:date @form-data) (:company @form-data) (:invoice-number @form-data)
|
||||
:disabled (if (and (:total @form-data) (:date @form-data) (:client @form-data) (:invoice-number @form-data)
|
||||
(:vendor @form-data))
|
||||
""
|
||||
"disabled")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns auto-ap.views.pages.paid-invoices
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.clients :as client]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.utils :refer [dispatch-event]]
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [current-company @(re-frame/subscribe [::subs/company])]
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])]
|
||||
[:div
|
||||
[:h1.title "Paid invoices"]
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns auto-ap.views.pages.transactions
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.clients :as client]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[reagent.core :as reagent]
|
||||
[goog.string :as gstring]
|
||||
@@ -33,7 +33,7 @@
|
||||
(assoc-in [::params] params))
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
:query-obj {:venia/queries [[:transaction_page
|
||||
(assoc params :client-id (:id @(re-frame/subscribe [::subs/company])))
|
||||
(assoc params :client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||
[[:transactions [:id
|
||||
:amount
|
||||
:date
|
||||
@@ -68,8 +68,8 @@
|
||||
(fn [{:keys [id transaction-page status on-params-change vendors checked]}]
|
||||
(let [{:keys [sort-by asc]} @state
|
||||
{:keys [transactions start end count total]} @transaction-page
|
||||
selected-company @(re-frame/subscribe [::subs/company])
|
||||
percentage-size (if selected-company "25%" "33%")]
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "25%" "33%")]
|
||||
[:div
|
||||
[paginator {:start start :end end :count count :total total
|
||||
:on-change (fn [p ]
|
||||
@@ -79,7 +79,7 @@
|
||||
[:table.table.is-fullwidth
|
||||
[:thead
|
||||
[:tr
|
||||
(when-not selected-company
|
||||
(when-not selected-client
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "client"
|
||||
@@ -126,7 +126,7 @@
|
||||
^{:key id}
|
||||
[:tr {:class (:class i)}
|
||||
|
||||
(when-not selected-company
|
||||
(when-not selected-client
|
||||
[:td (:name client)])
|
||||
[:td description-original]
|
||||
[:td (date->str date) ]
|
||||
@@ -145,7 +145,7 @@
|
||||
::manual-yodlee-import
|
||||
(fn [{:keys [db]} _]
|
||||
{:dispatch [::events/modal-status ::manual-yodlee-import {:visible? true}]
|
||||
:db (assoc-in db [::manual-yodlee-import] {:company-id (:id @(re-frame/subscribe [::subs/company]))
|
||||
:db (assoc-in db [::manual-yodlee-import] {:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||
:data ""})}))
|
||||
|
||||
(re-frame/reg-sub
|
||||
@@ -201,7 +201,7 @@
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [notification (re-frame/subscribe [::notification])
|
||||
current-company @(re-frame/subscribe [::subs/company])
|
||||
current-client @(re-frame/subscribe [::subs/client])
|
||||
user @(re-frame/subscribe [::subs/user])]
|
||||
|
||||
[:div
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[clojure.spec.alpha :as s]
|
||||
[cljs-time.core :as c]
|
||||
[goog.string :as gstring]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.clients :as client]
|
||||
[auto-ap.entities.invoice :as invoice]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.views.components.expense-accounts-dialog :as expense-accounts-dialog]
|
||||
@@ -105,7 +105,7 @@
|
||||
(-> db
|
||||
(update-in [::invoice-page :print-checks-shown?] #(not %) )
|
||||
(assoc-in [::advanced-print-checks] {:shown? true
|
||||
:bank-account-id (:id (first (:bank-accounts @(re-frame/subscribe [::subs/company]))))
|
||||
:bank-account-id (:id (first (:bank-accounts @(re-frame/subscribe [::subs/clients]))))
|
||||
:invoices (->> invoices
|
||||
(filter (comp checked :id))
|
||||
(map #(assoc % :amount (:outstanding-balance %))))} )))))
|
||||
@@ -122,7 +122,7 @@
|
||||
{:dispatch [::events/modal-status ::handwrite-checks {:visible? true}]
|
||||
:db (-> db
|
||||
(update-in [::invoice-page :print-checks-shown?] #(not %) )
|
||||
(assoc-in [::handwrite-checks] {:bank-account-id (:id (first (:bank-accounts @(re-frame/subscribe [::subs/company]))))
|
||||
(assoc-in [::handwrite-checks] {:bank-account-id (:id (first (:bank-accounts @(re-frame/subscribe [::subs/client]))))
|
||||
:amount (:outstanding-balance invoice)
|
||||
:invoice invoice } ))})))
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
(get-in db [::invoice-page :checked]))
|
||||
bank-account-id
|
||||
type
|
||||
(:company db))
|
||||
(:client db))
|
||||
:on-success [::checks-created]}})))
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@
|
||||
(fn [{:keys [db]} [_ bank-account-id]]
|
||||
(let [invoice-amounts (by :id (comp js/parseFloat :amount) (get-in db [::advanced-print-checks :invoices]))
|
||||
bank-account-id (get-in db [::advanced-print-checks :bank-account-id])
|
||||
type (->> @(re-frame/subscribe [::subs/company])
|
||||
type (->> @(re-frame/subscribe [::subs/client])
|
||||
:bank-accounts
|
||||
(filter #(= bank-account-id (:id %)))
|
||||
first
|
||||
@@ -213,7 +213,7 @@
|
||||
|
||||
:else
|
||||
:check)
|
||||
(:company db))
|
||||
(:client db))
|
||||
|
||||
:on-success [::checks-created]}})))
|
||||
|
||||
@@ -246,9 +246,9 @@
|
||||
::new-invoice
|
||||
(fn [{:keys [db]} _]
|
||||
{:dispatch [::events/modal-status ::new-invoice {:visible? true}]
|
||||
:db (assoc-in db [::new-invoice] {:client-id (:id @(re-frame/subscribe [::subs/company]))
|
||||
:db (assoc-in db [::new-invoice] {:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||
:date (date->str (c/now) standard)
|
||||
:location (first (:locations @(re-frame/subscribe [::subs/company])))})}))
|
||||
:location (first (:locations @(re-frame/subscribe [::subs/client])))})}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::edit-invoice
|
||||
@@ -414,7 +414,7 @@
|
||||
(defn print-checks-modal []
|
||||
(let [{:keys [checked]} @(re-frame/subscribe [::invoice-page])
|
||||
{:keys [shown? invoices printing?] :as advanced-print-checks} @(re-frame/subscribe [::advanced-print-checks])
|
||||
current-company @(re-frame/subscribe [::subs/company])]
|
||||
current-client @(re-frame/subscribe [::subs/client])]
|
||||
|
||||
(when shown?
|
||||
[modal {:title "Print Checks"
|
||||
@@ -439,7 +439,7 @@
|
||||
:field :bank-account-id
|
||||
:event ::edit-payment-bank-account
|
||||
:subscription advanced-print-checks}
|
||||
(for [{:keys [id number name]} (:bank-accounts current-company)]
|
||||
(for [{:keys [id number name]} (:bank-accounts current-client)]
|
||||
^{:key id} [:option {:value id} name])]]]]
|
||||
|
||||
[:table.table.is-fullwidth
|
||||
@@ -471,7 +471,7 @@
|
||||
(let [{:keys [checked]} @(re-frame/subscribe [::invoice-page])
|
||||
{:keys [invoice] :as handwrite-checks} @(re-frame/subscribe [::handwrite-checks])
|
||||
change-event [::events/change-form [::handwrite-checks]]
|
||||
current-company @(re-frame/subscribe [::subs/company])]
|
||||
current-client @(re-frame/subscribe [::subs/client])]
|
||||
|
||||
[action-modal {:id ::handwrite-checks
|
||||
:title "Handwrite Check"
|
||||
@@ -486,7 +486,7 @@
|
||||
:field :bank-account-id
|
||||
:event change-event
|
||||
:subscription handwrite-checks}
|
||||
(for [{:keys [id number name]} (:bank-accounts current-company)]
|
||||
(for [{:keys [id number name]} (:bank-accounts current-client)]
|
||||
^{:key id} [:option {:value id} name])]]]]
|
||||
|
||||
[horizontal-field
|
||||
@@ -521,9 +521,9 @@
|
||||
:subscription handwrite-checks}]]]]))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::change-new-invoice-company
|
||||
::change-new-invoice-client
|
||||
(fn [{:keys [db ]} [_ location field value]]
|
||||
(let [first-location (-> @(re-frame/subscribe [::subs/companies-by-id])
|
||||
(let [first-location (-> @(re-frame/subscribe [::subs/clients-by-id])
|
||||
(get-in [value :locations])
|
||||
first)]
|
||||
{:dispatch [::events/change-form location field value]
|
||||
@@ -533,7 +533,7 @@
|
||||
(defn new-invoice-modal []
|
||||
(let [data @(re-frame/subscribe [::new-invoice])
|
||||
change-event [::events/change-form [::new-invoice]]
|
||||
locations (get-in @(re-frame/subscribe [::subs/companies-by-id]) [(:client-id data) :locations])
|
||||
locations (get-in @(re-frame/subscribe [::subs/clients-by-id]) [(:client-id data) :locations])
|
||||
should-select-location? (and locations
|
||||
(> (count locations) 1))]
|
||||
[action-modal {:id ::new-invoice
|
||||
@@ -542,14 +542,14 @@
|
||||
:save-event [::create-invoice]
|
||||
:can-submit? (s/valid? ::invoice/invoice data)}
|
||||
|
||||
(when-not @(re-frame/subscribe [::subs/company])
|
||||
(when-not @(re-frame/subscribe [::subs/client])
|
||||
[horizontal-field
|
||||
[:label.label "Client"]
|
||||
[bind-field
|
||||
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/companies]))
|
||||
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/clients]))
|
||||
:type "typeahead"
|
||||
:field [:client-id]
|
||||
:event [::change-new-invoice-company [::new-invoice]]
|
||||
:event [::change-new-invoice-client [::new-invoice]]
|
||||
:spec ::invoice/client-id
|
||||
:subscription data}]]])
|
||||
(when should-select-location?
|
||||
@@ -614,7 +614,7 @@
|
||||
(defn edit-invoice-modal []
|
||||
(let [data @(re-frame/subscribe [::edit-invoice])
|
||||
change-event [::events/change-form [::edit-invoice]]
|
||||
locations (get-in @(re-frame/subscribe [::subs/companies-by-id]) [(:company-id data) :locations])
|
||||
locations (get-in @(re-frame/subscribe [::subs/clients-by-id]) [(:client-id data) :locations])
|
||||
min-total (- (:total (:original data)) (:outstanding-balance (:original data)))
|
||||
|
||||
should-select-location? (and locations
|
||||
@@ -670,13 +670,13 @@
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown?]} @(re-frame/subscribe [::invoice-page])
|
||||
current-company @(re-frame/subscribe [::subs/company])
|
||||
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
|
||||
[:button.button.is-danger {:on-click (dispatch-event [::new-invoice])} "New Invoice"]
|
||||
(when current-company
|
||||
(when current-client
|
||||
[:div.dropdown.is-right {:class (if print-checks-shown?
|
||||
"is-active"
|
||||
"")}
|
||||
@@ -696,7 +696,7 @@
|
||||
[:div.dropdown-menu {:role "menu"}
|
||||
[:div.dropdown-content
|
||||
(list
|
||||
(for [{:keys [id number name type]} (:bank-accounts current-company)]
|
||||
(for [{:keys [id number name type]} (:bank-accounts current-client)]
|
||||
(if (= :cash type)
|
||||
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :cash])} "With cash"]
|
||||
(list
|
||||
|
||||
Reference in New Issue
Block a user