frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
20.22k stars 7.06k forks source link

import purchases using e-invoice [india] #30919

Closed test2a closed 1 year ago

test2a commented 2 years ago

Is your feature request related to a problem? Please describe. when we generate an e-invoice, we are indicating that we have uploaded the invoice on GST portal. why not take it one step further and use the "signed json" that gets generated once an e-invoice is generated and import purchases data using that file?

Describe the solution you'd like use the signed json file and auto input data into purchases using the file. this would result in less manual data entry, reducing errors

https://taxguru.in/goods-and-service-tax/e-invoicing-e-invoice-gst.html

"The digitally signed JSON with IRN will be transferred to the seller along with the QR code and the said details then will be automatically uploaded on the GSTN Portal and the E-Way Bill portal. The GST system will update the details in ANX-1 of the seller and ANX-2 of the buyer, which will in turn determine the tax liability and ITC."

https://taxguru.in/goods-and-service-tax/signed-qr-code-e-invoicing-system-gst-faqs.html

https://lio.io/blog/how-to-download-e-invoice-from-gst-portal/

https://einvoice1.gst.gov.in/Documents/SampleJson.json

https://einvoice1.gst.gov.in/Others/VSignedInvoice

ok. so if you use https://jwt.io/ and copy paste "signed invoice" data from the sample signed json file, you will get the data so its just a matter of implementing this funcitonality....

test2a commented 2 years ago
eyJhbGciOiJSUzI1NiIsImtpZCI6IjExNUY0NDI2NjE3QTc5MzhCRTFCQTA2REJFRTkxQTQyNzU4NEVEQUIiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJFVjlFSm1GNmVUaS1HNkJ0dnVrYVFuV0U3YXMifQ.eyJkYXRhIjoie1wiQWNrTm9cIjoxMTIwMTAwMDAwMTE0NzQsXCJBY2tEdFwiOlwiMjAyMC0wOC0wNSAyMjo1NTowMFwiLFwiSXJuXCI6XCJhZmRjYzMyYTBlYWEzYTA1NGNmZmNkMjUxODg0ZDNlM2Y0ZjcyNmI3NWM4OTQzZTdkMzVmYmFiYzgyZjA1ZDhhXCIsXCJWZXJzaW9uXCI6XCIxLjAxXCIsXCJUcmFuRHRsc1wiOntcIlRheFNjaFwiOlwiR1NUXCIs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g61TOht4jqErRF7m2wVv8r5GsIDQnVkwN0zdDrcZZpVn9pEIQjdZ-kLPg

this data from the signed json file when put into https://jwt.io/ gives us

{
  "data": "{\"AckNo\":112010000011474,\"AckDt\":\"2020-08-05 22:55:00\",\"Irn\":\"afdcc32a0eaa3a054cffcd251884d3e3f4f726b75c8943e7d35fbabc82f05d8a\",\"Version\":\"1.01\",\"TranDtls\":{\"TaxSch\":\"GST\",\"SupTyp\":\"B2B\",\"RegRev\":\"N\",\"IgstOnIntra\":\"N\"},\"DocDtls\":{\"Typ\":\"INV\",\"No\":\"CTDN23456\",\"Dt\":\"05/08/2020\"},\"SellerDtls\":{\"Gstin\":\"37BZNPM9430M1KL\",\"LglNm\":\"SRI LAKSHMI INDUSTRIAL PVT LTD\",\"TrdNm\":\"SRI LAKSHMI INDUSTRIAL PVT LTD\",\"Addr1\":\"#123 . NETHAJI STREET\",\"Addr2\":\"GANDHI NAGAR\",\"Loc\":\"KURNOOL\",\"Pin\":518001,\"Stcd\":\"37\",\"Ph\":\"9030457736\",\"Em\":\"lakshmi123@gmail.com\"},\"BuyerDtls\":{\"Gstin\":\"03BZNPM9430M1KL\",\"LglNm\":\"VARSHA\",\"TrdNm\":\"VARSHA\",\"Pos\":\"03\",\"Addr1\":\"NO 123\",\"Addr2\":\"AMEERPET\",\"Loc\":\"PUNJAB\",\"Pin\":140118,\"Ph\":\"9066517875\",\"Em\":\"varsha123@gmail.com\",\"Stcd\":\"03\"},\"ItemList\":[{\"ItemNo\":1,\"SlNo\":\"1\",\"IsServc\":\"N\",\"PrdDesc\":\"ARTICLES FOR THE CONVEYANCE OR PACKING OF GOODS\",\"HsnCd\":\"39231010\",\"Qty\":150,\"FreeQty\":0,\"Unit\":\"BAG\",\"UnitPrice\":100,\"TotAmt\":15000,\"Discount\":50,\"PreTaxVal\":0,\"AssAmt\":14950,\"GstRt\":5,\"IgstAmt\":747.5,\"CgstAmt\":0,\"SgstAmt\":0,\"CesRt\":5,\"CesAmt\":747.5,\"CesNonAdvlAmt\":0,\"StateCesRt\":0,\"StateCesAmt\":0,\"StateCesNonAdvlAmt\":0,\"OthChrg\":100,\"TotItemVal\":16545}],\"ValDtls\":{\"AssVal\":14950,\"CgstVal\":0,\"SgstVal\":0,\"IgstVal\":747.5,\"CesVal\":747.5,\"StCesVal\":0,\"Discount\":100,\"OthChrg\":200,\"RndOffAmt\":5,\"TotInvVal\":16650}}",
  "iss": "NIC"
}

