fix patches
This commit is contained in:
parent
2fdb857fed
commit
b8ddae13ba
@ -439,3 +439,5 @@ erpnext.patches.v8_10.add_due_date_to_gle
|
|||||||
erpnext.patches.v8_10.update_gl_due_date_for_pi_and_si
|
erpnext.patches.v8_10.update_gl_due_date_for_pi_and_si
|
||||||
erpnext.patches.v8_10.add_payment_terms_field_to_supplier
|
erpnext.patches.v8_10.add_payment_terms_field_to_supplier
|
||||||
erpnext.patches.v8_10.change_default_customer_credit_days
|
erpnext.patches.v8_10.change_default_customer_credit_days
|
||||||
|
erpnext.patches.v8_10.add_payment_terms_field_to_supplier_type
|
||||||
|
erpnext.patches.v8_10.change_default_supplier_type_credit_days
|
||||||
|
@ -3,6 +3,10 @@ import frappe
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
|
frappe.reload_doc("accounts", "doctype", "payment_term")
|
||||||
|
frappe.reload_doc("accounts", "doctype", "payment_terms_template_detail")
|
||||||
|
frappe.reload_doc("accounts", "doctype", "payment_terms_template")
|
||||||
|
|
||||||
payment_terms = []
|
payment_terms = []
|
||||||
customers = []
|
customers = []
|
||||||
suppliers = []
|
suppliers = []
|
||||||
@ -14,9 +18,9 @@ def execute():
|
|||||||
credit_records = ((record[0], record[1], record[2]) for record in credit_days)
|
credit_records = ((record[0], record[1], record[2]) for record in credit_days)
|
||||||
for days, based_on, customer_name in credit_records:
|
for days, based_on, customer_name in credit_records:
|
||||||
payment_term = make_payment_term(days, based_on)
|
payment_term = make_payment_term(days, based_on)
|
||||||
payment_terms.append('WHEN `customer_name`="%s" THEN "%s"' % (customer_name, payment_term.payment_term_name))
|
template = make_template(payment_term)
|
||||||
|
payment_terms.append('WHEN `customer_name`="%s" THEN "%s"' % (customer_name, template.template_name))
|
||||||
customers.append(customer_name)
|
customers.append(customer_name)
|
||||||
make_template(payment_term)
|
|
||||||
|
|
||||||
begin_query_str = "UPDATE `tabCustomer` SET `payment_terms` = CASE "
|
begin_query_str = "UPDATE `tabCustomer` SET `payment_terms` = CASE "
|
||||||
value_query_str = " ".join(payment_terms)
|
value_query_str = " ".join(payment_terms)
|
||||||
@ -38,17 +42,17 @@ def execute():
|
|||||||
credit_records = ((record[0], record[1], record[2]) for record in credit_days)
|
credit_records = ((record[0], record[1], record[2]) for record in credit_days)
|
||||||
for days, based_on, supplier_name in credit_records:
|
for days, based_on, supplier_name in credit_records:
|
||||||
if based_on == "Fixed Days":
|
if based_on == "Fixed Days":
|
||||||
pyt_term_name = 'N{0}'.format(days)
|
pyt_template_name = 'Default Payment Term - N{0}'.format(days)
|
||||||
else:
|
else:
|
||||||
pyt_term_name = 'EO2M'
|
pyt_template_name = 'Default Payment Term - EO2M'
|
||||||
|
|
||||||
if not frappe.db.exists("Payment Term", pyt_term_name):
|
if not frappe.db.exists("Payment Term Template", pyt_template_name):
|
||||||
payment_term = make_payment_term(days, based_on)
|
payment_term = make_payment_term(days, based_on)
|
||||||
make_template(payment_term)
|
template = make_template(payment_term)
|
||||||
else:
|
else:
|
||||||
payment_term = frappe.get_doc("Payment Term", pyt_term_name)
|
template = frappe.get_doc("Payment Term Template", pyt_template_name)
|
||||||
|
|
||||||
payment_terms.append('WHEN `supplier_name`="%s" THEN "%s"' % (supplier_name, payment_term.payment_term_name))
|
payment_terms.append('WHEN `supplier_name`="%s" THEN "%s"' % (supplier_name, template.template_name))
|
||||||
suppliers.append(supplier_name)
|
suppliers.append(supplier_name)
|
||||||
|
|
||||||
begin_query_str = "UPDATE `tabSupplier` SET `payment_terms` = CASE "
|
begin_query_str = "UPDATE `tabSupplier` SET `payment_terms` = CASE "
|
||||||
@ -73,9 +77,11 @@ def make_template(payment_term):
|
|||||||
|
|
||||||
template = frappe.new_doc('Payment Terms Template')
|
template = frappe.new_doc('Payment Terms Template')
|
||||||
template.template_name = 'Default Payment Term - {0}'.format(payment_term.payment_term_name)
|
template.template_name = 'Default Payment Term - {0}'.format(payment_term.payment_term_name)
|
||||||
template.terms = [doc]
|
template.append('terms', doc)
|
||||||
template.save()
|
template.save()
|
||||||
|
|
||||||
|
return template
|
||||||
|
|
||||||
|
|
||||||
def make_payment_term(days, based_on):
|
def make_payment_term(days, based_on):
|
||||||
based_on_map = {
|
based_on_map = {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from patches.v8_10.change_default_customer_credit_days import make_payment_term, make_template
|
from erpnext.patches.v8_10.change_default_customer_credit_days import make_payment_term, make_template
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
@ -25,15 +25,15 @@ def execute():
|
|||||||
else:
|
else:
|
||||||
payment_term = frappe.get_doc("Payment Term", pyt_term_name)
|
payment_term = frappe.get_doc("Payment Term", pyt_term_name)
|
||||||
|
|
||||||
payment_terms.append('WHEN `supplier_name`="%s" THEN "%s"' % (supplier_type, payment_term.payment_term_name))
|
payment_terms.append('WHEN `supplier_type`="%s" THEN "%s"' % (supplier_type, payment_term.payment_term_name))
|
||||||
supplier_types.append(supplier_type)
|
supplier_types.append(supplier_type)
|
||||||
|
|
||||||
begin_query_str = "UPDATE `tabSupplier` SET `payment_terms` = CASE "
|
begin_query_str = "UPDATE `tabSupplier Type` SET `payment_terms` = CASE "
|
||||||
value_query_str = " ".join(payment_terms)
|
value_query_str = " ".join(payment_terms)
|
||||||
cond_query_str = " ELSE `payment_terms` END WHERE "
|
cond_query_str = " ELSE `payment_terms` END WHERE "
|
||||||
|
|
||||||
if supplier_types:
|
if supplier_types:
|
||||||
frappe.db.sql(
|
frappe.db.sql(
|
||||||
begin_query_str + value_query_str + cond_query_str + '`supplier_name` IN %s',
|
begin_query_str + value_query_str + cond_query_str + '`supplier_type` IN %s',
|
||||||
(supplier_types,)
|
(supplier_types,)
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user