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))))))))
|
||||
|
||||
Reference in New Issue
Block a user