this is all what we need to import this particular purchases invoice into the software,

there will be one issue of different item names which can be solved by having a "map bill data to inventories" option whereby we link each item in the bill to what we have in stock.

maharshivpatel commented 2 years ago

The digitally signed JSON with IRN will be transferred to the " seller " not the purchaser (buyer) so this will only work if seller sends you the JSON file. currently, this is highly unlikely however what you have proposed here is something that will be possible (viable) once GST E-Invoice API will implement an option to download JSON of your purchases (inwards supply).

test2a commented 2 years ago

Yes.

https://einv-apisandbox.nic.in/version1.03/generate-irn.html#overview

This link says when we send a request, a signed Json is given as a response which is used to generate the Qr Code and contains the IRN and ack no.

This Is the signed Json we would need.

Yes. The seller only gets this file for now but why can't we email the signed Json + PDF to the customer ? Or encode the entire signed json into a qr code at the end of the invoice so that the end user can use a qr code scanner to convert it to json and then import it?

We could take it even further with a short URL that has the raw json that gets generated on the seller side once an e invoice is created which gets printed on the invoice. At the receiver end, same thing. Type the URL to download and import the document.

My idea is, if we are able to successfully able to import the signed json as a customer that someone sent us, the distribution part shouldn't even be an issue. There are dozens of ways of invoice propagation.

My understanding is, when we generate an e-invoice, we are using this signed json but not keeping it. Once the data is extracted, all we have to do is allow user to save + send it.

Someone who has worked on e-invoice api could give some idea.

test2a commented 2 years ago

https://github.com/frappe/erpnext/pull/23455/commits/1d90a543e2c3f47ee7b57a4f3910ce43b3506241

This is the PR that says apparently it decodes the signed json so I am able to say that we do get this signed json from api so why not allow user to save it?

maharshivpatel commented 2 years ago

decoded json is already saved under "signed_einvoice" field of sales invoice doctype (unless you are talking about encoded json).

maharshivpatel commented 2 years ago

if I understand correctly you are suggesting 2 features here.

  1. save & send signed json to the customer as an attachment similar to sending a pdf.
  2. import the json file that the supplier sent you and auto-populate purchase based on that.

from a technical standpoint it is possible for sure. I haven't done any extensive research on this but earlier when I said it is not possible (viable) for now what I meant was it is not practical right now as most ERPs and legacy systems don’t support einvoice signed Json import-export. I was trying to understand the use case here.

Use cases I found are:

  1. if both customer and supplier use erpnext.
  2. Customer's ERP implements file export on their system.

Do you currently have a use case that requires these features? can you share details on how you will use this feature?

test2a commented 2 years ago

@maharshivpatel yeah. the 2 features you mentioned are what i am after.

the use cases:

  1. as a business, you deal with dozens or hundreds of purchase invoices on a daily basis. currently your accounting staff is trained to do the "data entry" . this step can be eliminated completely. imagine you give all your suppliers a single email address and you use software to parse emails containing these json files and auto import them. look at the collective time saved over say 100 businesses or even 1000 when automation would happen. errors would be greatly reduced.

  2. yes, since only erpnext if implemented will have that feature, at least all erpnext users would get to use it regardless of their e-invoicing generation or not because someone who is not yet above 20 crore still buys from a supplier who does generate e-invoices so i wont be a problem then.

  3. currently only above 20 Crore turnover businesses are made mandatory to issue e-invoices but there are discussions that the government will reduce that limit to 5 crore from next year. by that time, a lot more people will be exposed to generating e-invoices and a lot more would be getting their purchases as e-invoices.

  4. if and when we have a working demo, there is a gst developer google group where we can pitch this to all major and minor accounting softwares and GSPs and i am sure it will be picked up, why? because it is taking e-invoicing to the complete cycle, not just the currently half implementation.

  5. people, including me have spent a lot of time and wasted most of it into building systems like https://github.com/naiveHobo/InvoiceNet which in theory would be used to take a photo of an invoice and the software could ocr then parse it into a digital invoice that enters itself into the system. With e-invoices, that step is made obsolete because now we have digital data from the start that can be reused.

  6. think of it this way. once as an erpnext user, you are getting auto imports for bills from one supplier, you will demand/look for other suppliers to do the same they will pressure their software vendors to implement this. in this fast environment, it wont take long before one major player implements it and then everyone else will rush to do the same.

  7. for my part, i am helping build "gnukhata", which is still not production ready as yet but it will have this feature in the coming months so its only a matter of time when people will feel the need for it because it saves "time"

deepeshgarg007 commented 1 year ago

@test2a Closing this as all India Compliance has been moved to a separate app. You can make an issue on https://github.com/resilient-tech/india-compliance is this still doesn't exist