feat(subscription): add refunded status, billing heatmap and billing UX (#55617)

* fix(subscription): bill on creation and keep status in sync with invoices

* feat(subscription): add refunded status, billing heatmap and billing UX
This commit is contained in:
Jatin3128
2026-06-09 16:43:24 +05:30
committed by GitHub
parent ca77145522
commit 4c3aa9b4f3
9 changed files with 714 additions and 190 deletions

View File

@@ -0,0 +1,17 @@
import frappe
VALUE_MAP = {
"End of the current subscription period": "Postpaid (bill at period end)",
"Beginning of the current subscription period": "Prepaid (bill at period start)",
"Days before the current subscription period": "Bill N days before period start",
}
def execute():
subscription = frappe.qb.DocType("Subscription")
for old_value, new_value in VALUE_MAP.items():
(
frappe.qb.update(subscription)
.set(subscription.generate_invoice_at, new_value)
.where(subscription.generate_invoice_at == old_value)
).run()

View File

@@ -0,0 +1,26 @@
import frappe
def execute():
"""Move billing-period data to the renamed fields.
`current_invoice_start/end` used to hold the open (next) billing period and now
holds the actual current invoice period, while the open period moved to
`next_billing_period_start/end`.
"""
columns = set(frappe.db.get_table_columns("Subscription"))
subscription = frappe.qb.DocType("Subscription")
if {"next_billing_period_start", "next_billing_period_end"} <= columns:
(
frappe.qb.update(subscription)
.set(subscription.next_billing_period_start, subscription.current_invoice_start)
.set(subscription.next_billing_period_end, subscription.current_invoice_end)
).run()
if {"current_invoice_from_date", "current_invoice_to_date"} <= columns:
(
frappe.qb.update(subscription)
.set(subscription.current_invoice_start, subscription.current_invoice_from_date)
.set(subscription.current_invoice_end, subscription.current_invoice_to_date)
).run()