Skip to content

Commit

Permalink
Merge pull request #670 from recurly/add-revrec-features-to-python
Browse files Browse the repository at this point in the history
[DO NOT MERGE] Add RevRec Features to Python
  • Loading branch information
wsethbrown authored Mar 13, 2024
2 parents 91f3b25 + 1f408bb commit 699dab3
Show file tree
Hide file tree
Showing 30 changed files with 1,866 additions and 4 deletions.
63 changes: 61 additions & 2 deletions recurly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ class BusinessEntity(Resource):
'default_vat_number',
'default_registration_number',
'created_at',
'updated_at'
'updated_at',
'default_revenue_gl_account_id',
'default_liability_gl_account_id',
)

_classes_for_nodename = {
Expand All @@ -515,6 +517,40 @@ class GatewayAttributes(Resource):
'account_reference',
)

class GeneralLedgerAccount(Resource):

"""General Ledger Account for Revenue Recognition"""

member_path = 'general_ledger_accounts/%s'
collection_path = 'general_ledger_accounts'

nodename = 'general_ledger_account'

attributes = (
'id',
'account_type',
'code',
'description',
'created_at',
'updated_at',
)

class PerformanceObligation(Resource):

"""Performance Obligation for Revenue Recognition"""

member_path = 'performance_obligations/%s'
collection_path = 'performance_obligations'

nodename = 'performance_obligation'

attributes = (
'id',
'name',
'created_at',
'updated_at',
)

class BillingInfo(Resource):

"""A set of billing information for an account."""
Expand Down Expand Up @@ -751,6 +787,9 @@ class GiftCard(Resource):
'updated_at',
'unit_amount_in_cents',
'billing_info',
'liability_gl_account_id',
'revenue_gl_account_id',
'performance_obligation_id'
)
_classes_for_nodename = {'recipient_account': Account,'gifter_account':
Account, 'delivery': Delivery}
Expand Down Expand Up @@ -961,6 +1000,9 @@ class Item(Resource):
'created_at',
'updated_at',
'deleted_at',
'liability_gl_account_id',
'revenue_gl_account_id',
'performance_obligation_id'
)

class Adjustment(Resource):
Expand Down Expand Up @@ -1003,6 +1045,11 @@ class Adjustment(Resource):
'shipping_address_id',
'refundable_total_in_cents',
'custom_fields',
'liability_gl_account_code',
'liability_gl_account_id',
'revenue_gl_account_code',
'revenue_gl_account_id',
'performance_obligation_id',
)
xml_attribute_attributes = ('type',)
_classes_for_nodename = {
Expand Down Expand Up @@ -1447,6 +1494,9 @@ class ShippingMethod(Resource):
'name',
'accounting_code',
'tax_code',
'liability_gl_account_id',
'revenue_gl_account_id',
'performance_obligation_id',
'created_at',
'updated_at',
)
Expand Down Expand Up @@ -1491,6 +1541,12 @@ class Plan(Resource):
'trial_interval_unit',
'accounting_code',
'setup_fee_accounting_code',
'liability_gl_account_id',
'revenue_gl_account_id',
'performance_obligation_id',
'setup_fee_liability_gl_account_id',
'setup_fee_revenue_gl_account_id',
'setup_fee_performance_obligation_id',
'created_at',
'updated_at',
'tax_exempt',
Expand Down Expand Up @@ -2081,7 +2137,10 @@ class AddOn(Resource):
'updated_at',
'tier_type',
'tiers',
'percentage_tiers'
'percentage_tiers',
'liability_gl_account_id',
'revenue_gl_account_id',
'performance_obligation_id'
)

