Tuesday, February 27, 2024

Get sales line tax percent to calculate GST / TAX on sales line in D365 F&O

private Percent calcSalesLineTaxPercent(Salesline  _salesline)

{

    TaxOnItem       taxOnItem;

    TaxGroupData    taxGroupData;

    TaxValue        taxValue;

    if(_salesline.TaxItemGroup && _salesline.TaxGroup && _salesline.LineAmount != 0)

    {

       select firstonly TaxOnItem

            where TaxOnItem.TaxItemGroup == _salesline.TaxItemGroup

           join TaxGroupData

                    where TaxGroupData.TaxGroup == _salesline.TaxGroup

                    && TaxGroupData.TaxCode     == TaxOnItem.TaxCode;

        if(TaxGroupData)

        {

            TaxValue  =  TaxData::find(TaxOnItem.TaxCode, DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()), 0).TaxValue;

        }

    }

    return TaxValue;

}


No comments:

Post a Comment