Exemplo n.º 1
0
        private void ValidateAdjustment(APInvoiceEntry.APAdjust adjustment)
        {
            var referenceId = ComplianceDocumentReferenceRetriever.GetComplianceDocumentReferenceId(Base, adjustment);
            var hasExpiredComplianceDocuments = service.ValidateRelatedField <
                APInvoiceEntry.APAdjust, ComplianceDocument.apCheckId, APAdjust.displayRefNbr>(adjustment, referenceId);

            service.ValidateRelatedRow <APInvoiceEntry.APAdjust, ApAdjustExt.hasExpiredComplianceDocuments>(
                adjustment, hasExpiredComplianceDocuments);
        }
Exemplo n.º 2
0
        public void RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
        {
            var refCache = cache.Graph.Caches[typeof(ComplianceDocumentReference)];

            if (e.TranStatus == PXTranStatus.Open)
            {
                ComplianceDocument doc = e.Row as ComplianceDocument;

                if (doc == null)
                {
                    return;
                }

                var referenceId = (Guid?)cache.GetValue(e.Row, _FieldOrdinal);

                if (referenceId.HasValue && referenceId.Value != Guid.Empty)
                {
                    var reference =
                        ComplianceDocumentReferenceRetriever.GetComplianceDocumentReference(cache.Graph, referenceId);

                    if (reference != null)
                    {
                        reference = (ComplianceDocumentReference)refCache.Locate(reference);

                        if (reference != null)
                        {
                            if (refCache.GetStatus(reference) == PXEntryStatus.Inserted)
                            {
                                refCache.PersistInserted(reference);
                            }
                            else if (refCache.GetStatus(reference) == PXEntryStatus.Updated)
                            {
                                refCache.PersistUpdated(reference);
                            }
                        }
                    }
                    else
                    {
                        reference = (ComplianceDocumentReference)refCache.Locate(new ComplianceDocumentReference()
                        {
                            ComplianceDocumentReferenceId = referenceId
                        });

                        if (reference != null && refCache.GetStatus(reference) == PXEntryStatus.Deleted)
                        {
                            refCache.PersistDeleted(reference);
                        }
                    }
                }
            }
            else if (e.TranStatus == PXTranStatus.Aborted || e.TranStatus == PXTranStatus.Completed)
            {
                refCache.Persisted(e.TranStatus == PXTranStatus.Aborted);
            }
        }
Exemplo n.º 3
0
        private static decimal?GetBillAmount(Guid?refNoteId, PXGraph senderGraph)
        {
            if (!refNoteId.HasValue)
            {
                return(null);
            }
            var reference = ComplianceDocumentReferenceRetriever.GetComplianceDocumentReference(senderGraph, refNoteId);
            var bill      = GetBill(senderGraph, reference);

            return(bill?.OrigDocAmt);
        }
Exemplo n.º 4
0
        private void TryDeleteReference(PXCache cache, Guid?referenceId)
        {
            if (referenceId.HasValue && referenceId.Value != Guid.Empty)
            {
                var reference = ComplianceDocumentReferenceRetriever.GetComplianceDocumentReference(cache.Graph, referenceId);

                if (reference != null)
                {
                    cache.Graph.Caches[typeof(ComplianceDocumentReference)].Delete(reference);
                }
            }
        }
