Example #1
0
        protected virtual IEnumerable dummyCustomAction(PXAdapter adapter)
        {
            SOShipment      shipment        = Base.Document.Current;
            SOOrderShipment soOrderShipment = PXSelect <SOOrderShipment,
                                                        Where <SOOrderShipment.shipmentNbr, Equal <Required <SOOrderShipment.shipmentNbr> > > > .
                                              Select(Base, shipment.ShipmentNbr);

            ARInvoice arInvoice = PXSelect <ARInvoice, Where <ARInvoice.refNbr, Equal <Required <ARInvoice.refNbr> >,
                                                              And <ARInvoice.docType, Equal <Required <ARInvoice.docType> > > > > .
                                  Select(Base, soOrderShipment.InvoiceNbr, "INV");

            PXLongOperation.StartOperation(Base, delegate()
            {
                SOInvoiceEntry soInvoiceGraph   = PXGraph.CreateInstance <SOInvoiceEntry>();
                SOShipmentEntry soShipmentGraph = PXGraph.CreateInstance <SOShipmentEntry>();
                //Release Sales Invoice
                soInvoiceGraph.Clear();
                soInvoiceGraph.Document.Current = soInvoiceGraph.Document.Search <ARInvoice.docType, ARInvoice.refNbr>(arInvoice.DocType, arInvoice.RefNbr);
                soInvoiceGraph.release.Press();
                //Update IN on Shipment
                soShipmentGraph.Clear();
                soShipmentGraph.Document.Current = soShipmentGraph.Document.Search <SOShipment.shipmentNbr>(shipment.ShipmentNbr);
                soShipmentGraph.UpdateIN.Press();
            });
            return(adapter.Get());
        }
        public static void ValidateCCPayment(PXGraph graph, List <IExternalTransaction> list, bool isMassProcess)
        {
            bool            failed          = false;
            ARCashSaleEntry arCashSaleGraph = null;
            ARPaymentEntry  arPaymentGraph  = null;
            SOInvoiceEntry  soInvoiceGraph  = null;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] == null)
                {
                    continue;
                }

                if ((i % 100) == 0)
                {
                    if (arCashSaleGraph != null)
                    {
                        arCashSaleGraph.Clear();
                    }
                    if (arPaymentGraph != null)
                    {
                        arPaymentGraph.Clear();
                    }
                    if (soInvoiceGraph != null)
                    {
                        soInvoiceGraph.Clear();
                    }
                }

                IExternalTransaction tran = list[i];

                var resultSet = PXSelectJoin <Standalone.ARRegister,
                                              LeftJoin <ARPayment,
                                                        On <ARPayment.refNbr, Equal <Standalone.ARRegister.refNbr>,
                                                            And <ARPayment.docType, Equal <Standalone.ARRegister.docType> > >,
                                                        LeftJoin <ARInvoice,
                                                                  On <ARInvoice.refNbr, Equal <Standalone.ARRegister.refNbr>,
                                                                      And <ARInvoice.docType, Equal <Standalone.ARRegister.docType> > >,
                                                                  LeftJoin <SOInvoice,
                                                                            On <SOInvoice.refNbr, Equal <Standalone.ARRegister.refNbr>,
                                                                                And <SOInvoice.docType, Equal <Standalone.ARRegister.docType> > >,
                                                                            LeftJoin <Standalone.ARCashSale,
                                                                                      On <Standalone.ARCashSale.refNbr, Equal <Standalone.ARRegister.refNbr>,
                                                                                          And <Standalone.ARCashSale.docType, Equal <Standalone.ARRegister.docType> > > > > > >,
                                              Where <Standalone.ARRegister.refNbr, Equal <Required <Standalone.ARRegister.refNbr> >,
                                                     And <Standalone.ARRegister.docType, Equal <Required <Standalone.ARRegister.docType> > > > >
                                .SelectSingleBound(graph, null, tran.RefNbr, tran.DocType);

                foreach (PXResult <Standalone.ARRegister, ARPayment, ARInvoice, SOInvoice, Standalone.ARCashSale> arDoc in resultSet)
                {
                    if (arDoc == null)
                    {
                        continue;
                    }

                    try
                    {
                        if ((ARInvoice)arDoc is ARInvoice arInvoice &&
                            arInvoice != null && arInvoice.RefNbr != null)
                        {
                            if ((SOInvoice)arDoc is SOInvoice soInvoice &&
                                soInvoice != null && soInvoice.RefNbr != null)
                            {
                                soInvoiceGraph = soInvoiceGraph != null ? soInvoiceGraph : PXGraph.CreateInstance <SOInvoiceEntry>();
                                SOInvoiceEntry.PaymentTransaction ext = soInvoiceGraph.GetExtension <SOInvoiceEntry.PaymentTransaction>();
                                soInvoiceGraph.Document.Current   = arInvoice;
                                soInvoiceGraph.SODocument.Current = soInvoice;
                                if (ext.CanValidate(arInvoice))
                                {
                                    ext.validateCCPayment.Press();
                                }
                            }
                            else if ((Standalone.ARCashSale)arDoc is Standalone.ARCashSale arCashSale &&
                                     arCashSale != null && arCashSale.RefNbr != null)
                            {
                                arCashSaleGraph = arCashSaleGraph != null ? arCashSaleGraph : PXGraph.CreateInstance <ARCashSaleEntry>();
                                ARCashSaleEntry.PaymentTransaction ext = arCashSaleGraph.GetExtension <ARCashSaleEntry.PaymentTransaction>();
                                arCashSaleGraph.Document.Current = arCashSale;
                                if (ext.CanValidate(arCashSaleGraph.Document.Current))
                                {
                                    ext.validateCCPayment.Press();
                                }
                            }
                        }