Skip to content

Commit

Permalink
change alignment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reshmabidikar committed Jul 3, 2024
1 parent 789e0af commit 22109ba
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions killbill-integration-tests/core/test_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,102 @@ def test_create_alignment
add_days_and_check_invoice_item(14, 7, 'BasicAOStartOfSubscription-monthly', '2013-10-14', '2013-11-14', 150)
end

def test_change_alignment_start_of_bundle
bp, ao = setup_change_alignment_test

# Change plan with a start of bundle change alignment: the trial will still end on 2013-08-31
change_ao_entitlement(ao, 3, 'BasicAOStartOfBundle', 'MONTHLY', '2013-08-05', 0.0, '2013-08-15')
check_subscription_events(bp,
ao,
[{ type: 'START_ENTITLEMENT', date: '2013-08-01' },
{ type: 'START_BILLING', date: '2013-08-01' },
{ type: 'PHASE', date: '2013-08-31' }],
[{ type: 'START_ENTITLEMENT', date: '2013-08-05' },
{ type: 'START_BILLING', date: '2013-08-05' },
{ type: 'CHANGE', date: '2013-08-15' },
{ type: 'PHASE', date: '2013-08-31' }])

# Move the clock to 2013-08-31 (30 days trial)
add_days(16)

# Both subscriptions are aligned on the same invoice (ACCOUNT billing alignment)
invoice = check_invoice_balance(4, '2013-08-31', 1100.0)
check_invoice_item(invoice.items[0], invoice.invoice_id, 100.0, 'USD', 'RECURRING', 'BasicAOStartOfBundle-monthly', 'BasicAOStartOfBundle-monthly-evergreen', '2013-08-31', '2013-09-30')
check_invoice_item(invoice.items[1], invoice.invoice_id, 1000.0, 'USD', 'RECURRING', 'basic-monthly', 'basic-monthly-evergreen', '2013-08-31', '2013-09-30')
end

def test_change_alignment_start_of_subscription
bp, ao = setup_change_alignment_test

# Change plan with a start of subscription change alignment: the trial will now end on 2013-09-04
change_ao_entitlement(ao, 3, 'BasicAOStartOfSubscription', 'MONTHLY', '2013-08-05', 0.0, '2013-08-15')
check_subscription_events(bp,
ao,
[{ type: 'START_ENTITLEMENT', date: '2013-08-01' },
{ type: 'START_BILLING', date: '2013-08-01' },
{ type: 'PHASE', date: '2013-08-31' }],
[{ type: 'START_ENTITLEMENT', date: '2013-08-05' },
{ type: 'START_BILLING', date: '2013-08-05' },
{ type: 'CHANGE', date: '2013-08-15' },
{ type: 'PHASE', date: '2013-09-04' }])

# Move the clock to 2013-08-31 (30 days trial)
add_days(16)

invoice = check_invoice_balance(4, '2013-08-31', 1000.0)
check_invoice_item(invoice.items[0], invoice.invoice_id, 1000.0, 'USD', 'RECURRING', 'basic-monthly', 'basic-monthly-evergreen', '2013-08-31', '2013-09-30')

# Move the clock to 2013-09-04
add_days(4)

# Pro-rated invoice for the add-on (ACCOUNT billing alignment)
invoice = check_invoice_balance(5, '2013-09-04', 125.81)
check_invoice_item(invoice.items[0], invoice.invoice_id, 125.81, 'USD', 'RECURRING', 'BasicAOStartOfSubscription-monthly', 'BasicAOStartOfSubscription-monthly-evergreen', '2013-09-04', '2013-09-30')

# Move the clock to 2013-09-30
add_days(26)

invoice = check_invoice_balance(6, '2013-09-30', 1150.0)
check_invoice_item(invoice.items[0], invoice.invoice_id, 150.0, 'USD', 'RECURRING', 'BasicAOStartOfSubscription-monthly', 'BasicAOStartOfSubscription-monthly-evergreen', '2013-09-30', '2013-10-31')
check_invoice_item(invoice.items[1], invoice.invoice_id, 1000.0, 'USD', 'RECURRING', 'basic-monthly', 'basic-monthly-evergreen', '2013-09-30', '2013-10-31')
end

def test_change_alignment_change_of_plan
bp, ao = setup_change_alignment_test

# Change plan with a start of change of plan change alignment: the trial will now end on 2013-09-14
change_ao_entitlement(ao, 3, 'BasicAOChangeOfPlan', 'MONTHLY', '2013-08-05', 0.0, '2013-08-15')
check_subscription_events(bp,
ao,
[{ type: 'START_ENTITLEMENT', date: '2013-08-01' },
{ type: 'START_BILLING', date: '2013-08-01' },
{ type: 'PHASE', date: '2013-08-31' }],
[{ type: 'START_ENTITLEMENT', date: '2013-08-05' },
{ type: 'START_BILLING', date: '2013-08-05' },
{ type: 'CHANGE', date: '2013-08-15' },
{ type: 'PHASE', date: '2013-09-14' }])

# Move the clock to 2013-08-31 (30 days trial)
add_days(16)

invoice = check_invoice_balance(4, '2013-08-31', 1000.0)
check_invoice_item(invoice.items[0], invoice.invoice_id, 1000.0, 'USD', 'RECURRING', 'basic-monthly', 'basic-monthly-evergreen', '2013-08-31', '2013-09-30')

# Move the clock to 2013-09-14
add_days(14)

# Pro-rated invoice for the add-on (ACCOUNT billing alignment)
invoice = check_invoice_balance(5, '2013-09-14', 103.23)
check_invoice_item(invoice.items[0], invoice.invoice_id, 103.23, 'USD', 'RECURRING', 'BasicAOChangeOfPlan-monthly', 'BasicAOChangeOfPlan-monthly-evergreen', '2013-09-14', '2013-09-30')

# Move the clock to 2013-09-30
add_days(16)

invoice = check_invoice_balance(6, '2013-09-30', 1200.0)
check_invoice_item(invoice.items[0], invoice.invoice_id, 200.0, 'USD', 'RECURRING', 'BasicAOChangeOfPlan-monthly', 'BasicAOChangeOfPlan-monthly-evergreen', '2013-09-30', '2013-10-31')
check_invoice_item(invoice.items[1], invoice.invoice_id, 1000.0, 'USD', 'RECURRING', 'basic-monthly', 'basic-monthly-evergreen', '2013-09-30', '2013-10-31')
end

def test_create_simple_plan
upload_catalog('Catalog-v1.xml', false, @user, @options)

Expand Down

0 comments on commit 22109ba

Please sign in to comment.