Expected behavior
My guess is that since the recurring key on the schedule is required, you should prob do a num_left: Math.max(1, subscriptionDefinition.billingCyclesLeft), on the recurring key. But it makes sense to examine that approach for new edge cases.
Environment
NodeJS version
Vendure version: [e.g. 1.7.1]
Plugin version 1.8.1
Database [e.g. MySQL]
Any other version numbers from the environment you're using
Good catch. I think actually it should always round up with Math.ceil:
next_run_date has to be in the future, so earliest tomorrow
If we start tomorrow, nr of cycles should be 1, because: We create the subscription now, there is 1 cycle left, tomorrow is next run, and the there are no cycles left.
Which plugin/repository is the issue about? accept-blue stripe-subscriptions (potentially)
Describe the bug Accept Blue treats
num_left: 0
on subscriptions as "ongoing". The calculation forgetNrOfBillingCyclesLeft
at https://github.com/Pinelab-studio/pinelab-vendure-plugins/blob/acca18999ab1acd4224e92595c00f034f7fe4f82/packages/vendure-plugin-accept-blue/src/api/accept-blue-service.ts#L119C17-L119C41 calculates the number of cycles usingMath.floor
. That could lead to a result of 0 if the endDate is sufficiently close. This in turn would lead to an "endless scenario" when it should likely be "once only" scenario.To Reproduce Steps to reproduce the behavior:
It's just something I noticed reviewing the code
Expected behavior My guess is that since the
recurring
key on the schedule is required, you should prob do anum_left: Math.max(1, subscriptionDefinition.billingCyclesLeft),
on the recurring key. But it makes sense to examine that approach for new edge cases.Environment