示例#1
0
 private IEnumerable <LienWaiverGenerationKey> CreateGroupingKeys(IReadOnlyCollection <JointPayee> jointPayees,
                                                                  APRegister payment, APTran transaction)
 {
     return(jointPayees.IsEmpty()
         ? GetLienWaiverGroupingKey(transaction, null, payment).AsSingleEnumerable()
         : jointPayees.Select(jp => GetLienWaiverGroupingKey(transaction, jp.JointPayeeInternalId, payment)));
 }
示例#2
0
        private IEnumerable <LienWaiverGenerationKey> CreateGroupingKeysForPaymentByLines(
            IEnumerable <JointPayee> jointPayees, APRegister payment, APTran transaction)
        {
            var payees = jointPayees.Where(jp => jp.BillLineNumber == transaction.LineNbr).ToList();

            return(CreateGroupingKeys(payees, payment, transaction));
        }
示例#3
0
 private void CheckPrimaryVendorForOutstandingLienWaivers(APRegister document, IEnumerable <int?> projectIds)
 {
     if (lienWaiverDataProvider.DoesAnyOutstandingComplianceExistForPrimaryVendor(document.VendorID, projectIds))
     {
         throw new PXException(exceptionMessage);
     }
 }
 public IEnumerable <APTran> GetTransactions(APRegister payment)
 {
     Transactions = TransactionRetriever.GetTransactions().ToList();
     return(Transactions.IsEmpty() || ShouldStopForOutstandingLienWaivers(payment)
         ? Enumerable.Empty <APTran>()
         : Transactions.Where(transaction => IsApplicable(transaction, payment)));
 }
        private bool IsApplicable(APTran transaction, APRegister payment)
        {
            var projectId = LienWaiverProjectDataProvider.GetProjectId(Graph, transaction);

            return(AreThereAnyLienWaiverRecipientsForVendorClass(payment.VendorID, projectId) &&
                   DoesCommitmentAmountExceedMinimumCommitmentAmount(payment.VendorID, transaction));
        }
示例#6
0
        protected virtual void CABatchDetail_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            CABatchDetail row        = (CABatchDetail)e.Row;
            bool          isReleased = false;
            bool          isVoided   = false;

            if (row.OrigModule == GL.BatchModule.AP)
            {
                APRegister apDocument = PXSelect <APRegister, Where <APRegister.docType, Equal <Required <APRegister.docType> >,
                                                                     And <APRegister.refNbr, Equal <Required <APRegister.refNbr> > > > > .Select(this, row.OrigDocType, row.OrigRefNbr);

                isReleased = (bool)apDocument.Released;
                isVoided   = (bool)apDocument.Voided;
            }

            if (row.OrigModule == GL.BatchModule.AR)
            {
                ARRegister arDocument = PXSelect <ARRegister, Where <ARRegister.docType, Equal <Required <ARRegister.docType> >,
                                                                     And <ARRegister.refNbr, Equal <Required <ARRegister.refNbr> > > > > .Select(this, row.OrigDocType, row.OrigRefNbr);

                isReleased = (bool)arDocument.Released;
                isVoided   = (bool)arDocument.Voided;
            }

            if (isReleased && !isVoided)
            {
                throw new PXException(Messages.ReleasedDocumentMayNotBeDeletedFromCABatch);
            }
        }
示例#7
0
        protected virtual void APSetup_MigrationMode_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            APSetup row = e.Row as APSetup;

            if (row == null)
            {
                return;
            }

            bool?oldvalue = (bool?)e.OldValue;

            if (row.MigrationMode == true && oldvalue != true)
            {
                GLTran glTransactionFromModule = PXSelect <GLTran,
                                                           Where <GLTran.module, Equal <BatchModule.moduleAP> > > .SelectSingleBound(this, null);

                if (glTransactionFromModule != null)
                {
                    sender.RaiseExceptionHandling <APSetup.migrationMode>(row, row.MigrationMode,
                                                                          new PXSetPropertyException(Common.Messages.MigrationModeActivateGLTransactionFromModuleExist, PXErrorLevel.Warning));
                }
            }
            else if (row.MigrationMode != true && oldvalue == true)
            {
                APRegister unreleasedMigratedDocument = PXSelect <APRegister,
                                                                  Where <APRegister.released, NotEqual <True>,
                                                                         And <APRegister.isMigratedRecord, Equal <True> > > > .SelectSingleBound(this, null);

                if (unreleasedMigratedDocument != null)
                {
                    sender.RaiseExceptionHandling <APSetup.migrationMode>(row, row.MigrationMode,
                                                                          new PXSetPropertyException(Common.Messages.MigrationModeDeactivateUnreleasedMigratedDocumentExist, PXErrorLevel.Warning));
                }
            }
        }
 public static void Ensure(PXGraph graph, APRegister document)
 {
     if (!IsDocumentSchedulable(graph, document))
     {
         throw new PXException(Messages.DocumentCannotBeScheduled);
     }
 }
 /// <summary>
 /// Indicates whether the record is a child Retainage document
 /// with <see cref="APRegister.IsRetainageDocument"/> flag equal to true
 /// and existing reference on the original Retainage document.
 /// </summary>
 public static bool IsChildRetainageDocument(this APRegister doc)
 {
     return
         (doc.IsRetainageDocument == true &&
          !string.IsNullOrEmpty(doc.OrigDocType) &&
          !string.IsNullOrEmpty(doc.OrigRefNbr));
 }
