rules can be edited fully and more.

This commit is contained in:
Bryce Covert
2019-05-12 20:31:28 -07:00
parent 51691fa553
commit 76c903d16d
16 changed files with 132 additions and 38 deletions

View File

@@ -12,9 +12,9 @@
[clj-time.core :as time]
[clj-time.coerce :as coerce]))
#_ (def uri "datomic:sql://invoices?jdbc:postgresql://database:5432/datomic?user=datomic&password=datomic")
(def uri "datomic:sql://invoices?jdbc:postgresql://database:5432/datomic?user=datomic&password=datomic")
(def uri "datomic:mem://datomic-transactor:4334/invoice")
#_(def uri "datomic:mem://datomic-transactor:4334/invoice")
(defn create-database []
(d/create-database uri))

View File

@@ -72,7 +72,16 @@
{:db/ident :journal-entry-line/location
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "Location of the entry"}]
:db/doc "Location of the entry"}
{:db/ident :transaction/approval-status
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one
:db/doc "Status of a transaction"}
{:db/ident :transaction-approval-status/approved}
{:db/ident :transaction-approval-status/unapproved}
{:db/ident :transaction-approval-status/requires-feedback}]
]
)
(def add-transaction-account

View File

@@ -12,6 +12,7 @@
{:transaction-rule/client [:client/name :db/id :client/code]}
{:transaction-rule/bank-account [*]}
{:transaction-rule/yodlee-merchant [*]}
{:transaction-rule/transaction-status [:db/id :db/ident]}
{:transaction-rule/vendor [:vendor/name :db/id :vendor/default-account]}
{:transaction-rule/accounts [:transaction-rule-account/percentage
:transaction-rule-account/location

View File

@@ -201,7 +201,8 @@
:dom_lte {:type 'Int}
:dom_gte {:type 'Int}
:vendor {:type :vendor}
:accounts {:type '(list :percentage_account)}}}
:accounts {:type '(list :percentage_account)}
:transaction_approval_status {:type :transaction_approval_status}}}
:invoice_payment
{:fields {:id {:type :id}
@@ -537,7 +538,8 @@
:dom_lte {:type 'Int}
:dom_gte {:type 'Int}
:vendor_id {:type :id}
:accounts {:type '(list :edit_percentage_account)}}}
:accounts {:type '(list :edit_percentage_account)}
:transaction_approval_status {:type :transaction_approval_status}}}
:edit_account
{:fields {:id {:type :id}
@@ -558,7 +560,10 @@
{:enum-value :asset}
{:enum-value :liability}
{:enum-value :equities}
{:enum-value :revenue}]}}
{:enum-value :revenue}]}
:transaction_approval_status {:values [{:enum-value :approved}
{:enum-value :unapproved}
{:enum-value :requires_feedback}]}}
:mutations
{:reject_invoices {:type '(list :id)
:args {:invoices {:type '(list :id)}}

View File

@@ -34,6 +34,8 @@
#_(assert-admin (:id context))
(let [existing-transaction (tr/get-by-id id)
deleted (deleted-accounts existing-transaction accounts)
_ (println existing-transaction)
_ (println "DELETING" deleted)
account-total (reduce + 0 (map (fn [x] (:percentage x)) accounts))
_ (when-not (dollars= 1.0 account-total)
(let [error (str "Account total (" account-total ") does not reach 100%")]

View File

@@ -37,27 +37,23 @@
[:span {:class "name"} "Vendors"]]]
[:li.menu-item
[:a {:href (bidi/path-for routes/routes :admin-users), :class (str "item" (active-when ap = :admin-users))}
[:span {:class "icon"}
[:i {:class "fa fa-envelope-o"}]]
[:span {:class "icon icon-single-neutral-book" :style {:font-size "25px"}}]
[:span {:class "name"} "Users"]]]
[:li.menu-item
[:a {:href (bidi/path-for routes/routes :admin-accounts), :class (str "item" (active-when ap = :admin-accounts))}
[:span {:class "icon"}
[:i {:class "fa fa-envelope-o"}]]
[:span {:class "icon icon-list-bullets" :style {:font-size "25px"}}]
[:span {:class "name"} "Accounts"]]]
[:li.menu-item
[:a {:href (bidi/path-for routes/routes :admin-rules), :class (str "item" (active-when ap = :admin-rules))}
[:span {:class "icon"}
[:i {:class "fa fa-envelope-o"}]]
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
[:span {:class "name"} "Rules"]]]
[:li.menu-item
[:a {:href (bidi/path-for routes/routes :admin-yodlee), :class (str "item" (active-when ap = :admin-yodlee))}
[:span {:class "icon"}
[:i {:class "fa fa-envelope-o"}]]
[:span {:class "icon icon-saving-bank-1" :style {:font-size "25px"}}]
[:span {:class "name"} "Yodlee Link"]]]
[:ul ]]

View File

@@ -10,4 +10,8 @@
[:vendor [:name :id]]
[:client [:name :id]]
[:bank-account [:name :id]]
[:accounts [[:account [:id :name :numeric-code]]
:id
:percentage
:location]]
])

View File

@@ -39,7 +39,18 @@
:amount-gte
:dom-lte
:dom-gte
:accounts
:note])
(assoc :vendor-id (:id (:vendor data)))
(update :accounts (fn [as]
(map #(-> %
(update :id (fn [i] (if (some-> i (str/starts-with? "new-"))
nil
i)))
(assoc :percentage (/ (get-in % [:amount-percentage]) 100 ))
(assoc :account-id (get-in % [:account :id]))
(select-keys [:percentage :id :location :account-id]))
as)))
(assoc :client-id (:id (:client data)))
(assoc :bank-account-id (:id (:bank-account data))))}
default-read]}]}))
@@ -88,23 +99,27 @@
:dom-lte nil
:dom-gte nil
:vendor nil
:expense-accounts [])))))
:accounts [])))))
(re-frame/reg-event-db
::editing
(fn [db [_ which]]
(-> db (forms/start-form ::form (assoc (select-keys which
[:description
:id
:client
:bank-account
:note
:amount-lte
:amount-gte
:dom-lte
:dom-gte
:vendor])
:expense-accounts [])))))
(-> db (forms/start-form ::form (-> which
(select-keys [:description
:id
:client
:bank-account
:note
:amount-lte
:amount-gte
:dom-lte
:dom-gte
:vendor
:accounts])
(update :accounts (fn [xs]
(println xs)
(mapv #(assoc % :amount-percentage (* (:percentage %) 100.0))
xs))))))))
(re-frame/reg-event-db
@@ -251,7 +266,7 @@
:percentage-only? true
:locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client data))])
:max 100
:field [:expense-accounts]}]]
:field [:accounts]}]]
[error-notification]