Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Invoiced credit note taking positive values for markupTrans table

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello everyone,

We have a customized process to automate credit note for Sales Order using OOTB Microsoft code. The issue that arises is when we create invoice for the credit note, the total markuptrans values appear as positive rather than negative which in turn causes financial instability of the invoices. Any help would be greatly appreciated. Code is given below:

public static container createCreditNote(SalesLineRefRecId _salesLineRecId, SalesQty _returnQty)
{
SalesTable salesTable;
SalesLine salesLineCN, salesLine;
SalesCopying salesCopying;
TmpFrmVirtual tmpFrmVirtualLines, tmpFrmVirtualHeader;
CustInvoiceTrans custInvoiceTrans;
CustInvoiceJour custInvoiceJour;

container conReturn;

salesLine = SalesLine::findRecId(_salesLineRecId);
salesTable = SalesTable::find(salesLine.SalesId, true);

void loadTmpFrmVirtualAndCreateCN(CustInvoiceTrans _custInvoiceTrans)
{
delete_from tmpFrmVirtualLines;

tmpFrmVirtualLines.TableNum = _custInvoiceTrans.TableId;
tmpFrmVirtualLines.RecordNo = _custInvoiceTrans.RecId;
tmpFrmVirtualLines.Id = _custInvoiceTrans.SalesId;
tmpFrmVirtualLines.LineNum = _custInvoiceTrans.LineNum;
tmpFrmVirtualLines.TransDate = _custInvoiceTrans.InvoiceDate;
tmpFrmVirtualLines.Qty = _returnQty;
tmpFrmVirtualLines.write();


salesCopying = SalesCopying::construct(SalesPurchCopy::CreditNoteLines);
salesCopying.initParameters(salesTable, tmpFrmVirtualLines, tmpFrmVirtualHeader, 1, true,false, true, true, false);
salesCopying.copy();
}

select firstonly RecId, TableId, SalesId, LineNum, InvoiceDate, Qty, LineDisc, SalesPrice, LineAmount, TaxGroup from custInvoiceTrans
order by custInvoiceTrans.InvoiceDate desc
where custInvoiceTrans.InventTransId == salesLine.InventTransId;

if (custInvoiceTrans)
{
try
{
// Create credit note
loadTmpFrmVirtualAndCreateCN(custInvoiceTrans);

// Populate container
conReturn = SLD_PostReturnOrderHelper::fillContainer(true, 'Credit note processed successfuly!');
}
catch
{
// Populate container
conReturn = SLD_PostReturnOrderHelper::fillContainer(false, strFmt('Exception occurred while creating credit note of item %1 of %2 sales order', salesLine.ItemId, salesLine.SalesId));
}
}

return conReturn;
}

  • Hatem.Mahdy Profile Picture
    Hatem.Mahdy 10 on at
    RE: Invoiced credit note taking positive values for markupTrans table

    Did anyone solve this issue?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans