private void SetProcessDelegate() { BalanceFilter filter = Filter.Current; bool depriciate = filter.Action == BalanceFilter.action.Depreciate; Balances.SetProcessDelegate(delegate(List <FABookBalance> list) { if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Length > 1) { throw new PXException(Messages.AnotherDeprRunning); } List <FABookBalance> balances = GetProcessableRecords(list); if (depriciate) { AssetProcess.DepreciateAsset(balances, null, filter.PeriodID, true); } else { AssetProcess.CalculateAsset(balances, filter.PeriodID); } }); bool canDepreciate = !string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true; PXUIFieldAttribute.SetEnabled <BalanceFilter.action>(Filter.Cache, filter, canDepreciate); if (!canDepreciate) { filter.Action = BalanceFilter.action.Calculate; } }
protected virtual IEnumerable balances() { BalanceFilter filter = Filter.Current; PXView view = new Select2 <FABookBalance, InnerJoin <FixedAsset, On <FixedAsset.assetID, Equal <FABookBalance.assetID> >, InnerJoin <FADetails, On <FADetails.assetID, Equal <FABookBalance.assetID> >, LeftJoin <Account, On <Account.accountID, Equal <FixedAsset.fAAccountID> > > > >, Where <FABookBalance.depreciate, Equal <True>, And <FABookBalance.status, Equal <FixedAssetStatus.active>, And <FADetails.status, Equal <FixedAssetStatus.active> > > > >() .CreateView(this, mergeCache: PXView.MaximumRows > 1); if (filter.BookID != null) { view.WhereAnd <Where <FABookBalance.bookID, Equal <Current <BalanceFilter.bookID> > > >(); } if (filter.ClassID != null) { view.WhereAnd <Where <FixedAsset.classID, Equal <Current <BalanceFilter.classID> > > >(); } if (PXAccess.FeatureInstalled <FeaturesSet.multipleCalendarsSupport>() || filter.OrgBAccountID != null) { view.WhereAnd <Where <FixedAsset.branchID, Inside <Current <BalanceFilter.orgBAccountID> > > >(); } if (!string.IsNullOrEmpty(filter.PeriodID)) { view.WhereAnd <Where <FABookBalance.currDeprPeriod, LessEqual <Current <BalanceFilter.periodID> > > >(); } if (filter.ParentAssetID != null) { view.WhereAnd <Where <FixedAsset.parentAssetID, Equal <Current <BalanceFilter.parentAssetID> > > >(); } int startRow = PXView.StartRow; int totalRows = 0; List <PXFilterRow> newFilters = new List <PXFilterRow>(); foreach (PXFilterRow f in PXView.Filters) { if (f.DataField.ToLower() == "status") { f.DataField = "FADetails__Status"; } newFilters.Add(f); } List <object> list = view.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows); PXView.StartRow = 0; return(list); }
protected virtual void BalanceFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { if (e.Row != null) { BalanceFilter filter = Filter.Current; if (Depreciate) { Balances.SetProcessDelegate(delegate(List <FABookBalance> list) { if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Count() > 1) { throw new PXException(Messages.AnotherDeprRunning); } AssetProcess.DepreciateAsset(list, null, filter.PeriodID, true); }); } else { Balances.SetProcessDelegate(delegate(List <FABookBalance> list) { if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Count() > 1) { throw new PXException(Messages.AnotherDeprRunning); } AssetProcess.CalculateAsset(list, filter.PeriodID); }); } Balances.SetProcessVisible(false); Balances.SetProcessAllVisible(false); PXButtonState pstate = Actions["Process"].GetState(e.Row) as PXButtonState; PXButtonState pastate = Actions["ProcessAll"].GetState(e.Row) as PXButtonState; bool penabled = pstate == null || pstate.Enabled; bool paenabled = pastate == null || pastate.Enabled; Calculate.SetEnabled(penabled); CalculateAll.SetEnabled(paenabled); CalcDepr.SetEnabled(!string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true && penabled); CalcDeprAll.SetEnabled(!string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true && paenabled); } }
protected virtual IEnumerable balances() { BalanceFilter filter = Filter.Current; PXSelectBase <FABookBalance> cmd; //PXFilteredProcessing sets IsDirty = false when processing all records and all records are placed in cache, //until _Header refresh we will return readonly result, after it _InProc will be returned bypassing this delegate //if (false) //{ // cmd = new PXSelectReadonly2<FABookBalance, // InnerJoin<FixedAsset, On<FixedAsset.assetID, Equal<FABookBalance.assetID>>, // InnerJoin<FADetails, On<FADetails.assetID, Equal<FABookBalance.assetID>>>>, // Where<FABookBalance.depreciate, Equal<True>, And<FABookBalance.status, Equal<FixedAssetStatus.active>, And<FADetails.status, Equal<FixedAssetStatus.active>>>>>(this); //} //else { cmd = new PXSelectJoin <FABookBalance, InnerJoin <FixedAsset, On <FixedAsset.assetID, Equal <FABookBalance.assetID> >, InnerJoin <FADetails, On <FADetails.assetID, Equal <FABookBalance.assetID> > > >, Where <FABookBalance.depreciate, Equal <True>, And <FABookBalance.status, Equal <FixedAssetStatus.active>, And <FADetails.status, Equal <FixedAssetStatus.active> > > > >(this); } if (filter.BookID != null) { cmd.WhereAnd <Where <FABookBalance.bookID, Equal <Current <BalanceFilter.bookID> > > >(); } if (filter.ClassID != null) { cmd.WhereAnd <Where <FixedAsset.classID, Equal <Current <BalanceFilter.classID> > > >(); } if (filter.BranchID != null) { cmd.Join <LeftJoin <FALocationHistory, On <FALocationHistory.revisionID, Equal <FADetails.locationRevID>, And <FALocationHistory.assetID, Equal <FADetails.assetID> > > > >(); cmd.WhereAnd <Where <FALocationHistory.locationID, Equal <Current <BalanceFilter.branchID> > > >(); } if (!string.IsNullOrEmpty(filter.PeriodID)) { cmd.WhereAnd <Where <FABookBalance.currDeprPeriod, LessEqual <Current <BalanceFilter.periodID> > > >(); } if (filter.ParentAssetID != null) { cmd.WhereAnd <Where <FixedAsset.parentAssetID, Equal <Current <BalanceFilter.parentAssetID> > > >(); } int startRow = PXView.StartRow; int totalRows = 0; List <PXFilterRow> newFilters = new List <PXFilterRow>(); foreach (PXFilterRow f in PXView.Filters) { if (f.DataField.ToLower() == "status") { f.DataField = "FADetails__Status"; } newFilters.Add(f); } List <object> list = cmd.View.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows); PXView.StartRow = 0; return(list); }
protected virtual IEnumerable balances() { BalanceFilter filter = Filter.Current; PXSelectBase <FABookBalance> cmd; if (PXView.MaximumRows == 1) // SyncPosition call on PXGrid { cmd = new PXSelectReadonly2 <FABookBalance, InnerJoin <FixedAsset, On <FixedAsset.assetID, Equal <FABookBalance.assetID> >, InnerJoin <FADetails, On <FADetails.assetID, Equal <FABookBalance.assetID> >, LeftJoin <Account, On <Account.accountID, Equal <FixedAsset.fAAccountID> > > > >, Where <FABookBalance.depreciate, Equal <True>, And <FABookBalance.status, Equal <FixedAssetStatus.active>, And <FADetails.status, Equal <FixedAssetStatus.active> > > > >(this); } else { cmd = new PXSelectJoin <FABookBalance, InnerJoin <FixedAsset, On <FixedAsset.assetID, Equal <FABookBalance.assetID> >, InnerJoin <FADetails, On <FADetails.assetID, Equal <FABookBalance.assetID> >, LeftJoin <Account, On <Account.accountID, Equal <FixedAsset.fAAccountID> > > > >, Where <FABookBalance.depreciate, Equal <True>, And <FABookBalance.status, Equal <FixedAssetStatus.active>, And <FADetails.status, Equal <FixedAssetStatus.active> > > > >(this); } if (filter.BookID != null) { cmd.WhereAnd <Where <FABookBalance.bookID, Equal <Current <ProcessAssetFilter.bookID> > > >(); } if (filter.ClassID != null) { cmd.WhereAnd <Where <FixedAsset.classID, Equal <Current <ProcessAssetFilter.classID> > > >(); } if (filter.BranchID != null) { cmd.Join <LeftJoin <FALocationHistory, On <FALocationHistory.revisionID, Equal <FADetails.locationRevID>, And <FALocationHistory.assetID, Equal <FADetails.assetID> > > > >(); cmd.WhereAnd <Where <FALocationHistory.locationID, Equal <Current <ProcessAssetFilter.branchID> > > >(); } if (!string.IsNullOrEmpty(filter.PeriodID)) { cmd.WhereAnd <Where <FABookBalance.currDeprPeriod, LessEqual <Current <BalanceFilter.periodID> > > >(); } if (filter.ParentAssetID != null) { cmd.WhereAnd <Where <FixedAsset.parentAssetID, Equal <Current <ProcessAssetFilter.parentAssetID> > > >(); } int startRow = PXView.StartRow; int totalRows = 0; List <PXFilterRow> newFilters = new List <PXFilterRow>(); foreach (PXFilterRow f in PXView.Filters) { if (f.DataField.ToLower() == "status") { f.DataField = "FADetails__Status"; } newFilters.Add(f); } List <object> list = cmd.View.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows); PXView.StartRow = 0; return(list); }