weekly debits/credits.

This commit is contained in:
Bryce Covert
2020-05-30 11:49:21 -07:00
parent 3101dd1fe6
commit bb2df01d89
9 changed files with 140 additions and 56 deletions

View File

@@ -44,7 +44,7 @@
:graphql {:token token
:query-obj {:venia/queries [[:client
[:id :name :code :email :matches :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] ]
[: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]]]]
[: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
@@ -71,7 +71,7 @@
(fn [{:keys [db]} [_ token user]]
{:graphql {:token token
:query-obj {:venia/queries [[:client
[:id :name :code :matches :locations [: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] ]]]
[: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]]]]]]]}

View File

@@ -1,6 +1,9 @@
(ns auto-ap.views.components.invoice-table
(:require [re-frame.core :as re-frame]
[bidi.bidi :as bidi]
[cemerick.url :as url]
[auto-ap.subs :as subs]
[auto-ap.routes :as routes]
[auto-ap.views.utils :refer [date->str dispatch-event delayed-dispatch nf]]
[auto-ap.views.components.paginator :refer [paginator]]
[auto-ap.views.components.sort-by-list :refer [sort-by-list]]
@@ -145,9 +148,11 @@
} "Payments"]}
[:div
(for [payment payments]
(if (:s3-url (:payment payment))
(if (:check-number (:payment payment))
^{:key (:id payment)}
[:a.dropdown-item {:href (:s3-url (:payment payment))
[:a.dropdown-item {:href (str (bidi/path-for routes/routes :payments )
"?"
(url/map->query {:check-number-like (:check-number (:payment payment))}))
:target "_new"}
[:i.fa.fa-money-check]
[:span.icon [:i.fa.fa-money]]

View File

@@ -44,7 +44,8 @@
:email (:email new-client-data)
:locations (:locations new-client-data)
:matches (vec (:matches new-client-data))
:location-matches (:location-matches new-client-data)
:location-matches (:location-matches new-client-data) :weekly-credits (:weekly-credits new-client-data)
:weekly-debits (:weekly-debits new-client-data)
:address {:street1 (:street1 (:address new-client-data))
:street2 (:street2 (:address new-client-data)),
:city (:city (:address new-client-data))
@@ -90,7 +91,10 @@
:operation/name "EditClient"}
:venia/queries [{:query/data [:edit-client
{:edit-client new-client-req}
[:id :name :code :email :locations :matches [:location-matches [:location :match]] [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :code :bank-code :bank-name :routing :type :visible :yodlee-account-id :sort-order :locations]]]]}]}
[:id :name :code :email :locations :matches :weekly-debits :weekly-credits
[:location-matches [:location :match]]
[:address [:street1 :street2 :city :state :zip]]
[: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]}}
{:db new-client-form}))))
@@ -556,6 +560,27 @@
#_(when (:saving? new-client) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])
#_(println (s/explain-data ::entity/client new-client))
[:div.field
[:p.help "Weekly credits"]
[:div.control
[bind-field
[:input.input {:type "number"
:placeholder "250.00"
:field [:weekly-credits]
:step "0.01"
:event change-event
:subscription new-client}]]]]
[:div.field
[:p.help "Weekly debits"]
[:div.control
[bind-field
[:input.input {:type "number"
:placeholder "250.00"
:field [:weekly-debits]
:step "0.01"
:event change-event
:subscription new-client}]]]]
(when error
[:div.notification.is-warning.animated.fadeInUp
error])

View File

@@ -5,9 +5,10 @@
[auto-ap.routes :as routes]
[auto-ap.subs :as subs]
[cljs-time.core :as t]
[auto-ap.views.utils :refer [local-now date->str standard]]
[auto-ap.views.utils :refer [local-now date->str standard dispatch-event]]
[reagent.core :as r]
[pushy.core :as pushy]))
[pushy.core :as pushy]
))
(def pie-chart (r/adapt-react-class js/Recharts.PieChart))
@@ -91,11 +92,22 @@
(seq cash-flow)
(assoc ::cash-flow cash-flow)))))
(re-frame/reg-event-db
::select-cash-flow-range
[(re-frame/path ::chart-options)]
(fn [chart-options [_ which]]
(assoc chart-options :cash-flow-range which)))
(re-frame/reg-sub
::invoice-stats
(fn [db]
(::invoice-stats db)))
(re-frame/reg-sub
::chart-options
(fn [db]
(merge {:cash-flow-range :seven-days} (::chart-options db))))
(re-frame/reg-sub
::top-expense-categories
(fn [db]
@@ -113,9 +125,16 @@
pairs))
(re-frame/reg-sub
::cash-flow
::cash-flow-data
(fn [db]
(let [{:keys [outstanding-payments beginning-balance invoices-due-soon upcoming-credits upcoming-debits]} (::cash-flow db)
(::cash-flow db)))
(re-frame/reg-sub
::cash-flow
:<- [::chart-options]
:<- [::cash-flow-data]
(fn [[chart-options cash-flow-data]]
(let [{:keys [outstanding-payments beginning-balance invoices-due-soon upcoming-credits upcoming-debits]} cash-flow-data
invoices-due-soon (sum-by-date (map (fn [i] [(:due i) (:outstanding-balance i)]) invoices-due-soon))
upcoming-credits (sum-by-date (map (fn [i] [(:date i) (:amount i)]) upcoming-credits))
upcoming-debits (sum-by-date (map (fn [i] [(:date i) (:amount i)]) upcoming-debits))
@@ -148,7 +167,9 @@
:debits (upcoming-debits (date->str start-date) 0.0)
:outstanding-payments (- outstanding-payments)
:query-params (cemerick.url/map->query {:due-range {:end (date->str start-date standard)}})})
(range 1 7))))))
(if (= :seven-days (:cash-flow-range chart-options))
(range 1 7)
(range 1 31)))))))
(re-frame/reg-event-fx
::mounted
@@ -171,7 +192,8 @@
:on-success [::received]}}))
(defn home-content []
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)]
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)
chart-options @(re-frame/subscribe [::chart-options])]
^{:key client-id}
[side-bar-layout {:side-bar [:div]
:main [:div [:h1.title "Home"]
@@ -184,6 +206,17 @@
@(re-frame/subscribe [::invoice-stats]))})
[:h1.title.is-4 "Cash Flow"]
[:div.buttons.has-addons
[:a.button {:class (when (= :seven-days (:cash-flow-range chart-options))
["is-info" "is-selected"])
:on-click (dispatch-event [::select-cash-flow-range :seven-days])}
"7 days"]
[:a.button {:class (when (= :thirty-days (:cash-flow-range chart-options))
["is-info" "is-selected"])
:on-click (dispatch-event [::select-cash-flow-range :thirty-days])}
"30 days"]]
(make-cash-flow-chart {:width 800 :height 500
:data (clj->js @(re-frame/subscribe [::cash-flow]))})]}]))