Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Implementing item_based_expense_line_detail
diff --git a/lib/quickbooks-ruby.rb b/lib/quickbooks-ruby.rb
index dbf6a6e..51fb518 100644
--- a/lib/quickbooks-ruby.rb
+++ b/lib/quickbooks-ruby.rb
@@ -29,6 +29,7 @@ require 'quickbooks/model/discount_line_detail'
require 'quickbooks/model/discount_override'
require 'quickbooks/model/payment_line_detail'
require 'quickbooks/model/account_based_expense_line_detail'
+require 'quickbooks/model/item_based_expense_line_detail'
require 'quickbooks/model/linked_transaction'
require 'quickbooks/model/tax_line_detail'
require 'quickbooks/model/tax_line'
diff --git a/lib/quickbooks/model/bill_line_item.rb b/lib/quickbooks/model/bill_line_item.rb
index d8ae206..34c3f9f 100644
--- a/lib/quickbooks/model/bill_line_item.rb
+++ b/lib/quickbooks/model/bill_line_item.rb
@@ -4,6 +4,7 @@ module Quickbooks
#== Constants
ACCOUNT_BASED_EXPENSE_LINE_DETAIL = 'AccountBasedExpenseLineDetail'
+ ITEM_BASED_EXPENSE_LINE_DETAIL = 'ItemBasedExpenseLineDetail'
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :line_num, :from => 'LineNum', :as => Integer
@@ -13,11 +14,16 @@ module Quickbooks
#== Various detail types
xml_accessor :account_based_expense_line_detail, :from => 'AccountBasedExpenseLineDetail', :as => AccountBasedExpenseLineDetail
+ xml_accessor :item_based_expense_line_detail, :from => 'ItemBasedExpenseLineDetail', :as => ItemBasedExpenseLineDetail
def account_based_expense_item?
detail_type.to_s == ACCOUNT_BASED_EXPENSE_LINE_DETAIL
end
+ def item_based_expense_item?
+ detail_type.to_s == ITEM_BASED_EXPENSE_LINE_DETAIL
+ end
+
end
end
end
diff --git a/lib/quickbooks/model/item_based_expense_line_detail.rb b/lib/quickbooks/model/item_based_expense_line_detail.rb
index 2e72a0d..1594c62 100644
--- a/lib/quickbooks/model/item_based_expense_line_detail.rb
+++ b/lib/quickbooks/model/item_based_expense_line_detail.rb
@@ -1,3 +1,5 @@
+require 'quickbooks/model/markup_info'
+
module Quickbooks
module Model
class ItemBasedExpenseLineDetail < BaseModel
diff --git a/spec/lib/quickbooks/model/bill_spec.rb b/spec/lib/quickbooks/model/bill_spec.rb
index 8dc92ae..6e6c5fd 100644
--- a/spec/lib/quickbooks/model/bill_spec.rb
+++ b/spec/lib/quickbooks/model/bill_spec.rb
@@ -36,4 +36,11 @@ describe "Quickbooks::Model::Bill" do
line_item2.account_based_expense_line_detail.tax_code_ref.to_s.should == "NON"
end
+ it "can parse an Item-based bill from XML" do
+ xml = fixture("bill_line_item_expense.xml")
+ bill = Quickbooks::Model::Bill.from_xml(xml)
+ line_item1 = bill.line_items[0]
+ line_item1.item_based_expense_item?.should == true
+ end
+
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.