Saudi Arabia’s General Authority of Zakat and Tax
(GAZT) published a draft resolution for E-Invoicing.
E-Invoicing will be implemented in 2 Phases.
Phase I: All invoices should be electronically and
for B2C, electronic invoice should have QR code. Starting date 4 DEC 2021.
Phase II: Integration with Saudi Arabia’s General
Authority of Zakat and Tax (GAZT) System. Starting date 1 JAN 2023.
In this article, I am trying to cover Phase I
meaning how to add QR code in Sales invoice.
Lets start..and hope you will enjoy it.
First you need to download
MessagingToolkit.QRCode.dll file from here.
Copy MessagingToolkit.QRCode.dll and paste in
Dynamics AX client directory as shown in below screen shot.
Add new field in Temp table "SalesInvoiceTmp".
Add new display method "qrcode" in table
"CustInvoiceJour".
display container qrcode()
{
Bindata bindata = new Bindata();
Image Imgobj;
FileIOPermission perm = null;
System.Drawing.Image img;
System.Drawing.Bitmap obj;
Filename filename;
Filepath _path;
container con;
str GRate,CustName,CustNumber,GTot,PONox,Company,Amount1,InvDate1,SalesOrder;
real Amount;
date InvDate;
MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
;
CustNumber=this.custTable_InvoiceAccount().AccountNum;
CustName=this.custTable_InvoiceAccount().name();
Company=this.custTable_InvoiceAccount().company();
InvDate= this.InvoiceDate;
Amount = this.InvoiceAmountMST;
SalesOrder=this.SalesId;
InvDate1=date2str(InvDate,123,2,DateSeparator::Dot,2,DateSeparator::Dot,4,0);
Amount1=num2str(Amount,2,2,1,0);
obj = new System.Drawing.Bitmap(encoder.Encode("Cust No:" +CustNumber+"Cust Name: "+CustName+" Date: "+ InvDate1 +" Amount: "+ Amount1 +" Seller: "+ Company));\\Note you can add required as per need.This is just example.
filename = @"C:\temp\newPhoto.bmp";
perm = new FileIOPermission(filename, 'RW');
perm.assert();
obj.Save(filename,System.Drawing.Imaging.ImageFormat::get_Bmp());
bindata.loadFile(filename);
con = bindata.getData();
return con;
}
Add qrcode()
method to SalesInvoiceDP class.
Now add
created QRcode field to SSRS report.
In AOT,Find
the Visual Studio Project as given below and right-click-->edit.
Refresh
Datasets of SalesInvoiceReport in Visual Studio.
Select
report ; Right-click-->Edit using designer.
Insert image
in report designer.
Set the
properties as shown below of inserted image. And image size 1.2inch,1.2inch
Rebuild,deploy
and add to AOT.
Compile AX and restart the AOS service before generating Sales invoice.
Finally try
to invoice Sales order.
Completed.
Hope you enjoyed it.
Thank you.
Syed Faiz
Abbas
Hi Syed Can you share your email id please. vaibhawkj@gmail.com
ReplyDeletefaizabbas@outlook.com
Deletei am getting error MessagingToolkit.QRCode.Codec.QRCodeEncoder is not referenced. while executing the report my report server is not same as AOS server.
ReplyDeleteMake sure copy MessagingToolkit.QRCode.dll and paste in Dynamics AX client/Server directory. Then restart AOS it will work.
DeleteLet me know if you face any problem.
copying at client also work it. thanks.
DeleteAssalam aly Kum Syed Bhai! Great Job.
DeleteBut Still Received this error after full CIL as well. pls advise
Assembly containing type MessagingToolkit.QRCode.Codec.QRCodeEncoder is not referenced.
Object 'CLRObject' could not be created
Hi Syed,
ReplyDeleteThanks for your very useful code.
Tiny update to avoid the limitation of the string length (122 characters only) is to add:
encoder.set_QRCodeVersion(0);
after the line of:
MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
Hi Syed,
ReplyDeleteI'm getting this error while adding qrcode method to CustInvoiceJour
"Variable MessagingToolkit has not been declared."
dll file has been added to client and server folders , I did full compile and same issue
any suggestions
Follow these steps correctly:
Delete1- Register the Dlls file as references.
2- Import the xpo project.
3- Stop the AOS service.
4- Delete all files in XppIL folders (Only files).
5- Start the AOS service again.
6- Compile the AOS from AOT (F7).
7- Generate Incremental CIL.
Note:
DeleteStep 2 can be skipped if you follow Syed process on the same server.
What I did, is tried the process on TEST server then export from TEST and Import into Live server following the 7 steps.
Variable MessagingToolkit has not been declared, error while saving in the display method underCustInvoiceJour.
ReplyDeleteHi Ramji,
ReplyDeleteWhat error you are getting. Share error message.
Thanks,
what about storage of invoice on public domain. do you have any understanding of this requirement of ZATCA ?
ReplyDeleteHi syed,
DeletePhase 1, no need to store invoices on public domain.
Dear All
ReplyDeletewe're using Dynamics GP 10 can help us to implement the same above topic
thanks in advance
Hi Mustafa,
DeleteSorry, I do not know about GP at all.
Hi Syed,
ReplyDeleteThank you very much for your valuable post.
I followed your instructions and it worked successfully, but I'm having trouble if the string contains Arabic characters. Where the text is required to be in Arabic. How to solve this problem and include UTF-8 format?
Hi Ahmed,
ReplyDeleteSorry to say but Arabic characters. I do not know.
Assembly containing type MessagingToolkit.QRCode.Codec.QRCodeEncoder is not referenced.
ReplyDeleteObject 'CLRObject' could not be created
Hi Umair Khan,
ReplyDeleteMake sure copy MessagingToolkit.QRCode.dll and paste in Dynamics AX client/Server directory. Then restart AOS it will work.
Let me know if you face any problem.
Regards,
Syed
Already paste it than to same error... is it required to enables
Delete"Enable the hot-swapping of assemblies for each development session"?
Will this QRCode after scanning values will display in encoded base64 format? or normal text
ReplyDeleteHi,
DeleteIt will display normal text(string).
Best Regard,
Syed Faiz Abbas
Thank you for reply, but as per the ZATCA requirement the QRCode Values should be encoded in TLV format and then HEX and then to base64 format
DeleteHi,
DeleteI don't think so, For Phase 1 implementation.
If you have any document/article from ZATCA.Please share.
Thanks,
Syed Faiz Abbas
Pls check your email on faizabbas@outlook.com. i sent the document which was shared by Zatka recently fyi.
DeleteI will check the document.
DeleteThanks,
Syed Faiz Abbas
I hope you have gone through the document. Just eager to know that you are going to update or not this requirement in the Messaging Toolkit DLL?
DeleteYes, Not yet.
DeleteThanks,
Syed Faiz Abbas
Hi Syed, Thanks for this valuable post, Do we need to follow same procedure for D365FO as well?
ReplyDeleteHi Noor,
ReplyDeleteYou can go through below link.
https://dynamicsax-fico.com/2020/08/19/do-you-know-how-to-embed-qr-payment-codes-in-customer-invoices/
regards,
Syed Faiz Abbas
Hi Syed, I have a question about D365's capabilities to meet any Arabic language requirements with regards to printing reports. Reports such as VAT, WHT, and other ZAKAT specific reports. Some of these reports are only available with the (SA) localization. For example, in the Tax module I have the option to print a "Saudi Arabia monthly withholding tax report." This is an SSRS report that comes pre-formatted, and even has a unique logo I assume represents their sales tax authority. However, I am unable to print this report in Arabic. I have tried changing the my user language and the legal entity language, but it only prints in English.
ReplyDeleteI'm helping roll out a new legal entity for a company that's going to do business in Saudi Arabia, and I would imagine these reports must be submitted to authorities in Arabic. Perhaps I'm missing something, but wouldn't a report specifically made for Saudi Arabia have a translation component to it?