weekly debits/credits.
This commit is contained in:
@@ -67,6 +67,8 @@
|
||||
{:fields {:id {:type :id}
|
||||
:name {:type 'String}
|
||||
:code {:type 'String}
|
||||
:weekly_debits {:type :money}
|
||||
:weekly_credits {:type :money}
|
||||
:email {:type 'String}
|
||||
:address {:type :address}
|
||||
:location_matches {:type '(list :location_match)}
|
||||
@@ -520,6 +522,8 @@
|
||||
:name {:type 'String}
|
||||
:code {:type 'String}
|
||||
:email {:type 'String}
|
||||
:weekly_credits {:type :money}
|
||||
:weekly_debits {:type :money}
|
||||
:address {:type :add_address}
|
||||
:locations {:type '(list String)}
|
||||
:matches {:type '(list String)}
|
||||
@@ -900,7 +904,8 @@
|
||||
|
||||
(defn get-cash-flow [context {:keys [client_id]} value]
|
||||
(when client_id
|
||||
(let [total-cash (reduce
|
||||
(let [{:client/keys [weekly-credits weekly-debits ]} (doto (d/pull (d/db (d/connect uri)) '[*] client_id ) println)
|
||||
total-cash (reduce
|
||||
(fn [total [credit debit]]
|
||||
(- (+ total credit)
|
||||
debit))
|
||||
@@ -921,7 +926,7 @@
|
||||
'[?i :invoice/due ?due]
|
||||
'[(<= ?due ?due-before)]
|
||||
'[?i :invoice/outstanding-balance ?outstanding]]}
|
||||
:args [(d/db (d/connect uri)) client_id (coerce/to-date (t/plus (time/local-now) (t/days 7)))]})
|
||||
:args [(d/db (d/connect uri)) client_id (coerce/to-date (t/plus (time/local-now) (t/days 31)))]})
|
||||
outstanding-checks (reduce
|
||||
+
|
||||
0.0
|
||||
@@ -933,21 +938,23 @@
|
||||
'(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 7)))]})))]
|
||||
:args [(d/db (d/connect uri)) client_id (coerce/to-date (t/plus (auto-ap.time/local-now) (t/days 31)))]})))]
|
||||
{: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 [{:amount 350000.23
|
||||
:date (coerce/to-date-time (t/plus (auto-ap.time/local-now) (t/days 0)))}
|
||||
{:amount 105000.23
|
||||
:date (coerce/to-date-time (t/plus (auto-ap.time/local-now) (t/days 3)))}]
|
||||
:upcoming_debits [{:amount -120000.23
|
||||
:date (coerce/to-date-time (t/plus (auto-ap.time/local-now) (t/days 5)))}
|
||||
{:amount -35000.23
|
||||
:date (coerce/to-date-time (t/plus (auto-ap.time/local-now) (t/days 4)))}]})))
|
||||
: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)))})))
|
||||
|
||||
(def schema
|
||||
(-> integreat-schema
|
||||
|
||||
@@ -27,45 +27,47 @@
|
||||
(mapv (fn [lm] [:db/retractEntity (:db/id lm)]) (:client/location-matches client))
|
||||
(mapv (fn [m] [:db/retract (:db/id client) :client/matches m]) (:client/matches client)))))
|
||||
transactions [(remove-nils {:db/id id
|
||||
:client/code (if (str/blank? (:client/code client))
|
||||
(:code edit_client)
|
||||
(:client/code client))
|
||||
:client/name (:name edit_client)
|
||||
:client/code (if (str/blank? (:client/code client))
|
||||
(:code edit_client)
|
||||
(:client/code client))
|
||||
:client/name (:name edit_client)
|
||||
:client/matches (:matches edit_client)
|
||||
:client/email (:email edit_client)
|
||||
:client/locations (filter identity (:locations 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/location-matches (->> (:location_matches edit_client)
|
||||
(filter (fn [lm] (and (:location lm) (:match lm))))
|
||||
(map (fn [lm] {:location-match/location (:location lm)
|
||||
:location-match/matches [(:match lm)]})))
|
||||
:client/address (remove-nils {
|
||||
:address/street1 (:street1 (:address edit_client))
|
||||
:address/street2 (:street2 (:address edit_client))
|
||||
:address/city (:city (:address edit_client))
|
||||
:address/state (:state (:address edit_client))
|
||||
:address/zip (:zip (:address edit_client))})
|
||||
:client/address (remove-nils {
|
||||
:address/street1 (:street1 (:address edit_client))
|
||||
:address/street2 (:street2 (:address edit_client))
|
||||
:address/city (:city (:address edit_client))
|
||||
:address/state (:state (:address edit_client))
|
||||
:address/zip (:zip (:address edit_client))})
|
||||
|
||||
:client/bank-accounts (map #(remove-nils
|
||||
{:db/id (:id %)
|
||||
:bank-account/code (:code %)
|
||||
:bank-account/bank-name (:bank_name %)
|
||||
:bank-account/bank-code (:bank_code %)
|
||||
:bank-account/routing (:routing %)
|
||||
:bank-account/include-in-reports (:include_in_reports %)
|
||||
:client/bank-accounts (map #(remove-nils
|
||||
{:db/id (:id %)
|
||||
:bank-account/code (:code %)
|
||||
:bank-account/bank-name (:bank_name %)
|
||||
:bank-account/bank-code (:bank_code %)
|
||||
:bank-account/routing (:routing %)
|
||||
:bank-account/include-in-reports (:include_in_reports %)
|
||||
|
||||
:bank-account/name (:name %)
|
||||
:bank-account/visible (:visible %)
|
||||
:bank-account/number (:number %)
|
||||
:bank-account/check-number (:check_number %)
|
||||
:bank-account/sort-order (:sort_order %)
|
||||
:bank-account/locations (:locations %)
|
||||
:bank-account/name (:name %)
|
||||
:bank-account/visible (:visible %)
|
||||
:bank-account/number (:number %)
|
||||
:bank-account/check-number (:check_number %)
|
||||
:bank-account/sort-order (:sort_order %)
|
||||
:bank-account/locations (:locations %)
|
||||
|
||||
:bank-account/yodlee-account-id (:yodlee_account_id %)
|
||||
:bank-account/type (keyword "bank-account-type" (name (:type %)))
|
||||
}
|
||||
) (:bank_accounts edit_client))
|
||||
:bank-account/yodlee-account-id (:yodlee_account_id %)
|
||||
:bank-account/type (keyword "bank-account-type" (name (:type %)))
|
||||
}
|
||||
) (:bank_accounts edit_client))
|
||||
|
||||
})]
|
||||
})]
|
||||
result @(d/transact (d/connect uri) transactions)]
|
||||
(println result "ID" id)
|
||||
(-> result :tempids (get id) (or id) d-clients/get-by-id
|
||||
|
||||
@@ -68,7 +68,8 @@
|
||||
(into {} (map vector header row))))
|
||||
(map (fn [row]
|
||||
{:vendor-code nil
|
||||
:customer-identifier (get row "Ship-To Name")
|
||||
:customer-identifier (str (get row "Ship-To Name") " " (or (get row "Ship-To Number")
|
||||
(get row "\"Ship-To Number\"")))
|
||||
:invoice-number (str/trim (get row "Invoice Number"))
|
||||
:date (parse-date-fallover (get row "Invoice Date") ["yyyy-MM-dd"])
|
||||
:total (str/replace (get row "Original Amount") #"[,\$]" "")
|
||||
@@ -81,7 +82,6 @@
|
||||
|
||||
(defmethod parse-csv :mama-lus
|
||||
[rows]
|
||||
(println "MAMA LU4")
|
||||
(transduce
|
||||
(comp (drop 1)
|
||||
(map (fn [[_ po-number despatch-number invoice-number invoice-date customer value :as row]]
|
||||
|
||||
@@ -20,3 +20,11 @@
|
||||
(f/unparse (f/formatter format) v)
|
||||
(catch Exception e
|
||||
nil)))
|
||||
|
||||
|
||||
(defn day-of-week-seq [day]
|
||||
(let [next-day (loop [d (auto-ap.time/local-now)]
|
||||
(if (= (time/day-of-week d) day)
|
||||
d
|
||||
(recur (time/plus d (time/days 1)))))]
|
||||
(iterate #(time/plus % (time/days 7)) next-day)))
|
||||
|
||||
Reference in New Issue
Block a user