Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add taxable address sources to business entity and adjustment #815

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Tests/Recurly/Adjustment_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adjustment><currency>USD</currency><unit_amount_in_cents>5000</unit_amount_in_cents><quantity>1</quantity><quantity_decimal>1.2</quantity_decimal><description>Charge for extra bandwidth</description><accounting_code>bandwidth</accounting_code><tax_exempt>false</tax_exempt><tax_code>fake-tax-code</tax_code><origin>external_gift_card</origin><product_code>abc123</product_code><shipping_address><address1>123 Main St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone><email>verena@example.com</email><nickname>Work</nickname><first_name>Verena</first_name><last_name>Example</last_name><company>Recurly Inc.</company></shipping_address><shipping_address_id>123456789</shipping_address_id><revenue_gl_account_id>revenue-gl-account-id</revenue_gl_account_id><liability_gl_account_id>liability_gl_account_id</liability_gl_account_id><performance_obligation_id>6</performance_obligation_id></adjustment>\n";
$expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adjustment><currency>USD</currency><unit_amount_in_cents>5000</unit_amount_in_cents><quantity>1</quantity><quantity_decimal>1.2</quantity_decimal><description>Charge for extra bandwidth</description><accounting_code>bandwidth</accounting_code><tax_exempt>false</tax_exempt><tax_code>fake-tax-code</tax_code><origin>external_gift_card</origin><product_code>abc123</product_code><shipping_address><address1>123 Main St.</address1><city>San Francisco</city><state>CA</state><zip>94110</zip><country>US</country><phone>555-555-5555</phone><email>verena@example.com</email><nickname>Work</nickname><first_name>Verena</first_name><last_name>Example</last_name><company>Recurly Inc.</company></shipping_address><shipping_address_id>123456789</shipping_address_id><revenue_gl_account_id>revenue-gl-account-id</revenue_gl_account_id><liability_gl_account_id>liability_gl_account_id</liability_gl_account_id><performance_obligation_id>6</performance_obligation_id><origin_tax_address_source>origin</origin_tax_address_source><destination_tax_address_source>destination</destination_tax_address_source></adjustment>\n";
$this->assertEquals($expected, $charge->xml());
}
}
2 changes: 2 additions & 0 deletions Tests/Recurly/BusinessEntity_List_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Tests/Recurly/BusinessEntity_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Tests/fixtures/adjustments/show-200-revrec.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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>Business entity tax address</origin_tax_address_source>
<destination_tax_address_source>Customer tax address</destination_tax_address_source>
<taxable type="boolean">false</taxable>
<start_date type="datetime">2011-04-30T07:00:00Z</start_date>
<end_date type="datetime">2011-04-30T07:00:00Z</end_date>
Expand Down
2 changes: 2 additions & 0 deletions Tests/fixtures/adjustments/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Content-Type: application/xml; charset=utf-8
<tax_in_cents type="integer">5000</tax_in_cents>
<total_in_cents type="integer">1200</total_in_cents>
<currency>USD</currency>
<origin_tax_address_source>Business entity tax address</origin_tax_address_source>
<destination_tax_address_source>Customer tax address</destination_tax_address_source>
<tax_exempt type="boolean">false</tax_exempt>
<tax_details type="array">
<tax_detail>
Expand Down
2 changes: 2 additions & 0 deletions Tests/fixtures/business_entities/index-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Content-Type: application/xml; charset=utf-8
<country>US</country>
<phone>718-555-1234</phone>
</tax_address>
<origin_tax_address_source>Business entity tax address</origin_tax_address_source>
<destination_tax_address_source>Customer tax address</destination_tax_address_source>
<subscriber_location_countries type="array">
<subscriber_location_country>GB</subscriber_location_country>
<subscriber_location_country>CO</subscriber_location_country>
Expand Down
2 changes: 2 additions & 0 deletions Tests/fixtures/business_entities/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Content-Type: application/xml; charset=utf-8
<country>US</country>
<phone>718-555-1234</phone>
</tax_address>
<origin_tax_address_source>Business entity tax address</origin_tax_address_source>
<destination_tax_address_source>Customer tax address</destination_tax_address_source>
<subscriber_location_countries type="array">
<subscriber_location_country>GB</subscriber_location_country>
<subscriber_location_country>CO</subscriber_location_country>
Expand Down
5 changes: 4 additions & 1 deletion lib/recurly/adjustment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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'
);
}
}
2 changes: 2 additions & 0 deletions lib/recurly/business_entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading