Skip to content

Commit 699dab3

Browse files
authored
Merge pull request #670 from recurly/add-revrec-features-to-python
[DO NOT MERGE] Add RevRec Features to Python
2 parents 91f3b25 + 1f408bb commit 699dab3

30 files changed

+1866
-4
lines changed

recurly/__init__.py

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@ class BusinessEntity(Resource):
490490
'default_vat_number',
491491
'default_registration_number',
492492
'created_at',
493-
'updated_at'
493+
'updated_at',
494+
'default_revenue_gl_account_id',
495+
'default_liability_gl_account_id',
494496
)
495497

496498
_classes_for_nodename = {
@@ -515,6 +517,40 @@ class GatewayAttributes(Resource):
515517
'account_reference',
516518
)
517519

520+
class GeneralLedgerAccount(Resource):
521+
522+
"""General Ledger Account for Revenue Recognition"""
523+
524+
member_path = 'general_ledger_accounts/%s'
525+
collection_path = 'general_ledger_accounts'
526+
527+
nodename = 'general_ledger_account'
528+
529+
attributes = (
530+
'id',
531+
'account_type',
532+
'code',
533+
'description',
534+
'created_at',
535+
'updated_at',
536+
)
537+
538+
class PerformanceObligation(Resource):
539+
540+
"""Performance Obligation for Revenue Recognition"""
541+
542+
member_path = 'performance_obligations/%s'
543+
collection_path = 'performance_obligations'
544+
545+
nodename = 'performance_obligation'
546+
547+
attributes = (
548+
'id',
549+
'name',
550+
'created_at',
551+
'updated_at',
552+
)
553+
518554
class BillingInfo(Resource):
519555

520556
"""A set of billing information for an account."""
@@ -751,6 +787,9 @@ class GiftCard(Resource):
751787
'updated_at',
752788
'unit_amount_in_cents',
753789
'billing_info',
790+
'liability_gl_account_id',
791+
'revenue_gl_account_id',
792+
'performance_obligation_id'
754793
)
755794
_classes_for_nodename = {'recipient_account': Account,'gifter_account':
756795
Account, 'delivery': Delivery}
@@ -961,6 +1000,9 @@ class Item(Resource):
9611000
'created_at',
9621001
'updated_at',
9631002
'deleted_at',
1003+
'liability_gl_account_id',
1004+
'revenue_gl_account_id',
1005+
'performance_obligation_id'
9641006
)
9651007

9661008
class Adjustment(Resource):
@@ -1003,6 +1045,11 @@ class Adjustment(Resource):
10031045
'shipping_address_id',
10041046
'refundable_total_in_cents',
10051047
'custom_fields',
1048+
'liability_gl_account_code',
1049+
'liability_gl_account_id',
1050+
'revenue_gl_account_code',
1051+
'revenue_gl_account_id',
1052+
'performance_obligation_id',
10061053
)
10071054
xml_attribute_attributes = ('type',)
10081055
_classes_for_nodename = {
@@ -1447,6 +1494,9 @@ class ShippingMethod(Resource):
14471494
'name',
14481495
'accounting_code',
14491496
'tax_code',
1497+
'liability_gl_account_id',
1498+
'revenue_gl_account_id',
1499+
'performance_obligation_id',
14501500
'created_at',
14511501
'updated_at',
14521502
)
@@ -1491,6 +1541,12 @@ class Plan(Resource):
14911541
'trial_interval_unit',
14921542
'accounting_code',
14931543
'setup_fee_accounting_code',
1544+
'liability_gl_account_id',
1545+
'revenue_gl_account_id',
1546+
'performance_obligation_id',
1547+
'setup_fee_liability_gl_account_id',
1548+
'setup_fee_revenue_gl_account_id',
1549+
'setup_fee_performance_obligation_id',
14941550
'created_at',
14951551
'updated_at',
14961552
'tax_exempt',
@@ -2081,7 +2137,10 @@ class AddOn(Resource):
20812137
'updated_at',
20822138
'tier_type',
20832139
'tiers',
2084-
'percentage_tiers'
2140+
'percentage_tiers',
2141+
'liability_gl_account_id',
2142+
'revenue_gl_account_id',
2143+
'performance_obligation_id'
20852144
)
20862145

