Files
schuetz3-erpnext/erpnext/patches/v13_0/update_subscription.py
Ankush Menat c07713b860 style: bulk format code with black
v13 port because otherwise backports will result in conflicts always
2022-03-29 17:29:34 +05:30

50 lines
1.1 KiB
Python

# Copyright (c) 2019, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
from six import iteritems
def execute():
frappe.reload_doc("accounts", "doctype", "subscription")
frappe.reload_doc("accounts", "doctype", "subscription_invoice")
frappe.reload_doc("accounts", "doctype", "subscription_plan")
if frappe.db.has_column("Subscription", "customer"):
frappe.db.sql(
"""
UPDATE `tabSubscription`
SET
start_date = start,
party_type = 'Customer',
party = customer,
sales_tax_template = tax_template
WHERE IFNULL(party,'') = ''
"""
)
frappe.db.sql(
"""
UPDATE `tabSubscription Invoice`
SET document_type = 'Sales Invoice'
WHERE IFNULL(document_type, '') = ''
"""
)
price_determination_map = {
"Fixed rate": "Fixed Rate",
"Based on price list": "Based On Price List",
}
for key, value in iteritems(price_determination_map):
frappe.db.sql(
"""
UPDATE `tabSubscription Plan`
SET price_determination = %s
WHERE price_determination = %s
""",
(value, key),
)