feat(e-invoicing): e-way bill validity field (#25555)

This commit is contained in:
Saqib 2021-05-06 16:10:55 +05:30 committed by GitHub
parent 8a1f86db16
commit d502f76319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 4 deletions

View File

@ -774,5 +774,6 @@ erpnext.patches.v12_0.add_document_type_field_for_italy_einvoicing
erpnext.patches.v13_0.make_non_standard_user_type #13-04-2021 erpnext.patches.v13_0.make_non_standard_user_type #13-04-2021
erpnext.patches.v13_0.update_shipment_status erpnext.patches.v13_0.update_shipment_status
erpnext.patches.v13_0.remove_attribute_field_from_item_variant_setting erpnext.patches.v13_0.remove_attribute_field_from_item_variant_setting
erpnext.patches.v12_0.add_ewaybill_validity_field
erpnext.patches.v13_0.germany_make_custom_fields erpnext.patches.v13_0.germany_make_custom_fields
erpnext.patches.v13_0.germany_fill_debtor_creditor_number erpnext.patches.v13_0.germany_fill_debtor_creditor_number

View File

@ -0,0 +1,16 @@
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)

View File

@ -71,13 +71,14 @@ def validate_einvoice_fields(doc):
def raise_document_name_too_long_error(): def raise_document_name_too_long_error():
title = _('Document ID Too Long') title = _('Document ID Too Long')
msg = _('As you have E-Invoicing enabled, to be able to generate IRN for this invoice, ') msg = _('As you have E-Invoicing enabled, to be able to generate IRN for this invoice')
msg += _('document id {} exceed 16 letters. ').format(bold(_('should not'))) msg += ', '
msg += _('document id {} exceed 16 letters.').format(bold(_('should not')))
msg += '<br><br>' msg += '<br><br>'
msg += _('You must {} your {} in order to have document id of {} length 16. ').format( msg += _('You must {} your {} in order to have document id of {} length 16.').format(
bold(_('modify')), bold(_('naming series')), bold(_('maximum')) bold(_('modify')), bold(_('naming series')), bold(_('maximum'))
) )
msg += _('Please account for ammended documents too. ') msg += _('Please account for ammended documents too.')
frappe.throw(msg, title=title) frappe.throw(msg, title=title)
def read_json(name): def read_json(name):
@ -847,6 +848,7 @@ class GSPConnector():
res = self.make_request('post', self.generate_ewaybill_url, headers, data) res = self.make_request('post', self.generate_ewaybill_url, headers, data)
if res.get('success'): if res.get('success'):
self.invoice.ewaybill = res.get('result').get('EwbNo') self.invoice.ewaybill = res.get('result').get('EwbNo')
self.invoice.eway_bill_validity = res.get('result').get('EwbValidTill')
self.invoice.eway_bill_cancelled = 0 self.invoice.eway_bill_cancelled = 0
self.invoice.update(args) self.invoice.update(args)
self.invoice.flags.updater_reference = { self.invoice.flags.updater_reference = {
@ -944,6 +946,7 @@ class GSPConnector():
self.invoice.irn = res.get('Irn') self.invoice.irn = res.get('Irn')
self.invoice.ewaybill = res.get('EwbNo') self.invoice.ewaybill = res.get('EwbNo')
self.invoice.eway_bill_validity = res.get('EwbValidTill')
self.invoice.ack_no = res.get('AckNo') self.invoice.ack_no = res.get('AckNo')
self.invoice.ack_date = res.get('AckDt') self.invoice.ack_date = res.get('AckDt')
self.invoice.signed_einvoice = dec_signed_invoice self.invoice.signed_einvoice = dec_signed_invoice
@ -960,6 +963,7 @@ class GSPConnector():
'label': _('IRN Generated') 'label': _('IRN Generated')
} }
self.update_invoice() self.update_invoice()
def attach_qrcode_image(self): def attach_qrcode_image(self):
qrcode = self.invoice.signed_qr_code qrcode = self.invoice.signed_qr_code
doctype = self.invoice.doctype doctype = self.invoice.doctype

View File

@ -422,6 +422,9 @@ def make_custom_fields(update=True):
dict(fieldname='irn_cancelled', label='IRN Cancelled', fieldtype='Check', 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'), depends_on='eval:(doc.irn_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
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'),
dict(fieldname='eway_bill_cancelled', label='E-Way Bill Cancelled', fieldtype='Check', no_copy=1, print_hide=1, 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'), depends_on='eval:(doc.eway_bill_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),