From 5660e3737e2e5fd82b01fb2dcba7daf22e305704 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 14 May 2015 13:01:46 +1000 Subject: [PATCH] Extract order rows generation to method --- lib/open_food_network/xero_invoices_report.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/open_food_network/xero_invoices_report.rb b/lib/open_food_network/xero_invoices_report.rb index 784550a4b4..7308f7740b 100644 --- a/lib/open_food_network/xero_invoices_report.rb +++ b/lib/open_food_network/xero_invoices_report.rb @@ -16,11 +16,7 @@ module OpenFoodNetwork @orders.each_with_index do |order, i| invoice_number = invoice_number_for(order, i) - rows << summary_row(order, 'Total untaxable produce (no tax)', 0, invoice_number, 'GST Free Income', @opts) - rows << summary_row(order, 'Total taxable produce (tax inclusive)', 0, invoice_number, 'GST on Income', @opts) - rows << summary_row(order, 'Total untaxable fees (no tax)', 0, invoice_number, 'GST Free Income', @opts) - rows << summary_row(order, 'Total taxable fees (tax inclusive)', 0, invoice_number, 'GST on Income', @opts) - rows << summary_row(order, 'Delivery Shipping Cost (tax inclusive)', 0, invoice_number, 'Tax or No Tax - depending on enterprise setting', @opts) + rows += rows_for_order(order, invoice_number, @opts) end rows @@ -29,6 +25,17 @@ module OpenFoodNetwork private + def rows_for_order(order, invoice_number, opts) + [ + summary_row(order, 'Total untaxable produce (no tax)', 0, invoice_number, 'GST Free Income', opts), + summary_row(order, 'Total taxable produce (tax inclusive)', 0, invoice_number, 'GST on Income', opts), + summary_row(order, 'Total untaxable fees (no tax)', 0, invoice_number, 'GST Free Income', opts), + summary_row(order, 'Total taxable fees (tax inclusive)', 0, invoice_number, 'GST on Income', opts), + summary_row(order, 'Delivery Shipping Cost (tax inclusive)', 0, invoice_number, 'Tax or No Tax - depending on enterprise setting', opts) + ] + end + + def invoice_number_for(order, i) @opts[:initial_invoice_number] ? @opts[:initial_invoice_number].to_i+i : order.number end