lots of new fixes.

This commit is contained in:
Bryce Covert
2020-06-19 10:05:55 -07:00
parent ef843ac9a2
commit d4559a7c2d
23 changed files with 451 additions and 56 deletions

View File

@@ -208,11 +208,14 @@
:yodlee_id {:type 'String}
:name {:type 'String}}}
:forecast_match {:fields {:id {:type :id}
:identifier {:type 'String}}}
:transaction {:fields {:id {:type :id}
:amount {:type 'String}
:description_original {:type 'String}
:description_simple {:type 'String}
:location {:type 'String}
:forecast_match {:type :forecast_match}
:status {:type 'String}
:yodlee_merchant {:type :yodlee_merchant}
:client {:type :client}
@@ -355,6 +358,7 @@
}}
:upcoming_transaction {:fields {:amount {:type :money}
:identifier {:type 'String}
:date {:type :iso_date}}}
:cash_flow_result {:fields {:beginning_balance {:type :money}
@@ -633,6 +637,7 @@
:edit_transaction
{:fields {:id {:type :id}
:vendor_id {:type :id}
:forecast_match {:type :id}
:approval_status {:type :transaction_approval_status}
:accounts {:type '(list :edit_expense_account)}}}
@@ -919,7 +924,7 @@
(defn get-cash-flow [context {:keys [client_id]} value]
(when client_id
(let [{:client/keys [weekly-credits weekly-debits ]} (d/pull (d/db (d/connect uri)) '[*] client_id )
(let [{:client/keys [weekly-credits weekly-debits forecasted-transactions ]} (d/pull (d/db (d/connect uri)) '[*] client_id )
total-cash (reduce
(fn [total [credit debit]]
(- (+ total credit)
@@ -953,23 +958,35 @@
'(or
[?p :payment/type :payment-type/debit]
[?p :payment/type :payment-type/check])]}
:args [(d/db (d/connect uri)) client_id (coerce/to-date (t/plus (auto-ap.time/local-now) (t/days 31)))]})))]
:args [(d/db (d/connect uri)) client_id (coerce/to-date (t/plus (time/local-now) (t/days 31)))]})))
forecasted-transactions (->> forecasted-transactions
(filter (fn [{:forecasted-transaction/keys [day-of-month]}]
(>= day-of-month (t/day (time/local-now)))))
(mapv (fn [{:forecasted-transaction/keys [amount identifier day-of-month]}]
{:identifier identifier
:amount amount
:date (coerce/to-date-time (t/local-date (t/year (time/local-now)) (t/month (time/local-now)) day-of-month ))}
)))]
{:beginning_balance total-cash
:outstanding_payments outstanding-checks
:invoices_due_soon (mapv (fn [[due outstanding]]
{:due (coerce/to-date-time due)
:outstanding_balance outstanding})
bills-due-soon)
:upcoming_credits (mapv
(fn [date]
{:amount (or weekly-credits 0)
:date (coerce/to-date-time date)})
(take 5 (auto-ap.time/day-of-week-seq 1)))
:upcoming_debits (mapv
(fn [date]
{:amount (- (or weekly-debits 0))
:date (coerce/to-date-time date)})
(take 5 (auto-ap.time/day-of-week-seq 1)))})))
:upcoming_credits (into (mapv
(fn [date]
{:amount (or weekly-credits 0)
:date (coerce/to-date-time date)})
(take 5 (time/day-of-week-seq 1)))
(filter #(>= (:amount %) 0) forecasted-transactions))
:upcoming_debits (doto (into (mapv
(fn [date]
{:amount (- (or weekly-debits 0))
:date (coerce/to-date-time date)})
(take 5 (time/day-of-week-seq 1)))
(filter #(< (:amount %) 0) forecasted-transactions))
println)
})))
(def schema
(-> integreat-schema