def execute(): company = frappe.get_all('Company', filters = {'country': 'India'}) if not company: return frappe.reload_doc('Payroll', 'doctype', 'payroll_period') frappe.reload_doc('Payroll', 'doctype', 'employee_tax_exemption_declaration') frappe.reload_doc('Payroll', 'doctype', 'employee_tax_exemption_proof_submission') frappe.reload_doc('Payroll', 'doctype', 'employee_tax_exemption_declaration_category') frappe.reload_doc('Payroll', 'doctype', 'employee_tax_exemption_proof_submission_detail') frappe.reload_doc('accounts', 'doctype', 'tax_category') for doctype in ["Sales Invoice", "Delivery Note", "Purchase Invoice"]: frappe.db.sql("""delete from `tabCustom Field` where dt = %s and fieldname in ('port_code', 'shipping_bill_number', 'shipping_bill_date')""", doctype) make_custom_fields() frappe.db.sql(""" update `tabCustom Field` set reqd = 0, `default` = '' where fieldname = 'reason_for_issuing_document' """) frappe.db.sql(""" update tabAddress set gst_state_number=concat("0", gst_state_number) where ifnull(gst_state_number, '') != '' and gst_state_number<10 """)
def execute(): company = frappe.get_all('Company', filters={'country': 'India'}) if not company: return frappe.reload_doc('accounts', 'doctype', 'Tax Category') make_custom_fields() for doctype in ['Sales Invoice', 'Purchase Invoice']: has_column = frappe.db.has_column(doctype, 'invoice_type') if has_column: update_map = { 'Regular': 'Registered Regular', 'Export': 'Overseas', 'SEZ': 'SEZ', 'Deemed Export': 'Deemed Export', } for old, new in update_map.items(): frappe.db.sql( "UPDATE `tab{doctype}` SET gst_category = %s where invoice_type = %s" .format(doctype=doctype), (new, old)) #nosec frappe.delete_doc('Custom Field', 'Sales Invoice-invoice_type') frappe.delete_doc('Custom Field', 'Purchase Invoice-invoice_type') itc_update_map = { "ineligible": "Ineligible", "input service": "Input Service Distributor", "capital goods": "Import Of Capital Goods", "input": "All Other ITC" } has_gst_fields = frappe.db.has_column('Purchase Invoice', 'eligibility_for_itc') if has_gst_fields: for old, new in itc_update_map.items(): frappe.db.sql( "UPDATE `tabPurchase Invoice` SET eligibility_for_itc = %s where eligibility_for_itc = %s ", (new, old)) for doctype in ["Customer", "Supplier"]: frappe.db.sql( """ UPDATE `tab{doctype}` t1, `tabAddress` t2, `tabDynamic Link` t3 SET t1.gst_category = "Registered Regular" where t3.link_name = t1.name and t3.parent = t2.name and t2.gstin IS NOT NULL and t2.gstin != '' """ .format(doctype=doctype)) #nosec frappe.db.sql( """ UPDATE `tab{doctype}` t1, `tabAddress` t2, `tabDynamic Link` t3 SET t1.gst_category = "Overseas" where t3.link_name = t1.name and t3.parent = t2.name and t2.country != 'India' """ .format(doctype=doctype)) #nosec
def execute(): company = frappe.get_all('Company', filters={'country': 'India'}) if not company: return frappe.reload_doc("Payroll", "doctype", "Employee Tax Exemption Declaration") frappe.reload_doc("Payroll", "doctype", "Employee Tax Exemption Proof Submission") frappe.reload_doc("hr", "doctype", "Employee Grade") frappe.reload_doc("hr", "doctype", "Leave Policy") frappe.reload_doc("accounts", "doctype", "Bank Account") frappe.reload_doc("accounts", "doctype", "Tax Withholding Category") frappe.reload_doc("accounts", "doctype", "Allowed To Transact With") frappe.reload_doc("accounts", "doctype", "Finance Book") frappe.reload_doc("accounts", "doctype", "Loyalty Program") frappe.reload_doc("stock", "doctype", "Item Barcode") make_custom_fields() frappe.reload_doc("accounts", "doctype", "sales_taxes_and_charges") frappe.reload_doc("accounts", "doctype", "purchase_taxes_and_charges") frappe.reload_doc("accounts", "doctype", "sales_taxes_and_charges_template") frappe.reload_doc("accounts", "doctype", "purchase_taxes_and_charges_template") # set is_inter_state in Taxes And Charges Templates if frappe.db.has_column("Sales Taxes and Charges Template", "is_inter_state") and\ frappe.db.has_column("Purchase Taxes and Charges Template", "is_inter_state"): igst_accounts = set( frappe.db.sql_list( '''SELECT igst_account from `tabGST Account` WHERE parent = "GST Settings"''' )) cgst_accounts = set( frappe.db.sql_list( '''SELECT cgst_account FROM `tabGST Account` WHERE parenttype = "GST Settings"''' )) when_then_sales = get_formatted_data("Sales Taxes and Charges", igst_accounts, cgst_accounts) when_then_purchase = get_formatted_data("Purchase Taxes and Charges", igst_accounts, cgst_accounts) if when_then_sales: frappe.db.sql('''update `tabSales Taxes and Charges Template` set is_inter_state = Case {when_then} Else 0 End '''.format(when_then=" ".join(when_then_sales))) if when_then_purchase: frappe.db.sql('''update `tabPurchase Taxes and Charges Template` set is_inter_state = Case {when_then} Else 0 End '''.format(when_then=" ".join(when_then_purchase)))
def execute(): company = frappe.get_all('Company', filters={'country': 'India'}) if not company: return make_custom_fields() frappe.reload_doctype('Tax Category') frappe.reload_doctype('Sales Taxes and Charges Template') frappe.reload_doctype('Purchase Taxes and Charges Template') # Create tax category with inter state field checked tax_category = frappe.db.get_value('Tax Category', {'name': 'OUT OF STATE'}, 'name') if not tax_category: inter_state_category = frappe.get_doc({ 'doctype': 'Tax Category', 'title': 'OUT OF STATE', 'is_inter_state': 1 }).insert() tax_category = inter_state_category.name for doctype in ('Sales Taxes and Charges Template', 'Purchase Taxes and Charges Template'): if not frappe.get_meta(doctype).has_field('is_inter_state'): continue template = frappe.db.get_value(doctype, { 'is_inter_state': 1, 'disabled': 0 }, ['name']) if template: frappe.db.set_value(doctype, template, 'tax_category', tax_category) frappe.db.sql(""" DELETE FROM `tabCustom Field` WHERE fieldname = 'is_inter_state' AND dt IN ('Sales Taxes and Charges Template', 'Purchase Taxes and Charges Template') """)
def execute(): company = frappe.get_all('Company', filters={'country': 'India'}) if not company: return make_custom_fields()
def execute(): companies = [ d.name for d in frappe.get_all('Company', filters={'country': 'India'}) ] if not companies: return make_custom_fields() # update invoice copy value values = [ "Original for Recipient", "Duplicate for Transporter", "Duplicate for Supplier", "Triplicate for Supplier" ] for d in values: frappe.db.sql( "update `tabSales Invoice` set invoice_copy=%s where invoice_copy=%s", (d, d)) # update tax breakup in transactions made after 1st July 2017 doctypes = [ "Quotation", "Sales Order", "Delivery Note", "Sales Invoice", "Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice" ] for doctype in doctypes: frappe.reload_doctype(doctype) date_field = "posting_date" if doctype in [ "Quotation", "Sales Order", "Supplier Quotation", "Purchase Order" ]: date_field = "transaction_date" records = [ d.name for d in frappe.get_all(doctype, filters={ "docstatus": ["!=", 2], date_field: [">=", "2017-07-01"], "company": ["in", companies], "total_taxes_and_charges": [">", 0], "other_charges_calculation": "" }) ] if records: frappe.db.sql( """ update `tab%s Item` dt_item set gst_hsn_code = (select gst_hsn_code from tabItem where name=dt_item.item_code) where parent in (%s) and (gst_hsn_code is null or gst_hsn_code = '') """ % (doctype, ', '.join(['%s'] * len(records))), tuple(records)) for record in records: doc = frappe.get_doc(doctype, record) html = get_itemised_tax_breakup_html(doc) doc.db_set("other_charges_calculation", html, update_modified=False)