Sales orders works correctly now.

This commit is contained in:
Bryce Covert
2020-12-11 11:40:17 -08:00
parent 173242f229
commit e2ae7a6d4f
8 changed files with 75 additions and 28 deletions

View File

@@ -135,7 +135,17 @@
:add-category {:txes [[{:db/ident :order-line-item/category
:db/doc "The item category"
: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}]]}})

View File

@@ -220,6 +220,8 @@
:tip {:type :money}
:tax {:type :money}
:discount {:type :money}
:service_charge {:type :money}
:returns {:type :money}
:client {:type :client}
:date {:type 'String}
:charges {:type '(list :charge)}

View File

@@ -64,6 +64,8 @@
:tip
:tax
:discount
:returns
:service_charge
:date
[:charges [:type_name :total :tip]]
[:line_items [:item_name :total :tax :discount :category]]

View File

@@ -120,7 +120,7 @@
(defn location_id->client-location [location]
({"2RVBYER6QSV7W" ["NGAK" "MH"]
#_#_"8JT71V8XGYAT3" ["NGKG" "NB"]
"8JT71V8XGYAT3" ["NGKG" "NB"]
"SCX0Y8CTGM1S0" ["NGE1" "UC"]
"FNH5VRT890WK8" ["NGMJ" "SC"]
"AMQ0NPA8FGDEF" ["NGPG" "SZ"]
@@ -132,6 +132,9 @@
(map :id)
(filter location_id->client-location)
(mapcat #(search % d))
(filter (fn [order]
(not= #{"FAILED"}
(set (map #(:status (:card_details %)) (:tenders order))))))
(map (fn [order]
(let [[client loc] (location_id->client-location (:location_id order))]
(remove-nils
@@ -140,13 +143,16 @@
:client [:client/code client]
:location loc
:external-id (str "square/order/" client "-" loc "-" (:id order))
:total (- (-> order :total_money amount->money)
(or (some-> order :return_amounts :total_money amount->money) 0.0))
:tax (- (-> order :total_tax_money amount->money)
(or (some-> order :return_amounts :tax_money amount->money) 0.0))
:tip (- (-> order :net_amounts :tip_money amount->money)
(or (some-> order :return_amounts :tip_money amount->money) 0.0))
:discount (-> order :total_discount_money amount->money)
:total (-> order :net_amounts :total_money amount->money)
:tax (-> order :net_amounts :tax_money amount->money)
:tip (-> order :net_amounts :tip_money amount->money)
:discount (-> order :net_amounts :discount_money amount->money)
:service-charge (-> order :net_amounts :service_charge_money amount->money)
:returns (+ (- (-> order :return_amounts :total_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)
(map (fn [t]
(remove-nils

View File

@@ -243,22 +243,27 @@
)))
(defn get-access-token []
(let [cob-session (login-cobrand)
user-session (login-user cob-session)
token (->
(str (:yodlee-base-url env) "/user/accessTokens?appIds=" 10003600)
(try
(let [cob-session (login-cobrand)
user-session (login-user cob-session)
token (->
(str (:yodlee-base-url env) "/user/accessTokens?appIds=" 10003600)
(client/get
(merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
:as :json}
other-config))
:body
:user
:accessTokens
first
:value
)]
[user-session token]))
(client/get
(merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
:as :json}
other-config))
(doto log/info)
:body
:user
:accessTokens
first
:value
)]
[user-session token])
(catch Exception e
(log/error e)
(throw e))))
(defn create-user []
(let [cob-session (login-cobrand)]

View File

@@ -117,6 +117,13 @@
(re-frame/reg-event-fx
::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]]
{:db (-> db
(assoc-in [::yodlee :authentication] authentication)
@@ -221,7 +228,7 @@
"value" v})
(: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] ]}}))
(re-frame/reg-event-fx

View File

@@ -26,9 +26,9 @@
:total-lte (:amount-lte (:total-range params))
:date-range (:date-range params)
: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]]
[:line-items [:item-name :total]]
[:line-items [:item-name :total :category]]
[:client [:name :id]]]]
:total
:start

View File

@@ -63,6 +63,21 @@
[money-field {:type "money"
:field [:tax]
: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"
[money-field {:type "money"
:field [:tip]
@@ -76,6 +91,6 @@
[:h1.subtitle.is-4 "Line Items"]
[:ul
(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)}))])