renamed company to client.
This commit is contained in:
@@ -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