(cloud) moves pay to datomic ions.
This commit is contained in:
@@ -391,3 +391,13 @@
|
||||
(if journal-entry
|
||||
(upsert-ledger db journal-entry)
|
||||
[[: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)})))
|
||||
|
||||
Reference in New Issue
Block a user