Skip to content

Commit

Permalink
Merge pull request #594 from recurly/decimal_usage
Browse files Browse the repository at this point in the history
Add decimal quantity fields to Adjustment and Usage
  • Loading branch information
icas-recurly authored Oct 20, 2022
2 parents 1baeae5 + bdb2345 commit 8d511ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions recurly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,9 @@ class Adjustment(Resource):
'item_code',
'external_sku',
'quantity',
'quantity_decimal',
'quantity_remaining',
'quantity_decimal_remaining',
'unit_amount_in_cents',
'discount_in_cents',
'tax_in_cents',
Expand Down Expand Up @@ -1093,6 +1096,10 @@ def _refund_line_items_xml(self, line_items, refund_options):
item['adjustment'].uuid))
adj_elem.append(Resource.element_for_value('quantity',
item['quantity']))

if 'quantity_decimal' in item:
adj_elem.append(Resource.element_for_value('quantity_decimal', item['quantity_decimal']))

adj_elem.append(Resource.element_for_value('prorate', item['prorate']))
line_items_elem.append(adj_elem)

Expand Down Expand Up @@ -1830,6 +1837,7 @@ class Usage(Resource):
attributes = (
'measured_unit',
'amount',
'amount_decimal',
'merchant_tag',
'recording_timestamp',
'usage_timestamp',
Expand Down
10 changes: 5 additions & 5 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def create_purchase():
quantity=2),
]
)

with self.mock_request('purchase/invoiced.xml'):
collection = create_purchase().invoice()
self.assertIsInstance(collection, InvoiceCollection)
Expand Down Expand Up @@ -192,7 +192,7 @@ def create_purchase():
recurly.Subscription(plan_code = 'ramp-plan')
],
)

with self.mock_request('purchase-with-ramp/invoiced.xml'):
collection = create_purchase().invoice()
self.assertIsInstance(collection, InvoiceCollection)
Expand Down Expand Up @@ -221,7 +221,7 @@ def create_purchase():
def test_purchase_with_ramp_intervals(self):
account_code = 'test%s' % self.test_id
def create_purchase():

subscription = recurly.Subscription(
plan_code = 'ramp-plan',
ramp_intervals = [
Expand Down Expand Up @@ -269,7 +269,7 @@ def create_purchase():
subscription
],
)

with self.mock_request('purchase-with-ramp-intervals/invoiced.xml'):
collection = create_purchase().invoice()
self.assertIsInstance(collection, InvoiceCollection)
Expand Down Expand Up @@ -1619,7 +1619,7 @@ def test_plan_with_ramps(self):
plan_code = 'plan%s' % self.test_id
with self.mock_request('plan/does-not-exist.xml'):
self.assertRaises(NotFoundError, Plan.get, plan_code)

ramp_interval_1 = PlanRampInterval(
unit_amount_in_cents=Money(USD=2000),
starting_billing_cycle=1,
Expand Down

0 comments on commit 8d511ae

Please sign in to comment.