mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
fix: remove patches
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company or not frappe.db.count('E Invoice User'):
|
||||
return
|
||||
|
||||
frappe.reload_doc("regional", "doctype", "e_invoice_user")
|
||||
for creds in frappe.db.get_all('E Invoice User', fields=['name', 'gstin']):
|
||||
company_name = frappe.db.sql("""
|
||||
select dl.link_name from `tabAddress` a, `tabDynamic Link` dl
|
||||
where a.gstin = %s and dl.parent = a.name and dl.link_doctype = 'Company'
|
||||
""", (creds.get('gstin')))
|
||||
if company_name and len(company_name) > 0:
|
||||
frappe.db.set_value('E Invoice User', creds.get('name'), 'company', company_name[0][0])
|
||||
@@ -1,72 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
# move hidden einvoice fields to a different section
|
||||
custom_fields = {
|
||||
'Sales Invoice': [
|
||||
dict(fieldname='einvoice_section', label='E-Invoice Fields', fieldtype='Section Break', insert_after='gst_vehicle_type',
|
||||
print_hide=1, hidden=1),
|
||||
|
||||
dict(fieldname='ack_no', label='Ack. No.', fieldtype='Data', read_only=1, hidden=1, insert_after='einvoice_section',
|
||||
no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='ack_date', label='Ack. Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_no', no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='irn_cancel_date', label='Cancel Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_date',
|
||||
no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='signed_einvoice', label='Signed E-Invoice', fieldtype='Code', options='JSON', hidden=1, insert_after='irn_cancel_date',
|
||||
no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='signed_qr_code', label='Signed QRCode', fieldtype='Code', options='JSON', hidden=1, insert_after='signed_einvoice',
|
||||
no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='qrcode_image', label='QRCode', fieldtype='Attach Image', hidden=1, insert_after='signed_qr_code',
|
||||
no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='einvoice_status', label='E-Invoice Status', fieldtype='Select', insert_after='qrcode_image',
|
||||
options='\nPending\nGenerated\nCancelled\nFailed', default=None, hidden=1, no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='failure_description', label='E-Invoice Failure Description', fieldtype='Code', options='JSON',
|
||||
hidden=1, insert_after='einvoice_status', no_copy=1, print_hide=1, read_only=1)
|
||||
]
|
||||
}
|
||||
create_custom_fields(custom_fields, update=True)
|
||||
|
||||
if frappe.db.exists('E Invoice Settings') and frappe.db.get_single_value('E Invoice Settings', 'enable'):
|
||||
frappe.db.sql('''
|
||||
UPDATE `tabSales Invoice` SET einvoice_status = 'Pending'
|
||||
WHERE
|
||||
posting_date >= '2021-04-01'
|
||||
AND ifnull(irn, '') = ''
|
||||
AND ifnull(`billing_address_gstin`, '') != ifnull(`company_gstin`, '')
|
||||
AND ifnull(gst_category, '') in ('Registered Regular', 'SEZ', 'Overseas', 'Deemed Export')
|
||||
''')
|
||||
|
||||
# set appropriate statuses
|
||||
frappe.db.sql('''UPDATE `tabSales Invoice` SET einvoice_status = 'Generated'
|
||||
WHERE ifnull(irn, '') != '' AND ifnull(irn_cancelled, 0) = 0''')
|
||||
|
||||
frappe.db.sql('''UPDATE `tabSales Invoice` SET einvoice_status = 'Cancelled'
|
||||
WHERE ifnull(irn_cancelled, 0) = 1''')
|
||||
|
||||
# set correct acknowledgement in e-invoices
|
||||
einvoices = frappe.get_all('Sales Invoice', {'irn': ['is', 'set']}, ['name', 'signed_einvoice'])
|
||||
|
||||
if einvoices:
|
||||
for inv in einvoices:
|
||||
signed_einvoice = inv.get('signed_einvoice')
|
||||
if signed_einvoice:
|
||||
signed_einvoice = json.loads(signed_einvoice)
|
||||
frappe.db.set_value('Sales Invoice', inv.get('name'), 'ack_no', signed_einvoice.get('AckNo'), update_modified=False)
|
||||
frappe.db.set_value('Sales Invoice', inv.get('name'), 'ack_date', signed_einvoice.get('AckDt'), update_modified=False)
|
||||
@@ -1,20 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
if frappe.db.exists('Report', 'E-Invoice Summary') and \
|
||||
not frappe.db.get_value('Custom Role', dict(report='E-Invoice Summary')):
|
||||
frappe.get_doc(dict(
|
||||
doctype='Custom Role',
|
||||
report='E-Invoice Summary',
|
||||
roles= [
|
||||
dict(role='Accounts User'),
|
||||
dict(role='Accounts Manager')
|
||||
]
|
||||
)).insert()
|
||||
@@ -1,20 +0,0 @@
|
||||
import frappe
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_field
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
|
||||
if not company:
|
||||
return
|
||||
|
||||
create_custom_field('Delivery Note', {
|
||||
'fieldname': 'ewaybill',
|
||||
'label': 'E-Way Bill No.',
|
||||
'fieldtype': 'Data',
|
||||
'depends_on': 'eval:(doc.docstatus === 1)',
|
||||
'allow_on_submit': 1,
|
||||
'insert_after': 'customer_name_in_arabic',
|
||||
'translatable': 0,
|
||||
'owner': 'Administrator'
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
custom_fields = {
|
||||
'Sales Invoice': [
|
||||
dict(fieldname='eway_bill_validity', label='E-Way Bill Validity', fieldtype='Data', no_copy=1, print_hide=1,
|
||||
depends_on='ewaybill', read_only=1, allow_on_submit=1, insert_after='ewaybill')
|
||||
]
|
||||
}
|
||||
create_custom_fields(custom_fields, update=True)
|
||||
@@ -1,41 +0,0 @@
|
||||
import frappe
|
||||
|
||||
from erpnext.regional.india.setup import make_custom_fields
|
||||
|
||||
|
||||
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')
|
||||
""")
|
||||
@@ -1,19 +0,0 @@
|
||||
import frappe
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
custom_fields = {
|
||||
'Delivery Note': [
|
||||
dict(fieldname='gst_category', label='GST Category',
|
||||
fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
|
||||
options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
|
||||
fetch_from='customer.gst_category', fetch_if_empty=1),
|
||||
]
|
||||
}
|
||||
|
||||
create_custom_fields(custom_fields, update=True)
|
||||
@@ -1,52 +0,0 @@
|
||||
import frappe
|
||||
|
||||
from erpnext.regional.india.setup import make_custom_fields
|
||||
|
||||
|
||||
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
|
||||
@@ -1,59 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
from erpnext.regional.india.setup import add_permissions, add_print_formats
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
frappe.reload_doc("custom", "doctype", "custom_field")
|
||||
frappe.reload_doc("regional", "doctype", "e_invoice_settings")
|
||||
custom_fields = {
|
||||
'Sales Invoice': [
|
||||
dict(fieldname='irn', label='IRN', fieldtype='Data', read_only=1, insert_after='customer', no_copy=1, print_hide=1,
|
||||
depends_on='eval:in_list(["Registered Regular", "SEZ", "Overseas", "Deemed Export"], doc.gst_category) && doc.irn_cancelled === 0'),
|
||||
|
||||
dict(fieldname='ack_no', label='Ack. No.', fieldtype='Data', read_only=1, hidden=1, insert_after='irn', no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='ack_date', label='Ack. Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_no', no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='irn_cancelled', label='IRN Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
|
||||
depends_on='eval:(doc.irn_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
|
||||
|
||||
dict(fieldname='eway_bill_cancelled', label='E-Way Bill Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
|
||||
depends_on='eval:(doc.eway_bill_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
|
||||
|
||||
dict(fieldname='signed_einvoice', fieldtype='Code', options='JSON', hidden=1, no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='signed_qr_code', fieldtype='Code', options='JSON', hidden=1, no_copy=1, print_hide=1, read_only=1),
|
||||
|
||||
dict(fieldname='qrcode_image', label='QRCode', fieldtype='Attach Image', hidden=1, no_copy=1, print_hide=1, read_only=1)
|
||||
]
|
||||
}
|
||||
create_custom_fields(custom_fields, update=True)
|
||||
add_permissions()
|
||||
add_print_formats()
|
||||
|
||||
einvoice_cond = 'in_list(["Registered Regular", "SEZ", "Overseas", "Deemed Export"], doc.gst_category)'
|
||||
t = {
|
||||
'mode_of_transport': [{'default': None}],
|
||||
'distance': [{'mandatory_depends_on': f'eval:{einvoice_cond} && doc.transporter'}],
|
||||
'gst_vehicle_type': [{'mandatory_depends_on': f'eval:{einvoice_cond} && doc.mode_of_transport == "Road"'}],
|
||||
'lr_date': [{'mandatory_depends_on': f'eval:{einvoice_cond} && in_list(["Air", "Ship", "Rail"], doc.mode_of_transport)'}],
|
||||
'lr_no': [{'mandatory_depends_on': f'eval:{einvoice_cond} && in_list(["Air", "Ship", "Rail"], doc.mode_of_transport)'}],
|
||||
'vehicle_no': [{'mandatory_depends_on': f'eval:{einvoice_cond} && doc.mode_of_transport == "Road"'}],
|
||||
'ewaybill': [
|
||||
{'read_only_depends_on': 'eval:doc.irn && doc.ewaybill'},
|
||||
{'depends_on': 'eval:((doc.docstatus === 1 || doc.ewaybill) && doc.eway_bill_cancelled === 0)'}
|
||||
]
|
||||
}
|
||||
|
||||
for field, conditions in t.items():
|
||||
for c in conditions:
|
||||
[(prop, value)] = c.items()
|
||||
frappe.db.set_value('Custom Field', { 'fieldname': field }, prop, value)
|
||||
@@ -1,14 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
irn_cancelled_field = frappe.db.exists('Custom Field', {'dt': 'Sales Invoice', 'fieldname': 'irn_cancelled'})
|
||||
if irn_cancelled_field:
|
||||
frappe.db.set_value('Custom Field', irn_cancelled_field, 'depends_on', 'eval: doc.irn')
|
||||
frappe.db.set_value('Custom Field', irn_cancelled_field, 'read_only', 0)
|
||||
@@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2020, Frappe and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
import frappe
|
||||
|
||||
from erpnext.regional.address_template.setup import set_up_address_templates
|
||||
|
||||
|
||||
def execute():
|
||||
if frappe.db.get_value('Company', {'country': 'India'}, 'name'):
|
||||
address_template = frappe.db.get_value('Address Template', 'India', 'template')
|
||||
if not address_template or "gstin" not in address_template:
|
||||
set_up_address_templates(default_country='India')
|
||||
@@ -1,27 +0,0 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
|
||||
if not company:
|
||||
return
|
||||
|
||||
field = frappe.db.get_value("Custom Field", {"dt": "Sales Invoice", "fieldname": "ewaybill"})
|
||||
|
||||
if field:
|
||||
ewaybill_field = frappe.get_doc("Custom Field", field)
|
||||
|
||||
ewaybill_field.flags.ignore_validate = True
|
||||
|
||||
ewaybill_field.update({
|
||||
'fieldname': 'ewaybill',
|
||||
'label': 'e-Way Bill No.',
|
||||
'fieldtype': 'Data',
|
||||
'depends_on': 'eval:(doc.docstatus === 1)',
|
||||
'allow_on_submit': 1,
|
||||
'insert_after': 'tax_id',
|
||||
'translatable': 0
|
||||
})
|
||||
|
||||
ewaybill_field.save()
|
||||
@@ -1,19 +0,0 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
frappe.db.sql(""" UPDATE `tabSales Invoice` set gst_category = 'Unregistered'
|
||||
where gst_category = 'Registered Regular'
|
||||
and ifnull(customer_gstin, '')=''
|
||||
and ifnull(billing_address_gstin,'')=''
|
||||
""")
|
||||
|
||||
frappe.db.sql(""" UPDATE `tabPurchase Invoice` set gst_category = 'Unregistered'
|
||||
where gst_category = 'Registered Regular'
|
||||
and ifnull(supplier_gstin, '')=''
|
||||
""")
|
||||
Reference in New Issue
Block a user