Skip to content

Commit

Permalink
add revrec to purchases and adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
wsethbrown committed Mar 1, 2024
1 parent cf497d6 commit 7d29779
Show file tree
Hide file tree
Showing 8 changed files with 566 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/recurly/adjustment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Adjustment < Resource
avalara_transaction_type
avalara_service_type
refundable_total_in_cents
]
] + RevRec::ALL_ATTRIBUTES
alias to_param uuid

# @return ["charge", "credit", nil] The type of adjustment.
Expand Down
2 changes: 1 addition & 1 deletion lib/recurly/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def invoice_number_with_prefix
refundable_total_in_cents
used_tax_service
business_entity_id
)
) + RevRec::PRODUCT_ATTRIBUTES
alias to_param invoice_number_with_prefix

def self.to_xml(attrs)
Expand Down
39 changes: 39 additions & 0 deletions spec/fixtures/adjustments/create-201-with-revrec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
HTTP/1.1 201 Created
Content-Type: application/xml; charset=utf-8
Location: https://api.recurly.com/v2/adjustments/67360781108ceacd23dee747b7b1f5af

<adjustment href="https://api.recurly.com/v2/adjustments/67360781108ceacd23dee747b7b1f5af">
<account href="https://api.recurly.com/v2/accounts/7747ed3b-1771-4a03-b32a-503e9d65d3ad"/>
<bill_for_account href="https://api.recurly.com/v2/accounts/account1"/>
<item_code nil="nil"/>
<external_sku nil="nil"/>
<credit_adjustments href="https://api.recurly.com/v2/adjustments/67360781108ceacd23dee747b7b1f5af/credit_adjustments"/>
<refundable_total_in_cents type="integer">0</refundable_total_in_cents>
<uuid>67360781108ceacd23dee747b7b1f5af</uuid>
<state>pending</state>
<description nil="nil"/>
<accounting_code nil="nil"/>
<product_code nil="nil"/>
<origin>debit</origin>
<unit_amount_in_cents type="integer">5000</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">5000</total_in_cents>
<currency>USD</currency>
<proration_rate nil="nil"/>
<start_date type="datetime">2023-01-18T23:34:52Z</start_date>
<end_date nil="nil"/>
<created_at type="datetime">2023-01-18T23:34:52Z</created_at>
<updated_at type="datetime">2023-01-18T23:34:52Z</updated_at>
<revenue_schedule_type>at_invoice</revenue_schedule_type>
<liability_gl_account_code>liability_gla</liability_gl_account_code>
<revenue_gl_account_code>revenue_gla</revenue_gl_account_code>
<performance_obligation_id>5</performance_obligation_id>
<custom_fields type="array">
<custom_field>
<name>field1</name>
<value>priceless</value>
</custom_field>
</custom_fields>
</adjustment>
64 changes: 64 additions & 0 deletions spec/fixtures/adjustments/show-200-with-revrec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<adjustment href="https://api.recurly.com/v2/adjustments/abcdef1234567890" type="charge">
<account href="https://api.recurly.com/v2/accounts/account"/>
<bill_for_account href="https://api.recurly.com/v2/accounts/abcdef1234567890"/>
<invoice href="https://api.recurly.com/v2/invoices/created-invoice"/>
<subscription href="https://api.recurly.com/v2/subscriptions/abcdef1234567890"/>
<credit_adjustments href="https://api.recurly.com/v2/adjustments/abcdef1234567890/credit_adjustments"/>
<item href="https://api.recurly.com/v2/items/plastic_gloves"/>
<item_code>plastic_gloves</item_code>
<external_sku>plastic_gloves</external_sku>
<uuid>abcdef1234567890</uuid>
<state>pending</state>
<accounting_code nil="nil"></accounting_code>
<origin>plan</origin>
<description>$12 Annual Subscription</description>
<unit_amount_in_cents type="integer">1200</unit_amount_in_cents>
<quantity type="integer">1</quantity>
<quantity_decimal>1.2</quantity_decimal>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">5000</tax_in_cents>
<tax_type>usst</tax_type>
<tax_region>CA</tax_region>
<tax_rate type="float">0.0875</tax_rate>
<total_in_cents type="integer">1200</total_in_cents>
<currency>USD</currency>
<product_code>basic</product_code>
<revenue_schedule_type>evenly</revenue_schedule_type>
<surcharge_in_cents type="integer">100</surcharge_in_cents>
<avalara_service_type type="integer">3</avalara_service_type>
<avalara_transaction_type type="integer">600</avalara_transaction_type>
<liability_gl_account_code>liability_gla</liability_gl_account_code>
<revenue_gl_account_code>revenue_gla</revenue_gl_account_code>
<performance_obligation_id>5</performance_obligation_id>
<tax_details type="array">
<tax_detail>
<name>california</name>
<type>state</type>
<tax_rate type="float">0.065</tax_rate>
<tax_in_cents type="integer">3000</tax_in_cents>
<level>state</level>
<billable type="boolean">true</billable>
</tax_detail>
<tax_detail>
<name>san francisco</name>
<type>county</type>
<tax_rate type="float">0.02</tax_rate>
<tax_in_cents type="integer">2000</tax_in_cents>
</tax_detail>
</tax_details>
<proration_rate type="float">0.5</proration_rate>
<original_adjustment_uuid>abcdefg1234567</original_adjustment_uuid>
<start_date type="datetime">2011-04-30T07:00:00Z</start_date>
<end_date type="datetime">2011-04-30T07:00:00Z</end_date>
<created_at type="datetime">2011-08-31T03:30:00Z</created_at>
<custom_fields>
<custom_field>
<name>field1</name>
<value>priceless</value>
</custom_field>
</custom_fields>
</adjustment>
228 changes: 228 additions & 0 deletions spec/fixtures/purchases/invoice-201-with-revrec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
HTTP/1.1 201 Created
Content-Type: application/xml; charset=utf-8
Location: https://api.recurly.com/v2/invoices/3517

