Sunday, 11 March 2018

GST, CGST, IGST,TCS, VAT using x++ code


Packing slip
this.insertGSTData(custPackingSlipJour.TableId, custPackingSlipJour.RecId, custPackingSlipTrans.TableId, custPackingSlipTrans.RecId);

Invoice
this.insertGSTData(custInvoiceJour.TableId, custInvoiceJour.RecId, custInvoiceTrans.TableId, custInvoiceTrans.RecId);


public void insertGSTData(RefTableId _headerTableID, RefRecId _headerRecId,RefTableId _transTableID, RefRecId _transRecId)
    {
        ITaxDocumentLine                    taxDocumentLine;
        ITaxDocument                        taxDocument;
        ITaxDocumentComponentLine           taxDocumentComponentLine;
        ITaxDocumentComponentLineEnumerator taxDocumentComponentLineEnumerator;
        ;
        taxDocument = TaxBusinessService::getTaxDocumentBySource(_headerTableID, _headerRecId);
       
        if (taxDocument)
        {
            taxDocumentLine = taxDocument.findLineBySource(_transTableID, _transRecId);
            if (taxDocumentLine)
            {
                taxDocumentComponentLineEnumerator = taxDocumentLine.componentLines("GST");
               
                while (taxDocumentComponentLineEnumerator.moveNext())
                {
                    taxDocumentComponentLine = taxDocumentComponentLineEnumerator.current();
                    if (taxDocumentComponentLine.metaData().taxComponent() == "CGST")
                    {
                        necSalesRegisterReportTmp.CGST      = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxAmount).value().value();
                        necSalesRegisterReportTmp.CGSTRate  = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxRate).value().value() * 100;
                    }
                    else if (taxDocumentComponentLine.metaData().taxComponent() == "SGST")
                    {
                        necSalesRegisterReportTmp.SGST      = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxAmount).value().value();
                        necSalesRegisterReportTmp.SGSTRate  = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxRate).value().value() * 100;
                    }
                    else if (taxDocumentComponentLine.metaData().taxComponent() == "CESS")
                    {
                        necSalesRegisterReportTmp.CESS      = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxAmount).value().value();
                    }
                    else if (taxDocumentComponentLine.metaData().taxComponent() == "IGST")
                    {
                        necSalesRegisterReportTmp.IGST      = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxAmount).value().value();
                        necSalesRegisterReportTmp.IGSTRate  = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxRate).value().value() * 100;
                    }
                    else if (taxDocumentComponentLine.metaData().taxComponent() == "SPCESS")
                    {
                        necSalesRegisterReportTmp.SPCCESS   = taxDocumentComponentLine.getMeasure(TaxEngineModelLineMeasuresConstants::TaxAmount).value().value();
                    }
                   
                }
            }
        }
       
    }

TCS, VAT 

TmpTaxWorkTrans         tmpTax;
PurchTotals             purchTotals;

purchTotals = purchTotals::newPurchTable(purchLine.purchTable());
purchTotals.calc();
tmpTax.setTmpData(purchTotals.tax().tmpTaxWorkTrans());

while select tmpTax
        where tmpTax.SourceRecId    == purchLine.RecId
            && tmpTax.SourceTableId == tablenum(PurchLine)
{
      if(tmpTax.TaxCode == "TCS")
      {
           PurchaseInvoiceTmp.TCSAmount = tmpTax.TaxAmount;
           PurchaseInvoiceTmp.TCSRate   = TaxData::percent(tmpTax.TaxCode,tmpTax.CalculationDate,tmpTax.TaxBaseAmount);
      }
      else
      {
           PurchaseInvoiceTmp.VATAmount = tmpTax.TaxAmount;
           PurchaseInvoiceTmp.VATRate   = TaxData::percent(tmpTax.TaxCode,tmpTax.CalculationDate,tmpTax.TaxBaseAmount);
      }

}


HSN Code

public void getTaxInfo(RefRecId _refRecId)
    {
        TransTaxInformationRelationView             taxRelation;
        TransTaxInformation                         taxInfo;
        TaxInformation_IN                           custTaxInfo;
       
        select firstonly taxRelation
            where taxRelation.TransactionRefRecId    == _refRecId
                && taxRelation.TransactionRefTableId == tablenum(SalesLine)
            join taxInfo
                where taxInfo.RecId == taxRelation.TransTaxInformationRefRecId
            join custTaxInfo
                where custTaxInfo.RecId == taxInfo.CustomerTaxInformation;

        custTaxInfo = TaxInformation_IN::find(taxInfo.CustomerTaxInformation);

        necSalesRegisterReportTmp.TIN       = TaxRegistrationNumbers_IN::find(custTaxInfo.TIN).RegistrationNumber;
        necSalesRegisterReportTmp.GSTNumber = TaxRegistrationNumbers_IN::find(custTaxInfo.GSTIN).RegistrationNumber;
        necSalesRegisterReportTmp.HSNCode   = HSNCodeTable_IN::find(taxInfo.HSNCodeTable).code;
    }

No comments:

Post a Comment