This file contains hidden or 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 hidden or 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 hidden or 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
| # Shipment.rb | |
| InvoiceMailer.sent_invoice(self.order_cart.invoices.last).deliver if self.order_cart.shipments.one?{|s| s.state == 'shipped'} | |
| InvoiceMailer.sent_invoice(self.order_cart.invoices.last).deliver if self.order_cart.order_items.one?{|b| b.state == 'done'} |
This file contains hidden or 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
| OrderItem.where( :state => Settings.shipping.timeplan.keys, :created_at => Date.today - 1.year .. Date.tomorrow - Settings.shipping.timeplan.values.min ) |
This file contains hidden or 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 t_online(filename) | |
| File.foreach(filename) do |f| | |
| InvoiceMailer.sent_order_confirmation(Customer.where(:email => f.squish).first.order_carts.last).deliver | |
| InvoiceMailer.sent_invoice(Customer.where(:email => f.squish).first.order_carts.last.invoices.last).deliver | |
| end | |
| end |
This file contains hidden or 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
| OrderItem.where(:created_at => Date.parse('2013-04-01')..Date.parse('2013-07-31')).select{|b| b.address.country_code == "CH"}.map(&:quantity).sum | |
| # noch flexibler | |
| OrderItem.where(:created_at => Date.parse('2013-04-01')..Date.today).select{|b| b.address.country_code == "CH"}.map(&:quantity).sum |
This file contains hidden or 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
| package week5 | |
| object higherOrderListFunctions { | |
| val l: List[Int] = new Cons[Int](5, Nil) //> l : week5.List[Int] = 5,. | |
| l.head //> res0: Int = 5 | |
| l.tail //> res1: week5.List[Int] = . | |
| l.map(x => x * 2).head //> res2: Int = 10 | |
| def squareList1(xs: List[Int]): List[Int] = xs match { | |
| case Nil => Nil |
This file contains hidden or 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 perform(timestamp, settings) | |
| Dir.glob(Pathname.new(settings["in"]).join(settings["format"]).to_s).each do |filename| | |
| xlsx_name = Pathname.new(settings["in"]).join("#{File.basename(filename, ".*")}.xlsx").to_s | |
| FileUtils.mv(filename, xlsx_name) | |
| xls = Roo::Spreadsheet.open(xlsx_name) | |
| sh = xls.sheet(0) | |
| CSV.open(filename, "w", {:col_sep => "\t"}) do |csv| | |
| (0..sh.last_row).each do |rn| | |
| row = sh.row(rn) | |
| next if (/\d{4}-\d{2}-\d{2}|Beleg.+/).match(row[0].to_s).nil? |
This file contains hidden or 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 render_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.render_erb "invoice_mailer/invoice_#{l}.pdf.erb", params | |
| end | |
| # usage render_invoice(Invoice.last) |
This file contains hidden or 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 trennzeichen(formatted_number) | |
| raise ArgumentError unless formatted_number.is_a?(String) | |
| return -1 if formatted_number.split(",").count == 1 && formatted_number.split(".").count == 1 # nix | |
| return 0 if formatted_number.split(",").count > 1 && formatted_number.split(".").count == 1 # bloß Komma | |
| return 1 if formatted_number.split(".").count > 1 && formatted_number.split(",").count == 1 # bloß Punkt | |
| # Gibt's beides, ein Komma UND einen Punkt? | |
| teile = formatted_number.split(",").map { |teil| |