mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Check for enterprise_number_required_on_invoices boolean
if true, then can edit invoice ; if false, then print a confirm alert popup to specify that a enterprise number must be set for this enterprise
This commit is contained in:
@@ -44,6 +44,14 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
def print_invoice_link
|
||||
if @order.distributor.can_invoice?
|
||||
print_invoice_link_with_url
|
||||
else
|
||||
notify_about_required_enterprise_number
|
||||
end
|
||||
end
|
||||
|
||||
def ticket_links
|
||||
return [] unless Spree::Config[:enable_receipt_printing?]
|
||||
|
||||
@@ -78,13 +86,20 @@ module Spree
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name) }
|
||||
end
|
||||
|
||||
def print_invoice_link
|
||||
def print_invoice_link_with_url
|
||||
{ name: t(:print_invoice),
|
||||
url: spree.print_admin_order_path(@order),
|
||||
icon: 'icon-print',
|
||||
target: "_blank" }
|
||||
end
|
||||
|
||||
def notify_about_required_enterprise_number
|
||||
{ name: t(:print_invoice),
|
||||
url: "#",
|
||||
icon: 'icon-print',
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name) }
|
||||
end
|
||||
|
||||
def print_ticket_link
|
||||
{ name: t(:print_ticket),
|
||||
url: print_ticket_admin_order_path(@order),
|
||||
|
||||
@@ -408,6 +408,8 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def can_invoice?
|
||||
return true unless Spree::Config.enterprise_number_required_on_invoices?
|
||||
|
||||
abn.present?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user