From d49b5d16e133a8a5cb67292354a356c7ec88e969 Mon Sep 17 00:00:00 2001 From: Evan Lepolt Date: Fri, 31 May 2024 11:58:54 -0600 Subject: [PATCH] Add taxable address sources to business entity and adjustment --- Tests/Recurly/Adjustment_Test.php | 6 +++++- Tests/Recurly/BusinessEntity_List_Test.php | 2 ++ Tests/Recurly/BusinessEntity_Test.php | 2 ++ Tests/fixtures/adjustments/show-200-revrec.xml | 2 ++ Tests/fixtures/adjustments/show-200.xml | 2 ++ Tests/fixtures/business_entities/index-200.xml | 2 ++ Tests/fixtures/business_entities/show-200.xml | 2 ++ lib/recurly/adjustment.php | 5 ++++- lib/recurly/business_entity.php | 2 ++ 9 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Tests/Recurly/Adjustment_Test.php b/Tests/Recurly/Adjustment_Test.php index 5e7c64d1..ac3d07e3 100644 --- a/Tests/Recurly/Adjustment_Test.php +++ b/Tests/Recurly/Adjustment_Test.php @@ -32,6 +32,8 @@ public function testGetAdjustment() { $this->assertEquals(5000, $adjustment->tax_in_cents); $this->assertEquals(1200, $adjustment->total_in_cents); $this->assertEquals('USD', $adjustment->currency); + $this->assertEquals('Business entity tax address', $adjustment->origin_tax_address_source); + $this->assertEquals('Customer tax address', $adjustment->destination_tax_address_source); $this->assertEquals(false, $adjustment->taxable); $this->assertEquals('2011-04-30T07:00:00+00:00', $adjustment->start_date->format('c')); $this->assertEquals('2011-04-30T07:00:00+00:00', $adjustment->end_date->format('c')); @@ -134,11 +136,13 @@ public function testXml() { $charge->revenue_gl_account_id = 'revenue-gl-account-id'; $charge->liability_gl_account_id = 'liability_gl_account_id'; $charge->performance_obligation_id = '6'; + $charge->origin_tax_address_source = 'origin'; + $charge->destination_tax_address_source = 'destination'; // This deprecated parameter should be ignored: $charge->taxable = 0; - $expected = "\nUSD500011.2Charge for extra bandwidthbandwidthfalsefake-tax-codeexternal_gift_cardabc123123 Main St.San FranciscoCA94110US555-555-5555verena@example.comWorkVerenaExampleRecurly Inc.123456789revenue-gl-account-idliability_gl_account_id6\n"; + $expected = "\nUSD500011.2Charge for extra bandwidthbandwidthfalsefake-tax-codeexternal_gift_cardabc123123 Main St.San FranciscoCA94110US555-555-5555verena@example.comWorkVerenaExampleRecurly Inc.123456789revenue-gl-account-idliability_gl_account_id6origindestination\n"; $this->assertEquals($expected, $charge->xml()); } } diff --git a/Tests/Recurly/BusinessEntity_List_Test.php b/Tests/Recurly/BusinessEntity_List_Test.php index b287f2e1..6a783eeb 100644 --- a/Tests/Recurly/BusinessEntity_List_Test.php +++ b/Tests/Recurly/BusinessEntity_List_Test.php @@ -32,6 +32,8 @@ public function testGetAll() { $this->assertEquals($business_entity->tax_address->city, 'Oakland'); $this->assertEquals($business_entity->tax_address->country, 'US'); $this->assertEquals($business_entity->tax_address->phone, '718-555-1234'); + $this->assertEquals($business_entity->origin_tax_address_source, 'Business entity tax address'); + $this->assertEquals($business_entity->destination_tax_address_source, 'Customer tax address'); $this->assertEquals($business_entity->default_vat_number, '1234'); $this->assertEquals($business_entity->default_registration_number, '5678'); $this->assertInstanceOf('DateTime', $business_entity->created_at); diff --git a/Tests/Recurly/BusinessEntity_Test.php b/Tests/Recurly/BusinessEntity_Test.php index dc93f27e..c94d4839 100644 --- a/Tests/Recurly/BusinessEntity_Test.php +++ b/Tests/Recurly/BusinessEntity_Test.php @@ -30,6 +30,8 @@ public function testGetBusinessEntity() { $this->assertEquals($business_entity->tax_address->city, 'Oakland'); $this->assertEquals($business_entity->tax_address->country, 'US'); $this->assertEquals($business_entity->tax_address->phone, '718-555-1234'); + $this->assertEquals($business_entity->origin_tax_address_source, 'Business entity tax address'); + $this->assertEquals($business_entity->destination_tax_address_source, 'Customer tax address'); $this->assertEquals($business_entity->default_vat_number, '1234'); $this->assertEquals($business_entity->default_registration_number, '5678'); $this->assertInstanceOf('DateTime', $business_entity->created_at); diff --git a/Tests/fixtures/adjustments/show-200-revrec.xml b/Tests/fixtures/adjustments/show-200-revrec.xml index 47650f5a..f93e77f9 100644 --- a/Tests/fixtures/adjustments/show-200-revrec.xml +++ b/Tests/fixtures/adjustments/show-200-revrec.xml @@ -22,6 +22,8 @@ Content-Type: application/xml; charset=utf-8 0 1200 USD + Business entity tax address + Customer tax address false 2011-04-30T07:00:00Z 2011-04-30T07:00:00Z diff --git a/Tests/fixtures/adjustments/show-200.xml b/Tests/fixtures/adjustments/show-200.xml index b509ac53..f2a83d15 100644 --- a/Tests/fixtures/adjustments/show-200.xml +++ b/Tests/fixtures/adjustments/show-200.xml @@ -26,6 +26,8 @@ Content-Type: application/xml; charset=utf-8 5000 1200 USD + Business entity tax address + Customer tax address false diff --git a/Tests/fixtures/business_entities/index-200.xml b/Tests/fixtures/business_entities/index-200.xml index 4d65148d..e3a5de12 100644 --- a/Tests/fixtures/business_entities/index-200.xml +++ b/Tests/fixtures/business_entities/index-200.xml @@ -26,6 +26,8 @@ Content-Type: application/xml; charset=utf-8 US 718-555-1234 + Business entity tax address + Customer tax address GB CO diff --git a/Tests/fixtures/business_entities/show-200.xml b/Tests/fixtures/business_entities/show-200.xml index e6d37e43..a0783244 100644 --- a/Tests/fixtures/business_entities/show-200.xml +++ b/Tests/fixtures/business_entities/show-200.xml @@ -25,6 +25,8 @@ Content-Type: application/xml; charset=utf-8 US 718-555-1234 + Business entity tax address + Customer tax address GB CO diff --git a/lib/recurly/adjustment.php b/lib/recurly/adjustment.php index f0f71098..f2686882 100644 --- a/lib/recurly/adjustment.php +++ b/lib/recurly/adjustment.php @@ -28,6 +28,8 @@ * @property string $tax_type The tax type of the adjustment. * @property string $tax_region The tax region of the adjustment. * @property float $tax_rate The tax rate of the adjustment. + * @property string $origin_tax_address_source The source of the address that will be used as the "origin" in determining taxes. + * @property string $destination_tax_address_source The source of the address that will be used as the "destination" in determining taxes. * @property boolean $tax_exempt true exempts tax on the charge, false applies tax on the charge. If not defined, then defaults to the Plan and Site settings. This attribute does not work for credits (negative adjustments). Credits are always post-tax. Pre-tax discounts should use the Coupons feature. * @property mixed[] $tax_details The nested address information of the adjustment: name, type, tax_rate, tax_in_cents. * @property string $tax_code Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of unknown, physical, or digital. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules. @@ -134,7 +136,8 @@ protected function getWriteableAttributes() { 'accounting_code', 'tax_exempt', 'tax_inclusive', 'tax_code', 'start_date', 'end_date', 'revenue_schedule_type', 'origin', 'product_code', 'credit_reason_code', 'shipping_address', 'shipping_address_id', 'item_code', 'external_sku', 'custom_fields', - 'revenue_gl_account_id', 'liability_gl_account_id', 'performance_obligation_id' + 'revenue_gl_account_id', 'liability_gl_account_id', 'performance_obligation_id', + 'origin_tax_address_source', 'destination_tax_address_source' ); } } diff --git a/lib/recurly/business_entity.php b/lib/recurly/business_entity.php index cd222bad..4f42c743 100644 --- a/lib/recurly/business_entity.php +++ b/lib/recurly/business_entity.php @@ -10,6 +10,8 @@ * @property string $default_liability_gl_account_id * @property Recurly_Address $invoice_display_address The nested invoice address information of the business entity: address1, address2, city, state, zip, country, phone. * @property Recurly_Address $tax_address The nested tax address information of the business entity: address1, address2, city, state, zip, country, phone. + * @property string $origin_tax_address_source The source of the address that will be used as the "origin" in determining taxes. + * @property string $destination_tax_address_source The source of the address that will be used as the "destination" in determining taxes. * @property Recurly_SubscriberLocationCountry[] $subscriber_location_countries * @property string $default_vat_number * @property string $default_registration_number