diff --git a/erpnext/regional/india/e_invoice/einv_item_template.json b/erpnext/regional/india/e_invoice/einv_item_template.json index 23afd013d56..78e56518dff 100644 --- a/erpnext/regional/india/e_invoice/einv_item_template.json +++ b/erpnext/regional/india/e_invoice/einv_item_template.json @@ -8,9 +8,9 @@ "Qty": "{item.qty}", "FreeQty": "{item.free_qty}", "UnitPrice": "{item.unit_rate}", - "TotAmt": "{item.total_amount}", + "TotAmt": "{item.gross_amount}", "Discount": "{item.discount_amount}", - "AssAmt": "{item.base_amount}", + "AssAmt": "{item.taxable_value}", "PrdSlNo": "{item.serial_no}", "GstRt": "{item.tax_rate}", "IgstAmt": "{item.igst_amount}", diff --git a/erpnext/regional/india/e_invoice/einv_validation.json b/erpnext/regional/india/e_invoice/einv_validation.json index 3f0767b8be8..86290cfe524 100644 --- a/erpnext/regional/india/e_invoice/einv_validation.json +++ b/erpnext/regional/india/e_invoice/einv_validation.json @@ -2,12 +2,14 @@ "Version": { "type": "string", "minLength": 1, - "maxLength": 6 + "maxLength": 6, + "description": "Version of the schema" }, "Irn": { "type": "string", "minLength": 64, - "maxLength": 64 + "maxLength": 64, + "description": "Invoice Reference Number" }, "TranDtls": { "type": "object", @@ -16,31 +18,37 @@ "type": "string", "minLength": 3, "maxLength": 10, - "enum": ["GST"] + "enum": ["GST"], + "description": "GST- Goods and Services Tax Scheme" }, "SupTyp": { "type": "string", "minLength": 3, "maxLength": 10, - "enum": ["B2B", "SEZWP", "SEZWOP", "EXPWP", "EXPWOP", "DEXP"] + "enum": ["B2B", "SEZWP", "SEZWOP", "EXPWP", "EXPWOP", "DEXP"], + "description": "Type of Supply: B2B-Business to Business, SEZWP - SEZ with payment, SEZWOP - SEZ without payment, EXPWP - Export with Payment, EXPWOP - Export without payment,DEXP - Deemed Export" }, "RegRev": { "type": "string", "minLength": 1, "maxLength": 1, - "enum": ["Y", "N"] + "enum": ["Y", "N"], + "description": "Y- whether the tax liability is payable under reverse charge" }, "EcmGstin": { "type": "string", "minLength": 15, "maxLength": 15, - "pattern": "([0-9]{2}[0-9A-Z]{13})" + "pattern": "([0-9]{2}[0-9A-Z]{13})", + "description": "E-Commerce GSTIN", + "validationMsg": "E-Commerce GSTIN is invalid" }, "IgstOnIntra": { "type": "string", "minLength": 1, "maxLength": 1, - "enum": ["Y", "N"] + "enum": ["Y", "N"], + "description": "Y- indicates the supply is intra state but chargeable to IGST" } }, "required": ["TaxSch", "SupTyp"] @@ -52,22 +60,23 @@ "type": "string", "minLength": 3, "maxLength": 3, - "enum": ["INV", "CRN", "DBN"] + "enum": ["INV", "CRN", "DBN"], + "description": "Document Type" }, "No": { "type": "string", "minLength": 1, "maxLength": 16, "pattern": "^([A-Z1-9]{1}[A-Z0-9/-]{0,15})$", - "label": "Document Name", - "validationMsg": "Document name should not be starting with 0, / and -" + "description": "Document Number", + "validationMsg": "Document Number should not be starting with 0, / and -" }, "Dt": { "type": "string", "minLength": 10, "maxLength": 10, "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", - "validationMsg": "Document Date is invalid" + "description": "Document Date" } }, "required": ["Typ", "No", "Dt"] @@ -80,52 +89,62 @@ "minLength": 15, "maxLength": 15, "pattern": "([0-9]{2}[0-9A-Z]{13})", - "validationMsg": "Seller GSTIN is invalid" + "description": "Supplier GSTIN", + "validationMsg": "Company GSTIN is invalid" }, "LglNm": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Legal Name" }, "TrdNm": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Tradename" }, "Addr1": { "type": "string", - "minLength": 3, - "maxLength": 100 + "minLength": 1, + "maxLength": 100, + "description": "Address Line 1" }, "Addr2": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Address Line 2" }, "Loc": { "type": "string", "minLength": 3, - "maxLength": 50 + "maxLength": 50, + "description": "Location" }, "Pin": { "type": "number", "minimum": 100000, - "maximum": 999999 + "maximum": 999999, + "description": "Pincode" }, "Stcd": { "type": "string", "minLength": 1, - "maxLength": 2 + "maxLength": 2, + "description": "Supplier State Code" }, "Ph": { "type": "string", "minLength": 6, - "maxLength": 12 + "maxLength": 12, + "description": "Phone" }, "Em": { "type": "string", "minLength": 6, - "maxLength": 100 + "maxLength": 100, + "description": "Email-Id" } }, "required": ["Gstin", "LglNm", "Addr1", "Loc", "Pin", "Stcd"] @@ -138,57 +157,68 @@ "minLength": 3, "maxLength": 15, "pattern": "^(([0-9]{2}[0-9A-Z]{13})|URP)$", - "validationMsg": "Buyer GSTIN is invalid" + "description": "Buyer GSTIN", + "validationMsg": "Customer GSTIN is invalid" }, "LglNm": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Legal Name" }, "TrdNm": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Trade Name" }, "Pos": { "type": "string", "minLength": 1, - "maxLength": 2 + "maxLength": 2, + "description": "Place of Supply State code" }, "Addr1": { "type": "string", - "minLength": 3, - "maxLength": 100 + "minLength": 1, + "maxLength": 100, + "description": "Address Line 1" }, "Addr2": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Address Line 2" }, "Loc": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Location" }, "Pin": { "type": "number", "minimum": 100000, - "maximum": 999999 + "maximum": 999999, + "description": "Pincode" }, "Stcd": { "type": "string", "minLength": 1, - "maxLength": 2 + "maxLength": 2, + "description": "Buyer State Code" }, "Ph": { "type": "string", "minLength": 6, - "maxLength": 12 + "maxLength": 12, + "description": "Phone" }, "Em": { "type": "string", "minLength": 6, - "maxLength": 100 + "maxLength": 100, + "description": "Email-Id" } }, "required": ["Gstin", "LglNm", "Pos", "Addr1", "Loc", "Stcd"] @@ -199,32 +229,38 @@ "Nm": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Dispatch Address Name" }, "Addr1": { "type": "string", - "minLength": 3, - "maxLength": 100 + "minLength": 1, + "maxLength": 100, + "description": "Address Line 1" }, "Addr2": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Address Line 2" }, "Loc": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Location" }, "Pin": { "type": "number", "minimum": 100000, - "maximum": 999999 + "maximum": 999999, + "description": "Pincode" }, "Stcd": { "type": "string", "minLength": 1, - "maxLength": 2 + "maxLength": 2, + "description": "State Code" } }, "required": ["Nm", "Addr1", "Loc", "Pin", "Stcd"] @@ -237,42 +273,50 @@ "maxLength": 15, "minLength": 3, "pattern": "^(([0-9]{2}[0-9A-Z]{13})|URP)$", + "description": "Shipping Address GSTIN", "validationMsg": "Shipping Address GSTIN is invalid" }, "LglNm": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Legal Name" }, "TrdNm": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Trade Name" }, "Addr1": { "type": "string", - "minLength": 3, - "maxLength": 100 + "minLength": 1, + "maxLength": 100, + "description": "Address Line 1" }, "Addr2": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Address Line 2" }, "Loc": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Location" }, "Pin": { "type": "number", "minimum": 100000, - "maximum": 999999 + "maximum": 999999, + "description": "Pincode" }, "Stcd": { "type": "string", "minLength": 1, - "maxLength": 2 + "maxLength": 2, + "description": "State Code" } }, "required": ["LglNm", "Addr1", "Loc", "Pin", "Stcd"] @@ -283,143 +327,171 @@ "SlNo": { "type": "string", "minLength": 1, - "maxLength": 6 + "maxLength": 6, + "description": "Serial No. of Item" }, "PrdDesc": { "type": "string", "minLength": 3, - "maxLength": 300 + "maxLength": 300, + "description": "Item Name" }, "IsServc": { "type": "string", "minLength": 1, "maxLength": 1, - "enum": ["Y", "N"] + "enum": ["Y", "N"], + "description": "Is Service Item" }, "HsnCd": { "type": "string", "minLength": 4, - "maxLength": 8 + "maxLength": 8, + "description": "HSN Code" }, "Barcde": { "type": "string", "minLength": 3, - "maxLength": 30 + "maxLength": 30, + "description": "Barcode" }, "Qty": { "type": "number", "minimum": 0, - "maximum": 9999999999.999 + "maximum": 9999999999.999, + "description": "Quantity" }, "FreeQty": { "type": "number", "minimum": 0, - "maximum": 9999999999.999 + "maximum": 9999999999.999, + "description": "Free Quantity" }, "Unit": { "type": "string", "minLength": 3, - "maxLength": 8 + "maxLength": 8, + "description": "UOM" }, "UnitPrice": { "type": "number", "minimum": 0, - "maximum": 999999999999.999 + "maximum": 999999999999.999, + "description": "Rate" }, "TotAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Gross Amount" }, "Discount": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Discount" }, "PreTaxVal": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Pre tax value" }, "AssAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Taxable Value" }, "GstRt": { "type": "number", "minimum": 0, - "maximum": 999.999 + "maximum": 999.999, + "description": "GST Rate" }, "IgstAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "IGST Amount" }, "CgstAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "CGST Amount" }, "SgstAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "SGST Amount" }, "CesRt": { "type": "number", "minimum": 0, - "maximum": 999.999 + "maximum": 999.999, + "description": "Cess Rate" }, "CesAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Cess Amount (Advalorem)" }, "CesNonAdvlAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Cess Amount (Non-Advalorem)" }, "StateCesRt": { "type": "number", "minimum": 0, - "maximum": 999.999 + "maximum": 999.999, + "description": "State CESS Rate" }, "StateCesAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "State CESS Amount" }, "StateCesNonAdvlAmt": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "State CESS Amount (Non Advalorem)" }, "OthChrg": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Other Charges" }, "TotItemVal": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Total Item Value" }, "OrdLineRef": { "type": "string", "minLength": 1, - "maxLength": 50 + "maxLength": 50, + "description": "Order line reference" }, "OrgCntry": { "type": "string", "minLength": 2, - "maxLength": 2 + "maxLength": 2, + "description": "Origin Country" }, "PrdSlNo": { "type": "string", "minLength": 1, - "maxLength": 20 + "maxLength": 20, + "description": "Serial number" }, "BchDtls": { "type": "object", @@ -427,21 +499,22 @@ "Nm": { "type": "string", "minLength": 3, - "maxLength": 20 + "maxLength": 20, + "description": "Batch number" }, "ExpDt": { "type": "string", "maxLength": 10, "minLength": 10, "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", - "validationMsg": "Expiry Date is invalid" + "description": "Batch Expiry Date" }, "WrDt": { "type": "string", "maxLength": 10, "minLength": 10, "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", - "validationMsg": "Warranty Date is invalid" + "description": "Warranty Date" } }, "required": ["Nm"] @@ -454,12 +527,14 @@ "Nm": { "type": "string", "minLength": 1, - "maxLength": 100 + "maxLength": 100, + "description": "Attribute name of the item" }, "Val": { "type": "string", "minLength": 1, - "maxLength": 100 + "maxLength": 100, + "description": "Attribute value of the item" } } } @@ -482,57 +557,68 @@ "AssVal": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Total Assessable value of all items" }, "CgstVal": { "type": "number", "maximum": 99999999999999.99, - "minimum": 0 + "minimum": 0, + "description": "Total CGST value of all items" }, "SgstVal": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Total SGST value of all items" }, "IgstVal": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Total IGST value of all items" }, "CesVal": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Total CESS value of all items" }, "StCesVal": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Total State CESS value of all items" }, "Discount": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Invoice Discount" }, "OthChrg": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Other Charges" }, "RndOffAmt": { "type": "number", - "minimum": 0, - "maximum": 99.99 + "minimum": -99.99, + "maximum": 99.99, + "description": "Rounded off Amount" }, "TotInvVal": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Final Invoice Value " }, "TotInvValFc": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Final Invoice value in Foreign Currency" } }, "required": ["AssVal", "TotInvVal"] @@ -543,57 +629,68 @@ "Nm": { "type": "string", "minLength": 1, - "maxLength": 100 + "maxLength": 100, + "description": "Payee Name" }, "AccDet": { "type": "string", "minLength": 1, - "maxLength": 18 + "maxLength": 18, + "description": "Bank Account Number of Payee" }, "Mode": { "type": "string", "minLength": 1, - "maxLength": 18 + "maxLength": 18, + "description": "Mode of Payment" }, "FinInsBr": { "type": "string", "minLength": 1, - "maxLength": 11 + "maxLength": 11, + "description": "Branch or IFSC code" }, "PayTerm": { "type": "string", "minLength": 1, - "maxLength": 100 + "maxLength": 100, + "description": "Terms of Payment" }, "PayInstr": { "type": "string", "minLength": 1, - "maxLength": 100 + "maxLength": 100, + "description": "Payment Instruction" }, "CrTrn": { "type": "string", "minLength": 1, - "maxLength": 100 + "maxLength": 100, + "description": "Credit Transfer" }, "DirDr": { "type": "string", "minLength": 1, - "maxLength": 100 + "maxLength": 100, + "description": "Direct Debit" }, "CrDay": { "type": "number", "minimum": 0, - "maximum": 9999 + "maximum": 9999, + "description": "Credit Days" }, "PaidAmt": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Advance Amount" }, "PaymtDue": { "type": "number", "minimum": 0, - "maximum": 99999999999999.99 + "maximum": 99999999999999.99, + "description": "Outstanding Amount" } } }, @@ -604,7 +701,8 @@ "type": "string", "maxLength": 100, "minLength": 3, - "pattern": "^[0-9A-Za-z/-]{3,100}$" + "pattern": "^[0-9A-Za-z/-]{3,100}$", + "description": "Remarks/Note" }, "DocPerdDtls": { "type": "object", @@ -613,16 +711,18 @@ "type": "string", "maxLength": 10, "minLength": 10, - "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]" + "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", + "description": "Invoice Period Start Date" }, "InvEndDt": { "type": "string", "maxLength": 10, "minLength": 10, - "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]" + "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", + "description": "Invoice Period End Date" } }, - "required": ["InvStDt", "InvEndDt"] + "required": ["InvStDt ", "InvEndDt "] }, "PrecDocDtls": { "type": "object", @@ -631,22 +731,25 @@ "type": "string", "minLength": 1, "maxLength": 16, - "pattern": "^[1-9A-Z]{1}[0-9A-Z/-]{1,15}$" + "pattern": "^[1-9A-Z]{1}[0-9A-Z/-]{1,15}$", + "description": "Reference of Original Invoice" }, "InvDt": { "type": "string", "maxLength": 10, "minLength": 10, - "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]" + "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", + "description": "Date of Orginal Invoice" }, "OthRefNo": { "type": "string", "minLength": 1, - "maxLength": 20 + "maxLength": 20, + "description": "Other Reference" } - }, - "required": ["InvNo", "InvDt"] + } }, + "required": ["InvNo", "InvDt"], "ContrDtls": { "type": "object", "properties": { @@ -654,117 +757,132 @@ "type": "string", "minLength": 1, "maxLength": 20, - "pattern": "^([0-9A-Za-z/-]){1,20}$" + "pattern": "^([0-9A-Za-z/-]){1,20}$", + "description": "Receipt Advice No." }, "RecAdvDt": { "type": "string", "minLength": 10, "maxLength": 10, - "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]" + "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", + "description": "Date of receipt advice" }, "TendRefr": { "type": "string", "minLength": 1, "maxLength": 20, - "pattern": "^([0-9A-Za-z/-]){1,20}$" + "pattern": "^([0-9A-Za-z/-]){1,20}$", + "description": "Lot/Batch Reference No." }, "ContrRefr": { "type": "string", "minLength": 1, "maxLength": 20, - "pattern": "^([0-9A-Za-z/-]){1,20}$" + "pattern": "^([0-9A-Za-z/-]){1,20}$", + "description": "Contract Reference Number" }, "ExtRefr": { "type": "string", "minLength": 1, "maxLength": 20, - "pattern": "^([0-9A-Za-z/-]){1,20}$" + "pattern": "^([0-9A-Za-z/-]){1,20}$", + "description": "Any other reference" }, "ProjRefr": { "type": "string", "minLength": 1, "maxLength": 20, - "pattern": "^([0-9A-Za-z/-]){1,20}$" + "pattern": "^([0-9A-Za-z/-]){1,20}$", + "description": "Project Reference Number" }, "PORefr": { "type": "string", "minLength": 1, "maxLength": 16, - "pattern": "^([0-9A-Za-z/-]){1,16}$" + "pattern": "^([0-9A-Za-z/-]){1,16}$", + "description": "PO Reference Number" }, "PORefDt": { "type": "string", "minLength": 10, "maxLength": 10, - "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]" + "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", + "description": "PO Reference date" } } } - }, - "required": ["InvStDt", "InvEndDt"] - }, - "AddlDocDtls": { - "type": "Array", - "AddlDocument": { - "type": "object", - "properties": { - "Url": { - "type": "string", - "minLength": 3, - "maxLength": 100 - }, - "Docs": { - "type": "string", - "minLength": 3, - "maxLength": 1000 - }, - "Info": { - "type": "string", - "minLength": 3, - "maxLength": 1000 - } - } } }, + "AddlDocDtls": { + "type": "Array", + "properties": { + "Url": { + "type": "string", + "minLength": 3, + "maxLength": 100, + "description": "Supporting document URL" + }, + "Docs": { + "type": "string", + "minLength": 3, + "maxLength": 1000, + "description": "Supporting document in Base64 Format" + }, + "Info": { + "type": "string", + "minLength": 3, + "maxLength": 1000, + "description": "Any additional information" + } + } + }, + "ExpDtls": { "type": "object", "properties": { "ShipBNo": { "type": "string", "minLength": 1, - "maxLength": 20 + "maxLength": 20, + "description": "Shipping Bill No." }, "ShipBDt": { "type": "string", "minLength": 10, "maxLength": 10, - "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]" + "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", + "description": "Shipping Bill Date" }, "Port": { "type": "string", "minLength": 2, "maxLength": 10, - "pattern": "^[0-9A-Za-z]{2,10}$" + "pattern": "^[0-9A-Za-z]{2,10}$", + "description": "Port Code. Refer the master" }, "RefClm": { "type": "string", "minLength": 1, - "maxLength": 1 + "maxLength": 1, + "description": "Claiming Refund. Y/N" }, "ForCur": { "type": "string", "minLength": 3, - "maxLength": 16 + "maxLength": 16, + "description": "Additional Currency Code. Refer the master" }, "CntCode": { "type": "string", "minLength": 2, - "maxLength": 2 + "maxLength": 2, + "description": "Country Code. Refer the master" }, "ExpDuty": { "type": "number", "minimum": 0, - "maximum": 999999999999.99 + "maximum": 999999999999.99, + "description": "Export Duty" } } }, @@ -774,46 +892,54 @@ "TransId": { "type": "string", "minLength": 15, - "maxLength": 15 + "maxLength": 15, + "description": "Transporter GSTIN" }, "TransName": { "type": "string", "minLength": 3, - "maxLength": 100 + "maxLength": 100, + "description": "Transporter Name" }, "TransMode": { "type": "string", "maxLength": 1, "minLength": 1, - "enum": ["1", 2, 3, 4] + "enum": ["1", "2", "3", "4"], + "description": "Mode of Transport" }, "Distance": { "type": "number", "minimum": 1, - "maximum": 9999 + "maximum": 9999, + "description": "Distance" }, "TransDocNo": { "type": "string", "minLength": 1, "maxLength": 15, - "pattern": "^([0-9A-Z/-]){1,15}$" + "pattern": "^([0-9A-Z/-]){1,15}$", + "description": "Tranport Document Number" }, "TransDocDt": { "type": "string", "minLength": 10, "maxLength": 10, - "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]" + "pattern": "[0-3][0-9]/[0-1][0-9]/[2][0][1-2][0-9]", + "description": "Transport Document Date" }, "VehNo": { "type": "string", "minLength": 4, - "maxLength": 20 + "maxLength": 20, + "description": "Vehicle Number" }, "VehType": { "type": "string", "minLength": 1, "maxLength": 1, - "enum": ["O", "R"] + "enum": ["O", "R"], + "description": "Vehicle Type" } }, "required": ["Distance"] diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index 8e2b154ffd0..11284852484 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -60,10 +60,16 @@ def get_trans_details(invoice): elif invoice.gst_category == 'Deemed Export': supply_type = 'DEXP' if not supply_type: - return _('Invalid invoice transaction category.') + rr, sez, overseas, export = bold('Registered Regular'), bold('SEZ'), bold('Overseas'), bold('Deemed Export') + frappe.throw( + _('GST category should be one of {}, {}, {}, {}').format(rr, sez, overseas, export), + title=_('Invalid Supply Type') + ) return frappe._dict(dict( - tax_scheme='GST', supply_type=supply_type, reverse_charge=invoice.reverse_charge + tax_scheme='GST', + supply_type=supply_type, + reverse_charge=invoice.reverse_charge )) def get_doc_details(invoice): @@ -75,7 +81,11 @@ def get_doc_details(invoice): invoice_name = invoice.name invoice_date = format_date(invoice.posting_date, 'dd/mm/yyyy') - return frappe._dict(dict(invoice_type=invoice_type, invoice_name=invoice_name, invoice_date=invoice_date)) + return frappe._dict(dict( + invoice_type=invoice_type, + invoice_name=invoice_name, + invoice_date=invoice_date + )) def get_party_details(address_name): address = frappe.get_all('Address', filters={'name': address_name}, fields=['*'])[0] @@ -127,16 +137,11 @@ def get_item_list(invoice): item.batch_expiry_date = format_date(item.batch_expiry_date, 'dd/mm/yyyy') if item.batch_expiry_date else None item.qty = abs(item.qty) item.unit_rate = abs(item.base_price_list_rate) if item.discount_amount else abs(item.base_net_rate) - item.total_amount = abs(item.unit_rate * item.qty) + item.gross_amount = abs(item.unit_rate * item.qty) item.discount_amount = abs(item.discount_amount * item.qty) - item.base_amount = abs(item.base_net_amount) - item.tax_rate = 0 - item.igst_amount = 0 - item.cgst_amount = 0 - item.sgst_amount = 0 - item.cess_rate = 0 - item.cess_amount = 0 - item.other_charges = 0 + item.taxable_value = abs(item.base_net_amount) + item.tax_rate = item.cess_rate = item.other_charges = 0 + item.cgst_amount = item.sgst_amount = item.igst_amount = item.cess_amount = 0 for t in invoice.taxes: item_tax_detail = json.loads(t.item_wise_tax_detail).get(item.item_code) if t.account_head in gst_accounts_list: @@ -210,8 +215,8 @@ def get_return_doc_reference(invoice): )) def get_eway_bill_details(invoice): - if not invoice.distance: - frappe.throw(_('Distance is mandatory for E-Way Bill generation'), title=_('E Invoice Validation Failed')) + if invoice.is_return: + frappe.throw(_('E-Way Bill cannot be generated for Credit Notes & Debit Notes'), title=_('E Invoice Validation Failed')) mode_of_transport = { 'Road': '1', 'Air': '2', 'Rail': '3', 'Ship': '4' } vehicle_type = { 'Regular': 'R', 'Over Dimensional Cargo (ODC)': 'O' } @@ -220,7 +225,7 @@ def get_eway_bill_details(invoice): gstin=invoice.gst_transporter_id, name=invoice.transporter_name, mode_of_transport=mode_of_transport[invoice.mode_of_transport], - distance=invoice.distance, + distance=invoice.distance or 0, document_name=invoice.lr_no, document_date=format_date(invoice.lr_date, 'dd/mm/yyyy'), vehicle_no=invoice.vehicle_no, @@ -232,6 +237,7 @@ def make_einvoice(doctype, name): invoice = frappe.get_doc(doctype, name) schema = read_json('einv_template') + trans_details = get_trans_details(invoice) item_list = get_item_list(invoice) doc_details = get_doc_details(invoice) value_details = get_value_details(invoice) @@ -272,7 +278,7 @@ def make_einvoice(doctype, name): einvoice = json.loads(einvoice) validations = json.loads(read_json('einv_validation')) - errors = validate_einvoice(validations, einvoice, []) + errors = validate_einvoice(validations, einvoice) if errors: frappe.log_error(title="E Invoice Validation Failed", message=json.dumps(errors, default=str, indent=4)) if len(errors) > 1: @@ -312,7 +318,9 @@ def validate_einvoice(validations, einvoice, errors=[]): if value_type == 'string': einvoice[fieldname] = str(value) elif value_type == 'number': - einvoice[fieldname] = flt(value, 2) if fieldname not in ['Pin', 'Distance'] else int(value) + is_integer = '.' not in str(field_validation.get('maximum')) + einvoice[fieldname] = flt(value, 2) if not is_integer else cint(value) + value = einvoice[fieldname] max_length = field_validation.get('maxLength') minimum = flt(field_validation.get('minimum')) @@ -320,12 +328,12 @@ def validate_einvoice(validations, einvoice, errors=[]): pattern_str = field_validation.get('pattern') pattern = re.compile(pattern_str or '') - label = field_validation.get('label') or fieldname + label = field_validation.get('description') or fieldname if value_type == 'string' and len(value) > 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 value_type == 'number' and (value > maximum or value < minimum): + errors.append(_('{} {} should be between {} and {}').format(label, value, minimum, maximum)) if pattern_str and not pattern.match(value): errors.append(field_validation.get('validationMsg'))