you can exclude from the ledger.
This commit is contained in:
@@ -124,11 +124,11 @@
|
||||
:requires [:auto-ap/add-location-to-transaction]}
|
||||
:auto-ap/convert-invoices {:txes-fn `add-general-ledger/convert-invoices
|
||||
:requires [:auto-ap/convert-vendors]}
|
||||
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions
|
||||
:requires [:auto-ap/convert-invoices]}
|
||||
:auto-ap/add-yodlee-merchant2 {:txes add-general-ledger/add-yodlee-merchant :requires [:auto-ap/convert-transactions]}
|
||||
:auto-ap/add-external-id-to-ledger {:txes add-general-ledger/add-external-id-to-ledger :requires [:auto-ap/add-yodlee-merchant2]}
|
||||
|
||||
:auto-ap/add-yodlee-merchant2 {:txes add-general-ledger/add-yodlee-merchant :requires [:auto-ap/convert-vendors]}
|
||||
:auto-ap/add-external-id-to-ledger {:txes add-general-ledger/add-external-id-to-ledger :requires [:auto-ap/add-yodlee-merchant2]}
|
||||
:auto-ap/add-exclude-to-transaction {:txes add-general-ledger/add-exclude-to-transaction :requires [:auto-ap/add-external-id-to-ledger]}
|
||||
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions :requires [:auto-ap/add-external-id-to-ledger]}
|
||||
#_#_:auto-ap/bulk-load-invoice-ledger3 {:txes-fn `add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/convert-transactions]}
|
||||
#_#_:auto-ap/bulk-load-transaction-ledger3 {:txes-fn `add-general-ledger/bulk-load-transaction-ledger :requires [:auto-ap/convert-transactions]}
|
||||
|
||||
|
||||
@@ -263,6 +263,7 @@
|
||||
(remove-nils {:db/id transaction-id
|
||||
:transaction/vendor vendor-id
|
||||
:transaction/location "A"
|
||||
:transaction/exclude-from-ledger true
|
||||
:transaction/accounts [#:transaction-account {:account (:db/id (accounts/get-account-by-numeric-code-and-sets 2110 ["default"]))
|
||||
:location "A"
|
||||
:amount (Math/abs amount)}]
|
||||
@@ -282,6 +283,12 @@
|
||||
:db/unique :db.unique/identity
|
||||
:db/doc "For externally imported id"}]])
|
||||
|
||||
(def add-exclude-to-transaction
|
||||
[[{:db/ident :transaction/exclude-from-ledger
|
||||
:db/valueType :db.type/boolean
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "Whether to exclude from the ledger"}]])
|
||||
|
||||
(def add-credit-bank-account
|
||||
[[{:db/ident :bank-account-type/credit}]])
|
||||
|
||||
|
||||
@@ -159,6 +159,7 @@
|
||||
: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}
|
||||
@@ -444,6 +445,7 @@
|
||||
:total {:type 'Float}}}
|
||||
:edit_transaction
|
||||
{:fields {:id {:type :id}
|
||||
:exclude_from_ledger {:type 'Boolean}
|
||||
:vendor_id {:type :id}
|
||||
:accounts {:type '(list :edit_expense_account)}}}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
set)]
|
||||
(set/difference existing-ids specified-ids)))
|
||||
|
||||
(defn edit-transaction [context {{:keys [id accounts vendor_id] :as transaction} :transaction} value]
|
||||
(defn edit-transaction [context {{:keys [id exclude_from_ledger accounts vendor_id] :as transaction} :transaction} value]
|
||||
(let [existing-transaction (d-transactions/get-by-id id)
|
||||
deleted (deleted-accounts existing-transaction accounts)
|
||||
account-total (reduce + 0 (map (fn [x] (Double/parseDouble (:amount x))) accounts))
|
||||
@@ -63,6 +63,7 @@
|
||||
@(d/transact (d/connect uri)
|
||||
(concat [(remove-nils {:db/id id
|
||||
:transaction/vendor vendor_id
|
||||
:transaction/exclude-from-ledger exclude_from_ledger
|
||||
:transaction/accounts (map transaction-account->entity accounts)
|
||||
})]
|
||||
(map (fn [d]
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
(keyword (snake->kebab (name x)))))
|
||||
|
||||
(defn kebab->snake [s]
|
||||
(str/replace s #"-" "_"))
|
||||
(str/replace (str/replace s #"-" "_") #"\?$" "" ))
|
||||
|
||||
(defn snake [x]
|
||||
(keyword (kebab->snake (name x))))
|
||||
|
||||
@@ -69,32 +69,33 @@
|
||||
credit-from-bank? decreasing?
|
||||
debit-from-bank? (not decreasing?)]
|
||||
|
||||
(remove-nils
|
||||
{:journal-entry/source "transaction"
|
||||
:journal-entry/client (:db/id (:transaction/client entity))
|
||||
:journal-entry/date (:transaction/date entity)
|
||||
:journal-entry/original-entity (:db/id entity)
|
||||
:journal-entry/vendor (:db/id (:transaction/vendor entity))
|
||||
:journal-entry/amount (Math/abs (:transaction/amount entity))
|
||||
(when-not (:transaction/exclude-from-ledger entity)
|
||||
(remove-nils
|
||||
{:journal-entry/source "transaction"
|
||||
:journal-entry/client (:db/id (:transaction/client entity))
|
||||
:journal-entry/date (:transaction/date entity)
|
||||
:journal-entry/original-entity (:db/id entity)
|
||||
:journal-entry/vendor (:db/id (:transaction/vendor entity))
|
||||
:journal-entry/amount (Math/abs (:transaction/amount entity))
|
||||
|
||||
:journal-entry/line-items (into [(remove-nils {:journal-entry-line/account (:db/id (:transaction/bank-account entity))
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit (when credit-from-bank?
|
||||
(Math/abs (:transaction/amount entity)))
|
||||
:journal-entry-line/debit (when debit-from-bank?
|
||||
(Math/abs (:transaction/amount entity)))})
|
||||
]
|
||||
(map
|
||||
(fn [a]
|
||||
(remove-nils{:journal-entry-line/account (:db/id (:transaction-account/account a))
|
||||
:journal-entry-line/location (:transaction-account/location a)
|
||||
:journal-entry-line/debit (when credit-from-bank?
|
||||
(Math/abs (:transaction-account/amount a)))
|
||||
:journal-entry-line/credit (when debit-from-bank?
|
||||
(Math/abs (:transaction-account/amount a)))}))
|
||||
(:transaction/accounts entity)))
|
||||
|
||||
:journal-entry/cleared true})))
|
||||
:journal-entry/line-items (into [(remove-nils {:journal-entry-line/account (:db/id (:transaction/bank-account entity))
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit (when credit-from-bank?
|
||||
(Math/abs (:transaction/amount entity)))
|
||||
:journal-entry-line/debit (when debit-from-bank?
|
||||
(Math/abs (:transaction/amount entity)))})
|
||||
]
|
||||
(map
|
||||
(fn [a]
|
||||
(remove-nils{:journal-entry-line/account (:db/id (:transaction-account/account a))
|
||||
:journal-entry-line/location (:transaction-account/location a)
|
||||
:journal-entry-line/debit (when credit-from-bank?
|
||||
(Math/abs (:transaction-account/amount a)))
|
||||
:journal-entry-line/credit (when debit-from-bank?
|
||||
(Math/abs (:transaction-account/amount a)))}))
|
||||
(:transaction/accounts entity)))
|
||||
|
||||
:journal-entry/cleared true}))))
|
||||
|
||||
(defmethod entity-change->ledger :invoice-expense-account
|
||||
[db [entity changes]]
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
:amount (double amount)
|
||||
:description-original description-original
|
||||
:description-simple description-simple
|
||||
:exclude-from-ledger false
|
||||
:type type
|
||||
:status status
|
||||
:client client-id
|
||||
|
||||
Reference in New Issue
Block a user