web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
New Discussion

GST upload for Indian Clients.

(0) ShareShare
ReportReport
Posted on by 150

Folks we were doing a lot of manual entries whenever we receive a new HSN. We had to create this for all the states in India and for both CGST,SGST & IGST. We had a requirement to upload the tax on inventory for FnB business as well. 

We created one job to do all these with the template as provided below(csv).

path company hsnCode sac value taxType frmDate toDate state incTax frmVal toVal itmGrp
Header/Lines/GST/CGST/Rate DAT 123 9.00000 CGST 01/07/2017 31/03/2025 KL No 0 0 1234

static void hsnUpload()
{
CommaTextIo file;
container rec;
Dialog dlg;
DialogField dlgFld;
Str1260 path,company,hsnCode,taxType,sac,state,incTax,itmGrp;
real value,frmVal,toVal;
date frmDate,toDate;
int row;
RecId lookupVes;

TaxRuntimeDocComponentMeasure docComponetMeasure;
TaxRuntimeLookupCondition lookupCondition,lookupConditionSel,lookupConditionUp,lookupConditionUpdate;
TaxRuntimeLookupMeasureResult lookUpResult,lookUpResultSel,lookUpResultUp;
TaxRuntimeLookupMeasureResultDetail resultDetail;
Ledger ledger;
HSNCodeTable_IN hsnMaster;
LineNum POLineNo, lineNo;
;

dlg = new Dialog("Upload charge allocation");
dlgFld = dlg.addField(ExtendedTypeStr(FilenameOpen));

row = 2;

if (dlg.run())
{
file = new CommaTextIo(dlgFld.value(), 'r');
file.inFieldDelimiter(',');

rec = file.read(); // Header
rec = file.read(); // First Record

lineNo = 0;

while (rec)
{
lineNo++;
path = conPeek(rec, 1);
company = conPeek(rec, 2);
hsnCode = conPeek(rec, 3);
sac = conPeek(rec, 4);
value = conPeek(rec, 5);
taxType = conPeek(rec, 6);
frmDate = str2Date(conPeek(rec, 7), 123);// conPeek(rec, 7);
toDate = str2Date(conPeek(rec, 8), 123);//conPeek(rec, 8);
state = conPeek(rec, 9);
incTax = conPeek(rec, 10);
frmVal = conPeek(rec, 11);
toVal = conPeek(rec, 12);
itmGrp = conPeek(rec, 13);

if(taxType == "LICGST")
lookupVes = 5637145762;
else if(taxType == "LISGST")
lookupVes = 5637145775;
else if(taxType == "LIIGST")
lookupVes = 5637145785;

else if(taxType == "CGST")
lookupVes = 5637145690;
else if(taxType == "SGST")
lookupVes = 5637145695;
else if(taxType == "IGST")
lookupVes = 5637145699;

select docComponetMeasure
where docComponetMeasure.Path == path
&& docComponetMeasure.DocContext == 5637145327; //

select ledger
where ledger.Name == company;

select firstOnly1 lookupConditionSel
order by lookupConditionSel.RecId desc
where lookupConditionSel.Ledger == ledger.RecId
&& lookupConditionSel.LookupVersion == lookupVes; // 5637145762--> CGST, 5637145785-->IGST, 5637145775-->SGST
if(taxType == 'LICGST' || taxType == 'LISGST' || taxType == 'LIIGST' )
{
if(hsnCode != '' && sac == '')// Update or insert HSN
{
select lookupConditionUp
where lookupConditionUp.Ledger == ledger.RecId
&& lookupConditionUp.LookupVersion == lookupVes
&& (lookupConditionUp.DimValue1 == hsnCode );// || lookupConditionUp.DimValue2 == sac);

if(!lookupConditionUp)
{
ttsBegin;
lookupCondition.Ledger = ledger.RecId;
lookupCondition.LookupVersion = lookupVes; // 5637145762--> CGST, 5637145785-->IGST, 5637145775-->SGST
//lookupCondition.NotEmptyDimValueColumnCount = 16;
lookupCondition.SortNumber = lookupConditionSel.SortNumber + 1;
lookupCondition.DimValue1 = hsnCode;
lookupCondition.DimValue2 = sac;
lookupCondition.insert();
ttsCommit;

ttsBegin;
lookUpResult.LookupCondition = lookupCondition.RecId;
lookUpResult.OwnerRecId = docComponetMeasure.RecId;
lookUpResult.OwnerTableId = 105361;
lookUpResult.insert();
ttsCommit;

select firstOnly1 lookUpResultSel
order by lookUpResultSel.RecId desc;

ttsBegin;
resultDetail.LookupMeasureResult = lookUpResult.RecId;
resultDetail.Measure = 5637145351; /// SELECT RECID FROM TAXRUNTIMEMEASURE WHERE NAME='Load on Inventory Percentage' and DEFCONTEXT='5637145327'
resultDetail.Value = value;
resultDetail.insert();
ttsCommit;
}
else //Update
{
select lookUpResultUp
where lookUpResultUp.LookupCondition == lookupConditionUp.RecId
&& lookUpResultUp.OwnerRecId == docComponetMeasure.RecId
&& lookUpResultUp.OwnerTableId == 105361;

while select forUpdate resultDetail
where resultDetail.LookupMeasureResult == lookUpResultUp.RecId
&& resultDetail.Measure == 5637145351
{
ttsBegin;
resultDetail.Value = value;
resultDetail.update();
ttsCommit;
}
}
}
else if(hsnCode == '' && sac != '')// update or insert SAC
{
select lookupConditionUp
where lookupConditionUp.Ledger == ledger.RecId
&& lookupConditionUp.LookupVersion == lookupVes
&& (lookupConditionUp.DimValue2 == sac );// || lookupConditionUp.DimValue2 == sac);

if(!lookupConditionUp)
{
ttsBegin;
lookupCondition.Ledger = ledger.RecId;
lookupCondition.LookupVersion = lookupVes; // 5637145762--> CGST, 5637145785-->IGST, 5637145775-->SGST
//lookupCondition.NotEmptyDimValueColumnCount = 16;
lookupCondition.SortNumber = lookupConditionSel.SortNumber + 1;
lookupCondition.DimValue1 = hsnCode;
lookupCondition.DimValue2 = sac;
lookupCondition.insert();
ttsCommit;

ttsBegin;
lookUpResult.LookupCondition = lookupCondition.RecId;
lookUpResult.OwnerRecId = docComponetMeasure.RecId;
lookUpResult.OwnerTableId = 105361;
lookUpResult.insert();
ttsCommit;

select firstOnly1 lookUpResultSel
order by lookUpResultSel.RecId desc;

ttsBegin;
resultDetail.LookupMeasureResult = lookUpResult.RecId;
resultDetail.Measure = 5637145351; /// SELECT RECID FROM TAXRUNTIMEMEASURE WHERE NAME='Load on Inventory Percentage' and DEFCONTEXT='5637145327'
resultDetail.Value = value;
resultDetail.insert();
ttsCommit;
}
else //Update
{
select lookUpResultUp
where lookUpResultUp.LookupCondition == lookupConditionUp.RecId
&& lookUpResultUp.OwnerRecId == docComponetMeasure.RecId
&& lookUpResultUp.OwnerTableId == 105361;

while select forUpdate resultDetail
where resultDetail.LookupMeasureResult == lookUpResultUp.RecId
&& resultDetail.Measure == 5637145351
{
ttsBegin;
resultDetail.Value = value;
resultDetail.update();
ttsCommit;
}
}
}
}
else // Insert or update standard GST--------------------------------------------------------------------------------------------------------------
{
if(hsnCode != '' && sac == '')// Update or insert HSN
{
select lookupConditionUp
where lookupConditionUp.Ledger == ledger.RecId
&& lookupConditionUp.LookupVersion == lookupVes
&& lookupConditionUp.DimValue2 == hsnCode
&& lookupConditionUp.DimValue3 == itmGrp
&& lookupConditionUp.DimValue1 == state
&& lookupConditionUp.DimValue5 == incTax// || lookupConditionUp.DimValue2 == sac);
//&& lookupConditionUp.DateRangeFrom1 == frmDate
//&& lookupConditionUp.DateRangeTo1 == toDate
&& lookupConditionUp.ValueRangeFrom2 == frmVal
&& lookupConditionUp.ValueRangeTo2 == toVal;
if(!lookupConditionUp)
{
ttsBegin;
lookupCondition.Ledger = ledger.RecId;
lookupCondition.LookupVersion = lookupVes; // 5637145762--> CGST, 5637145785-->IGST, 5637145775-->SGST
//lookupCondition.NotEmptyDimValueColumnCount = 16;
lookupCondition.SortNumber = lookupConditionSel.SortNumber + 1;
lookupCondition.DimValue2 = hsnCode;
lookupCondition.DimValue1 = state;
lookupCondition.DateRangeFrom1 = frmDate;
lookupCondition.DateRangeTo1 = toDate;
lookupCondition.DimValue5 = incTax;
lookupCondition.DimValue3 = itmGrp;
lookupCondition.ValueRangeFrom2 = frmVal;
lookupCondition.ValueRangeTo2 = toVal;
lookupCondition.insert();
ttsCommit;

ttsBegin;
lookUpResult.LookupCondition = lookupCondition.RecId;
lookUpResult.OwnerRecId = docComponetMeasure.RecId;
lookUpResult.OwnerTableId = 105361;
lookUpResult.insert();
ttsCommit;

select firstOnly1 lookUpResultSel
order by lookUpResultSel.RecId desc;

ttsBegin;
resultDetail.LookupMeasureResult = lookUpResult.RecId;
resultDetail.Measure = 5637145349; /// SELECT RECID FROM TAXRUNTIMEMEASURE WHERE NAME='Load on Inventory Percentage' and DEFCONTEXT='5637145327'
resultDetail.Value = value;
resultDetail.insert();
ttsCommit;
}
else //Update
{

while select forUpdate lookupConditionUpdate
where lookupConditionUpdate.Ledger == ledger.RecId
&& lookupConditionUpdate.LookupVersion == lookupVes
&& lookupConditionUpdate.DimValue2 == hsnCode
&& lookupConditionUpdate.DimValue1 == state
&& lookupConditionUp.DimValue3 == itmGrp
&& lookupConditionUpdate.DimValue5 == incTax// || lookupConditionUp.DimValue2 == sac);
//&& lookupConditionUp.DateRangeFrom1 == frmDate
//&& lookupConditionUp.DateRangeTo1 == toDate
&& lookupConditionUpdate.ValueRangeFrom2 == frmVal
&& lookupConditionUpdate.ValueRangeTo2 == toVal
{
ttsBegin;
lookupConditionUpdate.Ledger = ledger.RecId;
lookupConditionUpdate.LookupVersion = lookupVes;
lookupConditionUpdate.DimValue2 = hsnCode;
lookupConditionUpdate.DimValue1 = state;
lookupConditionUpdate.DimValue5 = incTax;// || lookupConditionUp.DimValue2 == sac);
lookupConditionUpdate.DateRangeFrom1 = frmDate;
lookupConditionUpdate.DateRangeTo1 = toDate;
lookupConditionUpdate.ValueRangeFrom2 = frmVal;
lookupConditionUpdate.ValueRangeTo2 = toVal;
lookupConditionUp.DimValue3 = itmGrp ;
lookupConditionUpdate.update();
ttsCommit;
}

select lookUpResultUp
where lookUpResultUp.LookupCondition == lookupConditionUp.RecId
&& lookUpResultUp.OwnerRecId == docComponetMeasure.RecId
&& lookUpResultUp.OwnerTableId == 105361;

while select forUpdate resultDetail
where resultDetail.LookupMeasureResult == lookUpResultUp.RecId
&& resultDetail.Measure == 5637145349
{
ttsBegin;
resultDetail.Value = value;
resultDetail.update();
ttsCommit;
}
}
}
else if(hsnCode == '' && sac != '')// update or insert SAC
{
select lookupConditionUp
where lookupConditionUp.Ledger == ledger.RecId
&& lookupConditionUp.LookupVersion == lookupVes
&& (lookupConditionUp.DimValue4 == sac );// || lookupConditionUp.DimValue2 == sac);

if(!lookupConditionUp)
{
ttsBegin;
lookupCondition.Ledger = ledger.RecId;
lookupCondition.LookupVersion = lookupVes; // 5637145762--> CGST, 5637145785-->IGST, 5637145775-->SGST
//lookupCondition.NotEmptyDimValueColumnCount = 16;
lookupCondition.SortNumber = lookupConditionSel.SortNumber + 1;
lookupCondition.DimValue4 = sac;
lookupCondition.DimValue1 = state;
lookupCondition.DateRangeFrom1 = frmDate;
lookupCondition.DateRangeTo1 = toDate;
lookupCondition.DimValue5 = incTax;
lookupCondition.DimValue3 = itmGrp;
lookupCondition.ValueRangeFrom2 = frmVal;
lookupCondition.ValueRangeTo2 = toVal;
lookupCondition.insert();
ttsCommit;

ttsBegin;
lookUpResult.LookupCondition = lookupCondition.RecId;
lookUpResult.OwnerRecId = docComponetMeasure.RecId;
lookUpResult.OwnerTableId = 105361;
lookUpResult.insert();
ttsCommit;

select firstOnly1 lookUpResultSel
order by lookUpResultSel.RecId desc;

ttsBegin;
resultDetail.LookupMeasureResult = lookUpResult.RecId;
resultDetail.Measure = 5637145349; /// SELECT RECID FROM TAXRUNTIMEMEASURE WHERE NAME='Load on Inventory Percentage' and DEFCONTEXT='5637145327'
resultDetail.Value = value;
resultDetail.insert();
ttsCommit;
}
else //Update
{
select lookUpResultUp
where lookUpResultUp.LookupCondition == lookupConditionUp.RecId
&& lookUpResultUp.OwnerRecId == docComponetMeasure.RecId
&& lookUpResultUp.OwnerTableId == 105361;

while select forUpdate resultDetail
where resultDetail.LookupMeasureResult == lookUpResultUp.RecId
&& resultDetail.Measure == 5637145349
{
ttsBegin;
resultDetail.Value = value;
resultDetail.update();
ttsCommit;
}
}
}
}

row ++;
rec = file.read();
}
info(strfmt("%1 rows have been uploaded.",(row-2)));
}
}

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans