Moved to biweekly
This commit is contained in:
@@ -282,7 +282,24 @@
|
||||
:auto-ap/add-forecasted-transaction-match {:txes [[{:db/ident :transaction/forecast-match
|
||||
:db/doc "Which forecast this transaction matches, for cashflow"
|
||||
:db/valueType :db.type/ref
|
||||
:db/cardinality :db.cardinality/one}]]}}
|
||||
:db/cardinality :db.cardinality/one}]]}
|
||||
:auto-ap/add-week-a-and-b {:txes [[{:db/ident :client/week-a-debits
|
||||
:db/doc "How much money gets debited each week"
|
||||
:db/valueType :db.type/double
|
||||
:db/cardinality :db.cardinality/one}
|
||||
{:db/ident :client/week-a-credits
|
||||
:db/doc "How much money gets credited each week"
|
||||
:db/valueType :db.type/double
|
||||
:db/cardinality :db.cardinality/one}
|
||||
|
||||
{:db/ident :client/week-b-debits
|
||||
:db/doc "How much money gets debited each week"
|
||||
:db/valueType :db.type/double
|
||||
:db/cardinality :db.cardinality/one}
|
||||
{:db/ident :client/week-b-credits
|
||||
:db/doc "How much money gets credited each week"
|
||||
:db/valueType :db.type/double
|
||||
:db/cardinality :db.cardinality/one}]]}}
|
||||
]
|
||||
(println "Conforming database...")
|
||||
(c/ensure-conforms conn norms-map)
|
||||
|
||||
@@ -67,8 +67,10 @@
|
||||
{:fields {:id {:type :id}
|
||||
:name {:type 'String}
|
||||
:code {:type 'String}
|
||||
:weekly_debits {:type :money}
|
||||
:weekly_credits {:type :money}
|
||||
:week_a_debits {:type :money}
|
||||
:week_a_credits {:type :money}
|
||||
:week_b_debits {:type :money}
|
||||
:week_b_credits {:type :money}
|
||||
:email {:type 'String}
|
||||
:address {:type :address}
|
||||
:location_matches {:type '(list :location_match)}
|
||||
@@ -539,8 +541,10 @@
|
||||
:name {:type 'String}
|
||||
:code {:type 'String}
|
||||
:email {:type 'String}
|
||||
:weekly_credits {:type :money}
|
||||
:weekly_debits {:type :money}
|
||||
:week_a_credits {:type :money}
|
||||
:week_a_debits {:type :money}
|
||||
:week_b_credits {:type :money}
|
||||
:week_b_debits {:type :money}
|
||||
:address {:type :add_address}
|
||||
:locations {:type '(list String)}
|
||||
:matches {:type '(list String)}
|
||||
@@ -933,12 +937,13 @@
|
||||
(<= (t/in-days (apply t/interval (sort [date potential-date]))) 10)))))
|
||||
conj
|
||||
[]
|
||||
recent-fulfillments))
|
||||
)
|
||||
recent-fulfillments)))
|
||||
|
||||
(def first-week-a (coerce/to-date-time #inst "1999-12-27T00:00:00.000-07:00"))
|
||||
|
||||
(defn get-cash-flow [context {:keys [client_id]} value]
|
||||
(when client_id
|
||||
(let [{:client/keys [weekly-credits weekly-debits forecasted-transactions ]} (d/pull (d/db (d/connect uri)) '[*] client_id )
|
||||
(let [{:client/keys [week-a-credits week-a-debits week-b-credits week-b-debits forecasted-transactions ]} (d/pull (d/db (d/connect uri)) '[*] client_id )
|
||||
total-cash (reduce
|
||||
(fn [total [credit debit]]
|
||||
(- (+ total credit)
|
||||
@@ -990,8 +995,11 @@
|
||||
:when (not (has-fulfilled? id next recent-fulfillments))]
|
||||
{:identifier identifier
|
||||
:amount amount
|
||||
:date (coerce/to-date-time next)})]
|
||||
(println "RECENT" forecasted-transactions)
|
||||
:date (coerce/to-date-time next)})
|
||||
is-week-a? (fn [d]
|
||||
(println d)
|
||||
(= 0 (mod (t/in-weeks (t/interval first-week-a d)) 2)))]
|
||||
|
||||
{:beginning_balance total-cash
|
||||
:outstanding_payments outstanding-checks
|
||||
:invoices_due_soon (mapv (fn [[due outstanding]]
|
||||
@@ -1000,13 +1008,17 @@
|
||||
bills-due-soon)
|
||||
:upcoming_credits (into (mapv
|
||||
(fn [date]
|
||||
{:amount (or weekly-credits 0)
|
||||
{:amount (if (is-week-a? (coerce/to-date-time date))
|
||||
(or week-a-credits 0)
|
||||
(or week-b-credits 0))
|
||||
:date (coerce/to-date-time date)})
|
||||
(take 5 (time/day-of-week-seq 1)))
|
||||
(filter #(>= (:amount %) 0) forecasted-transactions))
|
||||
:upcoming_debits (into (mapv
|
||||
(fn [date]
|
||||
{:amount (- (or weekly-debits 0))
|
||||
{:amount (- (if (is-week-a? (coerce/to-date-time date))
|
||||
(or week-a-debits 0)
|
||||
(or week-b-debits 0)))
|
||||
:date (coerce/to-date-time date)})
|
||||
(take 5 (time/day-of-week-seq 1)))
|
||||
(filter #(< (:amount %) 0) forecasted-transactions))
|
||||
|
||||
@@ -34,8 +34,10 @@
|
||||
:client/matches (:matches edit_client)
|
||||
:client/email (:email edit_client)
|
||||
:client/locations (filter identity (:locations edit_client))
|
||||
:client/weekly-debits (:weekly_debits edit_client)
|
||||
:client/weekly-credits (:weekly_credits edit_client)
|
||||
:client/week-a-debits (:week_a_debits edit_client)
|
||||
:client/week-a-credits (:week_a_credits edit_client)
|
||||
:client/week-b-debits (:week_b_debits edit_client)
|
||||
:client/week-b-credits (:week_b_credits edit_client)
|
||||
:client/location-matches (->> (:location_matches edit_client)
|
||||
(filter (fn [lm] (and (:location lm) (:match lm))))
|
||||
(map (fn [lm] {:location-match/location (:location lm)
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
(let [jwt (jwt/sign (doto {:user (:name profile)
|
||||
:exp (time/plus (time/now) (time/days 30))
|
||||
:user/clients (map (fn [c]
|
||||
(dissoc c :client/bank-accounts :client/location-matches :client/forecasted-transactions :client/matches :client/weekly-debits :client/weekly-credits :client/signature-file :client/address))
|
||||
(dissoc c :client/bank-accounts :client/location-matches :client/forecasted-transactions :client/matches :client/week-a-debits :client/week-a-credits :client/week-b-debits :client/week-b-credits :client/signature-file :client/address))
|
||||
(:user/clients user))
|
||||
:user/role (name (:user/role user))
|
||||
:user/name (:name profile)}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
:graphql {:token token
|
||||
: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] ]
|
||||
[:id :name :code :email :matches :week-a-debits :week-a-credits :week-b-debits :week-b-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]]
|
||||
[:forecasted-transactions [:id :amount :identifier :day-of-month]]]]
|
||||
[:vendor
|
||||
@@ -72,7 +72,7 @@
|
||||
(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]]
|
||||
[:id :name :code :matches :locations :week-a-debits :week-a-credits :week-b-debits :week-b-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]]]]
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
[reagent.core :as reagent]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.string :as str]
|
||||
[cljs-time.core :as t]
|
||||
[cljs-time.coerce :as coerce]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.events :as events]
|
||||
@@ -51,8 +53,11 @@
|
||||
:email (:email new-client-data)
|
||||
:locations (:locations new-client-data)
|
||||
:matches (vec (: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)
|
||||
:location-matches (:location-matches new-client-data)
|
||||
:week-a-credits (:week-a-credits new-client-data)
|
||||
:week-a-debits (:week-a-debits new-client-data)
|
||||
:week-b-credits (:week-b-credits new-client-data)
|
||||
:week-b-debits (:week-b-debits new-client-data)
|
||||
:address {:street1 (:street1 (:address new-client-data))
|
||||
:street2 (:street2 (:address new-client-data)),
|
||||
:city (:city (:address new-client-data))
|
||||
@@ -104,7 +109,7 @@
|
||||
:operation/name "EditClient"}
|
||||
:venia/queries [{:query/data [:edit-client
|
||||
{:edit-client new-client-req}
|
||||
[:id :name :code :email :locations :matches :weekly-debits :weekly-credits
|
||||
[:id :name :code :email :locations :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits
|
||||
[:location-matches [:location :match]]
|
||||
[:address [:street1 :street2 :city :state :zip]]
|
||||
[:forecasted-transactions [:id :amount :identifier :day-of-month]]
|
||||
@@ -434,10 +439,20 @@
|
||||
)
|
||||
|
||||
|
||||
(def first-week-a (coerce/to-date-time #inst "1999-12-27T00:00:00.000-07:00"))
|
||||
|
||||
(defn is-week-a? [d]
|
||||
(= 0 (mod (t/in-weeks (t/interval first-week-a d)) 2)))
|
||||
|
||||
(defn new-client-form []
|
||||
(let [{new-client :data } @(re-frame/subscribe [::forms/form ::form])
|
||||
{:keys [form field raw-field error-notification submit-button ]} client-form]
|
||||
{:keys [form field raw-field error-notification submit-button ]} client-form
|
||||
next-week-a (if (is-week-a? (t/now))
|
||||
"This week"
|
||||
"Next week")
|
||||
next-week-b (if (is-week-a? (t/now))
|
||||
"Next week"
|
||||
"This week")]
|
||||
|
||||
[side-bar {:on-close (dispatch-event [::forms/form-closing ::form ])}
|
||||
[form {:title "Add client"}
|
||||
@@ -536,15 +551,27 @@
|
||||
[: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"
|
||||
[:label.label (str "Week A (" next-week-a ")")]
|
||||
[field "Regular Credits"
|
||||
[:input.input {:type "number"
|
||||
:placeholder "250.00"
|
||||
:field [:weekly-credits]
|
||||
:placeholder "500.00"
|
||||
:field [:week-a-credits]
|
||||
:step "0.01"}]]
|
||||
[field "Weekly debits"
|
||||
[field "Regular Debits"
|
||||
[:input.input {:type "number"
|
||||
:placeholder "150.00"
|
||||
:field [:week-a-debits]
|
||||
:step "0.01"}]]
|
||||
[:label.label (str "Week B (" next-week-b ")")]
|
||||
[field "Regular Credits"
|
||||
[:input.input {:type "number"
|
||||
:placeholder "1000.00"
|
||||
:field [:week-b-credits]
|
||||
:step "0.01"}]]
|
||||
[field "Regular Debits"
|
||||
[:input.input {:type "number"
|
||||
:placeholder "250.00"
|
||||
:field [:weekly-debits]
|
||||
:field [:week-b-debits]
|
||||
:step "0.01"}]]
|
||||
[:div.field
|
||||
[:label.label "Forecasted transactions"]
|
||||
|
||||
Reference in New Issue
Block a user