Retrieve currency_symbol via private method rather than before_filter + instance var - cleaner syntax

This commit is contained in:
Rohan Mitchell
2015-01-08 10:12:27 +11:00
parent a438216189
commit 4839c00d62

View File

@@ -31,7 +31,6 @@ Spree::Admin::ReportsController.class_eval do
# Fetches user's distributors, suppliers and order_cycles
before_filter :load_data, only: [:customers, :products_and_inventory, :order_cycle_management]
before_filter :set_currency_symbol
# Render a partial for orders and fulfillment description
respond_override :index => { :html => { :success => lambda {
@@ -281,7 +280,7 @@ Spree::Admin::ReportsController.class_eval do
when "payments_by_payment_type"
table_items = payments
header = ["Payment State", "Distributor", "Payment Type", "Total (#{@currency_symbol})"]
header = ["Payment State", "Distributor", "Payment Type", "Total (#{currency_symbol})"]
columns = [ proc { |payments| payments.first.order.payment_state },
proc { |payments| payments.first.order.distributor.name },
@@ -298,7 +297,7 @@ Spree::Admin::ReportsController.class_eval do
when "itemised_payment_totals"
table_items = orders
header = ["Payment State", "Distributor", "Product Total (#{@currency_symbol})", "Shipping Total (#{@currency_symbol})", "Outstanding Balance (#{@currency_symbol})", "Total (#{@currency_symbol})"]
header = ["Payment State", "Distributor", "Product Total (#{currency_symbol})", "Shipping Total (#{currency_symbol})", "Outstanding Balance (#{currency_symbol})", "Total (#{currency_symbol})"]
columns = [ proc { |orders| orders.first.payment_state },
proc { |orders| orders.first.distributor.name },
@@ -315,7 +314,7 @@ Spree::Admin::ReportsController.class_eval do
when "payment_totals"
table_items = orders
header = ["Payment State", "Distributor", "Product Total (#{@currency_symbol})", "Shipping Total (#{@currency_symbol})", "Total (#{@currency_symbol})", "EFT (#{@currency_symbol})", "PayPal (#{@currency_symbol})", "Outstanding Balance (#{@currency_symbol})"]
header = ["Payment State", "Distributor", "Product Total (#{currency_symbol})", "Shipping Total (#{currency_symbol})", "Total (#{currency_symbol})", "EFT (#{currency_symbol})", "PayPal (#{currency_symbol})", "Outstanding Balance (#{currency_symbol})"]
columns = [ proc { |orders| orders.first.payment_state },
proc { |orders| orders.first.distributor.name },
@@ -334,7 +333,7 @@ Spree::Admin::ReportsController.class_eval do
else
table_items = payments
header = ["Payment State", "Distributor", "Payment Type", "Total (#{@currency_symbol})"]
header = ["Payment State", "Distributor", "Payment Type", "Total (#{currency_symbol})"]
columns = [ proc { |payments| payments.first.order.payment_state },
proc { |payments| payments.first.order.distributor.name },
@@ -494,7 +493,7 @@ Spree::Admin::ReportsController.class_eval do
table_items = @line_items
@include_blank = 'All'
header = ["Hub", "Customer", "Email", "Phone", "Producer", "Product", "Variant", "Amount", "Item (#{@currency_symbol})", "Item + Fees (#{@currency_symbol})", "Dist (#{@currency_symbol})", "Ship (#{@currency_symbol})", "Total (#{@currency_symbol})", "Paid?",
header = ["Hub", "Customer", "Email", "Phone", "Producer", "Product", "Variant", "Amount", "Item (#{currency_symbol})", "Item + Fees (#{currency_symbol})", "Dist (#{currency_symbol})", "Ship (#{currency_symbol})", "Total (#{currency_symbol})", "Paid?",
"Shipping", "Delivery?", "Ship street", "Ship street 2", "Ship city", "Ship postcode", "Ship state", "Order notes"]
rsa = proc { |line_items| line_items.first.order.shipping_method.andand.require_ship_address }
@@ -618,8 +617,8 @@ Spree::Admin::ReportsController.class_eval do
private
def set_currency_symbol
@currency_symbol = Spree::Money.currency_symbol
def currency_symbol
Spree::Money.currency_symbol
end
def load_data