huge number of changes to start making all usages of expense accounts dynamic.

This commit is contained in:
Bryce Covert
2019-04-12 15:39:32 -07:00
parent e64820d71a
commit b6e73f0bfb
21 changed files with 103 additions and 181 deletions

View File

@@ -96,7 +96,7 @@
:secondary_contact {:type :contact}
:address {:type :address}
:default_expense_account {:type 'Int}
:default_account {:type :account}
:invoice_reminder_schedule {:type 'String}}}
:reminder
{:fields {:id {:type 'Int}
@@ -196,6 +196,7 @@
:invoices_expense_accounts
{:fields {:id {:type :id}
:invoice_id {:type 'String}
:account {:type :account}
:expense_account_id {:type 'Int}
:location {:type 'String}
:expense_account {:type :expense_account
@@ -250,8 +251,7 @@
:check_result {:fields {:invoices {:type '(list :invoice)}
:pdf_url {:type 'String}}}
:expense_account_stat {:fields {:expense_account_id {:type 'Int}
:expense_account_name {:type 'String}
:expense_account_stat {:fields {:account {:type :account}
:total {:type 'String}}}
:invoice_stat {:fields {:name {:type 'String}
@@ -392,12 +392,12 @@
:secondary_contact {:type :add_contact}
:address {:type :add_address}
:default_expense_account {:type 'Int}
:default_account_id {:type :id}
:invoice_reminder_schedule {:type 'String}}}
:edit_expense_account
{:fields {:id {:type :id}
:expense_account_id {:type 'Int}
:account_id {:type :id}
:location {:type 'String}
:amount {:type 'String}}}
@@ -581,7 +581,7 @@
(:type args))))
(defn get-expense-account-stats [context {:keys [client_id] } value]
(let [result (cond-> {:query {:find ['?expense-account-id '(sum ?amount)]
(let [result (cond-> {:query {:find ['?account '?account-name '(sum ?amount)]
:in ['$]
:where []}
:args [(d/db (d/connect uri)) client_id]}
@@ -592,13 +592,13 @@
true (merge-query {:query {:where ['[?i :invoice/client ?c]
'[?i :invoice/expense-accounts ?expense-account]
'[?expense-account :invoice-expense-account/expense-account-id ?expense-account-id]
'[?expense-account :invoice-expense-account/account ?account]
'[?account :account/name ?account-name]
'[?expense-account :invoice-expense-account/amount ?amount]]}})
true (doto println)
true (d/query ))]
(for [[expense-account-id total] result]
{:expense_account_id expense-account-id :total total :expense_account_name (-> expense-account-id e-expense-accounts/expense-accounts :name)})))
(for [[account-id account-name total] result]
{:account {:id account-id :name account-name} :total total })))
(defn categorize [x]
(cond (<= x 0) :due