コード例 #1
0
        private void RedistributeDeduction(IRUTROTable document, RUTROT rutrot, ARSetup setup, CurrencyInfo curyInfo)
        {
            if (document == null || document.IsRUTROTDeductible != true || rutrot == null)
            {
                return;
            }

            var persons = RRDistribution.Select().ToList();
            int count   = persons.Count;

            if (rutrot.AutoDistribution == true && count != 0)
            {
                decimal totalFromTrans = rutrot.CuryTotalAmt ?? 0.0m;


                var distributor = new DistributionRounding(setup, PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.invoiceRounding>())
                {
                    PreventOverflow = true, CuryPlaces = curyInfo?.CuryPrecision ?? 0
                };
                var amts = distributor.DistributeEven(totalFromTrans, count);

                foreach (var p in persons.Zip(amts, (p, a) => new { DistributionItem = p, Amount = a }))
                {
                    var item = (RUTROTDistribution)RRDistribution.Cache.CreateCopy((RUTROTDistribution)p.DistributionItem);
                    if (item.CuryAmount != p.Amount)
                    {
                        item.CuryAmount = p.Amount;
                        RRDistribution.Cache.Update(item);
                    }
                }
            }

            RRDistribution.View.RequestRefresh();
        }
        public static CCProcTran findCapturing(PXSelectBase <CCProcTran> ccProcTran)
        {
            List <CCProcTran> authTrans = new List <CCProcTran>(1);
            List <CCProcTran> result    = new List <CCProcTran>(1);

            foreach (CCProcTran iTran in ccProcTran.Select())
            {
                if (iTran.ProcStatus != CCProcStatus.Finalized)
                {
                    continue;
                }
                if ((
                        iTran.TranType == CCTranTypeCode.PriorAuthorizedCapture ||
                        iTran.TranType == CCTranTypeCode.AuthorizeAndCapture ||
                        iTran.TranType == CCTranTypeCode.CaptureOnly
                        ) &&
                    iTran.TranStatus == CCTranStatusCode.Approved)
                {
                    authTrans.Add(iTran);
                }
            }
            foreach (CCProcTran it in authTrans)
            {
                bool cancelled = false;
                foreach (CCProcTran iTran in ccProcTran.Select())
                {
                    if (iTran.ProcStatus != CCProcStatus.Finalized)
                    {
                        continue;
                    }
                    if (iTran.RefTranNbr == it.TranNbr && iTran.TranStatus == CCTranStatusCode.Approved)
                    {
                        if (iTran.TranType == CCTranTypeCode.Credit ||
                            iTran.TranType == CCTranTypeCode.VoidTran)
                        {
                            cancelled = true;
                            break;
                        }
                    }
                }
                if (!cancelled)
                {
                    result.Add(it);
                }
            }
            if (result.Count > 0)
            {
                result.Sort(new CCProcTranOrderComparer(true)                 /*Comparison<CCProcTran>(delegate(CCProcTran a, CCProcTran b)
                                                                               * {
                                                                               * return a.EndTime.Value.CompareTo(b.EndTime.Value);
                                                                               * }
                                                                               * )*/
                            );
                return(result[0]);
            }
            return(null);
        }
コード例 #3
0
        public static void CaptureCCPayment <TNode>(TNode doc, PXSelectBase <CCProcTran> ccProcTran,
                                                    CCPaymentEntry.ReleaseDelegate aReleaseDelegate,
                                                    UpdateDocStateDelegate aDocStateUpdater,
                                                    ICCTransactionsProcessor processor = null)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (processor == null)
            {
                processor = CCTransactionsProcessor.GetCCTransactionsProcessor();
            }
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCProcTranHelper.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                CCPaymentState paymentState = CCProcTranHelper.ResolveCCPaymentState(ccProcTran.Select());
                if ((paymentState & (CCPaymentState.Captured)) > 0)
                {
                    throw new PXException(Messages.ERR_CCAuthorizedPaymentAlreadyCaptured);
                }
                if (doc.Released == false)
                {
                    ccProcTran.View.Graph.Actions.PressSave();
                }
                CCProcTran authTran = CCProcTranHelper.FindCCPreAthorizing(ccProcTran.Select());
                TNode      toProc   = PXCache <TNode> .CreateCopy(doc);

                CCProcTran authTranCopy = null;
                if (authTran != null && !CCProcTranHelper.IsExpired(authTran))
                {
                    authTranCopy = PXCache <CCProcTran> .CreateCopy(authTran);
                }
                CCTranType operation = (authTranCopy) != null ? CCTranType.PriorAuthorizedCapture : CCTranType.AuthorizeAndCapture;
                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        processor.ProcessCCTransaction(toProc, authTranCopy, operation);
                    }
                    finally
                    {
                        //Update doc state in any case
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, operation);
                        }
                    }
                    if (aReleaseDelegate != null)
                    {
                        aReleaseDelegate(toProc);                               //On Success Only
                    }
                });
            }
        }
