public virtual IEnumerable Recalculate(PXAdapter adapter) { DRSchedule schedule = Base.DocumentProperties.Current; if (schedule.IsOverridden == true) { WebDialogResult result = Base.DocumentProperties.View.Ask( Base.DocumentProperties.Current, GL.Messages.Confirmation, Messages.ClearOverriden, MessageButtons.YesNo, MessageIcon.Question); if (result != WebDialogResult.Yes) { return(adapter.Get()); } } schedule.IsOverridden = false; schedule.IsRecalculated = false; Base.DocumentProperties.Update(schedule); SingleScheduleCreator.RecalculateSchedule(Base); return(adapter.Get()); }
protected virtual void _(Events.FieldUpdated <DRSchedule, DRSchedule.isOverridden> e) { if (e.Row == null) { return; } if ((e.ExternalCall || e.Cache.Graph.IsImport) && e.Row.IsOverridden == false && (bool)e.OldValue == true && e.Row.DocType != null && e.Row.RefNbr != null) { SingleScheduleCreator.RecalculateSchedule(Base); } if ((e.ExternalCall || e.Cache.Graph.IsImport) && e.Row.IsOverridden == true && (bool)e.OldValue == false && e.Row.DocType != null && e.Row.RefNbr != null) { var copyRow = (DRSchedule)e.Cache.CreateCopy(e.Row); copyRow.IsRecalculated = false; e.Cache.Update(copyRow); } Base.ReallocationPool.View.RequestRefresh(); }
private void CreateSingleSchedule <T>(T originalDocument, Amount lineTotal, int?DefScheduleID, bool isDraft, DRScheduleParameters scheduleParameters) where T : ARRegister { ARSetup arSetup = PXSelect <ARSetup> .Select(this); DRSchedule existingSchedule = PXSelect < DRSchedule, Where < DRSchedule.module, Equal <BatchModule.moduleAR>, And <DRSchedule.docType, Equal <Required <ARRegister.docType> >, And <DRSchedule.refNbr, Equal <Required <ARRegister.refNbr> > > > > > .SelectSingleBound(this, null, originalDocument.DocType, originalDocument.RefNbr, 1); if (existingSchedule?.LineNbr != null) { throw new PXException(Messages.CantCompleteBecauseASC606FeatureIsEnabled); } if (DefScheduleID == null) { Location location = PXSelect <Location, Where <Location.locationID, Equal <Required <DRSchedule.bAccountLocID> > > > .SelectSingleBound(this, null, scheduleParameters.BAccountLocID); CurrencyInfo currencyInfo = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <DRSchedule.curyInfoID> > > > .SelectSingleBound(this, null, scheduleParameters.CuryInfoID); SingleScheduleCreator scheduleCreator = new SingleScheduleCreator( this, new ARSubaccountProvider(this), this, this, this, this, this, FinPeriodRepository, roundingFunction: x => PXDBCurrencyAttribute.Round(Schedule.Cache, Schedule.Current, x, CMPrecision.TRANCURY), branchID: originalDocument.BranchID, isDraft: isDraft, location: location, currencyInfo: currencyInfo); if (existingSchedule == null) { scheduleCreator.CreateOriginalSchedule( scheduleParameters, lineTotal); } else { scheduleCreator.ReevaluateSchedule( existingSchedule, scheduleParameters, lineTotal, attachedToOriginalSchedule: false); } } else { if (originalDocument.DocType == ARDocType.CreditMemo || originalDocument.DocType == ARDocType.DebitMemo) { bool accountForPostedTransactions = originalDocument.DocType == ARDocType.CreditMemo; if (existingSchedule == null) { CreateRelatedSingleSchedule(scheduleParameters, DefScheduleID, lineTotal, isDraft, accountForPostedTransactions); } else { Location location = PXSelect <Location, Where <Location.locationID, Equal <Required <DRSchedule.bAccountLocID> > > > .SelectSingleBound(this, null, scheduleParameters.BAccountLocID); CurrencyInfo currencyInfo = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <DRSchedule.curyInfoID> > > > .SelectSingleBound(this, null, scheduleParameters.CuryInfoID); var scheduleCreator = new SingleScheduleCreator( this, new ARSubaccountProvider(this), this, this, this, this, this, FinPeriodRepository, roundingFunction: x => PXCurrencyAttribute.BaseRound(this, x), branchID: originalDocument.BranchID, isDraft: !accountForPostedTransactions, location: location, currencyInfo: currencyInfo); scheduleCreator.ReevaluateSchedule( existingSchedule, scheduleParameters, lineTotal, attachedToOriginalSchedule: true); } } } }