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
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
[:id
|
||||
:amount
|
||||
:location
|
||||
:exclude-from-ledger
|
||||
[:vendor [:name :id]]
|
||||
[:accounts [:id :amount :location [:account [:name :id :location]]]]
|
||||
:date
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
(re-frame/reg-sub
|
||||
::request
|
||||
:<- [::forms/form ::edit-transaction]
|
||||
(fn [{{:keys [id vendor-id accounts]} :data}]
|
||||
(fn [{{:keys [id vendor-id accounts exclude-from-ledger]} :data}]
|
||||
{:transaction {:id id
|
||||
:vendor-id vendor-id
|
||||
:exclude-from-ledger exclude-from-ledger
|
||||
:accounts (map
|
||||
(fn [{:keys [id account amount location]}]
|
||||
{:id (when-not (str/starts-with? id "new-")
|
||||
@@ -50,6 +51,7 @@
|
||||
:amount (:amount which)
|
||||
:description-original (:description-original which)
|
||||
:location (:location which)
|
||||
:exclude-from-ledger (:exclude-from-ledger which)
|
||||
:client-id (:id (:client which))
|
||||
:vendor-id (:id (:vendor which))
|
||||
:vendor-name (:name (:vendor which))
|
||||
@@ -154,6 +156,18 @@
|
||||
:event change-event
|
||||
:subscription data}]]]]
|
||||
|
||||
[:div.field
|
||||
[:div.control
|
||||
[:label.checkbox
|
||||
[bind-field
|
||||
[:input.checkbox {:type "checkbox"
|
||||
:field [:exclude-from-ledger]
|
||||
:subscription data
|
||||
:event change-event}
|
||||
]]
|
||||
" Exclude from ledger?"
|
||||
]]]
|
||||
|
||||
[:div.field
|
||||
[bind-field
|
||||
[expense-accounts-field
|
||||
|
||||
@@ -113,6 +113,20 @@
|
||||
keys (dissoc keys :field :subscription :event :spec)]
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
(defmethod do-bind "checkbox" [dom {:keys [field subscription event class value spec] :as keys} & rest]
|
||||
(let [field (if (keyword? field) [field] field)
|
||||
event (if (keyword? event) [event] event)
|
||||
keys (assoc keys
|
||||
:on-change (dispatch-event (-> event
|
||||
(conj field)
|
||||
(conj (not (get-in subscription field)))))
|
||||
:checked (boolean (get-in subscription field))
|
||||
:class (str class
|
||||
(when (and spec (not (s/valid? spec (get-in subscription field ))))
|
||||
" is-danger")))
|
||||
keys (dissoc keys :field :subscription :event :spec)]
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
(defmethod do-bind "typeahead" [dom {:keys [field text-field event text-event subscription class spec] :as keys} & rest]
|
||||
(let [field (if (keyword? field) [field] field)
|
||||
event (if (keyword? event) [event] event)
|
||||
|
||||
Reference in New Issue
Block a user