コード例 #4
0
 public void GenerateColumns(PXCache cache, string documentsView, string answerView,
                             bool areColumnsEnabled = true)
 {
     areControlsEnabled = areColumnsEnabled;
     documentCache      = cache;
     RemoveUnboundFields(cache);
     attributeGroups.Select().FirstTableItems.OrderBy(x => x.SortOrder)
     .ForEach(attributeGroup => ProcessAttributeGroup(cache, documentsView, attributeGroup));
     AddRowEventHandlers(documentsView, answerView);
 }
コード例 #5
0
        private void RedistributeDeduction(IRUTROTable document, RUTROT rutrot, ARSetup setup, CurrencyInfo curyInfo)
        {
            if (document == null || document.IsRUTROTDeductible != true || rutrot == null)
            {
                return;
            }

            var persons = RRDistribution.Select().ToList();
            int count   = persons.Count;

            if (rutrot.AutoDistribution == true && count != 0)
            {
                decimal totalFromTrans = rutrot.CuryTotalAmt ?? 0.0m;


                DistributionRounding distributor;

                PXCache  currencyInfoCache = Base.Caches[typeof(CurrencyInfo)];
                Currency currency          = null;

                if (currencyInfoCache.Current != null)
                {
                    currency = PXSelect <Currency, Where <Currency.curyID, Equal <Required <CurrencyInfo.curyID> > > > .Select(Base, (currencyInfoCache.Current as CurrencyInfo).CuryID);
                }

                if (currency?.UseARPreferencesSettings == false)
                {
                    distributor = new DistributionRounding(currency, PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.invoiceRounding>())
                    {
                        PreventOverflow = true, CuryPlaces = curyInfo?.CuryPrecision ?? 0
                    };
                }
                else
                {
                    distributor = new DistributionRounding(setup, PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.invoiceRounding>())
                    {
                        PreventOverflow = true, CuryPlaces = curyInfo?.CuryPrecision ?? 0
                    };
                }

                var amts = distributor.DistributeEven(totalFromTrans, count);

                foreach (var p in persons.Zip(amts, (p, a) => new { DistributionItem = p, Amount = a }))
                {
                    var item = (RUTROTDistribution)RRDistribution.Cache.CreateCopy((RUTROTDistribution)p.DistributionItem);
                    if (item.CuryAmount != p.Amount)
                    {
                        item.CuryAmount = p.Amount;
                        RRDistribution.Cache.Update(item);
                    }
                }
            }

            RRDistribution.View.RequestRefresh();
        }
コード例 #6
0
        public static void RecordCCPayment <TNode>(TNode doc, string aExtPCTranNbr, string aPCAuthNbr, PXSelectBase <CCProcTran> ccProcTran, CCPaymentEntry.ReleaseDelegate aReleaseDelegate, UpdateDocStateDelegate aDocStateUpdater)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCProcTranHelper.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                if (string.IsNullOrEmpty(aExtPCTranNbr))
                {
                    throw new PXException(Messages.ERR_PCTransactionNumberOfTheOriginalPaymentIsRequired);
                }


                CCPaymentState paymentState = CCProcTranHelper.ResolveCCPaymentState(ccProcTran.Select());
                if ((paymentState & (CCPaymentState.Captured)) > 0)
                {
                    throw new PXException(Messages.ERR_CCAuthorizedPaymentAlreadyCaptured);
                }

                if (doc.Released == false)
                {
                    ccProcTran.View.Graph.Actions.PressSave();
                }

                TNode toProc = PXCache <TNode> .CreateCopy(doc);

                CCProcTran authTran  = CCProcTranHelper.FindCCPreAthorizing(ccProcTran.Select());
                CCTranType operation = CCTranType.AuthorizeAndCapture;
                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        var graph        = PXGraph.CreateInstance <CCPaymentProcessingGraph>();
                        int?tranID       = 0;
                        string extTranID = aExtPCTranNbr;
                        graph.RecordCapture(doc, extTranID, aPCAuthNbr, null, ref tranID);
                    }
                    finally
                    {
                        //Update doc state in any case
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, operation);
                        }
                    }
                    if (aReleaseDelegate != null)
                    {
                        aReleaseDelegate(toProc);                               //On Success Only
                    }
                });
            }
        }
コード例 #7
0
        private void ClearWorkTypes(RUTROT rutrot)
        {
            foreach (Tran line in Transactions.Select())
            {
                TranExt        lineRR   = RUTROTHelper.GetExtensionNullable <Tran, TranExt>(line);
                RUTROTWorkType workType = PXSelect <RUTROTWorkType, Where <RUTROTWorkType.workTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this.Base, lineRR.RUTROTWorkTypeID);

                if (workType?.RUTROTType != rutrot.RUTROTType)
                {
                    lineRR.RUTROTWorkTypeID = null;
                    Transactions.Update(line);
                }
            }
        }
コード例 #8
0
 public IEnumerable <IExternalTransaction> Select(params object[] arguments)
 {
     foreach (T item in externalTransaction.Select(arguments))
     {
         yield return(item);
     }
 }
