Class: Dorsale::BillingMachine::Quotation::ToInvoice
- Defined in:
- app/services/dorsale/billing_machine/quotation/to_invoice.rb
Instance Attribute Summary collapse
-
#invoice ⇒ Object
Returns the value of attribute invoice.
-
#quotation ⇒ Object
Returns the value of attribute quotation.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(quotation) ⇒ ToInvoice
constructor
A new instance of ToInvoice.
Methods inherited from Service
Constructor Details
#initialize(quotation) ⇒ ToInvoice
Returns a new instance of ToInvoice.
4 5 6 |
# File 'app/services/dorsale/billing_machine/quotation/to_invoice.rb', line 4 def initialize(quotation) @quotation = quotation end |
Instance Attribute Details
#invoice ⇒ Object
Returns the value of attribute invoice.
2 3 4 |
# File 'app/services/dorsale/billing_machine/quotation/to_invoice.rb', line 2 def invoice @invoice end |
#quotation ⇒ Object
Returns the value of attribute quotation.
2 3 4 |
# File 'app/services/dorsale/billing_machine/quotation/to_invoice.rb', line 2 def quotation @quotation end |
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/dorsale/billing_machine/quotation/to_invoice.rb', line 8 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 |