you can now edit invoices.
This commit is contained in:
@@ -63,6 +63,10 @@
|
||||
(defn approve []
|
||||
(j/update! (get-conn) :invoices {:imported true} [] ))
|
||||
|
||||
(defn update [v]
|
||||
(j/update! (get-conn) :invoices v ["id = ?" (:id v)])
|
||||
(get-by-id (:id v)))
|
||||
|
||||
(defn reject []
|
||||
(j/delete! (get-conn) :invoices ["imported = false"]))
|
||||
|
||||
|
||||
@@ -258,6 +258,12 @@
|
||||
:company_id {:type 'Int}
|
||||
:vendor_id {:type 'Int}
|
||||
:vendor_name {:type 'String}
|
||||
:total {:type 'Float}}}
|
||||
|
||||
:edit_invoice
|
||||
{:fields {:id {:type 'Int}
|
||||
:invoice_number {:type 'String}
|
||||
:date {:type 'String}
|
||||
:total {:type 'Float}}}}
|
||||
|
||||
:mutations
|
||||
@@ -281,6 +287,9 @@
|
||||
:add_invoice {:type :invoice
|
||||
:args {:invoice {:type :add_invoice}}
|
||||
:resolve :mutation/add-invoice}
|
||||
:edit_invoice {:type :invoice
|
||||
:args {:invoice {:type :edit_invoice}}
|
||||
:resolve :mutation/edit-invoice}
|
||||
:edit_expense_accounts {:type :invoice
|
||||
:args {:invoice_id {:type 'Int}
|
||||
:expense_accounts {:type '(list :edit_expense_account)}}
|
||||
@@ -494,6 +503,7 @@
|
||||
:mutation/print-checks print-checks
|
||||
:mutation/edit-user gq-users/edit-user
|
||||
:mutation/add-invoice gq-invoices/add-invoice
|
||||
:mutation/edit-invoice gq-invoices/edit-invoice
|
||||
:mutation/edit-expense-accounts gq-invoices/edit-expense-accounts
|
||||
:get-vendor get-vendor
|
||||
:get-expense-account expense-accounts/get-expense-account
|
||||
|
||||
@@ -33,6 +33,17 @@
|
||||
(->graphql))))
|
||||
|
||||
|
||||
(defn edit-invoice [context {{:keys [id] :as in} :invoice} value]
|
||||
(let [invoice (invoices/get-by-id id)
|
||||
paid-amount (- (:total invoice) (:outstanding-balance invoice))
|
||||
_ (assert-can-see-company (:id context) (:company-id invoice))
|
||||
updated-invoice (invoices/update (-> in
|
||||
(update :date parse iso-date)
|
||||
(assoc :outstanding_balance (- (:total in) paid-amount))))]
|
||||
(-> updated-invoice
|
||||
(->graphql))))
|
||||
|
||||
|
||||
(defn get-invoices-expense-accounts [context args value]
|
||||
(->graphql
|
||||
(invoices-expense-accounts/get-for-invoice (:id value))))
|
||||
|
||||
Reference in New Issue
Block a user