made the profit and loss report work correctly.
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
:balance_sheet_account
|
||||
{:fields {:id {:type 'String}
|
||||
:amount {:type 'String}
|
||||
:location {:type 'String}
|
||||
:numeric_code {:type 'Int}
|
||||
:account_type {:type :account_type}
|
||||
:name {:type 'String}}}
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
{:name (str (or (:bank-account/name account) (:account/name account)) (when-not (#{"A" } location)
|
||||
(str
|
||||
"-" location)))
|
||||
:location location
|
||||
:id (str (:db/id account) "-" location)
|
||||
:numeric-code (or (:account/numeric-code account)
|
||||
(and (:bank-account/type account)
|
||||
@@ -106,39 +107,11 @@
|
||||
|
||||
starting-accounts (roll-up starting-results)
|
||||
ending-accounts (roll-up ending-results)
|
||||
|
||||
|
||||
accounts (reduce-kv
|
||||
(fn [result account line-item]
|
||||
(update-in result [(cond
|
||||
(expense-account? account)
|
||||
"Expenses"
|
||||
|
||||
(credit-account? account)
|
||||
"Liabilities"
|
||||
(debit-account? account)
|
||||
"Assets")
|
||||
|
||||
(if (credit-account? account)
|
||||
"Accounts Payable"
|
||||
"1100 Cash and Bank Accounts" )
|
||||
]
|
||||
conj
|
||||
(update line-item :amount #(- % (:amount (starting-accounts account 0) 0)) )
|
||||
))
|
||||
{}
|
||||
ending-accounts)
|
||||
]
|
||||
pnl starting-accounts
|
||||
comparable-pnl ending-accounts]
|
||||
(->graphql
|
||||
{:balance-sheet-groupings
|
||||
(-> []
|
||||
|
||||
(into (->> (get accounts "Expenses")
|
||||
(map (fn [[n accounts]]
|
||||
{:name n
|
||||
:grouping-type "Expenses"
|
||||
:accounts accounts}
|
||||
)))))})))
|
||||
{:balance-sheet-accounts pnl
|
||||
:comparable-balance-sheet-accounts comparable-pnl})))
|
||||
|
||||
#_(get-profit-and-loss nil {:client_id [:client/code "CBC"]
|
||||
:from_date "2018-01-01"
|
||||
|
||||
Reference in New Issue
Block a user