2020-07-23 05:41:23 +00:00
|
|
|
# Copyright (c) 2019, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2020-07-23 05:41:23 +00:00
|
|
|
import frappe
|
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2020-07-23 05:41:23 +00:00
|
|
|
def execute():
|
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
frappe.reload_doc("accounts", "doctype", "subscription")
|
|
|
|
frappe.reload_doc("accounts", "doctype", "subscription_invoice")
|
|
|
|
frappe.reload_doc("accounts", "doctype", "subscription_plan")
|
2020-07-23 05:41:23 +00:00
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
if frappe.db.has_column("Subscription", "customer"):
|
|
|
|
frappe.db.sql(
|
|
|
|
"""
|
2020-07-23 05:41:23 +00:00
|
|
|
UPDATE `tabSubscription`
|
|
|
|
SET
|
|
|
|
start_date = start,
|
|
|
|
party_type = 'Customer',
|
|
|
|
party = customer,
|
|
|
|
sales_tax_template = tax_template
|
|
|
|
WHERE IFNULL(party,'') = ''
|
2022-03-28 13:22:46 +00:00
|
|
|
"""
|
|
|
|
)
|
2020-07-23 05:41:23 +00:00
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
frappe.db.sql(
|
|
|
|
"""
|
2020-07-23 05:41:23 +00:00
|
|
|
UPDATE `tabSubscription Invoice`
|
|
|
|
SET document_type = 'Sales Invoice'
|
|
|
|
WHERE IFNULL(document_type, '') = ''
|
2022-03-28 13:22:46 +00:00
|
|
|
"""
|
|
|
|
)
|
2020-07-23 05:41:23 +00:00
|
|
|
|
|
|
|
price_determination_map = {
|
2022-03-28 13:22:46 +00:00
|
|
|
"Fixed rate": "Fixed Rate",
|
|
|
|
"Based on price list": "Based On Price List",
|
2020-07-23 05:41:23 +00:00
|
|
|
}
|
|
|
|
|
2021-11-04 14:18:32 +00:00
|
|
|
for key, value in price_determination_map.items():
|
2022-03-28 13:22:46 +00:00
|
|
|
frappe.db.sql(
|
|
|
|
"""
|
2020-07-23 05:41:23 +00:00
|
|
|
UPDATE `tabSubscription Plan`
|
|
|
|
SET price_determination = %s
|
|
|
|
WHERE price_determination = %s
|
2022-03-28 13:22:46 +00:00
|
|
|
""",
|
|
|
|
(value, key),
|
|
|
|
)
|