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.9.5 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.9.4 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.9.3 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.9.2 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.9.1 app/services/dorsale/billing_machine/quotation/copy.rb
dorsale-3.9.0 app/services/dorsale/billing_machine/quotation/copy.rb