Skip to content

Commit

Permalink
Ensure all Id attributes are parsed as strings. Closes #230
Browse files Browse the repository at this point in the history
  • Loading branch information
ruckus committed Mar 25, 2015
1 parent e6e0a62 commit 97414f7
Show file tree
Hide file tree
Showing 77 changed files with 146 additions and 150 deletions.
2 changes: 1 addition & 1 deletion lib/quickbooks/model/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Account < BaseModel

xml_name XML_NODE

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :has_attachment?, :from => 'HasAttachment'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/attachable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Attachable < BaseModel
XML_NODE = "Attachable"
REST_RESOURCE = 'attachable'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :attachable_ref, :as => AttachableRef
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/bill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Bill < BaseModel
XML_NODE = "Bill"
REST_RESOURCE = 'bill'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :doc_number, :from => 'DocNumber'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/bill_line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BillLineItem < BaseModel
ACCOUNT_BASED_EXPENSE_LINE_DETAIL = 'AccountBasedExpenseLineDetail'
ITEM_BASED_EXPENSE_LINE_DETAIL = 'ItemBasedExpenseLineDetail'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :line_num, :from => 'LineNum', :as => Integer
xml_accessor :description, :from => 'Description'
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/bill_payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class BillPayment < BaseModel
XML_NODE = "BillPayment"
REST_RESOURCE = 'billpayment'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :doc_number, :from => 'DocNumber'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/bill_payment_line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BillPaymentLineItem < BaseModel
PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :line_num, :from => 'LineNum', :as => Integer
xml_accessor :description, :from => 'Description'
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Class < BaseModel
include NameEntity::PermitAlterations

xml_name XML_NODE
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :name, :from => 'Name'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/company_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CompanyInfo < BaseModel
REST_RESOURCE = 'companyinfo'

xml_name XML_NODE
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :company_name, :from => 'CompanyName'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/credit_memo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CreditMemo < BaseModel
XML_NODE = "CreditMemo"
REST_RESOURCE = 'creditmemo'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :auto_doc_number, :from => 'AutoDocNumber' # See auto_doc_number! method below for usage
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Customer < BaseModel
include NameEntity::PermitAlterations

xml_name XML_NODE
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :title, :from => 'Title'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/customer_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Model
class CustomerChange < BaseModel
XML_NODE = "Customer"

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :status, :from => '@status'
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
end
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/department.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Department < BaseModel
include NameEntity::PermitAlterations

xml_name XML_NODE
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :name, :from => 'Name'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/deposit_line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DepositLineItem < BaseModel
#== Constants
DEPOSIT_LINE_DETAIL = 'DepositLineDetail'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :line_num, :from => 'LineNum', :as => Integer
xml_accessor :description, :from => 'Description'
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/employee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Employee < BaseModel
include NameEntity::PermitAlterations

xml_name XML_NODE
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :organization?, :from => 'Organization'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/estimate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Estimate < BaseModel
XML_COLLECTION_NODE = "Estimate"
XML_NODE = "Estimate"

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Invoice < BaseModel
XML_NODE = "Invoice"
EMAIL_STATUS_NEED_TO_SEND = 'NeedToSend'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :custom_fields, :from => 'CustomField', :as => [CustomField]
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/invoice_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Model
class InvoiceChange < BaseModel
XML_NODE = "Invoice"

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :status, :from => '@status'
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
end
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/invoice_line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class InvoiceLineItem < BaseModel
PAYMENT_LINE_DETAIL = 'PaymentLineDetail'
DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :line_num, :from => 'LineNum', :as => Integer
xml_accessor :description, :from => 'Description'
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Item < BaseModel
ITEM_TYPES = [INVENTORY_TYPE, NON_INVENTORY_TYPE, SERVICE_TYPE]

xml_name 'Item'
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :name, :from => 'Name'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/item_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Model
class ItemChange < BaseModel
XML_NODE = "Item"

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :status, :from => '@status'
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
end
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/journal_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class JournalEntry < BaseModel
XML_NODE = "JournalEntry"
REST_RESOURCE = 'journalentry'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :doc_number, :from => 'DocNumber'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Line < BaseModel
DISCOUNT_LINE_DETAIL = 'DiscountLineDetail'
JOURNAL_ENTRY_LINE_DETAIL = 'JournalEntryLineDetail'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :line_num, :from => 'LineNum', :as => Integer
xml_accessor :description, :from => 'Description'
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Payment < BaseModel
XML_NODE = "Payment"
REST_RESOURCE = 'payment'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :txn_date, :from => 'TxnDate', :as => Date
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/payment_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PaymentMethod < BaseModel

