mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
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:
@@ -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()
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user