This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Bis Dezember | |
bis_dezember = Invoice.where("state = 'r2' AND created_at < '2012-12-01'") #111 | |
@context = Time.now.to_i.to_s | |
bis_dezember.each{|r| r.updated_at = Date.parse('2012-12-18'); r.save; InvoiceStateTransition.create(:invoice_id => r.id, :event => 'second_inv', :from => 'csv', :to => 'r2', :context => @context)} | |
# Ab Dezember | |
ab_dezember = Invoice.where("state = 'r2' AND created_at >= '2012-12-01'") #111 | |
@context = Time.now.to_i.to_s | |
ab_dezember.each{|r| r.paid; r.reopen} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_invoice(invoice, out) | |
i = invoice | |
o = i.order_cart | |
l = i.customer.lang[0..1].downcase === 'de' ? 'de' : 'en' # unoptimal, reicht aber im Augenblick | |
params = {:@invoice_address => o.invoice_address, :@order_cart => o, :@shipments => o.shipments, :@invoice => i} | |
Clixxie::PdfGenerator.from_template "invoice_mailer/invoice_2_#{l}.pdf.erb", out, "#{i.invoice_number}_2r.pdf", params | |
end | |
# Usage | |
# print_invoice(Invoice.last, "mahnung/out") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_invoice(invoice, out) | |
i = invoice | |
o = i.order_cart | |
l = i.customer.lang[0..1].downcase === 'de' ? 'de' : 'en' # unoptimal, reicht aber im Augenblick | |
params = {:@invoice_address => o.invoice_address, :@order_cart => o, :@shipments => o.shipments, :@invoice => i, :@filedate => Date.today} | |
Clixxie::PdfGenerator.from_template "invoice_mailer/invoice_#{l}.pdf.erb", out, "#{i.invoice_number}.pdf", params | |
end | |
# Usage | |
# print_invoice(Invoice.last, "~/Downloads") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zip/zip' | |
def zip(zipfile_name, *input_filenames) | |
Zip::ZipFile.open(zipfile_name, Zip::ZipFile::CREATE) do |zipfile| | |
input_filenames.each do |filename| | |
zipfile.add(File.basename(filename), filename) | |
end | |
end | |
end | |
# usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_blanks(filename) | |
nonblank, ranges, range_first_val, range_last_val = [], [], 0, 0 | |
File.open(filename, "rb") do |io| | |
reader = PDF::Reader.new(io) | |
reader.pages.each_with_index do |page, i| | |
nonblank << (i + 1) unless page.text.length.zero? | |
end | |
range_first_val, range_last_val = nonblank.first, nonblank.last | |
range_first_val = -1 if nonblank.length === reader.pages.length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_invoice(invoice, out) | |
i = invoice | |
o = i.order_cart | |
l = i.customer.lang[0..1].downcase === 'de' ? 'de' : 'en' # unoptimal, reicht aber im Augenblick | |
params = {:@invoice_address => o.invoice_address, :@order_cart => o, :@shipments => o.shipments, :@invoice => i, :@filedate => Date.today} | |
Clixxie::PdfGenerator.from_template "invoice_mailer/mahnung_1_de.pdf.erb", out, "#{i.invoice_number}_1m.pdf", params | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_invoice(invoice, out) | |
i = invoice | |
o = i.order_cart | |
l = i.customer.lang[0..1].downcase === 'de' ? 'de' : 'en' # unoptimal, reicht aber im Augenblick | |
params = {:@invoice_address => o.invoice_address, :@order_cart => o, :@shipments => o.shipments, :@invoice => i, :@filedate => Date.today} | |
Clixxie::PdfGenerator.from_template "invoice_mailer/mahnung_1_en.pdf.erb", out, "#{i.invoice_number}_1m.pdf", params | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_invoice(invoice, out) | |
i = invoice | |
o = i.order_cart | |
l = i.customer.lang[0..1].downcase === 'de' ? 'de' : 'en' # unoptimal, reicht aber im Augenblick | |
params = {:@invoice_address => o.invoice_address, :@order_cart => o, :@shipments => o.shipments, :@invoice => i, :@filedate => Date.today} | |
Clixxie::PdfGenerator.from_template "invoice_mailer/mahnung_2_en.pdf.erb", out, "#{i.invoice_number}_2m.pdf", params | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_invoice(invoice, out) | |
i = invoice | |
o = i.order_cart | |
l = i.customer.lang[0..1].downcase === 'de' ? 'de' : 'en' # unoptimal, reicht aber im Augenblick | |
params = {:@invoice_address => o.invoice_address, :@order_cart => o, :@shipments => o.shipments, :@invoice => i, :@filedate => Date.today} | |
Clixxie::PdfGenerator.from_template "invoice_mailer/mahnung_2_de.pdf.erb", out, "#{i.invoice_number}_2m.pdf", params | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_test_orders(destination_server, number_of_test_orders) | |
Settings.crm[:host] = "https://" + destination_server | |
return 0 if number_of_test_orders.zero? | |
crm_client = Clixxie::CrmClient::CrmClient.new | |
orders_stack = Order.last(number_of_test_orders) | |
number_of_test_orders.times do |i| | |
crm_client.post_order(orders_stack[i]) | |
end | |
end | |
OlderNewer