コード例 #9
0
        //@TODO SD-7694
        public static IEnumerable RouteRecordsDelegate(
            PXFilter <RouteAppointmentAssignmentFilter> filter,
            PXSelectBase <FSRouteDocument> cmd)
        {
            if (filter.Current == null)
            {
                yield break;
            }

            foreach (PXResult <FSRouteDocument, FSRoute> bqlResult in cmd.Select())
            {
                FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult;
                FSRoute         fsRouteRow         = (FSRoute)bqlResult;
                if (filter.Current.RouteDate.HasValue == true)
                {
                    if (!fsRouteDocumentRow.TimeBegin.HasValue)
                    {
                        fsRouteDocumentRow.TimeBegin = AppointmentCore.GetDateTimeEnd(fsRouteDocumentRow.Date, 0, 0, 0);
                    }

                    if (fsRouteDocumentRow.Date.Value.Date >= filter.Current.RouteDate.Value.Date &&
                        fsRouteDocumentRow.Date.Value.Date <= AppointmentCore.GetDateTimeEnd(filter.Current.RouteDate.Value.Date, 23, 59, 59))
                    {
                        yield return(bqlResult);
                    }
                }
                else
                {
                    yield return(bqlResult);
                }
            }
        }
        public static void AuthorizeCCPayment <TNode>(TNode doc, PXSelectBase <CCProcTran> ccProcTran, UpdateDocStateDelegate aDocStateUpdater)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCPaymentEntry.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                CCPaymentState paymentState = CCPaymentEntry.ResolveCCPaymentState(ccProcTran.Select());
                if ((paymentState & (CCPaymentState.Captured | CCPaymentState.PreAuthorized)) > 0)
                {
                    throw new PXException(Messages.ERR_CCPaymentAlreadyAuthorized);
                }

                ccProcTran.View.Graph.Actions.PressSave();

                TNode toProc = PXCache <TNode> .CreateCopy(doc);

                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate() {
                    try
                    {
                        CCPaymentEntry.ProcessCCTransaction(toProc, null, CCTranType.AuthorizeOnly);
                    }
                    finally
                    {
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, CCTranType.AuthorizeOnly);
                        }
                    }
                });
            }
        }
コード例 #11
0
        public static void CalculateBalancesAR <TInvoice>(PXGraph graph, PXSelectBase <CurrencyInfo> curyInfoSelect, ARAdjust adj, TInvoice invoice, bool isCalcRGOL, bool DiscOnDiscDate)
            where TInvoice : IInvoice
        {
            Customer currentCustomer = PXSelect <Customer, Where <Customer.bAccountID, Equal <Optional <CABankTran.payeeBAccountID> > > > .Select(graph);

            PaymentEntry.CalcBalances <TInvoice, ARAdjust>(curyInfoSelect, adj.AdjgCuryInfoID, adj.AdjdCuryInfoID, invoice, adj);
            if (DiscOnDiscDate)
            {
                PaymentEntry.CalcDiscount <TInvoice, ARAdjust>(adj.AdjgDocDate, invoice, adj);
            }
            PaymentEntry.WarnDiscount <TInvoice, ARAdjust>(graph, adj.AdjgDocDate, invoice, adj);

            CurrencyInfo pay_info   = curyInfoSelect.Select(adj.AdjgCuryInfoID);
            CurrencyInfo vouch_info = curyInfoSelect.Select(adj.AdjdCuryInfoID);

            if (vouch_info != null && string.Equals(pay_info.CuryID, vouch_info.CuryID) == false)
            {
                adj.AdjdCuryRate = Math.Round((vouch_info.CuryMultDiv == "M" ? (decimal)vouch_info.CuryRate : 1 / (decimal)vouch_info.CuryRate) * (pay_info.CuryMultDiv == "M" ? 1 / (decimal)pay_info.CuryRate : (decimal)pay_info.CuryRate), 8, MidpointRounding.AwayFromZero);
            }
            else
            {
                adj.AdjdCuryRate = 1m;
            }

            if (currentCustomer != null && currentCustomer.SmallBalanceAllow == true && adj.AdjgDocType != ARDocType.Refund && adj.AdjdDocType != ARDocType.CreditMemo)
            {
                decimal      payment_smallbalancelimit;
                CurrencyInfo payment_info = curyInfoSelect.Select(adj.AdjgCuryInfoID);
                PXDBCurrencyAttribute.CuryConvCury(curyInfoSelect.Cache, payment_info, currentCustomer.SmallBalanceLimit ?? 0m, out payment_smallbalancelimit);
                adj.CuryWOBal = payment_smallbalancelimit;
                adj.WOBal     = currentCustomer.SmallBalanceLimit;
            }
            else
            {
                adj.CuryWOBal = 0m;
                adj.WOBal     = 0m;
            }

            PaymentEntry.AdjustBalance <ARAdjust>(curyInfoSelect, adj);
            if (isCalcRGOL && (adj.Voided != true))
            {
                PaymentEntry.CalcRGOL <TInvoice, ARAdjust>(curyInfoSelect, invoice, adj);
                adj.RGOLAmt = (bool)adj.ReverseGainLoss ? -1.0m * adj.RGOLAmt : adj.RGOLAmt;
            }
        }
