protected virtual void FixedAsset_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { FixedAsset asset = (FixedAsset)e.Row; if (asset == null) { return; } FADetails det = PXSelect <FADetails, Where <FADetails.assetID, Equal <Current <FixedAsset.assetID> > > > .SelectSingleBound(this, new object[] { asset }); try { AssetProcess.ThrowDisabled_Transfer(this, asset, det); } catch (PXException exc) { PXUIFieldAttribute.SetEnabled <FixedAsset.selected>(sender, asset, false); sender.RaiseExceptionHandling <FixedAsset.selected>(asset, null, new PXSetPropertyException(exc.MessageNoNumber, PXErrorLevel.RowWarning)); } if (string.IsNullOrEmpty(det.TransferPeriod)) { PXUIFieldAttribute.SetEnabled <FixedAsset.selected>(sender, asset, false); sender.RaiseExceptionHandling <FADetails.transferPeriod>(asset, null, new PXSetPropertyException(Messages.NextPeriodNotGenerated)); } }
protected virtual void FATran_RowDeleted(PXCache sender, PXRowDeletedEventArgs e) { FATran tran = e.Row as FATran; if (tran != null && tran.TranType == FATran.tranType.TransferPurchasing && tran.Released != true) { SetCurrentAsset(tran); FixedAsset asset = PXCache <FixedAsset> .CreateCopy(Asset.Current); FADetails details = PXCache <FADetails> .CreateCopy(assetdetails.Current); FALocationHistory lastLocation = locationHistory.SelectSingle(tran.AssetID); locationHistory.Delete(lastLocation); FALocationHistory restoringLocation = locationHistory.SelectSingle(tran.AssetID); if (restoringLocation == null) { throw new PXException(Messages.PrevLocationRevisionNotFound, asset.AssetID); } details.LocationRevID = restoringLocation.RevisionID; assetdetails.Update(details); asset.BranchID = restoringLocation.BranchID ?? asset.BranchID; asset.FASubID = restoringLocation.FASubID ?? asset.FASubID; asset.AccumulatedDepreciationSubID = restoringLocation.AccumulatedDepreciationSubID ?? asset.AccumulatedDepreciationSubID; asset.DepreciatedExpenseSubID = restoringLocation.DepreciatedExpenseSubID ?? asset.DepreciatedExpenseSubID; asset.DisposalSubID = restoringLocation.DisposalSubID ?? asset.DisposalSubID; asset.GainSubID = restoringLocation.GainSubID ?? asset.GainSubID; asset.LossSubID = restoringLocation.LossSubID ?? asset.LossSubID; Asset.Update(asset); } }
protected virtual void FixedAsset_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { FixedAsset asset = (FixedAsset)e.Row; // AssetID can be <0 when the datasource inserts a temporary record on redirect from selector if (asset == null || asset.AssetID < 0) { return; } FADetails assetdet = PXSelect <FADetails, Where <FADetails.assetID, Equal <Required <FADetails.assetID> > > > .Select(this, asset.AssetID); try { AssetProcess.ThrowDisabled_Dispose(this, asset, assetdet, fasetup.Current, (DateTime)Filter.Current.DisposalDate, Filter.Current.DisposalPeriodID, Filter.Current.DeprBeforeDisposal == true); } catch (PXException exc) { PXUIFieldAttribute.SetEnabled <FixedAsset.selected>(sender, asset, false); sender.RaiseExceptionHandling <FixedAsset.selected>(asset, null, new PXSetPropertyException(exc.MessageNoNumber, PXErrorLevel.RowWarning)); } if (Filter.Current.DisposalAmtMode == DisposalFilter.disposalAmtMode.Manual && asset.Selected == true && asset.DisposalAmt == null) { sender.RaiseExceptionHandling <FixedAsset.disposalAmt>(asset, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName <FixedAsset.disposalAmt>(sender))); } }
public virtual IEnumerable amts(PXAdapter adapter) { AccBalanceByAssetFilter filter = Filter.Current; if (filter == null) { yield break; } PXSelectBase <FATran> select = new PXSelectJoin <FATran, InnerJoin <FixedAsset, On <FixedAsset.assetID, Equal <FATran.assetID>, And <FixedAsset.recordType, Equal <FARecordType.assetType> > >, InnerJoin <FADetails, On <FADetails.assetID, Equal <FixedAsset.assetID> >, InnerJoin <Branch, On <FixedAsset.branchID, Equal <Branch.branchID> >, InnerJoin <FALocationHistoryCurrent, On <FALocationHistoryCurrent.assetID, Equal <FixedAsset.assetID> >, InnerJoin <FALocationHistory, On <FALocationHistory.assetID, Equal <FixedAsset.assetID>, And <FALocationHistory.periodID, Equal <FALocationHistoryCurrent.lastPeriodID>, And <FALocationHistory.revisionID, Equal <FALocationHistoryCurrent.lastRevisionID> > > > > > > > >, Where <FATran.released, Equal <True>, And <FATran.finPeriodID, LessEqual <Current <AccBalanceByAssetFilter.periodID> >, And <FATran.bookID, Equal <Current <AccBalanceByAssetFilter.bookID> >, And2 <Where <FALocationHistory.fAAccountID, Equal <Current <AccBalanceByAssetFilter.accountID> >, And <FALocationHistory.fASubID, Equal <Current <AccBalanceByAssetFilter.subID> >, Or <FALocationHistory.accumulatedDepreciationAccountID, Equal <Current <AccBalanceByAssetFilter.accountID> >, And <FALocationHistory.accumulatedDepreciationSubID, Equal <Current <AccBalanceByAssetFilter.subID> > > > > >, And <Where <FATran.debitAccountID, Equal <Current <AccBalanceByAssetFilter.accountID> >, And <FATran.debitSubID, Equal <Current <AccBalanceByAssetFilter.subID> >, Or <FATran.creditAccountID, Equal <Current <AccBalanceByAssetFilter.accountID> >, And <FATran.creditSubID, Equal <Current <AccBalanceByAssetFilter.subID> > > > > > > > > > > >(this); if (PXAccess.FeatureInstalled <FeaturesSet.multipleCalendarsSupport>() || filter.OrganizationID != null) { select.WhereAnd <Where <Branch.organizationID, Equal <Current <AccBalanceByAssetFilter.organizationID> >, And <MatchWithBranch <Branch.branchID> > > >(); } if (filter.BranchID != null) { select.WhereAnd <Where <Branch.branchID, Equal <Current <AccBalanceByAssetFilter.branchID> > > >(); } Dictionary <int?, Amounts> dict = new Dictionary <int?, Amounts>(); foreach (PXResult <FATran, FixedAsset, FADetails, Branch, FALocationHistoryCurrent, FALocationHistory> res in select.Select()) { FATran tran = (FATran)res; FixedAsset asset = (FixedAsset)res; FADetails details = (FADetails)res; FALocationHistory location = (FALocationHistory)res; Amounts record = null; if (!dict.TryGetValue(asset.AssetID, out record)) { record = new Amounts { AssetID = asset.AssetID, Description = asset.Description, Status = details.Status, ClassID = asset.ClassID, DepreciateFromDate = details.DepreciateFromDate, BranchID = location.BranchID, Department = location.Department, ItdAmt = decimal.Zero, YtdAmt = decimal.Zero, PtdAmt = decimal.Zero }; } decimal tranAmt = tran.TranAmt ?? decimal.Zero; decimal amount = tran.DebitAccountID == tran.CreditAccountID && tran.DebitSubID == tran.CreditSubID ? decimal.Zero : tran.DebitAccountID == filter.AccountID && tran.DebitSubID == filter.SubID ? tranAmt : -tranAmt; record.ItdAmt += amount; record.YtdAmt += (FinPeriodUtils.FinPeriodEqual(filter.PeriodID, tran.FinPeriodID, FinPeriodUtils.FinPeriodComparison.Year) ? amount : decimal.Zero); record.PtdAmt += (filter.PeriodID == tran.FinPeriodID ? amount : decimal.Zero); dict[asset.AssetID] = record; } foreach (Amounts amt in dict.Values) { if (amt.ItdAmt != decimal.Zero || amt.YtdAmt != decimal.Zero || amt.PtdAmt != decimal.Zero) { yield return(amt); } } }
protected virtual void DoTransfer(TransferFilter filter, List <FixedAsset> list) { DocumentList <FARegister> created = new DocumentList <FARegister>(this); foreach (FixedAsset asset in list) { FADetails det = PXSelect <FADetails, Where <FADetails.assetID, Equal <Current <FixedAsset.assetID> > > > .SelectSingleBound(this, new object[] { asset }); FALocationHistory location = PXSelect <FALocationHistory, Where <FALocationHistory.assetID, Equal <Current <FADetails.assetID> >, And <FALocationHistory.revisionID, Equal <Current <FADetails.locationRevID> > > > > .SelectSingleBound(this, new object[] { det }); int? destClassID = filter.ClassTo ?? asset.ClassID; int? destBranchID = filter.BranchTo ?? location.LocationID; string destDeptID = string.IsNullOrEmpty(filter.DepartmentTo) ? location.Department : filter.DepartmentTo; if (location.LocationID != destBranchID || location.Department != destDeptID || asset.ClassID != destClassID) { FADetails copy_det = (FADetails)Details.Cache.CreateCopy(det); FALocationHistory copy_loc = (FALocationHistory)Lochist.Cache.CreateCopy(location); copy_loc.RevisionID = ++copy_det.LocationRevID; copy_loc.LocationID = destBranchID; copy_loc.Department = destDeptID; copy_loc.PeriodID = filter.PeriodID; copy_loc.TransactionDate = filter.TransferDate; copy_loc.Reason = filter.Reason; TransactionEntry.SegregateRegister(this, (int)destBranchID, FARegister.origin.Transfer, null, filter.TransferDate, "", created); Details.Update(copy_det); location = Lochist.Insert(copy_loc); if (asset.ClassID != destClassID) { asset.ClassID = destClassID; AssetSelect.Cache.Update(asset); } FARegister reg = Register.Current; AssetProcess.TransferAsset(this, asset, location, ref reg); } } if (Register.Current != null && created.Find(Register.Current) == null) { created.Add(Register.Current); } Actions.PressSave(); if (fasetup.Current.AutoReleaseTransfer == true) { SelectTimeStamp(); PXLongOperation.StartOperation(this, delegate { AssetTranRelease.ReleaseDoc(created, false); }); } else if (created.Count > 0) { AssetTranRelease graph = CreateInstance <AssetTranRelease>(); AssetTranRelease.ReleaseFilter fltr = (AssetTranRelease.ReleaseFilter)graph.Filter.Cache.CreateCopy(graph.Filter.Current); fltr.Origin = FARegister.origin.Transfer; graph.Filter.Update(fltr); graph.SelectTimeStamp(); Dictionary <string, string> parameters = new Dictionary <string, string>(); for (int i = 0; i < created.Count; ++i) { FARegister reg = created[i]; reg.Selected = true; graph.FADocumentList.Update(reg); graph.FADocumentList.Cache.SetStatus(reg, PXEntryStatus.Updated); graph.FADocumentList.Cache.IsDirty = false; parameters["FARegister.RefNbr" + i] = reg.RefNbr; } parameters["PeriodFrom"] = FinPeriodIDFormattingAttribute.FormatForDisplay(filter.PeriodID); parameters["PeriodTo"] = FinPeriodIDFormattingAttribute.FormatForDisplay(filter.PeriodID); parameters["Mode"] = "U"; PXReportRequiredException reportex = new PXReportRequiredException(parameters, "FA642000", "Preview"); throw new PXRedirectWithReportException(graph, reportex, "Release FA Transaction"); } }