Ejemplo n.º 1
0
        public virtual void Batch_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            var batch = e.Row as Batch;

            bool batchNotReleased    = (batch.Released != true);
            bool batchPosted         = (batch.Posted == true);
            bool batchVoided         = (batch.Voided == true);
            bool batchModuleGL       = (batch.Module == GL.BatchModule.GL);
            bool batchStatusInserted = (cache.GetStatus(batch) == PXEntryStatus.Inserted);

            bool isReclass      = batch.BatchType == BatchTypeCode.Reclassification;
            bool isTrialBalance = batch.BatchType == BatchTypeCode.TrialBalance;
            bool isAllocation   = batch.BatchType == BatchTypeCode.Allocation;

            bool allowCreateTaxTrans = PXAccess.FeatureInstalled <FeaturesSet.taxEntryFromGL>();

            allowCreateTaxTrans = allowCreateTaxTrans && batch != null && batch.Module == GL.BatchModule.GL;
            bool isViewSourceSupported = true;

            if (batch.Module == GL.BatchModule.GL ||
                batch.Module == GL.BatchModule.CM ||
                batch.Module == GL.BatchModule.FA)
            {
                isViewSourceSupported = false;
            }


            JournalEntry.viewDocument.SetEnabled(isViewSourceSupported);

            PXUIFieldAttribute.SetVisible <Batch.curyID>(cache, batch, PXAccess.FeatureInstalled <FeaturesSet.multicurrency>());
            PXUIFieldAttribute.SetVisible <Batch.createTaxTrans>(cache, batch, allowCreateTaxTrans);
            PXUIFieldAttribute.SetEnabled <Batch.createTaxTrans>(cache, batch, false);
            PXUIFieldAttribute.SetEnabled <Batch.autoReverseCopy>(cache, batch, false);

            if (!JournalEntry.IsImport || HttpContext.Current != null)
            {
                PXUIFieldAttribute.SetVisible <GLTran.tranDate>(GLTranCache, null, batch.Module != BatchModule.GL);

                PXUIFieldAttribute.SetVisible <GLTran.taxID>(GLTranCache, null, ShouldCreateTaxTrans(batch));
                PXUIFieldAttribute.SetVisible <GLTran.taxCategoryID>(GLTranCache, null, ShouldCreateTaxTrans(batch));
            }

            JournalEntry.release.SetEnabled(batchModuleGL && batchNotReleased && batch.Scheduled != true && batch.Status != BatchStatus.Hold && !batchVoided);
            JournalEntry.createSchedule.SetEnabled(batchModuleGL && !batchVoided && !batchStatusInserted && (batchNotReleased || batch.Scheduled == true) &&
                                                   !isReclass && !isTrialBalance && !isAllocation);

            PXUIFieldAttribute.SetEnabled <Batch.module>(cache, batch);
            PXUIFieldAttribute.SetEnabled <Batch.batchNbr>(cache, batch);
            PXUIFieldAttribute.SetVisible <Batch.scheduleID>(cache, batch, false);
            PXUIFieldAttribute.SetVisible <Batch.curyControlTotal>(cache, batch, (bool)JournalEntry.glsetup.Current.RequireControlTotal);
            PXUIFieldAttribute.SetVisible <Batch.skipTaxValidation>(cache, batch, batch.CreateTaxTrans == true);

            JournalEntry.batchRegisterDetails.SetEnabled(!batchNotReleased);
            JournalEntry.glEditDetails.SetEnabled(batchNotReleased && !batchPosted && !batchStatusInserted);

            bool canReverse = CanReverseBatch(batch);

            JournalEntry.reverseBatch.SetEnabled(canReverse);
            JournalEntry.glReversingBatches.SetEnabled(canReverse);
            PXUIFieldAttribute.SetVisible <Batch.reverseCount>(cache, batch, batch.ReverseCount.GetValueOrDefault(0) > 0);

            SetReclassifyButtonState(batch);

            PXUIFieldAttribute.SetVisible <GLTran.origBatchNbr>(GLTranCache, null, isReclass);
            JournalEntry.editReclassBatch.SetVisible(isReclass);
        }
Ejemplo n.º 2
0
        public void Revalue(RevalueFilter filter, List <RevaluedAPHistory> list)
        {
            JournalEntry je        = PXGraph.CreateInstance <JournalEntry>();
            PostGraph    pg        = PXGraph.CreateInstance <PostGraph>();
            PXCache      cache     = je.Caches[typeof(CuryAPHist)];
            PXCache      basecache = je.Caches[typeof(APHist)];

            je.Views.Caches.Add(typeof(CuryAPHist));
            je.Views.Caches.Add(typeof(APHist));

            string extRefNbrNumbering = je.CMSetup.Current.ExtRefNbrNumberingID;

            if (string.IsNullOrEmpty(extRefNbrNumbering) == false)
            {
                RevaluationRefNbrHelper helper = new RevaluationRefNbrHelper(extRefNbrNumbering);
                helper.Subscribe(je);
            }

            DocumentList <Batch> created = new DocumentList <Batch>(je);

            Currency currency = PXSelect <Currency, Where <Currency.curyID, Equal <Required <Currency.curyID> > > > .Select(je, filter.CuryID);

            bool hasErrors = false;

            using (PXTransactionScope ts = new PXTransactionScope())
            {
                foreach (RevaluedAPHistory hist in list)
                {
                    PXProcessing <RevaluedAPHistory> .SetCurrentItem(hist);

                    if (hist.FinPtdRevalued == 0m)
                    {
                        PXProcessing <RevaluedAPHistory> .SetProcessed();

                        continue;
                    }

                    string FinPeriod =
                        FinPeriodRepository.GetFinPeriodByMasterPeriodID(PXAccess.GetParentOrganizationID(hist.BranchID), filter.FinPeriodID)
                        .Result
                        .FinPeriodID;

                    ProcessingResult result = CheckFinPeriod(FinPeriod, hist.BranchID);
                    if (!result.IsSuccess)
                    {
                        hasErrors = true;
                        continue;
                    }

                    if (je.GLTranModuleBatNbr.Cache.IsInsertedUpdatedDeleted)
                    {
                        je.Save.Press();

                        if (created.Find(je.BatchModule.Current) == null)
                        {
                            created.Add(je.BatchModule.Current);
                        }
                    }

                    Batch cmbatch = created.Find <Batch.branchID>(hist.BranchID) ?? new Batch();
                    if (cmbatch.BatchNbr == null)
                    {
                        je.Clear();

                        CurrencyInfo info = new CurrencyInfo();
                        info.CuryID      = hist.CuryID;
                        info.CuryEffDate = hist.CuryEffDate;
                        info.BaseCalc    = false;
                        info             = je.currencyinfo.Insert(info) ?? info;

                        cmbatch             = new Batch();
                        cmbatch.BranchID    = hist.BranchID;
                        cmbatch.Module      = "CM";
                        cmbatch.Status      = "U";
                        cmbatch.AutoReverse = true;
                        cmbatch.Released    = true;
                        cmbatch.Hold        = false;
                        cmbatch.DateEntered = filter.CuryEffDate;
                        FinPeriodIDAttribute.SetPeriodsByMaster <Batch.finPeriodID>(je.BatchModule.Cache, cmbatch, filter.FinPeriodID);

                        cmbatch.CuryID      = hist.CuryID;
                        cmbatch.CuryInfoID  = info.CuryInfoID;
                        cmbatch.DebitTotal  = 0m;
                        cmbatch.CreditTotal = 0m;
                        cmbatch.Description = filter.Description;
                        je.BatchModule.Insert(cmbatch);

                        CurrencyInfo b_info = je.currencyinfo.Select();
                        if (b_info != null)
                        {
                            b_info.CuryID         = hist.CuryID;
                            b_info.CuryEffDate    = hist.CuryEffDate;
                            b_info.CuryRateTypeID = hist.CuryRateTypeID;
                            b_info.CuryRate       = hist.CuryRate;
                            b_info.RecipRate      = hist.RateReciprocal;
                            b_info.CuryMultDiv    = hist.CuryMultDiv;
                            je.currencyinfo.Update(b_info);
                        }
                    }
                    else
                    {
                        if (!je.BatchModule.Cache.ObjectsEqual(je.BatchModule.Current, cmbatch))
                        {
                            je.Clear();
                        }

                        je.BatchModule.Current = je.BatchModule.Search <Batch.batchNbr>(cmbatch.BatchNbr, cmbatch.Module);
                    }

                    {
                        GLTran tran = new GLTran();
                        tran.SummPost      = false;
                        tran.AccountID     = currency.APProvAcctID ?? hist.AccountID;
                        tran.SubID         = currency.APProvSubID ?? hist.SubID;
                        tran.CuryDebitAmt  = 0m;
                        tran.CuryCreditAmt = 0m;

                        tran.DebitAmt  = (hist.FinPtdRevalued < 0m) ? -1m * hist.FinPtdRevalued : 0m;
                        tran.CreditAmt = (hist.FinPtdRevalued < 0m) ? 0m : hist.FinPtdRevalued;

                        tran.TranType  = "REV";
                        tran.TranClass = AccountType.Liability;
                        tran.RefNbr    = string.Empty;
                        tran.TranDesc  = filter.Description;
                        FinPeriodIDAttribute.SetPeriodsByMaster <GLTran.finPeriodID>(je.GLTranModuleBatNbr.Cache, tran, filter.FinPeriodID);
                        tran.TranDate    = filter.CuryEffDate;
                        tran.CuryInfoID  = null;
                        tran.Released    = true;
                        tran.ReferenceID = hist.VendorID;

                        je.GLTranModuleBatNbr.Insert(tran);
                    }

                    VendorClass vendclass = PXSelectReadonly <VendorClass, Where <VendorClass.vendorClassID, Equal <Required <VendorClass.vendorClassID> > > > .Select(je, hist.VendorClassID);

                    if (vendclass == null)
                    {
                        vendclass = new VendorClass();
                    }

                    if (vendclass.UnrealizedGainAcctID == null)
                    {
                        vendclass.UnrealizedGainSubID = null;
                    }

                    if (vendclass.UnrealizedLossAcctID == null)
                    {
                        vendclass.UnrealizedLossSubID = null;
                    }

                    {
                        GLTran tran = new GLTran();
                        tran.SummPost      = true;
                        tran.ZeroPost      = false;
                        tran.CuryDebitAmt  = 0m;
                        tran.CuryCreditAmt = 0m;

                        if (je.BatchModule.Current.DebitTotal > je.BatchModule.Current.CreditTotal)
                        {
                            tran.AccountID = vendclass.UnrealizedGainAcctID ?? currency.UnrealizedGainAcctID;
                            tran.SubID     = vendclass.UnrealizedGainSubID ?? GainLossSubAccountMaskAttribute.GetSubID <Currency.unrealizedGainSubID>(je, hist.BranchID, currency);
                            tran.DebitAmt  = 0m;
                            tran.CreditAmt = (je.BatchModule.Current.DebitTotal - je.BatchModule.Current.CreditTotal);
                        }
                        else
                        {
                            tran.AccountID = vendclass.UnrealizedLossAcctID ?? currency.UnrealizedLossAcctID;
                            tran.SubID     = vendclass.UnrealizedLossSubID ?? GainLossSubAccountMaskAttribute.GetSubID <Currency.unrealizedLossSubID>(je, hist.BranchID, currency);
                            tran.DebitAmt  = (je.BatchModule.Current.CreditTotal - je.BatchModule.Current.DebitTotal);
                            tran.CreditAmt = 0m;
                        }

                        tran.TranType    = "REV";
                        tran.TranClass   = GLTran.tranClass.UnrealizedAndRevaluationGOL;
                        tran.RefNbr      = string.Empty;
                        tran.TranDesc    = filter.Description;
                        tran.Released    = true;
                        tran.ReferenceID = null;

                        je.GLTranModuleBatNbr.Insert(tran);
                    }

                    {
                        CuryAPHist aphist = new CuryAPHist();
                        aphist.BranchID    = hist.BranchID;
                        aphist.AccountID   = hist.AccountID;
                        aphist.SubID       = hist.SubID;
                        aphist.FinPeriodID = filter.FinPeriodID;
                        aphist.VendorID    = hist.VendorID;
                        aphist.CuryID      = hist.CuryID;

                        aphist = (CuryAPHist)cache.Insert(aphist);
                        aphist.FinPtdRevalued += hist.FinPtdRevalued;
                    }

                    {
                        APHist aphist = new APHist();
                        aphist.BranchID    = hist.BranchID;
                        aphist.AccountID   = hist.AccountID;
                        aphist.SubID       = hist.SubID;
                        aphist.FinPeriodID = filter.FinPeriodID;
                        aphist.VendorID    = hist.VendorID;

                        aphist = (APHist)basecache.Insert(aphist);
                        aphist.FinPtdRevalued += hist.FinPtdRevalued;
                    }

                    PXProcessing <RevaluedAPHistory> .SetProcessed();
                }

                if (je.GLTranModuleBatNbr.Cache.IsInsertedUpdatedDeleted)
                {
                    je.Save.Press();

                    if (created.Find(je.BatchModule.Current) == null)
                    {
                        created.Add(je.BatchModule.Current);
                    }
                }

                ts.Complete();
            }

            //Clean current to prevent set exception to the last item
            PXProcessing <RevaluedAPHistory> .SetCurrentItem(null);

            CMSetup cmsetup = PXSelect <CMSetup> .Select(je);

            for (int i = 0; i < created.Count; i++)
            {
                if (cmsetup.AutoPostOption == true)
                {
                    pg.Clear();
                    pg.PostBatchProc(created[i]);
                }
            }

            if (hasErrors)
            {
                throw new PXException(ErrorMessages.SeveralItemsFailed);
            }

            if (created.Count > 0)
            {
                je.BatchModule.Current = created[created.Count - 1];
                throw new PXRedirectRequiredException(je, "Preview");
            }

            decimal val = 0m;

            foreach (RevaluedAPHistory res in APAccountList.Cache.Updated)
            {
                if ((bool)res.Selected)
                {
                    val += (decimal)res.FinPtdRevalued;
                }
            }

            if (val == 0)
            {
                throw new PXOperationCompletedWithWarningException(Messages.NoRevaluationEntryWasMade);
            }
        }
