mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Reports Refactor 2: Fix linting
This commit is contained in:
committed by
Jean-Baptiste Bellet
parent
452a3fa933
commit
caccbb698b
@@ -25,7 +25,7 @@ module OpenFoodNetwork
|
||||
if @coordinator.sells == "any"
|
||||
# If the coordinator sells any, relationships come into play
|
||||
related_enterprises_granting(:add_to_order_cycle,
|
||||
to: [@coordinator.id]).each do |enterprise_id|
|
||||
to: [@coordinator.id]).each do |enterprise_id|
|
||||
coordinator_permitted_ids << enterprise_id
|
||||
end
|
||||
|
||||
@@ -125,7 +125,7 @@ module OpenFoodNetwork
|
||||
# Find the variants that a user can POTENTIALLY see within incoming exchanges
|
||||
def visible_variants_for_incoming_exchanges_from(producer)
|
||||
if @order_cycle &&
|
||||
(user_manages_coordinator_or(producer) || user_is_permitted_add_to_oc_by(producer))
|
||||
(user_manages_coordinator_or(producer) || user_is_permitted_add_to_oc_by(producer))
|
||||
all_variants_supplied_by(producer)
|
||||
else
|
||||
no_variants
|
||||
@@ -212,8 +212,8 @@ module OpenFoodNetwork
|
||||
# Variants produced by MY PRODUCERS that are in this OC,
|
||||
# where my producer has granted P-OC to the hub
|
||||
granting_producer_ids = related_enterprises_granting(:add_to_order_cycle,
|
||||
to: [hub.id],
|
||||
scope: granted_producers)
|
||||
to: [hub.id],
|
||||
scope: granted_producers)
|
||||
permitted_variants = variants_from_suppliers(granting_producer_ids)
|
||||
|
||||
Spree::Variant.where(id: permitted_variants)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# The result from those models
|
||||
module Reporting
|
||||
class ReportObjectTemplate < ReportTemplate
|
||||
|
||||
def table_headers
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ module Reporting
|
||||
def as_json
|
||||
table_rows.map do |row|
|
||||
result = {}
|
||||
table_headers.zip(row) { |a,b| result[a.to_sym] = b }
|
||||
table_headers.zip(row) { |a, b| result[a.to_sym] = b }
|
||||
result
|
||||
end.as_json
|
||||
end
|
||||
|
||||
@@ -4,7 +4,6 @@ module Reporting
|
||||
module Reports
|
||||
module UsersAndEnterprises
|
||||
class UsersAndEnterprisesReport < ReportObjectTemplate
|
||||
|
||||
def initialize(user, params = {})
|
||||
super(user, params)
|
||||
|
||||
|
||||
@@ -21,12 +21,14 @@ describe Admin::ReportsController, type: :controller do
|
||||
|
||||
# Given two order cycles with both distributors
|
||||
let(:ocA) {
|
||||
create(:simple_order_cycle, coordinator: coordinator1, distributors: [distributor1, distributor2],
|
||||
create(:simple_order_cycle, coordinator: coordinator1,
|
||||
distributors: [distributor1, distributor2],
|
||||
suppliers: [supplier1, supplier2, supplier3],
|
||||
variants: [product1.master, product3.master])
|
||||
}
|
||||
let(:ocB) {
|
||||
create(:simple_order_cycle, coordinator: coordinator2, distributors: [distributor1, distributor2],
|
||||
create(:simple_order_cycle, coordinator: coordinator2,
|
||||
distributors: [distributor1, distributor2],
|
||||
suppliers: [supplier1, supplier2, supplier3],
|
||||
variants: [product2.master])
|
||||
}
|
||||
@@ -157,7 +159,8 @@ describe Admin::ReportsController, type: :controller do
|
||||
spree_get :index
|
||||
|
||||
report_types = assigns(:reports).keys
|
||||
expect(report_types).to include :orders_and_fulfillment, :products_and_inventory, :packing # and others
|
||||
expect(report_types).to include :orders_and_fulfillment,
|
||||
:products_and_inventory, :packing # and others
|
||||
expect(report_types).to_not include :sales_tax
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,10 +19,10 @@ module Reporting
|
||||
around { |example| Timecop.travel(Time.zone.local(2015, 5, 5, 14, 0, 0)) { example.run } }
|
||||
|
||||
it "uses defaults when blank params are passed" do
|
||||
expect(report.instance_variable_get(:@params)).to eq( invoice_date: Date.civil(2015, 5, 5),
|
||||
due_date: Date.civil(2015, 6, 5),
|
||||
account_code: 'food sales',
|
||||
report_subtype: 'summary' )
|
||||
expect(report.instance_variable_get(:@params)).to eq(invoice_date: Date.civil(2015, 5, 5),
|
||||
due_date: Date.civil(2015, 6, 5),
|
||||
account_code: 'food sales',
|
||||
report_subtype: 'summary' )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user