editing clients has started.
This commit is contained in:
@@ -117,6 +117,10 @@
|
|||||||
:db/valueType :db.type/string
|
:db/valueType :db.type/string
|
||||||
:db/cardinality :db.cardinality/one
|
:db/cardinality :db.cardinality/one
|
||||||
:db/doc "A client's human-friendly name"}
|
:db/doc "A client's human-friendly name"}
|
||||||
|
{:db/ident :client/email
|
||||||
|
:db/valueType :db.type/string
|
||||||
|
:db/cardinality :db.cardinality/one
|
||||||
|
:db/doc "hello@example.com"}
|
||||||
{:db/ident :client/code
|
{:db/ident :client/code
|
||||||
:db/valueType :db.type/string
|
:db/valueType :db.type/string
|
||||||
:db/unique :db.unique/identity
|
:db/unique :db.unique/identity
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
(defn get-all []
|
(defn get-all []
|
||||||
|
|
||||||
(->> (d/q '[:find (pull ?e [*])
|
(->> (d/q '[:find (pull ?e [* {:client/address [*]}])
|
||||||
:where [?e :client/name]]
|
:where [?e :client/name]]
|
||||||
(d/db (d/connect uri)))
|
(d/db (d/connect uri)))
|
||||||
(map first)
|
(map first)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
[auto-ap.datomic.invoices :as d-invoices]
|
[auto-ap.datomic.invoices :as d-invoices]
|
||||||
[auto-ap.datomic.vendors :as d-vendors]
|
[auto-ap.datomic.vendors :as d-vendors]
|
||||||
[auto-ap.graphql.users :as gq-users]
|
[auto-ap.graphql.users :as gq-users]
|
||||||
|
[auto-ap.graphql.clients :as gq-clients]
|
||||||
[auto-ap.graphql.vendors :as gq-vendors]
|
[auto-ap.graphql.vendors :as gq-vendors]
|
||||||
[auto-ap.graphql.checks :as gq-checks]
|
[auto-ap.graphql.checks :as gq-checks]
|
||||||
[auto-ap.graphql.expense-accounts :as expense-accounts]
|
[auto-ap.graphql.expense-accounts :as expense-accounts]
|
||||||
@@ -245,6 +246,21 @@
|
|||||||
:invoice_payment_amount {:fields {:invoice_id {:type :id}
|
:invoice_payment_amount {:fields {:invoice_id {:type :id}
|
||||||
:amount {:type 'Float}}}
|
:amount {:type 'Float}}}
|
||||||
|
|
||||||
|
:edit_client {:fields {:id {:type :id}
|
||||||
|
:name {:type 'String}
|
||||||
|
:email {:type 'String}
|
||||||
|
:address {:type :add_address}
|
||||||
|
:locations {:type '(list String)}
|
||||||
|
:bank_accounts {:type '(list :edit_bank_account)}}}
|
||||||
|
:edit_bank_account
|
||||||
|
{:fields {:id {:type :id }
|
||||||
|
:type {:type :bank_account_type}
|
||||||
|
:number {:type 'String}
|
||||||
|
:check_number {:type 'Int}
|
||||||
|
:name {:type 'String}
|
||||||
|
:bank_code {:type 'String}
|
||||||
|
:bank_name {:type 'String}
|
||||||
|
:yodlee_account_id {:type 'Int}}}
|
||||||
:edit_user
|
:edit_user
|
||||||
{:fields {:id {:type :id}
|
{:fields {:id {:type :id}
|
||||||
:name {:type 'String}
|
:name {:type 'String}
|
||||||
@@ -322,6 +338,10 @@
|
|||||||
:args {:edit_user {:type :edit_user}}
|
:args {:edit_user {:type :edit_user}}
|
||||||
:resolve :mutation/edit-user}
|
:resolve :mutation/edit-user}
|
||||||
|
|
||||||
|
:edit_client {:type :client
|
||||||
|
:args {:edit_client {:type :edit_client}}
|
||||||
|
:resolve :mutation/edit-client}
|
||||||
|
|
||||||
:upsert_vendor {:type :vendor
|
:upsert_vendor {:type :vendor
|
||||||
:args {:vendor {:type :add_vendor}}
|
:args {:vendor {:type :add_vendor}}
|
||||||
:resolve :mutation/upsert-vendor}
|
:resolve :mutation/upsert-vendor}
|
||||||
@@ -392,10 +412,7 @@
|
|||||||
:limit Integer/MAX_VALUE))))
|
:limit Integer/MAX_VALUE))))
|
||||||
|
|
||||||
|
|
||||||
(defn get-client [context args value]
|
|
||||||
(->graphql
|
|
||||||
(filter #(can-see-client? (:id context) %)
|
|
||||||
(d-clients/get-all))))
|
|
||||||
|
|
||||||
(defn get-user [context args value]
|
(defn get-user [context args value]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
@@ -429,13 +446,14 @@
|
|||||||
:get-payment-page gq-checks/get-payment-page
|
:get-payment-page gq-checks/get-payment-page
|
||||||
:get-transaction-page gq-transactions/get-transaction-page
|
:get-transaction-page gq-transactions/get-transaction-page
|
||||||
|
|
||||||
:get-client get-client
|
:get-client gq-clients/get-client
|
||||||
:get-user get-user
|
:get-user get-user
|
||||||
:mutation/add-handwritten-check gq-checks/add-handwritten-check
|
:mutation/add-handwritten-check gq-checks/add-handwritten-check
|
||||||
:mutation/print-checks print-checks
|
:mutation/print-checks print-checks
|
||||||
:mutation/edit-user gq-users/edit-user
|
:mutation/edit-user gq-users/edit-user
|
||||||
:mutation/add-invoice gq-invoices/add-invoice
|
:mutation/add-invoice gq-invoices/add-invoice
|
||||||
:mutation/edit-invoice gq-invoices/edit-invoice
|
:mutation/edit-invoice gq-invoices/edit-invoice
|
||||||
|
:mutation/edit-client gq-clients/edit-client
|
||||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||||
:mutation/void-invoice gq-invoices/void-invoice
|
:mutation/void-invoice gq-invoices/void-invoice
|
||||||
:mutation/void-payment gq-checks/void-check
|
:mutation/void-payment gq-checks/void-check
|
||||||
|
|||||||
@@ -320,8 +320,6 @@
|
|||||||
base-payment (base-payment [invoice] (:invoice/vendor invoice)
|
base-payment (base-payment [invoice] (:invoice/vendor invoice)
|
||||||
(:invoice/client invoice)
|
(:invoice/client invoice)
|
||||||
bank-account :payment-type/check 0 {(:invoice_id args) (:amount args)})]
|
bank-account :payment-type/check 0 {(:invoice_id args) (:amount args)})]
|
||||||
|
|
||||||
|
|
||||||
@(d/transact (d/connect uri)
|
@(d/transact (d/connect uri)
|
||||||
(into [(assoc base-payment
|
(into [(assoc base-payment
|
||||||
:payment/type :payment-type/check
|
:payment/type :payment-type/check
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
:graphql {:token token
|
:graphql {:token token
|
||||||
:query-obj {:venia/queries [[:client
|
:query-obj {:venia/queries [[:client
|
||||||
|
|
||||||
[:id :name :locations [:bank-accounts [:id :number :check-number :name :type] ]
|
[:id :name :email :locations [:bank-accounts [:id :number :check-number :name :type] ]
|
||||||
[:address [:street1 :street2 :city :state :zip]]]]
|
[:address [:street1 :street2 :city :state :zip]]]]
|
||||||
[:vendor
|
[:vendor
|
||||||
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
(fn [{:keys [db]} [_ token user]]
|
(fn [{:keys [db]} [_ token user]]
|
||||||
{:graphql {:token token
|
{:graphql {:token token
|
||||||
:query-obj {:venia/queries [[:client
|
:query-obj {:venia/queries [[:client
|
||||||
[:id :name [:bank-accounts [:id :number :check-number :name :type]]]]
|
[:id :name [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :type]]]]
|
||||||
[:vendor
|
[:vendor
|
||||||
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::edit
|
::edit
|
||||||
(fn [{:keys [db]} [_ client-id]]
|
(fn [{:keys [db]} [_ client-id]]
|
||||||
|
(println "EDITING")
|
||||||
{:dispatch [::events/modal-status :auto-ap.views.pages.admin.clients/edit {:visible? true}]
|
{:dispatch [::events/modal-status :auto-ap.views.pages.admin.clients/edit {:visible? true}]
|
||||||
:db (assoc-in db [:admin :client]
|
:db (assoc-in db [:admin :client]
|
||||||
(get (:clients db) client-id))}))
|
(get (:clients db) client-id))}))
|
||||||
@@ -17,15 +18,18 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::save
|
::save
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
|
(println "saving")
|
||||||
(let [edited-client (-> (get-in db [:admin :clients])
|
(let [edited-client (-> (get-in db [:admin :clients])
|
||||||
(dissoc :location))]
|
(dissoc :location))]
|
||||||
|
|
||||||
{:db (assoc-in db [:admin :client :saving?] true)
|
{:db (assoc-in db [:admin :client :saving?] true)
|
||||||
:http {:method :put
|
:graphql
|
||||||
:token (:user db)
|
{:token (-> db :user)
|
||||||
:body (pr-str edited-client)
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
:headers {"Content-Type" "application/edn"}
|
:operation/name "EditClient"}
|
||||||
:uri (str "/api/clients/" (:id edited-client))
|
:venia/queries [{:query/data [:upsert-client
|
||||||
|
{:client edited-client}
|
||||||
|
[:id :name]
|
||||||
|
]}]}
|
||||||
:on-success [::save-complete]
|
:on-success [::save-complete]
|
||||||
:on-error [::save-error]}})))
|
:on-error [::save-error]}})))
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,16 @@
|
|||||||
::save
|
::save
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(let [edited-client (-> (get-in db [:admin :client])
|
(let [edited-client (-> (get-in db [:admin :client])
|
||||||
(dissoc :location)
|
(dissoc :location))]
|
||||||
(dissoc :new-account))]
|
|
||||||
|
|
||||||
{:db (assoc-in db [:admin :client :saving?] true)
|
{:db (assoc-in db [:admin :client :saving?] true)
|
||||||
:http {:method :put
|
:graphql
|
||||||
:token (:user db)
|
{:token (-> db :user)
|
||||||
:body (pr-str edited-client)
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
:headers {"Content-Type" "application/edn"}
|
:operation/name "EditClient"}
|
||||||
:uri (str "/api/clients/" (:id edited-client))
|
:venia/queries [{:query/data [:edit-client
|
||||||
|
{:edit-client edited-client}
|
||||||
|
[:id :name]
|
||||||
|
]}]}
|
||||||
:on-success [::save-complete]
|
:on-success [::save-complete]
|
||||||
:on-error [::save-error]}})))
|
:on-error [::save-error]}})))
|
||||||
|
|
||||||
@@ -151,6 +152,7 @@
|
|||||||
^{:key location} [:li location ])]]]
|
^{:key location} [:li location ])]]]
|
||||||
[:h2.subtitle "Address"]
|
[:h2.subtitle "Address"]
|
||||||
|
|
||||||
|
|
||||||
[address-field {:field [:address]
|
[address-field {:field [:address]
|
||||||
:event ::change
|
:event ::change
|
||||||
:subscription editing-client}]
|
:subscription editing-client}]
|
||||||
|
|||||||
Reference in New Issue
Block a user