Ejemplo n.º 3
0
        public virtual Result Calculate(PMProject project, PMTran pmt, PMAccountGroup ag, string accountType, int amountSign, int qtySign)
        {
            PMBudgetLite target = null;
            bool         isExisting;

            target = service.SelectProjectBalance(pmt, ag, project, out isExisting);

            var rollupQty = CalculateRollupQty(pmt, target);

            List <PMHistory>  list     = new List <PMHistory>();
            PMTaskTotal       ta       = null;
            PMBudget          ps       = null;
            PMForecastHistory forecast = null;

            if (pmt.TaskID != null && (rollupQty != 0 || pmt.Amount != 0))             //TaskID will be null for Contract
            {
                ps                = new PMBudget();
                ps.ProjectID      = target.ProjectID;
                ps.ProjectTaskID  = target.TaskID;
                ps.AccountGroupID = target.AccountGroupID;
                ps.Type           = target.Type;
                ps.InventoryID    = target.InventoryID;
                ps.CostCodeID     = target.CostCodeID;
                ps.UOM            = target.UOM;
                ps.IsProduction   = target.IsProduction;
                ps.Description    = target.Description;
                if (ps.CuryInfoID == null)
                {
                    ps.CuryInfoID = project.CuryInfoID;
                }
                decimal amt     = amountSign * pmt.Amount.GetValueOrDefault();
                decimal curyAmt = amountSign * pmt.ProjectCuryAmount.GetValueOrDefault();

                ps.ActualQty        = rollupQty * qtySign;
                ps.ActualAmount     = amt;
                ps.CuryActualAmount = curyAmt;

                #region PMTask Totals Update

                ta           = new PMTaskTotal();
                ta.ProjectID = ps.ProjectID;
                ta.TaskID    = ps.TaskID;

                string accType = ag.IsExpense == true ? AccountType.Expense : ag.Type;
                switch (accType)
                {
                case AccountType.Asset:
                    ta.CuryAsset = curyAmt;
                    ta.Asset     = amt;
                    break;

                case AccountType.Liability:
                    ta.CuryLiability = curyAmt;
                    ta.Liability     = amt;
                    break;

                case AccountType.Income:
                    ta.CuryIncome = curyAmt;
                    ta.Income     = amt;
                    break;

                case AccountType.Expense:
                    ta.CuryExpense = curyAmt;
                    ta.Expense     = amt;
                    break;
                }

                #endregion

                #region History
                PMHistory hist = new PMHistory();
                hist.ProjectID      = ps.ProjectID;
                hist.ProjectTaskID  = ps.TaskID;
                hist.AccountGroupID = ps.AccountGroupID;
                hist.InventoryID    = pmt.InventoryID ?? ps.InventoryID;
                hist.CostCodeID     = pmt.CostCodeID ?? ps.CostCodeID;
                hist.PeriodID       = pmt.FinPeriodID;
                hist.BranchID       = pmt.BranchID;
                decimal baseQty = 0;
                list.Add(hist);
                if (pmt.InventoryID != null && pmt.InventoryID != PMInventorySelectorAttribute.EmptyInventoryID && pmt.Qty != 0)
                {
                    if (PXAccess.FeatureInstalled <FeaturesSet.multipleUnitMeasure>())
                    {
                        baseQty = qtySign * IN.INUnitAttribute.ConvertToBase(graph.Caches[typeof(PMHistory)], pmt.InventoryID, pmt.UOM, pmt.Qty.Value, PX.Objects.IN.INPrecision.QUANTITY);
                    }
                    else
                    {
                        IN.InventoryItem initem = PXSelectorAttribute.Select <PMTran.inventoryID>(graph.Caches[typeof(PMTran)], pmt) as IN.InventoryItem;
                        if (initem != null && !string.IsNullOrEmpty(pmt.UOM))
                        {
                            baseQty = qtySign * IN.INUnitAttribute.ConvertGlobalUnits(graph, pmt.UOM, initem.BaseUnit, pmt.Qty ?? 0, IN.INPrecision.QUANTITY);
                        }
                    }
                }
                hist.FinPTDCuryAmount = curyAmt;
                hist.FinPTDAmount     = amt;
                hist.FinYTDCuryAmount = curyAmt;
                hist.FinYTDAmount     = amt;
                hist.FinPTDQty        = baseQty;
                hist.FinYTDQty        = baseQty;
                if (pmt.FinPeriodID == pmt.TranPeriodID)
                {
                    hist.TranPTDCuryAmount = curyAmt;
                    hist.TranPTDAmount     = amt;
                    hist.TranYTDCuryAmount = curyAmt;
                    hist.TranYTDAmount     = amt;
                    hist.TranPTDQty        = baseQty;
                    hist.TranYTDQty        = baseQty;
                }
                else
                {
                    PMHistory tranHist = new PMHistory();
                    tranHist.ProjectID      = ps.ProjectID;
                    tranHist.ProjectTaskID  = ps.TaskID;
                    tranHist.AccountGroupID = ps.AccountGroupID;
                    tranHist.InventoryID    = pmt.InventoryID ?? PM.PMInventorySelectorAttribute.EmptyInventoryID;
                    tranHist.CostCodeID     = pmt.CostCodeID ?? CostCodeAttribute.GetDefaultCostCode();
                    tranHist.PeriodID       = pmt.TranPeriodID;
                    tranHist.BranchID       = pmt.BranchID;
                    list.Add(tranHist);
                    tranHist.TranPTDCuryAmount = curyAmt;
                    tranHist.TranPTDAmount     = amt;
                    tranHist.TranYTDCuryAmount = curyAmt;
                    tranHist.TranYTDAmount     = amt;
                    tranHist.TranPTDQty        = baseQty;
                    tranHist.TranYTDQty        = baseQty;
                }
                #endregion

                forecast                  = new PMForecastHistory();
                forecast.ProjectID        = ps.ProjectID;
                forecast.ProjectTaskID    = ps.ProjectTaskID;
                forecast.AccountGroupID   = ps.AccountGroupID;
                forecast.InventoryID      = ps.InventoryID;
                forecast.CostCodeID       = ps.CostCodeID;
                forecast.PeriodID         = pmt.TranPeriodID;
                forecast.ActualQty        = ps.ActualQty;
                forecast.CuryActualAmount = ps.CuryActualAmount;
                forecast.ActualAmount     = ps.ActualAmount;
            }
            return(new Result(list, ps, ta, forecast));
        }
 public static bool IsActive()
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.rutRotDeduction>());
 }
Ejemplo n.º 5
0
 public virtual bool IsPrintingAllowed(SOInvoiceFilter filter)
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.deviceHub>() &&
            (filter != null && !String.IsNullOrEmpty(filter.Action) && SOReports.GetReportIDByName(SOInvoiceList, filter.Action) == SOReports.PrintInvoiceReport));
 }
