(cloud) moves pay to datomic ions.

This commit is contained in:
2023-04-03 09:08:52 -07:00
parent 6622aae589
commit 94d8346bac
4 changed files with 15 additions and 8 deletions

View File

@@ -391,3 +391,13 @@
(if journal-entry (if journal-entry
(upsert-ledger db journal-entry) (upsert-ledger db journal-entry)
[[:db/retractEntity [:journal-entry/original-entity (:db/id transaction)]]])))) [[:db/retractEntity [:journal-entry/original-entity (:db/id transaction)]]]))))
(defn pay [db e amount]
(let [current-outstanding-balance (-> (dc/pull db [:invoice/outstanding-balance] e) :invoice/outstanding-balance)
new-outstanding-balance (- current-outstanding-balance amount)]
(upsert-invoice db {:db/id e
:invoice/outstanding-balance new-outstanding-balance
:invoice/status (if (> new-outstanding-balance 0)
:invoice-status/unpaid
:invoice-status/paid)})))

View File

@@ -5,7 +5,8 @@
iol-ion.tx/min-by iol-ion.tx/min-by
iol-ion.tx/propose-invoice iol-ion.tx/propose-invoice
iol-ion.tx/upsert-invoice iol-ion.tx/upsert-invoice
iol-ion.tx/upsert-transaction
iol-ion.tx/pay
iol-ion.query/dollars= iol-ion.query/dollars=
iol-ion.query/dollars-0?] iol-ion.query/dollars-0?]
:app-name "iol-cloud"} :app-name "iol-cloud"}

View File

@@ -3,7 +3,7 @@
[amazonica.aws.s3 :as s3] [amazonica.aws.s3 :as s3]
[auto-ap.datomic :refer [conn remove-nils plus pull-many audit-transact]] [auto-ap.datomic :refer [conn remove-nils plus pull-many audit-transact]]
[auto-ap.datomic.accounts :as a] [auto-ap.datomic.accounts :as a]
[iol-ion.tx :refer [upsert-invoice]] [iol-ion.tx :refer [upsert-invoice pay]]
[auto-ap.datomic.bank-accounts :as d-bank-accounts] [auto-ap.datomic.bank-accounts :as d-bank-accounts]
[auto-ap.datomic.checks :as d-checks] [auto-ap.datomic.checks :as d-checks]
[auto-ap.datomic.clients :as d-clients] [auto-ap.datomic.clients :as d-clients]
@@ -230,7 +230,7 @@
[{:invoice-payment/payment (-> invoice :invoice/vendor :db/id str) [{:invoice-payment/payment (-> invoice :invoice/vendor :db/id str)
:invoice-payment/amount invoice-amount :invoice-payment/amount invoice-amount
:invoice-payment/invoice (:db/id invoice)} :invoice-payment/invoice (:db/id invoice)}
`(d-checks/pay ~(:db/id invoice) ~invoice-amount)]) `(pay ~(:db/id invoice) ~invoice-amount)])
(reduce into []))) (reduce into [])))
(defn base-payment [invoices vendor client bank-account _ _ invoice-amounts] (defn base-payment [invoices vendor client bank-account _ _ invoice-amounts]
@@ -759,8 +759,7 @@
:mutation/void-payments void-payments :mutation/void-payments void-payments
:mutation/print-checks print-checks :mutation/print-checks print-checks
:mutation/pay-invoices-from-balance pay-invoices-from-balance :mutation/pay-invoices-from-balance pay-invoices-from-balance
:mutation/add-handwritten-check add-handwritten-check :mutation/add-handwritten-check add-handwritten-check})
})
(defn attach [schema] (defn attach [schema]
(-> (->

View File

@@ -1,6 +1,3 @@
* try again to see if we can get upsert-ledger into the same transaction, making it all or nothing
* look for all usages of transact-with-ledger
it looks like there are a bbunch of orrphaned customizations for accounts, breaking indexes it looks like there are a bbunch of orrphaned customizations for accounts, breaking indexes
upsertledger - matching transaction rule might not assign an account. Other things might not assign accounts. This is an assertion that is commented out. Determine consequence of disabling upsertledger - matching transaction rule might not assign an account. Other things might not assign accounts. This is an assertion that is commented out. Determine consequence of disabling
Double check each job still functions in the new system Double check each job still functions in the new system