I'm facing an issue while completing the payment for a return order. The system is throwing the following exception:
"Not more than 0.00 can be reversed."
"The refund invoice total 522.58 is greater than the total refundable amount 493.00."
Could you please help me understand and resolve this?
public void createCallCenterReturnPayment(SalesId _returnsalesId,SalesId _origSalesTable)
{
MCRCustPaymTable mcrCustPaymTable,origMcrCustPaymTable;
SalesTable returnSalesTableBuf = SalesTable::find(_returnsalesId);
SalesTable origSalesTableBuf = SalesTable::find(_origSalesTable);
RetailChannelTable retailChannelTable;
select firstonly retailChannelTable
where retailChannelTable.RecId == returnSalesTableBuf.RetailChannelTable;
if(retailChannelTable.ChannelType == RetailChannelType::MCRCallCenter)
{
MCRCustPaymStatus mcrCustPaymStatus = MCRCustPaymStatus::NotSubmitted;
SalesTotals salesTotals = salesTotals::construct(returnSalesTableBuf,SalesUpdate::All);
Total totalAmount = salesTotals.totalAmount();
//Total totalAmount1 = salesTotals.totalAmount() - salesTotals.totalMarkup() - salesTotals.totalTaxAmount();
select firstonly origMcrCustPaymTable
where origMcrCustPaymTable.RefTableId == origSalesTableBuf.TableId
&& origMcrCustPaymTable.RefRecId == origSalesTableBuf.RecId;
try
{
ttsbegin;
mcrCustPaymTable.clear();
mcrCustPaymTable.Channel = returnSalesTableBuf.retailSalesTable().RetailChannel;
mcrCustPaymTable.CurrencyCode = returnSalesTableBuf.CurrencyCode;
mcrCustPaymTable.TenderTypeId = "2";
mcrCustPaymTable.RefTableId = returnSalesTableBuf.TableId;
mcrCustPaymTable.RefRecId = returnSalesTableBuf.RecId;
mcrCustPaymTable.CustAccount = returnSalesTableBuf.CustAccount;
mcrCustPaymTable.OrigRefundRecID = origMcrCustPaymTable.RecId;
mcrCustPaymTable.Status = mcrCustPaymStatus;
mcrCustPaymTable.CustPaymType = MCRCustPaymType::RefundCheck;
switch (mcrCustPaymStatus)
{
case MCRCustPaymStatus::NotSubmitted:
case MCRCustPaymStatus::Authorized:
mcrCustPaymTable.Amount = CurrencyExchange::round(totalAmount, returnSalesTableBuf.CurrencyCode);
break;
}
mcrCustPaymTable.insert();
ttscommit;
MCRSalesOrderTotals mcrSalesOrderTotals = new MCRSalesOrderTotals(returnSalesTableBuf, true);
//complete
MCREndOrder::endOrder(returnSalesTableBuf.SalesId, true, mcrSalesOrderTotals, false);
}
catch
{
Error("@BASIS_SOCancellation:NewLabel1");
}
}
}