Ejemplo n.º 6
0
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            GLSetup gLSetup = PXSelect <GLSetup> .Select(sender.Graph);

            decimal?result        = 0m;
            object  cashAccountID = sender.GetValue(e.Row, _CashAccount);

            object finPeriodID = null;

            if (string.IsNullOrEmpty(_FinPeriodID))
            {
                object finDate   = sender.GetValue(e.Row, _FinDate);
                var    finPeriod = "";

                if (finPeriod != null)
                {
                    CashAccount cashaccount = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(sender.Graph, cashAccountID);

                    if (cashaccount != null)
                    {
                        finPeriodID = sender.Graph.GetService <IFinPeriodRepository>().FindFinPeriodByDate((DateTime?)sender.GetValue(e.Row, _FinDate), PXAccess.GetParentOrganizationID(cashaccount.BranchID))?.FinPeriodID;
                    }
                }
            }
            else
            {
                finPeriodID = sender.GetValue(e.Row, _FinPeriodID);
            }

            if (cashAccountID != null && finPeriodID != null)
            {
                // clear glhistory cache for ReleasePayments longrun
                sender.Graph.Caches <GLHistory>().ClearQueryCache();
                sender.Graph.Caches <GLHistory>().Clear();

                GLHistory gLHistory = PXSelectJoin <GLHistory,
                                                    InnerJoin <GLHistoryByPeriod,
                                                               On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                   And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                        And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                             And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                  And <GLHistoryByPeriod.lastActivityPeriod, Equal <GLHistory.finPeriodID> > > > > >,
                                                               InnerJoin <Branch,
                                                                          On <Branch.branchID, Equal <GLHistory.branchID>,
                                                                              And <Branch.ledgerID, Equal <GLHistory.ledgerID> > >,
                                                                          InnerJoin <CashAccount,
                                                                                     On <GLHistoryByPeriod.branchID, Equal <CashAccount.branchID>,
                                                                                         And <GLHistoryByPeriod.accountID, Equal <CashAccount.accountID>,
                                                                                              And <GLHistoryByPeriod.subID, Equal <CashAccount.subID> > > >,
                                                                                     InnerJoin <Account,
                                                                                                On <GLHistoryByPeriod.accountID, Equal <Account.accountID>,
                                                                                                    And <Match <Account, Current <AccessInfo.userName> > > >,
                                                                                                InnerJoin <Sub,
                                                                                                           On <GLHistoryByPeriod.subID, Equal <Sub.subID>, And <Match <Sub, Current <AccessInfo.userName> > > > > > > > >,
                                                    Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> >,
                                                           And <GLHistoryByPeriod.finPeriodID, Equal <Required <GLHistoryByPeriod.finPeriodID> > >
                                                           > > .Select(sender.Graph, cashAccountID, finPeriodID);

                if (gLHistory != null)
                {
                    result = gLHistory.CuryFinYtdBalance;
                }
            }
            e.ReturnValue = result;
            e.Cancel      = true;
        }
        public EmployeeActivitiesApprove()
        {
            //NO CRM Mode
            PXUIFieldAttribute.SetVisible <EPActivityApprove.contractID>(Activity.Cache, null, !PXAccess.FeatureInstalled <FeaturesSet.customerModule>());
            PXUIFieldAttribute.SetVisible <ContractEx.contractCD>(dummyContract.Cache, null, PXAccess.FeatureInstalled <FeaturesSet.customerModule>());
            PXUIFieldAttribute.SetVisible <CRCase.caseCD>(dummyCase.Cache, null, PXAccess.FeatureInstalled <FeaturesSet.customerModule>());

            if (!PXAccess.FeatureInstalled <FeaturesSet.timeReportingModule>())
            {
                PXUIFieldAttribute.SetVisible(Activity.Cache, typeof(EPActivityApprove.timeSpent).Name, false);
                PXUIFieldAttribute.SetVisible(Activity.Cache, typeof(EPActivityApprove.timeBillable).Name, false);
                PXUIFieldAttribute.SetVisible(Activity.Cache, typeof(EPActivityApprove.isBillable).Name, false);

                PXUIFieldAttribute.SetVisible <EPActivityFilter.regularOvertime>(Filter.Cache, null, false);
                PXUIFieldAttribute.SetVisible <EPActivityFilter.regularTime>(Filter.Cache, null, false);
                PXUIFieldAttribute.SetVisible <EPActivityFilter.regularTotal>(Filter.Cache, null, false);
                PXUIFieldAttribute.SetVisible <EPActivityFilter.billableOvertime>(Filter.Cache, null, false);
                PXUIFieldAttribute.SetVisible <EPActivityFilter.billableTime>(Filter.Cache, null, false);
                PXUIFieldAttribute.SetVisible <EPActivityFilter.billableTotal>(Filter.Cache, null, false);
            }

            if (!PXAccess.FeatureInstalled <FeaturesSet.projectModule>())
            {
                PXUIFieldAttribute.SetVisible(Activity.Cache, typeof(EPActivityApprove.projectTaskID).Name, false);
                PXUIFieldAttribute.SetVisible <EPActivityFilter.projectTaskID>(Filter.Cache, null, false);
            }
        }
        public virtual IList <DRScheduleTran> GenerateTransactions(
            DRSchedule deferralSchedule,
            DRScheduleDetail scheduleDetail)
        {
            if (deferralSchedule == null)
            {
                throw new ArgumentNullException(nameof(deferralSchedule));
            }
            if (scheduleDetail == null)
            {
                throw new ArgumentNullException(nameof(scheduleDetail));
            }

            if (PXAccess.FeatureInstalled <CS.FeaturesSet.aSC606>())
            {
                ValidateTerms(scheduleDetail);
            }
            else
            {
                ValidateTerms(deferralSchedule);
            }


            int?    organizationID = PXAccess.GetParentOrganizationID(scheduleDetail.BranchID);
            decimal defAmount      = scheduleDetail.TotalAmt.Value;

            List <DRScheduleTran> list = new List <DRScheduleTran>();

            short lineCounter = 0;

            if (_code.ReconNowPct.Value > 0)
            {
                decimal recNowRaw = defAmount * _code.ReconNowPct.Value * 0.01m;
                decimal recNow    = _roundingFunction(recNowRaw);
                defAmount -= recNow;

                lineCounter++;

                DRScheduleTran nowTran = new DRScheduleTran
                {
                    BranchID     = scheduleDetail.BranchID,
                    AccountID    = scheduleDetail.AccountID,
                    SubID        = scheduleDetail.SubID,
                    Amount       = recNow,
                    RecDate      = deferralSchedule.DocDate,
                    FinPeriodID  = scheduleDetail.FinPeriodID,
                    TranPeriodID = scheduleDetail.TranPeriodID,

                    LineNbr       = lineCounter,
                    DetailLineNbr = scheduleDetail.DetailLineNbr,
                    ScheduleID    = scheduleDetail.ScheduleID,
                    ComponentID   = scheduleDetail.ComponentID,
                    Status        = GetStatus(),
                };

                list.Add(nowTran);
            }

            bool isFlexibleDeferralCode = DeferredMethodType.RequiresTerms(_code.Method);

            DateTime?termStartDate = null;
            DateTime?termEndDate   = null;

            if (isFlexibleDeferralCode)
            {
                bool isASC606 = PXAccess.FeatureInstalled <CS.FeaturesSet.aSC606>();
                termStartDate = isASC606 ? scheduleDetail.TermStartDate.Value : deferralSchedule.TermStartDate.Value;
                termEndDate   = isASC606 ? scheduleDetail.TermEndDate.Value : deferralSchedule.TermEndDate.Value;
            }

            DateTime  documentDate      = deferralSchedule.DocDate.Value;
            FinPeriod documentFinPeriod = _finPeriodRepository.FindFinPeriodByDate(documentDate, organizationID);
            int       occurrences       = isFlexibleDeferralCode ? CalcOccurrences(termStartDate.Value, termEndDate.Value, organizationID) : _code.Occurrences.Value;

            List <DRScheduleTran> deferredList   = new List <DRScheduleTran>(_code.Occurrences.Value);
            FinPeriod             deferredPeriod = null;

            for (int i = 0; i < occurrences; i++)
            {
                try
                {
                    if (deferredPeriod == null)
                    {
                        deferredPeriod = isFlexibleDeferralCode ?
                                         _finPeriodRepository.FindFinPeriodByDate(termStartDate, organizationID):
                                         _finPeriodRepository.GetOffsetPeriod(scheduleDetail.FinPeriodID, _code.StartOffset.Value, organizationID);
                    }
                    else
                    {
                        deferredPeriod = _finPeriodRepository.GetOffsetPeriod(deferredPeriod.FinPeriodID, _code.Frequency.Value, organizationID);
                    }
                }
                catch (PXFinPeriodException ex)
                {
                    throw new PXException(ex, Messages.NoFinPeriod, _code.DeferredCodeID);
                }

                lineCounter++;

                DateTime recognitionDate = GetRecognitionDate(
                    deferredPeriod.FinPeriodID,
                    minimumDate: isFlexibleDeferralCode ? termStartDate.Value : documentDate,
                    maximumDate: isFlexibleDeferralCode ? termEndDate : null,
                    organizationID: organizationID);

                FinPeriod finPeriod = _finPeriodRepository.FindFinPeriodByDate(recognitionDate, organizationID);

                DRScheduleTran deferralTransaction = new DRScheduleTran
                {
                    BranchID      = scheduleDetail.BranchID,
                    AccountID     = scheduleDetail.AccountID,
                    SubID         = scheduleDetail.SubID,
                    RecDate       = recognitionDate,
                    FinPeriodID   = finPeriod?.FinPeriodID,
                    TranPeriodID  = finPeriod?.MasterFinPeriodID,
                    LineNbr       = lineCounter,
                    DetailLineNbr = scheduleDetail.DetailLineNbr,
                    ScheduleID    = scheduleDetail.ScheduleID,
                    ComponentID   = scheduleDetail.ComponentID,
                    Status        = GetStatus(),
                };

                deferredList.Add(deferralTransaction);
            }

            SetAmounts(deferredList, defAmount, deferralSchedule.DocDate, termStartDate, termEndDate, organizationID);

            if (DeferredMethodType.RequiresTerms(_code) &&
                _code.RecognizeInPastPeriods != true)
            {
                // Adjust recognition dates and financial periods
                // that are in the past relative to the document date.
                // -
                foreach (DRScheduleTran transaction in deferredList
                         .Where(transaction => transaction.RecDate < documentDate))
                {
                    transaction.RecDate      = documentDate;
                    transaction.FinPeriodID  = documentFinPeriod?.FinPeriodID;
                    transaction.TranPeriodID = documentFinPeriod?.MasterFinPeriodID;
                }
            }

            list.AddRange(deferredList);

            return(list);
        }
