Sha256: e9e47e12b22a7763cc213fd26316fb1f0f7f48878a7d9f55ebcaad64621261bb

Contents?: true

Size: 765 Bytes

Versions: 26

Compression:

Stored size: 765 Bytes

Contents

class Dorsale::BillingMachine::Quotation::Copy < ::Dorsale::Service
  attr_accessor :quotation, :copy

  def initialize(quotation)
    @quotation = quotation
  end

  def call
    @copy = quotation.dup

    @quotation.lines.each do |line|
      @copy.lines << line.dup
    end

    @copy.unique_index = nil
    @copy.created_at   = nil
    @copy.updated_at   = nil
    @copy.date         = Time.zone.now.to_date
    @copy.state        = ::Dorsale::BillingMachine::Quotation::STATES.first

    @copy.save!

    @quotation.attachments.each do |attachment|
      new_attachment            = attachment.dup
      new_attachment.attachable = @copy
      new_attachment.file       = File.open(attachment.file.path)
      new_attachment.save!
    end

    @copy
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dorsale-3.8.1 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.8.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.7.8 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.7.7 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.7.6 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.7.5 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.7.4 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.7.2 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.7.1 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.7.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.6.1 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.6.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.5.2 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.5.1 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.5.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.4.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.3.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.2.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.1.7 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.1.6 app/services/dorsale/billing_machine/quotation/copy.rb