Tuesday, June 8, 2021

Some Code Example For Sales Order Invoice Or Free Text Invoice:

If we are going to find the data for the sales order or free text invoice then I think you have RecID of particular Invoiced sales order or free text invoice lets move to the data and some X++ code to find the data in D365 F and O

TransTaxInformation table contains HSN, SAC, and other tax Related line Information.

    TransTaxInformation GetTransTaxInformation(CustInvoiceTrans invoiceLine)
    {
        TransTaxInformation                         taxInfo;
        TransTaxInformationRelationView   taxRelation;

        select firstonly1 taxRelation
            where taxRelation.TransactionRefRecId    == invoiceLine.RecId
            && taxRelation.TransactionRefTableId == tablenum(CustInvoiceTrans)
           join taxInfo
            where taxInfo.RecId == taxRelation.TransTaxInformationRefRecId;

        return taxInfo;

    }

HSN = HSNCodeTable_IN::find(this.GetTransTaxInformation(transLine).HSNCodeTable);

SAC = ServiceAccountingCodeTable_IN::find(this.GetServiceAccountingCode(transLine).ServiceAccountingCodeTable);

Purchase Line Tax Details Before Invoicing: 

    this.taxData(purchLine,purchTable);

    public void taxData(PurchLine       _line, PurchTable   _head)

    {

        ITaxDocument                        taxDocument;

        ITaxDocumentLine                    taxDocumentLine;

        ITaxDocumentComponentLineEnumerator componentLineEnumerator,totalcomponentLineEnumerator;

        ITaxDocumentComponentLine           componentLineObject;

        ITaxDocumentMeasureEnumerator       measureEnumerator;

        TaxAmount                           taxAmount,taxValue;

        TaxComponent_IN                     taxComponent;

        

        taxDocument     = TaxBusinessService::getTaxDocumentBySource(_head.TableId, _head.RecId);

        taxDocumentLine = taxDocument.findLineBySource(_line.TableId,_line.RecId);

        componentLineEnumerator = taxDocumentLine.componentLines();


        while(componentLineEnumerator.moveNext())

        {

            componentLineObject = componentLineEnumerator.current();

            if(taxComponent)

            {

                taxComponent = taxComponent + "/" + componentLineObject.metaData().taxComponent();

            }

            else

            {

                taxComponent = componentLineObject.metaData().taxComponent();

            }

            

            taxValue += componentLineObject.getMeasure("Rate").value().value() * 100;

            taxAmount += componentLineObject.getMeasure("Tax Amount").value().value();

        }

        tmpTable.TaxCode = taxComponent;

        tmpTable.TaxValue = taxValue;

        tmpTable.TaxAmount = taxAmount;

        tmptable.GrossAmt = abs(tmptable.LineAmount) + tmptable.TaxAmount - tmptable.DiscAmount;

 }

TAX RATE

line.CGSTRate = abs(this.TaxRate(_jour,'CGST', transLine));
line.SGSTRate = abs(this.TaxRate(_jour,'SGST', transLine));
line.IGSTRate = abs(this.TaxRate(_jour,'IGST', transLine));

    protected Real TaxRate(CustInvoiceJour  invoiceJour, str    _component, CustInvoiceTrans  invoiceTrans)
    {
        TaxTrans   taxTrans;

        select taxTrans where taxTrans.InventTransId == invoiceTrans.InventTransId
            && taxTrans.Voucher == invoiceJour.LedgerVoucher
            && taxTrans.TaxCode == _component;

        return abs(taxTrans.TaxValue);
    }

TAX AMOUNT

line.CGST = abs(this.TaxAmount(_jour,'CGST', transLine));
line.SGST = abs(this.TaxAmount(_jour,'SGST', transLine));
line.IGST = abs(this.TaxAmount(_jour,'IGST', transLine));

    protected Real TaxAmount(CustInvoiceJour  invoiceJour, str    _component, CustInvoiceTrans  invoiceTrans)
    {
        TaxTrans   taxTrans;

        select sum(SourceRegulateAmountCur),TaxValue,SourceRecid from taxTrans
            where taxTrans.Voucher == invoiceJour.LedgerVoucher
            && taxTrans.TaxCode == _component
            && taxTrans.TransDate == invoiceJour.InvoiceDate
            && taxTrans.InventTransId == invoiceTrans.InventTransId;


        return abs(taxtrans.SourceRegulateAmountCur);
    }

GSTIN:
header.CompanyGSTIN     = TaxRegistrationNumbers_IN::find(TaxInformation_IN::findDefaultbyLocation(DirPartyTable::findByNum(companyInfo.PartyNumber).PrimaryAddressLocation).GSTIN).RegistrationNumber;

header.CustomerGSTIN      = TaxRegistrationNumbers_IN::find(TaxInformation_IN::findDefaultbyLocation(DirPartyTable::findRec(CustTable::find(SalesTable::find(_jour.SalesId).CustAccount).Party).PrimaryAddressLocation).GSTIN).RegistrationNumber;

PAN:

header.CompanyPAN       = PanInfo.PANNumber;
TaxInformationLegalEntity_IN    PanInfo = TaxInformationLegalEntity_IN::findByLegalEntity(companyInfo.RecId);

Tax Transaction ID or Date:

ITaxDocument                    taxDocumentObject;
TaxDocumentExtension_IN         taxDocumentExtension;

taxDocumentObject       = TaxBusinessService::getTaxDocumentBySource(_jour.TableId, _jour.RecId);
taxDocumentExtension    = taxDocumentExtension_in::findByTaxDocument(taxDocumentObject.getGUID());

header.InvoiceNumber    = taxDocumentExtension.TaxTransactionId;
header.InvoiceDate      = taxDocumentExtension.TaxTransactionDate;

QRCode IN D365:
Field Type: Bitmap, Report Design: In Image Use Field Expression and Type IMG/BPS.
header.S3EINVQRCode = new EFDocQRCode_BR().generateQRCode(ewayBill.SignedQRCode);






No comments:

Post a Comment

Workflow Approver Name For PurchRequsition Order

 For First Approver, this.workflowApprover(purchReqTable.RecId);     public void workflowApprover (RecId _recId)  // Requsation Table RecId ...