Hi Team
We have a requirement where on payment save we have to programmatically open the financial periods, if closed. I have tried to Implement logic in ARPaymentEntry graph on Save but it is not working as expected, can you help please to achieve this.
public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate del)
{
if (Base.Document.Current != null/* && Base.IsImport == true*/)
{
FinPeriodStatusProcess finPeriodStatusProcess = PXGraph.CreateInstance<FinPeriodStatusProcess>();
finPeriodStatusProcess.Filter.Current.Action = FinPeriodStatusProcessParameters.action.Open;
finPeriodStatusProcess.Filter.Current.FromYear = "2024";
finPeriodStatusProcess.Filter.Current.ToYear = "2024";
string month = "202404";
string year = "2024";
FinPeriod masterFinPeriod = PXSelect<FinPeriod, Where<FinPeriod.finPeriodID, Equal<Required<FinPeriod.finPeriodID>>,
And<FinPeriod.finYear, Equal<Required<FinPeriod.finYear>>>>>.Select(Base, month, year);
finPeriodStatusProcess.FinPeriods.Current = masterFinPeriod;
masterFinPeriod.Selected = true;
// masterFinPeriod.Closed = true;
masterFinPeriod.Status = "Open";
finPeriodStatusProcess.FinPeriods.Update(masterFinPeriod);
finPeriodStatusProcess.Actions["Process"].Press();
}
del();
}
Thank you In Advance.