diff --git a/recurly/__init__.py b/recurly/__init__.py index 3e409c83..05594a3c 100644 --- a/recurly/__init__.py +++ b/recurly/__init__.py @@ -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 = { @@ -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.""" @@ -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} @@ -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): @@ -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 = { @@ -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', ) @@ -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', @@ -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 = { diff --git a/tests/fixtures/add-on/created-with-revrec.xml b/tests/fixtures/add-on/created-with-revrec.xml new file mode 100644 index 00000000..2d68b8b5 --- /dev/null +++ b/tests/fixtures/add-on/created-with-revrec.xml @@ -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 + + + + addonrevrec + t5ejtge1xw0x + Add-On with RevRec + 5 + t5ejtgf1vxh1 + + 40 + + + +HTTP/1.1 201 Created +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/plans/planmock/add_ons/addonrevrec + + + + + addonrevrec + Add-On with RevRec + 1 + false + + + 40 + + + fixed + true + evenly + t5ejtge1xw0x + t5ejtgf1vxh1 + 5 + flat + 2024-02-20T23:06:46Z + 2024-02-20T23:06:46Z + diff --git a/tests/fixtures/add-on/exists-with-revrec.xml b/tests/fixtures/add-on/exists-with-revrec.xml new file mode 100644 index 00000000..83dd1f5f --- /dev/null +++ b/tests/fixtures/add-on/exists-with-revrec.xml @@ -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 + + + + + addonrevrec + Add-On with RevRec + 1 + false + + + 40 + + + fixed + true + evenly + t5ejtge1xw0x + t5ejtgf1vxh1 + 5 + flat + 2024-02-20T23:06:46Z + 2024-02-20T23:06:46Z + diff --git a/tests/fixtures/add-on/updated-with-revrec.xml b/tests/fixtures/add-on/updated-with-revrec.xml new file mode 100644 index 00000000..6cbe8d66 --- /dev/null +++ b/tests/fixtures/add-on/updated-with-revrec.xml @@ -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 + + + + + + + + +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 + + + + + addonrevrec + Add-On with RevRec + 1 + false + + + 40 + + + fixed + true + evenly + + + 6 + flat + 2024-02-20T23:06:46Z + 2024-02-20T23:14:00Z + diff --git a/tests/fixtures/adjustment/account-has-adjustments.xml b/tests/fixtures/adjustment/account-has-adjustments.xml index c3ef5764..f6be9f19 100644 --- a/tests/fixtures/adjustment/account-has-adjustments.xml +++ b/tests/fixtures/adjustment/account-has-adjustments.xml @@ -47,5 +47,8 @@ X-Records: 1 blue + firstliab + firstrev + 5 diff --git a/tests/fixtures/adjustment/charged-with-revrec.xml b/tests/fixtures/adjustment/charged-with-revrec.xml new file mode 100644 index 00000000..fea47e81 --- /dev/null +++ b/tests/fixtures/adjustment/charged-with-revrec.xml @@ -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 + + + + USD + test charge + t5ejtge1xw0x + 5 + t5ejtgf1vxh1 + 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 + + + + firstliab + firstrev + 5 + diff --git a/tests/fixtures/business_entity/get.xml b/tests/fixtures/business_entity/get.xml index 96407ea4..e5946c23 100644 --- a/tests/fixtures/business_entity/get.xml +++ b/tests/fixtures/business_entity/get.xml @@ -40,4 +40,6 @@ Content-Type: application/xml; charset=utf-8 ab1 2023-05-13T17:28:47Z 2023-10-13T17:28:48Z + t5ejtge1xw0x + t5ejtgf1vxh1 diff --git a/tests/fixtures/business_entity/list.xml b/tests/fixtures/business_entity/list.xml index 5d7c88a4..ab4f8008 100644 --- a/tests/fixtures/business_entity/list.xml +++ b/tests/fixtures/business_entity/list.xml @@ -39,6 +39,8 @@ Content-Type: application/xml; charset=utf-8 2023-05-25T15:56:47Z 2023-05-25T15:56:47Z + + @@ -69,5 +71,7 @@ Content-Type: application/xml; charset=utf-8 2023-04-12T15:11:58Z 2023-05-15T15:34:01Z + t5ejtge1xw0x + t5ejtgf1vxh1 diff --git a/tests/fixtures/general_ledger_accounts/created.xml b/tests/fixtures/general_ledger_accounts/created.xml new file mode 100644 index 00000000..367682ed --- /dev/null +++ b/tests/fixtures/general_ledger_accounts/created.xml @@ -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 + + + + liability + code2 + Liability Description + + + +HTTP/1.1 201 Created +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/general_ledger_accounts/u9hmrpzksuy8 + + + + u9hmrpzksuy8 + code2 + liability + Liability Description + 2024-01-18T23:20:01Z + 2024-01-18T23:20:01Z + diff --git a/tests/fixtures/general_ledger_accounts/get.xml b/tests/fixtures/general_ledger_accounts/get.xml new file mode 100644 index 00000000..95f0caa1 --- /dev/null +++ b/tests/fixtures/general_ledger_accounts/get.xml @@ -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 + + + + u90r5deeaxix + code1 + revenue + Some Description + 2024-01-16T14:34:16Z + 2024-01-16T14:34:16Z + diff --git a/tests/fixtures/general_ledger_accounts/list.xml b/tests/fixtures/general_ledger_accounts/list.xml new file mode 100644 index 00000000..b4311264 --- /dev/null +++ b/tests/fixtures/general_ledger_accounts/list.xml @@ -0,0 +1,30 @@ +GET 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} + + +HTTP/1.1 200 OK +X-Records: 1 +Content-Type: application/xml; charset=utf-8 + + + + + u90r5deeaxix + code1 + revenue + Some Description + 2024-01-16T14:34:16Z + 2024-01-16T14:34:16Z + + + u9hmrpzksuy8 + code2 + liability + Liability Description + 2024-01-18T23:20:01Z + 2024-01-18T23:20:01Z + + diff --git a/tests/fixtures/general_ledger_accounts/list_filtered.xml b/tests/fixtures/general_ledger_accounts/list_filtered.xml new file mode 100644 index 00000000..7f5fc180 --- /dev/null +++ b/tests/fixtures/general_ledger_accounts/list_filtered.xml @@ -0,0 +1,22 @@ +GET https://api.recurly.com/v2/general_ledger_accounts?account_type=revenue 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 + + + + + u90r5deeaxix + code1 + revenue + Some Description + 2024-01-16T14:34:16Z + 2024-01-16T14:34:16Z + + diff --git a/tests/fixtures/general_ledger_accounts/updated.xml b/tests/fixtures/general_ledger_accounts/updated.xml new file mode 100644 index 00000000..87906a15 --- /dev/null +++ b/tests/fixtures/general_ledger_accounts/updated.xml @@ -0,0 +1,27 @@ +PUT 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} +Content-Type: application/xml; charset=utf-8 + + + + code2 + Updated Description + + + +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/general_ledger_accounts/u90r5deeaxix + + + + u90r5deeaxix + code2 + liability + Updated Description + 2024-01-18T23:20:01Z + 2024-01-18T23:24:47Z + diff --git a/tests/fixtures/gift_cards/get.xml b/tests/fixtures/gift_cards/get.xml new file mode 100644 index 00000000..6e67fc84 --- /dev/null +++ b/tests/fixtures/gift_cards/get.xml @@ -0,0 +1,39 @@ +GET https://api.recurly.com/v2/gift_cards/3880289408739841209 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 + + + + + + 3880289408739841209 + ASDR63PM4JUTXW9I + test_gift_card + 1000 + USD + + email + sally@example.com + + Sally + Smith +
+ John + Congrats! +
+ 2023-08-29T18:42:23Z + 2023-08-29T18:42:23Z + 2023-08-29T18:42:23Z + + + + t5ejtge1xw0x + t5ejtgf1vxh1 + 4 +
diff --git a/tests/fixtures/gift_cards/list.xml b/tests/fixtures/gift_cards/list.xml new file mode 100644 index 00000000..afd0b6ce --- /dev/null +++ b/tests/fixtures/gift_cards/list.xml @@ -0,0 +1,69 @@ +GET https://api.recurly.com/v2/gift_cards 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 + + + + + + + 3880289408739841209 + ASDR63PM4JUTXW9I + test_gift_card + 1000 + USD + + email + sally@example.com + + Sally + Smith +
+ John + Congrats! +
+ 2023-08-29T18:42:23Z + 2023-08-29T18:42:23Z + 2023-08-29T18:42:23Z + + +
+ t5ejtge1xw0x + t5ejtgf1vxh1 + 4 + + + + + 3951365864235636055 + 6HZDUC8S1AGX7WVB + test_gift_card + 1000 + USD + + email + john@example.com + + John + Smith +
+ Sally + Hi John, Happy Birthday! I hope you have a great day! Love, Sally +
+ 2023-12-05T20:18:37Z + 2023-12-05T20:18:37Z + 2023-12-05T20:18:37Z + + +
+ t5ejtge1xw0x + t5ejtgf1vxh1 + 4 + + diff --git a/tests/fixtures/item/created-with-revrec.xml b/tests/fixtures/item/created-with-revrec.xml new file mode 100644 index 00000000..b7147b3e --- /dev/null +++ b/tests/fixtures/item/created-with-revrec.xml @@ -0,0 +1,43 @@ +POST https://api.recurly.com/v2/items 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 + + + + An item of the mocked variety + itemmock + t5ejtge1xw0x + Mock Item + 5 + t5ejtgf1vxh1 + + +HTTP/1.1 201 Created +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/items/itemmock + + + + itemmock + Mock Item + handcrafted-plastic-soap + An item of the mocked variety + true + 1569273867 + never + + + color + blue + + + 2019-09-23T21:25:45Z + 2019-09-23T21:25:45Z + + t5ejtge1xw0x + t5ejtgf1vxh1 + 5 + diff --git a/tests/fixtures/item/exists-with-revrec.xml b/tests/fixtures/item/exists-with-revrec.xml new file mode 100644 index 00000000..4864f3b4 --- /dev/null +++ b/tests/fixtures/item/exists-with-revrec.xml @@ -0,0 +1,19 @@ +GET https://api.recurly.com/v2/items/itemmock 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 + + + + itemmock + Mock Item + Sleek Plastic + t5ejtge1xw0x + t5ejtgf1vxh1 + 5 + diff --git a/tests/fixtures/item/updated-with-revrec.xml b/tests/fixtures/item/updated-with-revrec.xml new file mode 100644 index 00000000..89ef79b3 --- /dev/null +++ b/tests/fixtures/item/updated-with-revrec.xml @@ -0,0 +1,40 @@ +PUT https://api.recurly.com/v2/items/itemmock 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 + + + + A mocked description + + + + + +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 + + + + itemmock + Mock Item + handcrafted-plastic-soap + A mocked description + true + 1569273867 + never + + + color + blue + + + 2019-09-23T21:25:45Z + 2019-09-23T21:25:45Z + + + + 6 + diff --git a/tests/fixtures/performance_obligations/get.xml b/tests/fixtures/performance_obligations/get.xml new file mode 100644 index 00000000..27894e01 --- /dev/null +++ b/tests/fixtures/performance_obligations/get.xml @@ -0,0 +1,18 @@ +GET https://api.recurly.com/v2/performance_obligations/6 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 + + + + 6 + Over Time (Daily) + 2023-08-15T18:29:31Z + 2023-08-15T18:29:31Z + diff --git a/tests/fixtures/performance_obligations/list.xml b/tests/fixtures/performance_obligations/list.xml new file mode 100644 index 00000000..f6a5eafa --- /dev/null +++ b/tests/fixtures/performance_obligations/list.xml @@ -0,0 +1,50 @@ +GET https://api.recurly.com/v2/performance_obligations 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 + + + + + 6 + Over Time (Daily) + 2023-08-15T18:29:31Z + 2023-08-15T18:29:31Z + + + 5 + Over Time (Partial Monthly) + 2023-08-15T18:29:31Z + 2023-08-15T18:29:31Z + + + 4 + Point in Time + 2023-08-15T18:29:31Z + 2023-08-15T18:29:31Z + + + 3 + Manually Recognize + 2023-08-15T18:29:31Z + 2023-08-15T18:29:31Z + + + 2 + Manual Journal + 2023-08-15T18:29:31Z + 2023-08-15T18:29:31Z + + + 1 + Material Right + 2023-08-15T18:29:31Z + 2023-08-15T18:29:31Z + + diff --git a/tests/fixtures/plan/created-with-revrec.xml b/tests/fixtures/plan/created-with-revrec.xml new file mode 100644 index 00000000..5906909c --- /dev/null +++ b/tests/fixtures/plan/created-with-revrec.xml @@ -0,0 +1,76 @@ +POST https://api.recurly.com/v2/plans 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 + + + + t5ejtge1xw0x + RevRec Plan + 5 + planmock + t5ejtgf1vxh1 + + 200 + + t5ejtge1xw0x + 5 + t5ejtgf1vxh1 + + 1000 + + + +HTTP/1.1 201 Created +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/plans/planmock + + + + + planmock + RevRec Plan + + + + false + false + false + false + unit + + 1 + months + 0 + days + 1 + + + t5ejtge1xw0x + t5ejtgf1vxh1 + 5 + t5ejtge1xw0x + t5ejtgf1vxh1 + 5 + false + 2024-02-06T21:47:46Z + 2024-02-06T21:47:46Z + true + fixed + + + evenly + evenly + true + false + + + 1000 + + + 200 + + + diff --git a/tests/fixtures/plan/exists_with_revrec.xml b/tests/fixtures/plan/exists_with_revrec.xml new file mode 100644 index 00000000..13147ec0 --- /dev/null +++ b/tests/fixtures/plan/exists_with_revrec.xml @@ -0,0 +1,57 @@ +GET https://api.recurly.com/v2/plans/planmock 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 + + + + + planmock + RevRec Plan + + + + false + false + false + false + unit + + 1 + months + 0 + days + 1 + + + t5ejtge1xw0x + t5ejtgf1vxh1 + 5 + t5ejtge1xw0x + t5ejtgf1vxh1 + 5 + false + 2024-02-06T21:47:46Z + 2024-02-06T21:47:46Z + true + fixed + + + evenly + evenly + true + false + + + 1000 + + + 200 + + + diff --git a/tests/fixtures/plan/updated_with_revrec.xml b/tests/fixtures/plan/updated_with_revrec.xml new file mode 100644 index 00000000..010066e9 --- /dev/null +++ b/tests/fixtures/plan/updated_with_revrec.xml @@ -0,0 +1,67 @@ +PUT https://api.recurly.com/v2/plans/planmock 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 + + + + + + + + + + + +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 + + + + + planmock + RevRec Plan + + + + false + false + false + false + unit + + 1 + months + 0 + days + 1 + + + + + 6 + + + 4 + false + 2024-02-06T22:01:53Z + 2024-02-06T22:01:53Z + true + fixed + + + evenly + evenly + true + false + + + 1000 + + + 200 + + + diff --git a/tests/fixtures/purchase/authorized-with-revrec.xml b/tests/fixtures/purchase/authorized-with-revrec.xml new file mode 100644 index 00000000..e5683e6a --- /dev/null +++ b/tests/fixtures/purchase/authorized-with-revrec.xml @@ -0,0 +1,186 @@ +POST https://api.recurly.com/v2/purchases/authorize 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 + + + + + testmock + + + + t5ejtge1xw0x + 5 + t5ejtgf1vxh1 + 500 + + + USD + + +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/invoices/1362 + + + + + + + +
+ + test + mock + + test + + San Francisco + CA + 94016 + US + +
+ 6f4709e3703f51c54a8fad48e68b05da + processing + + 1362 + + 51 + 551 + USD + 2024-02-23T23:13:21Z + 2024-02-23T23:13:21Z + + + + + + 500 + 500 + 0 + 2024-02-23T23:13:21Z + 551 + charge + purchase + + 551 + + + 0 + automatic + + + usst + CA + 0.1025 + true + + + + + + + + + 551 + 6f4709e24662d1a609f4a64dfba04bab + invoiced + + + + debit + 500 + 1 + 0 + 51 + 551 + false + USD + + usst + CA + 0.1025 + false + + 2024-02-23T23:13:19Z + + 2024-02-23T23:13:21Z + 2024-02-23T23:13:21Z + + + + firstliab + firstrev + 5 + + + + + + + + 6f4709e44cc1195088d33f4273bc6806 + authorization + 551 + 51 + USD + success + credit_card + 3871597 + transaction + false + true + true + true + 172.22.0.1 + test + api + + Successful test transaction + + + + + Street address and postal code match. + + + 2024-02-23T23:13:20Z + 2024-02-23T23:13:21Z + 2024-02-23T23:13:21Z + false +
+ + testmock + + + + + + test + mock + test + + San Francisco + CA + 94016 + US + + + Visa + 2030 + 12 + 411111 + 1111 + + +
+
+
+
+ + +
diff --git a/tests/fixtures/purchase/invoiced-with-revrec.xml b/tests/fixtures/purchase/invoiced-with-revrec.xml new file mode 100644 index 00000000..42976d52 --- /dev/null +++ b/tests/fixtures/purchase/invoiced-with-revrec.xml @@ -0,0 +1,186 @@ +POST https://api.recurly.com/v2/purchases 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 + + + + + testmock + + + + t5ejtge1xw0x + 5 + t5ejtgf1vxh1 + 500 + + + USD + + +HTTP/1.1 201 Created +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/invoices/1359 + + + + + + + +
+ + test + mock + + test + + San Francisco + CA + 94016 + US + +
+ 6f4654a0444808153e65594a08b9e7a2 + paid + + 1359 + + 51 + 551 + USD + 2024-02-23T19:55:22Z + 2024-02-23T19:55:22Z + + 2024-02-23T19:55:22Z + + + + 500 + 500 + 0 + 2024-02-23T19:55:22Z + 0 + charge + purchase + + 551 + + + 0 + automatic + + + usst + CA + 0.1025 + true + + + + + + + + + 551 + 6f46549f12d532b7579250425881a3ba + invoiced + + + + debit + 500 + 1 + 0 + 51 + 551 + false + USD + + usst + CA + 0.1025 + false + + 2024-02-23T19:55:20Z + + 2024-02-23T19:55:22Z + 2024-02-23T19:55:22Z + + + + firstliab + firstrev + 5 + + + + + + + 6f4654a1a6ba44d5272c794d0d9bd5ef + purchase + 551 + 51 + USD + success + credit_card + 8996822 + transaction + false + true + true + true + 172.22.0.1 + test + api + + Successful test transaction + + + + + Street address and postal code match. + + + 2024-02-23T19:55:21Z + 2024-02-23T19:55:22Z + 2024-02-23T19:55:22Z + false +
+ + testmock + + + + + + test + mock + test + + San Francisco + CA + 94016 + US + + + Visa + 2030 + 12 + 411111 + 1111 + + +
+
+
+
+ + + + diff --git a/tests/fixtures/purchase/pending-with-revrec.xml b/tests/fixtures/purchase/pending-with-revrec.xml new file mode 100644 index 00000000..af78a571 --- /dev/null +++ b/tests/fixtures/purchase/pending-with-revrec.xml @@ -0,0 +1,123 @@ +POST https://api.recurly.com/v2/purchases/pending 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 + + + + + testmock + testmock@example.com + + + + t5ejtge1xw0x + 5 + t5ejtgf1vxh1 + 500 + + + USD + + +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 + + + + + + + +
+ + test + mock + + test + + San Francisco + CA + 94016 + US + +
+ 6f46b5f538e8d9d11e76244447a2c083 + pending + + + + 51 + 551 + USD + + + 2024-02-23T21:41:39Z + + + + + 500 + 500 + 0 + 2024-02-23T21:41:39Z + 551 + charge + purchase + 551 + + + 0 + automatic + + + usst + CA + 0.1025 + true + + + + + + + 551 + 6f46b5f4adb33d01d9986547ce854e5a + pending + + + + debit + 500 + 1 + 0 + 51 + 551 + false + USD + + usst + CA + 0.1025 + false + + 2024-02-23T21:41:39Z + + + + + + + firstliab + firstrev + 5 + + + + +
+ + +
diff --git a/tests/fixtures/purchase/previewed-with-revrec.xml b/tests/fixtures/purchase/previewed-with-revrec.xml new file mode 100644 index 00000000..1e5aabef --- /dev/null +++ b/tests/fixtures/purchase/previewed-with-revrec.xml @@ -0,0 +1,122 @@ +POST https://api.recurly.com/v2/purchases/preview 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 + + + + + testmock + + + + t5ejtge1xw0x + 5 + t5ejtgf1vxh1 + 500 + + + USD + + +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 + + + + + + + +
+ + test + mock + + test + + San Francisco + CA + 94016 + US + +
+ 6f46fd3a6fd7188696e66746c7af73a2 + pending + + + + 51 + 551 + USD + + + 2024-02-23T22:59:30Z + + + + + 500 + 500 + 0 + 2024-02-23T22:59:30Z + 551 + charge + purchase + 551 + + + 0 + automatic + + + usst + CA + 0.1025 + true + + + + + + + 551 + 6f46fd391c157c3e20bb8d4ab78587bd + pending + + + + debit + 500 + 1 + 0 + 51 + 551 + false + USD + + usst + CA + 0.1025 + false + + 2024-02-23T22:59:30Z + + + + + + + firstliab + firstrev + 5 + + + + +
+ + +
diff --git a/tests/fixtures/shipping-method/get.xml b/tests/fixtures/shipping-method/get.xml new file mode 100644 index 00000000..7eaeb2fe --- /dev/null +++ b/tests/fixtures/shipping-method/get.xml @@ -0,0 +1,22 @@ +GET https://api.recurly.com/v2/shipping_methods/shipping2 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 + + + + shipping2 + shipping 2 + ship + FR + t5ejtge1xw0x + t5ejtgf1vxh1 + 6 + 2023-07-06T16:57:18Z + 2023-07-06T16:57:18Z + diff --git a/tests/fixtures/shipping-method/list.xml b/tests/fixtures/shipping-method/list.xml new file mode 100644 index 00000000..b3e03684 --- /dev/null +++ b/tests/fixtures/shipping-method/list.xml @@ -0,0 +1,35 @@ +GET https://api.recurly.com/v2/shipping_methods 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 + + + + + shipping2 + shipping 2 + ship + FR + t5ejtge1xw0x + t5ejtgf1vxh1 + 6 + 2023-07-06T16:57:18Z + 2023-07-06T16:57:18Z + + + shipping + shipping + + + + + 4 + 2023-07-05T22:47:07Z + 2023-07-06T18:15:41Z + + diff --git a/tests/test_resources.py b/tests/test_resources.py index b2cfaa00..94cc2e8e 100644 --- a/tests/test_resources.py +++ b/tests/test_resources.py @@ -7,9 +7,9 @@ import recurly from recurly import Account, AddOn, Address, Adjustment, BillingInfo, Coupon, Item, Plan, Redemption, Subscription, \ - SubscriptionAddOn, Transaction, MeasuredUnit, Usage, GiftCard, Delivery, ShippingAddress, AccountAcquisition, \ + SubscriptionAddOn, Transaction, MeasuredUnit, Usage, GiftCard, Delivery, ShippingAddress, ShippingMethod, AccountAcquisition, \ Purchase, Invoice, InvoiceCollection, CreditPayment, CustomField, ExportDate, ExportDateFile, DunningCampaign, \ - DunningCycle, InvoiceTemplate, PlanRampInterval, SubRampInterval, ExternalSubscription, ExternalProduct, \ + DunningCycle, GeneralLedgerAccount, InvoiceTemplate, PerformanceObligation, PlanRampInterval, SubRampInterval, ExternalSubscription, ExternalProduct, \ ExternalProductReference, ExternalPaymentPhase, CustomFieldDefinition, ExternalInvoice, ExternalCharge, ExternalAccount, \ GatewayAttributes, BusinessEntity from recurly import Money, NotFoundError, ValidationError, BadRequestError, PageError @@ -362,6 +362,63 @@ def create_purchase(): self.assertIsInstance(collection, InvoiceCollection) self.assertIsInstance(collection.charge_invoice, Invoice) + def test_purchase_with_revrec(self): + account_code = 'test%s' % self.test_id + def create_purchase(): + return Purchase( + account = Account( + account_code = account_code, + ), + adjustments = [ + recurly.Adjustment( + currency = 'USD', + unit_amount_in_cents=500, + liability_gl_account_id='t5ejtge1xw0x', + revenue_gl_account_id='t5ejtgf1vxh1', + performance_obligation_id='5' + ) + ] + ) + + with self.mock_request('purchase/invoiced-with-revrec.xml'): + collection = create_purchase().invoice() + adjustment = collection.charge_invoice.line_items[0] + + self.assertIsInstance(collection, InvoiceCollection) + self.assertIsInstance(collection.charge_invoice, Invoice) + self.assertEqual(adjustment.liability_gl_account_code, 'firstliab') + self.assertEqual(adjustment.revenue_gl_account_code, 'firstrev') + self.assertEqual(adjustment.performance_obligation_id, '5') + with self.mock_request('purchase/previewed-with-revrec.xml'): + collection = create_purchase().preview() + adjustment = collection.charge_invoice.line_items[0] + + self.assertIsInstance(collection, InvoiceCollection) + self.assertIsInstance(collection.charge_invoice, Invoice) + self.assertEqual(adjustment.liability_gl_account_code, 'firstliab') + self.assertEqual(adjustment.revenue_gl_account_code, 'firstrev') + self.assertEqual(adjustment.performance_obligation_id, '5') + with self.mock_request('purchase/authorized-with-revrec.xml'): + collection = create_purchase().authorize() + adjustment = collection.charge_invoice.line_items[0] + + self.assertIsInstance(collection, InvoiceCollection) + self.assertIsInstance(collection.charge_invoice, Invoice) + self.assertEqual(adjustment.liability_gl_account_code, 'firstliab') + self.assertEqual(adjustment.revenue_gl_account_code, 'firstrev') + self.assertEqual(adjustment.performance_obligation_id, '5') + with self.mock_request('purchase/pending-with-revrec.xml'): + purchase = create_purchase() + purchase.account.email = 'testmock@example.com' + collection = purchase.pending() + adjustment = collection.charge_invoice.line_items[0] + + self.assertIsInstance(collection, InvoiceCollection) + self.assertIsInstance(collection.charge_invoice, Invoice) + self.assertEqual(adjustment.liability_gl_account_code, 'firstliab') + self.assertEqual(adjustment.revenue_gl_account_code, 'firstrev') + self.assertEqual(adjustment.performance_obligation_id, '5') + def test_account(self): account_code = 'test%s' % self.test_id with self.mock_request('account/does-not-exist.xml'): @@ -839,6 +896,56 @@ def test_item_backed_add_on(self): with self.mock_request('add-on/plan-deleted.xml'): plan.delete() + def test_add_on_with_revrec(self): + plan_code = 'plan%s' % self.test_id + add_on_code = 'addonrevrec' + + plan = Plan( + plan_code=plan_code, + name='Mock Plan', + setup_fee_in_cents=Money(0), + unit_amount_in_cents=Money(1000), + ) + with self.mock_request('add-on/plan-created.xml'): + plan.save() + + add_on = AddOn( + add_on_code=add_on_code, + name='Add-On with RevRec', + liability_gl_account_id='t5ejtge1xw0x', + revenue_gl_account_id='t5ejtgf1vxh1', + performance_obligation_id='5', + unit_amount_in_cents=Money(40) + ) + + with self.mock_request('add-on/created-with-revrec.xml'): + plan.create_add_on(add_on) + + self.assertEqual(add_on.add_on_code, add_on_code) + self.assertEqual(add_on.name, 'Add-On with RevRec') + self.assertEqual(add_on.liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(add_on.revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(add_on.performance_obligation_id, '5') + + with self.mock_request('add-on/exists-with-revrec.xml'): + same_add_on = plan.get_add_on(add_on_code) + + self.assertEqual(same_add_on.add_on_code, add_on_code) + self.assertEqual(same_add_on.liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(same_add_on.revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(same_add_on.performance_obligation_id, '5') + + add_on.liability_gl_account_id = None + add_on.revenue_gl_account_id = None + add_on.performance_obligation_id = None + + with self.mock_request('add-on/updated-with-revrec.xml'): + add_on.save() + + self.assertEqual(add_on.liability_gl_account_id, None) + self.assertEqual(add_on.revenue_gl_account_id, None) + self.assertEqual(add_on.performance_obligation_id, '6') + def test_billing_info(self): logging.basicConfig(level=logging.DEBUG) # make sure it's init'ed logger = logging.getLogger('recurly.http.request') @@ -1140,6 +1247,29 @@ def test_charge(self): credits = adjustment.credit_adjustments() self.assertEqual(len(credits), 1) + """Test revrec adjustment""" + with self.mock_request('adjustment/charged-with-revrec.xml'): + charge = Adjustment( + unit_amount_in_cents=1000, + currency='USD', + description='test charge', + type='charge', + liability_gl_account_id='t5ejtge1xw0x', + revenue_gl_account_id='t5ejtgf1vxh1', + performance_obligation_id='5', + ) + account.charge(charge) + + with self.mock_request('adjustment/account-has-adjustments.xml'): + charges = account.adjustments() + + self.assertEqual(len(charges), 1) + same_charge = charges[0] + self.assertEqual(same_charge.unit_amount_in_cents, 1000) + self.assertEqual(same_charge.liability_gl_account_code, 'firstliab') + self.assertEqual(same_charge.revenue_gl_account_code, 'firstrev') + self.assertEqual(same_charge.performance_obligation_id, '5') + finally: with self.mock_request('adjustment/account-deleted.xml'): account.delete() @@ -1712,6 +1842,49 @@ def test_item(self): with self.mock_request('item/deleted.xml'): item.delete() + def test_item_with_revrec(self): + item_code = 'item%s' % self.test_id + with self.mock_request('item/does-not-exist.xml'): + self.assertRaises(NotFoundError, Item.get, item_code) + + item = Item( + item_code=item_code, + name='Mock Item', + description='An item of the mocked variety', + liability_gl_account_id='t5ejtge1xw0x', + revenue_gl_account_id='t5ejtgf1vxh1', + performance_obligation_id='5' + ) + + with self.mock_request('item/created-with-revrec.xml'): + item.save() + + self.assertEqual(item.item_code, item_code) + self.assertEqual(item.liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(item.revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(item.performance_obligation_id, '5') + + with self.mock_request('item/exists-with-revrec.xml'): + same_item = Item.get(item_code) + + self.assertEqual(same_item.item_code, item_code) + self.assertEqual(same_item.liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(same_item.revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(same_item.performance_obligation_id, '5') + + item.description = 'A mocked description' + item.liability_gl_account_id = None + item.revenue_gl_account_id = None + item.performance_obligation_id = None + + with self.mock_request('item/updated-with-revrec.xml'): + item.save() + + self.assertEqual(item.description, 'A mocked description') + self.assertEqual(item.liability_gl_account_id, None) + self.assertEqual(item.revenue_gl_account_id, None) + self.assertEqual(item.performance_obligation_id, '6') + def test_custom_field_definition(self): """Test custom field definitions list""" with self.mock_request('custom_field_definitions/list.xml'): @@ -1841,6 +2014,67 @@ def test_plan_with_ramps(self): with self.mock_request('plan/updated_with_ramps.xml'): plan.save() + def test_plan_with_revrec(self): + plan_code = 'plan%s' % self.test_id + with self.mock_request('plan/does-not-exist.xml'): + self.assertRaises(NotFoundError, Plan.get, plan_code) + + plan = Plan( + name='RevRec Plan', + plan_code=plan_code, + setup_fee_in_cents=Money(200), + unit_amount_in_cents=Money(1000), + liability_gl_account_id='t5ejtge1xw0x', + revenue_gl_account_id='t5ejtgf1vxh1', + performance_obligation_id='5', + setup_fee_liability_gl_account_id='t5ejtge1xw0x', + setup_fee_revenue_gl_account_id='t5ejtgf1vxh1', + setup_fee_performance_obligation_id='5' + ) + + with self.mock_request('plan/created-with-revrec.xml'): + plan.save() + + self.assertEqual(plan.plan_code, plan_code) + self.assertEqual(plan.name, 'RevRec Plan') + self.assertEqual(plan.liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(plan.revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(plan.performance_obligation_id, '5') + self.assertEqual(plan.setup_fee_liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(plan.setup_fee_revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(plan.setup_fee_performance_obligation_id, '5') + + with self.mock_request('plan/exists_with_revrec.xml'): + same_plan = Plan.get(plan_code) + + self.assertEqual(plan.plan_code, plan_code) + self.assertEqual(plan.name, 'RevRec Plan') + self.assertEqual(plan.liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(plan.revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(plan.performance_obligation_id, '5') + self.assertEqual(plan.setup_fee_liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(plan.setup_fee_revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(plan.setup_fee_performance_obligation_id, '5') + + plan.liability_gl_account_id = None + plan.revenue_gl_account_id = None + plan.performance_obligation_id = None + plan.setup_fee_liability_gl_account_id = None + plan.setup_fee_revenue_gl_account_id = None + plan.setup_fee_performance_obligation_id = None + + with self.mock_request('plan/updated_with_revrec.xml'): + plan.save() + + self.assertEqual(plan.plan_code, plan_code) + self.assertEqual(plan.name, 'RevRec Plan') + self.assertEqual(plan.liability_gl_account_id, None) + self.assertEqual(plan.revenue_gl_account_id, None) + self.assertEqual(plan.performance_obligation_id, '6') + self.assertEqual(plan.setup_fee_liability_gl_account_id, None) + self.assertEqual(plan.setup_fee_revenue_gl_account_id, None) + self.assertEqual(plan.setup_fee_performance_obligation_id, '4') + def test_preview_subscription_change(self): with self.mock_request('subscription/show.xml'): sub = Subscription.get('123456789012345678901234567890ab') @@ -2840,6 +3074,33 @@ def _build_gift_card(self): gift_card.gifter_account = account return gift_card + def test_get_gift_card(self): + with self.mock_request('gift_cards/get.xml'): + gift_card = GiftCard.get(3880289408739841209) + + self.assertEqual(gift_card.id, 3880289408739841209) + self.assertEqual(gift_card.redemption_code, 'ASDR63PM4JUTXW9I') + self.assertEqual(gift_card.product_code, 'test_gift_card') + self.assertEqual(gift_card.unit_amount_in_cents, 1000) + self.assertEqual(gift_card.currency, 'USD') + self.assertEqual(gift_card.delivery.method, 'email') + self.assertEqual(gift_card.delivery.email_address, 'sally@example.com') + self.assertEqual(gift_card.delivery.first_name, 'Sally') + self.assertEqual(gift_card.delivery.last_name, 'Smith') + self.assertEqual(gift_card.delivery.gifter_name, 'John') + self.assertEqual(gift_card.delivery.personal_message, 'Congrats!') + self.assertEqual(gift_card.liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(gift_card.revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(gift_card.performance_obligation_id, '4') + + def test_list_gift_cards(self): + with self.mock_request('gift_cards/list.xml'): + gift_cards = GiftCard.all() + + self.assertEqual(len(gift_cards), 2) + self.assertIsInstance(gift_cards[0], GiftCard) + self.assertIsInstance(gift_cards[1], GiftCard) + def test_gift_cards_purchase(self): gift_card = self._build_gift_card() @@ -3210,6 +3471,8 @@ def test_get_business_entity(self): 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)) + self.assertEqual(entity.default_liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(entity.default_revenue_gl_account_id, 't5ejtgf1vxh1') def test_list_business_entities(self): with self.mock_request('business_entity/list.xml'): @@ -3393,6 +3656,86 @@ def test_account_external_accounts(self): with self.mock_request('account/created-with-external-accounts.xml'): account.save() + def test_list_general_ledger_accounts(self): + with self.mock_request('general_ledger_accounts/list.xml'): + general_ledger_accounts = GeneralLedgerAccount.all() + + self.assertEqual(len(general_ledger_accounts), 2) + + def test_list_filtered_general_ledger_accounts(self): + with self.mock_request('general_ledger_accounts/list_filtered.xml'): + general_ledger_accounts = GeneralLedgerAccount.all(account_type='revenue') + + self.assertEqual(len(general_ledger_accounts), 1) + self.assertEqual(general_ledger_accounts[0].account_type, 'revenue') + + def test_get_general_ledger_accounts(self): + with self.mock_request('general_ledger_accounts/get.xml'): + general_ledger_account = GeneralLedgerAccount.get('u90r5deeaxix') + + self.assertEqual(general_ledger_account.id, 'u90r5deeaxix') + self.assertEqual(general_ledger_account.code, 'code1') + self.assertEqual(general_ledger_account.account_type, 'revenue') + self.assertEqual(general_ledger_account.description, 'Some Description') + + def test_create_general_ledger_account(self): + general_ledger_account = GeneralLedgerAccount( + code='code2', + account_type='liability', + description='Liability Description' + ) + with self.mock_request('general_ledger_accounts/created.xml'): + general_ledger_account.save() + + self.assertEquals(general_ledger_account.code, 'code2') + self.assertEquals(general_ledger_account.account_type, 'liability') + self.assertEquals(general_ledger_account.description, 'Liability Description') + + def test_update_general_ledger_account(self): + with self.mock_request('general_ledger_accounts/get.xml'): + general_ledger_account = GeneralLedgerAccount.get('u90r5deeaxix') + + with self.mock_request('general_ledger_accounts/updated.xml'): + general_ledger_account.code = 'code2' + general_ledger_account.description = 'Updated Description' + general_ledger_account.save() + + self.assertEquals(general_ledger_account.code, 'code2') + self.assertEquals(general_ledger_account.description, 'Updated Description') + + def test_list_performance_obligations(self): + with self.mock_request('performance_obligations/list.xml'): + performance_obligations = PerformanceObligation.all() + + self.assertEqual(len(performance_obligations), 6) + + def test_get_performance_obligation(self): + with self.mock_request('performance_obligations/get.xml'): + performance_obligation = PerformanceObligation.get(6) + + self.assertEqual(performance_obligation.id, '6') + self.assertEqual(performance_obligation.name, 'Over Time (Daily)') + + def test_get_shipping_method(self): + with self.mock_request('shipping-method/get.xml'): + shipping_method = ShippingMethod.get('shipping2') + + self.assertEqual(shipping_method.code, 'shipping2') + self.assertEqual(shipping_method.name, 'shipping 2') + self.assertEqual(shipping_method.accounting_code, 'ship') + self.assertEqual(shipping_method.tax_code, 'FR') + self.assertEqual(shipping_method.liability_gl_account_id, 't5ejtge1xw0x') + self.assertEqual(shipping_method.revenue_gl_account_id, 't5ejtgf1vxh1') + self.assertEqual(shipping_method.performance_obligation_id, '6') + + def test_list_shipping_methods(self): + with self.mock_request('shipping-method/list.xml'): + shipping_methods = ShippingMethod.all() + + self.assertEqual(len(shipping_methods), 2) + self.assertIsInstance(shipping_methods[0], ShippingMethod) + self.assertIsInstance(shipping_methods[1], ShippingMethod) + if __name__ == '__main__': import unittest unittest.main()