public bool IsLienWaiverFinal(LienWaiverGenerationKey generationKey, bool isConditional)
        {
            graph.Caches <ComplianceDocument>().ClearQueryCache();
            var lienWaivers       = lienWaiverDataProvider.GetNotVoidedLienWaivers(generationKey).ToList();
            var lienNoticeAmounts = lienWaivers.Select(lw => lw.LienNoticeAmount)
                                    .Where(lna => lna != null).Distinct().ToList();

            if (lienNoticeAmounts.IsSingleElement())
            {
                try
                {
                    var totalAmount      = GetTotalAmount(lienWaivers);
                    var lienWaiverAmount = GetLienWaiverAmount(generationKey, isConditional);

                    return(totalAmount + lienWaiverAmount == lienNoticeAmounts.First());
                }
                catch (Exception e)
                {
                    var waiverIDs = lienWaivers?.Where(w => w.LienNoticeAmount != null)
                                    .Select(w => w.ComplianceDocumentID).ToArray();

                    throw new PXException(ComplianceMessages.LienWaiver.LienWaiverGenerationFailed, waiverIDs?.JoinIntoStringForMessageNoQuotes());
                }
            }

            return(false);
        }
        private void UpdateComplianceDocuments(APAdjust adjustment)
        {
            var complianceDocuments = GetRelatedComplianceDocuments(adjustment.AdjdRefNbr, adjustment.AdjdDocType);

            graph.Caches <JointPayeePayment>().Persist(PXDBOperation.Insert);
            foreach (var complianceDocument in complianceDocuments)
            {
                UpdateComplianceDocument(adjustment, complianceDocument);
            }
        }
Пример #3
0
        /// <summary>
        /// Returns transactions related to adjustments from the current payment in cache.
        /// Returns empty collection in case an adjustment relates to multiple transactions with references to
        /// different projects or commitments. It is possible for a bill without Pay per line feature.
        /// </summary>
        public IEnumerable <APTran> GetTransactions()
        {
            var insertedAdjustments = graph.Caches <APAdjust>().Inserted.RowCast <APAdjust>().ToList();
            var adjustments         = SiteMapExtension.IsPreparePaymentsScreenId()
                ? PreparePaymentsAdjustmentsCache.GetStoredAdjustments().Where(adjust =>
                                                                               IsRelatedAdjustment(insertedAdjustments.SingleOrDefault(), adjust))
                : graph.Adjustments.Select().FirstTableItems.Concat(insertedAdjustments).ToList();
            var transactions = adjustments.Select(GetTransaction).ToList();

            return(transactions.Any(t => t == null)
                ? Enumerable.Empty <APTran>()
                : transactions);
        }
 public JointAmountToPayValidationService(APPaymentEntry graph)
     : base(graph)
 {
     jointPayeeAmountsCalculationService = new JointPayeeAmountsCalculationService(graph);
     jointPayeePaymentCache = graph.Caches <JointPayeePayment>();
 }