switched from auto pay to scheduled payment

This commit is contained in:
Bryce Covert
2020-09-24 08:06:17 -07:00
parent 4ab492d759
commit c5ed61b2e1
16 changed files with 918 additions and 39 deletions

View File

@@ -56,7 +56,7 @@
:account account_id
:location location}))
(defn add-invoice-transaction [{:keys [total invoice_number location automatically_paid_when_due client_id vendor_id vendor_name date due expense_accounts] :as in}]
(defn add-invoice-transaction [{:keys [total invoice_number location scheduled_payment client_id vendor_id vendor_name date due expense_accounts] :as in}]
(let [vendor (d-vendors/get-by-id vendor_id)
account (:vendor/default-account vendor)
_ (when-not (:db/id account)
@@ -76,7 +76,8 @@
(:vendor/terms vendor) (assoc :invoice/due (coerce/to-date
(time/plus date (time/days (d-vendors/terms-for-client-id vendor client_id)))))
due (assoc :invoice/due (coerce/to-date due))
(boolean? automatically_paid_when_due) (assoc :invoice/automatically-paid-when-due automatically_paid_when_due))))
scheduled_payment (assoc :invoice/scheduled-payment (coerce/to-date scheduled_payment)))))
(defn deleted-expense-accounts [invoice expense-accounts]
@@ -121,7 +122,7 @@
->graphql)))
(defn edit-invoice [context {{:keys [id due invoice_number total vendor_id date client_id expense_accounts automatically_paid_when_due] :as in} :invoice} value]
(defn edit-invoice [context {{:keys [id due invoice_number total vendor_id date client_id expense_accounts scheduled_payment] :as in} :invoice} value]
(let [invoice (d-invoices/get-by-id id)
_ (when (seq (d-invoices/find-conflicting {:db/id id
:invoice/invoice-number invoice_number
@@ -146,7 +147,7 @@
:invoice/expense-accounts (map expense-account->entity
expense_accounts)}
due (assoc :invoice/due (coerce/to-date due))
(boolean? automatically_paid_when_due) (assoc :invoice/automatically-paid-when-due automatically_paid_when_due))]
scheduled_payment (assoc :invoice/scheduled-payment (coerce/to-date scheduled_payment)))]
(audit-transact (concat [updated-invoice]
(map (fn [d] [:db/retract id :invoice/expense-accounts d]) deleted))
(:id context))