示例#10
0
        private void CheckPaymentForOutstandingLienWaivers(APRegister document)
        {
            var adjustments = AdjustmentDataProvider.GetPaymentAdjustments(graph, document.RefNbr, document.DocType).ToList();
            var projectIds  = LienWaiverProjectDataProvider.GetProjectIds(graph, adjustments).ToList();

            CheckPrimaryVendorForOutstandingLienWaivers(document, projectIds);
            adjustments.ForEach(adjust => CheckJointVendorsForOutstandingLienWaivers(adjust, projectIds));
        }
示例#11
0
 public void ValidateLienWaivers(APRegister document, bool?shouldStopPayments)
 {
     if (shouldStopPayments == true)
     {
         exceptionMessage = ComplianceMessages.LienWaiver.BillHasOutstandingLienWaiverStopPayment;
         CheckPaymentForOutstandingLienWaivers(document);
     }
 }
        private bool DoesAnyOutstandingComplianceExistForJointPayees(APRegister payment, List <int?> projectIds)
        {
            var jointPayeePayments = JointPayeePaymentDataProvider.GetJointPayeePayments(graph, payment)
                                     .Where(jpp => jpp.JointAmountToPay > 0);
            var jointPayees = JointPayeeDataProvider.GetJointPayees(graph, jointPayeePayments);

            return(jointPayees.Any(jp => DoesAnyOutstandingComplianceExistForJointVendor(jp, projectIds)));
        }
示例#13
0
 public virtual List <APRegister> ReleaseDocProc(JournalEntry journalEntry, APRegister document,
                                                 bool isPreBooking, out List <INRegister> documents, ReleaseDocProcDelegate baseHandler)
 {
     ValidateEmptyInvoiceJointPayees(document);
     return(IsCheckOrVoidCheck(document)
                         ? ReleaseCheckOrVoidCheck(journalEntry, document, isPreBooking, out documents, baseHandler)
                         : baseHandler(journalEntry, document, isPreBooking, out documents));
 }
示例#14
0
 public static APRegister Select(PXGraph graph, APRegister payment)
 {
     if (payment == null || payment.RefNbr == null || payment.DocType == null)
     {
         return(null);
     }
     return(Select(graph, APPaymentType.GetVoidingAPDocType(payment.DocType), payment.DocType, payment.RefNbr));
 }
 public void UpdateComplianceForJointCheck(JointPayee jointPayee, ComplianceDocument complianceDocument,
                                           APRegister check)
 {
     if (IsSameJointVendorInternalId(jointPayee, complianceDocument) ||
         IsSameJointVendorExternalName(jointPayee, complianceDocument))
     {
         UpdateComplianceDocument(complianceDocument, check, false);
     }
 }
 private void UpdateComplianceDocumentForVendorCheck(ComplianceDocument complianceDocument,
                                                     APRegister vendorCheck)
 {
     if (!complianceDocument.JointVendorInternalId.HasValue &&
         complianceDocument.JointVendorExternalName.IsNullOrEmpty())
     {
         UpdateComplianceDocument(complianceDocument, vendorCheck, true);
     }
 }
示例#17
0
 public void ValidateLienWaiversOnManualStatusChange(APRegister document, bool?shouldStopPayments)
 {
     if (shouldStopPayments == true)
     {
         exceptionMessage = string.Concat(ComplianceMessages.LienWaiver.BillHasOutstandingLienWaiverStopPayment,
                                          Environment.NewLine, ComplianceMessages.LienWaiver.CheckWillBeAssignedOnHoldStatus);
         CheckPaymentForOutstandingLienWaivers(document);
     }
 }