コード例 #12
0
        private P GetPMDetail(T input)
        {
            P ret = pmDetailView.Select().ToList().Where(i => {
                P detail = i;
                return(detail.PaymentMethodID == input.PaymentMethodID && detail.DetailID == input.DetailID);
            }).First();

            return(ret);
        }
        ///<summary>
        /// Finding inconsistency between GL Batch and its transactions.
        /// Run this method at end point of the "Release" process.
        /// Validating case:
        /// Debit and credit sums for GL Batch and its transactions should always
        /// be the same after the "Release" process.
        ///</summary>
        public DataIntegrityValidator <TRegister> CheckBatchAndTransactionsSumsForDocument(bool disableCheck = false)
        {
            if (IsSkipCheck(disableCheck))
            {
                return(this);
            }

            PXSelectBase <Batch> selectBatchAndTrans = new PXSelectJoin <
                Batch,
                InnerJoin <GLTran,
                           On <GLTran.module, Equal <Batch.module>,
                               And <GLTran.batchNbr, Equal <Batch.batchNbr> > > >,
                Where <
                    Batch.module, Equal <Required <Batch.module> >,
                    And <Batch.batchNbr, Equal <Required <Batch.batchNbr> > > > >(_graph);

            foreach (string batchNbr in _selectGLTran
                     .Select(_module, _doc.DocType, _doc.RefNbr, _referenceID)
                     .RowCast <GLTran>()
                     .Where(tran => tran.Posted != true)
                     .GroupBy(tran => tran.BatchNbr)
                     .Select(group => group.Key))
            {
                PXResultset <Batch> set = selectBatchAndTrans.Select(_module, batchNbr);
                Batch batch             = (Batch)set;

                var result = set
                             .Cast <PXResult <Batch, GLTran> >()
                             .Select(item => new
                {
                    DebitTotal      = ((GLTran)item).DebitAmt,
                    CreditTotal     = ((GLTran)item).CreditAmt,
                    CuryDebitTotal  = ((GLTran)item).CuryDebitAmt,
                    CuryCreditTotal = ((GLTran)item).CuryCreditAmt
                })
                             .Aggregate((prev, next) => new
                {
                    DebitTotal      = prev.DebitTotal + next.DebitTotal,
                    CreditTotal     = prev.CreditTotal + next.CreditTotal,
                    CuryDebitTotal  = prev.CuryDebitTotal + next.CuryDebitTotal,
                    CuryCreditTotal = prev.CuryCreditTotal + next.CuryCreditTotal
                });

                if (batch.DebitTotal != result.DebitTotal ||
                    batch.CreditTotal != result.CreditTotal ||
                    batch.CuryDebitTotal != result.CuryDebitTotal ||
                    batch.CuryCreditTotal != result.CuryCreditTotal)
                {
                    _errors.Add(
                        new InconsistencyError <InconsistencyCode.batchTotalNotEqualToTransactionTotal>(
                            new RecordContextInfo(_docCache, _doc),
                            new RecordContextInfo(selectBatchAndTrans.Cache, batch)));
                }
            }

            return(this);
        }
コード例 #14
0
        public IEnumerable <Tuple <ICCPaymentProfileDetail, ICCPaymentMethodDetail> > Select(params object[] arguments)
        {
            PXResultset <T> resultSet = profileDetailView.Select(arguments);

            foreach (PXResult <T> item in resultSet)
            {
                var p1 = (T)item;
                var p2 = GetPMDetail(p1);
                yield return(Tuple.Create <ICCPaymentProfileDetail, ICCPaymentMethodDetail>(p1, p2));
            }
        }