20872146
_classes_for_nodename = {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
POST https://api.recurly.com/v2/plans/planmock/add_ons HTTP/1.1
2+
X-Api-Version: {api-version}
3+
Accept: application/xml
4+
Authorization: Basic YXBpa2V5Og==
5+
User-Agent: {user-agent}
6+
Content-Type: application/xml; charset=utf-8
7+
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<add_on>
10+
<add_on_code>addonrevrec</add_on_code>
11+
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
12+
<name>Add-On with RevRec</name>
13+
<performance_obligation_id>5</performance_obligation_id>
14+
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
15+
<unit_amount_in_cents>
16+
<USD type="integer">40</USD>
17+
</unit_amount_in_cents>
18+
</add_on>
19+

20+
HTTP/1.1 201 Created
21+
Content-Type: application/xml; charset=utf-8
22+
Location: https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec
23+
24+
<?xml version="1.0" encoding="UTF-8"?>
25+
<add_on href="https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec">
26+
<plan href="https://api.recurly.com/v2/plans/planmock"/>
27+
<add_on_code>addonrevrec</add_on_code>
28+
<name>Add-On with RevRec</name>
29+
<default_quantity type="integer">1</default_quantity>
30+
<display_quantity_on_hosted_page type="boolean">false</display_quantity_on_hosted_page>
31+
<tax_code nil="nil"></tax_code>
32+
<unit_amount_in_cents>
33+
<USD type="integer">40</USD>
34+
</unit_amount_in_cents>
35+
<accounting_code nil="nil"></accounting_code>
36+
<add_on_type>fixed</add_on_type>
37+
<optional type="boolean">true</optional>
38+
<revenue_schedule_type>evenly</revenue_schedule_type>
39+
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
40+
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
41+
<performance_obligation_id>5</performance_obligation_id>
42+
<tier_type>flat</tier_type>
43+
<created_at type="datetime">2024-02-20T23:06:46Z</created_at>
44+
<updated_at type="datetime">2024-02-20T23:06:46Z</updated_at>
45+
</add_on>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
GET https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec HTTP/1.1
2+
X-Api-Version: {api-version}
3+
Accept: application/xml
4+
Authorization: Basic YXBpa2V5Og==
5+
User-Agent: {user-agent}
6+
7+

8+
HTTP/1.1 200 OK
9+
Content-Type: application/xml; charset=utf-8
10+
11+
<?xml version="1.0" encoding="UTF-8"?>
12+
<add_on href="https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec">
13+
<plan href="https://api.recurly.com/v2/plans/planmock"/>
14+
<add_on_code>addonrevrec</add_on_code>
15+
<name>Add-On with RevRec</name>
16+
<default_quantity type="integer">1</default_quantity>
17+
<display_quantity_on_hosted_page type="boolean">false</display_quantity_on_hosted_page>
18+
<tax_code nil="nil"></tax_code>
19+
<unit_amount_in_cents>
20+
<USD type="integer">40</USD>
21+
</unit_amount_in_cents>
22+
<accounting_code nil="nil"></accounting_code>
23+
<add_on_type>fixed</add_on_type>
24+
<optional type="boolean">true</optional>
25+
<revenue_schedule_type>evenly</revenue_schedule_type>
26+
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
27+
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
28+
<performance_obligation_id>5</performance_obligation_id>
29+
<tier_type>flat</tier_type>
30+
<created_at type="datetime">2024-02-20T23:06:46Z</created_at>
31+
<updated_at type="datetime">2024-02-20T23:06:46Z</updated_at>
32+
</add_on>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
PUT https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec HTTP/1.1
2+
X-Api-Version: {api-version}
3+
Accept: application/xml
4+
Authorization: Basic YXBpa2V5Og==
5+
User-Agent: {user-agent}
6+
Content-Type: application/xml; charset=utf-8
7+
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<add_on>
10+
<liability_gl_account_id nil="nil"></liability_gl_account_id>
11+
<performance_obligation_id nil="nil"></performance_obligation_id>
12+
<revenue_gl_account_id nil="nil"></revenue_gl_account_id>
13+
</add_on>
14+

15+
HTTP/1.1 200 OK
16+
Content-Type: application/xml; charset=utf-8
17+
18+
<?xml version="1.0" encoding="UTF-8"?>
19+
<add_on href="https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec">
20+
<plan href="https://api.recurly.com/v2/plans/planmock"/>
21+
<add_on_code>addonrevrec</add_on_code>
22+
<name>Add-On with RevRec</name>
23+
<default_quantity type="integer">1</default_quantity>
24+
<display_quantity_on_hosted_page type="boolean">false</display_quantity_on_hosted_page>
25+
<tax_code nil="nil"></tax_code>
26+
<unit_amount_in_cents>
27+
<USD type="integer">40</USD>
28+
</unit_amount_in_cents>
29+
<accounting_code nil="nil"></accounting_code>
30+
<add_on_type>fixed</add_on_type>
31+
<optional type="boolean">true</optional>
32+
<revenue_schedule_type>evenly</revenue_schedule_type>
33+
<liability_gl_account_id nil="nil"></liability_gl_account_id>
34+
<revenue_gl_account_id nil="nil"></revenue_gl_account_id>
35+
<performance_obligation_id>6</performance_obligation_id>
36+
<tier_type>flat</tier_type>
37+
<created_at type="datetime">2024-02-20T23:06:46Z</created_at>
38+
<updated_at type="datetime">2024-02-20T23:14:00Z</updated_at>
39+
</add_on>

tests/fixtures/adjustment/account-has-adjustments.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@ X-Records: 1
4747
<value>blue</value>
4848
</custom_field>
4949
</custom_fields>
50+
<liability_gl_account_code>firstliab</liability_gl_account_code>
51+
<revenue_gl_account_code>firstrev</revenue_gl_account_code>
52+
<performance_obligation_id>5</performance_obligation_id>
5053
</adjustment>
5154
</adjustments>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
POST https://api.recurly.com/v2/accounts/chargemock/adjustments HTTP/1.1
2+
X-Api-Version: {api-version}
3+
Accept: application/xml
4+
Authorization: Basic YXBpa2V5Og==
5+
User-Agent: {user-agent}
6+
Content-Type: application/xml; charset=utf-8
7+
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<adjustment type="charge">
10+
<currency>USD</currency>
11+
<description>test charge</description>
12+
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
13+
<performance_obligation_id>5</performance_obligation_id>
14+
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
15+
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
16+
</adjustment>
17+

18+
HTTP/1.1 201 Created
19+
Content-Type: application/xml; charset=utf-8
20+
Location: https://api.recurly.com/v2/adjustments/6f56942e01241200964cb6425c85b9d4
21+
22+
<?xml version="1.0" encoding="UTF-8"?>
23+
<adjustment href="https://api.recurly.com/v2/adjustments/6f56942e01241200964cb6425c85b9d4" type="charge">
24+
<account href="https://api.recurly.com/v2/accounts/chargemock"/>
25+
<bill_for_account href="https://api.recurly.com/v2/accounts/chargemock"/>
26+
<item_code nil="nil"></item_code>
27+
<external_sku nil="nil"></external_sku>
28+
<credit_adjustments href="https://api.recurly.com/v2/adjustments/6f56942e01241200964cb6425c85b9d4/credit_adjustments"/>
29+
<refundable_total_in_cents type="integer">0</refundable_total_in_cents>
30+
<uuid>6f56942e01241200964cb6425c85b9d4</uuid>
31+
<state>pending</state>
32+
<description>test charge</description>
33+
<accounting_code nil="nil"></accounting_code>
34+
<product_code nil="nil"></product_code>
35+
<origin>debit</origin>
36+
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
37+
<quantity type="integer">1</quantity>
38+
<discount_in_cents type="integer">0</discount_in_cents>
39+
<tax_in_cents type="integer">0</tax_in_cents>
40+
<total_in_cents type="integer">1000</total_in_cents>
41+
<tax_inclusive type="boolean">false</tax_inclusive>
42+
<currency>USD</currency>
43+
<proration_rate nil="nil"></proration_rate>
44+
<tax_exempt type="boolean">false</tax_exempt>
45+
<tax_code nil="nil"></tax_code>
46+
<start_date type="datetime">2024-02-26T23:38:41Z</start_date>
47+
<end_date nil="nil"></end_date>
48+
<created_at type="datetime">2024-02-26T23:38:42Z</created_at>
49+
<updated_at type="datetime">2024-02-26T23:38:42Z</updated_at>
50+
<revenue_schedule_type></revenue_schedule_type>
51+
<custom_fields type="array">
52+
</custom_fields>
53+
<liability_gl_account_code>firstliab</liability_gl_account_code>
54+
<revenue_gl_account_code>firstrev</revenue_gl_account_code>
55+
<performance_obligation_id>5</performance_obligation_id>
56+
</adjustment>

tests/fixtures/business_entity/get.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ Content-Type: application/xml; charset=utf-8
4040
<default_registration_number>ab1</default_registration_number>
4141
<created_at type="datetime">2023-05-13T17:28:47Z</created_at>
4242
<updated_at type="datetime">2023-10-13T17:28:48Z</updated_at>
43+
<default_liability_gl_account_id>t5ejtge1xw0x</default_liability_gl_account_id>
44+
<default_revenue_gl_account_id>t5ejtgf1vxh1</default_revenue_gl_account_id>
4345
</business_entity>

tests/fixtures/business_entity/list.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Content-Type: application/xml; charset=utf-8
3939
<default_registration_number></default_registration_number>
4040
<created_at type="datetime">2023-05-25T15:56:47Z</created_at>
4141
<updated_at type="datetime">2023-05-25T15:56:47Z</updated_at>
42+
<default_liability_gl_account_id nil="nil"></default_liability_gl_account_id>
43+
<default_revenue_gl_account_id nil="nil"></default_revenue_gl_account_id>
4244
</business_entity>
4345
<business_entity href="https://pcc.recurly.dev:3000/v2/business_entities/sppvjs6eripk">
4446
<invoices href="https://pcc.recurly.dev:3000/v2/business_entities/sppvjs6eripk/invoices"/>
@@ -69,5 +71,7 @@ Content-Type: application/xml; charset=utf-8
6971
<default_registration_number></default_registration_number>
7072
<created_at type="datetime">2023-04-12T15:11:58Z</created_at>
7173
<updated_at type="datetime">2023-05-15T15:34:01Z</updated_at>
74+
<default_liability_gl_account_id>t5ejtge1xw0x</default_liability_gl_account_id>
75+
<default_revenue_gl_account_id>t5ejtgf1vxh1</default_revenue_gl_account_id>
7276
</business_entity>
7377
</business_entities>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
POST https://api.recurly.com/v2/general_ledger_accounts HTTP/1.1
2+
X-Api-Version: {api-version}
3+
Accept: application/xml
4+
Authorization: Basic YXBpa2V5Og==
5+
User-Agent: {user-agent}
6+
Content-Type: application/xml; charset=utf-8
7+
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<general_ledger_account>
10+
<account_type>liability</account_type>
11+
<code>code2</code>
12+
<description>Liability Description</description>
13+
</general_ledger_account>
14+
15+

16+
HTTP/1.1 201 Created
17+
Content-Type: application/xml; charset=utf-8
18+
Location: https://api.recurly.com/v2/general_ledger_accounts/u9hmrpzksuy8
19+
20+
<?xml version="1.0" encoding="UTF-8"?>
21+
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/u9hmrpzksuy8">
22+
<id>u9hmrpzksuy8</id>
23+
<code>code2</code>
24+
<account_type>liability</account_type>
25+
<description>Liability Description</description>
26+
<created_at type="datetime">2024-01-18T23:20:01Z</created_at>
27+
<updated_at type="datetime">2024-01-18T23:20:01Z</updated_at>
28+
</general_ledger_account>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GET https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix HTTP/1.1
2+
X-Api-Version: {api-version}
3+
Accept: application/xml
4+
Authorization: Basic YXBpa2V5Og==
5+
User-Agent: {user-agent}
6+
7+

8+
HTTP/1.1 200 OK
9+
X-Records: 1
10+
Content-Type: application/xml; charset=utf-8
11+
12+
<?xml version="1.0" encoding="UTF-8"?>
13+
<general_ledger_account href="https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix">
14+
<id>u90r5deeaxix</id>
15+
<code>code1</code>
16+
<account_type>revenue</account_type>
17+
<description>Some Description</description>
18+
<created_at type="datetime">2024-01-16T14:34:16Z</created_at>
19+
<updated_at type="datetime">2024-01-16T14:34:16Z</updated_at>
20+
</general_ledger_account>

0 commit comments

Comments
 (0)