starting work on cash flow.
This commit is contained in:
@@ -111,7 +111,7 @@
|
||||
"location" ['[?e :invoice/expense-accounts ?iea]
|
||||
'[?iea :invoice-expense-account/location ?sort-location]]
|
||||
"date" ['[?e :invoice/date ?sort-date]]
|
||||
"due" ['[?e :invoice/due ?sort-due]]
|
||||
"due" ['[(get-else $ ?e :invoice/due #inst "2050-01-01") ?sort-due]]
|
||||
"invoice-number" ['[?e :invoice/invoice-number ?sort-invoice-number]]
|
||||
"total" ['[?e :invoice/total ?sort-total]]
|
||||
"outstanding-balance" ['[?e :invoice/outstanding-balance ?sort-outstanding-balance]]}
|
||||
@@ -134,13 +134,30 @@
|
||||
(mapv <-datomic))]
|
||||
invoices))
|
||||
|
||||
(defn sum-outstanding [ids]
|
||||
|
||||
(->>
|
||||
(d/query {:query {:find ['?o]
|
||||
:in ['$ '[?id ...]]
|
||||
:where ['[?id :invoice/outstanding-balance ?o]]
|
||||
}
|
||||
:args [(d/db (d/connect uri))
|
||||
ids]})
|
||||
(map first)
|
||||
(reduce
|
||||
+
|
||||
0.0)))
|
||||
|
||||
(defn get-graphql [args]
|
||||
(let [db (d/db (d/connect uri))
|
||||
{ids-to-retrieve :ids matching-count :count} (raw-graphql-ids db args)]
|
||||
{ids-to-retrieve :ids matching-count :count} (raw-graphql-ids db args)
|
||||
outstanding (sum-outstanding ids-to-retrieve)]
|
||||
|
||||
|
||||
[(->> (graphql-results ids-to-retrieve db args))
|
||||
matching-count]))
|
||||
matching-count
|
||||
(doto
|
||||
outstanding println)]))
|
||||
|
||||
(defn get-by-id [id]
|
||||
(-> (d/db (d/connect uri))
|
||||
|
||||
@@ -74,7 +74,8 @@
|
||||
:location_matches {:type '(list :location_match)}
|
||||
:locations {:type '(list String)}
|
||||
:matches {:type '(list String)}
|
||||
:bank_accounts {:type '(list :bank_account)}}}
|
||||
:bank_accounts {:type '(list :bank_account)}
|
||||
:forecasted_transactions {:type '(list :forecasted_transaction)}}}
|
||||
:contact
|
||||
{:fields {:id {:type :id}
|
||||
:name {:type 'String}
|
||||
@@ -96,6 +97,10 @@
|
||||
:bank_name {:type 'String}
|
||||
:yodlee_account_id {:type 'Int}
|
||||
:locations {:type '(list String)}}}
|
||||
:forecasted_transaction {:fields {:identifier {:type 'String}
|
||||
:id {:type :id}
|
||||
:day_of_month {:type 'Int}
|
||||
:amount {:type :money}}}
|
||||
:balance_sheet_account
|
||||
{:fields {:id {:type 'String}
|
||||
:amount {:type 'String}
|
||||
@@ -295,6 +300,7 @@
|
||||
|
||||
|
||||
:invoice_page {:fields {:invoices {:type '(list :invoice)}
|
||||
:outstanding {:type :money}
|
||||
:count {:type 'Int}
|
||||
:total {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
@@ -500,7 +506,13 @@
|
||||
:invoice_payment_amount {:fields {:invoice_id {:type :id}
|
||||
:amount {:type 'Float}}}
|
||||
:edit_location_match {:fields {:location {:type 'String}
|
||||
:match {:type 'String}}}
|
||||
:match {:type 'String}}}
|
||||
|
||||
:edit_forecasted_transaction {:fields {:identifier {:type 'String}
|
||||
:id {:type :id}
|
||||
:day_of_month {:type 'Int}
|
||||
:amount {:type :money}}}
|
||||
|
||||
|
||||
:date_range {:fields {:start {:type :iso_date}
|
||||
:end {:type :iso_date}}}
|
||||
@@ -529,7 +541,9 @@
|
||||
:locations {:type '(list String)}
|
||||
:matches {:type '(list String)}
|
||||
:location_matches {:type '(list :edit_location_match)}
|
||||
:bank_accounts {:type '(list :edit_bank_account)}}}
|
||||
:bank_accounts {:type '(list :edit_bank_account)}
|
||||
:forecasted_transactions {:type '(list :edit_forecasted_transaction)}
|
||||
}}
|
||||
:edit_bank_account
|
||||
{:fields {:id {:type :id }
|
||||
:code {:type 'String}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
: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 %)
|
||||
@@ -67,7 +68,14 @@
|
||||
}
|
||||
) (:bank_accounts edit_client))
|
||||
|
||||
})]
|
||||
})
|
||||
[:reset id :client/forecasted-transactions (map #(remove-nils
|
||||
{:db/id (:id %)
|
||||
:forecasted-transaction/day-of-month (:day_of_month %)
|
||||
:forecasted-transaction/identifier (:identifier %)
|
||||
:forecasted-transaction/amount (:amount %)}
|
||||
)
|
||||
(:forecasted_transactions edit_client))]]
|
||||
result @(d/transact (d/connect uri) transactions)]
|
||||
(println result "ID" id)
|
||||
(-> result :tempids (get id) (or id) d-clients/get-by-id
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
(defn get-invoice-page [context args value]
|
||||
|
||||
(let [args (assoc args :id (:id context))
|
||||
[invoices invoice-count] (d-invoices/get-graphql (update (<-graphql (assoc args :id (:id context))) :status enum->keyword "invoice-status"))]
|
||||
[invoices invoice-count outstanding] (d-invoices/get-graphql (update (<-graphql (assoc args :id (:id context))) :status enum->keyword "invoice-status"))]
|
||||
[{:invoices (map ->graphql invoices)
|
||||
:outstanding outstanding
|
||||
:total invoice-count
|
||||
:count (count invoices)
|
||||
:start (:start args 0)
|
||||
|
||||
Reference in New Issue
Block a user