mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Add enterprise fee summary form without options
The objects will be filled in another commit. This simply sets up the filters UI for now.
This commit is contained in:
@@ -7,11 +7,13 @@ module Spree
|
||||
module Admin
|
||||
module Reports
|
||||
class EnterpriseFeeSummaryReportController < BaseController
|
||||
before_filter :load_report_parameters, only: [:index]
|
||||
|
||||
def index
|
||||
return render_report_form if params[:report].blank?
|
||||
return respond_to_invalid_parameters unless report_parameters.valid?
|
||||
return respond_to_invalid_parameters unless @report_parameters.valid?
|
||||
|
||||
service = report_klass::ReportService.new(report_parameters, report_renderer_klass)
|
||||
service = report_klass::ReportService.new(@report_parameters, report_renderer_klass)
|
||||
send_data service.render, filename: service.filename
|
||||
end
|
||||
|
||||
@@ -34,8 +36,8 @@ module Spree
|
||||
OrderManagement::Reports::EnterpriseFeeSummary
|
||||
end
|
||||
|
||||
def report_parameters
|
||||
@report_parameters ||= report_klass::Parameters.new(params[:report])
|
||||
def load_report_parameters
|
||||
@report_parameters = report_klass::Parameters.new(params[:report] || {})
|
||||
end
|
||||
|
||||
def report_renderer_klass
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
= form_for @report_parameters, as: :report, url: spree.enterprise_fee_summary_admin_reports_path, method: :get do |f|
|
||||
.row.date-range-filter
|
||||
.sixteen.columns.alpha
|
||||
= label_tag nil, t(".date_range")
|
||||
%br
|
||||
|
||||
= f.label :start_at, class: "inline"
|
||||
= f.text_field :start_at, class: "datetimepicker datepicker-from"
|
||||
|
||||
%span.range-divider
|
||||
%i.icon-arrow-right
|
||||
|
||||
= f.text_field :end_at, class: "datetimepicker datepicker-to"
|
||||
= f.label :end_at, class: "inline"
|
||||
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
= f.label :distributor_ids
|
||||
= f.collection_select(:distributor_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
= f.label :producer_ids
|
||||
= f.collection_select(:producer_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
= f.label :order_cycle_ids
|
||||
= f.collection_select(:order_cycle_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.eight.columns.alpha
|
||||
= f.label :enterprise_fee_ids
|
||||
= f.collection_select(:enterprise_fee_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
.eight.columns.omega
|
||||
= f.label :shipping_method_ids
|
||||
= f.collection_select(:shipping_method_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.eight.columns.alpha
|
||||
.eight.columns.omega
|
||||
= f.label :payment_method_ids
|
||||
= f.collection_select(:payment_method_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
= check_box_tag :report_format, "csv", false, id: "report_format_csv"
|
||||
= label_tag :report_format_csv, t(".report_format_csv")
|
||||
|
||||
= button t(".generate_report")
|
||||
|
||||
@@ -54,6 +54,16 @@ en:
|
||||
on_demand_but_count_on_hand_set: "must be blank if on demand"
|
||||
limited_stock_but_no_count_on_hand: "must be specified because forcing limited stock"
|
||||
activemodel:
|
||||
attributes:
|
||||
order_management/reports/enterprise_fee_summary/parameters:
|
||||
start_at: "Start"
|
||||
end_at: "End"
|
||||
distributor_ids: "Hubs"
|
||||
producer_ids: "Producers"
|
||||
order_cycle_ids: "Order Cycles"
|
||||
enterprise_fee_ids: "Fees Names"
|
||||
shipping_method_ids: "Shipping Methods"
|
||||
payment_method_ids: "Payment Methods"
|
||||
errors:
|
||||
models:
|
||||
subscription_validator:
|
||||
@@ -2820,6 +2830,11 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
bulk_coop_allocation: 'Bulk Co-op - Allocation'
|
||||
bulk_coop_packing_sheets: 'Bulk Co-op - Packing Sheets'
|
||||
bulk_coop_customer_payments: 'Bulk Co-op - Customer Payments'
|
||||
enterprise_fee_summary_report:
|
||||
filters:
|
||||
date_range: "Date Range"
|
||||
report_format_csv: "Download as CSV"
|
||||
generate_report: "Generate Report"
|
||||
users:
|
||||
index:
|
||||
listing_users: "Listing Users"
|
||||
|
||||
@@ -7,6 +7,7 @@ module OrderManagement
|
||||
DATE_END_BEFORE_START_ERROR = I18n.t("date_end_before_start_error", scope: @i18n_scope)
|
||||
|
||||
extend ActiveModel::Naming
|
||||
extend ActiveModel::Translation
|
||||
include ActiveModel::Validations
|
||||
|
||||
attr_accessor :start_at, :end_at, :distributor_ids, :producer_ids, :order_cycle_ids,
|
||||
@@ -33,6 +34,9 @@ module OrderManagement
|
||||
end
|
||||
end
|
||||
|
||||
# The parameters are never persisted.
|
||||
def to_key; end
|
||||
|
||||
protected
|
||||
|
||||
def require_valid_datetime_range
|
||||
|
||||
Reference in New Issue
Block a user