xeroizer 2.15.9 → 2.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +59 -1
- data/lib/xeroizer/exceptions.rb +14 -11
- data/lib/xeroizer/generic_application.rb +8 -1
- data/lib/xeroizer/http.rb +19 -10
- data/lib/xeroizer/models/attachment.rb +15 -13
- data/lib/xeroizer/models/bank_transaction.rb +3 -1
- data/lib/xeroizer/models/branding_theme.rb +1 -1
- data/lib/xeroizer/models/contact.rb +3 -1
- data/lib/xeroizer/models/credit_note.rb +26 -2
- data/lib/xeroizer/models/employee.rb +49 -4
- data/lib/xeroizer/models/invoice.rb +1 -1
- data/lib/xeroizer/models/journal.rb +3 -1
- data/lib/xeroizer/models/journal_line.rb +1 -0
- data/lib/xeroizer/models/journal_line_tracking_category.rb +2 -1
- data/lib/xeroizer/models/line_item.rb +1 -0
- data/lib/xeroizer/models/manual_journal.rb +1 -1
- data/lib/xeroizer/models/organisation.rb +41 -1
- data/lib/xeroizer/models/phone.rb +2 -1
- data/lib/xeroizer/models/prepayment.rb +39 -0
- data/lib/xeroizer/models/repeating_invoice.rb +80 -0
- data/lib/xeroizer/models/schedule.rb +33 -0
- data/lib/xeroizer/record/base.rb +6 -0
- data/lib/xeroizer/record/base_model.rb +41 -26
- data/lib/xeroizer/record/record_association_helper.rb +1 -1
- data/lib/xeroizer/record/validation_helper.rb +6 -2
- data/lib/xeroizer/record/validators/length_of_validator.rb +23 -0
- data/lib/xeroizer/record/xml_helper.rb +10 -2
- data/lib/xeroizer/version.rb +1 -1
- data/lib/xeroizer.rb +3 -0
- data/test/stub_responses/prepayments.xml +27 -0
- data/test/stub_responses/records/prepayment-7d3619b1-82cc-405b-8f44-9d4f9a787a8a.xml +92 -0
- data/test/stub_responses/records/repeating_invoice-ad3550bc-1ae0-45c0-a782-48c6d2061127.xml +43 -0
- data/test/stub_responses/repeating_invoices.xml +43 -0
- data/test/unit/models/contact_test.rb +1 -1
- data/test/unit/models/employee_test.rb +43 -0
- data/test/unit/models/invoice_test.rb +21 -1
- data/test/unit/models/journal_test.rb +44 -0
- data/test/unit/models/manual_journal_test.rb +25 -0
- data/test/unit/models/organisation_test.rb +38 -0
- data/test/unit/models/phone_test.rb +31 -0
- data/test/unit/models/prepayment_test.rb +21 -0
- data/test/unit/models/repeating_invoice_test.rb +36 -0
- data/test/unit/record/base_test.rb +4 -2
- metadata +27 -1
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ManualJournalTest < Test::Unit::TestCase
|
4
|
+
include TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
|
8
|
+
mock_api('ManualJournals')
|
9
|
+
end
|
10
|
+
|
11
|
+
context "paging" do
|
12
|
+
should "have journal lines without downloading full manual journal when paging" do
|
13
|
+
manual_journals = @client.ManualJournal.all(page: 1)
|
14
|
+
|
15
|
+
manual_journals.each do |manual_journal|
|
16
|
+
# This would kick off a full download without page param.
|
17
|
+
manual_journal.journal_lines.size
|
18
|
+
assert_equal(true, manual_journal.paged_record_downloaded?)
|
19
|
+
|
20
|
+
# This indicates that there wasn't a separate download of the individual manual journal.
|
21
|
+
assert_equal(false, manual_journal.complete_record_downloaded?)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class OrganisationTest < Test::Unit::TestCase
|
4
|
+
include TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "sales_tax_basis_validations" do
|
11
|
+
should "allow nil sales tax bases and countries" do
|
12
|
+
organisation = @client.Organisation.build
|
13
|
+
|
14
|
+
assert(organisation.valid?)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should validate sales_tax_basis' do
|
18
|
+
organisation = @client.Organisation.build(:sales_tax_basis => "Cat")
|
19
|
+
|
20
|
+
assert(!organisation.valid?)
|
21
|
+
|
22
|
+
organisation.sales_tax_basis = "ACCRUALS"
|
23
|
+
|
24
|
+
assert(organisation.valid?)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should validate sales_tax_basis for a specific country like NZ' do
|
28
|
+
organisation = @client.Organisation.build(:sales_tax_basis => "FLATRATECASH", :country_code => "NZ")
|
29
|
+
|
30
|
+
assert(!organisation.valid?)
|
31
|
+
|
32
|
+
organisation.sales_tax_basis = "NONE"
|
33
|
+
|
34
|
+
assert(organisation.valid?)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PhoneTest < Test::Unit::TestCase
|
4
|
+
include TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
|
8
|
+
@contact = @client.Contact.build
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
context "validators" do
|
13
|
+
|
14
|
+
should "not allow long phone numbers" do
|
15
|
+
@phone = @contact.add_phone(phone_number: "1234567890123456789012345678901234567890123456789012345678901234567890")
|
16
|
+
assert_equal(false, @phone.valid?)
|
17
|
+
blank_error = @phone.errors_for(:phone_number).first
|
18
|
+
assert_not_nil(blank_error)
|
19
|
+
assert_equal("must be shorter than 50 characters", blank_error)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
should "allow phone numbers" do
|
24
|
+
@phone = @contact.add_phone(phone_number: "12345690")
|
25
|
+
|
26
|
+
assert_equal(true, @phone.valid?)
|
27
|
+
assert_equal(0, @phone.errors.size)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PrepaymentTest < Test::Unit::TestCase
|
4
|
+
include TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
|
8
|
+
mock_api("Prepayments")
|
9
|
+
@prepayment = @client.Prepayment.first
|
10
|
+
end
|
11
|
+
|
12
|
+
context "prepayment attributes" do
|
13
|
+
should "large-scale testing from API XML" do
|
14
|
+
prepayments = @client.Prepayment.all
|
15
|
+
prepayments.each do | prepayment |
|
16
|
+
assert_equal(prepayment.attributes[:prepayment_id], prepayment.prepayment_id)
|
17
|
+
assert_equal(prepayment.attributes[:contact][:contact_id], prepayment.contact_id)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RepeatingInvoiceTest < Test::Unit::TestCase
|
4
|
+
include TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
|
8
|
+
mock_api('RepeatingInvoices')
|
9
|
+
end
|
10
|
+
|
11
|
+
context "GET" do
|
12
|
+
|
13
|
+
should "have return repeating invoices" do
|
14
|
+
repeating_invoices = @client.RepeatingInvoice.all(page: 1)
|
15
|
+
|
16
|
+
assert_equal 1, repeating_invoices.size
|
17
|
+
|
18
|
+
repeating_invoice = repeating_invoices.first
|
19
|
+
|
20
|
+
assert_equal "PowerDirect", repeating_invoice.contact_name
|
21
|
+
assert_equal BigDecimal.new(90), repeating_invoice.total
|
22
|
+
assert_equal true, repeating_invoice.accounts_payable?
|
23
|
+
|
24
|
+
schedule = repeating_invoice.schedule
|
25
|
+
|
26
|
+
assert_equal 1, schedule.period
|
27
|
+
assert_equal 'MONTHLY', schedule.unit
|
28
|
+
assert_equal 10, schedule.due_date
|
29
|
+
assert_equal 'OFFOLLOWINGMONTH', schedule.due_date_type
|
30
|
+
assert_equal Date.new(2013,1,21), schedule.start_date
|
31
|
+
assert_equal Date.new(2014,3,23), schedule.next_scheduled_date
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -74,7 +74,8 @@ class RecordBaseTest < Test::Unit::TestCase
|
|
74
74
|
:parse_response => stub("Stub response", :response_items => []),
|
75
75
|
:mark_dirty => nil,
|
76
76
|
:create_method => :http_put,
|
77
|
-
:mark_clean => nil
|
77
|
+
:mark_clean => nil,
|
78
|
+
:application => nil
|
78
79
|
|
79
80
|
an_example_instance = @example_class.new(a_fake_parent)
|
80
81
|
|
@@ -90,7 +91,8 @@ class RecordBaseTest < Test::Unit::TestCase
|
|
90
91
|
:http_post => "<FakeResponse />",
|
91
92
|
:parse_response => stub("Stub response", :response_items => []),
|
92
93
|
:mark_dirty => nil,
|
93
|
-
:mark_clean => nil
|
94
|
+
:mark_clean => nil,
|
95
|
+
:application => nil
|
94
96
|
|
95
97
|
an_example_instance = @example_class.new(a_fake_parent)
|
96
98
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xeroizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.16.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -318,7 +318,10 @@ files:
|
|
318
318
|
- lib/xeroizer/models/organisation.rb
|
319
319
|
- lib/xeroizer/models/payment.rb
|
320
320
|
- lib/xeroizer/models/phone.rb
|
321
|
+
- lib/xeroizer/models/prepayment.rb
|
321
322
|
- lib/xeroizer/models/receipt.rb
|
323
|
+
- lib/xeroizer/models/repeating_invoice.rb
|
324
|
+
- lib/xeroizer/models/schedule.rb
|
322
325
|
- lib/xeroizer/models/tax_component.rb
|
323
326
|
- lib/xeroizer/models/tax_rate.rb
|
324
327
|
- lib/xeroizer/models/tracking_category.rb
|
@@ -338,6 +341,7 @@ files:
|
|
338
341
|
- lib/xeroizer/record/validators/associated_validator.rb
|
339
342
|
- lib/xeroizer/record/validators/block_validator.rb
|
340
343
|
- lib/xeroizer/record/validators/inclusion_of_validator.rb
|
344
|
+
- lib/xeroizer/record/validators/length_of_validator.rb
|
341
345
|
- lib/xeroizer/record/validators/presence_of_validator.rb
|
342
346
|
- lib/xeroizer/record/validators/validator.rb
|
343
347
|
- lib/xeroizer/record/xml_helper.rb
|
@@ -385,6 +389,7 @@ files:
|
|
385
389
|
- test/stub_responses/organisation.xml
|
386
390
|
- test/stub_responses/organisations.xml
|
387
391
|
- test/stub_responses/payments.xml
|
392
|
+
- test/stub_responses/prepayments.xml
|
388
393
|
- test/stub_responses/rate_limit_exceeded
|
389
394
|
- test/stub_responses/records/contact-043892a1-aef1-4c18-88d8-b8ccb6d31466.xml
|
390
395
|
- test/stub_responses/records/contact-09664078-efe2-4a88-89a5-67eac9b0047b.xml
|
@@ -584,7 +589,10 @@ files:
|
|
584
589
|
- test/stub_responses/records/manual_journal-53fc5558-5b76-4ecd-ae5c-c4af3ccde87c.xml
|
585
590
|
- test/stub_responses/records/manual_journal-bb6cfcfc-4500-4475-bd3a-93ee512428e0.xml
|
586
591
|
- test/stub_responses/records/manual_journal-f00a355b-7374-445c-886b-0437bea4095c.xml
|
592
|
+
- test/stub_responses/records/prepayment-7d3619b1-82cc-405b-8f44-9d4f9a787a8a.xml
|
593
|
+
- test/stub_responses/records/repeating_invoice-ad3550bc-1ae0-45c0-a782-48c6d2061127.xml
|
587
594
|
- test/stub_responses/refresh_responses.rb
|
595
|
+
- test/stub_responses/repeating_invoices.xml
|
588
596
|
- test/stub_responses/reports/trial_balance.xml
|
589
597
|
- test/stub_responses/tax_rates.xml
|
590
598
|
- test/stub_responses/token_expired
|
@@ -599,10 +607,17 @@ files:
|
|
599
607
|
- test/unit/models/bank_transaction_validation_test.rb
|
600
608
|
- test/unit/models/contact_test.rb
|
601
609
|
- test/unit/models/credit_note_test.rb
|
610
|
+
- test/unit/models/employee_test.rb
|
602
611
|
- test/unit/models/invoice_test.rb
|
603
612
|
- test/unit/models/journal_line_test.rb
|
613
|
+
- test/unit/models/journal_test.rb
|
604
614
|
- test/unit/models/line_item_sum_test.rb
|
605
615
|
- test/unit/models/line_item_test.rb
|
616
|
+
- test/unit/models/manual_journal_test.rb
|
617
|
+
- test/unit/models/organisation_test.rb
|
618
|
+
- test/unit/models/phone_test.rb
|
619
|
+
- test/unit/models/prepayment_test.rb
|
620
|
+
- test/unit/models/repeating_invoice_test.rb
|
606
621
|
- test/unit/models/tax_rate_test.rb
|
607
622
|
- test/unit/oauth_config_test.rb
|
608
623
|
- test/unit/oauth_test.rb
|
@@ -673,6 +688,7 @@ test_files:
|
|
673
688
|
- test/stub_responses/organisation.xml
|
674
689
|
- test/stub_responses/organisations.xml
|
675
690
|
- test/stub_responses/payments.xml
|
691
|
+
- test/stub_responses/prepayments.xml
|
676
692
|
- test/stub_responses/rate_limit_exceeded
|
677
693
|
- test/stub_responses/records/contact-043892a1-aef1-4c18-88d8-b8ccb6d31466.xml
|
678
694
|
- test/stub_responses/records/contact-09664078-efe2-4a88-89a5-67eac9b0047b.xml
|
@@ -872,7 +888,10 @@ test_files:
|
|
872
888
|
- test/stub_responses/records/manual_journal-53fc5558-5b76-4ecd-ae5c-c4af3ccde87c.xml
|
873
889
|
- test/stub_responses/records/manual_journal-bb6cfcfc-4500-4475-bd3a-93ee512428e0.xml
|
874
890
|
- test/stub_responses/records/manual_journal-f00a355b-7374-445c-886b-0437bea4095c.xml
|
891
|
+
- test/stub_responses/records/prepayment-7d3619b1-82cc-405b-8f44-9d4f9a787a8a.xml
|
892
|
+
- test/stub_responses/records/repeating_invoice-ad3550bc-1ae0-45c0-a782-48c6d2061127.xml
|
875
893
|
- test/stub_responses/refresh_responses.rb
|
894
|
+
- test/stub_responses/repeating_invoices.xml
|
876
895
|
- test/stub_responses/reports/trial_balance.xml
|
877
896
|
- test/stub_responses/tax_rates.xml
|
878
897
|
- test/stub_responses/token_expired
|
@@ -887,10 +906,17 @@ test_files:
|
|
887
906
|
- test/unit/models/bank_transaction_validation_test.rb
|
888
907
|
- test/unit/models/contact_test.rb
|
889
908
|
- test/unit/models/credit_note_test.rb
|
909
|
+
- test/unit/models/employee_test.rb
|
890
910
|
- test/unit/models/invoice_test.rb
|
891
911
|
- test/unit/models/journal_line_test.rb
|
912
|
+
- test/unit/models/journal_test.rb
|
892
913
|
- test/unit/models/line_item_sum_test.rb
|
893
914
|
- test/unit/models/line_item_test.rb
|
915
|
+
- test/unit/models/manual_journal_test.rb
|
916
|
+
- test/unit/models/organisation_test.rb
|
917
|
+
- test/unit/models/phone_test.rb
|
918
|
+
- test/unit/models/prepayment_test.rb
|
919
|
+
- test/unit/models/repeating_invoice_test.rb
|
894
920
|
- test/unit/models/tax_rate_test.rb
|
895
921
|
- test/unit/oauth_config_test.rb
|
896
922
|
- test/unit/oauth_test.rb
|