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