You can now type accounts.
This commit is contained in:
@@ -82,6 +82,7 @@
|
|||||||
:auto-ap/add-general-ledger6 {:txes add-general-ledger/add-general-ledger :requires [:auto-ap/make-every-account-visible]}
|
:auto-ap/add-general-ledger6 {:txes add-general-ledger/add-general-ledger :requires [:auto-ap/make-every-account-visible]}
|
||||||
:auto-ap/add-general-ledger-fns2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/add-general-ledger-fns :requires [:auto-ap/add-general-ledger6]}
|
:auto-ap/add-general-ledger-fns2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/add-general-ledger-fns :requires [:auto-ap/add-general-ledger6]}
|
||||||
:auto-ap/add-accounts {:txes auto-ap.datomic.migrate.add-general-ledger/add-accounts :requires [:auto-ap/add-general-ledger-fns2]}
|
:auto-ap/add-accounts {:txes auto-ap.datomic.migrate.add-general-ledger/add-accounts :requires [:auto-ap/add-general-ledger-fns2]}
|
||||||
|
:auto-ap/add-transaction-account {:txes auto-ap.datomic.migrate.add-general-ledger/add-transaction-account :requires [:auto-ap/add-general-ledger-fns2]}
|
||||||
#_#_:auto-ap/bulk-load-invoice-ledger2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/make-entity-not-unique]}
|
#_#_:auto-ap/bulk-load-invoice-ledger2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/make-entity-not-unique]}
|
||||||
|
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -64,6 +64,12 @@
|
|||||||
:db/doc "Location of the entry"}]
|
:db/doc "Location of the entry"}]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
(def add-transaction-account
|
||||||
|
[[{:db/ident :transaction/account
|
||||||
|
:db/valueType :db.type/ref
|
||||||
|
:db/cardinality :db.cardinality/one
|
||||||
|
:db/doc "The debit/credit for this transaction"}]])
|
||||||
|
|
||||||
(def add-accounts
|
(def add-accounts
|
||||||
[[
|
[[
|
||||||
{:db/ident :account/code
|
{:db/ident :account/code
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
(= "client" sort-by)
|
(= "client" sort-by)
|
||||||
#(-> % :transaction/client :client/name)
|
#(-> % :transaction/client :client/name)
|
||||||
|
|
||||||
|
(= "account" sort-by)
|
||||||
|
#(-> % :transaction/account :account/name)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(keyword "transaction" sort-by)))
|
(keyword "transaction" sort-by)))
|
||||||
|
|
||||||
@@ -64,6 +67,13 @@
|
|||||||
|
|
||||||
(:sort-by args) (add-sorter-field {"client" ['[?e :transaction/client ?c]
|
(:sort-by args) (add-sorter-field {"client" ['[?e :transaction/client ?c]
|
||||||
'[?c :client/name ?sorter]]
|
'[?c :client/name ?sorter]]
|
||||||
|
"account" #_['[(get-else $ ?e :transaction/account 0) ?sorter]]
|
||||||
|
['(or (and [?e :transaction/account ?c]
|
||||||
|
[?c :account/name ?sorter])
|
||||||
|
(and
|
||||||
|
[?e :transaction/client]
|
||||||
|
[(ground 0) ?c]
|
||||||
|
[(ground "") ?sorter]))]
|
||||||
"description-original" ['[?e :transaction/description-original ?sorter]]
|
"description-original" ['[?e :transaction/description-original ?sorter]]
|
||||||
"date" ['[?e :transaction/date ?sorter]]
|
"date" ['[?e :transaction/date ?sorter]]
|
||||||
"amount" ['[?e :transaction/amount ?sorter]]
|
"amount" ['[?e :transaction/amount ?sorter]]
|
||||||
@@ -107,7 +117,8 @@
|
|||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db args]
|
||||||
(->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
|
(->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
|
||||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
|
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
|
||||||
:transaction/vendor [:db/id :vendor/name]}]
|
:transaction/vendor [:db/id :vendor/name]
|
||||||
|
:transaction/account [:db/id :account/name :account/numeric-code]}]
|
||||||
ids)
|
ids)
|
||||||
(map #(update % :transaction/date c/from-date))
|
(map #(update % :transaction/date c/from-date))
|
||||||
(map #(update % :transaction/post-date c/from-date))
|
(map #(update % :transaction/post-date c/from-date))
|
||||||
@@ -126,7 +137,8 @@
|
|||||||
(d/pull (d/db (d/connect uri))
|
(d/pull (d/db (d/connect uri))
|
||||||
'[* {:transaction/client [:client/name :db/id :client/code]
|
'[* {:transaction/client [:client/name :db/id :client/code]
|
||||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
|
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
|
||||||
:transaction/vendor [:db/id :vendor/name]}]
|
:transaction/vendor [:db/id :vendor/name]
|
||||||
|
:transaction/account [:db/id :account/name :account/numeric-code]}]
|
||||||
id)
|
id)
|
||||||
(update :transaction/date c/from-date)
|
(update :transaction/date c/from-date)
|
||||||
(update :transaction/post-date c/from-date)
|
(update :transaction/post-date c/from-date)
|
||||||
|
|||||||
@@ -133,6 +133,7 @@
|
|||||||
:status {:type 'String}
|
:status {:type 'String}
|
||||||
:merchant_name {:type 'String}
|
:merchant_name {:type 'String}
|
||||||
:client {:type :client}
|
:client {:type :client}
|
||||||
|
:account {:type :account}
|
||||||
:payment {:type :payment}
|
:payment {:type :payment}
|
||||||
:vendor {:type :vendor}
|
:vendor {:type :vendor}
|
||||||
:bank_account {:type :bank_account}
|
:bank_account {:type :bank_account}
|
||||||
@@ -371,7 +372,8 @@
|
|||||||
:total {:type 'Float}}}
|
:total {:type 'Float}}}
|
||||||
:edit_transaction
|
:edit_transaction
|
||||||
{:fields {:id {:type :id}
|
{:fields {:id {:type :id}
|
||||||
:vendor_id {:type :id}}}}
|
:vendor_id {:type :id}
|
||||||
|
:account_id {:type :id}}}}
|
||||||
|
|
||||||
:enums {:payment_type {:values [{:enum-value :check}
|
:enums {:payment_type {:values [{:enum-value :check}
|
||||||
{:enum-value :cash}
|
{:enum-value :cash}
|
||||||
|
|||||||
@@ -24,11 +24,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn edit-transaction [context {{:keys [id vendor_id] :as transaction} :transaction} value]
|
(defn edit-transaction [context {{:keys [id account_id vendor_id] :as transaction} :transaction} value]
|
||||||
(assert-can-see-client (:id context) (:db/id (d-transactions/get-by-id id)))
|
(assert-can-see-client (:id context) (:db/id (d-transactions/get-by-id id)))
|
||||||
@(d/transact (d/connect uri)
|
@(d/transact (d/connect uri)
|
||||||
[{:db/id id
|
[{:db/id id
|
||||||
:transaction/vendor vendor_id}])
|
:transaction/vendor vendor_id
|
||||||
|
:transaction/account account_id}])
|
||||||
(->graphql (d-transactions/get-by-id id))
|
(->graphql (d-transactions/get-by-id id))
|
||||||
#_(->graphql {:id id
|
#_(->graphql {:id id
|
||||||
:vendor (d-vendors/get-by-id vendor_id) }))
|
:vendor (d-vendors/get-by-id vendor_id) }))
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
(let [variables (some-> (query-params "variables")
|
(let [variables (some-> (query-params "variables")
|
||||||
edn/read-string)
|
edn/read-string)
|
||||||
body (some-> r :body slurp)]
|
body (some-> r :body slurp)]
|
||||||
(println "BODY" body)
|
|
||||||
{:status 200
|
{:status 200
|
||||||
:body (pr-str (ql/query (:identity r) (doto (if (= request-method :get) (query-params "query") body) println) variables ))
|
:body (pr-str (ql/query (:identity r) (doto (if (= request-method :get) (query-params "query") body) println) variables ))
|
||||||
:headers {"Content-Type" "application/edn"}})
|
:headers {"Content-Type" "application/edn"}})
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
(fn [db]
|
(fn [db]
|
||||||
(:accounts db)))
|
(:accounts db)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::accounts-for-client
|
||||||
|
(fn [db client]
|
||||||
|
(:accounts db)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::bank-accounts
|
::bank-accounts
|
||||||
:<- [::clients]
|
:<- [::clients]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
[:id
|
[:id
|
||||||
:amount
|
:amount
|
||||||
[:vendor [:name :id]]
|
[:vendor [:name :id]]
|
||||||
|
[:account [:id :name]]
|
||||||
:date
|
:date
|
||||||
:post_date
|
:post_date
|
||||||
:status
|
:status
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
(fn [db [_ which]]
|
(fn [db [_ which]]
|
||||||
(-> db
|
(-> db
|
||||||
(forms/start-form ::edit-transaction {:id (:id which)
|
(forms/start-form ::edit-transaction {:id (:id which)
|
||||||
|
:account-id (:id (:account which))
|
||||||
|
:account-name (:name (:account which))
|
||||||
:vendor-id (:id (:vendor which))
|
:vendor-id (:id (:vendor which))
|
||||||
:vendor-name (:name (:vendor which))}))))
|
:vendor-name (:name (:vendor which))}))))
|
||||||
|
|
||||||
@@ -32,14 +34,17 @@
|
|||||||
::saving
|
::saving
|
||||||
(fn [{:keys [db]} [_ edit-completed]]
|
(fn [{:keys [db]} [_ edit-completed]]
|
||||||
(when @(re-frame/subscribe [::can-submit])
|
(when @(re-frame/subscribe [::can-submit])
|
||||||
(let [{{:keys [id vendor-id]} :data :as data} @(re-frame/subscribe [::forms/form ::edit-transaction])]
|
(let [{{:keys [id vendor-id account-id]} :data :as data} @(re-frame/subscribe [::forms/form ::edit-transaction])]
|
||||||
|
(println "DATA" data)
|
||||||
{:db (forms/loading db ::edit-transaction )
|
{:db (forms/loading db ::edit-transaction )
|
||||||
:graphql
|
:graphql
|
||||||
{:token (-> db :user)
|
{:token (-> db :user)
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
:operation/name "EditTransaction"}
|
:operation/name "EditTransaction"}
|
||||||
:venia/queries [{:query/data [:edit-transaction
|
:venia/queries [{:query/data [:edit-transaction
|
||||||
{:transaction {:id id :vendor-id vendor-id}}
|
{:transaction {:id id
|
||||||
|
:vendor-id vendor-id
|
||||||
|
:account-id account-id}}
|
||||||
transaction-read]}]}
|
transaction-read]}]}
|
||||||
:on-success [::edited edit-completed]
|
:on-success [::edited edit-completed]
|
||||||
:on-error [::forms/save-error ::edit-transaction]}}))))
|
:on-error [::forms/save-error ::edit-transaction]}}))))
|
||||||
@@ -99,10 +104,11 @@
|
|||||||
[:p.help "Credit Account"]
|
[:p.help "Credit Account"]
|
||||||
[:div.control
|
[:div.control
|
||||||
[bind-field
|
[bind-field
|
||||||
[typeahead {:matches (map (fn [x] [(:id x) (str (:id x) " - " (:name x))]) @(re-frame/subscribe [::subs/chooseable-expense-accounts]))
|
[typeahead {:matches (map (fn [x] [(:id x) (str (:numeric-code x) " - " (:name x))]) @(re-frame/subscribe [::subs/accounts-for-client (:id (:client data))]))
|
||||||
:type "typeahead"
|
:type "typeahead"
|
||||||
:field [:expense-account-id]
|
:field [:account-id]
|
||||||
:event [::change id]
|
:text-field [:account-name]
|
||||||
|
:event change-event
|
||||||
:subscription data}]]]]
|
:subscription data}]]]]
|
||||||
|
|
||||||
(when error
|
(when error
|
||||||
|
|||||||
@@ -61,6 +61,14 @@
|
|||||||
:asc asc}
|
:asc asc}
|
||||||
"Amount"]
|
"Amount"]
|
||||||
|
|
||||||
|
[sorted-column {:on-sort opc
|
||||||
|
:style {:width "8em" :cursor "pointer"}
|
||||||
|
:sort-key "account"
|
||||||
|
:class "has-text-right"
|
||||||
|
:sort-by sort-by
|
||||||
|
:asc asc}
|
||||||
|
"Account"]
|
||||||
|
|
||||||
[sorted-column {:on-sort opc
|
[sorted-column {:on-sort opc
|
||||||
:style {:width "8em" :cursor "pointer"}
|
:style {:width "8em" :cursor "pointer"}
|
||||||
:sort-key "status"
|
:sort-key "status"
|
||||||
@@ -74,7 +82,7 @@
|
|||||||
[:tr
|
[:tr
|
||||||
[:td {:col-span 5}
|
[:td {:col-span 5}
|
||||||
[:i.fa.fa-spin.fa-spinner]]]
|
[:i.fa.fa-spin.fa-spinner]]]
|
||||||
(for [{:keys [client vendor check status bank-account description-original date amount id ] :as i} (:transactions @transaction-page)]
|
(for [{:keys [client account vendor check status bank-account description-original date amount id ] :as i} (:transactions @transaction-page)]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[:tr {:class (:class i)}
|
[:tr {:class (:class i)}
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
@@ -85,6 +93,7 @@
|
|||||||
[:td description-original]
|
[:td description-original]
|
||||||
[:td (date->str date) ]
|
[:td (date->str date) ]
|
||||||
[:td.has-text-right (nf amount )]
|
[:td.has-text-right (nf amount )]
|
||||||
|
[:td (:name account)]
|
||||||
[:td status]
|
[:td status]
|
||||||
[:td (:name bank-account )]
|
[:td (:name bank-account )]
|
||||||
[:td
|
[:td
|
||||||
|
|||||||
Reference in New Issue
Block a user