コード例 #15
0
        public GetAttributeRecords(PXGraph graph, ref int?bAccountID, ref int?inventoryID)
        {
            CROpportunity current1 = graph.Caches <CROpportunity>().Current as CROpportunity;
            PXFieldState  valueExt = graph.Caches <CROpportunity>().GetValueExt((object)current1, "AttributeENDCUSTOME") as PXFieldState;

            bAccountID = PXSelectBase <BAccountR, PXSelect <BAccountR, Where <BAccountR.acctCD, Equal <Required <BAccountR.acctCD> > > > .Config> .Select(graph, valueExt.Value).TopFirst.BAccountID;

            CROpportunityProducts current2 = graph.Caches <CROpportunityProducts>().Current as CROpportunityProducts;

            inventoryID = current2.InventoryID;
        }
 public static bool HasOpenCCTran(PXSelectBase <CCProcTran> ccProcTran)
 {
     foreach (CCProcTran iTr in ccProcTran.Select())
     {
         if (iTr.ProcStatus == CCProcStatus.Opened && !IsExpired(iTr))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #17
0
        /// <summary>
        /// Return a list of services without their skills.
        /// </summary>
        /// <param name="cmd">Base select over the Inventory Item table.</param>
        /// <param name="serviceList">Services that will be excluded from the returned list.</param>
        private static IEnumerable <InventoryItem> GetListWithServicesOnly(PXSelectBase <InventoryItem> cmd, List <int?> serviceList)
        {
            foreach (InventoryItem inventoryRow in cmd.Select())
            {
                if (serviceList.Exists(delegate(int?serviceID) { return(serviceID == inventoryRow.InventoryID); }) == true)
                {
                    continue;
                }

                yield return(inventoryRow);
            }
        }
コード例 #18
0
            public IEnumerable GetRecords()
            {
                if (_select == null)
                {
                    yield break;
                }

                foreach (PXResult <WikiPage> record in _select.Select(_graph.Message.Current.WikiID))
                {
                    yield return((WikiPage)record);
                }
            }
        public static void RecordCCCredit <TNode>(TNode doc, string aRefPCTranNbr, string aExtPCTranNbr, string aPCAuthNbr, PXSelectBase <CCProcTran> ccProcTran, CCPaymentEntry.ReleaseDelegate aReleaseDelegate, UpdateDocStateDelegate aDocStateUpdater)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCPaymentEntry.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                if (string.IsNullOrEmpty(aExtPCTranNbr))
                {
                    throw new PXException(Messages.ERR_PCTransactionNumberOfTheOriginalPaymentIsRequired);
                }


                CCPaymentState paymentState = CCPaymentEntry.ResolveCCPaymentState(ccProcTran.Select());
                if ((paymentState & (CCPaymentState.Refunded)) > 0)
                {
                    throw new PXException(Messages.ERR_CCPaymentIsAlreadyRefunded);
                }


                ccProcTran.View.Graph.Actions.PressSave();
                TNode toProc = PXCache <TNode> .CreateCopy(doc);

                CCTranType operation = CCTranType.Credit;
                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        CCPaymentProcessing ccProcGraph = PXGraph.CreateInstance <CCPaymentProcessing>();
                        int?tranID;
                        if (ccProcGraph.RecordCredit(doc, aRefPCTranNbr, aExtPCTranNbr, aPCAuthNbr, out tranID))
                        {
                        }
                    }
                    finally
                    {
                        //Update doc state in any case
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, operation);
                        }
                    }
                    if (aReleaseDelegate != null)
                    {
                        aReleaseDelegate(toProc);                               //On Success Only
                    }
                });
            }
        }
コード例 #20
0
        public PXResultset <CustomerPaymentMethodDetail, PaymentMethodDetail> Select(params object[] argumetns)
        {
            PXResultset <T> resultSet = dataView.Select(argumetns);
            PXResultset <CustomerPaymentMethodDetail, PaymentMethodDetail> retResultSet = new PXResultset <CustomerPaymentMethodDetail, PaymentMethodDetail>();

            foreach (PXResult <T, PaymentMethodDetail> result in resultSet)
            {
                CustomerPaymentMethodDetail cpmd = result;
                PaymentMethodDetail         pmd  = (PaymentMethodDetail)result;
                retResultSet.Add(new PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail>(cpmd, pmd));
            }
            return(retResultSet);
        }
コード例 #21
0
        protected virtual IEnumerable result()
        {
            var filter = Filter.Current;

            if (!ValidateFilter(filter))
            {
                return(new LumDeadStockEnqResult[0]);
            }

            GetStartDates(filter, out DateTime? inStockSince, out DateTime? noSalesSince);
            PXSelectBase <INSiteStatus> command = CreateCommand();
            var parameters = AddFilters(filter, command, inStockSince, noSalesSince);

            var singleRow = GetRowByPrimaryKeys(command, filter, inStockSince, noSalesSince);

            if (singleRow != null)
            {
                return new LumDeadStockEnqResult[] { singleRow }
            }
            ;

            bool userSortsFilters = ValidateViewSortsFilters();

            var result = new PXDelegateResult();

            result.IsResultFiltered = !userSortsFilters;
            result.IsResultSorted   = !userSortsFilters;
            int resultCounter = 0;

            foreach (PXResult <INSiteStatus> row in command.Select(parameters.ToArray()))
            {
                LumDeadStockEnqResult newResult = MakeResult(row, inStockSince, noSalesSince);

                if (newResult == null)
                {
                    continue;
                }

                result.Add(new PXResult <LumDeadStockEnqResult, InventoryItem>(newResult, row.GetItem <InventoryItem>()));
                resultCounter++;

                if (!userSortsFilters && (PXView.StartRow + PXView.MaximumRows) <= resultCounter)
                {
                    break;
                }
            }

            return(result);
        }
