Xero invoices report: Preserve form fields on submit, do not show rows with no cost

This commit is contained in:
Rohan Mitchell
2015-05-15 15:27:46 +10:00
parent 3640a71ab8
commit 3d4a0f8407
3 changed files with 8 additions and 6 deletions

View File

@@ -681,7 +681,7 @@ Spree::Admin::ReportsController.class_eval do
end
def xero_invoices
@search = Spree::Order.complete.managed_by(spree_current_user).search(params[:q])
@search = Spree::Order.complete.managed_by(spree_current_user).order('id DESC').search(params[:q])
orders = @search.result
@report = OpenFoodNetwork::XeroInvoicesReport.new orders, params
render_report(@report.header, @report.table, params[:csv], "xero_invoices_#{timestamp}.csv")

View File

@@ -1,16 +1,16 @@
= form_tag spree.xero_invoices_admin_reports_path do
.row
.four.columns.alpha= label_tag :initial_invoice_number, "Initial invoice number:"
.twelve.columns.omega= text_field_tag :initial_invoice_number
.twelve.columns.omega= text_field_tag :initial_invoice_number, params[:initial_invoice_number]
.row
.four.columns.alpha= label_tag :invoice_date, "Invoice date:"
.twelve.columns.omega= text_field_tag :invoice_date, '', class: 'datetimepicker'
.twelve.columns.omega= text_field_tag :invoice_date, params[:invoice_date], class: 'datetimepicker'
.row
.four.columns.alpha= label_tag :due_date, "Due date:"
.twelve.columns.omega= text_field_tag :due_date, '', class: 'datetimepicker'
.twelve.columns.omega= text_field_tag :due_date, params[:due_date], class: 'datetimepicker'
.row
.four.columns.alpha= label_tag :account_code, "Account code:"
.twelve.columns.omega= text_field_tag :account_code
.twelve.columns.omega= text_field_tag :account_code, params[:account_code]
.row
.four.columns.alpha= label_tag :csv, "Download as CSV:"
.twelve.columns.omega= check_box_tag :csv

View File

@@ -36,10 +36,12 @@ module OpenFoodNetwork
summary_row(order, 'Total untaxable fees (no tax)', total_untaxable_fees(order), invoice_number, 'GST Free Income', opts),
summary_row(order, 'Total taxable fees (tax inclusive)', total_taxable_fees(order), invoice_number, 'GST on Income', opts),
summary_row(order, 'Delivery Shipping Cost (tax inclusive)', total_shipping(order), invoice_number, tax_on_shipping_s(order), opts)
]
].compact
end
def summary_row(order, description, amount, invoice_number, tax_type, opts={})
return nil if amount == 0
[order.bill_address.full_name,
order.email,
order.bill_address.address1,