mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Don't compile xero report data before search
This commit is contained in:
@@ -232,7 +232,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
@distributors = Enterprise.is_distributor.managed_by(spree_current_user)
|
||||
@order_cycles = OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
|
||||
|
||||
@report = OpenFoodNetwork::XeroInvoicesReport.new spree_current_user, params
|
||||
@report = OpenFoodNetwork::XeroInvoicesReport.new spree_current_user, params, render_content?
|
||||
render_report(@report.header, @report.table, params[:csv], "xero_invoices_#{timestamp}.csv")
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module OpenFoodNetwork
|
||||
class XeroInvoicesReport
|
||||
def initialize(user, opts={})
|
||||
def initialize(user, opts = {}, compile_table = false)
|
||||
@user = user
|
||||
|
||||
@opts = opts.
|
||||
@@ -9,6 +9,7 @@ module OpenFoodNetwork
|
||||
invoice_date: Time.zone.today,
|
||||
due_date: Time.zone.today + 1.month,
|
||||
account_code: 'food sales'})
|
||||
@compile_table = compile_table
|
||||
end
|
||||
|
||||
def header
|
||||
@@ -26,6 +27,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def table
|
||||
return [] unless @compile_table
|
||||
rows = []
|
||||
|
||||
orders.each_with_index do |order, i|
|
||||
|
||||
@@ -423,6 +423,7 @@ feature %q{
|
||||
end
|
||||
|
||||
it "shows Xero invoices report" do
|
||||
click_button "Search"
|
||||
expect(xero_invoice_table).to match_table [
|
||||
xero_invoice_header,
|
||||
xero_invoice_summary_row('Total untaxable produce (no tax)', 12.54, 'GST Free Income'),
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'open_food_network/xero_invoices_report'
|
||||
|
||||
module OpenFoodNetwork
|
||||
describe XeroInvoicesReport do
|
||||
subject { XeroInvoicesReport.new user }
|
||||
subject { XeroInvoicesReport.new user, {}, true }
|
||||
|
||||
let(:user) { create(:user) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user