<?xml version="1.0" encoding="UTF-8"?>
<invoice_collection>
<charge_invoice href="https://api.recurly.com/v2/invoices/5333">
<account href="https://api.recurly.com/v2/accounts/7747ed3b-1771-4a03-b32a-503e9d65d3ad"/>
<address>
<address1>400 Alabama St</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94110</zip>
<country>US</country>
<phone nil="nil"></phone>
</address>
<subscriptions href="https://api.recurly.com/v2/invoices/5333/subscriptions"/>
<uuid>43d762734303e29025a8b64ef7953606</uuid>
<state>paid</state>
<invoice_number_prefix></invoice_number_prefix>
<invoice_number type="integer">5333</invoice_number>
<vat_number nil="nil"></vat_number>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">1013</total_in_cents>
<currency>USD</currency>
<created_at type="datetime">2018-03-27T17:52:42Z</created_at>
<updated_at type="datetime">2018-03-27T17:52:42Z</updated_at>
<attempt_next_collection_at nil="nil"></attempt_next_collection_at>
<closed_at type="datetime">2018-03-27T17:52:42Z</closed_at>
<customer_notes>Some notes for the customer.</customer_notes>
<recovery_reason nil="nil"></recovery_reason>
<subtotal_before_discount_in_cents type="integer">1013</subtotal_before_discount_in_cents>
<subtotal_in_cents type="integer">1013</subtotal_in_cents>
<discount_in_cents type="integer">0</discount_in_cents>
<due_on type="datetime">2018-03-27T17:52:42Z</due_on>
<balance_in_cents type="integer">0</balance_in_cents>
<type>charge</type>
<origin>purchase</origin>
<credit_invoices href="https://api.recurly.com/v2/invoices/5333/credit_invoices"/>
<refundable_total_in_cents type="integer">1013</refundable_total_in_cents>
<credit_payments type="array">
</credit_payments>
<net_terms type="integer">0</net_terms>
<collection_method>automatic</collection_method>
<po_number nil="nil"></po_number>
<terms_and_conditions>Our company terms and conditions.</terms_and_conditions>
<line_items type="array">
<adjustment href="https://api.recurly.com/v2/adjustments/43d762733e47a12cf3dd7c47d9aed1c4" type="charge">
<account href="https://api.recurly.com/v2/accounts/7747ed3b-1771-4a03-b32a-503e9d65d3ad"/>
<invoice href="https://api.recurly.com/v2/invoices/5333"/>
<subscription href="https://api.recurly.com/v2/subscriptions/43d76272ff13d1a1e6d5604528929f27"/>
<credit_adjustments href="https://api.recurly.com/v2/adjustments/43d762733e47a12cf3dd7c47d9aed1c4/credit_adjustments"/>
<refundable_total_in_cents type="integer">7</refundable_total_in_cents>
<uuid>43d762733e47a12cf3dd7c47d9aed1c4</uuid>
<state>invoiced</state>
<description>Setup fee: muWlYSa6U3</description>
<accounting_code nil="nil"></accounting_code>
<product_code>muwlysa6u3</product_code>
<origin>setup_fee</origin>
<unit_amount_in_cents type="integer">7</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">7</total_in_cents>
<currency>USD</currency>
<proration_rate nil="nil"></proration_rate>
<taxable type="boolean">false</taxable>
<tax_exempt type="boolean">false</tax_exempt>
<tax_code nil="nil"></tax_code>
<start_date type="datetime">2018-03-27T17:52:42Z</start_date>
<end_date nil="nil"></end_date>
<created_at type="datetime">2018-03-27T17:52:42Z</created_at>
<updated_at type="datetime">2018-03-27T17:52:42Z</updated_at>
<revenue_schedule_type>evenly</revenue_schedule_type>
<liability_gl_account_code>liability_gla</liability_gl_account_code>
<revenue_gl_account_code>revenue_gla</revenue_gl_account_code>
<performance_obligation_id>5</performance_obligation_id>
<shipping_address>
<address1>400 Alabama St</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94110</zip>
<country>US</country>
<phone nil="nil"></phone>
</shipping_address>
</adjustment>
<adjustment href="https://api.recurly.com/v2/adjustments/43d76273412274c8c041354ce7a27ee5" type="charge">
<account href="https://api.recurly.com/v2/accounts/7747ed3b-1771-4a03-b32a-503e9d65d3ad"/>
<invoice href="https://api.recurly.com/v2/invoices/5333"/>
<subscription href="https://api.recurly.com/v2/subscriptions/43d76272ff13d1a1e6d5604528929f27"/>
<credit_adjustments href="https://api.recurly.com/v2/adjustments/43d76273412274c8c041354ce7a27ee5/credit_adjustments"/>
<refundable_total_in_cents type="integer">6</refundable_total_in_cents>
<uuid>43d76273412274c8c041354ce7a27ee5</uuid>
<state>invoiced</state>
<description>muWlYSa6U3</description>
<accounting_code nil="nil"></accounting_code>
<product_code>muwlysa6u3</product_code>
<origin>plan</origin>
<unit_amount_in_cents type="integer">6</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">6</total_in_cents>
<currency>USD</currency>
<proration_rate nil="nil"></proration_rate>
<taxable type="boolean">false</taxable>
<tax_exempt type="boolean">false</tax_exempt>
<tax_code nil="nil"></tax_code>
<start_date type="datetime">2018-03-27T17:52:42Z</start_date>
<end_date type="datetime">2019-04-27T17:52:42Z</end_date>
<created_at type="datetime">2018-03-27T17:52:42Z</created_at>
<updated_at type="datetime">2018-03-27T17:52:42Z</updated_at>
<revenue_schedule_type>evenly</revenue_schedule_type>
<shipping_address>
<address1>400 Alabama St</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94110</zip>
<country>US</country>
<phone nil="nil"></phone>
</shipping_address>
</adjustment>
<adjustment href="https://api.recurly.com/v2/adjustments/43d76272fc2c59081d803145bbb017e4" type="charge">
<account href="https://api.recurly.com/v2/accounts/7747ed3b-1771-4a03-b32a-503e9d65d3ad"/>
<invoice href="https://api.recurly.com/v2/invoices/5333"/>
<credit_adjustments href="https://api.recurly.com/v2/adjustments/43d76272fc2c59081d803145bbb017e4/credit_adjustments"/>
<refundable_total_in_cents type="integer">1000</refundable_total_in_cents>
<uuid>43d76272fc2c59081d803145bbb017e4</uuid>
<state>invoiced</state>
<description nil="nil"></description>
<accounting_code nil="nil"></accounting_code>
<product_code>9d138ed5-7517-4984-b03d-a2116c0a714d</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>
<currency>USD</currency>
<proration_rate nil="nil"></proration_rate>
<taxable type="boolean">false</taxable>
<tax_exempt type="boolean">false</tax_exempt>
<tax_code nil="nil"></tax_code>
<start_date type="datetime">2018-03-27T17:52:42Z</start_date>
<end_date nil="nil"></end_date>
<created_at type="datetime">2018-03-27T17:52:42Z</created_at>
<updated_at type="datetime">2018-03-27T17:52:42Z</updated_at>
<revenue_schedule_type>at_invoice</revenue_schedule_type>
<shipping_address>
<address1>400 Alabama St</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94110</zip>
<country>US</country>
<phone nil="nil"></phone>
</shipping_address>
</adjustment>
</line_items>
<transactions type="array">
<transaction href="https://api.recurly.com/v2/transactions/43d762736a8c3f29413c0544ba92a44c" type="credit_card">
<account href="https://api.recurly.com/v2/accounts/7747ed3b-1771-4a03-b32a-503e9d65d3ad"/>
<invoice href="https://api.recurly.com/v2/invoices/5333"/>
<subscriptions href="https://api.recurly.com/v2/transactions/43d762736a8c3f29413c0544ba92a44c/subscriptions"/>
<uuid>43d762736a8c3f29413c0544ba92a44c</uuid>
<action>purchase</action>
<amount_in_cents type="integer">1013</amount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<currency>USD</currency>
<status>success</status>
<payment_method>credit_card</payment_method>
<reference>6871449</reference>
<source>subscription</source>
<recurring type="boolean">false</recurring>
<test type="boolean">true</test>
<voidable type="boolean">true</voidable>
<refundable type="boolean">true</refundable>
<ip_address nil="nil"></ip_address>
<gateway_type>test</gateway_type>
<origin>api</origin>
<description nil="nil"></description>
<message>Successful test transaction</message>
<approval_code nil="nil"></approval_code>
<failure_type nil="nil"></failure_type>
<gateway_error_codes nil="nil"></gateway_error_codes>
<cvv_result code="" nil="nil"></cvv_result>
<avs_result code="D">Street address and postal code match.</avs_result>
<avs_result_street nil="nil"></avs_result_street>
<avs_result_postal nil="nil"></avs_result_postal>
<created_at type="datetime">2018-03-27T17:52:42Z</created_at>
<collected_at type="datetime">2018-03-27T17:52:42Z</collected_at>
<updated_at type="datetime">2018-03-27T17:52:42Z</updated_at>
<details>
<account>
<account_code>7747ed3b-1771-4a03-b32a-503e9d65d3ad</account_code>
<first_name>Benjamin</first_name>
<last_name>Benjamin</last_name>
<company nil="nil"></company>
<email nil="nil"></email>
<billing_info type="credit_card">
<first_name>Benjamin</first_name>
<last_name>Du Monde</last_name>
<address1>400 Alabama St</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94110</zip>
<country>US</country>
<phone nil="nil"></phone>
<vat_number nil="nil"></vat_number>
<card_type>Visa</card_type>
<year type="integer">2019</year>
<month type="integer">12</month>
<first_six>411111</first_six>
<last_four>1111</last_four>
</billing_info>
</account>
</details>
</transaction>
</transactions>
<a name="refund" href="https://api.recurly.com/v2/invoices/5333/refund" method="post"/>
</charge_invoice>
<credit_invoices type="array">
</credit_invoices>
</invoice_collection>
Loading

0 comments on commit 7d29779

Please sign in to comment.