Skip to main content

Tax calculation through X++


Method 1:

void clicked()
{
real tax1;
;
    super();
 tax1 = Tax::calcTaxAmount(Salesline.TaxGroup, Salesline.TaxItemGroup, Systemdateget(), Salesline.CurrencyCode, Salesline.LineAmount, TaxModuleType::Sales);

info(strfmt("%1", tax1));
}

------------------------------------------------------------------------------------------------------------

Method 2:

void clicked()
{
TaxOnItem                       TaxOnItem;
TaxGroupData                    TaxGroupData, TaxGroupData_1;
real                            TaxAmount = 0, TaxAmount_1 = 0;
TaxValue                        TaxValue = 0, TaxValue_1 = 0;
;
   
    super();

    if(Salesline.TaxItemGroup && Salesline.TaxGroup && Salesline.LineAmount != 0)
    {
        while select TaxOnItem
             where TaxOnItem.TaxItemGroup == salesline.TaxItemGroup
             {
              if(TaxOnItem)
              {
             while select TaxGroupData
                  where TaxGroupData.TaxGroup == Salesline.TaxGroup
&& TaxGroupData.TaxCode  == TaxOnItem.TaxCode
                   {
                   if(TaxGroupData)
                   {
                    TaxValue  =  TaxData::find(TaxOnItem.TaxCode, Systemdateget(), 0).TaxValue;
                    TaxValue_1  += TaxValue;
                    TaxAmount = (Salesline.LineAmount * TaxValue)/100;
                    TaxAmount_1 += TaxAmount;
                   }
                   }
              }
              }
               info(strfmt("%1", TaxAmount_1));
        }
}

Comments

  1. Hello, I want to find calculated sales tax and actual sales tax on purchline. how to do that?

    ReplyDelete
  2. Hi Jeremy,
    Thanks! Keep visiting for more threads :)

    ReplyDelete

Post a Comment