private bool AreThereAnyLienWaiverRecipientsForVendorClass(JointPayee jointPayee) { var projectId = GetProjectId(jointPayee); return(projectId != null && AreThereAnyLienWaiverRecipientsForVendorClass(jointPayee.JointPayeeInternalId, projectId)); }
public static APTran GetTransaction(PXGraph graph, JointPayee jointPayee) { var jointPayeePayment = JointPayeePaymentDataProvider.GetJointPayeePayment(graph, jointPayee.JointPayeeId); return(GetTransaction(graph, jointPayeePayment.InvoiceDocType ?? jointPayeePayment.PaymentDocType, jointPayeePayment.InvoiceRefNbr ?? jointPayeePayment.PaymentRefNbr, jointPayee.BillLineNumber)); }
private bool IsValidJointPayee(JointPayee jointPayee) { return(IsVendorInternal(jointPayee) && AreThereAnyLienWaiverRecipientsForVendorClass(jointPayee) && !(LienWaiverSetup.ShouldStopPayments == true && AreThereAnyOutstandingLienWaivers(jointPayee)) && DoesCommitmentAmountExceedMinimumCommitmentAmount(jointPayee)); }
private void RaiseValidationException(JointPayee jointPayee, decimal?minValue) { var message = string.Format(JointCheckMessages.CorrectionToThisAmountIsNotAvailable, minValue); Base1.JointPayees.Cache.RaiseException <JointPayee.jointAmountOwed>( jointPayee, message, jointPayee.JointAmountOwed); }
private bool AreThereAnyOutstandingLienWaivers(JointPayee jointPayee) { var projectIds = LienWaiverProjectDataProvider.GetProjectIds(Graph, jointPayee); return(LienWaiverDataProvider.DoesAnyOutstandingComplianceExistForJointVendor( jointPayee.JointPayeeInternalId, projectIds)); }
private int?GetProjectId(JointPayee jointPayee) { var transaction = jointPayee.BillLineNumber != 0 ? TransactionDataProvider.GetTransaction(Graph, jointPayee) : Transactions.Select(tran => tran).Distinct().SingleOrNull(); return(TransactionDataProvider.GetOriginalTransaction(Graph, transaction).ProjectID); }
private void ModifyJointPayeeFieldsAvailability(JointPayee jointPayee) { SetJointPayeeFieldEnabled <JointPayee.jointPayeeInternalId>(jointPayee, !IsAdjustingInProgress); SetJointPayeeFieldEnabled <JointPayee.jointPayeeExternalName>(jointPayee, !IsAdjustingInProgress); SetJointPayeeFieldEnabled <JointPayee.billLineNumber>(jointPayee, !IsAdjustingInProgress); SetJointPayeeFieldEnabled <JointPayee.jointAmountOwed>( jointPayee, !IsAdjustingInProgress || jointPayee.OriginalJointBalance > 0); }
public bool DoesAnyOutstandingComplianceExistForJointVendor(JointPayee jointPayee, List <int?> projectIds) { var complianceDocuments = GetOutstandingLienWaiversForJointVendors(projectIds); return(complianceDocuments.Any(cd => cd.JointVendorInternalId != null && cd.JointVendorInternalId == jointPayee.JointPayeeInternalId || cd.JointVendorExternalName != null && cd.JointVendorExternalName == jointPayee.JointPayeeExternalName)); }
private static APTran GetTransaction(PXGraph graph, JointPayee jointPayee, IDocumentAdjustment adjustment) { var originalBill = InvoiceDataProvider.GetOriginalInvoice(graph, adjustment.AdjdRefNbr, adjustment.AdjdDocType); return(TransactionDataProvider.GetTransaction(graph, originalBill.DocType, originalBill.RefNbr, jointPayee.BillLineNumber)); }
public void UpdateComplianceForJointCheck(JointPayee jointPayee, ComplianceDocument complianceDocument, APRegister check) { if (IsSameJointVendorInternalId(jointPayee, complianceDocument) || IsSameJointVendorExternalName(jointPayee, complianceDocument)) { UpdateComplianceDocument(complianceDocument, check, false); } }
public static IEnumerable <int?> GetProjectIds(APPaymentEntry graph, JointPayee jointPayee) { var adjustments = graph.Adjustments.SelectMain(); var jointPayeeAdjustments = jointPayee.BillLineNumber == 0 ? adjustments.SelectMany(adjustment => GetTransactions(graph, adjustment)) : adjustments.Select(adjustment => GetTransaction(graph, jointPayee, adjustment)); return(jointPayeeAdjustments.Select(tran => tran.ProjectID)); }
private string CreateMessageLine(JointPayee jointPayee, ComplianceDocument compliance, string vendorName) { var project = projectDataProvider.GetProject(graph, compliance.ProjectID); var messageLine = $"{jointPayee.JointPayeeExternalName ?? vendorName}, {project.ContractCD}-{project.Description}"; return(AppendCommitments(compliance, messageLine)); }
private bool HasSameVendorAsReversedJointPayeePayment(JointPayee jointPayee) { var jointPayeeComparer = new JointPayeeComparer(); var reversedJointPayeesGroups = Base1.JointPayeePayments.Select().RowCast <JointPayee>() .GroupBy(jpp => jpp.JointPayeeId).Where(group => group.HasAtLeastTwoItems()); return(reversedJointPayeesGroups.Any(reversedJointPayeePaymentsGroup => jointPayeeComparer.Equals(reversedJointPayeePaymentsGroup.FirstOrDefault(), jointPayee))); }
public decimal?GetJointPreparedBalance(JointPayee jointPayee, string referenceNumber = null, int?lineNumber = null) { var nonReleasedJointPayeePayments = GetNonReleasedJointPayeePayments(jointPayee, referenceNumber, lineNumber); var sumOfJointAmountToPay = nonReleasedJointPayeePayments.Sum(jpp => jpp.JointAmountToPay); return(jointPayee.JointAmountOwed - jointPayee.JointAmountPaid - sumOfJointAmountToPay); }
private void RecalculateJointPayee(IEnumerable <JointPayeePayment> jointPayeePayments, JointPayee jointPayee) { var jointAmountToPay = jointPayeePayments.Sum(jpp => jpp.JointAmountToPay); jointPayee.JointBalance -= jointAmountToPay; jointPayee.JointAmountPaid += jointAmountToPay; Base.Caches <JointPayee>().Update(jointPayee); }
private static bool IsSameJointVendorExternalName(JointPayee jointPayee, ComplianceDocument complianceDocument) { var jointPayeeExternalName = jointPayee.JointPayeeExternalName; var jointVendorExternalName = complianceDocument.JointVendorExternalName; return(!jointPayeeExternalName.IsNullOrEmpty() && !jointVendorExternalName.IsNullOrEmpty() && string.Equals(jointPayeeExternalName.Trim(), jointVendorExternalName.Trim(), StringComparison.CurrentCultureIgnoreCase)); }
private IEnumerable <JointPayeePayment> GetNonReleasedJointPayeePayments(JointPayee jointPayee, string referenceNumber, int?lineNumber) { var nonReleasedJointPayeePayments = JointPayeePaymentDataProvider .GetNonReleasedJointPayeePayments(Graph, jointPayee); return(referenceNumber == null ? nonReleasedJointPayeePayments : nonReleasedJointPayeePayments.Where(jpp => jpp.InvoiceRefNbr == referenceNumber && jpp.BillLineNumber == lineNumber)); }
public string CreateWarningMessage(JointPayee jointPayee, string message, IEnumerable <int?> projectIds) { var outstandingCompliancesForJointCheck = lienWaiverDataProvider.GetOutstandingCompliancesForJointVendor(jointPayee, projectIds.ToList()); var vendorName = GetVendorName(jointPayee.JointPayeeInternalId); return(outstandingCompliancesForJointCheck .Select(compliance => CreateMessageLine(jointPayee, compliance, vendorName)) .Aggregate(message, string.Concat)); }
private void ValidateJointAmountOwedPerLine(JointPayee jointPayee) { var cashDiscount = GetCurrentCashDiscountValue(jointPayee); if (jointPayee.JointAmountOwed > jointPayee.BillLineAmount - cashDiscount) { ShowAmountOwedExceedsBillAmountException(jointPayee, cashDiscount == 0, JointCheckMessages.JointAmountOwedExceedsApBillLineAmount, JointCheckMessages.JointAmountOwedExceedsApBillLineAmountWithCashDiscount); } }
protected void ShowAmountOwedExceedsBillAmountException(JointPayee jointPayee, bool isCashDiscount, string messageWithoutCashDiscount, string messageWithCashDiscount) { var errorMessage = isCashDiscount ? messageWithoutCashDiscount : messageWithCashDiscount; JointPayees.Cache.RaiseException <JointPayee.jointAmountOwed>(jointPayee, errorMessage, jointPayee.JointAmountOwed); throw new PXException(); }
protected override void ValidateTotalJointAmountOwed(JointPayee jointPayee) { var cashDiscount = GetCurrentCashDiscountValue(jointPayee); if (transactionExtension.TotalJointAmountPerLine > jointPayee.BillLineAmount - cashDiscount) { ShowAmountOwedExceedsBillAmountException(jointPayee, cashDiscount == 0, JointCheckMessages.TotalJointAmountOwedExceedsApBillLineAmount, JointCheckMessages.TotalJointAmountOwedExceedsApBillLineAmountWithCashDiscount); } }
protected virtual void ValidateTotalJointAmountOwed(JointPayee jointPayee) { var cashDiscount = CurrentBill.CuryOrigDiscAmt; if (InvoiceExtension.TotalJointAmount > CurrentBill.CuryLineTotal - cashDiscount) { ShowAmountOwedExceedsBillAmountException(jointPayee, cashDiscount == 0, JointCheckMessages.AmountOwedExceedsBalance, JointCheckMessages.AmountOwedExceedsBalanceWithCashDiscount); } }
private JointPayeePayment CreateJointPayeePayment(JointPayee jointPayee) { return(new JointPayeePayment { JointPayeeId = jointPayee.JointPayeeId, PaymentDocType = Base.Document.Current.DocType, PaymentRefNbr = Base.Document.Current.RefNbr, JointAmountToPay = 0, AdjustmentNumber = 0 }); }
private static void UpdateJointCheckPrintModelWithNewPayee(JointCheckPrintModel printModel, JointPayee jointPayee, BAccount vendor) { if (jointPayee.JointPayeeExternalName.IsNullOrEmpty()) { printModel.InternalJointPayeeIds.Add(vendor.BAccountID); } else { printModel.ExternalJointPayeeNames.Add(jointPayee.JointPayeeExternalName); } }
private static JointPayeePayment CreateJointPayeePayment(JointPayee jointPayee, APAdjust adjustment) { return(new JointPayeePayment { JointPayeeId = jointPayee.JointPayeeId, PaymentRefNbr = adjustment.AdjgRefNbr, PaymentDocType = adjustment.AdjgDocType, InvoiceRefNbr = adjustment.AdjdRefNbr, InvoiceDocType = adjustment.AdjdDocType, AdjustmentNumber = adjustment.AdjNbr, BillLineNumber = adjustment.AdjdLineNbr }); }
private void ValidateJointPayee(PXCache cache, JointPayee jointPayee, APAdjust adjustment, List <int?> projectIds) { var message = string.Concat(ComplianceMessages.LienWaiver.JointPayeeHasOutstandingLienWaiver, Constants.WarningMessageSymbols.NewLine); var warningMessage = lienWaiverWarningMessageService.CreateWarningMessage(jointPayee, message, projectIds); var formattedWarningMessage = PXMessages.LocalizeFormatNoPrefix(warningMessage); var doesAnyOutstandingComplianceExistForJointCheck = lienWaiverDataProvider .DoesAnyOutstandingComplianceExistForJointVendor(jointPayee, projectIds); SetWarningIfNeeded <APAdjust.adjdLineNbr>(cache, adjustment, formattedWarningMessage, doesAnyOutstandingComplianceExistForJointCheck, PXErrorLevel.RowWarning); }
public override void ValidateAmountOwed(JointPayee jointPayee) { if (jointPayee.BillLineNumber == null) { return; } var transaction = TransactionDataProvider.GetTransaction(Graph, CurrentBill.DocType, CurrentBill.RefNbr, jointPayee.BillLineNumber); transactionExtension = PXCache <APTran> .GetExtension <ApTranExt>(transaction); ValidateJointAmountOwedPerLine(jointPayee); base.ValidateAmountOwed(jointPayee); }
public void ValidateJointPayee(PXCache cache, JointPayee jointPayee, List <int?> projectIds, string message, PXErrorLevel errorLevel = PXErrorLevel.Warning) { if (jointPayee.JointPayeeExternalName == null || jointPayee.JointPayeeInternalId == null) { var doesAnyOutstandingComplianceExist = lienWaiverDataProvider .DoesAnyOutstandingComplianceExistForJointVendor(jointPayee.JointPayeeInternalId, projectIds); SetWarningIfNeeded <JointPayee.jointPayeeInternalId>(cache, jointPayee, message, doesAnyOutstandingComplianceExist, errorLevel); doesAnyOutstandingComplianceExist = lienWaiverDataProvider .DoesAnyOutstandingComplianceExistForJointVendor(jointPayee.JointPayeeExternalName, projectIds); SetWarningIfNeeded <JointPayee.jointPayeeExternalName>(cache, jointPayee, message, doesAnyOutstandingComplianceExist, errorLevel); } }
public static IEnumerable <int?> GetProjectIds(APInvoiceEntry graph, JointPayee jointPayee) { var originalBill = InvoiceDataProvider.GetOriginalInvoice(graph, graph.Document.Current); var transactions = TransactionDataProvider.GetTransactions(graph, originalBill.DocType, originalBill.RefNbr) .ToList(); if (IsSingleProjectPerDocumentContext(graph.APSetup.Current, transactions)) { return(graph.Document.Current.ProjectID.AsSingleEnumerable()); } if (jointPayee != null && graph.Document.Current.PaymentsByLinesAllowed == true) { transactions = transactions.Where(tran => tran.LineNbr == jointPayee.BillLineNumber).ToList(); } return(transactions.Select(tran => tran.ProjectID).Distinct()); }
private bool ValidateJointAmountOwed(JointPayee jointPayee) { RemoveJointAmountOwedValidation(jointPayee); if (jointPayee.JointAmountOwed < decimal.Zero) { Base1.JointPayees.Cache.RaiseException <JointPayee.jointAmountOwed>(jointPayee, JointCheckMessages.TheValueMustNotBeLesserThanZero, jointPayee.JointAmountOwed); return(false); } var minValue = jointPayee.OriginalJointAmountOwed - jointPayee.OriginalJointPreparedBalance; var maxValue = jointPayee.OriginalJointAmountOwed; if (jointPayee.JointAmountOwed < minValue || jointPayee.JointAmountOwed > maxValue) { RaiseValidationException(jointPayee, minValue); return(false); } return(true); }