on 12-21-2017 3:52 PM
Hello experts.
Today, I was wondering how is it possible to retrieve the open amount of a invoice. By open amount, I mean the remaining amount that a customer (account) needs to pay on an invoice.
I discovered a Business Object named AccountsReceivablePayableLedgerAccount. It has the sub object DueItem, that offers few methods such as DueItemHistory.SetOfBooksClearingInformation. Apparently, it makes it possible to check the history on an invoice. Unfortunately, I have no information on these methods (even from the repository that could list them, but display no data). So, I was wondering if this method is reliable for retrieving the open amount of an invoice.
Here's a part of my code:
id = "FA-555-2017";
invoice = CustomerInvoice.Retrieve(id);
if (!invoice.IsSet()) { continue; }
var node = this.CustomerInvoices.Create();
node.ID = id.content;
node.TotalAmount = invoice.TotalGrossAmount;
node.OpenAmount = invoice.TotalGrossAmount;
// look for account
var accountParams = accountQuery.CreateSelectionParams();
accountParams.Add(accountQuery.BusinessPartnerID, "I", "EQ", invoice.BuyerParty.PartyKey.PartyID.content);
accountParams.Add(accountQuery.PartyRoleCategoryCode, "I", "EQ", "4");
var results = accountQuery.Execute(accountParams);
if (results.Count() == 0) { continue; }
account = results.GetFirst();
// look for due item
dueitems = account.DueItem.Where(n => n.Key.OrderReference.FormattedID == invoice.ID.content);
if (dueitems.Count() == 0) { continue; }
dueitem = dueitems.GetFirst();
// look for open amount
if (!dueitem.DueItemHistory.IsSet()) { continue; }
if (dueitem.DueItemHistory.SetOfBooksClearingInformation.Count() == 0) { continue; }
node.OpenAmount = dueitem.DueItemHistory.SetOfBooksClearingInformation.GetFirst().OpenLocalCurrencyAmount;
Thank you a lot for your help. 🙂
Best regards,
Frédéric
What you are looking for is actually in the TradeReceivablesPayablesRegister
import ABSL;
import AP.DueItemManagement.Global;
var query = TradeReceivablesPayablesRegister.ItemOverview.QueryByElements;
var selectionParams = query.CreateSelectionParams();
selectionParams.Add(query.BaseBusinessTransactionDocumentReference.ID.content, "I", "EQ", "INV-1234");
var resultData = query.Execute(selectionParams);
The amount will be in the OpenItemAmount
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tested with an unpaid invoice. It works. I can see my Open Amount = Total Amount. However, I realized that if I pay that invoice in ByD and check again on my Web Service, I still get the same answer : Open Amount = Total Amount, while it should be Open Amount = 0.
So, maybe it doesn't work either.
Thank you for your help.
I tested with an unpaid invoice. It works. I can see my Open Amount = Total Amount. However, I realized that if I pay that invoice in ByD and check again on my Web Service, I still get the same answer : Open Amount = Total Amount, while it should be Open Amount = 0.
So, maybe it doesn't work either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.