private void CreateLienWaiver(LienWaiverGenerationKey generationKey, APPayment payment,
                                      string lienWaiverDocumentTypeValue)
        {
            var complianceAttribute = LienWaiverDataProvider.GetComplianceAttribute(lienWaiverDocumentTypeValue);

            LienWaiverCreator.CreateLienWaiver(generationKey, payment, complianceAttribute);
        }
        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 CreateUnconditionalLienWaiver(LienWaiverGenerationKey generationKey, APPayment payment)
        {
            var lienWaiverDocumentTypeValue = LienWaiverTypeDeterminator.IsLienWaiverFinal(generationKey, false)
                ? Constants.LienWaiverDocumentTypeValues.UnconditionalFinal
                : Constants.LienWaiverDocumentTypeValues.UnconditionalPartial;

            CreateLienWaiver(generationKey, payment, lienWaiverDocumentTypeValue);
        }
Пример #4
0
 public void CreateLienWaiver(LienWaiverGenerationKey lienWaiverGenerationKey, APPayment payment,
                              ComplianceAttribute complianceAttribute)
 {
     generationKey = lienWaiverGenerationKey;
     CreateLienWaiver(payment, complianceAttribute);
     Cache.Update(lienWaiver);
     Cache.Persist(PXDBOperation.Insert);
     Cache.Persisted(false);
 }
        private decimal?GetLienWaiverAmount(LienWaiverGenerationKey generationKey, bool isConditional)
        {
            var transactions        = lienWaiverTransactionRetriever.GetTransactions(generationKey);
            var insertedAdjustments = graph.Caches <APAdjust>().Inserted.RowCast <APAdjust>().ToList();

            return(isConditional && LienWaiverSetup.FinalAmountSourceConditional == LienWaiverAmountSource.BillAmount
                                ? LienWaiverAmountCalculationService.GetBillAmount(transactions)
                                : LienWaiverAmountCalculationService.GetAmountPaid(graph.Adjustments.SelectMain()
                                                                                   .Concat(insertedAdjustments)));
        }
 private void CreateLienWaivers(LienWaiverGenerationKey generationKey, APPayment payment)
 {
     if (LienWaiverSetup.ShouldGenerateConditional == true)
     {
         CreateConditionalLienWaiver(generationKey, payment);
     }
     if (LienWaiverSetup.ShouldGenerateUnconditional == true)
     {
         CreateUnconditionalLienWaiver(generationKey, payment);
     }
 }
        public IEnumerable <ComplianceDocument> GetNotVoidedLienWaivers(LienWaiverGenerationKey generationKey)
        {
            var query = CreateLienWaiversQuery();

            query.WhereAnd <Where <ComplianceDocument.projectID.IsEqual <P.AsInt> > >();
            query.WhereAnd <Where <ComplianceDocument.vendorID.IsEqual <P.AsInt> > >();
            var parameters = new object[]
            {
                generationKey.ProjectId,
                generationKey.VendorId
            };

            parameters = AppendCommitmentCondition(generationKey.OrderNumber, query, parameters);
            return(query.Select <ComplianceDocument>(parameters).Where(lw => lw.IsVoided != true));
        }
Пример #8
0
 /// <summary>
 /// Returns transactions related to adjustments from the current payment in cache, that are referenced to
 /// to project and commitment from <see cref="LienWaiverGenerationKey"/>.
 /// </summary>
 public IEnumerable <APTran> GetTransactions(LienWaiverGenerationKey generationKey)
 {
     return(GetTransactions()
            .Where(tran => IsRelatedToCommitment(tran, generationKey.ProjectId, generationKey.OrderNumber)));
 }