Sha256: 308d84579ae4079b00abd97ca322baaf5aaccbeb06d24d0c88edd1e08487046e

Contents?: true

Size: 1.45 KB

Versions: 53

Compression:

Stored size: 1.45 KB

Contents

module IntacctRB
  class Attachment < IntacctRB::Base
    attr_accessor :customer_data
    define_hook :custom_bill_fields, :bill_item_fields

    def create
      return false if object.intacct_system_id.present?

      send_xml('create') do |xml|
        xml.function(controlid: "f1") {
          xml.create_supdoc {
            attachment_xml xml
          }
        }
      end

      if !successful?
        raise IntacctRB::Exceptions::Attachment.new(response.at('//error//description2'))
      end

      object.intacct_id
    end

    def get_date_at(xpath, object)
      year = object.at("#{xpath}/year").content
      month = object.at("#{xpath}/month").content
      day = object.at("#{xpath}/day").content
      if [year,month,day].any?(&:empty?)
        nil
      else
        Date.new(year.to_i,month.to_i,day.to_i)
      end
    end

    def attachment_xml xml
      xml.supdocid object.supdoc_id
      xml.supdocfoldername object.folder_name
      xml.attachments {
        object.attachments.each do |attachment|
          xml.attachment {
            xml.attachmentname attachment.name
            xml.attachmenttype attachment.type
            xml.attachmentdata attachment.data
          }
        end
      }
    end

    def set_intacct_system_id
      object.intacct_system_id = intacct_object_id
    end

    def delete_intacct_system_id
      object.intacct_system_id = nil
    end

    def delete_intacct_key
      object.intacct_key = nil
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
intacctrb-0.9.6 lib/intacctrb/attachment.rb
intacctrb-0.9.5 lib/intacctrb/attachment.rb
intacctrb-0.9.4 lib/intacctrb/attachment.rb
intacctrb-0.9.3 lib/intacctrb/attachment.rb
intacctrb-0.9.2 lib/intacctrb/attachment.rb
intacctrb-0.9.1 lib/intacctrb/attachment.rb
intacctrb-0.9.0 lib/intacctrb/attachment.rb
intacctrb-0.8.21 lib/intacctrb/attachment.rb
intacctrb-0.8.20 lib/intacctrb/attachment.rb
intacctrb-0.8.19 lib/intacctrb/attachment.rb
intacctrb-0.8.18 lib/intacctrb/attachment.rb
intacctrb-0.8.17 lib/intacctrb/attachment.rb
intacctrb-0.8.16 lib/intacctrb/attachment.rb
intacctrb-0.8.15 lib/intacctrb/attachment.rb
intacctrb-0.8.14 lib/intacctrb/attachment.rb
intacctrb-0.8.13 lib/intacctrb/attachment.rb
intacctrb-0.8.12 lib/intacctrb/attachment.rb
intacctrb-0.8.11 lib/intacctrb/attachment.rb
intacctrb-0.8.10 lib/intacctrb/attachment.rb
intacctrb-0.8.9 lib/intacctrb/attachment.rb