_classes_for_nodename = {
Expand Down
45 changes: 45 additions & 0 deletions tests/fixtures/add-on/created-with-revrec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
POST https://api.recurly.com/v2/plans/planmock/add_ons 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"?>
<add_on>
<add_on_code>addonrevrec</add_on_code>
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
<name>Add-On with RevRec</name>
<performance_obligation_id>5</performance_obligation_id>
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
<unit_amount_in_cents>
<USD type="integer">40</USD>
</unit_amount_in_cents>
</add_on>

HTTP/1.1 201 Created
Content-Type: application/xml; charset=utf-8
Location: https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec

<?xml version="1.0" encoding="UTF-8"?>
<add_on href="https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec">
<plan href="https://api.recurly.com/v2/plans/planmock"/>
<add_on_code>addonrevrec</add_on_code>
<name>Add-On with RevRec</name>
<default_quantity type="integer">1</default_quantity>
<display_quantity_on_hosted_page type="boolean">false</display_quantity_on_hosted_page>
<tax_code nil="nil"></tax_code>
<unit_amount_in_cents>
<USD type="integer">40</USD>
</unit_amount_in_cents>
<accounting_code nil="nil"></accounting_code>
<add_on_type>fixed</add_on_type>
<optional type="boolean">true</optional>
<revenue_schedule_type>evenly</revenue_schedule_type>
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
<performance_obligation_id>5</performance_obligation_id>
<tier_type>flat</tier_type>
<created_at type="datetime">2024-02-20T23:06:46Z</created_at>
<updated_at type="datetime">2024-02-20T23:06:46Z</updated_at>
</add_on>
32 changes: 32 additions & 0 deletions tests/fixtures/add-on/exists-with-revrec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
GET https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec HTTP/1.1
X-Api-Version: {api-version}
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: {user-agent}


HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<add_on href="https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec">
<plan href="https://api.recurly.com/v2/plans/planmock"/>
<add_on_code>addonrevrec</add_on_code>
<name>Add-On with RevRec</name>
<default_quantity type="integer">1</default_quantity>
<display_quantity_on_hosted_page type="boolean">false</display_quantity_on_hosted_page>
<tax_code nil="nil"></tax_code>
<unit_amount_in_cents>
<USD type="integer">40</USD>
</unit_amount_in_cents>
<accounting_code nil="nil"></accounting_code>
<add_on_type>fixed</add_on_type>
<optional type="boolean">true</optional>
<revenue_schedule_type>evenly</revenue_schedule_type>
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
<performance_obligation_id>5</performance_obligation_id>
<tier_type>flat</tier_type>
<created_at type="datetime">2024-02-20T23:06:46Z</created_at>
<updated_at type="datetime">2024-02-20T23:06:46Z</updated_at>
</add_on>
39 changes: 39 additions & 0 deletions tests/fixtures/add-on/updated-with-revrec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PUT https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec 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"?>
<add_on>
<liability_gl_account_id nil="nil"></liability_gl_account_id>
<performance_obligation_id nil="nil"></performance_obligation_id>
<revenue_gl_account_id nil="nil"></revenue_gl_account_id>
</add_on>

HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<add_on href="https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec">
<plan href="https://api.recurly.com/v2/plans/planmock"/>
<add_on_code>addonrevrec</add_on_code>
<name>Add-On with RevRec</name>
<default_quantity type="integer">1</default_quantity>
<display_quantity_on_hosted_page type="boolean">false</display_quantity_on_hosted_page>
<tax_code nil="nil"></tax_code>
<unit_amount_in_cents>
<USD type="integer">40</USD>
</unit_amount_in_cents>
<accounting_code nil="nil"></accounting_code>
<add_on_type>fixed</add_on_type>
<optional type="boolean">true</optional>
<revenue_schedule_type>evenly</revenue_schedule_type>
<liability_gl_account_id nil="nil"></liability_gl_account_id>
<revenue_gl_account_id nil="nil"></revenue_gl_account_id>
<performance_obligation_id>6</performance_obligation_id>
<tier_type>flat</tier_type>
<created_at type="datetime">2024-02-20T23:06:46Z</created_at>
<updated_at type="datetime">2024-02-20T23:14:00Z</updated_at>
</add_on>
3 changes: 3 additions & 0 deletions tests/fixtures/adjustment/account-has-adjustments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ X-Records: 1
<value>blue</value>
</custom_field>
</custom_fields>
<liability_gl_account_code>firstliab</liability_gl_account_code>
<revenue_gl_account_code>firstrev</revenue_gl_account_code>
<performance_obligation_id>5</performance_obligation_id>
</adjustment>
</adjustments>
56 changes: 56 additions & 0 deletions tests/fixtures/adjustment/charged-with-revrec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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>
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
<performance_obligation_id>5</performance_obligation_id>
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
<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>
<liability_gl_account_code>firstliab</liability_gl_account_code>
<revenue_gl_account_code>firstrev</revenue_gl_account_code>
<performance_obligation_id>5</performance_obligation_id>
</adjustment>
2 changes: 2 additions & 0 deletions tests/fixtures/business_entity/get.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ Content-Type: application/xml; charset=utf-8
<default_registration_number>ab1</default_registration_number>
<created_at type="datetime">2023-05-13T17:28:47Z</created_at>
<updated_at type="datetime">2023-10-13T17:28:48Z</updated_at>
<default_liability_gl_account_id>t5ejtge1xw0x</default_liability_gl_account_id>
<default_revenue_gl_account_id>t5ejtgf1vxh1</default_revenue_gl_account_id>
</business_entity>
4 changes: 4 additions & 0 deletions tests/fixtures/business_entity/list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Content-Type: application/xml; charset=utf-8
<default_registration_number></default_registration_number>
<created_at type="datetime">2023-05-25T15:56:47Z</created_at>
<updated_at type="datetime">2023-05-25T15:56:47Z</updated_at>
<default_liability_gl_account_id nil="nil"></default_liability_gl_account_id>
<default_revenue_gl_account_id nil="nil"></default_revenue_gl_account_id>
</business_entity>
<business_entity href="https://pcc.recurly.dev:3000/v2/business_entities/sppvjs6eripk">
<invoices href="https://pcc.recurly.dev:3000/v2/business_entities/sppvjs6eripk/invoices"/>
Expand Down Expand Up @@ -69,5 +71,7 @@ Content-Type: application/xml; charset=utf-8
<default_registration_number></default_registration_number>
<created_at type="datetime">2023-04-12T15:11:58Z</created_at>
<updated_at type="datetime">2023-05-15T15:34:01Z</updated_at>
<default_liability_gl_account_id>t5ejtge1xw0x</default_liability_gl_account_id>
<default_revenue_gl_account_id>t5ejtgf1vxh1</default_revenue_gl_account_id>
</business_entity>
</business_entities>
28 changes: 28 additions & 0 deletions tests/fixtures/general_ledger_accounts/created.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
POST https://api.recurly.com/v2/general_ledger_accounts 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"?>
<general_ledger_account>
<account_type>liability</account_type>
<code>code2</code>
<description>Liability Description</description>
</general_ledger_account>


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

<?xml version="1.0" encoding="UTF-8"?>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/u9hmrpzksuy8">
<id>u9hmrpzksuy8</id>
<code>code2</code>
<account_type>liability</account_type>
<description>Liability Description</description>
<created_at type="datetime">2024-01-18T23:20:01Z</created_at>
<updated_at type="datetime">2024-01-18T23:20:01Z</updated_at>
</general_ledger_account>
20 changes: 20 additions & 0 deletions tests/fixtures/general_ledger_accounts/get.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
GET https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix HTTP/1.1
X-Api-Version: {api-version}
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: {user-agent}


HTTP/1.1 200 OK
X-Records: 1
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix">
<id>u90r5deeaxix</id>
<code>code1</code>
<account_type>revenue</account_type>
<description>Some Description</description>
<created_at type="datetime">2024-01-16T14:34:16Z</created_at>
<updated_at type="datetime">2024-01-16T14:34:16Z</updated_at>
</general_ledger_account>
Loading

0 comments on commit 699dab3

Please sign in to comment.