move automatic invoices to plugin
changes on deposit calculation tiny changes on group order invoice pdf
This commit is contained in:
parent
42a1773a87
commit
e78d1ad072
67 changed files with 5579 additions and 69 deletions
|
|
@ -0,0 +1,10 @@
|
|||
require 'deface'
|
||||
require 'foodsoft_automatic_invoices/engine'
|
||||
require 'foodsoft_automatic_invoices/send_group_order_invoice_pdf'
|
||||
|
||||
|
||||
module FoodsoftAutomaticInvoices
|
||||
def self.enabled?
|
||||
FoodsoftConfig[:use_automatic_invoices]
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
module FoodsoftAutomaticInvoices
|
||||
class Engine < ::Rails::Engine
|
||||
|
||||
initializer 'automatic_invoices.assets.precompile' do |app|
|
||||
app.config.assets.precompile += %w(group_orders.css.less)
|
||||
end
|
||||
|
||||
def default_foodsoft_config(cfg)
|
||||
cfg[:use_automatic_invoices] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
module FoodsoftAutomaticInvoices
|
||||
module SendGroupOrderInvoicePdf
|
||||
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
protected
|
||||
|
||||
def create_invoice_pdf(group_order_invoice)
|
||||
invoice_data = group_order_invoice.load_data_for_invoice
|
||||
invoice_data[:title] = t('documents.group_order_invoice_pdf.title', supplier: invoice_data[:supplier])
|
||||
invoice_data[:no_footer] = true
|
||||
GroupOrderInvoicePdf.new invoice_data
|
||||
end
|
||||
|
||||
def send_group_order_invoice_pdf(group_order_invoice)
|
||||
pdf = create_invoice_pdf(group_order_invoice)
|
||||
send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActiveSupport.on_load(:after_initialize) do
|
||||
Concerns::SendOrderPdf.include FoodsoftAutomaticInvoices::SendGroupOrderInvoicePdf
|
||||
end
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module FoodsoftAutomaticInvoices
|
||||
VERSION = '0.0.1'
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue