locations.
This commit is contained in:
@@ -53,44 +53,81 @@
|
||||
|
||||
(let [
|
||||
conn (d/connect uri)
|
||||
norms-map {:auto-ap/base-schema {:txes auto-ap.datomic/base-schema}
|
||||
:auto-ap/functions {:txes-fn 'auto-ap.datomic.migrate/functions :requires [:auto-ap/base-schema]}
|
||||
:auto-ap/fx-pay-function-2 {:txes-fn 'auto-ap.datomic.migrate/fix-pay-function :requires [:auto-ap/functions]}
|
||||
:auto-ap/migrate-vendors {:txes-fn 'auto-ap.datomic/migrate-vendors :requires [:auto-ap/base-schema]}
|
||||
:auto-ap/migrate-clients {:txes-fn 'auto-ap.datomic/migrate-clients :requires [:auto-ap/migrate-vendors]}
|
||||
:auto-ap/migrate-users {:txes-fn 'auto-ap.datomic/migrate-users :requires [:auto-ap/migrate-clients]}
|
||||
:auto-ap/migrate-invoices {:txes-fn 'auto-ap.datomic/migrate-invoices :requires [:auto-ap/migrate-vendors :auto-ap/migrate-clients]}
|
||||
:auto-ap/migrate-payments {:txes-fn 'auto-ap.datomic/migrate-payments :requires [:auto-ap/migrate-invoices]}
|
||||
:auto-ap/migrate-invoices-payments {:txes-fn 'auto-ap.datomic/migrate-invoices-payments :requires [:auto-ap/migrate-payments :auto-ap/migrate-invoices]}
|
||||
:auto-ap/migrate-invoices-expense-accounts {:txes-fn 'auto-ap.datomic/migrate-invoices-expense-accounts :requires [:auto-ap/migrate-invoices-payments]}
|
||||
:auto-ap/migrate-transactions {:txes-fn 'auto-ap.datomic/migrate-transactions :requires [:auto-ap/migrate-invoices-expense-accounts]}
|
||||
:auto-ap/add-client-codes {:txes-fn 'auto-ap.datomic.migrate.add-client-codes/add-client-codes :requires [:auto-ap/migrate-transactions]}
|
||||
:auto-ap/add-bank-account-codes-schema {:txes-fn 'auto-ap.datomic.migrate.add-bank-account-codes/add-bank-account-codes-schema :requires [:auto-ap/add-client-codes]}
|
||||
:auto-ap/add-bank-account-codes {:txes-fn 'auto-ap.datomic.migrate.add-bank-account-codes/add-bank-account-codes :requires [:auto-ap/add-bank-account-codes-schema]}
|
||||
:auto-ap/add-nick-the-greek {:txes [[{:client/name "Nick the Greek" :client/code "NGAK" :client/locations ["MH"] :client/bank-accounts [{:bank-account/code "NGAK-0" :bank-account/type :bank-account-type/cash :bank-account/name "Cash"}]}]] :requires [:auto-ap/add-bank-account-codes]}
|
||||
:auto-ap/rename-codes-1 {:txes-fn 'auto-ap.datomic.migrate.rename-codes/rename-codes-1 :requires [:auto-ap/add-nick-the-greek]}
|
||||
:auto-ap/invoice-converter {:txes auto-ap.datomic.migrate.invoice-converter/add-matches :requires [:auto-ap/rename-codes-1]}
|
||||
:auto-ap/starter {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-starter :requires [:auto-ap/invoice-converter]}
|
||||
:auto-ap/add-default-location {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-default-location :requires [:auto-ap/invoice-converter]}
|
||||
:auto-ap/add-default-location-2 {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-default-location-2 :requires [:auto-ap/add-default-location]}
|
||||
:auto-ap/add-import-status {:txes auto-ap.datomic.migrate.invoice-converter/add-import-status :requires [:auto-ap/add-default-location-2]}
|
||||
:auto-ap/add-import-status-existing-invoices {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-import-status-existing-invoices :requires [:auto-ap/add-import-status]}
|
||||
:auto-ap/fix-check-numbers {:txes-fn 'auto-ap.datomic.migrate.check-numbers/fix-check-numbers :requires [:auto-ap/add-import-status-existing-invoices]}
|
||||
:auto-ap/add-new-vendors {:txes-fn 'auto-ap.datomic.migrate.add-new-vendors/add-new-vendors :requires [:auto-ap/fix-check-numbers]}
|
||||
:auto-ap/add-account-visibility-fields {:txes-fn 'auto-ap.datomic.migrate.account-sorting/add-account-visibility-fields :requires [:auto-ap/add-new-vendors]}
|
||||
:auto-ap/make-every-account-visible {:txes-fn 'auto-ap.datomic.migrate.account-sorting/make-every-account-visible :requires [:auto-ap/add-account-visibility-fields]}
|
||||
: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-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-accounts]}
|
||||
:auto-ap/change-expense-account-to-entity {:txes auto-ap.datomic.migrate.add-general-ledger/change-expense-account-to-entity :requires [:auto-ap/add-transaction-account]}
|
||||
:auto-ap/add-account-to-vendor {:txes auto-ap.datomic.migrate.add-general-ledger/add-account-to-vendor :requires [:auto-ap/change-expense-account-to-entity]}
|
||||
:auto-ap/convert-vendors {:txes-fn `add-general-ledger/convert-vendors :requires [:auto-ap/add-account-to-vendor]}
|
||||
:auto-ap/convert-invoices {:txes-fn `add-general-ledger/convert-invoices :requires [:auto-ap/add-account-to-vendor]}
|
||||
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions :requires [:auto-ap/convert-invoices]}
|
||||
#_#_: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]}
|
||||
norms-map {:auto-ap/base-schema {:txes auto-ap.datomic/base-schema}
|
||||
:auto-ap/functions {:txes-fn 'auto-ap.datomic.migrate/functions
|
||||
:requires [:auto-ap/base-schema]}
|
||||
:auto-ap/fx-pay-function-2 {:txes-fn 'auto-ap.datomic.migrate/fix-pay-function
|
||||
:requires [:auto-ap/functions]}
|
||||
:auto-ap/migrate-vendors {:txes-fn 'auto-ap.datomic/migrate-vendors
|
||||
:requires [:auto-ap/base-schema]}
|
||||
:auto-ap/migrate-clients {:txes-fn 'auto-ap.datomic/migrate-clients
|
||||
:requires [:auto-ap/migrate-vendors]}
|
||||
:auto-ap/migrate-users {:txes-fn 'auto-ap.datomic/migrate-users
|
||||
:requires [:auto-ap/migrate-clients]}
|
||||
:auto-ap/migrate-invoices {:txes-fn 'auto-ap.datomic/migrate-invoices
|
||||
:requires [:auto-ap/migrate-vendors :auto-ap/migrate-clients]}
|
||||
:auto-ap/migrate-payments {:txes-fn 'auto-ap.datomic/migrate-payments
|
||||
:requires [:auto-ap/migrate-invoices]}
|
||||
:auto-ap/migrate-invoices-payments {:txes-fn 'auto-ap.datomic/migrate-invoices-payments
|
||||
:requires [:auto-ap/migrate-payments :auto-ap/migrate-invoices]}
|
||||
:auto-ap/migrate-invoices-expense-accounts {:txes-fn 'auto-ap.datomic/migrate-invoices-expense-accounts
|
||||
:requires [:auto-ap/migrate-invoices-payments]}
|
||||
:auto-ap/migrate-transactions {:txes-fn 'auto-ap.datomic/migrate-transactions
|
||||
:requires [:auto-ap/migrate-invoices-expense-accounts]}
|
||||
:auto-ap/add-client-codes {:txes-fn 'auto-ap.datomic.migrate.add-client-codes/add-client-codes
|
||||
:requires [:auto-ap/migrate-transactions]}
|
||||
:auto-ap/add-bank-account-codes-schema {:txes-fn 'auto-ap.datomic.migrate.add-bank-account-codes/add-bank-account-codes-schema
|
||||
:requires [:auto-ap/add-client-codes]}
|
||||
:auto-ap/add-bank-account-codes {:txes-fn 'auto-ap.datomic.migrate.add-bank-account-codes/add-bank-account-codes
|
||||
:requires [:auto-ap/add-bank-account-codes-schema]}
|
||||
:auto-ap/add-nick-the-greek {:txes [[{:client/name "Nick the Greek" :client/code "NGAK" :client/locations ["MH"] :client/bank-accounts [{:bank-account/code "NGAK-0" :bank-account/type :bank-account-type/cash :bank-account/name "Cash"}]}]]
|
||||
:requires [:auto-ap/add-bank-account-codes]}
|
||||
:auto-ap/rename-codes-1 {:txes-fn 'auto-ap.datomic.migrate.rename-codes/rename-codes-1
|
||||
:requires [:auto-ap/add-nick-the-greek]}
|
||||
:auto-ap/invoice-converter {:txes auto-ap.datomic.migrate.invoice-converter/add-matches
|
||||
:requires [:auto-ap/rename-codes-1]}
|
||||
:auto-ap/starter {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-starter
|
||||
:requires [:auto-ap/invoice-converter]}
|
||||
:auto-ap/add-default-location {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-default-location
|
||||
:requires [:auto-ap/invoice-converter]}
|
||||
:auto-ap/add-default-location-2 {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-default-location-2
|
||||
:requires [:auto-ap/add-default-location]}
|
||||
:auto-ap/add-import-status {:txes auto-ap.datomic.migrate.invoice-converter/add-import-status
|
||||
:requires [:auto-ap/add-default-location-2]}
|
||||
:auto-ap/add-import-status-existing-invoices {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-import-status-existing-invoices
|
||||
:requires [:auto-ap/add-import-status]}
|
||||
:auto-ap/fix-check-numbers {:txes-fn 'auto-ap.datomic.migrate.check-numbers/fix-check-numbers
|
||||
:requires [:auto-ap/add-import-status-existing-invoices]}
|
||||
:auto-ap/add-new-vendors {:txes-fn 'auto-ap.datomic.migrate.add-new-vendors/add-new-vendors
|
||||
:requires [:auto-ap/fix-check-numbers]}
|
||||
:auto-ap/add-account-visibility-fields {:txes-fn 'auto-ap.datomic.migrate.account-sorting/add-account-visibility-fields
|
||||
:requires [:auto-ap/add-new-vendors]}
|
||||
:auto-ap/make-every-account-visible {:txes-fn 'auto-ap.datomic.migrate.account-sorting/make-every-account-visible
|
||||
:requires [:auto-ap/add-account-visibility-fields]}
|
||||
: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-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-accounts]}
|
||||
:auto-ap/change-expense-account-to-entity {:txes auto-ap.datomic.migrate.add-general-ledger/change-expense-account-to-entity
|
||||
:requires [:auto-ap/add-transaction-account]}
|
||||
:auto-ap/add-account-to-vendor {:txes auto-ap.datomic.migrate.add-general-ledger/add-account-to-vendor
|
||||
:requires [:auto-ap/change-expense-account-to-entity]}
|
||||
:auto-ap/add-location-to-transaction {:txes add-general-ledger/add-location-to-transaction
|
||||
:requires [:auto-ap/add-account-to-vendor]}
|
||||
:auto-ap/convert-vendors {:txes-fn `add-general-ledger/convert-vendors
|
||||
: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/bulk-load-invoice-ledger2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/convert-transactions]}
|
||||
|
||||
}]
|
||||
}]
|
||||
(println "Conforming database...")
|
||||
(println (c/ensure-conforms conn norms-map))
|
||||
(d/release conn)
|
||||
|
||||
@@ -225,10 +225,17 @@
|
||||
(fn [[transaction-id vendor-id]]
|
||||
(remove-nils {:db/id transaction-id
|
||||
:transaction/vendor vendor-id
|
||||
:transaction/location "A"
|
||||
:transaction/account (:db/id (accounts/get-account-by-numeric-code-and-sets 2110 ["default"]))
|
||||
}))
|
||||
matched-transactions)]))
|
||||
|
||||
(def add-location-to-transaction
|
||||
[[{:db/ident :transaction/location
|
||||
:db/valueType :db.type/string
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "Location of the transaction's target"}]])
|
||||
|
||||
|
||||
#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))]
|
||||
@(d/transact (d/connect auto-ap.datomic/uri) tran))
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
(defn get-by-id [id]
|
||||
(->
|
||||
(d/pull (d/db (d/connect uri))
|
||||
'[* {:transaction/client [:client/name :db/id :client/code]
|
||||
'[* {:transaction/client [:client/name :db/id :client/code :client/locations]
|
||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
|
||||
:transaction/vendor [:db/id :vendor/name]
|
||||
:transaction/account [:db/id :account/name :account/numeric-code]}]
|
||||
|
||||
@@ -155,6 +155,7 @@
|
||||
:amount {:type 'String}
|
||||
:description_original {:type 'String}
|
||||
:description_simple {:type 'String}
|
||||
:location {:type 'String}
|
||||
:status {:type 'String}
|
||||
:merchant_name {:type 'String}
|
||||
:client {:type :client}
|
||||
@@ -417,6 +418,7 @@
|
||||
:edit_transaction
|
||||
{:fields {:id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:location {:type 'String}
|
||||
:account_id {:type :id}}}
|
||||
|
||||
:edit_account
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
[com.walmartlabs.lacinia.executor :as executor]
|
||||
[com.walmartlabs.lacinia.resolve :as resolve]
|
||||
[auto-ap.utils :refer [by]]
|
||||
[auto-ap.time :refer [parse normal-date]]))
|
||||
[auto-ap.time :refer [parse normal-date]]
|
||||
[auto-ap.datomic.clients :as d-clients]))
|
||||
|
||||
(defn get-transaction-page [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
@@ -24,13 +25,23 @@
|
||||
|
||||
|
||||
|
||||
(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)))
|
||||
(println transaction)
|
||||
@(d/transact (d/connect uri)
|
||||
[{:db/id id
|
||||
:transaction/vendor vendor_id
|
||||
:transaction/account account_id}])
|
||||
(->graphql (d-transactions/get-by-id id))
|
||||
(defn edit-transaction [context {{:keys [id location account_id vendor_id] :as transaction} :transaction} value]
|
||||
(let [transaction (d-transactions/get-by-id id)]
|
||||
(assert-can-see-client (:id context) (:transaction/client transaction) )
|
||||
(when-not (-> (:transaction/client transaction)
|
||||
:client/locations
|
||||
set
|
||||
(conj "A")
|
||||
(conj "HQ")
|
||||
(get location))
|
||||
(throw (ex-info (str "Location '" location "' not found on client.") {}))
|
||||
)
|
||||
|
||||
@(d/transact (d/connect uri)
|
||||
[{:db/id id
|
||||
:transaction/vendor vendor_id
|
||||
:transaction/location location
|
||||
:transaction/account account_id}])
|
||||
(->graphql (d-transactions/get-by-id id)))
|
||||
#_(->graphql {:id id
|
||||
:vendor (d-vendors/get-by-id vendor_id) }))
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
:journal-entry/amount (:invoice/total entity)
|
||||
|
||||
:journal-entry/line-items (into [{:journal-entry-line/account (a/get-account-by-numeric-code-and-sets 2110 ["default"])
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit (:invoice/total entity)}]
|
||||
(map (fn [ea]
|
||||
(remove-nils {:journal-entry-line/account (:db/id (:invoice-expense-account/account ea))
|
||||
@@ -67,14 +68,14 @@
|
||||
:journal-entry/amount (Math/abs (:transaction/amount entity))
|
||||
|
||||
:journal-entry/line-items [(remove-nils{:journal-entry-line/account (:db/id (:transaction/account entity))
|
||||
:journal-entry-line/location "HQ"
|
||||
:journal-entry-line/location (:transaction/location entity)
|
||||
:journal-entry-line/debit (when (< (:transaction/amount entity) 0.0)
|
||||
(Math/abs (:transaction/amount entity)))
|
||||
:journal-entry-line/credit (when (>= (:transaction/amount entity) 0.0)
|
||||
(Math/abs (:transaction/amount entity)))})
|
||||
|
||||
(remove-nils {:journal-entry-line/account (:db/id (:transaction/bank-account entity))
|
||||
:journal-entry-line/location "HQ"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit (when (< (:transaction/amount entity) 0.0)
|
||||
(Math/abs (:transaction/amount entity)))
|
||||
:journal-entry-line/debit (when (>= (:transaction/amount entity) 0.0)
|
||||
|
||||
@@ -88,9 +88,10 @@
|
||||
|
||||
:vendor (when check
|
||||
(:db/id (:payment/vendor check)))
|
||||
:location (when check
|
||||
"A")
|
||||
:account (when check
|
||||
(:db/id (a/get-account-by-numeric-code-and-sets 2110 ["default"]))
|
||||
#_(:db/id (:payment/vendor check)))
|
||||
(:db/id (a/get-account-by-numeric-code-and-sets 2110 ["default"])))
|
||||
})]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user