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_3m(invoices, out) | |
os = invoices.map(&:order_cart) | |
params = {:@invoice_address => os.last.invoice_address, :@order_carts => os, :@invoices => invoices, :@filedate => Date.today} | |
Clixxie::PdfGenerator.from_template("invoice_mailer/mahnung_3_de.pdf.erb", out, "K#{invoices.first.customer_id}_3m.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
# NUTZLOS!!!! | |
def print_invoice(invoice) | |
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", "invoice/#{i.customer_id}", "#{i.invoice_number}_2m.pdf", params | |
puts "invoice/#{i.customer_id}/#{i.invoice_number}_2m.pdf geschrieben." | |
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 migrate | |
timestamp = Time.now.to_i.to_s | |
echt_ink = Invoice.where(:invoice_number => ['B12-001765','B12-001849','B12-001850','B12-001851','B12-002119','B12-002120','B12-002121','B12-002684','B12-003439','B12-003449','B12-003450','B12-003482','B12-003520','B12-003574','B12-003708','B12-004053','B12-004055','B13-001241','B13-001329','B13-001330','B13-001343','B13-001345','B13-001385','B12-004155']) | |
puts echt_ink.count #24 | |
all_ink = Invoice.where(:state => 'ink') | |
puts all_ink.count #70 | |
falsch_ink = all_ink - echt_ink | |
puts falsch_ink.count #46 | |
# Zusätzliche Tests | |
puts falsch_ink.map(&:state).uniq #["ink"] |
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
object mergesort { | |
def mergesort(a: List[Int], b: List[Int]): List[Int] = (a, b) match { | |
case (Nil, Nil) => Nil | |
case (xs, Nil) => xs | |
case (Nil, ys) => ys | |
case (x :: xs, y :: ys) => if (x < y) x :: mergesort(xs, b) else y :: mergesort(a, ys) | |
} //> mergesort: (a: List[Int], b: List[Int])List[Int] | |
def sort(a: List[Int]): List[Int] = a match { |
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 bearbeitungszeiten(monat = Date.today.month, location = Tempfile.new('Bearbeitungszeiten')) | |
monat = monat.to_i | |
ois = OrderItem.where(:created_at => Date.parse("2013-#{monat}-01")..Date.parse("2013-#{monat + 1}-01")) | |
CSV.open(location, "w", {:col_sep => ";"}) do |csv| | |
ois.each do |oi| | |
t0 = OrderItemStateTransition.where(:order_item_id => oi.id, :to => 'new').first.created_at.to_date | |
delivered = OrderItemStateTransition.where(:order_item_id => oi.id, :to => 'to_delivery').last | |
delivered.nil? ? t1 = Date.today : t1 = delivered.created_at.to_date | |
csv << [oi.code, t0.to_s, t1.to_s, (t1 - t0).to_i.to_s] | |
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_delivery_note(shipments, folder) | |
app_signature = AppSignature.new.app_signature(shipments.first.app_id) | |
params = {:@invoice_address => shipments.first.invoice_address, :@delivery_address => shipments.first.delivery_address, :@shipments => shipments, :@filedate => Date.today} | |
Clixxie::PdfGenerator.from_template("invoice_mailer/lieferschein.pdf.erb", folder, "#{app_signature}#{shipments.first.order_cart_id}_#{app_signature}#{shipments.first.delivery_address_id}_LS.pdf", params) | |
end | |
class AppSignature | |
include Clixxie::ShipmentTools | |
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
# Duplicates one order. | |
# @param order_cart_id int | |
# @return order_cart_id of the duplicate | |
# @see To be launched on vps-api-* | |
# 07.11.2013: Feste Rechnungsadresse für alle Nachdrucke. | |
def duplicate_order(order_cart_id, invoice_address_id = 38486) | |
# fotobuch-api-dev: 3, flexiphoto-api: 2388, flexiphoto-dev: 6556, vps-polapix: 1601, vps-calendar: 2948 | |
# 1. Datensammlung | |
o = Order.find(order_cart_id) |
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
stats = [] | |
(Date.parse('2012-09-01') .. Date.today).select{|d| d.day === 1}.map{|erster| erster - 1.month .. erster}.each do |range| | |
Invoice.state_machine.states.map(&:name).each do |state| | |
rechnungen = Invoice.where(:created_at => range, :state => state.to_s) | |
bestellungen = rechnungen.map(&:order_cart) | |
stats << [range.first.strftime("%m.%Y"), state.to_s, rechnungen.count, ActionController::Base.helpers.number_with_precision(bestellungen.sum(&:final_amount).to_f, :precision => 2)] | |
end | |
end | |
stats |
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
# Duplicates one order. | |
# @param order_cart_id int | |
# @return order_cart_id of the duplicate | |
# @see To be launched on vps-api-* | |
# 07.11.2013: Feste Rechnungsadresse für alle Nachdrucke. | |
def duplicate_order_flexiphoto(order_cart_id, invoice_address_id = 2388) | |
# fotobuch-api: 38486, fotobuch-api-dev: 3, flexiphoto-api: 2388, flexiphoto-dev: 6556 | |
# 1. Datensammlung | |
o = Order.find(order_cart_id) |
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
# string product_code - ["CLXB5S1F", "CLXB5S2F", "CLXB5S1Q", "CLXB5S2Q", "CLXB6S1F", "CLXB6S2F", "CLXF3S1F", "CLXF4S1F", "CLXF5S1F", "CLXF6S1F"] | |
# Date start_date - mit in den Report eingeschlossen | |
# Date end_date - mit in den Report eingeschlossen | |
# string path - der User muss schreibberechtigt darauf sein | |
def make_happy_hour_stats( product_code, start_date, end_date, path ) | |
timespan = ( start_date .. end_date ) | |
header = timespan.map( &:to_s ).unshift( "Uhr" ) | |
CSV.open( path, "w" ) do | csv | | |
csv << [product_code] | |
csv << header |