Auto create initial monthly engagement from subscription

This commit is contained in:
A R R R Associates
2026-08-10 14:07:54 +05:30
parent 29a0de1f07
commit 7e38527919
+29
View File
@@ -514,6 +514,35 @@ def subscription_bulk_submit(
if plan_effective_from and plan_effective_to and plan_effective_to < plan_effective_from: if plan_effective_from and plan_effective_to and plan_effective_to < plan_effective_from:
return RedirectResponse("/services/subscriptions/bulk?error=period", 303) return RedirectResponse("/services/subscriptions/bulk?error=period", 303)
if (
generation_mode == "subscription_only"
and auto_generate_periods is not None
and recurrence_type == "monthly"
and plan_effective_from is not None
):
if plan_effective_from.month == 1:
initial_monthly_period = f"{plan_effective_from.year - 1:04d}-12"
else:
initial_monthly_period = (
f"{plan_effective_from.year:04d}-{plan_effective_from.month - 1:02d}"
)
try:
requested_periods = [normalize_period_label(
initial_monthly_period,
financial_year=selected_financial_year,
recurrence_type=recurrence_type,
)]
except ValueError:
return RedirectResponse("/services/subscriptions/bulk?error=period", 303)
locked = redirect_if_financial_year_locked(
db,
tenant_id=tenant_id,
year_code=selected_financial_year,
redirect_url="/services/subscriptions/bulk?error=financial_year",
)
if locked:
return locked
for token in selected_tokens: for token in selected_tokens:
try: try:
client, scope_type, scope_key, business_unit_id, client_branch_id, registration_id = resolve_scope_target( client, scope_type, scope_key, business_unit_id, client_branch_id, registration_id = resolve_scope_target(