starting work on cash flow.
This commit is contained in:
@@ -159,7 +159,6 @@
|
||||
:graphql
|
||||
(fn [{:keys [query on-success on-error token variables query-obj]}]
|
||||
(go
|
||||
(println on-error)
|
||||
(let [headers (if token
|
||||
{"Authorization" (str "Token " token)}
|
||||
{})
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
:query-obj {:venia/queries [[:client
|
||||
|
||||
[:id :name :code :email :matches :weekly-debits :weekly-credits :locations [:location-matches [:location :match]] [:bank-accounts [:id :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations :include-in-reports] ]
|
||||
[:address [:street1 :street2 :city :state :zip]]]]
|
||||
[:address [:street1 :street2 :city :state :zip]]
|
||||
[:forecasted-transactions [:id :amount :identifier :day-of-month]]]]
|
||||
[:vendor
|
||||
[:id :name :hidden [:default-account [:name :id :location]] [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code
|
||||
[:account-overrides [[:client [:id :name]] :id [:account [:id :numeric-code :name]]]]
|
||||
@@ -71,7 +72,10 @@
|
||||
(fn [{:keys [db]} [_ token user]]
|
||||
{:graphql {:token token
|
||||
:query-obj {:venia/queries [[:client
|
||||
[:id :name :code :matches :locations :weekly-debits :weekly-credits [:location-matches [:location :match]] [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations :include-in-reports] ]]]
|
||||
[:id :name :code :matches :locations :weekly-debits :weekly-credits [:location-matches [:location :match]]
|
||||
[:address [:street1 :street2 :city :state :zip]]
|
||||
[:bank-accounts [:id :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations :include-in-reports] ]
|
||||
[:forecasted-transactions [:id :amount :identifier :day-of-month]]]]
|
||||
[:vendor
|
||||
[:id :name :hidden [:default-account [:name :id :location]] [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]
|
||||
[:accounts [:numeric-code :name :location :type :account_set :applicability :id [:client-overrides [:name [:client [:name :id]]]]]]]}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
[:client [:name :id :locations]]
|
||||
[:payments [:amount :id [:payment [:id :status :amount :s3_url :check_number
|
||||
[:transaction [:post_date]]]]]]]]
|
||||
:outstanding
|
||||
:total
|
||||
:start
|
||||
:end]]]})
|
||||
@@ -172,7 +173,7 @@
|
||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
{:keys [sort]} @(re-frame/subscribe [::table-params])
|
||||
{:keys [invoices start end count total]} @invoice-page
|
||||
{:keys [invoices outstanding start end count total]} @invoice-page
|
||||
visible-checks @(re-frame/subscribe [::visible-checks])
|
||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
@@ -200,7 +201,9 @@
|
||||
:on-change opc}]]
|
||||
[:div.level-item
|
||||
[sort-by-list {:sort sort
|
||||
:on-change opc}]]]]
|
||||
:on-change opc}]]
|
||||
[:div.level-item
|
||||
"Outstanding" (nf outstanding)]]]
|
||||
(doall
|
||||
(for [invoices invoice-groups]
|
||||
^{:key (:id (first invoices))}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
[:header.modal-card-head
|
||||
[:p.modal-card-title
|
||||
title]
|
||||
[:button.delete {:on-click (fn [] (re-frame/dispatch hide-event))}]]
|
||||
[:button.delete {:on-click (fn [e] (.preventDefault e) (re-frame/dispatch hide-event))}]]
|
||||
(into [:section.modal-card-body]
|
||||
(r/children (r/current-component)))
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
::save
|
||||
[with-user with-is-admin? (forms/triggers-loading ::vendor-form) (forms/in-form ::vendor-form)]
|
||||
(fn [{:keys [user is-admin?] {{:keys [name hidden print-as terms invoice-reminder-schedule primary-contact secondary-contact address default-account terms-overrides account-overrides id] :as data} :data} :db} _]
|
||||
(println user)
|
||||
(println user is-admin?)
|
||||
(when (s/valid? ::entity/vendor data)
|
||||
{ :graphql
|
||||
{:token user
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout appearing-side-bar side-bar] ]
|
||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field nf]]
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
[cljs.reader :as edn]
|
||||
[auto-ap.routes :as routes]
|
||||
@@ -58,6 +58,12 @@
|
||||
:city (:city (:address new-client-data))
|
||||
:state (:state (:address new-client-data))
|
||||
:zip (:zip (:address new-client-data))}
|
||||
:forecasted-transactions (map (fn [{:keys [id day-of-month identifier amount]}]
|
||||
{:id id
|
||||
:day-of-month day-of-month
|
||||
:identifier identifier
|
||||
:amount amount})
|
||||
(:forecasted-transactions new-client-data))
|
||||
:bank-accounts (map (fn [{:keys [number name check-number include-in-reports type id code bank-name routing bank-code new? sort-order visible yodlee-account-id locations]}]
|
||||
{:number number
|
||||
:name name
|
||||
@@ -101,6 +107,7 @@
|
||||
[:id :name :code :email :locations :matches :weekly-debits :weekly-credits
|
||||
[:location-matches [:location :match]]
|
||||
[:address [:street1 :street2 :city :state :zip]]
|
||||
[:forecasted-transactions [:id :amount :identifier :day-of-month]]
|
||||
[:bank-accounts [:id :number :check-number :name :code :bank-code :bank-name :routing :type :visible :yodlee-account-id :sort-order :locations]]]]}]}
|
||||
:on-success [::save-complete]
|
||||
:on-error [::forms/save-error ::new-client]}}
|
||||
@@ -157,6 +164,28 @@
|
||||
(update :location-matches conj (:location-match client))
|
||||
(dissoc :location-match))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::add-forecasted-transaction
|
||||
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||
(fn [client _]
|
||||
(-> client
|
||||
(update :forecasted-transactions conj (assoc (:new-forecasted-transaction client) :temp-id (random-uuid)))
|
||||
(dissoc :new-forecasted-transaction))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::remove-forecasted-transaction
|
||||
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||
(fn [client [_ which]]
|
||||
|
||||
(-> client
|
||||
(update :forecasted-transactions #(transduce
|
||||
(filter (fn [x] (and (not= (:temp-id x) which)
|
||||
(not= (:id x) which))))
|
||||
|
||||
conj
|
||||
[]
|
||||
%)))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::remove-location-match
|
||||
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||
@@ -506,6 +535,7 @@
|
||||
[:div.column.is-third
|
||||
[:a.button.is-primary.is-outlined.is-fullwidth {:on-click (dispatch-event [::add-new-bank-account :cash])} "Add Cash Account"]]]
|
||||
|
||||
[:h2.subtitle "Cash flow"]
|
||||
[field "Weekly credits"
|
||||
[:input.input {:type "number"
|
||||
:placeholder "250.00"
|
||||
@@ -516,8 +546,42 @@
|
||||
:placeholder "250.00"
|
||||
:field [:weekly-debits]
|
||||
:step "0.01"}]]
|
||||
[:div.field
|
||||
[:label.label "Forecasted transactions"]
|
||||
[:div.control
|
||||
[horizontal-field
|
||||
nil
|
||||
|
||||
[:p.control
|
||||
[:p.help "Identifier"]
|
||||
[raw-field
|
||||
[:input.input {:type "text"
|
||||
:placeholder "Identifier"
|
||||
:field [:new-forecasted-transaction :identifier]}]]]
|
||||
[:p.control
|
||||
[:p.help "Day of month"]
|
||||
[raw-field
|
||||
[:input.input {:type "number"
|
||||
:placeholder "Day of month"
|
||||
:step "1"
|
||||
:field [:new-forecasted-transaction :day-of-month]}]]]
|
||||
[:p.control
|
||||
[:p.help "Amount"]
|
||||
[raw-field
|
||||
[:input.input {:type "number"
|
||||
:placeholder "250.00"
|
||||
:field [:new-forecasted-transaction :amount]
|
||||
:step "0.01"}]]]
|
||||
[:a.button {:on-click (dispatch-event [::add-forecasted-transaction])} "Add"]]]
|
||||
|
||||
[:ul
|
||||
(for [forecasted-transaction (:forecasted-transactions new-client)]
|
||||
^{:key (or (:id forecasted-transaction)
|
||||
(:temp-id forecasted-transaction))}
|
||||
[:li (:identifier forecasted-transaction) ": " (nf (:amount forecasted-transaction)) " on day " (:day-of-month forecasted-transaction) " of the month"
|
||||
[:a {:on-click (dispatch-event [::remove-forecasted-transaction (or (:id forecasted-transaction)
|
||||
(:temp-id forecasted-transaction))])} [:span.icon [:span.fa.fa-times]]]])]]
|
||||
|
||||
|
||||
[error-notification]
|
||||
[submit-button "Save"]]]))
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
[cljs-time.format :as format]
|
||||
[goog.i18n.NumberFormat.Format]
|
||||
[cljs-time.core :as t]
|
||||
[clojure.string :as str])
|
||||
[clojure.string :as str]
|
||||
[goog.crypt.base64 :as base64])
|
||||
(:import
|
||||
(goog.i18n NumberFormat)
|
||||
(goog.i18n.NumberFormat Format)))
|
||||
@@ -327,8 +328,13 @@
|
||||
:before (fn [context]
|
||||
(-> context
|
||||
(assoc-in [:coeffects :is-admin?] (= "admin"
|
||||
(:user/role
|
||||
(get-in context [:coeffects :db :user]))))))))
|
||||
(-> (get-in context [:coeffects :db :user])
|
||||
(str/split #"\.")
|
||||
second
|
||||
(base64/decodeString )
|
||||
(#(.parse js/JSON % ))
|
||||
(js->clj :keywordize-keys true)
|
||||
:user/role)))))))
|
||||
|
||||
(defn query-params []
|
||||
(reduce-kv
|
||||
|
||||
Reference in New Issue
Block a user