From 320f47f8c7dd5341d4c6169134f053af2e0baab7 Mon Sep 17 00:00:00 2001 From: Amanda Date: Fri, 31 May 2024 11:09:39 -0700 Subject: [PATCH] add taxable address sources to business entity and adjustment --- recurly/__init__.py | 4 ++ .../charged-with-taxable-address-sources.xml | 54 +++++++++++++++++++ tests/fixtures/adjustment/lookup.xml | 2 + tests/fixtures/business_entity/get.xml | 2 + tests/fixtures/business_entity/list.xml | 4 ++ tests/test_resources.py | 14 +++++ 6 files changed, 80 insertions(+) create mode 100644 tests/fixtures/adjustment/charged-with-taxable-address-sources.xml diff --git a/recurly/__init__.py b/recurly/__init__.py index b0cc37e8..d74be6b1 100644 --- a/recurly/__init__.py +++ b/recurly/__init__.py @@ -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', @@ -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', diff --git a/tests/fixtures/adjustment/charged-with-taxable-address-sources.xml b/tests/fixtures/adjustment/charged-with-taxable-address-sources.xml new file mode 100644 index 00000000..754b8649 --- /dev/null +++ b/tests/fixtures/adjustment/charged-with-taxable-address-sources.xml @@ -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 + + + + USD + test charge + destination + origin + 1000 + + +HTTP/1.1 201 Created +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/adjustments/6f56942e01241200964cb6425c85b9d4 + + + + + + + + + 0 + 6f56942e01241200964cb6425c85b9d4 + pending + test charge + + + debit + 1000 + 1 + 0 + 0 + 1000 + false + USD + + false + + 2024-02-26T23:38:41Z + + 2024-02-26T23:38:42Z + 2024-02-26T23:38:42Z + + + + origin + destination + \ No newline at end of file diff --git a/tests/fixtures/adjustment/lookup.xml b/tests/fixtures/adjustment/lookup.xml index a5cc237d..5a622976 100644 --- a/tests/fixtures/adjustment/lookup.xml +++ b/tests/fixtures/adjustment/lookup.xml @@ -16,6 +16,8 @@ Content-Type: application/xml; charset=utf-8 usst CA 0.0875 + origin + destination 1000 USD diff --git a/tests/fixtures/business_entity/get.xml b/tests/fixtures/business_entity/get.xml index e5946c23..2502cbc5 100644 --- a/tests/fixtures/business_entity/get.xml +++ b/tests/fixtures/business_entity/get.xml @@ -32,6 +32,8 @@ Content-Type: application/xml; charset=utf-8 US 4344444222 + origin + destination GB CA diff --git a/tests/fixtures/business_entity/list.xml b/tests/fixtures/business_entity/list.xml index ab4f8008..e524864e 100644 --- a/tests/fixtures/business_entity/list.xml +++ b/tests/fixtures/business_entity/list.xml @@ -33,6 +33,8 @@ Content-Type: application/xml; charset=utf-8 US + origin + destination @@ -65,6 +67,8 @@ Content-Type: application/xml; charset=utf-8 US 3442565432 + origin + destination diff --git a/tests/test_resources.py b/tests/test_resources.py index a437374c..cc33cb02 100644 --- a/tests/test_resources.py +++ b/tests/test_resources.py @@ -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() @@ -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))