Most parts of staging ought to work
This commit is contained in:
@@ -34,27 +34,44 @@
|
||||
|
||||
(def integreat-schema
|
||||
{
|
||||
:scalars {:id {:parse (schema/as-conformer #(when % (Long/parseLong %)))
|
||||
:serialize (schema/as-conformer #(.toString %))}
|
||||
:ident {:parse (schema/as-conformer (fn [x] {:db/ident x}))
|
||||
:serialize (schema/as-conformer #(or (:ident %) (:db/ident %) %))}
|
||||
:iso_date {:parse (schema/as-conformer #(time/parse % time/iso-date))
|
||||
:serialize (schema/as-conformer #(time/unparse % time/iso-date))}
|
||||
:money {:parse (schema/as-conformer #(if (and (string? %)
|
||||
(not (str/blank? %)))
|
||||
(Double/parseDouble %)
|
||||
%))
|
||||
:serialize (schema/as-conformer #(if (double? %)
|
||||
(str %)
|
||||
%))
|
||||
:scalars {:id {:parse #(when % (Long/parseLong %))
|
||||
:serialize #(.toString %)}
|
||||
:ident {:parse (fn [x] {:db/ident x})
|
||||
:serialize #(or (:ident %) (:db/ident %) %)}
|
||||
:iso_date {:parse #(time/parse % time/iso-date)
|
||||
:serialize #(time/unparse % time/iso-date)}
|
||||
:money {:parse #(do
|
||||
(log/info "parsing money...")
|
||||
(cond (and (string? %)
|
||||
(not (str/blank? %)))
|
||||
(Double/parseDouble %)
|
||||
|
||||
(int? %)
|
||||
(double %)
|
||||
|
||||
:else
|
||||
%))
|
||||
:serialize #(cond (double? %)
|
||||
(str %)
|
||||
|
||||
(int? %)
|
||||
(str %)
|
||||
|
||||
:else
|
||||
%)
|
||||
}
|
||||
:percentage {:parse (schema/as-conformer #(if (and (string? %)
|
||||
(not (str/blank? %)))
|
||||
(Double/parseDouble %)
|
||||
%))
|
||||
:serialize (schema/as-conformer #(if (double? %)
|
||||
(str %)
|
||||
%))}}
|
||||
:percentage {:parse #(cond (and (string? %)
|
||||
(not (str/blank? %)))
|
||||
(Double/parseDouble %)
|
||||
|
||||
(int? %)
|
||||
(str %)
|
||||
|
||||
:else
|
||||
%)
|
||||
:serialize #(if (double? %)
|
||||
(str %)
|
||||
%)}}
|
||||
:objects
|
||||
{
|
||||
:message
|
||||
@@ -648,7 +665,7 @@
|
||||
:external_id_like {:type 'String}
|
||||
:sort {:type '(list :sort_item)}}}
|
||||
:invoice_payment_amount {:fields {:invoice_id {:type :id}
|
||||
:amount {:type 'Float}}}
|
||||
:amount {:type :money}}}
|
||||
:edit_location_match {:fields {:location {:type 'String}
|
||||
:match {:type 'String}
|
||||
:id {:type :id}}}
|
||||
@@ -766,20 +783,20 @@
|
||||
{:fields {:id {:type :id}
|
||||
:account_id {:type :id}
|
||||
:location {:type 'String}
|
||||
:amount {:type 'String}}}
|
||||
:amount {:type :money}}}
|
||||
|
||||
:add_invoice
|
||||
{:fields {:id {:type :id}
|
||||
:invoice_number {:type 'String}
|
||||
:expense_accounts {:type '(list :edit_expense_account)}
|
||||
:location {:type :iso_date}
|
||||
:location {:type 'String}
|
||||
:scheduled_payment {:type :iso_date}
|
||||
:date {:type :iso_date}
|
||||
:due {:type :iso_date}
|
||||
:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:vendor_name {:type 'String}
|
||||
:total {:type 'Float}}}
|
||||
:total {:type :money}}}
|
||||
|
||||
:edit_invoice
|
||||
{:fields {:id {:type :id}
|
||||
@@ -788,7 +805,7 @@
|
||||
:date {:type :iso_date}
|
||||
:scheduled_payment {:type :iso_date}
|
||||
:due {:type :iso_date}
|
||||
:total {:type 'Float}}}
|
||||
:total {:type :money}}}
|
||||
:edit_transaction
|
||||
{:fields {:id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
@@ -1285,9 +1302,16 @@
|
||||
result)
|
||||
|
||||
(catch Exception e
|
||||
(if-let [v (:validation-error (ex-data e))]
|
||||
(warn-event "validation error" {:validation-error v
|
||||
:data (ex-data e)})
|
||||
(error-event "query error" {:error e}))
|
||||
|
||||
(if-let [v (or (:validation-error (ex-data e))
|
||||
(:validation-error (ex-data (.getCause e)))
|
||||
)]
|
||||
(do
|
||||
(warn-event "validation error" {:validation-error v
|
||||
:data (ex-data e)})
|
||||
(throw (Exception. v))
|
||||
#_{:errors [{:message v}]})
|
||||
(do
|
||||
(error-event "query error" {:error e})
|
||||
|
||||
(throw e))))))
|
||||
(throw e))))))))
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
(defn expense-account->entity [{:keys [id account_id amount location]}]
|
||||
|
||||
|
||||
(remove-nils #:invoice-expense-account {:amount (Double/parseDouble amount)
|
||||
(remove-nils #:invoice-expense-account {:amount amount
|
||||
:db/id id
|
||||
:account account_id
|
||||
:location location}))
|
||||
@@ -160,7 +160,7 @@
|
||||
:invoice/client (:db/id (:invoice/client invoice))}))
|
||||
(throw (ex-info (str "Invoice '" invoice_number "' already exists.") {:invoice-number invoice_number})))
|
||||
|
||||
expense-account-total (reduce + 0 (map (fn [x] (Double/parseDouble (:amount x))) expense_accounts))
|
||||
expense-account-total (reduce + 0 (map (fn [x] (:amount x)) expense_accounts))
|
||||
_ (when-not (dollars= total expense-account-total)
|
||||
(let [error (str "Expense account total (" expense-account-total ") does not equal invoice total (" total ")")]
|
||||
(throw (ex-info error {:validation-error error}))))
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
|
||||
|
||||
(defn transaction-account->entity [{:keys [id account_id amount location]}]
|
||||
(remove-nils #:transaction-account {:amount (Double/parseDouble amount)
|
||||
(remove-nils #:transaction-account {:amount amount
|
||||
:db/id id
|
||||
:account account_id
|
||||
:location location}))
|
||||
@@ -163,7 +163,7 @@
|
||||
_ (assert-can-see-client (:id context) (:transaction/client existing-transaction) )
|
||||
_ (assert-valid-expense-accounts accounts)
|
||||
deleted (deleted-accounts existing-transaction accounts)
|
||||
account-total (reduce + 0 (map (fn [x] (Double/parseDouble (:amount x))) accounts))
|
||||
account-total (reduce + 0 (map (fn [x] (:amount x)) accounts))
|
||||
missing-locations (seq (set/difference
|
||||
(->> accounts
|
||||
(map :location)
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
(do (log/error "GraphQL error" e)
|
||||
{:status 500
|
||||
:body (pr-str {:errors [(merge {:message (str "Unhandled error:" (str e))} (ex-data e))]})
|
||||
:body (pr-str {:errors [(merge {:message (str "Unhandled error:" (str e))} #_(ex-data e))]})
|
||||
:headers {"Content-Type" "application/edn"}}))))))
|
||||
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
:signature-data (:signature-data new-client-data)
|
||||
:forecasted-transactions (map (fn [{:keys [id day-of-month identifier amount]}]
|
||||
{:id id
|
||||
:day-of-month day-of-month
|
||||
:day-of-month (js/parseInt day-of-month)
|
||||
:identifier identifier
|
||||
:amount amount})
|
||||
(:forecasted-transactions new-client-data))
|
||||
@@ -159,11 +159,10 @@
|
||||
(let [new-client-req @(re-frame/subscribe [::new-client-request])
|
||||
user @(re-frame/subscribe [::subs/token])]
|
||||
|
||||
{:db (-> new-client-form
|
||||
(assoc :status :loading)
|
||||
(assoc :error nil))
|
||||
{:db (-> new-client-form)
|
||||
:graphql
|
||||
{:token user
|
||||
:owns-state {:single ::form}
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "EditClient"}
|
||||
:venia/queries [{:query/data [:edit-client
|
||||
|
||||
Reference in New Issue
Block a user