Tidy up invoice template selection

This commit is contained in:
Matt-Yorkley
2018-10-14 12:30:20 +01:00
parent 9a71236abd
commit 96d530b473

View File

@@ -37,8 +37,7 @@ Spree::Admin::OrdersController.class_eval do
end
def invoice
template = if Spree::Config.invoice_style2? then "spree/admin/orders/invoice2" else "spree/admin/orders/invoice" end
pdf = render_to_string pdf: "invoice-#{@order.number}.pdf", template: template, formats: [:html], encoding: "UTF-8"
pdf = render_to_string pdf: "invoice-#{@order.number}.pdf", template: invoice_template, formats: [:html], encoding: "UTF-8"
Spree::OrderMailer.invoice_email(@order.id, pdf).deliver
flash[:success] = t('admin.orders.invoice_email_sent')
@@ -46,8 +45,7 @@ Spree::Admin::OrdersController.class_eval do
end
def print
template = if Spree::Config.invoice_style2? then "spree/admin/orders/invoice2" else "spree/admin/orders/invoice" end
render pdf: "invoice-#{@order.number}", template: template, encoding: "UTF-8"
render pdf: "invoice-#{@order.number}", template: invoice_template, encoding: "UTF-8"
end
def print_ticket
@@ -60,6 +58,10 @@ Spree::Admin::OrdersController.class_eval do
private
def invoice_template
Spree::Config.invoice_style2? ? "spree/admin/orders/invoice2" : "spree/admin/orders/invoice"
end
def require_distributor_abn
unless @order.distributor.abn.present?
flash[:error] = t(:must_have_valid_business_number, enterprise_name: @order.distributor.name)