class IntacctRuby::Functions::CreateARAdjustment

creates ar adjustment instance in Intacct

Public Class Methods

new(attrs = {}) click to toggle source
# File lib/intacct_ruby/functions/create_aradjustment.rb, line 10
def initialize(attrs = {})
  super "create_aradjustment (Customer \##{attrs[:customerid]}, " \
        "(#{timestamp})", attrs
end

Public Instance Methods

to_xml() click to toggle source
# File lib/intacct_ruby/functions/create_aradjustment.rb, line 15
def to_xml
  super do |xml|
    xml.create_aradjustment do
      xml.customerid @attrs[:customerid]

      xml << date_params(:datecreated, @attrs[:datecreated])

      xml.description @attrs[:description]

      xml.aradjustmentitems do
        xml << line_item_params(@attrs[:aradjustmentitems])
      end
    end
  end
end

Private Instance Methods

line_item_params(adjustment_item_attrs) click to toggle source
# File lib/intacct_ruby/functions/create_aradjustment.rb, line 33
def line_item_params(adjustment_item_attrs)
  xml = Builder::XmlMarkup.new

  adjustment_item_attrs.each do |item_params|
    xml.lineitem do
      [:glaccountno, :amount, :memo, :locationid].each do |param_key|
        xml.tag!(param_key) { xml << item_params[param_key].to_s }
      end
    end
  end

  xml.target!
end