Sha256: ccad18eab44f4ba96be65044261cb2ee79aa564b8981d1d4535dcc7d95f75fb7

Contents?: true

Size: 756 Bytes

Versions: 26

Compression:

Stored size: 756 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         = Date.current
    @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.14.9 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.8 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.7 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.6 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.5 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.4 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.3 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.2 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.1 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.14.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.13.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.12.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.11.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.10.3 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.10.2 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.10.1 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.10.0 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.9.8 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.9.7 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.9.6 app/services/dorsale/billing_machine/quotation/copy.rb