mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
There were a few changes needed: * Plugins are now specified through `plugin:` config keyword. * All plugin gems need to be specified explicitly in Gemfile since they are no longer dependencies of plugins already specified explicitly. * All plugin gems need to be updated in other to use the new APIs. * One cop was renamed. * New offenses safe to correct were corrected directly with `bundle exec rubocop -a`. * New offenses unsafe to correct were added to the TODO configuration with `bundle exec rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`.
65 lines
1.6 KiB
Ruby
65 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module ReportsHelper
|
|
def report_order_cycle_options(order_cycles)
|
|
order_cycles.map do |oc|
|
|
orders_open_at = oc.orders_open_at&.to_fs(:short) || 'NA'
|
|
orders_close_at = oc.orders_close_at&.to_fs(:short) || 'NA'
|
|
# rubocop:disable Rails/OutputSafety
|
|
["#{oc.name} (#{orders_open_at} - #{orders_close_at})".html_safe, oc.id]
|
|
# rubocop:enable Rails/OutputSafety
|
|
end
|
|
end
|
|
|
|
def report_payment_method_options(orders)
|
|
orders.map do |order|
|
|
payment_method = order.payments.last&.payment_method
|
|
|
|
next unless payment_method
|
|
|
|
[payment_method.name, payment_method.id]
|
|
end.compact.uniq
|
|
end
|
|
|
|
def report_shipping_method_options(orders)
|
|
orders.map do |o|
|
|
sm = o.shipping_method
|
|
[sm&.name, sm&.id]
|
|
end.uniq
|
|
end
|
|
|
|
def customer_email_options(order_customers)
|
|
order_customers.map do |customer|
|
|
[customer&.email, customer&.id]
|
|
end
|
|
end
|
|
|
|
def fee_name_options(orders)
|
|
EnterpriseFee.where(id: enterprise_fee_ids(orders))
|
|
.pluck(:name, :id)
|
|
end
|
|
|
|
def fee_owner_options(orders)
|
|
Enterprise.where(id: enterprise_fee_owner_ids(orders))
|
|
.pluck(:name, :id)
|
|
end
|
|
|
|
delegate :currency_symbol, to: :'Spree::Money'
|
|
|
|
def enterprise_fee_owner_ids(orders)
|
|
EnterpriseFee.where(id: enterprise_fee_ids(orders))
|
|
.pluck(:enterprise_id)
|
|
end
|
|
|
|
def enterprise_fee_ids(orders)
|
|
Spree::Adjustment.enterprise_fee
|
|
.where(order_id: orders.map(&:id))
|
|
.pluck(:originator_id)
|
|
end
|
|
|
|
def datepicker_time(datetime)
|
|
datetime = Time.zone.parse(datetime) if datetime.is_a? String
|
|
datetime.strftime('%Y-%m-%d %H:%M')
|
|
end
|
|
end
|