示例#18
0
        private IEnumerable <LienWaiverGenerationKey> CreateLienWaiverGroupingKeys(
            IReadOnlyCollection <JointPayee> jointPayees, APRegister payment, APTran transaction)
        {
            var adjustments = AdjustmentDataProvider.GetInvoiceAdjustments(Graph, transaction.RefNbr);

            return(adjustments.Any()
                ? CreateGroupingKeys(jointPayees, payment, transaction)
                : CreateGroupingKeysForPaymentByLines(jointPayees, payment, transaction));
        }
        public bool DoesAnyOutstandingComplianceExist(APRegister payment)
        {
            var adjustments = AdjustmentDataProvider.GetPaymentAdjustments(graph, payment.RefNbr, payment.DocType);
            var projectIds  = LienWaiverProjectDataProvider.GetProjectIds(graph, adjustments).ToList();

            return(DoesAnyOutstandingComplianceExistForPrimaryVendor(payment.VendorID, projectIds) ||
                   PaymentDataProvider.DoesCheckContainPaymentForJointVendors(graph, payment) &&
                   DoesAnyOutstandingComplianceExistForJointPayees(payment, projectIds));
        }
示例#20
0
        public void Test_CreateGAFRecordsForDocumentGroup_When_Document_Is_In_Base_Cury()
        {
            //Arrange
            var taxAgencyID = _vendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = _taxPeriodDataContext.TaxPeriod.TaxPeriodID;

            const decimal taxableAmt = 100;
            const decimal taxAmt     = 15;

            var paymentAggr = new APRegisterAggregateBuilder()
                              .CreateDocument(APDocType.Check,
                                              DocumentDataContext.RefNbr,
                                              DocumentDataContext.DocDate,
                                              CompanyDataContext.Company.BaseCuryID)
                              .DocumentWith(vendorID: _vendorDataContext.Vendor.BAccountID,
                                            vendorLocationID: _locationDataContext.VendorLocation.LocationID)
                              .AddTaxTran(new TaxTran()
            {
                TaxID          = TaxDataContext.WithholdingTax.TaxID,
                TaxableAmt     = taxableAmt,
                TaxAmt         = taxAmt,
                CuryTaxableAmt = 200,
                CuryTaxAmt     = 30,
                AdjdDocType    = APDocType.Invoice,
                AdjdRefNbr     = DocumentDataContext.RefNbr2
            })
                              .Build();

            var paymentAggregs = paymentAggr.SingleToArray();

            var adjdRegister = new APRegister
            {
                DocType = APDocType.Invoice,
                RefNbr  = DocumentDataContext.RefNbr2
            };

            SetupRepositoryMethods(paymentAggregs, adjdRegister.SingleToArray(), paymentAggr.Document.OrigModule, paymentAggr.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <AP.APRegister>()
            {
                Module            = paymentAggr.Document.OrigModule,
                DocumentType      = paymentAggr.Document.DocType,
                DocumentsByRefNbr = paymentAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var purchaseRecord = ApPaymentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID, taxPeriodID)
                                 .Single();

            //Assert
            Assert.Equal(taxableAmt, purchaseRecord.Amount);
            Assert.Equal(taxAmt, purchaseRecord.GSTAmount);
            Assert.Equal(ForeignCurrencyCodeForDocumentInBaseCury, purchaseRecord.ForeignCurrencyCode);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmount);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmountGST);
        }
 private void UpdateComplianceDocument(ComplianceDocument complianceDocument, APRegister check,
                                       bool isVendorCheck)
 {
     if (complianceDocument.DocumentType == GetLienWaiverDocumentTypeId())
     {
         UpdateComplianceDocumentForLienWaiverType(complianceDocument, check, isVendorCheck);
     }
     ComplianceDocumentRefNoteAttribute.SetComplianceDocumentReference <ComplianceDocument.apCheckId>(
         graph.Caches <ComplianceDocument>(), complianceDocument, check.DocType, check.RefNbr, check.NoteID);
 }
示例#22
0
        protected virtual void DocumentSelection_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
        {
            APRegister ap = e.Row as APRegister;

            if (ap != null && ap.Voided == false)
            {
                ap.ScheduleID = Schedule_Header.Current.ScheduleID;
                ap.Scheduled  = true;
            }
        }
示例#23
0
 public void VerifyStockItemLineHasReceipt(APRegister arRegisterRow, Action <APRegister> del)
 {
     if (arRegisterRow.CreatedByScreenID != ID.ScreenID.INVOICE_BY_APPOINTMENT &&
         arRegisterRow.CreatedByScreenID != ID.ScreenID.INVOICE_BY_SERVICE_ORDER)
     {
         if (del != null)
         {
             del(arRegisterRow);
         }
     }
 }
