Sales orders works correctly now.
This commit is contained in:
@@ -135,7 +135,17 @@
|
|||||||
:add-category {:txes [[{:db/ident :order-line-item/category
|
:add-category {:txes [[{:db/ident :order-line-item/category
|
||||||
:db/doc "The item category"
|
:db/doc "The item category"
|
||||||
:db/valueType :db.type/string
|
:db/valueType :db.type/string
|
||||||
:db/cardinality :db.cardinality/one}]]}})
|
:db/cardinality :db.cardinality/one}]]}
|
||||||
|
|
||||||
|
:add-other-types {:txes [[{:db/ident :sales-order/returns
|
||||||
|
:db/doc "The returned amount on the sale"
|
||||||
|
:db/valueType :db.type/double
|
||||||
|
:db/cardinality :db.cardinality/one}
|
||||||
|
|
||||||
|
{:db/ident :sales-order/service-charge
|
||||||
|
:db/doc "The total cost on the item"
|
||||||
|
:db/valueType :db.type/double
|
||||||
|
:db/cardinality :db.cardinality/one}]]}})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -220,6 +220,8 @@
|
|||||||
:tip {:type :money}
|
:tip {:type :money}
|
||||||
:tax {:type :money}
|
:tax {:type :money}
|
||||||
:discount {:type :money}
|
:discount {:type :money}
|
||||||
|
:service_charge {:type :money}
|
||||||
|
:returns {:type :money}
|
||||||
:client {:type :client}
|
:client {:type :client}
|
||||||
:date {:type 'String}
|
:date {:type 'String}
|
||||||
:charges {:type '(list :charge)}
|
:charges {:type '(list :charge)}
|
||||||
|
|||||||
@@ -64,6 +64,8 @@
|
|||||||
:tip
|
:tip
|
||||||
:tax
|
:tax
|
||||||
:discount
|
:discount
|
||||||
|
:returns
|
||||||
|
:service_charge
|
||||||
:date
|
:date
|
||||||
[:charges [:type_name :total :tip]]
|
[:charges [:type_name :total :tip]]
|
||||||
[:line_items [:item_name :total :tax :discount :category]]
|
[:line_items [:item_name :total :tax :discount :category]]
|
||||||
|
|||||||
@@ -120,7 +120,7 @@
|
|||||||
|
|
||||||
(defn location_id->client-location [location]
|
(defn location_id->client-location [location]
|
||||||
({"2RVBYER6QSV7W" ["NGAK" "MH"]
|
({"2RVBYER6QSV7W" ["NGAK" "MH"]
|
||||||
#_#_"8JT71V8XGYAT3" ["NGKG" "NB"]
|
"8JT71V8XGYAT3" ["NGKG" "NB"]
|
||||||
"SCX0Y8CTGM1S0" ["NGE1" "UC"]
|
"SCX0Y8CTGM1S0" ["NGE1" "UC"]
|
||||||
"FNH5VRT890WK8" ["NGMJ" "SC"]
|
"FNH5VRT890WK8" ["NGMJ" "SC"]
|
||||||
"AMQ0NPA8FGDEF" ["NGPG" "SZ"]
|
"AMQ0NPA8FGDEF" ["NGPG" "SZ"]
|
||||||
@@ -132,6 +132,9 @@
|
|||||||
(map :id)
|
(map :id)
|
||||||
(filter location_id->client-location)
|
(filter location_id->client-location)
|
||||||
(mapcat #(search % d))
|
(mapcat #(search % d))
|
||||||
|
(filter (fn [order]
|
||||||
|
(not= #{"FAILED"}
|
||||||
|
(set (map #(:status (:card_details %)) (:tenders order))))))
|
||||||
(map (fn [order]
|
(map (fn [order]
|
||||||
(let [[client loc] (location_id->client-location (:location_id order))]
|
(let [[client loc] (location_id->client-location (:location_id order))]
|
||||||
(remove-nils
|
(remove-nils
|
||||||
@@ -140,13 +143,16 @@
|
|||||||
:client [:client/code client]
|
:client [:client/code client]
|
||||||
:location loc
|
:location loc
|
||||||
:external-id (str "square/order/" client "-" loc "-" (:id order))
|
:external-id (str "square/order/" client "-" loc "-" (:id order))
|
||||||
:total (- (-> order :total_money amount->money)
|
:total (-> order :net_amounts :total_money amount->money)
|
||||||
(or (some-> order :return_amounts :total_money amount->money) 0.0))
|
:tax (-> order :net_amounts :tax_money amount->money)
|
||||||
:tax (- (-> order :total_tax_money amount->money)
|
:tip (-> order :net_amounts :tip_money amount->money)
|
||||||
(or (some-> order :return_amounts :tax_money amount->money) 0.0))
|
:discount (-> order :net_amounts :discount_money amount->money)
|
||||||
:tip (- (-> order :net_amounts :tip_money amount->money)
|
:service-charge (-> order :net_amounts :service_charge_money amount->money)
|
||||||
(or (some-> order :return_amounts :tip_money amount->money) 0.0))
|
:returns (+ (- (-> order :return_amounts :total_money amount->money)
|
||||||
:discount (-> order :total_discount_money amount->money)
|
(-> order :return_amounts :tax_money amount->money)
|
||||||
|
(-> order :return_amounts :tip_money amount->money)
|
||||||
|
(-> order :return_amounts :service_charge_money amount->money)
|
||||||
|
(-> order :return_amounts :discount_money amount->money)))
|
||||||
:charges (->> (:tenders order)
|
:charges (->> (:tenders order)
|
||||||
(map (fn [t]
|
(map (fn [t]
|
||||||
(remove-nils
|
(remove-nils
|
||||||
|
|||||||
@@ -243,22 +243,27 @@
|
|||||||
)))
|
)))
|
||||||
|
|
||||||
(defn get-access-token []
|
(defn get-access-token []
|
||||||
(let [cob-session (login-cobrand)
|
(try
|
||||||
user-session (login-user cob-session)
|
(let [cob-session (login-cobrand)
|
||||||
token (->
|
user-session (login-user cob-session)
|
||||||
(str (:yodlee-base-url env) "/user/accessTokens?appIds=" 10003600)
|
token (->
|
||||||
|
(str (:yodlee-base-url env) "/user/accessTokens?appIds=" 10003600)
|
||||||
|
|
||||||
(client/get
|
(client/get
|
||||||
(merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
(merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
:as :json}
|
:as :json}
|
||||||
other-config))
|
other-config))
|
||||||
:body
|
(doto log/info)
|
||||||
:user
|
:body
|
||||||
:accessTokens
|
:user
|
||||||
first
|
:accessTokens
|
||||||
:value
|
first
|
||||||
)]
|
:value
|
||||||
[user-session token]))
|
)]
|
||||||
|
[user-session token])
|
||||||
|
(catch Exception e
|
||||||
|
(log/error e)
|
||||||
|
(throw e))))
|
||||||
|
|
||||||
(defn create-user []
|
(defn create-user []
|
||||||
(let [cob-session (login-cobrand)]
|
(let [cob-session (login-cobrand)]
|
||||||
|
|||||||
@@ -117,6 +117,13 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::authenticated
|
::authenticated
|
||||||
|
(fn [{:keys [db]} [_ authentication]]
|
||||||
|
{:db (-> db
|
||||||
|
(assoc-in [::yodlee :authentication] authentication)
|
||||||
|
(assoc-in [::yodlee :loading?] false))}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::authenticated-mfa
|
||||||
(fn [{:keys [db]} [_ provider-account-id authentication]]
|
(fn [{:keys [db]} [_ provider-account-id authentication]]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [::yodlee :authentication] authentication)
|
(assoc-in [::yodlee :authentication] authentication)
|
||||||
@@ -221,7 +228,7 @@
|
|||||||
"value" v})
|
"value" v})
|
||||||
(:mfa (:data (get-in db [::forms/forms [::mfa-form provider-account-id]]))))}
|
(:mfa (:data (get-in db [::forms/forms [::mfa-form provider-account-id]]))))}
|
||||||
|
|
||||||
:on-success [::authenticated provider-account-id]
|
:on-success [::authenticated-mfa provider-account-id]
|
||||||
:on-error [::forms/save-error [::mfa-form provider-account-id] ]}}))
|
:on-error [::forms/save-error [::mfa-form provider-account-id] ]}}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
|
|||||||
@@ -26,9 +26,9 @@
|
|||||||
:total-lte (:amount-lte (:total-range params))
|
:total-lte (:amount-lte (:total-range params))
|
||||||
:date-range (:date-range params)
|
:date-range (:date-range params)
|
||||||
:client-id (:id @(re-frame/subscribe [::subs/client]))}
|
:client-id (:id @(re-frame/subscribe [::subs/client]))}
|
||||||
[[:sales-orders [:id :total :tax :tip :date
|
[[:sales-orders [:id :total :tax :tip :discount :service-charge :returns :date
|
||||||
[:charges [:type-name :total]]
|
[:charges [:type-name :total]]
|
||||||
[:line-items [:item-name :total]]
|
[:line-items [:item-name :total :category]]
|
||||||
[:client [:name :id]]]]
|
[:client [:name :id]]]]
|
||||||
:total
|
:total
|
||||||
:start
|
:start
|
||||||
|
|||||||
@@ -63,6 +63,21 @@
|
|||||||
[money-field {:type "money"
|
[money-field {:type "money"
|
||||||
:field [:tax]
|
:field [:tax]
|
||||||
:disabled true}])
|
:disabled true}])
|
||||||
|
(field "Discount"
|
||||||
|
[money-field {:type "money"
|
||||||
|
:field [:discount]
|
||||||
|
:disabled true}])
|
||||||
|
|
||||||
|
(field "Returns"
|
||||||
|
[money-field {:type "money"
|
||||||
|
:field [:returns]
|
||||||
|
:disabled true}])
|
||||||
|
|
||||||
|
(field "Service Charge"
|
||||||
|
[money-field {:type "money"
|
||||||
|
:field [:service-charge]
|
||||||
|
:disabled true}])
|
||||||
|
|
||||||
(field "Tip"
|
(field "Tip"
|
||||||
[money-field {:type "money"
|
[money-field {:type "money"
|
||||||
:field [:tip]
|
:field [:tip]
|
||||||
@@ -76,6 +91,6 @@
|
|||||||
[:h1.subtitle.is-4 "Line Items"]
|
[:h1.subtitle.is-4 "Line Items"]
|
||||||
[:ul
|
[:ul
|
||||||
(for [line-item (:line-items data)]
|
(for [line-item (:line-items data)]
|
||||||
[:li (:item-name line-item) ": " (:total line-item)])]])
|
[:li (:item-name line-item) ": " (:total line-item) [:span.tag (:category line-item)]])]])
|
||||||
{:key (:id data)}))])
|
{:key (:id data)}))])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user