Skip to content

Commit

Permalink
Merge pull request #906 from recurly/add-taxable-address-sources
Browse files Browse the repository at this point in the history
add taxable address sources to business entity and adjustment
  • Loading branch information
ELepolt authored Jul 3, 2024
2 parents c873318 + 8e90c4c commit 8846aa6
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/recurly/adjustment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Adjustment < Resource
tax_type
tax_region
tax_rate
origin_tax_address_source
destination_tax_address_source
tax_exempt
tax_inclusive
tax_code
Expand Down
2 changes: 2 additions & 0 deletions lib/recurly/business_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class BusinessEntity < Resource
name
invoice_display_address
tax_address
origin_tax_address_source
destination_tax_address_source
subscriber_location_countries
default_vat_number
default_registration_number
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
HTTP/1.1 201 Created
Content-Type: application/xml; charset=utf-8
Location: https://api.recurly.com/v2/adjustments/67360781108ceacd23dee747b7b1f5af

<adjustment href="https://api.recurly.com/v2/adjustments/67360781108ceacd23dee747b7b1f5af">
<account href="https://api.recurly.com/v2/accounts/7747ed3b-1771-4a03-b32a-503e9d65d3ad"/>
<bill_for_account href="https://api.recurly.com/v2/accounts/account1"/>
<item_code nil="nil"/>
<external_sku nil="nil"/>
<credit_adjustments href="https://api.recurly.com/v2/adjustments/67360781108ceacd23dee747b7b1f5af/credit_adjustments"/>
<refundable_total_in_cents type="integer">0</refundable_total_in_cents>
<uuid>67360781108ceacd23dee747b7b1f5af</uuid>
<state>pending</state>
<description nil="nil"/>
<accounting_code nil="nil"/>
<product_code nil="nil"/>
<origin>debit</origin>
<unit_amount_in_cents type="integer">5000</unit_amount_in_cents>
<quantity type="integer">1</quantity>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">5000</total_in_cents>
<currency>USD</currency>
<proration_rate nil="nil"/>
<start_date type="datetime">2023-01-18T23:34:52Z</start_date>
<end_date nil="nil"/>
<created_at type="datetime">2023-01-18T23:34:52Z</created_at>
<updated_at type="datetime">2023-01-18T23:34:52Z</updated_at>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
</adjustment>
2 changes: 2 additions & 0 deletions spec/fixtures/adjustments/show-200-taxed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Content-Type: application/xml; charset=utf-8
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">1200</total_in_cents>
<currency>USD</currency>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
<tax_exempt type="boolean">false</tax_exempt>
<product_code>basic</product_code>
<!-- Vertex -->
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/business_entities/index-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Link: <https://api.recurly.com/v2/business_entities?cursor=1234567890&per_page=2
<country>US</country>
<phone nil="nil"></phone>
</tax_address>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
<default_vat_number nil="nil"></default_vat_number>
<default_registration_number nil="nil"></default_registration_number>
<default_liability_gl_account_id>12345</default_liability_gl_account_id>
Expand Down Expand Up @@ -56,6 +58,8 @@ Link: <https://api.recurly.com/v2/business_entities?cursor=1234567890&per_page=2
<country>US</country>
<phone nil="nil"></phone>
</tax_address>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
<default_vat_number nil="nil"></default_vat_number>
<default_liability_gl_account_id>abc123</default_liability_gl_account_id>
<default_revenue_gl_account_id>xyz789</default_revenue_gl_account_id>
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/business_entities/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Content-Type: application/xml; charset=utf-8
<country>US</country>
<phone nil="nil"></phone>
</tax_address>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
<default_vat_number nil="nil"></default_vat_number>
<default_registration_number nil="nil"></default_registration_number>
<default_liability_gl_account_id>12345</default_liability_gl_account_id>
Expand Down
42 changes: 42 additions & 0 deletions spec/recurly/adjustment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@

adjustment = Adjustment.find 'abcdef1234567890'
adjustment.tax_exempt?.must_equal false
adjustment.origin_tax_address_source.must_equal('origin')
adjustment.destination_tax_address_source.must_equal('destination')
end

it 'must parse the vertex details if available' do
Expand Down Expand Up @@ -254,4 +256,44 @@
charge.performance_obligation_id.must_equal '5'
end
end

describe 'with taxable address sources #POST /accounts/{account_code}/adjustments' do
let(:adjustment_body) do
{
unit_amount_in_cents: 5000,
currency: 'USD',
quantity: 1,
accounting_code: 'bandwidth',
tax_exempt: false,
origin_tax_address_source: 'origin',
destination_tax_address_source: 'destination'
}
end
let(:adjustment) { Adjustment.new(adjustment_body) }

it 'must serialize' do
adjustment.to_xml.must_equal <<XML.chomp
<adjustment>\
<accounting_code>bandwidth</accounting_code>\
<currency>USD</currency>\
<destination_tax_address_source>destination</destination_tax_address_source>\
<origin_tax_address_source>origin</origin_tax_address_source>\
<quantity>1</quantity>\
<tax_exempt>false</tax_exempt>\
<unit_amount_in_cents>5000</unit_amount_in_cents>\
</adjustment>
XML
end

it 'it creates an adjustment with taxable address details on the account specified' do
stub_api_request :get, 'accounts/abcdef1234567890', 'accounts/show-200'
stub_api_request :post, 'accounts/abcdef1234567890/adjustments', 'adjustments/create-201-with-taxable-address-sources'

account = Account.find('abcdef1234567890')

charge = account.adjustments.create(adjustment_body)
charge.origin_tax_address_source.must_equal 'origin'
charge.destination_tax_address_source.must_equal 'destination'
end
end
end
4 changes: 4 additions & 0 deletions spec/recurly/business_entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
country: "Australia",
zip: "2060"
}),
origin_tax_address_source: 'origin',
destination_tax_address_source: 'desination',
subscriber_location_countries: ['US', 'AU'],
default_vat_number: '12345',
default_registration_number: '12345',
Expand Down Expand Up @@ -74,6 +76,8 @@
business_entity.code.must_equal('default')
business_entity.default_liability_gl_account_id.must_equal('12345')
business_entity.default_revenue_gl_account_id.must_equal('56789')
business_entity.origin_tax_address_source.must_equal('origin')
business_entity.destination_tax_address_source.must_equal('destination')
end
end

Expand Down

0 comments on commit 8846aa6

Please sign in to comment.