PAYMENT_METHOD_TYPES = [CREDIT_CARD, NON_CREDIT_CARD]

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :name, :from => 'Name'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/physical_address.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Quickbooks
module Model
class PhysicalAddress < BaseModel
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :line1, :from => 'Line1'
xml_accessor :line2, :from => 'Line2'
xml_accessor :line3, :from => 'Line3'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/purchase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Purchase < BaseModel
XML_COLLECTION_NODE = "Purchase"
XML_NODE = "Purchase"

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :doc_number, :from => 'DocNumber'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/purchase_line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PurchaseLineItem < BaseModel
ACCOUNT_BASED_EXPENSE_LINE_DETAIL = 'AccountBasedExpenseLineDetail'
GROUP_LINE_DETAIL = 'GroupLineDetail'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :line_num, :from => 'LineNum', :as => Integer
xml_accessor :description, :from => 'Description'
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/purchase_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PurchaseOrder < BaseModel
XML_COLLECTION_NODE = "PurchaseOrder"
XML_NODE = "PurchaseOrder"

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :doc_number, :from => 'DocNumber'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/refund_receipt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RefundReceipt < BaseModel
XML_NODE = "RefundReceipt"
REST_RESOURCE = 'refundreceipt'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :auto_doc_number, :from => 'AutoDocNumber' # See auto_doc_number! method below for usage
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/sales_receipt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SalesReceipt < BaseModel
XML_NODE = "SalesReceipt"
REST_RESOURCE = 'salesreceipt'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :auto_doc_number, :from => 'AutoDocNumber' # See auto_doc_number! method below for usage
Expand Down
4 changes: 2 additions & 2 deletions lib/quickbooks/model/tax_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module Quickbooks
module Model
class TaxLine < BaseModel

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :line_num, :from => 'LineNum', :as => Integer
xml_accessor :description, :from => 'Description'
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
xml_accessor :detail_type, :from => 'DetailType'

xml_accessor :tax_line_detail, :from => 'TaxLineDetail', :as => TaxLineDetail

end
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/tax_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TaxRate < BaseModel
XML_NODE = "TaxRate"
REST_RESOURCE = "taxrate"

xml_accessor :id, :from => "Id", :as => Integer
xml_accessor :id, :from => "Id"
xml_accessor :sync_token, :from => "SyncToken", :as => Integer
xml_accessor :meta_data, :from => "MetaData", :as => MetaData
xml_accessor :name, :from => "Name"
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/term.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Term < BaseModel
XML_NODE = "Term"
REST_RESOURCE = 'term'

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :name, :from => 'Name'
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/time_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TimeActivity < BaseModel

xml_name XML_NODE

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData

Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/vendor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Vendor < BaseModel
include NameEntity::PermitAlterations

xml_name XML_NODE
xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :attachable_ref, :from => 'AttachableRef', :as => BaseReference
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/vendor_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Model
class VendorChange < BaseModel
XML_NODE = "Vendor"

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :status, :from => '@status'
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
end
Expand Down
2 changes: 1 addition & 1 deletion lib/quickbooks/model/vendor_credit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class VendorCredit < BaseModel
XML_COLLECTION_NODE = "VendorCredit"
XML_NODE = "VendorCredit"

xml_accessor :id, :from => 'Id', :as => Integer
xml_accessor :id, :from => 'Id'
xml_accessor :sync_token, :from => 'SyncToken', :as => Integer
xml_accessor :meta_data, :from => 'MetaData', :as => MetaData
xml_accessor :doc_number, :from => 'DocNumber'
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/quickbooks/model/batch_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
item_res2.bId.should == "2b"
item_res2.should_not be_a_fault
item_res2.customer.should_not be_nil
item_res2.customer.id.should == 19891
item_res2.customer.id.should == "19891"

item_res3 = batch_response.response_items[2]
item_res3.bId.should == "3c"
item_res3.should_not be_a_fault
item_res3.item.should_not be_nil
item_res3.item.id.should == 19891
item_res3.item.id.should == "19891"

item_res4 = batch_response.response_items[3]
item_res4.account.should_not be_nil
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/quickbooks/model/bill_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
bill.line_items.size.should == 2

line_item1 = bill.line_items[0]
line_item1.id.should == 1
line_item1.id.should == "1"
line_item1.amount.should == 700.0
line_item1.account_based_expense_item?.should == true
line_item1.account_based_expense_line_detail.account_ref.value.should == "42"
Expand All @@ -25,7 +25,7 @@
line_item1.account_based_expense_line_detail.tax_code_ref.to_s.should == "NON"

line_item2 = bill.line_items[1]
line_item2.id.should == 2
line_item2.id.should == "2"
line_item2.amount.should == 55.12
line_item2.account_based_expense_item?.should == true
line_item2.account_based_expense_line_detail.account_ref.value.should == "77"
Expand Down
Loading

0 comments on commit 97414f7

Please sign in to comment.