コード例 #22
0
        /// <summary>
        /// Fills the serviceList list with those services that already exist in the Details tab.
        /// </summary>
        /// <param name="servicesView">Service view of the detail tab of the screen that calls the selector.</param>
        public static List <int?> GetServicesInServiceTab <ServiceDetType>(PXSelectBase <ServiceDetType> servicesView, string serviceLineRefNbr)
            where ServiceDetType : class, IBqlTable, IFSSODetBase, new()
        {
            List <int?> serviceIDList = new List <int?>();

            foreach (ServiceDetType row in servicesView.Select())
            {
                if (string.IsNullOrEmpty(serviceLineRefNbr) || row.LineRef == serviceLineRefNbr)
                {
                    serviceIDList.Add(row.InventoryID);
                }
            }

            return(serviceIDList);
        }
        private void CSAnswers_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                return;
            }

            var row = (CSAnswers)e.Row;

            if (row.AttributeID == "NODROPSHIP" && row.Value as string == "0")
            {
                foreach (CSAnswers attr in _answers.Select())
                {
                    if (attr.AttributeID == "PRODUCTBUY")
                    {
                        if (!String.Equals(attr.Value, "Dropship"))
                        {
                            sender.RaiseExceptionHandling <CSAnswers.value>(row, row.Value, new PXSetPropertyException("Dropshipping is only allowed only on items with 'Dropship' Product Buy Type."));
                        }
                        break;
                    }
                }
            }
        }
コード例 #24
0
ファイル: 11FLXAttribute.cs プロジェクト: JeffJave/Flexxon
        public virtual void FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            if (e.Cancel || e.Row == null)
            {
                return;
            }
            object obj = sender.GetValue(e.Row, this._inventoryType.Name);

            if (obj == null)
            {
                return;
            }
            InventoryItem inventoryItem = InventoryItem.PK.Find(sender.Graph, new int?((int)obj));

            if (!inventoryItem.DfltSiteID.HasValue)
            {
                object branchId = sender.GetValue(e.Row, this._branchType.Name);
                if (branchId == null)
                {
                    CROpportunityProducts current = (CROpportunityProducts)sender.Current;
                    if (current != null)
                    {
                        branchId = (object)SelectFrom <CROpportunity> .Where <CROpportunity.quoteNoteID.IsEqual <P.AsGuid> > .View.SelectSingleBound(sender.Graph, null, (object)current.QuoteID).TopFirst.BranchID;
                    }
                }
                PX.Objects.CR.Location location = (PX.Objects.CR.Location)SelectFrom <PX.Objects.CR.Location> .InnerJoin <PX.Objects.GL.Branch> .On <PX.Objects.GL.Branch.bAccountID.IsEqual <PX.Objects.CR.Location.bAccountID> >
                                                  .Where <PX.Objects.GL.Branch.branchID.IsEqual <P.AsInt> > .View.ReadOnly.Select(sender.Graph, branchId);

                if (location == null)
                {
                    return;
                }
                e.NewValue = (object)location.CSiteID;
            }
            else
            {
                INSite inSite = (INSite)PXSelectBase <INSite, PXSelectReadonly <INSite, Where <INSite.siteID, Equal <Required <INSite.siteID> >, And <Match <INSite, Current <AccessInfo.userName> > > > > .Config> .Select(sender.Graph, (object)inventoryItem.DfltSiteID);

                if (inSite == null)
                {
                    return;
                }
                e.NewValue = (object)inSite.SiteID;
            }
        }
コード例 #25
0
        public static List <ErrorInfo> GetErrorInfo <TranType, TranExtensionType>(PXCache headerCache, IBqlTable headerRow, PXSelectBase <TranType> detailView)
            where TranType : class, IBqlTable, new()
            where TranExtensionType : PXCacheExtension <TranType>, IPostDocLineExtension
        {
            List <ErrorInfo> errorList = new List <ErrorInfo>();
            ErrorInfo        errorInfo = null;

            string headerErrorMessage = MessageHelper.GetRowMessage(headerCache, headerRow, true, false);

            if (string.IsNullOrEmpty(headerErrorMessage) == false)
            {
                errorInfo = new ErrorInfo()
                {
                    HeaderError   = true,
                    SOID          = null,
                    AppointmentID = null,
                    ErrorMessage  = headerErrorMessage
                };

                errorList.Add(errorInfo);
            }

            foreach (TranType row in detailView.Select())
            {
                string errorMessage = MessageHelper.GetRowMessage(detailView.Cache, row, true, false);

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    TranExtensionType rowExtension = detailView.Cache.GetExtension <TranExtensionType>(row);

                    errorInfo = new ErrorInfo()
                    {
                        HeaderError   = false,
                        SOID          = rowExtension.SOID,
                        AppointmentID = rowExtension.AppointmentID,
                        ErrorMessage  = errorMessage + ", "
                    };

                    errorList.Add(errorInfo);
                }
            }

            return(errorList);
        }
        public static CCProcTran findCCLastSuccessfulTran(PXSelectBase <CCProcTran> ccProcTran)
        {
            CCProcTran lastTran = null;
            CCProcTranOrderComparer ascComparer = new CCProcTranOrderComparer();

            foreach (CCProcTran iTran in ccProcTran.Select())
            {
                if (iTran.ProcStatus != CCProcStatus.Finalized)
                {
                    continue;
                }
                if (iTran.TranStatus == CCTranStatusCode.Approved)
                {
                    if (lastTran == null || (ascComparer.Compare(iTran, lastTran) > 0))
                    {
                        lastTran = iTran;
                    }
                }
            }
            return(lastTran);
        }
