@@ -0,0 +1,1304 @@
+import frappe%0Afrom patches.v8_10.change_default_customer_credit_days import make_payment_term, make_template%0A%0A%0Adef execute():%0A%09payment_terms = %5B%5D%0A%09supplier_types = %5B%5D%0A%0A%09credit_days = frappe.db.sql(%0A%09%09%22SELECT DISTINCT %60credit_days%60, %60credit_days_based_on%60, %60supplier_type%60 from %22%0A%09%09%22%60tabSupplier Type%60 where credit_days_based_on='Fixed Days' or %22%0A%09%09%22credit_days_based_on='Last Day of the Next Month'%22)%0A%0A%09records = ((record%5B0%5D, record%5B1%5D, record%5B2%5D) for record in credit_days)%0A%0A%09for days, based_on, supplier_type in records:%0A%09%09if based_on == %22Fixed Days%22:%0A%09%09%09pyt_term_name = 'N%7B0%7D'.format(days)%0A%09%09else:%0A%09%09%09pyt_term_name = 'EO2M'%0A%0A%09%09if not frappe.db.exists(%22Payment Term%22, pyt_term_name):%0A%09%09%09payment_term = make_payment_term(days, based_on)%0A%09%09%09make_template(payment_term)%0A%09%09else:%0A%09%09%09payment_term = frappe.get_doc(%22Payment Term%22, pyt_term_name)%0A%0A%09%09payment_terms.append('WHEN %60supplier_name%60=%22%25s%22 THEN %22%25s%22' %25 (supplier_type, payment_term.payment_term_name))%0A%09%09supplier_types.append(supplier_type)%0A%0A%09begin_query_str = %22UPDATE %60tabSupplier%60 SET %60payment_terms%60 = CASE %22%0A%09value_query_str = %22 %22.join(payment_terms)%0A%09cond_query_str = %22 ELSE %60payment_terms%60 END WHERE %22%0A%0A%09if supplier_types:%0A%09%09frappe.db.sql(%0A%09%09%09begin_query_str + value_query_str + cond_query_str + '%60supplier_name%60 IN %25s',%0A%09%09%09(supplier_types,)%0A%09%09)%0A

patch for credit days in Supplier Type