Skip to content

Commit

Permalink
add taxable address sources to business entity and adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
amandamfielding committed Jul 3, 2024
1 parent 470ae5f commit 320f47f
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recurly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,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 Expand Up @@ -1030,6 +1032,8 @@ class Adjustment(Resource):
'tax_type',
'tax_region',
'tax_rate',
'origin_tax_address_source',
'destination_tax_address_source',
'total_in_cents',
'currency',
'tax_exempt',
Expand Down
54 changes: 54 additions & 0 deletions tests/fixtures/adjustment/charged-with-taxable-address-sources.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
POST https://api.recurly.com/v2/accounts/chargemock/adjustments HTTP/1.1
X-Api-Version: {api-version}
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: {user-agent}
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<adjustment type="charge">
<currency>USD</currency>
<description>test charge</description>
<destination_tax_address_source>destination</destination_tax_address_source>
<origin_tax_address_source>origin</origin_tax_address_source>
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
</adjustment>

HTTP/1.1 201 Created
Content-Type: application/xml; charset=utf-8
Location: https://api.recurly.com/v2/adjustments/6f56942e01241200964cb6425c85b9d4

<?xml version="1.0" encoding="UTF-8"?>
<adjustment href="https://api.recurly.com/v2/adjustments/6f56942e01241200964cb6425c85b9d4" type="charge">
<account href="https://api.recurly.com/v2/accounts/chargemock"/>
<bill_for_account href="https://api.recurly.com/v2/accounts/chargemock"/>
<item_code nil="nil"></item_code>
<external_sku nil="nil"></external_sku>
<credit_adjustments href="https://api.recurly.com/v2/adjustments/6f56942e01241200964cb6425c85b9d4/credit_adjustments"/>
<refundable_total_in_cents type="integer">0</refundable_total_in_cents>
<uuid>6f56942e01241200964cb6425c85b9d4</uuid>
<state>pending</state>
<description>test charge</description>
<accounting_code nil="nil"></accounting_code>
<product_code nil="nil"></product_code>
<origin>debit</origin>
<unit_amount_in_cents type="integer">1000</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">1000</total_in_cents>
<tax_inclusive type="boolean">false</tax_inclusive>
<currency>USD</currency>
<proration_rate nil="nil"></proration_rate>
<tax_exempt type="boolean">false</tax_exempt>
<tax_code nil="nil"></tax_code>
<start_date type="datetime">2024-02-26T23:38:41Z</start_date>
<end_date nil="nil"></end_date>
<created_at type="datetime">2024-02-26T23:38:42Z</created_at>
<updated_at type="datetime">2024-02-26T23:38:42Z</updated_at>
<revenue_schedule_type></revenue_schedule_type>
<custom_fields type="array">
</custom_fields>
<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 tests/fixtures/adjustment/lookup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Content-Type: application/xml; charset=utf-8
<tax_type>usst</tax_type>
<tax_region>CA</tax_region>
<tax_rate type="float">0.0875</tax_rate>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
<currency>USD</currency>
<tax_details type="array">
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/business_entity/get.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Content-Type: application/xml; charset=utf-8
<country>US</country>
<phone>4344444222</phone>
</tax_address>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
<subscriber_location_countries type="array">
<subscriber_location_country>GB</subscriber_location_country>
<subscriber_location_country>CA</subscriber_location_country>
Expand Down
4 changes: 4 additions & 0 deletions tests/fixtures/business_entity/list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Content-Type: application/xml; charset=utf-8
<country>US</country>
<phone></phone>
</tax_address>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
<subscriber_location_countries type="array">
</subscriber_location_countries>
<default_vat_number></default_vat_number>
Expand Down Expand Up @@ -65,6 +67,8 @@ Content-Type: application/xml; charset=utf-8
<country>US</country>
<phone>3442565432</phone>
</tax_address>
<origin_tax_address_source>origin</origin_tax_address_source>
<destination_tax_address_source>destination</destination_tax_address_source>
<subscriber_location_countries type="array">
</subscriber_location_countries>
<default_vat_number></default_vat_number>
Expand Down
14 changes: 14 additions & 0 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,18 @@ def test_charge(self):
)
account.charge(charge)

"""Test adjustment with taxable addresses"""
with self.mock_request('adjustment/charged-with-taxable-address-sources.xml'):
charge = Adjustment(
unit_amount_in_cents=1000,
currency='USD',
description='test charge',
type='charge',
origin_tax_address_source='origin',
destination_tax_address_source='destination',
)
account.charge(charge)

with self.mock_request('adjustment/account-has-adjustments.xml'):
charges = account.adjustments()

Expand Down Expand Up @@ -3633,6 +3645,8 @@ def test_get_business_entity(self):
self.assertEqual(entity.default_registration_number, 'ab1')
self.assertEqual(entity.subscriber_location_countries, ['GB', 'CA'])
self.assertIsInstance(entity.tax_address, Address)
self.assertEqual(entity.origin_tax_address_source, 'origin')
self.assertEqual(entity.destination_tax_address_source, 'destination')
self.assertIsInstance(entity.invoice_display_address, Address)
self.assertEqual(entity.created_at, datetime(2023, 5, 13, 17, 28, 47, tzinfo=entity.created_at.tzinfo))
self.assertEqual(entity.updated_at, datetime(2023, 10, 13, 17, 28, 48, tzinfo=entity.updated_at.tzinfo))
Expand Down

0 comments on commit 320f47f

Please sign in to comment.