Working with delivery remainders: a word of caution

 


While updating the delivery remainder through code, you must be aware of the following code, which is widely available in the Google market:


 SalesUpdateRemain::construct().updateDeliverRemainder(salesLine2update,

                                                                                        qty2Delv,

                                                                                        qty2Delv);

However, this won't help you, if you are working for a Call-center based client/retail clients/royalty clients . Retail clients have a facility known as: 'Complete' sales orders, which processes any payments or refunds, if you are making, from F&O.  

Suppose I have ordered initially 5 qtys and want to receive only 3 out of them, scrapping the rest 2, I need to consequently update the same using delivery reminders. However, if you want to automate the same (some integration staging table from where a batch reads and updates the deliver reminder), then the above code won't work, while 'Completing' the record, runtime.

This is because, if you see the standard code, the standard calls for adjusting the MCRCustPayment posting, which the above code is not doing. Hence, you have to call the below method, along with the above:

this.callMCRPaymentCancellation(salesLine2Updatel);

The above method looks like this:

void callMCRPaymentCancellation(SalesLine _callerSalesLine)

    {

        MCRSalesOrderCancellation mcrSalesOrderCancellation;


        if (isConfigurationkeyEnabled(configurationKeyNum(MCRCallCenter)))

        {

            mcrSalesOrderCancellation = new MCRSalesOrderCancellation();

            mcrSalesOrderCancellation.preCancel(SalesTable::find(_callerSalesLine.SalesId));

        }


        if (isConfigurationkeyEnabled(configurationKeyNum(MCRCallCenter)))

        {

            SalesTable salesTable = SalesTable::find(_callerSalesLine.SalesId, true);

                    

            if (_callerSalesLine.SalesStatus == SalesStatus::Canceled)

            {

                SalesLine salesLineLocal = SalesLine::findRecId(_callerSalesLine.RecId);

                mcrSalesOrderCancellation.postCancelLine(salesLineLocal);

                

                if (salesTable.SalesStatus == SalesStatus::Canceled)

                {

                    mcrSalesOrderCancellation.postCancelOrder(salesTable);

                }

            }


            

            // If sales order is paid by loyalty create the refund loyalty lines and post them as part of this process

            if (salesTable.SalesStatus != SalesStatus::Canceled)

            {

                mcrSalesOrderCancellation.RefundLoyaltyPointsForSalesLine(salesTable, _callerSalesLine);

            }

            mcrSalesOrderCancellation.postCancelAdjPayment(salesTable);

        }

    }


}


Yes, this is already present in the Form: SalesUpdateRemain\\Methods\\closeOk method. Unfortunately, the standard has all defined it locally in this form, hence in this case, you have to reinvent the wheel.

That's it guys!

It will create necessary refund/payment lines and you can call methods for Completing the sales order, seamlessly. 


Comments

Popular posts from this blog

X++ : mistakes which developers commit the most

Make your menu items visible on main menu, conditionally,, using this cool feature of D365FO

Speed up your execution performance by using SysGlobalCaches