Skip to content

Commit

Permalink
* Added support for Line Extras and Name Values to Payment model. Thi…
Browse files Browse the repository at this point in the history
…s is needed to read payments against invoices.

* Released 0.5.0
  • Loading branch information
ruckus committed Jul 17, 2017
1 parent ab1aa69 commit 9dd5e43
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 2 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
@@ -1,3 +1,7 @@
## 0.5.0 (2017-07-17)

* Added support for Line Extras and Name Values to Payment model. This is needed to read payments against invoices.

## 0.4.9 (2017-05-14)

* Adding journal enteries and spec to batch request and response - pull request #380 from nathan-mots/add-journal-entries-to-bulk - thank you!
Expand Down
6 changes: 6 additions & 0 deletions RELEASE.md
Expand Up @@ -3,3 +3,9 @@
* Bump version number in `lib/quickbooks/version.rb`
* Document changes in `HISTORY.md`
* Run `gem release quickbooks-ruby.gemspec` -- requires the `gem-release` gem

* Tag the release
$ git tag -a v0.5.0 -m "0.5.0"

* Push with tags
git push origin --tags
3 changes: 2 additions & 1 deletion lib/quickbooks-ruby.rb
Expand Up @@ -23,6 +23,7 @@
require 'quickbooks/model/document_numbering'
require 'quickbooks/model/global_tax_calculation'
require 'quickbooks/model/has_line_items'
require 'quickbooks/model/name_value'
require 'quickbooks/model/access_token_response'
require 'quickbooks/model/meta_data'
require 'quickbooks/model/class'
Expand All @@ -44,6 +45,7 @@
require 'quickbooks/model/transaction_tax_detail'
require 'quickbooks/model/entity'
require 'quickbooks/model/journal_entry_line_detail'
require 'quickbooks/model/line_ex'
require 'quickbooks/model/line'
require 'quickbooks/model/journal_entry'
require 'quickbooks/model/item_group_line'
Expand All @@ -64,7 +66,6 @@
require 'quickbooks/model/physical_address'
require 'quickbooks/model/invoice_line_item'
require 'quickbooks/model/invoice_group_line_detail'
require 'quickbooks/model/name_value'
require 'quickbooks/model/company_info'
require 'quickbooks/model/customer'
require 'quickbooks/model/delivery_info'
Expand Down
1 change: 1 addition & 0 deletions lib/quickbooks/model/line.rb
Expand Up @@ -14,6 +14,7 @@ class Line < BaseModel
xml_accessor :amount, :from => 'Amount', :as => BigDecimal, :to_xml => to_xml_big_decimal
xml_accessor :detail_type, :from => 'DetailType'
xml_accessor :linked_transactions, :from => 'LinkedTxn', :as => [LinkedTransaction]
xml_accessor :line_extras, :from => 'LineEx', :as => LineEx

#== Various detail types
xml_accessor :sales_item_line_detail, :from => 'SalesItemLineDetail', :as => SalesItemLineDetail
Expand Down
9 changes: 9 additions & 0 deletions lib/quickbooks/model/line_ex.rb
@@ -0,0 +1,9 @@

module Quickbooks
module Model
class LineEx < BaseModel

xml_accessor :name_values, :from => "NameValue", :as => [NameValue]
end
end
end
2 changes: 1 addition & 1 deletion lib/quickbooks/version.rb
@@ -1,5 +1,5 @@
module Quickbooks

VERSION = "0.4.9"
VERSION = "0.5.0"

end
37 changes: 37 additions & 0 deletions spec/fixtures/payment_with_line_extras.xml
@@ -0,0 +1,37 @@
<Payment domain="QBO">
<Id>83</Id>
<SyncToken>0</SyncToken>
<MetaData>
<CreateTime>2017-07-17T14:26:54-07:00</CreateTime>
<LastUpdatedTime>2017-07-17T14:26:54-07:00</LastUpdatedTime>
</MetaData>
<TxnDate>2016-09-16</TxnDate>
<CurrencyRef name="United States Dollar">USD</CurrencyRef>
<Line>
<Amount>2400.00</Amount>
<LinkedTxn>
<TxnId>68</TxnId>
<TxnType>Invoice</TxnType>
</LinkedTxn>
<LineEx>
<NameValue>
<Name>txnId</Name>
<Value>68</Value>
</NameValue>
<NameValue>
<Name>txnOpenBalance</Name>
<Value>2400.00</Value>
</NameValue>
<NameValue>
<Name>txnReferenceNumber</Name>
<Value>1246</Value>
</NameValue>
</LineEx>
</Line>
<CustomerRef name="Acme Enterprises">3</CustomerRef>
<DepositToAccountRef>4</DepositToAccountRef>
<TotalAmt>2400.00</TotalAmt>
<UnappliedAmt>0</UnappliedAmt>
<ProcessPayment>false</ProcessPayment>
</Payment>

16 changes: 16 additions & 0 deletions spec/lib/quickbooks/model/payment_spec.rb
Expand Up @@ -33,4 +33,20 @@
invoice.should be_valid
end

it "can parse payments with LineExtras" do
xml = fixture("payment_with_line_extras.xml")
payment = Quickbooks::Model::Payment.from_xml(xml)
payment.line_items.size.should == 1

line = payment.line_items[0]
line.line_extras.should_not be_nil

extras = line.line_extras.name_values
extras.size.should == 3

txnReferenceNumber = extras.detect { |a| a.name == "txnReferenceNumber" }
txnReferenceNumber.should_not be_nil

end

end

0 comments on commit 9dd5e43

Please sign in to comment.