Performance improvements for printing checks
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
[clojure.set :as set]
|
||||
[clojure.tools.logging :as log]
|
||||
[datomic.api :as d]
|
||||
[manifold.deferred :as de]))
|
||||
[manifold.deferred :as de]
|
||||
[com.brunobonacci.mulog :as mu]))
|
||||
|
||||
(defn ->graphql [invoice user ]
|
||||
(if (= "admin" (:user/role user))
|
||||
@@ -188,20 +189,24 @@
|
||||
|
||||
|
||||
(defn add-and-print-invoice [context {{:keys [total client_id vendor_id] :as in} :invoice bank-account-id :bank_account_id type :type} _]
|
||||
(assert-no-conflicting in)
|
||||
(assert-can-see-client (:id context) client_id)
|
||||
(assert-bank-account-belongs client_id bank-account-id)
|
||||
(assert-not-locked client_id (:date in))
|
||||
(assert-valid-expense-accounts (:expense_accounts in) vendor_id)
|
||||
(assert-invoice-amounts-add-up in)
|
||||
(mu/trace ::validating-invoice [:invoice in]
|
||||
(do
|
||||
(assert-no-conflicting in)
|
||||
(assert-can-see-client (:id context) client_id)
|
||||
(assert-bank-account-belongs client_id bank-account-id)
|
||||
(assert-not-locked client_id (:date in))
|
||||
(assert-valid-expense-accounts (:expense_accounts in) vendor_id)
|
||||
(assert-invoice-amounts-add-up in)))
|
||||
(let [transaction-result (transact-with-ledger [(add-invoice-transaction in)] (:id context))]
|
||||
(-> (gq-checks/print-checks-internal [{:invoice-id (get-in transaction-result [:tempids "invoice"])
|
||||
:amount total}]
|
||||
client_id
|
||||
bank-account-id
|
||||
type
|
||||
(:id context))
|
||||
u/->graphql)))
|
||||
(mu/trace ::printing-checks
|
||||
[]
|
||||
(-> (gq-checks/print-checks-internal [{:invoice-id (get-in transaction-result [:tempids "invoice"])
|
||||
:amount total}]
|
||||
client_id
|
||||
bank-account-id
|
||||
type
|
||||
(:id context))
|
||||
u/->graphql))))
|
||||
|
||||
(defn edit-invoice [context {{:keys [id due invoice_number vendor_id total date expense_accounts scheduled_payment] :as in} :invoice} _]
|
||||
(let [invoice (d-invoices/get-by-id id)
|
||||
|
||||
Reference in New Issue
Block a user