Exemple #1
0
        protected APPayment GenerateVendorCheck()
        {
            if (InvoiceExtension.AmountToPay == 0)
            {
                return(null);
            }
            var vendorCheck = CreateVendorCheck();

            ComplianceDocumentsService.UpdateComplianceDocumentsForVendorCheck(ComplianceDocuments, vendorCheck);
            CreateZeroAmountJointPayeePaymentsForVendorCheck(vendorCheck);
            MarkPaymentForLienWaiverGeneration(true);
            PaymentEntry.Persist();
            return(vendorCheck);
        }
Exemple #2
0
        private const bool AutoReleaseDebitAdjustments = true;         //TODO: now (26.10.2017) we can't apply nonreleased debit adjustment

        public static APInvoice CreateAndReleasePPDDebitAdj(APInvoiceEntry ie, APPPDDebitAdjParameters filter, List <PendingPPDDebitAdjApp> list, bool autoReleaseDebitAdjustments)
        {
            APInvoice invDebitAdj;

            try
            {
                ie.Clear(PXClearOption.ClearAll);
                PXUIFieldAttribute.SetError(ie.Document.Cache, null, null, null);

                using (var ts = new PXTransactionScope())
                {
                    invDebitAdj = ie.CreatePPDDebitAdj(filter, list);
                    if (invDebitAdj != null)
                    {
                        if (autoReleaseDebitAdjustments == true)
                        {
                            using (new PXTimeStampScope(null))
                            {
                                APDocumentRelease.ReleaseDoc(new List <APRegister> {
                                    invDebitAdj
                                }, false);
                                APPaymentEntry paymentEntry = PXGraph.CreateInstance <APPaymentEntry>();
                                APPayment      debitAdj     = PXSelect <APPayment,
                                                                        Where <APPayment.docType, Equal <Required <APPayment.docType> >,
                                                                               And <APPayment.refNbr, Equal <Required <APPayment.refNbr> > > > >
                                                              .Select(paymentEntry, invDebitAdj.DocType, invDebitAdj.RefNbr)
                                                              .First();

                                paymentEntry.Document.Current = debitAdj;
                                paymentEntry.SelectTimeStamp();
                                CreatePPDApplications(paymentEntry, list, debitAdj);
                                paymentEntry.Persist();
                                APDocumentRelease.ReleaseDoc(new List <APRegister> {
                                    invDebitAdj
                                }, false);                                                                                               // It needs to release applications
                            }
                        }

                        foreach (PendingPPDDebitAdjApp adj in list)
                        {
                            PXProcessing <PendingPPDDebitAdjApp> .SetInfo(adj.Index, ActionsMessages.RecordProcessed);
                        }
                    }
                    ts.Complete();
                }
            }
            catch (Exception e)
            {
                foreach (PendingPPDDebitAdjApp adj in list)
                {
                    PXProcessing <PendingPPDDebitAdjApp> .SetError(adj.Index, e);
                }

                invDebitAdj = null;
            }

            return(invDebitAdj);
        }
        private void LinkComplianceDocumentsToCheck(APPaymentEntry paymentEntry)
        {
            paymentEntry.Persist();
            Base.Persist();

            Base.Caches <ComplianceDocument>().ClearQueryCache();
            Base.Caches <ComplianceDocument>().Clear();

            PXDBTimestampAttribute timestampAttribute = Base.Caches <ComplianceDocument>()
                                                        .GetAttributesOfType <PXDBTimestampAttribute>(null, nameof(ComplianceDocument.Tstamp))
                                                        .First();

            timestampAttribute.RecordComesFirst = true;

            var complianceDocuments = complianceDocumentsService.GetComplianceDocumentsToLink();

            complianceDocumentsService.UpdateComplianceDocumentsForVendorCheck(complianceDocuments,
                                                                               paymentEntry.Document.Current);
            complianceDocumentsService.ClearLinkToPaymentFlag(complianceDocuments);
        }