supports terms.
This commit is contained in:
@@ -261,8 +261,8 @@
|
||||
:invoice_number {:type 'String}
|
||||
:status {:type 'String}
|
||||
:expense_accounts {:type '(list :invoices_expense_accounts)}
|
||||
:date {:type 'String}
|
||||
:due {:type 'String}
|
||||
:date {:type :iso_date}
|
||||
:due {:type :iso_date}
|
||||
:client_id {:type 'Int}
|
||||
:payments {:type '(list :invoice_payment)}
|
||||
:vendor {:type :vendor}
|
||||
@@ -541,8 +541,9 @@
|
||||
{:fields {:id {:type :id}
|
||||
:invoice_number {:type 'String}
|
||||
:expense_accounts {:type '(list :edit_expense_account)}
|
||||
:location {:type 'String}
|
||||
:location {:type :iso_date}
|
||||
:date {:type :iso_date}
|
||||
:due {:type :iso_date}
|
||||
:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:vendor_name {:type 'String}
|
||||
@@ -552,7 +553,8 @@
|
||||
{:fields {:id {:type :id}
|
||||
:invoice_number {:type 'String}
|
||||
:expense_accounts {:type '(list :edit_expense_account)}
|
||||
:date {:type 'String}
|
||||
:date {:type :iso_date}
|
||||
:due {:type :iso_date}
|
||||
:total {:type 'Float}}}
|
||||
:edit_transaction
|
||||
{:fields {:id {:type :id}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
:account account_id
|
||||
:location location}))
|
||||
|
||||
(defn add-invoice-transaction [{:keys [total invoice_number location client_id vendor_id vendor_name date expense_accounts] :as in}]
|
||||
(defn add-invoice-transaction [{:keys [total invoice_number location client_id vendor_id vendor_name date due expense_accounts] :as in}]
|
||||
(println date)
|
||||
(let [vendor (d-vendors/get-by-id vendor_id)
|
||||
account (:vendor/default-account vendor)
|
||||
@@ -75,7 +75,8 @@
|
||||
:invoice/expense-accounts (map expense-account->entity
|
||||
expense_accounts)}
|
||||
(:vendor/terms vendor) (assoc :invoice/due (coerce/to-date
|
||||
(time/plus date (time/days (:vendor/terms vendor))))))))
|
||||
(time/plus date (time/days (:vendor/terms vendor)))))
|
||||
due (assoc :invoice/due (doto (coerce/to-date due) println)))))
|
||||
|
||||
|
||||
(defn deleted-expense-accounts [invoice expense-accounts]
|
||||
@@ -114,7 +115,7 @@
|
||||
->graphql)))
|
||||
|
||||
|
||||
(defn edit-invoice [context {{:keys [id invoice_number total vendor_id date client_id expense_accounts] :as in} :invoice} value]
|
||||
(defn edit-invoice [context {{:keys [id due invoice_number total vendor_id date client_id expense_accounts] :as in} :invoice} value]
|
||||
(let [invoice (d-invoices/get-by-id id)
|
||||
_ (when (seq (doto (d-invoices/find-conflicting {:db/id id
|
||||
:invoice/invoice-number invoice_number
|
||||
@@ -131,13 +132,14 @@
|
||||
_ (assert-can-see-client (:id context) (:db/id (:invoice/client invoice)))
|
||||
deleted (deleted-expense-accounts invoice expense_accounts)
|
||||
|
||||
updated-invoice {:db/id id
|
||||
:invoice/invoice-number invoice_number
|
||||
:invoice/date (coerce/to-date (parse date iso-date))
|
||||
:invoice/total total
|
||||
:invoice/outstanding-balance (- total paid-amount)
|
||||
:invoice/expense-accounts (map expense-account->entity
|
||||
expense_accounts)}]
|
||||
updated-invoice (cond-> {:db/id id
|
||||
:invoice/invoice-number invoice_number
|
||||
:invoice/date (coerce/to-date date)
|
||||
:invoice/total total
|
||||
:invoice/outstanding-balance (- total paid-amount)
|
||||
:invoice/expense-accounts (map expense-account->entity
|
||||
expense_accounts)}
|
||||
due (assoc :invoice/due (coerce/to-date due)))]
|
||||
@(d/transact (d/connect uri) (concat [updated-invoice]
|
||||
(map (fn [d] [:db/retract id :invoice/expense-accounts d]) deleted)))
|
||||
(-> (d-invoices/get-by-id id)
|
||||
|
||||
Reference in New Issue
Block a user