Sha256: e7c6248fef7cdfb87b303286c8fb8ca3aaf3b97a0c18b760bfe01602242ce4da
Contents?: true
Size: 935 Bytes
Versions: 26
Compression:
Stored size: 935 Bytes
Contents
class Dorsale::BillingMachine::Quotation::ToInvoice < ::Dorsale::Service attr_accessor :quotation, :invoice def initialize(quotation) @quotation = quotation end def call @invoice = Dorsale::BillingMachine::Invoice.new quotation.attributes.each do |k, v| next if k.to_s == "id" next if k.to_s.match /index|tracking|state/ next if k.to_s.end_with?("_at") if invoice.respond_to?("#{k}=") invoice.public_send("#{k}=", v) end end quotation.lines.each do |quotation_line| invoice_line = invoice.lines.new quotation_line.attributes.each do |k, v| next if k.to_s == "id" next if k.to_s.match /index|tracking|state/ next if k.to_s.end_with?("_at") if invoice_line.respond_to?("#{k}=") invoice_line.public_send("#{k}=", v) end end end invoice.date = Time.zone.now.to_date invoice end end
Version data entries
26 entries across 26 versions & 1 rubygems