Subscription not generating invoice


I create Subscription document via code when user register at my site via a web form.
The Subscription Plan has a 1 month trial period so the first status is Trialling.

Here is the screen shot for a user registering on Dec 23, 2020.

But until now (Jan 25, 2021) the Current Invoice End Date is not changing.
The status still Trialling.
And there is no invoice generated.
Here is the code I use to make Subscription docs:

	subs_doc = frappe.new_doc('Subscription')
	subs_doc.start =
	subs_doc.trial_period_start = subs_doc.start
	subs_doc.trial_period_end = frappe.utils.add_months(subs_doc.trial_period_start, 1)

Is there any mistake I made?
Do I need to ?

Please your input.
Thank you very much.

I haven’t got the answer for my problem above.
From the erpnext hooks I found the trigger:

So I see the codes in erpnext/erpnext/accounts/doctype/subscription/ to try to identify the process of changing the Trial period into Active.

But I think I don’t see any function changing the status from Trialling to Active.
And the method generate_invoice() is triggered for 3 reasons:

  • if status is Active: process_for_active()
  • if status is Past Due Date: process_for_past_due_date()
  • if status is not Cancelled: cancel_subscription()

My guess the status is changed when the Current Invoice End Date hit the Past Due Date, but there is no direct connection between status Trialling and running the process of generating new invoice.

Then I found in def process (self) (which called in process_all() from hooks):

  • if status == 'Active' which is not applied here.
  • if status in ['Past Due Date', 'Unpaid'] which trigger the

So I guess this last method should be the trigger. But the status are not including Trialing.

Is this by design (and all my analysis above is wrong)?
Or does the status Trialling is excluded accidentally?

Sorry for the long post but I hope someone can help me on tis issue.
Thank you