a lot of progress on typeaheads, etc.
This commit is contained in:
17
src/clj/auto_ap/graphql/invoices.clj
Normal file
17
src/clj/auto_ap/graphql/invoices.clj
Normal file
@@ -0,0 +1,17 @@
|
||||
(ns auto-ap.graphql.invoices
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql]]
|
||||
[auto-ap.db.invoices :as invoices]
|
||||
[auto-ap.time :refer [parse normal-date]]))
|
||||
|
||||
(defn add-invoice [context {{:keys [total invoice_number company_id vendor_id date] :as in} :invoice} value]
|
||||
|
||||
(-> (invoices/insert-multi! [{:invoice-number invoice_number
|
||||
:company-id company_id
|
||||
:vendor-id vendor_id
|
||||
:total total
|
||||
:outstanding-balance total
|
||||
:status "unpaid"
|
||||
:imported true
|
||||
:date (parse date normal-date)}])
|
||||
(first)
|
||||
(->graphql)))
|
||||
@@ -1,8 +1,9 @@
|
||||
(ns auto-ap.graphql.users
|
||||
(:require [auto-ap.db.users :as users]))
|
||||
|
||||
(defn edit-user [user]
|
||||
(users/update! user)
|
||||
(users/get-by-id (:id user)))
|
||||
(:require [auto-ap.db.users :as users]
|
||||
[auto-ap.graphql.utils :refer [->graphql]]))
|
||||
|
||||
(defn edit-user [context args value]
|
||||
(users/update! (:edit_user args))
|
||||
(->graphql
|
||||
(users/get-by-id (:edit_user args))))
|
||||
|
||||
|
||||
40
src/clj/auto_ap/graphql/utils.clj
Normal file
40
src/clj/auto_ap/graphql/utils.clj
Normal file
@@ -0,0 +1,40 @@
|
||||
(ns auto-ap.graphql.utils
|
||||
(:require [clojure.string :as str]
|
||||
[clojure.walk :as walk]))
|
||||
|
||||
|
||||
(defn snake->kebab [s]
|
||||
(str/replace s #"_" "-"))
|
||||
|
||||
(defn kebab [x]
|
||||
(keyword (snake->kebab (name x))))
|
||||
|
||||
(defn kebab->snake [s]
|
||||
(str/replace s #"-" "_"))
|
||||
|
||||
(defn snake [x]
|
||||
(keyword (kebab->snake (name x))))
|
||||
|
||||
(defn ->graphql [m]
|
||||
(walk/postwalk
|
||||
(fn [node]
|
||||
(cond
|
||||
|
||||
(keyword? node)
|
||||
(snake node)
|
||||
|
||||
:else
|
||||
node))
|
||||
m))
|
||||
|
||||
(defn <-graphql [m]
|
||||
(walk/postwalk
|
||||
(fn [node]
|
||||
(cond
|
||||
|
||||
(keyword? node)
|
||||
(kebab node)
|
||||
|
||||
:else
|
||||
node))
|
||||
m))
|
||||
Reference in New Issue
Block a user