2022-08-19 19:59:13 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-09-12 19:44:13 +02:00
|
|
|
json.extract! order, :id, :token, :statistic_profile_id, :operator_profile_id, :reference, :state, :created_at, :updated_at, :invoice_id,
|
2022-09-14 19:54:24 +02:00
|
|
|
:payment_method
|
2022-08-26 10:46:30 +02:00
|
|
|
json.total order.total / 100.0 if order.total.present?
|
2022-09-13 13:03:56 +02:00
|
|
|
json.payment_date order.invoice.created_at if order.invoice_id.present?
|
|
|
|
json.wallet_amount order.wallet_amount / 100.0 if order.wallet_amount.present?
|
|
|
|
json.paid_total order.paid_total / 100.0 if order.paid_total.present?
|
2022-09-12 19:44:13 +02:00
|
|
|
if order.coupon_id
|
|
|
|
json.coupon do
|
|
|
|
json.extract! order.coupon, :id, :code, :type, :percent_off, :validity_per_user
|
|
|
|
json.amount_off order.coupon.amount_off / 100.00 unless order.coupon.amount_off.nil?
|
|
|
|
end
|
|
|
|
end
|
2022-08-25 16:23:00 +02:00
|
|
|
if order&.statistic_profile&.user
|
|
|
|
json.user do
|
|
|
|
json.id order.statistic_profile.user.id
|
|
|
|
json.role order.statistic_profile.user.roles.first.name
|
|
|
|
json.name order.statistic_profile.user.profile.full_name
|
|
|
|
end
|
2022-08-25 08:52:17 +02:00
|
|
|
end
|
2022-08-19 19:59:13 +02:00
|
|
|
|
2022-09-08 12:13:34 +02:00
|
|
|
json.order_items_attributes order.order_items.order(created_at: :asc) do |item|
|
2022-08-19 19:59:13 +02:00
|
|
|
json.id item.id
|
|
|
|
json.orderable_type item.orderable_type
|
|
|
|
json.orderable_id item.orderable_id
|
|
|
|
json.orderable_name item.orderable.name
|
2022-09-13 18:55:08 +02:00
|
|
|
json.orderable_ref item.orderable.sku
|
2022-10-04 18:50:29 +02:00
|
|
|
json.orderable_slug item.orderable.slug
|
2022-09-12 19:44:13 +02:00
|
|
|
json.orderable_main_image_url item.orderable.main_image&.attachment_url
|
2022-09-16 16:50:05 +02:00
|
|
|
json.orderable_external_stock item.orderable.stock['external']
|
2022-08-19 19:59:13 +02:00
|
|
|
json.quantity item.quantity
|
2022-09-13 16:36:44 +02:00
|
|
|
json.quantity_min item.orderable.quantity_min
|
2022-08-19 19:59:13 +02:00
|
|
|
json.amount item.amount / 100.0
|
|
|
|
json.is_offered item.is_offered
|
|
|
|
end
|