Ejemplo n.º 9
0
        public virtual List <PMTask> CreateProjectTrans()
        {
            var autoAllocateTasks = new List <PMTask>();

            if (Base.BatchModule.Current != null && Base.BatchModule.Current.Module != BatchModule.GL)
            {
                PXResultset <GLTran> trans = new PXSelect <GLTran,
                                                           Where <GLTran.module, Equal <Current <Batch.module> >,
                                                                  And <GLTran.batchNbr, Equal <Current <Batch.batchNbr> >,
                                                                       And <GLTran.pMTranID, IsNull,
                                                                            And <GLTran.isNonPM, NotEqual <True> > > > > >(Base).Select();

                if (trans.Count > 0)
                {
                    ProjectBalance pb = CreateProjectBalance();
                    var            tasksToAutoAllocate = new Dictionary <string, PMTask>();
                    var            sourceForAllocation = new List <PMTran>();

                    var doc = new PMRegister();
                    doc.Module      = Base.BatchModule.Current.Module;
                    doc.Date        = Base.BatchModule.Current.DateEntered;
                    doc.Description = Base.BatchModule.Current.Description;
                    doc.Released    = true;
                    doc.Status      = PMRegister.status.Released;
                    bool docInserted = false;                     //to prevent creating empty batch
                    JournalEntryTranRef entryRefGraph = PXGraph.CreateInstance <JournalEntryTranRef>();

                    foreach (GLTran tran in trans)
                    {
                        var acc = (Account)PXSelect <Account,
                                                     Where <Account.accountID, Equal <Required <GLTran.accountID> >,
                                                            And <Account.accountGroupID, IsNotNull> > > .Select(Base, tran.AccountID);

                        if (acc == null)
                        {
                            continue;
                        }

                        var ag = (PMAccountGroup)PXSelect <PMAccountGroup,
                                                           Where <PMAccountGroup.groupID, Equal <Required <Account.accountGroupID> >,
                                                                  And <PMAccountGroup.type, NotEqual <PMAccountType.offBalance> > > > .Select(Base, acc.AccountGroupID);

                        if (ag == null)
                        {
                            continue;
                        }

                        var project = (PMProject)PXSelect <PMProject,
                                                           Where <PMProject.contractID, Equal <Required <GLTran.projectID> >,
                                                                  And <PMProject.nonProject, Equal <False> > > > .Select(Base, tran.ProjectID);

                        if (project == null)
                        {
                            continue;
                        }

                        var task = (PMTask)PXSelect <PMTask,
                                                     Where <PMTask.projectID, Equal <Required <GLTran.projectID> >,
                                                            And <PMTask.taskID, Equal <Required <GLTran.taskID> > > > > .Select(Base, tran.ProjectID, tran.TaskID);

                        if (task == null)
                        {
                            continue;
                        }

                        APTran apTran = null;
                        if (Base.BatchModule.Current.Module == BatchModule.AP)
                        {
                            apTran = (APTran)PXSelect <APTran,
                                                       Where <APTran.refNbr, Equal <Required <GLTran.refNbr> >,
                                                              And <APTran.lineNbr, Equal <Required <GLTran.tranLineNbr> >,
                                                                   And <APTran.tranType, Equal <Required <GLTran.tranType> > > > > > .Select(Base, tran.RefNbr, tran.TranLineNbr, tran.TranType);
                        }

                        ARTran arTran = null;
                        if (Base.BatchModule.Current.Module == BatchModule.AR)
                        {
                            arTran = (ARTran)PXSelect <ARTran,
                                                       Where <ARTran.refNbr, Equal <Required <GLTran.refNbr> >,
                                                              And <ARTran.lineNbr, Equal <Required <GLTran.tranLineNbr> >,
                                                                   And <ARTran.tranType, Equal <Required <GLTran.tranType> > > > > > .Select(Base, tran.RefNbr, tran.TranLineNbr, tran.TranType);
                        }

                        if (!docInserted)
                        {
                            doc         = ProjectDocs.Insert(doc);
                            docInserted = true;
                        }

                        doc.OrigDocType = entryRefGraph.GetDocType(apTran, arTran, tran);
                        doc.OrigNoteID  = entryRefGraph.GetNoteID(apTran, arTran, tran);

                        PMTran pmt = (PMTran)ProjectTrans.Cache.Insert();

                        pmt.BranchID       = tran.BranchID;
                        pmt.AccountGroupID = acc.AccountGroupID;
                        pmt.AccountID      = tran.AccountID;
                        pmt.SubID          = tran.SubID;
                        entryRefGraph.AssignCustomerVendorEmployee(tran, pmt);                         //CustomerLocation is lost.
                        //pmt.BatchNbr = tran.BatchNbr;
                        pmt.Date         = tran.TranDate;
                        pmt.TranDate     = tran.TranDate;
                        pmt.Description  = tran.TranDesc;
                        pmt.FinPeriodID  = tran.FinPeriodID;
                        pmt.TranPeriodID = tran.TranPeriodID;
                        pmt.InventoryID  = tran.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID;
                        pmt.OrigLineNbr  = tran.LineNbr;
                        pmt.OrigModule   = tran.Module;
                        pmt.OrigRefNbr   = tran.RefNbr;
                        pmt.OrigTranType = tran.TranType;
                        pmt.ProjectID    = tran.ProjectID;
                        pmt.TaskID       = tran.TaskID;
                        pmt.CostCodeID   = tran.CostCodeID;
                        if (arTran != null)
                        {
                            pmt.Billable                  = false;
                            pmt.ExcludedFromBilling       = true;
                            pmt.ExcludedFromBillingReason = arTran.TranType == ARDocType.CreditMemo ?
                                                            PXMessages.LocalizeFormatNoPrefix(Messages.ExcludedFromBillingAsCreditMemoResult, arTran.RefNbr) :
                                                            PXMessages.LocalizeFormatNoPrefix(Messages.ExcludedFromBillingAsARInvoiceResult, arTran.RefNbr);
                        }
                        else
                        {
                            pmt.Billable = tran.NonBillable != true;
                        }
                        pmt.Released = true;

                        if (apTran != null && apTran.Date != null)
                        {
                            pmt.Date = apTran.Date;
                        }

                        pmt.UseBillableQty = true;
                        pmt.UOM            = tran.UOM;

                        pmt.Amount = tran.DebitAmt - tran.CreditAmt;

                        CurrencyInfo projectCuryInfo = null;
                        if (PXAccess.FeatureInstalled <FeaturesSet.projectMultiCurrency>())
                        {
                            pmt.TranCuryID     = Base.BatchModule.Current.CuryID;
                            pmt.ProjectCuryID  = project.CuryID;
                            pmt.BaseCuryInfoID = tran.CuryInfoID;
                            pmt.TranCuryAmount = tran.CuryDebitAmt - tran.CuryCreditAmt;

                            if (project.CuryID == Base.ledger.Current.BaseCuryID)
                            {
                                pmt.ProjectCuryInfoID = tran.CuryInfoID;
                                pmt.ProjectCuryAmount = pmt.Amount;
                            }
                            else if (project.CuryID == Base.BatchModule.Current.CuryID)
                            {
                                projectCuryInfo                = new CurrencyInfo();
                                projectCuryInfo.ModuleCode     = GL.BatchModule.PM;
                                projectCuryInfo.BaseCuryID     = project.CuryID;
                                projectCuryInfo.CuryID         = project.CuryID;
                                projectCuryInfo.CuryRateTypeID = project.RateTypeID ?? Base.CMSetup.Current.PMRateTypeDflt;
                                projectCuryInfo.CuryEffDate    = tran.TranDate;
                                projectCuryInfo.CuryRate       = 1;
                                projectCuryInfo.RecipRate      = 1;
                                projectCuryInfo                = Base.currencyinfo.Insert(projectCuryInfo);
                                pmt.ProjectCuryInfoID          = projectCuryInfo.CuryInfoID;
                                pmt.ProjectCuryAmount          = pmt.TranCuryAmount;
                            }
                            else
                            {
                                CM.Extensions.IPXCurrencyService currencyService = ServiceLocator.Current.GetInstance <Func <PXGraph, CM.Extensions.IPXCurrencyService> >()(Base);

                                projectCuryInfo                = new CurrencyInfo();
                                projectCuryInfo.ModuleCode     = GL.BatchModule.PM;
                                projectCuryInfo.BaseCuryID     = project.CuryID;
                                projectCuryInfo.CuryID         = Base.BatchModule.Current.CuryID;
                                projectCuryInfo.CuryRateTypeID = project.RateTypeID ?? currencyService.DefaultRateTypeID(BatchModule.PM);
                                projectCuryInfo.CuryEffDate    = tran.TranDate;

                                var rate = currencyService.GetRate(projectCuryInfo.CuryID, projectCuryInfo.BaseCuryID, projectCuryInfo.CuryRateTypeID, projectCuryInfo.CuryEffDate);
                                if (rate == null)
                                {
                                    throw new PXException(PM.Messages.FxTranToProjectNotFound, projectCuryInfo.CuryID, projectCuryInfo.BaseCuryID, projectCuryInfo.CuryRateTypeID, tran.TranDate);
                                }

                                projectCuryInfo       = Base.currencyinfo.Insert(projectCuryInfo);
                                pmt.ProjectCuryInfoID = projectCuryInfo.CuryInfoID;
                                decimal val;
                                PXCurrencyAttribute.CuryConvBase(Base.BatchModule.Cache, projectCuryInfo, pmt.TranCuryAmount.GetValueOrDefault(), out val);
                                pmt.ProjectCuryAmount = val;
                            }
                        }
                        else
                        {
                            pmt.TranCuryAmount    = pmt.Amount;
                            pmt.ProjectCuryAmount = pmt.Amount;
                            pmt.TranCuryID        = Base.ledger.Current.BaseCuryID;
                            pmt.ProjectCuryID     = Base.ledger.Current.BaseCuryID;

                            if (Base.BatchModule.Current.CuryID != Base.ledger.Current.BaseCuryID)
                            {
                                CurrencyInfo baseCuryInfo = new CurrencyInfo();
                                baseCuryInfo.ModuleCode     = GL.BatchModule.PM;
                                baseCuryInfo.BaseCuryID     = Base.ledger.Current.BaseCuryID;
                                baseCuryInfo.CuryID         = Base.ledger.Current.BaseCuryID;
                                baseCuryInfo.CuryRateTypeID = null;
                                baseCuryInfo.CuryEffDate    = tran.TranDate;
                                baseCuryInfo.CuryRate       = 1;
                                baseCuryInfo.RecipRate      = 1;
                                baseCuryInfo          = Base.currencyinfo.Insert(baseCuryInfo);
                                pmt.ProjectCuryInfoID = baseCuryInfo.CuryInfoID;
                                pmt.BaseCuryInfoID    = baseCuryInfo.CuryInfoID;
                            }
                            else
                            {
                                pmt.ProjectCuryInfoID = tran.CuryInfoID;
                                pmt.BaseCuryInfoID    = tran.CuryInfoID;
                            }
                        }

                        pmt.Qty = tran.Qty;                        //pmt.Amount >= 0 ? tran.Qty : (tran.Qty * -1);
                        int sign = 1;
                        if (acc.Type == AccountType.Income || acc.Type == AccountType.Liability)
                        {
                            sign = -1;
                        }

                        if (ProjectBalance.IsFlipRequired(acc.Type, ag.Type))
                        {
                            pmt.ProjectCuryAmount = -pmt.ProjectCuryAmount;
                            pmt.TranCuryAmount    = -pmt.TranCuryAmount;
                            pmt.Amount            = -pmt.Amount;
                            pmt.Qty = -pmt.Qty;
                        }
                        pmt.BillableQty = pmt.Qty;


                        Base.GLTranModuleBatNbr.SetValueExt <GLTran.pMTranID>(tran, pmt.TranID);

                        if (apTran != null && apTran.NoteID != null)
                        {
                            PXNoteAttribute.CopyNoteAndFiles(Base.Caches[typeof(AP.APTran)], apTran, ProjectTrans.Cache, pmt);
                        }
                        else if (arTran != null && arTran.NoteID != null)
                        {
                            PXNoteAttribute.CopyNoteAndFiles(Base.Caches[typeof(AR.ARTran)], arTran, ProjectTrans.Cache, pmt);
                        }

                        ProjectBalance.Result balance = pb.Calculate(project, pmt, ag, acc.Type, sign, 1);

                        if (balance.Status != null)
                        {
                            PMBudgetAccum ps = new PMBudgetAccum();
                            ps.ProjectID      = balance.Status.ProjectID;
                            ps.ProjectTaskID  = balance.Status.ProjectTaskID;
                            ps.AccountGroupID = balance.Status.AccountGroupID;
                            ps.InventoryID    = balance.Status.InventoryID;
                            ps.CostCodeID     = balance.Status.CostCodeID;
                            ps.UOM            = balance.Status.UOM;
                            ps.IsProduction   = balance.Status.IsProduction;
                            ps.Type           = balance.Status.Type;
                            ps.Description    = balance.Status.Description;
                            ps.CuryInfoID     = balance.Status.CuryInfoID;

                            ps                   = ProjectBudget.Insert(ps);
                            ps.ActualQty        += balance.Status.ActualQty.GetValueOrDefault();
                            ps.CuryActualAmount += balance.Status.CuryActualAmount.GetValueOrDefault();
                            ps.ActualAmount     += balance.Status.ActualAmount.GetValueOrDefault();

                            if (arTran != null && arTran.LineNbr != null && ag.Type == GL.AccountType.Income)
                            {
                                ps.CuryInvoicedAmount -= balance.Status.CuryActualAmount.GetValueOrDefault();
                                ps.InvoicedAmount     -= balance.Status.ActualAmount.GetValueOrDefault();
                            }
                        }

                        if (balance.ForecastHistory != null)
                        {
                            PMForecastHistoryAccum forecast = new PMForecastHistoryAccum();
                            forecast.ProjectID      = balance.ForecastHistory.ProjectID;
                            forecast.ProjectTaskID  = balance.ForecastHistory.ProjectTaskID;
                            forecast.AccountGroupID = balance.ForecastHistory.AccountGroupID;
                            forecast.InventoryID    = balance.ForecastHistory.InventoryID;
                            forecast.CostCodeID     = balance.ForecastHistory.CostCodeID;
                            forecast.PeriodID       = balance.ForecastHistory.PeriodID;

                            forecast = ForecastHistory.Insert(forecast);

                            forecast.ActualQty        += balance.ForecastHistory.ActualQty.GetValueOrDefault();
                            forecast.CuryActualAmount += balance.ForecastHistory.CuryActualAmount.GetValueOrDefault();
                            forecast.ActualAmount     += balance.ForecastHistory.ActualAmount.GetValueOrDefault();
                        }

                        if (balance.TaskTotal != null)
                        {
                            PMTaskTotal ta = new PMTaskTotal();
                            ta.ProjectID = balance.TaskTotal.ProjectID;
                            ta.TaskID    = balance.TaskTotal.TaskID;

                            ta                = ProjectTaskTotals.Insert(ta);
                            ta.CuryAsset     += balance.TaskTotal.CuryAsset.GetValueOrDefault();
                            ta.Asset         += balance.TaskTotal.Asset.GetValueOrDefault();
                            ta.CuryLiability += balance.TaskTotal.CuryLiability.GetValueOrDefault();
                            ta.Liability     += balance.TaskTotal.Liability.GetValueOrDefault();
                            ta.CuryIncome    += balance.TaskTotal.CuryIncome.GetValueOrDefault();
                            ta.Income        += balance.TaskTotal.Income.GetValueOrDefault();
                            ta.CuryExpense   += balance.TaskTotal.CuryExpense.GetValueOrDefault();
                            ta.Expense       += balance.TaskTotal.Expense.GetValueOrDefault();
                        }

                        RegisterReleaseProcess.AddToUnbilledSummary(Base, pmt);

                        sourceForAllocation.Add(pmt);
                        if (pmt.Allocated != true && pmt.ExcludedFromAllocation != true && project.AutoAllocate == true)
                        {
                            if (!tasksToAutoAllocate.ContainsKey(string.Format("{0}.{1}", task.ProjectID, task.TaskID)))
                            {
                                tasksToAutoAllocate.Add(string.Format("{0}.{1}", task.ProjectID, task.TaskID), task);
                            }
                        }

                        entryRefGraph.AssignAdditionalFields(tran, pmt);
                    }
                    autoAllocateTasks.AddRange(tasksToAutoAllocate.Values);
                }
            }
            return(autoAllocateTasks);
        }
