mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-17 17:26:43 +00:00
feat: add patch
This commit is contained in:
@@ -677,4 +677,5 @@ erpnext.patches.v12_0.set_multi_uom_in_rfq
|
||||
erpnext.patches.v12_0.update_state_code_for_daman_and_diu
|
||||
erpnext.patches.v12_0.rename_lost_reason_detail
|
||||
erpnext.patches.v12_0.update_leave_application_status
|
||||
erpnext.patches.v12_0.update_payment_entry_status
|
||||
erpnext.patches.v12_0.update_payment_entry_status
|
||||
erpnext.patches.v12_0.setup_einvoice_fields
|
||||
|
||||
31
erpnext/patches/v12_0/setup_einvoice_fields.py
Normal file
31
erpnext/patches/v12_0/setup_einvoice_fields.py
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
|
||||
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='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()
|
||||
@@ -16,8 +16,8 @@ from Crypto.Cipher import PKCS1_v1_5, AES
|
||||
from Crypto.Util.Padding import pad, unpad
|
||||
from frappe.model.document import Document
|
||||
from frappe import _, get_module_path, scrub
|
||||
from erpnext.regional.india.utils import get_gst_accounts
|
||||
from frappe.integrations.utils import make_post_request, make_get_request
|
||||
from erpnext.regional.india.utils import get_gst_accounts, get_place_of_supply
|
||||
from frappe.utils.data import get_datetime, cstr, cint, format_date, flt, time_diff_in_seconds, now_datetime
|
||||
|
||||
def validate_einvoice_fields(doc):
|
||||
@@ -33,6 +33,9 @@ def validate_einvoice_fields(doc):
|
||||
|
||||
def get_credentials():
|
||||
doc = frappe.get_doc('E Invoice Settings')
|
||||
if not doc.enable:
|
||||
frappe.throw(_("To setup E Invoicing you need to enable E Invoice Settings first."), title=_("E Invoicing Disabled"))
|
||||
|
||||
if not doc.token_expiry or time_diff_in_seconds(now_datetime(), doc.token_expiry) > 5.0:
|
||||
fetch_token(doc)
|
||||
doc.load_from_db()
|
||||
@@ -437,7 +440,8 @@ def make_einvoice(doctype, name):
|
||||
buyer_details = get_overseas_address_details(invoice.customer_address)
|
||||
else:
|
||||
buyer_details = get_party_gstin_details(invoice.customer_address)
|
||||
place_of_supply = invoice.place_of_supply.split('-')[0]
|
||||
place_of_supply = get_place_of_supply(invoice, doctype) or invoice.billing_address_gstin
|
||||
place_of_supply = place_of_supply[:2]
|
||||
buyer_details.update(dict(place_of_supply=place_of_supply))
|
||||
|
||||
shipping_details = payment_details = prev_doc_details = eway_bill_details = frappe._dict({})
|
||||
@@ -513,7 +517,7 @@ def validate_einvoice(validations, einvoice, errors=[]):
|
||||
label = field_validation.get('label') or fieldname
|
||||
|
||||
if value_type == 'string' and len(value) > max_length:
|
||||
errors.append(_('{} should not exceed {} characters').format(fieldname_label, max_length))
|
||||
errors.append(_('{} should not exceed {} characters').format(label, max_length))
|
||||
if value_type == 'number' and not (flt(value) <= maximum):
|
||||
errors.append(_('{} should be less than {}').format(label, maximum))
|
||||
if pattern_str and not pattern.match(value):
|
||||
|
||||
Reference in New Issue
Block a user