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%")]