lots of changes to make ledger actually visible.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
[auto-ap.utils :refer [by]]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri remove-nils]]
|
||||
[auto-ap.datomic.accounts :as a]
|
||||
[clj-time.coerce :as coerce]
|
||||
[digest :refer [sha-256]]
|
||||
[auto-ap.datomic.checks :as d-checks]
|
||||
@@ -11,15 +12,15 @@
|
||||
|
||||
|
||||
|
||||
(defn transaction->check-id [_ check-number client-id bank-account-id amount]
|
||||
(defn transaction->payment [_ check-number client-id bank-account-id amount]
|
||||
|
||||
(cond (and check-number client-id bank-account-id)
|
||||
(-> (d-checks/get-graphql {:client-id client-id
|
||||
:bank-account-id bank-account-id
|
||||
:check-number check-number
|
||||
:amount (- amount)
|
||||
:status :payment-status/pending})
|
||||
first
|
||||
:db/id)
|
||||
first)
|
||||
|
||||
(and client-id bank-account-id amount)
|
||||
|
||||
@@ -28,7 +29,7 @@
|
||||
:amount (- amount)
|
||||
:status :payment-status/pending})]
|
||||
(if (= 1 (count matching-checks))
|
||||
(:db/id (first matching-checks))
|
||||
(first matching-checks)
|
||||
nil))
|
||||
|
||||
:else
|
||||
@@ -64,7 +65,7 @@
|
||||
check-number (extract-check-number transaction)
|
||||
client-id (transaction->client transaction)
|
||||
bank-account-id (transaction->bank-account-id transaction)
|
||||
check-id (transaction->check-id transaction check-number client-id bank-account-id amount)]]
|
||||
check (transaction->payment transaction check-number client-id bank-account-id amount)]]
|
||||
(try
|
||||
(when client-id
|
||||
@(->> [(remove-nils #:transaction
|
||||
@@ -80,10 +81,17 @@
|
||||
:client client-id
|
||||
:check-number check-number
|
||||
:bank-account (transaction->bank-account-id transaction)
|
||||
:payment (when check-id
|
||||
{:db/id check-id
|
||||
:payment (when check
|
||||
{:db/id (:db/id check)
|
||||
:payment/status :payment-status/cleared}
|
||||
)})]
|
||||
)
|
||||
|
||||
:vendor (when check
|
||||
(:db/id (:payment/vendor check)))
|
||||
:account (when check
|
||||
(:db/id (a/get-account-by-numeric-code-and-sets 2110 ["default"]))
|
||||
#_(:db/id (:payment/vendor check)))
|
||||
})]
|
||||
|
||||
|
||||
(d/transact (d/connect uri))))
|
||||
|
||||
Reference in New Issue
Block a user