remove excluded from ledger.

This commit is contained in:
Bryce Covert
2019-05-19 08:06:21 -07:00
parent 9396bbb7eb
commit cf2319b681
19 changed files with 3508 additions and 144 deletions

View File

@@ -397,6 +397,7 @@
{:db/ident :transaction-approval-status/approved}
{:db/ident :transaction-approval-status/unapproved}
{:db/ident :transaction-approval-status/requires-feedback}
{:db/ident :transaction-approval-status/excluded}
]])
(def add-credit-bank-account

View File

@@ -66,6 +66,11 @@
'[(<= ?date ?end-date)]]}
:args [(coerce/to-date (:end (:date-range args)))]})
(:approval-status args)
(merge-query {:query {:in ['?approval-status]
:where ['[?e :transaction/approval-status ?approval-status]]}
:args [(:approval-status args)]})
(:client-code args)
(merge-query {:query {:in ['?client-code]
:where ['[?e :transaction/client ?client-id]

View File

@@ -180,7 +180,6 @@
:description_original {:type 'String}
:description_simple {:type 'String}
:location {:type 'String}
:exclude_from_ledger {:type 'Boolean}
:status {:type 'String}
:yodlee_merchant {:type :yodlee_merchant}
:client {:type :client}
@@ -387,7 +386,8 @@
:date_range {:type :date_range}
:start {:type 'Int}
:sort_by {:type 'String}
:asc {:type 'Boolean}}
:asc {:type 'Boolean}
:approval_status {:type :transaction_approval_status}}
:resolve :get-transaction-page}
@@ -528,7 +528,6 @@
:total {:type 'Float}}}
:edit_transaction
{:fields {:id {:type :id}
:exclude_from_ledger {:type 'Boolean}
:vendor_id {:type :id}
:approval_status {:type :transaction_approval_status}
:accounts {:type '(list :edit_expense_account)}}}
@@ -576,7 +575,8 @@
{:enum-value :revenue}]}
:transaction_approval_status {:values [{:enum-value :approved}
{:enum-value :unapproved}
{:enum-value :requires_feedback}]}}
{:enum-value :requires_feedback}
{:enum-value :excluded}]}}
:mutations
{:reject_invoices {:type '(list :id)
:args {:invoices {:type '(list :id)}}

View File

@@ -26,7 +26,11 @@
(defn get-transaction-page [context args value]
(let [args (assoc args :id (:id context))
[transactions transactions-count] (d-transactions/get-graphql (<-graphql args))
[transactions transactions-count] (d-transactions/get-graphql (update (<-graphql args) :approval-status
#(some->> %
name
snake->kebab
(keyword "transaction-approval-status"))))
transactions (map ->graphql (map approval-status->graphql transactions))]
[{:transactions transactions
:total transactions-count
@@ -51,7 +55,7 @@
set)]
(set/difference existing-ids specified-ids)))
(defn edit-transaction [context {{:keys [id exclude_from_ledger accounts vendor_id approval_status] :as transaction} :transaction} value]
(defn edit-transaction [context {{:keys [id accounts vendor_id approval_status] :as transaction} :transaction} value]
(let [existing-transaction (d-transactions/get-by-id id)
_ (assert-can-see-client (:id context) (:transaction/client existing-transaction) )
deleted (deleted-accounts existing-transaction accounts)
@@ -79,7 +83,6 @@
name
snake->kebab
(keyword "transaction-approval-status"))
:transaction/exclude-from-ledger exclude_from_ledger
:transaction/accounts (map transaction-account->entity accounts)
})]
(map (fn [d]

View File

@@ -58,6 +58,7 @@
[db [type id]]
(let [entity (d/pull db ['* {:transaction/vendor '[*]
:transaction/client '[*]
:transaction/approval-status '[*]
:transaction/bank-account '[* {:bank-account/type [:db/ident]}]
:transaction/accounts '[*
{:transaction-account/account [*]}] }] id)
@@ -65,7 +66,7 @@
decreasing? (< (:transaction/amount entity) 0.0)
credit-from-bank? decreasing?
debit-from-bank? (not decreasing?)]
(when-not (:transaction/exclude-from-ledger entity)
(when-not (= :transaction-approval-status/excluded (:db/ident (:transaction/approval-status entity)))
(remove-nils
{:journal-entry/source "transaction"
:journal-entry/client (:db/id (:transaction/client entity))

View File

@@ -93,7 +93,7 @@
:amount (double amount)
:description-original description-original
:description-simple description-simple
:exclude-from-ledger false
:approval-status :transaction-approval-status/unapproved
:type type
:status status
:client client-id