示例#24
0
        public virtual APRegister OnBeforeRelease(APRegister apdoc, OnBeforeReleaseDelegate del)
        {
            ValidatePostBatchStatus(PXDBOperation.Update, ID.Batch_PostTo.AP, apdoc.DocType, apdoc.RefNbr);

            if (del != null)
            {
                return(del(apdoc));
            }

            return(null);
        }
示例#25
0
        public void UpdateVendorBalanceDisplayName(APRegister invoice, PXCache cache)
        {
            var isRetainageGroup = invoice.IsRetainageDocument.GetValueOrDefault() ||
                                   invoice.RetainageApply.GetValueOrDefault();
            var displayName = isRetainageGroup
                ? JointCheckLabels.MaxAvailableAmount
                : JointCheckLabels.VendorBalance;
            var fieldAttributes = cache.GetAttributesOfType <PXUIFieldAttribute>(
                invoice, typeof(APInvoiceJCExt.vendorBalance).Name);

            fieldAttributes.Where(attribute => attribute != null).ForEach(x => x.DisplayName = displayName);
        }
示例#26
0
        private LienWaiverGenerationKey GetLienWaiverGroupingKey(APTran transaction, int?jointPayeeVendorId,
                                                                 APRegister payment)
        {
            var originalTransaction = TransactionDataProvider.GetOriginalTransaction(Graph, transaction);

            return(new LienWaiverGenerationKey
            {
                ProjectId = originalTransaction.ProjectID,
                VendorId = payment.VendorID,
                JointPayeeVendorId = jointPayeeVendorId,
                OrderNumber = GetCommitment(originalTransaction).OrderNbr
            });
        }
        /// <summary>
        /// Returns an enumerable string array, which is included all
        /// possible original document types for voiding document.
        /// </summary>
        public static IEnumerable <string> PossibleOriginalDocumentTypes(this APRegister voidcheck)
        {
            switch (voidcheck.DocType)
            {
            case APDocType.VoidCheck:
            case APDocType.VoidRefund:
            case APDocType.VoidQuickCheck:
                return(APPaymentType.GetVoidedAPDocType(voidcheck.DocType));

            default:
                return(new[] { voidcheck.DocType });
            }
        }
示例#28
0
        private void ReleaseJointPayeePayments(APRegister document)
        {
            var jointPayeePaymentsAndJointPayees = JointPayeePaymentDataProvider
                                                   .GetNonReleasedJointPayeePaymentsAndJointPayees(Base, document).ToList();

            foreach (var jointPayeePaymentAndJointPayee in jointPayeePaymentsAndJointPayees)
            {
                var jointPayee         = jointPayeePaymentAndJointPayee.GetItem <JointPayee>();
                var jointPayeePayments = jointPayeePaymentsAndJointPayees.RowCast <JointPayeePayment>()
                                         .Where(jpp => jpp.JointPayeeId == jointPayee.JointPayeeId);
                RecalculateJointPayee(jointPayeePayments, jointPayee);
            }
        }
        /// <summary>
        /// Indicates whether the record has zero document balance and zero lines balances
        /// depending on <see cref="APRegister.PaymentsByLinesAllowed"/> flag value.
        /// </summary>
        public static bool HasZeroBalance <TDocBal, TLineBal>(this APRegister document, PXGraph graph)
            where TDocBal : IBqlField
            where TLineBal : IBqlField
        {
            PXCache cache = graph.Caches[typeof(APRegister)];

            return((cache.GetValue <TDocBal>(document) as decimal? ?? 0m) == 0m && (document.PaymentsByLinesAllowed != true ||
                                                                                    // Select + AsEnumerable here to check Any() on merged cache.
                                                                                    !PXSelect <APTran,
                                                                                               Where <APTran.tranType, Equal <Required <APTran.tranType> >,
                                                                                                      And <APTran.refNbr, Equal <Required <APTran.refNbr> >,
                                                                                                           And <TLineBal, NotEqual <decimal0> > > > >
                                                                                    .Select(graph, document.DocType, document.RefNbr).AsEnumerable().Any()));
        }
示例#30
0
        public static bool Verify(PXGraph graph, APRegister payment)
        {
            bool?  result = null;
            object value  = null;

            new HasUnreleasedVoidPayment <APRegister.docType, APRegister.refNbr>().Verify(
                graph.Caches[payment.GetType()],
                payment,
                new List <object>(0),
                ref result,
                ref value);

            return(result == true);
        }