renamed company to client.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(ns auto-ap.graphql.invoices
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-company assert-admin]]
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin]]
|
||||
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.datomic.invoices :as d-invoices]
|
||||
@@ -34,7 +34,7 @@
|
||||
:invoice/vendor vendor_id
|
||||
:invoice/client client_id}))
|
||||
(throw (ex-info (str "Invoice '" invoice_number "' already exists.") {:invoice-number invoice_number})))
|
||||
(let [_ (assert-can-see-company (:id context) client_id)
|
||||
(let [_ (assert-can-see-client (:id context) client_id)
|
||||
vendor (d-vendors/get-by-id vendor_id)
|
||||
|
||||
expense-account-id (:vendor/default-expense-account vendor)
|
||||
@@ -59,7 +59,7 @@
|
||||
(->graphql))))
|
||||
|
||||
|
||||
(defn edit-invoice [context {{:keys [id invoice_number total vendor_id date company_id] :as in} :invoice} value]
|
||||
(defn edit-invoice [context {{:keys [id invoice_number total vendor_id date client_id] :as in} :invoice} value]
|
||||
|
||||
|
||||
(let [invoice (d-invoices/get-by-id id)
|
||||
@@ -71,7 +71,7 @@
|
||||
println))
|
||||
(throw (ex-info (str "Invoice '" invoice_number "' already exists.") {:invoice-number invoice_number})))
|
||||
paid-amount (- (:invoice/total invoice) (:invoice/outstanding-balance invoice))
|
||||
_ (assert-can-see-company (:id context) (:db/id (:client invoice)))
|
||||
_ (assert-can-see-client (:id context) (:db/id (:invoice/client invoice)))
|
||||
updated-invoice (d-invoices/update {:db/id id
|
||||
:invoice/invoice-number invoice_number
|
||||
:invoice/date (coerce/to-date (parse date iso-date))
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
(defn void-invoice [context {id :invoice_id} value]
|
||||
(let [invoice (d-invoices/get-by-id id)
|
||||
_ (assert-can-see-company (:id context) (:company-id invoice))
|
||||
_ (assert-can-see-client (:id context) (:client-id invoice))
|
||||
updated-invoice (d-invoices/update {:db/id id
|
||||
:invoice/total 0.0
|
||||
:invoice/outstanding-balance 0.0
|
||||
@@ -98,7 +98,7 @@
|
||||
(defn edit-expense-accounts [context args value]
|
||||
;; TODO - Can expense account id be used as a unique field? It may compose with component, meaning
|
||||
;; that you don't have to figure out which ones to delete and which ones to add. Just set to 0.
|
||||
(assert-can-see-company (:id context) (:db/id (:client (d-invoices/get-by-id (:invoice_id args)))))
|
||||
(assert-can-see-client (:id context) (:db/id (:invoice/client (d-invoices/get-by-id (:invoice_id args)))))
|
||||
(let [current-expense-accounts (:invoice/expense-accounts (d-invoices/get-by-id (:invoice_id args)))
|
||||
invoice-id (:invoice_id args)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user