Ejemplo n.º 10
0
        protected virtual void CATransfer_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            CATransfer transfer = (CATransfer)e.Row;

            if (transfer == null)
            {
                return;
            }

            transfer.RGOLAmt = transfer.TranIn - transfer.TranOut;

            bool transferOnHold      = (transfer.Hold == true);
            bool transferNotReleased = (transfer.Released != true);
            bool transferReleased    = (transfer.Released == true);
            bool msFeatureInstalled  = PXAccess.FeatureInstalled <FeaturesSet.multicurrency>();

            PXUIFieldAttribute.SetVisible <CATransfer.inCuryID>(sender, transfer, msFeatureInstalled);
            PXUIFieldAttribute.SetVisible <CATransfer.outCuryID>(sender, transfer, msFeatureInstalled);
            PXUIFieldAttribute.SetVisible <CATransfer.rGOLAmt>(sender, transfer, msFeatureInstalled);
            PXUIFieldAttribute.SetVisible <CATransfer.inGLBalance>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.outGLBalance>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.cashBalanceIn>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.cashBalanceOut>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.tranIDIn_CATran_batchNbr>(sender, transfer, transferReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.tranIDOut_CATran_batchNbr>(sender, transfer, transferReleased);

            PXUIFieldAttribute.SetEnabled(sender, transfer, false);

            sender.AllowDelete = transferNotReleased;
            sender.AllowUpdate = transferNotReleased;
            Expenses.Cache.SetAllEditPermissions(transferNotReleased);

            CashAccount cashaccountOut = (CashAccount)PXSelectorAttribute.Select <CATransfer.outAccountID>(sender, e.Row);
            CashAccount cashaccountIn  = (CashAccount)PXSelectorAttribute.Select <CATransfer.inAccountID>(sender, e.Row);

            bool clearEnabledIn  = transferNotReleased && (cashaccountIn != null) && (cashaccountIn.Reconcile == true);
            bool clearEnabledOut = transferNotReleased && (cashaccountOut != null) && (cashaccountOut.Reconcile == true);

            PXUIFieldAttribute.SetEnabled <CATransfer.hold>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.transferNbr>(sender, transfer, true);
            PXUIFieldAttribute.SetEnabled <CATransfer.descr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.curyTranIn>(sender, transfer, transferNotReleased && (transfer.OutCuryID != transfer.InCuryID));
            PXUIFieldAttribute.SetEnabled <CATransfer.inAccountID>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.inDate>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.inExtRefNbr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.curyTranOut>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outAccountID>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outDate>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outExtRefNbr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearedOut>(sender, transfer, clearEnabledOut);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearDateOut>(sender, transfer, clearEnabledOut && transfer.ClearedOut == true);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearedIn>(sender, transfer, clearEnabledIn);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearDateIn>(sender, transfer, clearEnabledIn && transfer.ClearedIn == true);

            Release.SetEnabled(transferNotReleased && !transferOnHold);
            Reverse.SetEnabled(transferReleased);

            UIState.RaiseOrHideErrorByErrorLevelPriority <CATransfer.inDate>(sender, transfer, transfer.Released != true && transfer.OutDate > transfer.InDate, Messages.EarlyInDate, PXErrorLevel.Warning);

            SetAdjRefNbrVisibility();
        }
Ejemplo n.º 11
0
 protected virtual bool IsPrintingAllowed(PrintParameters row)
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.deviceHub>() && (row != null && row.Action == ActionTypes.Print));
 }
        public NumberingDetector(PXGraph graph, ApplicationAreas areas)
        {
            parentGraph             = graph;
            setupNumberingSequences = new Dictionary <Type, PXSelectBase>();
            if (areas.HasFlag(ApplicationAreas.StandardFinance))
            {
                PXSelect <AR.ARSetup> arsetup = new PXSelect <AR.ARSetup>(graph);
                PXSelect <AP.APSetup> apsetup = new PXSelect <AP.APSetup>(graph);
                PXSelect <CA.CASetup> casetup = new PXSelect <CA.CASetup>(graph);
                PXSelect <GL.GLSetup> glsetup = new PXSelect <GL.GLSetup>(graph);

                setupNumberingSequences.Add(typeof(AR.ARSetup.batchNumberingID), arsetup);
                setupNumberingSequences.Add(typeof(AR.ARSetup.creditAdjNumberingID), arsetup);
                setupNumberingSequences.Add(typeof(AR.ARSetup.debitAdjNumberingID), arsetup);
                setupNumberingSequences.Add(typeof(AR.ARSetup.finChargeNumberingID), arsetup);
                setupNumberingSequences.Add(typeof(AR.ARSetup.invoiceNumberingID), arsetup);
                setupNumberingSequences.Add(typeof(AR.ARSetup.paymentNumberingID), arsetup);
                setupNumberingSequences.Add(typeof(AR.ARSetup.priceWSNumberingID), arsetup);
                setupNumberingSequences.Add(typeof(AR.ARSetup.usageNumberingID), arsetup);
                setupNumberingSequences.Add(typeof(AR.ARSetup.writeOffNumberingID), arsetup);

                setupNumberingSequences.Add(typeof(AP.APSetup.batchNumberingID), apsetup);
                setupNumberingSequences.Add(typeof(AP.APSetup.creditAdjNumberingID), apsetup);
                setupNumberingSequences.Add(typeof(AP.APSetup.debitAdjNumberingID), apsetup);
                setupNumberingSequences.Add(typeof(AP.APSetup.checkNumberingID), apsetup);
                setupNumberingSequences.Add(typeof(AP.APSetup.invoiceNumberingID), apsetup);
                setupNumberingSequences.Add(typeof(AP.APSetup.priceWSNumberingID), apsetup);

                setupNumberingSequences.Add(typeof(CA.CASetup.batchNumberingID), casetup);
                setupNumberingSequences.Add(typeof(CA.CASetup.cABatchNumberingID), casetup);
                setupNumberingSequences.Add(typeof(CA.CASetup.cAImportPaymentsNumberingID), casetup);
                setupNumberingSequences.Add(typeof(CA.CASetup.cAStatementNumberingID), casetup);
                setupNumberingSequences.Add(typeof(CA.CASetup.registerNumberingID), casetup);
                setupNumberingSequences.Add(typeof(CA.CASetup.transferNumberingID), casetup);

                setupNumberingSequences.Add(typeof(GL.GLSetup.batchNumberingID), glsetup);
                setupNumberingSequences.Add(typeof(GL.GLSetup.allocationNumberingID), glsetup);
                setupNumberingSequences.Add(typeof(GL.GLSetup.docBatchNumberingID), glsetup);
                setupNumberingSequences.Add(typeof(GL.GLSetup.scheduleNumberingID), glsetup);
                setupNumberingSequences.Add(typeof(GL.GLSetup.tBImportNumberingID), glsetup);

                var cashaccount = new PXSelect <CA.CashAccount, Where <CA.CashAccount.reconNumberingID, Equal <Required <Numbering.numberingID> > > >(graph);
                setupNumberingSequences.Add(typeof(CA.CashAccount.reconNumberingID), cashaccount);
            }
            if (areas.HasFlag(ApplicationAreas.AdvancedFinance))
            {
                if (PXAccess.FeatureInstalled <FeaturesSet.fixedAsset>())
                {
                    PXSelect <FA.FASetup> fasetup = new PXSelect <FA.FASetup>(graph);
                    setupNumberingSequences.Add(typeof(FA.FASetup.registerNumberingID), fasetup);
                    setupNumberingSequences.Add(typeof(FA.FASetup.assetNumberingID), fasetup);
                    setupNumberingSequences.Add(typeof(FA.FASetup.batchNumberingID), fasetup);
                    setupNumberingSequences.Add(typeof(FA.FASetup.tagNumberingID), fasetup);
                }
                if (PXAccess.FeatureInstalled <FeaturesSet.multicurrency>())
                {
                    PXSelect <CM.CMSetup> cmsetup = new PXSelect <CM.CMSetup>(graph);
                    setupNumberingSequences.Add(typeof(CM.CMSetup.batchNumberingID), cmsetup);
                    setupNumberingSequences.Add(typeof(CM.CMSetup.translNumberingID), cmsetup);
                    setupNumberingSequences.Add(typeof(CM.CMSetup.extRefNbrNumberingID), cmsetup);
                }
            }

            if (areas.HasFlag(ApplicationAreas.Distribution) && PXAccess.FeatureInstalled <FeaturesSet.distributionModule>())
            {
                PXSelect <IN.INSetup> insetup = new PXSelect <IN.INSetup>(graph);
                setupNumberingSequences.Add(typeof(IN.INSetup.batchNumberingID), insetup);
                setupNumberingSequences.Add(typeof(IN.INSetup.receiptNumberingID), insetup);
                setupNumberingSequences.Add(typeof(IN.INSetup.issueNumberingID), insetup);
                setupNumberingSequences.Add(typeof(IN.INSetup.adjustmentNumberingID), insetup);
                setupNumberingSequences.Add(typeof(IN.INSetup.kitAssemblyNumberingID), insetup);
                setupNumberingSequences.Add(typeof(IN.INSetup.pINumberingID), insetup);
                setupNumberingSequences.Add(typeof(IN.INSetup.replenishmentNumberingID), insetup);

                PXSelect <SO.SOSetup> sosetup = new PXSelect <SO.SOSetup>(graph);
                setupNumberingSequences.Add(typeof(SO.SOSetup.shipmentNumberingID), sosetup);

                var orderTypeInvoice = new PXSelect <SO.SOOrderType,
                                                     Where <SO.SOOrderType.invoiceNumberingID, Equal <Required <Numbering.numberingID> > > >(graph);
                var orderTypeOrder = new PXSelect <SO.SOOrderType,
                                                   Where <SO.SOOrderType.orderNumberingID, Equal <Required <Numbering.numberingID> > > >(graph);
                setupNumberingSequences.Add(typeof(SO.SOOrderType.invoiceNumberingID), orderTypeInvoice);
                setupNumberingSequences.Add(typeof(SO.SOOrderType.orderNumberingID), orderTypeOrder);

                PXSelect <PO.POSetup> posetup = new PXSelect <PO.POSetup>(graph);
                setupNumberingSequences.Add(typeof(PO.POSetup.standardPONumberingID), posetup);
                setupNumberingSequences.Add(typeof(PO.POSetup.regularPONumberingID), posetup);
                setupNumberingSequences.Add(typeof(PO.POSetup.receiptNumberingID), posetup);

                PXSelect <RQ.RQSetup> rqsetup = new PXSelect <RQ.RQSetup>(graph);
                setupNumberingSequences.Add(typeof(RQ.RQSetup.requestNumberingID), rqsetup);
                setupNumberingSequences.Add(typeof(RQ.RQSetup.requisitionNumberingID), rqsetup);
            }

            if (areas.HasFlag(ApplicationAreas.Project) && PXAccess.FeatureInstalled <FeaturesSet.projectModule>())
            {
                PXSelect <PM.PMSetup> pmsetup = new PXSelect <PM.PMSetup>(graph);
                setupNumberingSequences.Add(typeof(PM.PMSetup.tranNumbering), pmsetup);
                setupNumberingSequences.Add(typeof(PM.PMSetup.batchNumberingID), pmsetup);
            }
        }
