Hello, community.
I am trying to create a manual clearing for open customer invoices using the DueClearingUtilities library.
I follow the Help documentation and in the result of the call i get a clearing UUID.
However the clearing can't be found (when querying in the repository explorer by UUID) and the invoice is staying Open.
Can you tell what is missing in the code and how to make this work?
Here is my code:
var invoiceQuery_Results = invoiceQuery.Execute(invoiceQuery_SelParams);
var listOpenItems: collectionof DueClearingClearOpenItemsElements;
var result;
foreach (var invoice in invoiceQuery_Results) {
// Variables
var OpenItems: DueClearingClearOpenItemsElements;
var PostingDate;
var DocumentDate;
var ItemDetails: DueClearingOpenItemDetailsList;
var TRPItemStringUUID;
var TRPItemUUID: UUID;
var ItemTransactionCurrencyCode;
var AppliedNetAmount;
var CashDiscountAmount;
var DeductionsList;
var DeductionAmount;
var DedTransactionCurrencyCode;
var PaymentDifferenceReasonCode;
OpenItems.PostingDate = invoice.Date;
OpenItems.DocumentDate = invoice.Date;
//Fetch Items for your usecase by querying BO Trade Receivables Payables Register - Item Overview Node - QueryByElements
var trRecPblQuery = TradeReceivablesPayablesRegister.ItemOverview.QueryByElements;
var trRecPblQuery_SelParams = trRecPblQuery.CreateSelectionParams();
trRecPblQuery_SelParams.Add(trRecPblQuery.BaseBusinessTransactionDocumentReference.ID.content, "I", "EQ", invoice.ID.content);
var trRecPblQuery_Results = trRecPblQuery.ExecuteDataOnly(trRecPblQuery_SelParams);
var trRecPblItem = trRecPblQuery_Results.GetFirst();
if (!trRecPblItem.IsInitial() && trRecPblItem.ClearingStatusCode == "1") {
//Assign Item Details
ItemDetails.TRPItemUUID.content = trRecPblItem.UUID.content;
ItemDetails.TransactionCurrencyCode = trRecPblItem.TransactionCurrencyAmount.currencyCode.GetDescription().ToUpperCase();
//ItemDetails.AppliedNetAmount.content = trRecPblItem.TransactionCurrencyAmount.content;
//ItemDetails.AppliedNetAmount.currencyCode = trRecPblItem.TransactionCurrencyAmount.currencyCode;
// add discount
var deductionData : DueClearingOpenItemDetailsDeductionsList;
deductionData.DeductionAmount.content = trRecPblItem.TransactionCurrencyAmount.content;
deductionData.DeductionAmount.currencyCode = trRecPblItem.TransactionCurrencyAmount.currencyCode;
deductionData.TransactionCurrencyCode = trRecPblItem.TransactionCurrencyAmount.currencyCode.GetDescription().ToUpperCase();
deductionData.PaymentDifferenceReasonCode = "S01";
ItemDetails.DeductionsList.Add(deductionData);
OpenItems.ItemDetails.Add(ItemDetails);
listOpenItems.Add(OpenItems);
}
}
result = Library::DueClearingUtilities.ClearOpenItems(listOpenItems);