コード例 #27
0
        public virtual int CompleteMultipleLogs(DateTime?dateTimeEnd, string newApptDetStatus, bool completeRelatedItemLines, IEnumerable <ILogDetail> completeLogItems, PXSelectBase <FSAppointmentLog> logSelect, params object[] logSelectArgs)
        {
            if (dateTimeEnd == null)
            {
                dateTimeEnd = PXTimeZoneInfo.Now;
            }

            int rowsAffected = 0;
            List <FSAppointmentDet> apptDetRows = null;

            if (completeRelatedItemLines == true)
            {
                apptDetRows = AppointmentDetails.Select().RowCast <FSAppointmentDet>().ToList();
            }

            if (completeLogItems != null)
            {
                var logRows = LogRecords.Select();

                foreach (ILogDetail row in completeLogItems)
                {
                    FSAppointmentLog logRow = logRows.RowCast <FSAppointmentLog>().Where(_ => _.LineRef == row.LineRef).FirstOrDefault();

                    ProcessCompleteLog(dateTimeEnd.Value, newApptDetStatus, logRow, apptDetRows);
                    rowsAffected++;
                }
            }

            if (logSelect != null)
            {
                foreach (FSAppointmentLog logRow in logSelect.Select(logSelectArgs))
                {
                    ProcessCompleteLog(dateTimeEnd.Value, newApptDetStatus, logRow, apptDetRows);
                    rowsAffected++;
                }
            }

            return(rowsAffected);
        }
        public static void SyncNewPMI <TPaymentMethodType, TDetialsType>(PXGraph graph, PXSelectBase <TPaymentMethodType> customerPaymentMethodView, PXSelectBase <TDetialsType> detailsView)
            where TPaymentMethodType : CustomerPaymentMethod, new()
            where TDetialsType : CustomerPaymentMethodDetail, new()
        {
            bool isHF         = CCProcessingUtils.isHFPaymentMethod(graph, customerPaymentMethodView.Current.PMInstanceID);
            bool isConverting = customerPaymentMethodView.Current.Selected == true;

            isHF = isHF && !isConverting;
            TDetialsType CCPIDDet          = null;
            bool         isIDFilled        = false;
            bool         isOtherDetsFilled = false;

            foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select())
            {
                TDetialsType        cpmd = det;
                PaymentMethodDetail cmd  = det;
                if (cmd.IsCCProcessingID == true)
                {
                    isIDFilled = cpmd.Value != null;
                    CCPIDDet   = (TDetialsType)detailsView.Cache.CreateCopy(cpmd);
                }
                else
                {
                    isOtherDetsFilled = cpmd.Value != null || isOtherDetsFilled;
                }
            }
            if (CCPIDDet == null)
            {
                //something's very wrong
                throw new PXException(Messages.NOCCPID, customerPaymentMethodView.Current.Descr);
            }
            if (isIDFilled && isOtherDetsFilled)
            {
                return;
            }

            if ((isIDFilled || isOtherDetsFilled) && !isHF || isIDFilled && !isOtherDetsFilled)
            {
                CCCustomerInformationManager cim = new CCCustomerInformationManager(customerPaymentMethodView.Current.CCProcessingCenterID, CCProcessingFeature.Tokenization,
                                                                                    new ProcessingContext()
                {
                    aCustomerID   = customerPaymentMethodView.Current.BAccountID,
                    aPMInstanceID = customerPaymentMethodView.Current.PMInstanceID,
                    callerGraph   = graph
                });
                if (customerPaymentMethodView.Current.CustomerCCPID == null)
                {
                    string             id  = cim.CreateCustomer();
                    TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(customerPaymentMethodView.Current);
                    cpm.CustomerCCPID = id;
                    customerPaymentMethodView.Update(cpm);
                }
                if (isOtherDetsFilled)
                {
                    string newPMId = cim.CreatePaymentMethod();
                    CCPIDDet.Value = newPMId;
                    CCPIDDet       = detailsView.Update(CCPIDDet);
                }
                SyncPMResponse syncResponse = cim.GetPaymentMethod();
                if (syncResponse.PMList.ContainsKey(CCPIDDet.Value))
                {
                    foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select())
                    {
                        TDetialsType cpmd = det;
                        if (cpmd.DetailID == CCPIDDet.DetailID)
                        {
                            continue;
                        }
                        string detailValue;
                        if (!syncResponse.PMList[CCPIDDet.Value].TryGetValue(cpmd.DetailID, out detailValue))
                        {
                            detailValue = null;
                        }
                        TDetialsType newcpmd = (TDetialsType)detailsView.Cache.CreateCopy(cpmd);
                        newcpmd.Value = detailValue;
                        detailsView.Update(newcpmd);
                    }
                }
                else
                {
                    throw new PXException(Messages.CouldntGetPMIDetails, customerPaymentMethodView.Current.Descr);
                }
            }
        }