Ejemplo n.º 13
0
        public static void UpdateServiceOrderHeader(ServiceOrderEntry graphServiceOrderEntry,
                                                    PXCache cache,
                                                    CRCase crCaseRow,
                                                    FSCreateServiceOrderOnCaseFilter fsCreateServiceOrderOnCaseFilterRow,
                                                    FSServiceOrder fsServiceOrderRow,
                                                    bool updatingExistingSO)
        {
            if (fsServiceOrderRow.Status == ID.Status_ServiceOrder.CLOSED)
            {
                return;
            }

            bool somethingChanged = false;

            FSSrvOrdType fsSrvOrdTypeRow = GetServiceOrderType(graphServiceOrderEntry, fsServiceOrderRow.SrvOrdType);

            if (fsSrvOrdTypeRow.Behavior != ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT)
            {
                if (fsServiceOrderRow.CustomerID != crCaseRow.CustomerID)
                {
                    graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.customerID>(fsServiceOrderRow, crCaseRow.CustomerID);
                    somethingChanged = true;
                }

                if (fsServiceOrderRow.LocationID != crCaseRow.LocationID)
                {
                    graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.locationID>(fsServiceOrderRow, crCaseRow.LocationID);
                    somethingChanged = true;
                }
            }

            if (PXAccess.FeatureInstalled <FeaturesSet.multicurrency>())
            {
                Customer customer = (Customer)PXSelect <Customer,
                                                        Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > >
                                    .Select(graphServiceOrderEntry, crCaseRow.CustomerID);

                if (customer != null &&
                    fsServiceOrderRow.CuryID != customer.CuryID)
                {
                    graphServiceOrderEntry.ServiceOrderRecords.Cache.SetValueExt <FSServiceOrder.curyID>(fsServiceOrderRow, customer.CuryID);
                    somethingChanged = true;
                }
            }

            if (fsServiceOrderRow.BranchLocationID != fsCreateServiceOrderOnCaseFilterRow.BranchLocationID)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.branchLocationID>(fsServiceOrderRow, fsCreateServiceOrderOnCaseFilterRow.BranchLocationID);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.ContactID != crCaseRow.ContactID)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.contactID>(fsServiceOrderRow, crCaseRow.ContactID);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.DocDesc != crCaseRow.Subject)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.docDesc>(fsServiceOrderRow, crCaseRow.Subject);
                somethingChanged = true;
            }

            if (crCaseRow.OwnerID != null)
            {
                if (crCaseRow.OwnerID != (Guid?)cache.GetValueOriginal <CROpportunity.ownerID>(crCaseRow))
                {
                    int?salesPersonID = GetSalesPersonID(graphServiceOrderEntry, crCaseRow.OwnerID);

                    if (salesPersonID != null)
                    {
                        graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.salesPersonID>(fsServiceOrderRow, salesPersonID);
                        somethingChanged = true;
                    }
                }
            }

            if (crCaseRow.CreatedDateTime.HasValue &&
                fsServiceOrderRow.OrderDate != crCaseRow.CreatedDateTime.Value.Date)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.orderDate>(fsServiceOrderRow, crCaseRow.CreatedDateTime.Value.Date);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.SLAETA != crCaseRow.SLAETA)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.sLAETA>(fsServiceOrderRow, crCaseRow.SLAETA);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.AssignedEmpID != fsCreateServiceOrderOnCaseFilterRow.AssignedEmpID)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.assignedEmpID>(fsServiceOrderRow, fsCreateServiceOrderOnCaseFilterRow.AssignedEmpID);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.ProblemID != fsCreateServiceOrderOnCaseFilterRow.ProblemID)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.problemID>(fsServiceOrderRow, fsCreateServiceOrderOnCaseFilterRow.ProblemID);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.LongDescr != crCaseRow.Description)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.longDescr>(fsServiceOrderRow, crCaseRow.Description);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.Priority != crCaseRow.Priority)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.priority>(fsServiceOrderRow, crCaseRow.Priority);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.Severity != crCaseRow.Severity)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.severity>(fsServiceOrderRow, crCaseRow.Severity);
                somethingChanged = true;
            }

            if (somethingChanged && updatingExistingSO)
            {
                graphServiceOrderEntry.ServiceOrderRecords.Update(fsServiceOrderRow);
            }
        }
        public void SOSetup_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            SOSetup setup = e.Row as SOSetup;

            if (setup == null)
            {
                return;
            }

            if (setup.UseShippedNotInvoiced == true && setup.ShippedNotInvoicedAcctID == null)
            {
                throw new PXRowPersistingException(typeof(SOSetup.shippedNotInvoicedAcctID).Name, null, ErrorMessages.FieldIsEmpty, typeof(SOSetup.shippedNotInvoicedAcctID).Name);
            }
            if (setup.UseShippedNotInvoiced == true && setup.ShippedNotInvoicedSubID == null && PXAccess.FeatureInstalled <FeaturesSet.subAccount>())
            {
                throw new PXRowPersistingException(typeof(SOSetup.shippedNotInvoicedSubID).Name, null, ErrorMessages.FieldIsEmpty, typeof(SOSetup.shippedNotInvoicedSubID).Name);
            }
        }
Ejemplo n.º 15
0
    /// <summary>
    ///
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (PX.Data.Update.PXUpdateHelper.CheckUpdateLock())
        {
            throw new PXUnderMaintenanceException();
        }

        var lockoutStatus = PXSiteLockout.GetStatus(true);

        if (lockoutStatus == PXSiteLockout.Status.Locked)
        {
            lblUnderMaintenance.Text    = PXMessages.Localize(PX.Data.Update.Messages.SiteUnderMaintenance);
            lblUnderMaintenance.Visible = true;

            if (!string.IsNullOrWhiteSpace(PXSiteLockout.Message))
            {
                lblUnderMaintenanceReason.Text = string.Format(
                    PXMessages.Localize(PX.Data.Update.Messages.LockoutReason), PXSiteLockout.Message);
                lblUnderMaintenanceReason.Visible = true;
            }
        }

        if (lockoutStatus == PXSiteLockout.Status.Pending)
        {
            string datetime = string.Format("{0} ({1} UTC)", PXSiteLockout.DateTime, PXSiteLockout.DateTimeUtc);
            lblUnderMaintenance.Text = string.Format(
                PXMessages.Localize(PX.Data.Update.Messages.PendingLockout),

                datetime, PXSiteLockout.Message);
            lblUnderMaintenance.Visible = true;
        }

        if (GetPostBackControl(this.Page) == cmbCompany)
        {
            txtPass.Attributes.Add("value", txtPass.Text);
        }

        if (GetPostBackControl(this.Page) == btnLogin && !String.IsNullOrEmpty(txtDummyCpny.Value))
        {
            cmbCompany.SelectedValue = txtDummyCpny.Value;
        }

        // if user already set password then we should disabling login and password
        if (!String.IsNullOrEmpty(txtVeryDummyPass.Value))
        {
            txtPass.Text = txtVeryDummyPass.Value;
            DisablingUserPassword();
            if (!MultiCompaniesSecure)
            {
                EnablingChangingPassword();
            }
        }

        // if (SecureCompanyID) then we should hide combobox before first login.
        // and also we should shrink companies list
        if (PXDatabase.SecureCompanyID && (Membership.Provider is PXBaseMembershipProvider))
        {
            this.cmbCompany.Visible = !String.IsNullOrEmpty(txtVeryDummyPass.Value);

            if (!String.IsNullOrEmpty(txtVeryDummyPass.Value))
            {
                List <String> companyFilter = new List <String>(PXAccess.GetCompanies(txtUser.Text, txtVeryDummyPass.Value));
                for (int i = cmbCompany.Items.Count - 1; i >= 0; i--)
                {
                    ListItem item = cmbCompany.Items[i];
                    if (!companyFilter.Contains(item.Value))
                    {
                        cmbCompany.Items.RemoveAt(i);
                    }
                }
            }
        }

        // Is user trying to recover his password using link from Email?
        if (Request.QueryString.AllKeys.Length > 0 && Request.QueryString.GetValues("gk") != null)
        {
            RemindUserPassword();
        }
        try
        {
            this.SetInfoText();
        }
        catch { /*SKIP ERROS*/ }
        this.idStorage.Value = seed;
        //try silent login
        btnLoginSilent_Click(sender, e);
    }
Ejemplo n.º 16
0
 public static bool IsActive()
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.projectModule>());
 }
 public static bool IsActive()
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.construction>() &&
            !SiteMapExtension.IsTaxBillsAndAdjustmentsScreenId());
 }
Ejemplo n.º 18
0
        public virtual void UpdateSalesPrice(ARSalesPrice item)
        {
            using (PXConnectionScope cs = new PXConnectionScope())
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    DateTime updateTime = DateTime.Now;

                    //FOR UI:
                    item.LastPrice       = item.SalesPrice;
                    item.SalesPrice      = item.PendingPrice;
                    item.LastBreakQty    = item.BreakQty;
                    item.BreakQty        = item.PendingBreakQty;
                    item.LastDate        = item.EffectiveDate;
                    item.EffectiveDate   = null;
                    item.PendingPrice    = 0;
                    item.PendingBreakQty = 0;
                    item.LastTaxID       = item.TaxID;
                    item.TaxID           = item.PendingTaxID;
                    item.PendingTaxID    = null;


                    PXDatabase.Update <ARSalesPrice>(
                        new PXDataFieldAssign("LastPrice", PXDbType.Decimal, item.LastPrice),
                        new PXDataFieldAssign("LastTaxID", PXDbType.NVarChar, item.LastTaxID),
                        new PXDataFieldAssign("LastBreakQty", PXDbType.Decimal, item.LastBreakQty),
                        new PXDataFieldAssign("SalesPrice", PXDbType.Decimal, item.SalesPrice),
                        new PXDataFieldAssign("TaxID", PXDbType.NVarChar, item.TaxID),
                        new PXDataFieldAssign("BreakQty", PXDbType.Decimal, item.BreakQty),
                        new PXDataFieldAssign("LastDate", PXDbType.DateTime, item.LastDate),
                        new PXDataFieldAssign("PendingPrice", PXDbType.Decimal, 0m),
                        new PXDataFieldAssign("PendingTaxID", PXDbType.Decimal, null),
                        new PXDataFieldAssign("EffectiveDate", PXDbType.DateTime, null),
                        new PXDataFieldAssign("PendingBreakQty", PXDbType.Decimal, 0m),
                        new PXDataFieldAssign("LastModifiedDateTime", PXDbType.DateTime, updateTime),

                        new PXDataFieldRestrict("RecordID", PXDbType.Int, item.RecordID),
                        PXDataFieldRestrict.OperationSwitchAllowed
                        );

                    PXDatabase.Update <ARSalesPrice>(
                        new PXDataFieldAssign("SalesPrice", PXDbType.Decimal, item.SalesPrice),
                        new PXDataFieldAssign("LastDate", PXDbType.DateTime, item.LastDate),
                        new PXDataFieldAssign("LastModifiedDateTime", PXDbType.DateTime, updateTime),
                        new PXDataFieldRestrict("InventoryID", PXDbType.Int, item.InventoryID),
                        item.IsCustClassPrice == true
                                                                                ? new PXDataFieldRestrict("CustPriceClassID", PXDbType.NVarChar, item.CustPriceClassID)
                                                                                : new PXDataFieldRestrict("CustomerID", PXDbType.Int, item.CustomerID),
                        new PXDataFieldRestrict("CuryID", PXDbType.NVarChar, item.CuryID),
                        new PXDataFieldRestrict("UOM", PXDbType.NVarChar, item.UOM),
                        new PXDataFieldRestrict("IsPromotionalPrice", PXDbType.Bit, false),
                        new PXDataFieldRestrict("BreakQty", PXDbType.Decimal, item.BreakQty),
                        new PXDataFieldRestrict("RecordID", PXDbType.Int, 4, item.RecordID, PXComp.NE)
                        );

                    InventoryItem ii = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, item.InventoryID);

                    string uom = PXAccess.FeatureInstalled <FeaturesSet.distributionModule>() && sosetup.Current.SalesPriceUpdateUnit == SalesPriceUpdateUnitType.SalesUnit ? ii.SalesUnit : ii.BaseUnit;
                    if (item.UOM == uom && item.CuryID == Company.Current.BaseCuryID && item.CustPriceClassID == AR.ARPriceClass.EmptyPriceClass && item.BreakQty == 0 && item.PendingBreakQty == 0 && item.IsPromotionalPrice == false)
                    {
                        decimal price     = PXAccess.FeatureInstalled <FeaturesSet.distributionModule>() && sosetup.Current.SalesPriceUpdateUnit == SalesPriceUpdateUnitType.SalesUnit ? INUnitAttribute.ConvertFromBase(Inventory.Cache, ii.InventoryID, ii.SalesUnit, item.SalesPrice ?? 0m, INPrecision.UNITCOST) : item.SalesPrice ?? 0m;
                        decimal lastPrice = PXAccess.FeatureInstalled <FeaturesSet.distributionModule>() && sosetup.Current.SalesPriceUpdateUnit == SalesPriceUpdateUnitType.SalesUnit ? INUnitAttribute.ConvertFromBase(Inventory.Cache, ii.InventoryID, ii.SalesUnit, item.LastPrice ?? 0m, INPrecision.UNITCOST) : item.LastPrice ?? 0m;
                        PXDatabase.Update <InventoryItem>(
                            new PXDataFieldAssign("BasePrice", PXDbType.Decimal, price),
                            new PXDataFieldAssign("BasePriceDate", PXDbType.DateTime, item.LastDate),
                            new PXDataFieldAssign("PendingBasePrice", PXDbType.Decimal, 0m),
                            new PXDataFieldAssign("PendingBasePriceDate", PXDbType.DateTime, null),
                            new PXDataFieldAssign("LastBasePrice", PXDbType.Decimal, lastPrice),
                            new PXDataFieldAssign("LastModifiedDateTime", PXDbType.DateTime, updateTime),
                            new PXDataFieldRestrict("InventoryID", PXDbType.Int, item.InventoryID)
                            );
                    }


                    ts.Complete();
                }
            }
        }
