Skip to content

Commit

Permalink
[CLD-737-item-receipt-expenses]
Browse files Browse the repository at this point in the history
Why:

*There was not support for expense lines to show up on item receipts in Netsuite

This change addresses the need by:

*added in the item receipt expense list and item receipt expense models to the gem

Ticket

* [CLD-737]
  • Loading branch information
reginad1 committed Mar 17, 2020
1 parent f9b05f7 commit 7fbe5b2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/netsuite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ module Records
autoload :ItemMember, 'netsuite/records/item_member'
autoload :ItemMemberList, 'netsuite/records/item_member_list'
autoload :ItemReceipt, 'netsuite/records/item_receipt'
autoload :ItemReceiptExpenseList, 'netsuite/records/item_receipt_expense_list'
autoload :ItemReceiptExpense, 'netsuite/records/item_receipt_expense'
autoload :ItemReceiptItemList, 'netsuite/records/item_receipt_item_list'
autoload :ItemReceiptItem, 'netsuite/records/item_receipt_item'
autoload :ItemVendor, 'netsuite/records/item_vendor'
Expand Down
1 change: 1 addition & 0 deletions lib/netsuite/records/item_receipt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ItemReceipt
# :landed_costs_list

field :item_list, ItemReceiptItemList
field :expense_list, ItemReceiptExpenseList
field :custom_field_list, CustomFieldList

attr_reader :internal_id
Expand Down
36 changes: 36 additions & 0 deletions lib/netsuite/records/item_receipt_expense.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module NetSuite
module Records
class ItemReceiptExpense
include Support::Fields
include Support::RecordRefs
include Support::Records
include Namespaces::TranPurch

fields :account, :amount, :line, :mark_received, :memo, :order_line

field :options, CustomFieldList
field :custom_field_list, CustomFieldList

def initialize(attributes_or_record = {})
case attributes_or_record
when Hash
initialize_from_attributes_hash(attributes_or_record)
when self.class
initialize_from_record(attributes_or_record)
end
end

def initialize_from_record(record)
self.attributes = record.send(:attributes)
end

def to_record
rec = super
if rec["#{record_namespace}:customFieldList"]
rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
end
rec
end
end
end
end
11 changes: 11 additions & 0 deletions lib/netsuite/records/item_receipt_expense_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module NetSuite
module Records
class ItemReceiptExpenseList < Support::Sublist
include Namespaces::TranPurch

sublist :expense, ItemReceiptExpense

alias :expenses :expense
end
end
end

0 comments on commit 7fbe5b2

Please sign in to comment.