mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
add feature toggle
seperate the invoice templates that rely on presenters from the old ones.
This commit is contained in:
committed by
Konrad
parent
fa14dc370b
commit
d86173c509
@@ -7,7 +7,7 @@ module Spree
|
||||
authorize_resource class: false
|
||||
|
||||
def index
|
||||
@order = Spree::Order.find_by_number(params[:order_id])
|
||||
@order = Spree::Order.find_by(number: params[:order_id])
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -17,6 +17,23 @@ module Spree
|
||||
render json: invoice_service.id, status: :ok
|
||||
end
|
||||
|
||||
def generate
|
||||
@order = Order.find_by(number: params[:order_id])
|
||||
if @order.can_generate_new_invoice?
|
||||
@order.invoices.create!(
|
||||
date: Time.zone.today,
|
||||
number: @order.next_invoice_number,
|
||||
data: invoice_data
|
||||
)
|
||||
elsif @order.can_update_latest_invoice?
|
||||
@order.invoices.last.update!(
|
||||
date: Time.zone.today,
|
||||
data: invoice_data
|
||||
)
|
||||
end
|
||||
redirect_back(fallback_location: spree.admin_dashboard_path)
|
||||
end
|
||||
|
||||
def show
|
||||
invoice_id = params[:id]
|
||||
invoice_pdf = BulkInvoiceService.new.filepath(invoice_id)
|
||||
@@ -33,6 +50,12 @@ module Spree
|
||||
render json: { created: false }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def invoice_data
|
||||
@invoice_data ||= InvoiceDataGenerator.new(@order).generate
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -99,11 +99,10 @@ module Spree
|
||||
end
|
||||
|
||||
def print
|
||||
# This is for testing on realtime
|
||||
# I'll replace it later
|
||||
data = Invoice::OrderSerializer.new(@order).serializable_hash
|
||||
@invoice=Invoice.new(order: @order, data: data, date: Time.now.to_date)
|
||||
@invoice_presenter= @invoice.presenter
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:invoices)
|
||||
@invoice = @order.invoices.find(params[:invoice_id])
|
||||
@invoice_presenter = @invoice.presenter
|
||||
end
|
||||
render_with_wicked_pdf InvoiceRenderer.new.args(@order)
|
||||
end
|
||||
|
||||
|
||||
@@ -8,4 +8,9 @@ module OrderHelper
|
||||
def outstanding_balance_label(order)
|
||||
order.outstanding_balance.label
|
||||
end
|
||||
|
||||
def show_generate_invoice_button?(order)
|
||||
order.can_generate_new_invoice? ||
|
||||
order.can_update_latest_invoice?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,6 +31,7 @@ module Spree
|
||||
end
|
||||
|
||||
def invoice_links
|
||||
return [] if OpenFoodNetwork::FeatureToggle.enabled?(:invoices)
|
||||
return [] unless Spree::Config[:enable_invoices?]
|
||||
|
||||
[send_invoice_link, print_invoice_link]
|
||||
|
||||
@@ -578,11 +578,21 @@ module Spree
|
||||
def can_generate_new_invoice?
|
||||
return true if invoices.empty?
|
||||
|
||||
!invoice_comparator.equal? current_state_invoice, invoices.last
|
||||
invoice_comparator.can_generate_new_invoice? current_state_invoice, invoices.last
|
||||
end
|
||||
|
||||
def can_update_latest_invoice?
|
||||
return false if invoices.empty?
|
||||
|
||||
invoice_comparator.can_update_latest_invoice? current_state_invoice, invoices.last
|
||||
end
|
||||
|
||||
def next_invoice_number
|
||||
invoices.count + 1
|
||||
end
|
||||
|
||||
def invoice_comparator
|
||||
@invoice_comparator ||= InvoiceComparator.new
|
||||
@invoice_comparator ||= OrderInvoiceComparator.new
|
||||
end
|
||||
|
||||
def current_state_invoice
|
||||
|
||||
@@ -59,6 +59,6 @@ class InvoiceDataGenerator
|
||||
end
|
||||
|
||||
def old_data
|
||||
@old_data ||= order.invoices&.last.data
|
||||
@old_data ||= order.invoices&.last&.data
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,10 +24,20 @@ class InvoiceRenderer
|
||||
attr_reader :renderer
|
||||
|
||||
def invoice_template
|
||||
if Spree::Config.invoice_style2?
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:invoices)
|
||||
invoice_presenter_template
|
||||
elsif Spree::Config.invoice_style2?
|
||||
"spree/admin/orders/invoice2"
|
||||
else
|
||||
"spree/admin/orders/invoice"
|
||||
end
|
||||
end
|
||||
|
||||
def invoice_presenter_template
|
||||
if Spree::Config.invoice_style2?
|
||||
"spree/admin/orders/invoice4"
|
||||
else
|
||||
"spree/admin/orders/invoice3"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
%td.align-center.label
|
||||
= invoice.number
|
||||
%td.align-center.label
|
||||
= invoice.data['order']['total']
|
||||
= invoice.presenter.total
|
||||
%td.align-center.label
|
||||
= t(invoice.status)
|
||||
%td.align-center.label
|
||||
=link_to(t(:download),invoice.status)
|
||||
=link_to(t(:download),print_admin_order_path(@order,invoice_id: invoice.id),target: "_blank")
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
= t(:invoices)
|
||||
|
||||
- content_for :page_actions do
|
||||
- if @order.can_generate_new_invoice?
|
||||
%li= button_link_to t(:new_invoice), new_admin_order_adjustment_url(@order), :icon => 'icon-plus', disabled: true
|
||||
- if show_generate_invoice_button?(@order)
|
||||
%li= button_link_to t(:new_invoice), generate_admin_order_invoices_path(@order), :icon => 'icon-plus', data: { method: 'post' }
|
||||
= render partial: 'spree/admin/shared/order_links'
|
||||
%li= button_link_to t(:back_to_orders_list), admin_orders_path, :icon => 'icon-arrow-left'
|
||||
|
||||
|
||||
@@ -6,33 +6,33 @@
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h4= t(:invoice_column_qty)
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h4= @invoice_presenter.total_tax > 0 ? t(:invoice_column_tax) : ""
|
||||
%h4= @order.total_tax > 0 ? t(:invoice_column_tax) : ""
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h4= t(:invoice_column_price)
|
||||
%tbody
|
||||
- @invoice_presenter.sorted_line_items.each do |item|
|
||||
- @order.sorted_line_items.each do |item|
|
||||
%tr
|
||||
%td
|
||||
= render 'spree/admin/orders/_invoice/line_item_name', line_item: item
|
||||
= render 'spree/shared/line_item_name', line_item: item
|
||||
%br
|
||||
%small
|
||||
%em= raw(item.variant.product.supplier.name)
|
||||
%td{:align => "right"}
|
||||
= item.quantity
|
||||
%td{:align => "right"}
|
||||
= item.display_line_items_taxes
|
||||
= display_line_items_taxes(item)
|
||||
%td{:align => "right"}
|
||||
= item.display_amount_with_adjustments
|
||||
|
||||
- @invoice_presenter.checkout_adjustments(exclude: [:line_item]).reverse_each do |adjustment|
|
||||
- taxable = adjustment#.adjustable_type == "Spree::Shipment" ? adjustment.adjustable : adjustment
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
|
||||
- taxable = adjustment.adjustable_type == "Spree::Shipment" ? adjustment.adjustable : adjustment
|
||||
%tr
|
||||
%td
|
||||
%strong= "#{raw(adjustment.label)}"
|
||||
%td{:align => "right"}
|
||||
1
|
||||
%td{:align => "right"}
|
||||
= adjustment.display_taxes
|
||||
= display_taxes(taxable, display_zero: false)
|
||||
%td{:align => "right"}
|
||||
= adjustment.display_amount
|
||||
%tfoot
|
||||
@@ -40,16 +40,16 @@
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= t(:invoice_tax_total)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= @invoice_presenter.display_checkout_tax_total
|
||||
%strong= display_checkout_tax_total(@order)
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= t(:total_excl_tax)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= @invoice_presenter.display_checkout_total_less_tax
|
||||
%strong= display_checkout_total_less_tax(@order)
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= t(:total_incl_tax)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= @invoice_presenter.display_total
|
||||
%strong= @order.display_total
|
||||
%p
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h5= t(:invoice_column_qty)
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h5= @invoice_presenter.has_taxes_included ? t(:invoice_column_unit_price_with_taxes) : t(:invoice_column_unit_price_without_taxes)
|
||||
%h5= @order.has_taxes_included ? t(:invoice_column_unit_price_with_taxes) : t(:invoice_column_unit_price_without_taxes)
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h5= @invoice_presenter.has_taxes_included ? t(:invoice_column_price_with_taxes) : t(:invoice_column_price_without_taxes)
|
||||
- if @invoice_presenter.total_tax > 0
|
||||
%h5= @order.has_taxes_included ? t(:invoice_column_price_with_taxes) : t(:invoice_column_price_without_taxes)
|
||||
- if @order.total_tax > 0
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h5= t(:invoice_column_tax_rate)
|
||||
%tbody
|
||||
@@ -44,9 +44,9 @@
|
||||
%tfoot
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "3"}
|
||||
%strong= @invoice_presenter.has_taxes_included ? t(:total_incl_tax) : t(:total_excl_tax)
|
||||
%strong= @order.has_taxes_included ? t(:total_incl_tax) : t(:total_excl_tax)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= @invoice_presenter.has_taxes_included ? @invoice_presenter.display_total : @invoice_presenter.display_checkout_total_less_tax
|
||||
%strong= @order.has_taxes_included ? @order.display_total : display_checkout_total_less_tax(@order)
|
||||
- display_checkout_taxes_hash(@order).each do |tax|
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "3"}
|
||||
@@ -55,8 +55,8 @@
|
||||
= tax[:amount]
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "3"}
|
||||
= @invoice_presenter.has_taxes_included ? t(:total_excl_tax) : t(:total_incl_tax)
|
||||
= @order.has_taxes_included ? t(:total_excl_tax) : t(:total_incl_tax)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
= @invoice_presenter.has_taxes_included ? @invoice_presenter.display_checkout_total_less_tax : @invoice_presenter.display_total
|
||||
= @order.has_taxes_included ? display_checkout_total_less_tax(@order) : @order.display_total
|
||||
%p
|
||||
|
||||
|
||||
55
app/views/spree/admin/orders/_invoice_table3.html.haml
Normal file
55
app/views/spree/admin/orders/_invoice_table3.html.haml
Normal file
@@ -0,0 +1,55 @@
|
||||
%table.order-summary{:width => "100%"}
|
||||
%thead
|
||||
%tr
|
||||
%th{:align => "left"}
|
||||
%h4= t(:invoice_column_item)
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h4= t(:invoice_column_qty)
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h4= @invoice_presenter.total_tax > 0 ? t(:invoice_column_tax) : ""
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h4= t(:invoice_column_price)
|
||||
%tbody
|
||||
- @invoice_presenter.sorted_line_items.each do |item|
|
||||
%tr
|
||||
%td
|
||||
= render 'spree/admin/orders/_invoice/line_item_name', line_item: item
|
||||
%br
|
||||
%small
|
||||
%em= raw(item.variant.product.supplier.name)
|
||||
%td{:align => "right"}
|
||||
= item.quantity
|
||||
%td{:align => "right"}
|
||||
= item.display_line_items_taxes
|
||||
%td{:align => "right"}
|
||||
= item.display_amount_with_adjustments
|
||||
|
||||
- @invoice_presenter.checkout_adjustments(exclude: [:line_item]).reverse_each do |adjustment|
|
||||
- taxable = adjustment#.adjustable_type == "Spree::Shipment" ? adjustment.adjustable : adjustment
|
||||
%tr
|
||||
%td
|
||||
%strong= "#{raw(adjustment.label)}"
|
||||
%td{:align => "right"}
|
||||
1
|
||||
%td{:align => "right"}
|
||||
= adjustment.display_taxes
|
||||
%td{:align => "right"}
|
||||
= adjustment.display_amount
|
||||
%tfoot
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= t(:invoice_tax_total)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= @invoice_presenter.display_checkout_tax_total
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= t(:total_excl_tax)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= @invoice_presenter.display_checkout_total_less_tax
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= t(:total_incl_tax)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= @invoice_presenter.display_total
|
||||
%p
|
||||
|
||||
62
app/views/spree/admin/orders/_invoice_table4.html.haml
Normal file
62
app/views/spree/admin/orders/_invoice_table4.html.haml
Normal file
@@ -0,0 +1,62 @@
|
||||
%table.order-summary{:width => "100%"}
|
||||
%thead
|
||||
%tr
|
||||
%th{:align => "left"}
|
||||
%h5= t(:invoice_column_item)
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h5= t(:invoice_column_qty)
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h5= @invoice_presenter.has_taxes_included ? t(:invoice_column_unit_price_with_taxes) : t(:invoice_column_unit_price_without_taxes)
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h5= @invoice_presenter.has_taxes_included ? t(:invoice_column_price_with_taxes) : t(:invoice_column_price_without_taxes)
|
||||
- if @invoice_presenter.total_tax > 0
|
||||
%th{:align => "right", :width => "15%"}
|
||||
%h5= t(:invoice_column_tax_rate)
|
||||
%tbody
|
||||
- @order.sorted_line_items.each do |item|
|
||||
%tr
|
||||
%td
|
||||
= render 'spree/shared/line_item_name', line_item: item
|
||||
%br
|
||||
%small
|
||||
%em= raw(item.variant.product.supplier.name)
|
||||
%td{:align => "right"}
|
||||
= item.quantity
|
||||
%td{:align => "right"}
|
||||
= item.single_display_amount_with_adjustments
|
||||
%td{:align => "right"}
|
||||
= item.display_amount_with_adjustments
|
||||
- if @order.total_tax > 0
|
||||
%td{:align => "right"}
|
||||
= display_line_item_tax_rates(item)
|
||||
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
|
||||
%tr
|
||||
%td
|
||||
%strong= "#{raw(adjustment.label)}"
|
||||
%td{:align => "right"}
|
||||
%td{:align => "right"}
|
||||
%td{:align => "right"}
|
||||
= adjustment.display_amount
|
||||
- if @order.total_tax > 0
|
||||
%td{:align => "right"}
|
||||
= display_adjustment_tax_rates(adjustment)
|
||||
%tfoot
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "3"}
|
||||
%strong= @invoice_presenter.has_taxes_included ? t(:total_incl_tax) : t(:total_excl_tax)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
%strong= @invoice_presenter.has_taxes_included ? @invoice_presenter.display_total : @invoice_presenter.display_checkout_total_less_tax
|
||||
- display_checkout_taxes_hash(@order).each do |tax|
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "3"}
|
||||
= t(:tax_total, rate: tax[:percentage])
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
= tax[:amount]
|
||||
%tr
|
||||
%td{:align => "right", :colspan => "3"}
|
||||
= @invoice_presenter.has_taxes_included ? t(:total_excl_tax) : t(:total_incl_tax)
|
||||
%td{:align => "right", :colspan => "2"}
|
||||
= @invoice_presenter.has_taxes_included ? @invoice_presenter.display_checkout_total_less_tax : @invoice_presenter.display_total
|
||||
%p
|
||||
|
||||
@@ -6,32 +6,32 @@
|
||||
%td{ :align => "left", colspan: 3 }
|
||||
%h6
|
||||
= "#{t('.issued_on')}: "
|
||||
= l @invoice_presenter.invoice_date
|
||||
= l Time.zone.now.to_date
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left" }
|
||||
%h4
|
||||
= "#{t('.tax_invoice')}: "
|
||||
= "#{@invoice_presenter.order_number}"
|
||||
= "#{@order.number}"
|
||||
%td{width: "10%" }
|
||||
|
||||
%td{ :align => "right" }
|
||||
%h4= @invoice_presenter.order_cycle.name
|
||||
%h4= @order.order_cycle&.name
|
||||
%tr{ valign: "top" }
|
||||
%td{ align: "left", colspan: 3 }
|
||||
- if @invoice_presenter.distributor.business_address.blank?
|
||||
%strong= "#{t('.from')}: #{@invoice_presenter.distributor.name}"
|
||||
- if @order.distributor.business_address.blank?
|
||||
%strong= "#{t('.from')}: #{@order.distributor.name}"
|
||||
- else
|
||||
%strong= "#{t('.from')}: #{@invoice_presenter.distributor.business_address.company}"
|
||||
- if @invoice_presenter.distributor.abn.present?
|
||||
%strong= "#{t('.from')}: #{@order.distributor.business_address.company}"
|
||||
- if @order.distributor.abn.present?
|
||||
%br
|
||||
= "#{t(:abn)} #{@invoice_presenter.distributor.abn}"
|
||||
= "#{t(:abn)} #{@order.distributor.abn}"
|
||||
%br
|
||||
- if @invoice_presenter.distributor.business_address.blank?
|
||||
= @invoice_presenter.distributor.address.full_address
|
||||
- if @order.distributor.business_address.blank?
|
||||
= @order.distributor.address.full_address
|
||||
- else
|
||||
= @invoice_presenter.distributor.business_address.full_address
|
||||
= @order.distributor.business_address.full_address
|
||||
%br
|
||||
= @invoice_presenter.distributor.contact.email
|
||||
= @order.distributor.contact.email
|
||||
%tr{ valign: "top" }
|
||||
%td{ colspan: 3 }
|
||||
|
||||
@@ -39,44 +39,44 @@
|
||||
%td{ align: "left" }
|
||||
%strong= "#{t('.to')}:"
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
= @invoice_presenter.bill_address.full_name
|
||||
- if @invoice_presenter.customer.code.present?
|
||||
- if @order.bill_address
|
||||
= @order.bill_address.full_name
|
||||
- if @order&.customer&.code.present?
|
||||
%br
|
||||
= "#{t('.code')}: #{@invoice_presenter.customer.code}"
|
||||
= "#{t('.code')}: #{@order.customer.code}"
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
= @invoice_presenter.bill_address.full_address
|
||||
- if @order.bill_address
|
||||
= @order.bill_address.full_address
|
||||
%br
|
||||
- if @invoice_presenter.customer.email.present?
|
||||
= "#{@invoice_presenter.customer.email},"
|
||||
- if @invoice_presenter.bill_address
|
||||
= "#{@invoice_presenter.bill_address.phone}"
|
||||
- if @order&.customer&.email.present?
|
||||
= "#{@order.customer.email},"
|
||||
- if @order.bill_address
|
||||
= "#{@order.bill_address.phone}"
|
||||
%td
|
||||
|
||||
%td{ align: "left", style: "border-left: .1em solid black; padding-left: 1em" }
|
||||
%strong= "#{t('.shipping')}: #{@invoice_presenter.shipping_method.name}"
|
||||
- if @invoice_presenter.shipping_method.require_ship_address
|
||||
%strong= "#{t('.shipping')}: #{@order.shipping_method&.name}"
|
||||
- if @order.shipping_method&.require_ship_address
|
||||
%br
|
||||
= @invoice_presenter.ship_address.full_name
|
||||
= @order.ship_address.full_name
|
||||
%br
|
||||
= @invoice_presenter.ship_address.full_address
|
||||
= @order.ship_address.full_address
|
||||
%br
|
||||
= @invoice_presenter.ship_address.phone
|
||||
- if @invoice_presenter.order_special_instructions.present?
|
||||
= @order.ship_address.phone
|
||||
- if @order.special_instructions.present?
|
||||
%br
|
||||
%br
|
||||
%strong= t :customer_instructions
|
||||
= @invoice_presenter.order_special_instructions
|
||||
= @order.special_instructions
|
||||
|
||||
|
||||
= render 'spree/admin/orders/invoice_table'
|
||||
|
||||
- if @invoice_presenter.distributor.invoice_text.present?
|
||||
- if @order.distributor.invoice_text.present?
|
||||
%p
|
||||
= @invoice_presenter.distributor.invoice_text
|
||||
= @order.distributor.invoice_text
|
||||
|
||||
= render 'spree/admin/orders/_invoice/payment'
|
||||
= render 'spree/shared/payment'
|
||||
|
||||
- if @invoice_presenter.order_note.present?
|
||||
= render partial: 'spree/admin/orders/_invoice/order_note'
|
||||
- if @order.note.present?
|
||||
= render partial: 'spree/shared/order_note'
|
||||
|
||||
@@ -6,89 +6,89 @@
|
||||
%td{ :align => "left" }
|
||||
%h4
|
||||
= t :tax_invoice
|
||||
- if @invoice_presenter.distributor.display_invoice_logo? && @invoice_presenter.distributor.logo_url
|
||||
- if @order.distributor.display_invoice_logo? && @order.distributor.logo.variable?
|
||||
%td{ :align => "right", rowspan: 2 }
|
||||
= wicked_pdf_image_tag @invoice_presenter.distributor.logo_url
|
||||
= wicked_pdf_image_tag @order.distributor.logo_url(:small)
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left" }
|
||||
- if @invoice_presenter.distributor.business_address.blank?
|
||||
%strong= @invoice_presenter.distributor.name
|
||||
- if @order.distributor.business_address.blank?
|
||||
%strong= @order.distributor.name
|
||||
%br
|
||||
= @invoice_presenter.distributor.address.address_part1
|
||||
= @order.distributor.address.address_part1
|
||||
%br
|
||||
= @invoice_presenter.distributor.address.address_part2
|
||||
= @order.distributor.address.address_part2
|
||||
%br
|
||||
= @invoice_presenter.distributor.email_address
|
||||
- if @invoice_presenter.distributor.phone.present?
|
||||
= @order.distributor.email_address
|
||||
- if @order.distributor.phone.present?
|
||||
%br
|
||||
= @invoice_presenter.distributor.phone
|
||||
= @order.distributor.phone
|
||||
- else
|
||||
%strong= @invoice_presenter.distributor.business_address.company
|
||||
%strong= @order.distributor.business_address.company
|
||||
%br
|
||||
= @invoice_presenter.distributor.business_address.address_part1
|
||||
= @order.distributor.business_address.address_part1
|
||||
%br
|
||||
= @invoice_presenter.distributor.business_address.address_part2
|
||||
= @order.distributor.business_address.address_part2
|
||||
%br
|
||||
= @invoice_presenter.distributor.email_address
|
||||
- if @invoice_presenter.distributor.business_address.phone.present?
|
||||
= @order.distributor.email_address
|
||||
- if @order.distributor.business_address.phone.present?
|
||||
%br
|
||||
= @invoice_presenter.distributor.business_address.phone
|
||||
- if @invoice_presenter.distributor.abn.present?
|
||||
= @order.distributor.business_address.phone
|
||||
- if @order.distributor.abn.present?
|
||||
%br
|
||||
= "#{t :abn} #{@invoice_presenter.distributor.abn}"
|
||||
- if @invoice_presenter.distributor.acn.present?
|
||||
= "#{t :abn} #{@order.distributor.abn}"
|
||||
- if @order.distributor.acn.present?
|
||||
%br
|
||||
= "#{t :acn} #{@invoice_presenter.distributor.acn}"
|
||||
= "#{t :acn} #{@order.distributor.acn}"
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left", colspan: 2 }
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left" }
|
||||
%br
|
||||
= t :invoice_issued_on
|
||||
= l @invoice_presenter.invoice_date
|
||||
= l Time.zone.now.to_date
|
||||
%br
|
||||
= t :date_of_transaction
|
||||
= l @invoice_presenter.order_completed_at.to_date
|
||||
= l @order.completed_at.to_date
|
||||
%br
|
||||
= t :order_number
|
||||
= @invoice_presenter.order_number
|
||||
= @order.number
|
||||
%td{ :align => "right" }
|
||||
= t :invoice_billing_address
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
%strong= @invoice_presenter.bill_address.full_name
|
||||
- if @invoice_presenter&.customer&.code.present?
|
||||
- if @order.bill_address
|
||||
%strong= @order.bill_address.full_name
|
||||
- if @order&.customer&.code.present?
|
||||
%br
|
||||
= "Code: #{@invoice_presenter.customer.code}"
|
||||
= "Code: #{@order.customer.code}"
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
= @invoice_presenter.bill_address.address_part1
|
||||
- if @order.bill_address
|
||||
= @order.bill_address.address_part1
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
= @invoice_presenter.bill_address.address_part2
|
||||
- if @invoice_presenter.bill_address.phone.present?
|
||||
- if @order.bill_address
|
||||
= @order.bill_address.address_part2
|
||||
- if @order.bill_address.phone.present?
|
||||
%br
|
||||
= @invoice_presenter.bill_address.phone
|
||||
- if @invoice_presenter&.customer&.email.present?
|
||||
= @order.bill_address.phone
|
||||
- if @order&.customer&.email.present?
|
||||
%br
|
||||
= @invoice_presenter.customer.email
|
||||
= @order.customer.email
|
||||
|
||||
= render 'spree/admin/orders/invoice_table2'
|
||||
|
||||
- if @invoice_presenter.order_special_instructions.present?
|
||||
- if @order.special_instructions.present?
|
||||
%p.callout
|
||||
%strong
|
||||
= t :customer_instructions
|
||||
%p
|
||||
%em= @invoice_presenter.order_special_instructions
|
||||
%em= @order.special_instructions
|
||||
%p
|
||||
|
||||
|
||||
- if @invoice_presenter.distributor.invoice_text.present?
|
||||
- if @order.distributor.invoice_text.present?
|
||||
%p
|
||||
= @invoice_presenter.distributor.invoice_text
|
||||
= @order.distributor.invoice_text
|
||||
|
||||
= render 'spree/admin/orders/_invoice/payment'
|
||||
= render 'spree/shared/payment'
|
||||
|
||||
- if @invoice_presenter.order_note.present?
|
||||
= render partial: 'spree/admin/orders/_invoice/order_note'
|
||||
- if @order.note.present?
|
||||
= render partial: 'spree/shared/order_note'
|
||||
|
||||
82
app/views/spree/admin/orders/invoice3.html.haml
Normal file
82
app/views/spree/admin/orders/invoice3.html.haml
Normal file
@@ -0,0 +1,82 @@
|
||||
= pdf_stylesheet_pack_tag "mail"
|
||||
|
||||
%table{:width => "100%"}
|
||||
%tbody
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left", colspan: 3 }
|
||||
%h6
|
||||
= "#{t('spree.admin.orders.invoice.issued_on')}: "
|
||||
= l @invoice_presenter.invoice_date
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left" }
|
||||
%h4
|
||||
= "#{t('spree.admin.orders.invoice.tax_invoice')}: "
|
||||
= "#{@invoice_presenter.order_number}"
|
||||
%td{width: "10%" }
|
||||
|
||||
%td{ :align => "right" }
|
||||
%h4= @invoice_presenter.order_cycle.name
|
||||
%tr{ valign: "top" }
|
||||
%td{ align: "left", colspan: 3 }
|
||||
- if @invoice_presenter.distributor.business_address.blank?
|
||||
%strong= "#{t('spree.admin.orders.invoice.from')}: #{@invoice_presenter.distributor.name}"
|
||||
- else
|
||||
%strong= "#{t('spree.admin.orders.invoice.from')}: #{@invoice_presenter.distributor.business_address.company}"
|
||||
- if @invoice_presenter.distributor.abn.present?
|
||||
%br
|
||||
= "#{t(:abn)} #{@invoice_presenter.distributor.abn}"
|
||||
%br
|
||||
- if @invoice_presenter.distributor.business_address.blank?
|
||||
= @invoice_presenter.distributor.address.full_address
|
||||
- else
|
||||
= @invoice_presenter.distributor.business_address.full_address
|
||||
%br
|
||||
= @invoice_presenter.distributor.contact.email
|
||||
%tr{ valign: "top" }
|
||||
%td{ colspan: 3 }
|
||||
|
||||
%tr{ valign: "top" }
|
||||
%td{ align: "left" }
|
||||
%strong= "#{t('spree.admin.orders.invoice.to')}:"
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
= @invoice_presenter.bill_address.full_name
|
||||
- if @invoice_presenter.customer.code.present?
|
||||
%br
|
||||
= "#{t('spree.admin.orders.invoice.code')}: #{@invoice_presenter.customer.code}"
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
= @invoice_presenter.bill_address.full_address
|
||||
%br
|
||||
- if @invoice_presenter.customer.email.present?
|
||||
= "#{@invoice_presenter.customer.email},"
|
||||
- if @invoice_presenter.bill_address
|
||||
= "#{@invoice_presenter.bill_address.phone}"
|
||||
%td
|
||||
|
||||
%td{ align: "left", style: "border-left: .1em solid black; padding-left: 1em" }
|
||||
%strong= "#{t('spree.admin.orders.invoice.shipping')}: #{@invoice_presenter.shipping_method.name}"
|
||||
- if @invoice_presenter.shipping_method.require_ship_address
|
||||
%br
|
||||
= @invoice_presenter.ship_address.full_name
|
||||
%br
|
||||
= @invoice_presenter.ship_address.full_address
|
||||
%br
|
||||
= @invoice_presenter.ship_address.phone
|
||||
- if @invoice_presenter.order_special_instructions.present?
|
||||
%br
|
||||
%br
|
||||
%strong= t :customer_instructions
|
||||
= @invoice_presenter.order_special_instructions
|
||||
|
||||
|
||||
= render 'spree/admin/orders/invoice_table3'
|
||||
|
||||
- if @invoice_presenter.distributor.invoice_text.present?
|
||||
%p
|
||||
= @invoice_presenter.distributor.invoice_text
|
||||
|
||||
= render 'spree/admin/orders/_invoice/payment'
|
||||
|
||||
- if @invoice_presenter.order_note.present?
|
||||
= render partial: 'spree/admin/orders/_invoice/order_note'
|
||||
94
app/views/spree/admin/orders/invoice4.html.haml
Normal file
94
app/views/spree/admin/orders/invoice4.html.haml
Normal file
@@ -0,0 +1,94 @@
|
||||
= pdf_stylesheet_pack_tag "mail"
|
||||
|
||||
%table{:width => "100%"}
|
||||
%tbody
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left" }
|
||||
%h4
|
||||
= t :tax_invoice
|
||||
- if @invoice_presenter.distributor.display_invoice_logo? && @invoice_presenter.distributor.logo_url
|
||||
%td{ :align => "right", rowspan: 2 }
|
||||
= wicked_pdf_image_tag @invoice_presenter.distributor.logo_url
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left" }
|
||||
- if @invoice_presenter.distributor.business_address.blank?
|
||||
%strong= @invoice_presenter.distributor.name
|
||||
%br
|
||||
= @invoice_presenter.distributor.address.address_part1
|
||||
%br
|
||||
= @invoice_presenter.distributor.address.address_part2
|
||||
%br
|
||||
= @invoice_presenter.distributor.email_address
|
||||
- if @invoice_presenter.distributor.phone.present?
|
||||
%br
|
||||
= @invoice_presenter.distributor.phone
|
||||
- else
|
||||
%strong= @invoice_presenter.distributor.business_address.company
|
||||
%br
|
||||
= @invoice_presenter.distributor.business_address.address_part1
|
||||
%br
|
||||
= @invoice_presenter.distributor.business_address.address_part2
|
||||
%br
|
||||
= @invoice_presenter.distributor.email_address
|
||||
- if @invoice_presenter.distributor.business_address.phone.present?
|
||||
%br
|
||||
= @invoice_presenter.distributor.business_address.phone
|
||||
- if @invoice_presenter.distributor.abn.present?
|
||||
%br
|
||||
= "#{t :abn} #{@invoice_presenter.distributor.abn}"
|
||||
- if @invoice_presenter.distributor.acn.present?
|
||||
%br
|
||||
= "#{t :acn} #{@invoice_presenter.distributor.acn}"
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left", colspan: 2 }
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left" }
|
||||
%br
|
||||
= t :invoice_issued_on
|
||||
= l @invoice_presenter.invoice_date
|
||||
%br
|
||||
= t :date_of_transaction
|
||||
= l @invoice_presenter.order_completed_at.to_date
|
||||
%br
|
||||
= t :order_number
|
||||
= @invoice_presenter.order_number
|
||||
%td{ :align => "right" }
|
||||
= t :invoice_billing_address
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
%strong= @invoice_presenter.bill_address.full_name
|
||||
- if @invoice_presenter&.customer&.code.present?
|
||||
%br
|
||||
= "Code: #{@invoice_presenter.customer.code}"
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
= @invoice_presenter.bill_address.address_part1
|
||||
%br
|
||||
- if @invoice_presenter.bill_address
|
||||
= @invoice_presenter.bill_address.address_part2
|
||||
- if @invoice_presenter.bill_address.phone.present?
|
||||
%br
|
||||
= @invoice_presenter.bill_address.phone
|
||||
- if @invoice_presenter&.customer&.email.present?
|
||||
%br
|
||||
= @invoice_presenter.customer.email
|
||||
|
||||
= render 'spree/admin/orders/invoice_table4'
|
||||
|
||||
- if @invoice_presenter.order_special_instructions.present?
|
||||
%p.callout
|
||||
%strong
|
||||
= t :customer_instructions
|
||||
%p
|
||||
%em= @invoice_presenter.order_special_instructions
|
||||
%p
|
||||
|
||||
|
||||
- if @invoice_presenter.distributor.invoice_text.present?
|
||||
%p
|
||||
= @invoice_presenter.distributor.invoice_text
|
||||
|
||||
= render 'spree/admin/orders/_invoice/payment'
|
||||
|
||||
- if @invoice_presenter.order_note.present?
|
||||
= render partial: 'spree/admin/orders/_invoice/order_note'
|
||||
@@ -61,9 +61,10 @@
|
||||
%li{ class: adjustments_classes }
|
||||
= link_to_with_icon 'icon-cogs', t(:adjustments), spree.admin_order_adjustments_url(@order)
|
||||
|
||||
- invoices_classes = "active" if current == 'Invoices'
|
||||
%li{ class: invoices_classes }
|
||||
= link_to_with_icon 'icon-cogs', t(:invoices), spree.admin_order_invoices_url(@order)
|
||||
- if feature?(:invoices)
|
||||
- invoices_classes = "active" if current == 'Invoices'
|
||||
%li{ class: invoices_classes }
|
||||
= link_to_with_icon 'icon-cogs', t(:invoices), spree.admin_order_invoices_url(@order)
|
||||
|
||||
- if @order.completed?
|
||||
- authorizations_classes = "active" if current == "Return Authorizations"
|
||||
|
||||
@@ -100,7 +100,10 @@ Spree::Core::Engine.routes.draw do
|
||||
end
|
||||
|
||||
resources :adjustments
|
||||
resources :invoices
|
||||
resources :invoices, only: [:index]
|
||||
resource :invoices, only: [] do
|
||||
post :generate, to: :generate
|
||||
end
|
||||
|
||||
resources :payments do
|
||||
member do
|
||||
|
||||
@@ -38,6 +38,12 @@ module OpenFoodNetwork
|
||||
"vouchers" => <<~DESC,
|
||||
Add voucher functionality. Voucher can be managed via Enterprise settings.
|
||||
DESC
|
||||
"white_label" => <<~DESC,
|
||||
Customize shopfront (shop, cart, checkout) and emails without OFN branding.
|
||||
DESC
|
||||
"invoices" => <<~DESC,
|
||||
Enable invoices.
|
||||
DESC
|
||||
}.freeze
|
||||
|
||||
def self.setup!
|
||||
|
||||
Reference in New Issue
Block a user