override employee time card release method

Viewed 30

Hello friends I need help: Here I specify what I am doing:

1.- I am overriding the release method of Employee Timecard, do a validation to get the project's default branch code, and then insert it into the project's transaction screen.

public class TimeCardMaint_Extension : PXGraphExtension<TimeCardMaint>
{
    #region Event Handlers
    public delegate IEnumerable ReleaseDelegate(PXAdapter a);
    [PXOverride]
    public IEnumerable Release(PXAdapter adapter, ReleaseDelegate InvokeBase)
    {
        PXGraph.InstanceCreated.AddHandler<RegisterEntry>((graph) =>
        {
            graph.RowInserted.AddHandler<PMTran>((sender, e) =>
            {

                EPTimecardDetail detail = PXResult<EPTimecardDetail>.Current;
                if (detail != null)
                {
                    var tran = (PMTran)e.Row;
                    PMProject project = PXSelect<PMProject,
                      Where<PMProject.contractID, Equal<Required<PMProject.contractID>>>>.Select(Base, detail.ProjectID);
                    if (project != null)
                    {
                        tran.BranchID = project.DefaultBranchID;
                    }
                }
            });
        });
        return InvokeBase(adapter);
    }
    #endregion
}

enter image description here

Here we see the Transactions screen of the project, make the correct change.

So far everything perfect: enter image description here

However, if I check the Journal Transactions screen, it has generated two new entries, it should really only generate a single journal entry as it does by default in acumatica.

enter image description here

Due to these consequences, it is because I have modified the employee's time card, in the release method, I don't know what is happening:

I need you to tell me what I should do or what I am doing wrong, really I only have to modify the Project Transactions screen and the others should not affect I hope I have been clear..

0 Answers
Related