/// <summary> /// Generates a list of documents that meet the filter criteria. /// This list is used for display in the processing screen /// </summary> /// <returns>List of Customers with Dunning Letters</returns> protected virtual IEnumerable details() { CreditHoldParameters header = Filter.Current; List <DetailsResult> result = new List <DetailsResult>(); if (header == null) { yield break; } foreach (PXResult <Customer, ARDunningLetter> record in GetCustomersToProcess(header)) { ARDunningLetter dunningLetter = record; Customer customer = record; if (header.ShowAll == false && customer.Status != header.IncludedCustomerStatus) { continue; } DetailsResult res = new DetailsResult(); res.Copy(this, dunningLetter, customer); IEnumerable <Override.ExtendedCustomer> customerFamily = CustomerMaint.GetChildAccountsAndSelfStripped <Override.Customer.sharedCreditCustomerID>(this, customer.BAccountID); int?[] customerFamilyIDs = customerFamily .Select(row => row.BusinessAccount.BAccountID) .Where(id => id != null) .ToArray(); var balances = CustomerMaint.GetCustomerBalances(this, customerFamilyIDs); if (balances != null) { res.InvBal = balances.CurrentBal ?? 0.0m; } result.Add(res); } foreach (var item in result) { Details.Cache.SetStatus(item, PXEntryStatus.Held); yield return(item); } Details.Cache.IsDirty = false; }
protected virtual void GetCustomerBalance(PXCache cache, Customer customer, out decimal?CustomerBal, out DateTime?OldInvoiceDate) { ARBalances summarybal; using (new PXConnectionScope()) { summarybal = CustomerMaint.GetCustomerBalances <PX.Objects.AR.Override.Customer.sharedCreditCustomerID>( cache.Graph, customer.SharedCreditCustomerID); } CustomerBal = 0m; var curaccumbal = cache.Current as ARBalances; if (curaccumbal != null && cache.GetStatus(curaccumbal) == PXEntryStatus.Inserted) { //get balance only from PXAccumulator foreach (ARBalances accumbal in cache.Inserted) { if (accumbal.CustomerID != curaccumbal.CustomerID) { continue; } CustomerBal += accumbal.CurrentBal + accumbal.UnreleasedBal + accumbal.TotalOpenOrders; } } OldInvoiceDate = null; if (summarybal != null) { CustomerBal += (summarybal.CurrentBal ?? 0m); CustomerBal += (summarybal.UnreleasedBal ?? 0m); CustomerBal += (summarybal.TotalOpenOrders ?? 0m); CustomerBal += (summarybal.TotalShipped ?? 0m); CustomerBal -= (summarybal.TotalPrepayments ?? 0m); OldInvoiceDate = summarybal.OldInvoiceDate; } }
/// <summary> /// Generates a list of documents that meet the filter criteria. /// This list is used for display in the processing screen /// </summary> /// <returns>List of Customers with Dunning Letters</returns> protected virtual IEnumerable details() { CreditHoldParameters header = Filter.Current; List <DetailsResult> result = new List <DetailsResult>(); if (header == null) { yield break; } foreach (PXResult <Customer, ARDunningLetter> record in GetCustomersToProcess(header)) { ARDunningLetter dunningLetter = record; Customer customer = record; if (header.ShowAll == false && customer.Status != header.IncludedCustomerStatus) { continue; } DetailsResult res = new DetailsResult(); res.Copy(this, dunningLetter, customer); ARBalances balances = CustomerMaint.GetCustomerBalances <Override.Customer.sharedCreditCustomerID>(this, customer.BAccountID); if (balances != null) { res.InvBal = balances.CurrentBal ?? 0.0m; } result.Add(res); } foreach (var item in result) { Details.Cache.SetStatus(item, PXEntryStatus.Held); yield return(item); } Details.Cache.IsDirty = false; }