Ejemplo n.º 19
0
    protected void Page_Init(object sender, EventArgs e)
    {
        // remove unum parameter
        PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);

        // make collection editable
        isreadonly.SetValue(this.Request.QueryString, false, null);
        this.Request.QueryString.Remove(PXUrl.UNum);
        isreadonly.SetValue(this.Request.QueryString, true, null);

        this.usrCaption.CustomizationAvailable = false;

        var date = PXContext.GetBusinessDate();

        PX.Common.PXContext.SetBusinessDate((DateTime?)date);

        if ((this.viewer.SchemaUrl = this.Request.QueryString["ID"]) == null)
        {
            this.viewer.SchemaUrl = ReportID;
        }

        if (SiteMap.CurrentNode != null)
        {
            this.Title = PXSiteMap.CurrentNode.Title;
            _screenID  = PXSiteMap.CurrentNode.ScreenID;
        }
        else
        {
            string url;
            if (Request.ApplicationPath != "/")
            {
                url = Request.Path.Replace(Request.ApplicationPath, "~") + "?ID=" + this.viewer.SchemaUrl;
            }
            else if (Request.Path.StartsWith("/"))
            {
                url = "~" + Request.Path;
            }
            else
            {
                url = Request.Path;
            }
            PXSiteMapNode node = SiteMap.Provider.FindSiteMapNode(url) as PXSiteMapNode;
            if (node != null)
            {
                this.Title = node.Title;
                this.usrCaption.ScreenTitle = node.Title;
                this.usrCaption.ScreenID    = PX.Common.Mask.Format(">CC.CC.CC.CC", node.ScreenID);
                _screenID = node.ScreenID;
            }
            else
            {
                using (PXDataRecord record = PXDatabase.SelectSingle <PX.SM.SiteMap>(
                           new PXDataField("ScreenID"),
                           new PXDataFieldValue("Url", PXDbType.VarChar, 512, url)
                           ))
                {
                    if (record != null)
                    {
                        _screenID = record.GetString(0);
                        if (!String.IsNullOrEmpty(_screenID) && !PXAccess.VerifyRights(_screenID))
                        {
                            throw new PXSetPropertyException(ErrorMessages.NotEnoughRights, this.viewer.SchemaUrl);
                        }
                    }
                }
            }
        }
        if (String.IsNullOrEmpty(PX.Common.PXContext.GetScreenID()))
        {
            if (String.IsNullOrEmpty(_screenID) && !String.IsNullOrEmpty(this.viewer.SchemaUrl))
            {
                string schema = this.viewer.SchemaUrl;
                if (schema.EndsWith(".rpx", StringComparison.OrdinalIgnoreCase))
                {
                    schema = schema.Substring(0, schema.Length - 4);
                }
                if (schema.Length == 8)
                {
                    _screenID = schema;
                }
            }
            if (!String.IsNullOrEmpty(_screenID))
            {
                PX.Common.PXContext.SetScreenID(PX.Common.Mask.Format(">CC.CC.CC.CC", _screenID));
            }
        }
        if (_canSendEmail)
        {
            viewer.EmailSend += new PXReportViewer.EmailSendHandler(viewer_EmailSend);
        }
        else
        {
            viewer.AllowSendEmails = false;
        }
    }
Ejemplo n.º 20
0
        protected void ARPayment_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            ARPayment arPaymentRow = (ARPayment)e.Row;

            PXUIFieldAttribute.SetVisible <FSxARPayment.serviceContractID>(cache, arPaymentRow, PXAccess.FeatureInstalled <FeaturesSet.equipmentManagementModule>() == true && arPaymentRow.DocType == ARPaymentType.Prepayment);

            bool atleastoneFSAdjust = FSAdjustments.SelectWindowed(0, 1).Count > 0;

            FSAdjustments.Cache.AllowInsert = !(atleastoneFSAdjust);
            FSAdjustments.Cache.AllowDelete = false;
            FSAdjustments.AllowSelect       = arPaymentRow.CreatedByScreenID == ID.ScreenID.APPOINTMENT ||
                                              arPaymentRow.CreatedByScreenID == ID.ScreenID.SERVICE_ORDER ||
                                              atleastoneFSAdjust;
        }
 public static bool IsActive()
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.avalaraTax>());
 }
 protected void Logout(object sender, EventArgs e)
 {
     try
     {
         PXLogin.LogoutUser(PXAccess.GetUserName(), Session.SessionID);
         PXContext.Session.SetString("UserLogin", string.Empty);
         Session.Abandon();
         PX.Data.Auth.ExternalAuthHelper.SignOut(Context, "~/Frames/Outlook/FirstRun.html");
         PXDatabase.Delete <PX.SM.UserIdentity>(
             new PXDataFieldRestrict <PX.SM.UserIdentity.providerName>(PXDbType.VarChar, "ExchangeIdentityToken"),
             new PXDataFieldRestrict <PX.SM.UserIdentity.userID>(PXDbType.UniqueIdentifier, PXAccess.GetUserID())
             );
     }
     finally
     {
         PX.Data.Redirector.Redirect(System.Web.HttpContext.Current, "~/Frames/Outlook/FirstRun.html");
     }
 }
        protected virtual IEnumerable enqResult()
        {
            AccountByYearFilter filter = CurrentFilter;
            bool showCurrency          = filter.ShowCuryDetail.HasValue && filter.ShowCuryDetail.Value;

            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyID>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdCreditTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdDebitTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyEndBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryEndBalance>(EnqResult.Cache, null, showCurrency);

            if (filter.AccountID == null || filter.LedgerID == null || filter.FinYear == null)
            {
                yield break;                                                                                            //Prevent code from accessing database;
            }
            using (new PXReadBranchRestrictedScope(null, null, restrictByAccessRights: false, requireAccessForAllSpecified: false))
            {
                PXSelectBase <GLHistoryByPeriod> cmd = new PXSelectJoinGroupBy <GLHistoryByPeriod,
                                                                                LeftJoin <Account, On <GLHistoryByPeriod.accountID, Equal <Account.accountID>,
                                                                                                       And <Match <Account, Current <AccessInfo.userName> > > >,
                                                                                          LeftJoin <MasterFinPeriod, On <GLHistoryByPeriod.finPeriodID, Equal <MasterFinPeriod.finPeriodID> >,
                                                                                                    LeftJoin <Sub, On <GLHistoryByPeriod.subID, Equal <Sub.subID>,
                                                                                                                       And <Match <Sub, Current <AccessInfo.userName> > > >,
                                                                                                              LeftJoin <GLHistory, On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                                                                                       And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                                                                            And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                                                                                                 And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                                                                                                      And <GLHistoryByPeriod.finPeriodID, Equal <GLHistory.finPeriodID> > > > > >,
                                                                                                                        LeftJoin <AH, On <GLHistoryByPeriod.ledgerID, Equal <AH.ledgerID>,
                                                                                                                                          And <GLHistoryByPeriod.branchID, Equal <AH.branchID>,
                                                                                                                                               And <GLHistoryByPeriod.accountID, Equal <AH.accountID>,
                                                                                                                                                    And <GLHistoryByPeriod.subID, Equal <AH.subID>,
                                                                                                                                                         And <GLHistoryByPeriod.lastActivityPeriod, Equal <AH.finPeriodID> > > > > > > > > > >,
                                                                                Where <GLHistoryByPeriod.ledgerID, Equal <Current <AccountByYearFilter.ledgerID> >,
                                                                                       And <MasterFinPeriod.finYear, Equal <Current <AccountByYearFilter.finYear> >,
                                                                                            And <GLHistoryByPeriod.accountID, Equal <Current <AccountByYearFilter.accountID> >,
                                                                                                 And <Where2 <
                                                                                                          Where <Account.accountID, NotEqual <Current <GLSetup.ytdNetIncAccountID> >, And <Where <Account.type, Equal <AccountType.asset>,
                                                                                                                                                                                                  Or <Account.type, Equal <AccountType.liability> > > > >,
                                                                                                          Or <Where <GLHistoryByPeriod.lastActivityPeriod, GreaterEqual <Required <GLHistoryByPeriod.lastActivityPeriod> >,
                                                                                                                     And <Where <Account.type, Equal <AccountType.expense>,
                                                                                                                                 Or <Account.type, Equal <AccountType.income>,
                                                                                                                                     Or <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > > > > > > > > > >,
                                                                                Aggregate <
                                                                                    Sum <AH.finYtdBalance,
                                                                                         Sum <AH.tranYtdBalance,
                                                                                              Sum <AH.curyFinYtdBalance,
                                                                                                   Sum <AH.curyTranYtdBalance,
                                                                                                        Sum <GLHistory.finPtdDebit,
                                                                                                             Sum <GLHistory.tranPtdDebit,
                                                                                                                  Sum <GLHistory.finPtdCredit,
                                                                                                                       Sum <GLHistory.tranPtdCredit,
                                                                                                                            Sum <GLHistory.finBegBalance,
                                                                                                                                 Sum <GLHistory.tranBegBalance,
                                                                                                                                      Sum <GLHistory.finYtdBalance,
                                                                                                                                           Sum <GLHistory.tranYtdBalance,
                                                                                                                                                Sum <GLHistory.curyFinBegBalance,
                                                                                                                                                     Sum <GLHistory.curyTranBegBalance,
                                                                                                                                                          Sum <GLHistory.curyFinYtdBalance,
                                                                                                                                                               Sum <GLHistory.curyTranYtdBalance,
                                                                                                                                                                    Sum <GLHistory.curyFinPtdCredit,
                                                                                                                                                                         Sum <GLHistory.curyTranPtdCredit,
                                                                                                                                                                              Sum <GLHistory.curyFinPtdDebit,
                                                                                                                                                                                   Sum <GLHistory.curyTranPtdDebit,
                                                                                                                                                                                        GroupBy <GLHistoryByPeriod.ledgerID,
                                                                                                                                                                                                 GroupBy <GLHistoryByPeriod.accountID,
                                                                                                                                                                                                          GroupBy <GLHistoryByPeriod.finPeriodID> > > > > > > > > > > > > > > > > > > > > > > > >(this);

                if (filter.SubID != null)
                {
                    cmd.WhereAnd <Where <GLHistoryByPeriod.subID, Equal <Current <AccountByYearFilter.subID> > > >();
                }

                int[] branchIDs = null;

                if (filter.BranchID != null)
                {
                    cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, Equal <Current <AccountByYearFilter.branchID> > > >();
                }
                else if (filter.OrganizationID != null)
                {
                    branchIDs = PXAccess.GetChildBranchIDs(filter.OrganizationID, false);

                    cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, In <Required <GLHistoryByPeriod.branchID> >,
                                         And <MatchWithBranch <GLHistoryByPeriod.branchID> > > >();
                }

                if (!SubCDUtils.IsSubCDEmpty(filter.SubCD))
                {
                    cmd.WhereAnd <Where <Sub.subCD, Like <Current <AccountByYearFilter.subCDWildcard> > > >();
                }

                foreach (PXResult <GLHistoryByPeriod, Account, MasterFinPeriod, Sub, GLHistory, AH> it in cmd.Select(filter.BegFinPeriod, branchIDs))
                {
                    GLHistoryByPeriod baseview = it;
                    Account           acct     = it;
                    GLHistory         ah       = it;
                    AH ah1 = it;
                    ah.FinFlag  = filter.UseMasterCalendar != true;
                    ah1.FinFlag = filter.UseMasterCalendar != true;
                    GLHistoryEnquiryResult item = new GLHistoryEnquiryResult
                    {
                        AccountID          = baseview.AccountID,
                        AccountCD          = acct.AccountCD,
                        LedgerID           = baseview.LedgerID,
                        LastActivityPeriod = baseview.FinPeriodID,
                        PtdCreditTotal     = ah.PtdCredit ?? 0m,
                        PtdDebitTotal      = ah.PtdDebit ?? 0m,
                        CuryID             = ah1.CuryID,
                        Type       = acct.Type,
                        EndBalance = ah1.YtdBalance ?? 0m
                    };
                    if (!string.IsNullOrEmpty(ah1.CuryID))
                    {
                        item.CuryEndBalance     = ah1.CuryYtdBalance ?? 0m;
                        item.CuryPtdCreditTotal = ah.CuryPtdCredit ?? 0m;
                        item.CuryPtdDebitTotal  = ah.CuryPtdDebit ?? 0m;
                    }
                    else
                    {
                        item.CuryEndBalance     = null;
                        item.CuryPtdCreditTotal = null;
                        item.CuryPtdDebitTotal  = null;
                    }
                    item.recalculate(true);             // End balance is considered as correct digit - so we need to calculate begBalance base on ending one
                    item.recalculateSignAmount(glsetup.Current?.TrialBalanceSign == GLSetup.trialBalanceSign.Reversed);
                    yield return(item);
                }
            }
        }
        private void UpdateDistributionControls(bool showSection, bool enableEdit, bool isAutoDistribution)
        {
            RRDistribution.Cache.AllowSelect = showSection;

            PXUIFieldAttribute.SetVisible <RUTROT.curyUndistributedAmt>(Rutrots.Cache, null, showSection && isAutoDistribution == false);
            PXUIFieldAttribute.SetVisible <RUTROT.curyDistributedAmt>(Rutrots.Cache, null, showSection && PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.invoiceRounding>() && isAutoDistribution);

            PXUIFieldAttribute.SetEnabled <RUTROTDistribution.curyAmount>(RRDistribution.Cache, null, isAutoDistribution == false);

            RRDistribution.Cache.AllowInsert = enableEdit;
            RRDistribution.Cache.AllowDelete = enableEdit;
            RRDistribution.Cache.AllowUpdate = enableEdit;
        }
