xeroizer 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
data/lib/xeroizer.rb CHANGED
@@ -52,6 +52,7 @@ require 'xeroizer/models/phone'
52
52
  require 'xeroizer/models/tax_rate'
53
53
  require 'xeroizer/models/tracking_category'
54
54
  require 'xeroizer/models/tracking_category_child'
55
+ require 'xeroizer/models/journal_line_tracking_category'
55
56
 
56
57
  require 'xeroizer/report/factory'
57
58
 
@@ -20,7 +20,7 @@ module Xeroizer
20
20
  string :tax_type
21
21
  string :tax_name
22
22
 
23
- has_many :tracking_categories, :model_name => 'TrackingCategoryChild'
23
+ has_many :tracking_categories, :model_name => 'JournalLineTrackingCategory'
24
24
 
25
25
  end
26
26
 
@@ -0,0 +1,20 @@
1
+ module Xeroizer
2
+ module Record
3
+
4
+ class JournalLineTrackingCategoryModel < BaseModel
5
+
6
+ set_xml_root_name 'TrackingCategories'
7
+ set_xml_node_name 'TrackingCategory'
8
+
9
+ end
10
+
11
+ class JournalLineTrackingCategory < Base
12
+
13
+ string :name
14
+ string :option
15
+ guid :tracking_category_id
16
+
17
+ end
18
+
19
+ end
20
+ end
@@ -24,7 +24,8 @@ module Xeroizer
24
24
  string :status
25
25
  string :line_amount_types
26
26
  string :narration
27
- string :url, :api_name => 'URL'
27
+ string :url
28
+ boolean :show_on_cash_basis_reports
28
29
  datetime :updated_date_utc, :api_name => 'UpdatedDateUTC'
29
30
 
30
31
  has_many :journal_lines, :model_name => 'ManualJournalLine'
@@ -13,6 +13,7 @@ module Xeroizer
13
13
  class_inheritable_attributes :permissions
14
14
 
15
15
  class_inheritable_attributes :xml_root_name
16
+ class_inheritable_attributes :optional_xml_root_name
16
17
  class_inheritable_attributes :xml_node_name
17
18
 
18
19
  include BaseModelHttpProxy
@@ -57,6 +58,11 @@ module Xeroizer
57
58
  self.xml_root_name = root_name
58
59
  end
59
60
 
61
+ # Method to add an extra top-level node to use in has_many associations.
62
+ def set_optional_xml_root_name(optional_root_name)
63
+ self.optional_root_name = optional_root_name
64
+ end
65
+
60
66
  end
61
67
 
62
68
  public
@@ -56,7 +56,7 @@ module Xeroizer
56
56
 
57
57
  # Turn a record into its XML representation.
58
58
  def to_xml(b = Builder::XmlMarkup.new(:indent => 2))
59
- optional_root_tag(parent.class.xml_root_name, b) do |b|
59
+ # optional_root_tag(parent.class.xml_root_name, b) do |b|
60
60
  b.tag!(parent.class.xml_node_name || parent.model_name) {
61
61
  attributes.each do | key, value |
62
62
  field = self.class.fields[key]
@@ -64,7 +64,7 @@ module Xeroizer
64
64
  xml_value_from_field(b, field, value) unless value.nil?
65
65
  end
66
66
  }
67
- end
67
+ # end
68
68
  end
69
69
 
70
70
  protected
@@ -0,0 +1,22 @@
1
+ require "test_helper"
2
+
3
+ class JournalLineTest < Test::Unit::TestCase
4
+ include TestHelper
5
+ include Xeroizer::Record
6
+
7
+ def setup
8
+ @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
9
+ end
10
+
11
+ it "journal_line tracking specified correctly" do
12
+ invoice = @client.Journal.build
13
+ line = invoice.add_journal_line({})
14
+
15
+ line.add_tracking_category(:name => "Name 1", :option => "Option 1")
16
+ line.add_tracking_category(:name => "Name 2", :option => "Option 2")
17
+
18
+ doc = Nokogiri::XML(line.to_xml)
19
+ assert_equal 2, doc.xpath("/JournalLine/TrackingCategories/TrackingCategory").size
20
+ end
21
+
22
+ end
@@ -1,7 +1,23 @@
1
1
  require "test_helper"
2
2
 
3
3
  class LineItemTest < Test::Unit::TestCase
4
+ include TestHelper
4
5
  include Xeroizer::Record
6
+
7
+ def setup
8
+ @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
9
+ end
10
+
11
+ it "line_item tracking specified correctly" do
12
+ invoice = @client.Invoice.build
13
+ line_item = invoice.add_line_item({})
14
+
15
+ line_item.add_tracking(:name => "Name 1", :option => "Option 1")
16
+ line_item.add_tracking(:name => "Name 2", :option => "Option 2")
17
+
18
+ doc = Nokogiri::XML(line_item.to_xml)
19
+ assert_equal 2, doc.xpath("/LineItem/Tracking/TrackingCategory").size
20
+ end
5
21
 
6
22
  it "line_amount equals unit_price times quantity" do
7
23
  line_item = LineItem.new(nil)
data/xeroizer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "xeroizer"
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wayne Robinson"]
@@ -52,6 +52,7 @@ Gem::Specification.new do |s|
52
52
  "lib/xeroizer/models/item_sales_details.rb",
53
53
  "lib/xeroizer/models/journal.rb",
54
54
  "lib/xeroizer/models/journal_line.rb",
55
+ "lib/xeroizer/models/journal_line_tracking_category.rb",
55
56
  "lib/xeroizer/models/line_amount_type.rb",
56
57
  "lib/xeroizer/models/line_item.rb",
57
58
  "lib/xeroizer/models/line_item_sum.rb",
@@ -334,6 +335,7 @@ Gem::Specification.new do |s|
334
335
  "test/unit/models/contact_test.rb",
335
336
  "test/unit/models/credit_note_test.rb",
336
337
  "test/unit/models/invoice_test.rb",
338
+ "test/unit/models/journal_line_test.rb",
337
339
  "test/unit/models/line_item_sum_test.rb",
338
340
  "test/unit/models/line_item_test.rb",
339
341
  "test/unit/oauth_config_test.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xeroizer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wayne Robinson
@@ -238,6 +238,7 @@ files:
238
238
  - lib/xeroizer/models/item_sales_details.rb
239
239
  - lib/xeroizer/models/journal.rb
240
240
  - lib/xeroizer/models/journal_line.rb
241
+ - lib/xeroizer/models/journal_line_tracking_category.rb
241
242
  - lib/xeroizer/models/line_amount_type.rb
242
243
  - lib/xeroizer/models/line_item.rb
243
244
  - lib/xeroizer/models/line_item_sum.rb
@@ -520,6 +521,7 @@ files:
520
521
  - test/unit/models/contact_test.rb
521
522
  - test/unit/models/credit_note_test.rb
522
523
  - test/unit/models/invoice_test.rb
524
+ - test/unit/models/journal_line_test.rb
523
525
  - test/unit/models/line_item_sum_test.rb
524
526
  - test/unit/models/line_item_test.rb
525
527
  - test/unit/oauth_config_test.rb