Method: NetSuite::Utilities#append_memo

Defined in:
lib/netsuite/utilities.rb

#append_memo(ns_record, added_memo, opts = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/netsuite/utilities.rb', line 37

def append_memo(ns_record, added_memo, opts = {})
  opts[:skip_if_exists] ||= false

  memo_key = if ns_record.class == NetSuite::Records::Customer
    :comments
  else
    :memo
  end

  return if opts[:skip_if_exists] &&
    ns_record.send(memo_key) &&
    ns_record.send(memo_key).include?(added_memo)

  if ns_record.send(memo_key)
    ns_record.send(:"#{memo_key}=", "#{ns_record.send(memo_key)}. #{added_memo}")
  else
    ns_record.send(:"#{memo_key}=", added_memo.to_s)
  end

  ns_record
end