You can use the below code to fetch the HSN level GST component tax percentage(CGST,SGST,IGST). We shall pass the HSN code of the Item along with GST component eg.”IGST”, as parameters and can fetch respective GST percentage values..
public static TaxRuntimeTaxMeasureValue getgstvalue (HSNCode_IN _code ,str _gstcomponent)
{
TaxRuntimeDocComponentMeasure taxRuntimeDocComponentMeasure;
TaxRuntimeLookupCondition taxRuntimeLookupCondition;
TaxRuntimeLookupVersion taxRuntimeLookupVersion;
TaxRuntimeDocComponent taxRuntimeDocComponent;
TaxRuntimeLookup taxRuntimeLookup;
TaxSolutionScope taxSolutionScope;
TaxRuntimeDocContext taxRuntimeDocContext;
TaxRuntimeDocContextVersion taxRuntimeDocContextVersion;
TaxRuntimeLookupMeasureResult taxRuntimeLookupMeasureResult;
TaxRuntimeLookupMeasureResultDetail taxRuntimeLookupMeasureResultDetail;
HSNCode_IN code;
TaxSolutionScopeSetup taxSolutionScopeSetup = TaxSolutionScopeSetup::findByLedger(Ledger::current());
select taxSolutionScope
join taxSolutionScopeSetup
where taxSolutionScopeSetup.TaxSolutionScope == taxSolutionScope.RecId
join taxRuntimeDocContext
where taxRuntimeDocContext.TaxSolutionScope == taxSolutionScope.RecId
&& taxRuntimeDocContext.Solution == taxSolutionScope.Solution
join taxRuntimeDocComponent
where taxRuntimeDocComponent.DocContext == taxRuntimeDocContext.RecId
join taxRuntimeDocContextVersion
where taxRuntimeDocContextVersion.SolutionVersion == taxSolutionScope.SolutionVersion
&& taxRuntimeDocContextVersion.TaxRuntimeDocContext == taxRuntimeDocContext.RecId;
select taxRuntimeLookupVersion
where taxRuntimeLookupVersion.DocContextVersion == taxRuntimeDocContextVersion.RecId
join taxRuntimeLookup
where taxRuntimeLookup.RecId == taxRuntimeLookupVersion.Lookup
&& taxRuntimeLookup.DocContext == taxRuntimeDocContext.RecId
join taxRuntimeDocComponentMeasure
where taxRuntimeDocComponentMeasure.RecId == taxRuntimeLookup.LookupOwnerRecId
&& taxRuntimeDocComponentMeasure.DocContext == taxRuntimeDocContext.RecId
&& taxRuntimeDocComponentMeasure.Name =="Rate"
&& taxRuntimeDocComponentMeasure.ParentMeasure == 0
join taxRuntimeDocComponent
where taxRuntimeDocComponent.RecId == taxRuntimeDocComponentMeasure.TaxRuntimeDocComponent
&& taxRuntimeDocComponent.Name ==_gstcomponent
&& taxRuntimeDocComponent.DocContext == taxRuntimeDocContext.RecId;
select firstonly taxRuntimeLookupCondition
where taxRuntimeLookupCondition.DimValue2 == _code
&& taxRuntimeLookupCondition.LookupVersion == taxRuntimeLookupVersion.RecId
join taxRuntimeLookupMeasureResult
where taxRuntimeLookupMeasureResult.LookupCondition == taxRuntimeLookupCondition.RecId
join taxRuntimeLookupMeasureResultDetail
where taxRuntimeLookupMeasureResultDetail.LookupMeasureResult == taxRuntimeLookupMeasureResult.RecId;
return taxRuntimeLookupMeasureResultDetail.Value;
}