Ejemplo n.º 25
0
 public static bool IsActive()
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.serviceManagementModule>());
 }
Ejemplo n.º 26
0
        private void CreateActivity(int classId, Guid?refNoteID, string typeCode, Guid?owner, PXRedirectHelper.WindowMode windowMode = PXRedirectHelper.WindowMode.NewWindow)
        {
            var graphType = CRActivityPrimaryGraphAttribute.GetGraphType(classId);

            if (!PXAccess.VerifyRights(graphType))
            {
                throw new AccessViolationException(CR.Messages.FormNoAccessRightsMessage(graphType));
            }

            CRActivity activity = null;

            var cache = CreateInstanceCache <CRActivity>(graphType);

            if (cache == null)
            {
                return;
            }

            if (owner == null)
            {
                owner = EmployeeMaint.GetCurrentEmployeeID(cache.Graph);
            }

            Action <object> initializeHandler = delegate(object act1)
            {
                var act = act1 as CRActivity;
                if (act == null)
                {
                    return;
                }

                act.ClassID   = classId;
                act.RefNoteID = refNoteID;
                if (!string.IsNullOrEmpty(typeCode))
                {
                    act.Type = typeCode;
                }
                act.OwnerID = owner;
            };

            EntityHelper helper = new EntityHelper(cache.Graph);
            var          type   = helper.GetEntityRowType(refNoteID);
            var          entity = helper.GetEntityRow(type, refNoteID);

            Type entityGraphType = null;

            if (type != null)
            {
                PXPrimaryGraphAttribute.FindPrimaryGraph(cache.Graph.Caches[type], ref entity, out entityGraphType);
            }
            if (entityGraphType != null)
            {
                PXGraph entry = PXGraph.CreateInstance(entityGraphType);
                PXCache <CRActivity> activityCache = entry.Caches[typeof(CRActivity)] as PXCache <CRActivity>;
                if (activityCache != null)
                {
                    entry.Views[entry.PrimaryView].Cache.Current = entity;
                    activity = (CRActivity)activityCache.CreateInstance();
                    if (initializeHandler != null)
                    {
                        initializeHandler(activity);
                    }
                    activity = activityCache.InitNewRow(activity);
                }
            }

            if (activity == null)
            {
                activity = (CRActivity)cache.CreateInstance();

                initializeHandler(activity);

                activity = ((PXCache <CRActivity>)cache).InitNewRow(activity);
            }

            cache.Update(activity);
            PXRedirectHelper.TryRedirect(cache.Graph, windowMode);
        }
Ejemplo n.º 27
0
 public static bool IsActive()
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.matrixItem>());
 }
 public static bool IsActive()
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.gLWorkBooks>());
 }
Ejemplo n.º 29
0
        public virtual IEnumerable LinkLineOrderTran()
        {
            APTran currentAPTran = Base.Transactions.Current;

            if (currentAPTran == null)
            {
                yield break;
            }

            var comparer = new POAccrualComparer();
            HashSet <APTran> usedPOLine   = new HashSet <APTran>(comparer);
            HashSet <APTran> unusedPOLine = new HashSet <APTran>(comparer);

            foreach (APTran aPTran in Base.Transactions.Cache.Inserted)
            {
                if (currentAPTran.InventoryID == aPTran.InventoryID && currentAPTran.UOM == aPTran.UOM)
                {
                    usedPOLine.Add(aPTran);
                }
            }

            foreach (APTran aPTran in Base.Transactions.Cache.Deleted)
            {
                if (currentAPTran.InventoryID == aPTran.InventoryID && currentAPTran.UOM == aPTran.UOM &&
                    Base.Transactions.Cache.GetStatus(aPTran) != PXEntryStatus.InsertedDeleted)
                {
                    if (!usedPOLine.Remove(aPTran))
                    {
                        unusedPOLine.Add(aPTran);
                    }
                }
            }

            foreach (APTran aPTran in Base.Transactions.Cache.Updated)
            {
                if (currentAPTran.InventoryID == aPTran.InventoryID && currentAPTran.UOM == aPTran.UOM)
                {
                    APTran originAPTran = new APTran
                    {
                        POAccrualType      = (string)Base.Transactions.Cache.GetValueOriginal <APTran.pOAccrualType>(aPTran),
                        POAccrualRefNoteID = (Guid?)Base.Transactions.Cache.GetValueOriginal <APTran.pOAccrualRefNoteID>(aPTran),
                        POAccrualLineNbr   = (int?)Base.Transactions.Cache.GetValueOriginal <APTran.pOAccrualLineNbr>(aPTran),
                        POOrderType        = (string)Base.Transactions.Cache.GetValueOriginal <APTran.pOOrderType>(aPTran),
                        PONbr          = (string)Base.Transactions.Cache.GetValueOriginal <APTran.pONbr>(aPTran),
                        POLineNbr      = (int?)Base.Transactions.Cache.GetValueOriginal <APTran.pOLineNbr>(aPTran),
                        ReceiptNbr     = (string)Base.Transactions.Cache.GetValueOriginal <APTran.receiptNbr>(aPTran),
                        ReceiptType    = (string)Base.Transactions.Cache.GetValueOriginal <APTran.receiptType>(aPTran),
                        ReceiptLineNbr = (int?)Base.Transactions.Cache.GetValueOriginal <APTran.receiptLineNbr>(aPTran)
                    };

                    if (!usedPOLine.Remove(originAPTran))
                    {
                        unusedPOLine.Add(originAPTran);
                    }

                    if (!unusedPOLine.Remove(aPTran))
                    {
                        usedPOLine.Add(aPTran);
                    }
                }
            }

            unusedPOLine.Add(currentAPTran);

            PXSelectBase <LinkLineOrder> cmd = new PXSelect <LinkLineOrder,
                                                             Where2 <
                                                                 Where <Current <LinkLineFilter.pOOrderNbr>, Equal <LinkLineOrder.orderNbr>,
                                                                        Or <Current <LinkLineFilter.pOOrderNbr>, IsNull> >,
                                                                 And2 <Where <Current <LinkLineFilter.siteID>, IsNull,
                                                                              Or <LinkLineOrder.orderSiteID, Equal <Current <LinkLineFilter.siteID> > > >,
                                                                       And <LinkLineOrder.inventoryID, Equal <Current <APTran.inventoryID> >,
                                                                            And <LinkLineOrder.uOM, Equal <Current <APTran.uOM> >,
                                                                                 And <LinkLineOrder.orderCuryID, Equal <Current <APInvoice.curyID> > > > > > > >(Base);

            if (Base.APSetup.Current.RequireSingleProjectPerDocument == true)
            {
                cmd.WhereAnd <Where <LinkLineOrder.projectID, Equal <Current <APInvoice.projectID> > > >();
            }

            if (PXAccess.FeatureInstalled <FeaturesSet.vendorRelations>())
            {
                cmd.WhereAnd <Where <LinkLineOrder.vendorID, Equal <Current <APInvoice.suppliedByVendorID> >,
                                     And <LinkLineOrder.vendorLocationID, Equal <Current <APInvoice.suppliedByVendorLocationID> >,
                                          And <LinkLineOrder.payToVendorID, Equal <Current <APInvoice.vendorID> > > > > >();
            }
            else
            {
                cmd.WhereAnd <Where <LinkLineOrder.vendorID, Equal <Current <APInvoice.vendorID> >,
                                     And <LinkLineOrder.vendorLocationID, Equal <Current <APInvoice.vendorLocationID> > > > >();
            }

            foreach (LinkLineOrder item in cmd.Select())
            {
                APTran aPTran = new APTran
                {
                    POAccrualType      = item.POAccrualType,
                    POAccrualRefNoteID = item.OrderNoteID,
                    POAccrualLineNbr   = item.OrderLineNbr,
                    POOrderType        = item.OrderType,
                    PONbr     = item.OrderNbr,
                    POLineNbr = item.OrderLineNbr
                };
                if (!usedPOLine.Contains(aPTran))
                {
                    var res = (PXResult <POLineS, POOrder>)POLineLink.Select(item.OrderNbr, item.OrderType, item.OrderLineNbr);
                    if (linkLineOrderTran.Cache.GetStatus((POLineS)res) != PXEntryStatus.Updated &&
                        ((POLineS)res).CompareReferenceKey(currentAPTran))
                    {
                        linkLineOrderTran.Cache.SetValue <POLineS.selected>((POLineS)res, true);
                        linkLineOrderTran.Cache.SetStatus((POLineS)res, PXEntryStatus.Updated);
                    }
                    yield return(res);
                }
            }

            foreach (APTran item in unusedPOLine.Where(t => t.POAccrualType == POAccrualType.Order))
            {
                var res = (PXResult <POLineS, POOrder>)POLineLink.Select(item.PONbr, item.POOrderType, item.POLineNbr);
                if (linkLineOrderTran.Cache.GetStatus((POLineS)res) != PXEntryStatus.Updated &&
                    ((POLineS)res).CompareReferenceKey(currentAPTran))
                {
                    linkLineOrderTran.Cache.SetValue <POLineS.selected>((POLineS)res, true);
                    linkLineOrderTran.Cache.SetStatus((POLineS)res, PXEntryStatus.Updated);
                }
                if (currentAPTran.InventoryID == ((POLineS)res).InventoryID)
                {
                    yield return(res);
                }
            }
        }
Ejemplo n.º 30
0
 protected bool IsTaxTranCreationAllowed(Batch batch)
 {
     return(PXAccess.FeatureInstalled <FeaturesSet.taxEntryFromGL>() &&
            batch != null &&
            batch.Module == BatchModule.GL);
 }