Class: Workarea::Listrak::Models::OrderForm
- Inherits:
-
Object
- Object
- Workarea::Listrak::Models::OrderForm
- Defined in:
- app/services/workarea/listrak/models/order_form.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
- #as_json(_options) ⇒ Object
-
#associate_id ⇒ String
Associate ID of order.
-
#billing_address ⇒ Workarea::Listrak::Models::Address
Billing address of order.
-
#coupon_code ⇒ String
Coupon code used with order.
-
#customer_number ⇒ String
Internal customer number.
-
#date_entered ⇒ String
Timestamp of order date (ET).
-
#discount_total ⇒ Float
Total value of order discount.
-
#email ⇒ String
Email address of customer.
-
#handling_total ⇒ Float
Total handling costs.
-
#initialize(order) ⇒ OrderForm
constructor
A new instance of OrderForm.
-
#item_total ⇒ Float
Total cost of items ordered (subtotal).
-
#items ⇒ Array<Workarea::Listrak::Models::OrderItem>
Order items.
-
#merchandise_discount ⇒ Float
Discount applied to the merchandise of the order.
-
#merchandise_discount_description ⇒ String
Description of the discount applied to the merchandise of the order.
-
#merchandise_discount_type ⇒ String
Type of discount applied to the merchandise of the order.
-
#meta1 ⇒ String
Additional meta information.
-
#meta2 ⇒ String
Additional meta information.
-
#meta3 ⇒ String
Additional meta information.
-
#meta4 ⇒ String
Additional meta information.
-
#meta5 ⇒ String
Additional meta information.
-
#non_merchandise_discount ⇒ Float
Discounts applied to the order that is not related to the merchandise.
-
#non_merchandise_discount_description ⇒ String
Description of the discount applied to the order not related to the merchandise.
-
#non_merchandise_discount_type ⇒ String
Type of discount applied to the order not related to the merchandise.
-
#order_number ⇒ String
Unique order number.
-
#order_total ⇒ Object
Total value of order.
-
#ship_date ⇒ String
Timestamp when entire order shipped (ET).
-
#shipping_address ⇒ Workarea::Listrak::Models::Address
Shipping address of order.
-
#shipping_method ⇒ String
Shipping method (e.g. UPS Ground).
-
#shipping_total ⇒ Float
Total shipping costs.
-
#source ⇒ String
Describes the source at which the order was placed (online, POS, etc.).
-
#status ⇒ String
Status indicator.
-
#store_number ⇒ String
Brick and mortar store location.
-
#tax_total ⇒ Float
Total sales tax charged.
-
#tracking_number ⇒ String
Shipment tracking number.
Constructor Details
#initialize(order) ⇒ OrderForm
Returns a new instance of OrderForm.
7 8 9 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 7 def initialize(order) @order = order end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
5 6 7 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 5 def order @order end |
Instance Method Details
#as_json(_options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 11 def as_json() { associateID: associate_id, billingAddress: billing_address, couponCode: coupon_code, customerNumber: customer_number, dateEntered: date_entered, discountTotal: discount_total, email: email, handlingTotal: handling_total, items: items, itemTotal: item_total, merchandiseDiscount: merchandise_discount, merchandiseDiscountDescription: merchandise_discount_description, merchandiseDiscountType: merchandise_discount_type, meta1: , meta2: , meta3: , meta4: , meta5: , nonMerchandiseDiscount: non_merchandise_discount, nonMerchandiseDiscountDescription: non_merchandise_discount_description, nonMerchandiseDiscountType: non_merchandise_discount_type, orderNumber: order_number, orderTotal: order_total, shipDate: ship_date, shippingAddress: shipping_address, shippingMethod: shipping_method, shippingTotal: shipping_total, source: source, status: status, storeNumber: store_number, taxTotal: tax_total, trackingNumber: tracking_number } end |
#associate_id ⇒ String
Associate ID of order
51 52 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 51 def associate_id end |
#billing_address ⇒ Workarea::Listrak::Models::Address
Billing address of order
58 59 60 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 58 def billing_address Workarea::Listrak::Models::Address.new payment.address end |
#coupon_code ⇒ String
Coupon code used with order
limited to 32 characters
68 69 70 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 68 def coupon_code order.promo_codes.first end |
#customer_number ⇒ String
Internal customer number
limited to 20 characters
78 79 80 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 78 def customer_number order.user_id.to_s end |
#date_entered ⇒ String
Timestamp of order date (ET)
86 87 88 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 86 def date_entered order.placed_at.strftime '%FT%TZ' end |
#discount_total ⇒ Float
Total value of order discount
94 95 96 97 98 99 100 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 94 def discount_total order.price_adjustments .select { |pa| pa.data['discount_value'].present? && pa.price != 'item' } .sum { |d| d.data['discount_value'] } .abs .try(:to_f) end |
#email ⇒ String
Email address of customer. This property is required for accounts that are not CRM enabled.
limited to 100 characters
109 110 111 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 109 def email order.email end |
#handling_total ⇒ Float
Total handling costs
117 118 119 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 117 def handling_total shipping.shipping_total.to_f end |
#item_total ⇒ Float
Total cost of items ordered (subtotal)
135 136 137 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 135 def item_total order.subtotal_price.to_f end |
#items ⇒ Array<Workarea::Listrak::Models::OrderItem>
Order items
125 126 127 128 129 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 125 def items @order_items ||= order.items.map do |order_item| Workarea::Listrak::Models::OrderItem.new order, order_item end end |
#merchandise_discount ⇒ Float
Discount applied to the merchandise of the order
143 144 145 146 147 148 149 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 143 def merchandise_discount order.price_adjustments .select { |pa| pa.data['discount_value'].present? && pa.price == 'item' } .sum { |d| d.data['discount_value'] } .abs .try(:to_f) end |
#merchandise_discount_description ⇒ String
Description of the discount applied to the merchandise of the order
155 156 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 155 def merchandise_discount_description end |
#merchandise_discount_type ⇒ String
Type of discount applied to the merchandise of the order
“NotSet” “PriceOverride” “PriceRule” “Promotion” “SeniorCitizen” “Markdown” “Coupon” “QuantityDiscount” “Rebate” “CashDiscount” “TradeDiscount” “TradeInKind” “PromptPaymentDiscount” “GeneralDiscount” “GiftVoucher” “FlexibleDiscount” “RewardProgram” “ManufacturerReward” “CreditCardReward”
164 165 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 164 def merchandise_discount_type end |
#meta1 ⇒ String
Additional meta information
limited to 500 characters
173 174 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 173 def end |
#meta2 ⇒ String
Additional meta information
limted to 500 characters
182 183 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 182 def end |
#meta3 ⇒ String
Additional meta information
limted to 500 characters
191 192 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 191 def end |
#meta4 ⇒ String
Additional meta information
limted to 500 characters
200 201 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 200 def end |
#meta5 ⇒ String
Additional meta information
limted to 500 characters
209 210 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 209 def end |
#non_merchandise_discount ⇒ Float
Discounts applied to the order that is not related to the merchandise
216 217 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 216 def non_merchandise_discount end |
#non_merchandise_discount_description ⇒ String
Description of the discount applied to the order not related to the merchandise
223 224 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 223 def non_merchandise_discount_description end |
#non_merchandise_discount_type ⇒ String
Type of discount applied to the order not related to the merchandise
“NotSet” “PriceOverride” “PriceRule” “Promotion” “SeniorCitizen” “Markdown” “Coupon” “QuantityDiscount” “Rebate” “CashDiscount” “TradeDiscount” “TradeInKind” “PromptPaymentDiscount” “GeneralDiscount” “GiftVoucher” “FlexibleDiscount” “RewardProgram” “ManufacturerReward” “CreditCardReward”
232 233 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 232 def non_merchandise_discount_type end |
#order_number ⇒ String
Unique order number
limited to 50 characters
241 242 243 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 241 def order_number order.id.to_s end |
#order_total ⇒ Object
Total value of order
return [Float]
249 250 251 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 249 def order_total order.total_value.to_f end |
#ship_date ⇒ String
Timestamp when entire order shipped (ET)
257 258 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 257 def ship_date end |
#shipping_address ⇒ Workarea::Listrak::Models::Address
Shipping address of order
264 265 266 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 264 def shipping_address Workarea::Listrak::Models::Address.new shipping.address end |
#shipping_method ⇒ String
Shipping method (e.g. UPS Ground)
limted to 32 characters
274 275 276 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 274 def shipping_method shipping.shipping_service&.name end |
#shipping_total ⇒ Float
Total shipping costs
282 283 284 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 282 def shipping_total order.shipping_total.to_f end |
#source ⇒ String
Describes the source at which the order was placed (online, POS, etc.)
limted to 25 characters
292 293 294 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 292 def source 'web' end |
#status ⇒ String
Status indicator
“NotSet” “Misc” “PreOrder” “BackOrder” “Pending” “Hold” “Processing” “Shipped” “Completed” “Returned” “Canceled” “Unknown” “Closed”
302 303 304 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 302 def status order.status end |
#store_number ⇒ String
Brick and mortar store location
limited to 100 characters
312 313 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 312 def store_number end |
#tax_total ⇒ Float
Total sales tax charged
319 320 321 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 319 def tax_total order.tax_total.to_f end |
#tracking_number ⇒ String
Shipment tracking number
limited to 32 characters
329 330 |
# File 'app/services/workarea/listrak/models/order_form.rb', line 329 def tracking_number end |