Exemplo n.º 5
0
        private string GetDescription(PXCache cache, object row)
        {
            var referenceId = (Guid?)cache.GetValue(row, _FieldOrdinal);

            if (referenceId.HasValue && referenceId.Value != Guid.Empty)
            {
                var reference = ComplianceDocumentReferenceRetriever.GetComplianceDocumentReference(
                    cache.Graph, referenceId);
                if (reference != null)
                {
                    return(GetFieldValue(reference));
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        private void ValidateTransaction(APTran transaction)
        {
            var projectHasExpiredCompliance =
                service.ValidateRelatedProjectField <APTran, APTran.projectID>(transaction, transaction.ProjectID);
            var taskHasExpiredCompliance =
                service.ValidateRelatedField <APTran, ComplianceDocument.costTaskID, APTran.taskID>(transaction,
                                                                                                    transaction.TaskID);
            var purchaseOrderOrSubcontractHasExpiredCompliance = IsSubcontract(transaction)
                ? service.ValidateRelatedField <APTran, ComplianceDocument.subcontract,
                                                ApTranExt.subcontractNbr>(transaction, transaction.PONbr)
                : service.ValidateRelatedField <APTran, ComplianceDocument.purchaseOrder, APTran.pONbr>(
                transaction, ComplianceDocumentReferenceRetriever.GetComplianceDocumentReferenceId(Base, transaction));

            service.ValidateRelatedRow <APTran, PX.Objects.CN.Compliance.AP.CacheExtensions.ApTranExt.hasExpiredComplianceDocuments>(transaction,
                                                                                                                                     projectHasExpiredCompliance || taskHasExpiredCompliance || purchaseOrderOrSubcontractHasExpiredCompliance);
        }
Exemplo n.º 7
0
        public void Redirect(Type itemType, Guid referenceId)
        {
            var redirectionInstruction = redirectionInstructions.Single(x => x.EntityType == itemType);
            var graph = PXGraph.CreateInstance(redirectionInstruction.GraphType);

            if (graph != null)
            {
                var reference = ComplianceDocumentReferenceRetriever.GetComplianceDocumentReference(graph, referenceId);
                var entity    = GetEntity(graph, redirectionInstruction, reference.Type, reference.ReferenceNumber);
                graph.Caches[redirectionInstruction.EntityType].Current = entity;
                throw new PXRedirectRequiredException(graph, string.Empty)
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
        }
Exemplo n.º 8
0
 private Guid?GetComplianceDocumentReferenceId(APInvoice bill)
 {
     return(ComplianceDocumentReferenceRetriever.GetComplianceDocumentReferenceId(Base, bill));
 }
Exemplo n.º 9
0
 private Guid?GetComplianceDocumentReferenceId(ARInvoice invoice)
 {
     return(ComplianceDocumentReferenceRetriever.GetComplianceDocumentReferenceId(Base, invoice));
 }
Exemplo n.º 10
0
        private void ValidateAdjustment(ARAdjust2 adjustment)
        {
            var documentHasExpiredCompliance =
                service.ValidateRelatedField <ARAdjust2, ComplianceDocument.arPaymentID, ARAdjust2.adjgRefNbr>(adjustment,
                                                                                                               ComplianceDocumentReferenceRetriever.GetComplianceDocumentReferenceId(Base, adjustment));

            service.ValidateRelatedRow <ARAdjust2, ArAdjust2Ext.hasExpiredComplianceDocuments>(adjustment,
                                                                                               documentHasExpiredCompliance);
        }
Exemplo n.º 11
0
        private void ValidateAdjustments <TInvoiceField, TCustomerField>(ARAdjust adjustment)
            where TInvoiceField : IBqlField
            where TCustomerField : IBqlField
        {
            var arInvoice = GetArInvoice(adjustment);

            if (arInvoice == null)
            {
                return;
            }
            var invoiceHasExpiredCompliance =
                service.ValidateRelatedField <ARAdjust, ComplianceDocument.invoiceID, TInvoiceField>(adjustment,
                                                                                                     ComplianceDocumentReferenceRetriever.GetComplianceDocumentReferenceId(Base, arInvoice));
            var customerHasExpiredCompliance =
                service.ValidateRelatedField <ARAdjust, ComplianceDocument.customerID, TCustomerField>(adjustment,
                                                                                                       arInvoice.CustomerID);

            service.ValidateRelatedRow <ARAdjust, ArAdjustExt.hasExpiredComplianceDocuments>(adjustment,
                                                                                             invoiceHasExpiredCompliance || customerHasExpiredCompliance);
        }
        private decimal?GetTotalAmountForRelatedToCheckLienWaivers(
            IEnumerable <ComplianceDocument> lienWaiversRelatedToCheck)
        {
            var lienWaiversCheckReferences = lienWaiversRelatedToCheck.ToDictionary(lw => lw,
                                                                                    lw => ComplianceDocumentReferenceRetriever.GetComplianceDocumentReference(graph, lw.ApCheckID)
                                                                                    .RefNoteId);
            var referenceGroups = lienWaiversCheckReferences.GroupBy(checkRef => checkRef.Value);

            return(referenceGroups.Sum(rg => rg.Max(group => group.Key.LienWaiverAmount)));
        }