Don't compile xero report data before search

This commit is contained in:
Maikel Linke
2018-05-03 14:45:53 +10:00
parent 14e7cdd138
commit b8ca37e9d2
4 changed files with 6 additions and 3 deletions

View File

@@ -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

View File

@@ -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|

View File

@@ -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'),

View File

@@ -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) }