Charges creation before free text invoice posting

 /// <summary>

/// Create chages for free text invoices.

/// </summary>

[ExtensionOf(classStr(CustPostInvoiceJob))]

final class CustPostInvoiceJob_Extension

{

     /// <summary>

     /// 

     /// </summary>

    public void run()

    {

        CustInvoiceTable                    custInvoiceTableLoc;

        CustParameters                      custParameters = CustParameters::find();

        MarkupTrans                         markupTrans;


        if (custParameters.AdvanceStampDutyManagement_Custom)

        {

            CustFreeInvoiceCalcTotals   custFreeInvoiceCalcTotals;

            TmpTaxWorkTrans             tmpTaxWorkTrans;


            while (queryRun.next())

            {

                var custInvoiceTable = queryRun.get(tablenum(CustInvoiceTable));


                select firstonly custInvoiceTableLoc

                    where custInvoiceTableLoc.RecId == custInvoiceTable.RecId;


                custFreeInvoiceCalcTotals = new CustFreeInvoiceCalcTotals(custInvoiceTableLoc);

                custFreeInvoiceCalcTotals.calc();


                tmpTaxWorkTrans = custFreeInvoiceCalcTotals.tax().tmpTaxWorkTrans();


                ttsbegin;

                delete_from markupTrans

                    where markupTrans.TransTableId == custInvoiceTableLoc.TableId &&

                    markupTrans.TransRecId == custInvoiceTableLoc.RecId;

                ttscommit;

                

                //Create markup for free text invoices.

                ChargesForInvoice_Class::createStampChargesFreeText(custInvoiceTableLoc, tmpTaxWorkTrans);

                

                //delete taxUncommitted record for recalculating in base posting method

                TaxUncommitted::deleteForDocumentHeader(custInvoiceTableLoc.TableId, custInvoiceTableLoc.RecId);

            }

            queryRun.reset();

        }

        next run();

    }

}

Comments

Popular posts from this blog

On clicked event of form button in D365 X++

Finding unit price of item from trade agreement through code AX X++

Create Sales Line Through Code AX X++ D365 Finance & Operations