コード例 #29
0
        public static IEnumerable StaffRecordsDelegate(
            object staffView,
            PXSelectBase <SkillGridFilter> skillView,
            PXSelectBase <LicenseTypeGridFilter> licenseTypeView,
            PXFilter <StaffSelectionFilter> filter)
        {
            if (filter.Current == null)
            {
                yield break;
            }

            PXGraph graphFilter = filter.Cache.Graph;
            IEnumerable <BAccountStaffMember> staffSet = GetStaffAvailableForSelect(filter, staffView);

            List <int?> skillsSelection = skillView.Select()
                                          .Where(y => ((SkillGridFilter)y).Mem_Selected == true)
                                          .Select(y => ((SkillGridFilter)y).SkillID)
                                          .ToList();

            List <int?> licenseTypesSelection = licenseTypeView.Select()
                                                .Where(y => ((LicenseTypeGridFilter)y).Mem_Selected == true)
                                                .Select(y => ((LicenseTypeGridFilter)y).LicenseTypeID)
                                                .ToList();

            if (skillsSelection.Count == 0 && licenseTypesSelection.Count == 0)
            {
                foreach (BAccountStaffMember staffRow in staffSet)
                {
                    yield return(staffRow);
                }
            }
            else
            {
                List <int?> employeeIDList = staffSet.Select(y => y.BAccountID).ToList();

                //Loading Skill list for each employee in employeeIDList
                List <SharedClasses.ItemList> allStaffSkillList = SharedFunctions.GetItemWithList <FSEmployeeSkill,
                                                                                                   FSEmployeeSkill.employeeID,
                                                                                                   FSEmployeeSkill.skillID>(graphFilter, employeeIDList);

                //NOTE: TIME info must be removed in order to catch licenses that expire the same day as ScheduledDateTimeBegin
                filter.Current.ScheduledDateTimeBegin = SharedFunctions.RemoveTimeInfo(filter.Current.ScheduledDateTimeBegin);

                //Loading LicenseType list for each employee in employeeIDList
                List <SharedClasses.ItemList> allStaffLicenseTypeList = SharedFunctions.GetItemWithList <FSLicense,
                                                                                                         FSLicense.employeeID,
                                                                                                         FSLicense.licenseTypeID,
                                                                                                         Where2 <
                                                                                                             Where <Current <StaffSelectionFilter.scheduledDateTimeBegin>, IsNull>,
                                                                                                             Or <Where <FSLicense.expirationDate, GreaterEqual <Current <StaffSelectionFilter.scheduledDateTimeBegin> >,
                                                                                                                        And <FSLicense.issueDate, LessEqual <Current <StaffSelectionFilter.scheduledDateTimeBegin> > > > > > >
                                                                            (graphFilter, employeeIDList);

                foreach (BAccountStaffMember staffRow in staffSet)
                {
                    SharedClasses.ItemList employeeSkillList = allStaffSkillList.FirstOrDefault(y => y.itemID == staffRow.BAccountID);
                    if (HasEmployeeItemsSelected(employeeSkillList, skillsSelection) == false && staffRow.Selected == false)
                    {
                        continue;
                    }

                    SharedClasses.ItemList employeeLicenseTypeList = allStaffLicenseTypeList.FirstOrDefault(y => y.itemID == staffRow.BAccountID);
                    if (HasEmployeeItemsSelected(employeeLicenseTypeList, licenseTypesSelection) == false && staffRow.Selected == false)
                    {
                        continue;
                    }

                    yield return(staffRow);
                }
            }
        }
        public static void SyncExistingPMI(PXGraph graph, PXSelectBase <CustomerPaymentMethod> customerPaymentMethodView, PXSelectBase <CustomerPaymentMethodDetail> detailsView)
        {
            string CCPID = null;

            foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> det in detailsView.Select())
            {
                CustomerPaymentMethodDetail cpmd = (CustomerPaymentMethodDetail)det;
                PaymentMethodDetail         pmd  = (PaymentMethodDetail)det;
                if (pmd.IsCCProcessingID == true)
                {
                    CCPID = cpmd.Value;
                    break;
                }
            }
            if (String.IsNullOrEmpty(CCPID))
            {
                throw new PXException(Messages.CreditCardTokenIDNotFound);
            }
            CCCustomerInformationManager cim = new CCCustomerInformationManager(customerPaymentMethodView.Current.CCProcessingCenterID, CCProcessingFeature.Tokenization,
                                                                                new ProcessingContext()
            {
                aCustomerID   = customerPaymentMethodView.Current.BAccountID,
                aPMInstanceID = customerPaymentMethodView.Current.PMInstanceID,
                callerGraph   = graph
            });
            SyncPMResponse response = cim.GetPaymentMethod();

            if (response.PMList.Count == 0)
            {
                throw new PXException(Messages.CreditCardNotFoundInProcCenter, CCPID, customerPaymentMethodView.Current.CCProcessingCenterID);
            }
            foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> det in detailsView.Select())
            {
                CustomerPaymentMethodDetail cpmd = (CustomerPaymentMethodDetail)det;
                PaymentMethodDetail         pmd  = (PaymentMethodDetail)det;
                if (pmd.IsCCProcessingID != true && response.PMList.First().Value.ContainsKey(cpmd.DetailID))
                {
                    cpmd.Value = response.PMList.First().Value[cpmd.DetailID];
                    detailsView.Update(cpmd);
                }
            }
        }