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)}
|
||||
|
||||
Reference in New Issue
Block a user