project QadFinancials > class BEmployee > method PreValidateComponent

Description

This method is run before the standard ValidateComponent.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BEmployee.ValidateComponent


program code (program1/bemployee.p)

/* PreValidates all New and Changed Employees */
for each t_sEmployee where
         t_sEmployee.tc_Status = 'N':U or
         t_sEmployee.tc_Status = 'C':U:
    if  (t_sEmployee.EmployeeCode <> ?  and
         t_sEmployee.EmployeeCode <> "":U)
    then assign t_sEmployee.EmployeeCode = trim(t_sEmployee.EmployeeCode).

    if t_sEmployee.tc_Status = 'N':U
    then do:
        /* Check for an automatic number for employee */
        if t_sEmployee.EmployeeCode = '':U or
           t_sEmployee.EmployeeCode = ?
        then do:
            assign vhFcComponent = ?.
            <M-7 run GetAutoNumber
               (input  t_sEmployee.tc_Rowid (icRowid), 
                output t_sEmployee.EmployeeCode (ocEmployeeCode), 
                output viFcReturnSuper (oiReturnStatus)) in BEmployee>
            if viFcReturnSuper <> 0
            then assign oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then return.
        end.
    end.

    if t_sEmployee.EmployeeIsActive          = ? then assign t_sEmployee.EmployeeIsActive          = false.
    if t_sEmployee.EmployeeIsActiveExpNotes  = ? then assign t_sEmployee.EmployeeIsActiveExpNotes  = false.
    if t_sEmployee.EmployeeIsActiveTimeReg   = ? then assign t_sEmployee.EmployeeIsActiveTimeReg   = false.
    if t_sEmployee.EmployeeIsExternal        = ? then assign t_sEmployee.EmployeeIsExternal        = false.
    if t_sEmployee.EmployeeIsUser            = ? then assign t_sEmployee.EmployeeIsUser            = false.

    /* Added validations for project and department codes */
    <M-1 run ValDepartmentCode (output viFcReturnSuper (oiReturnStatus)) in BEmployee>
    assign oiReturnStatus = if (oiReturnStatus  > 0 and viFcReturnSuper = 0) or oiReturnStatus  < 0
        then oiReturnStatus
        else viFcReturnSuper.
    <M-2 run ValProjectCode (output viFcReturnSuper (oiReturnStatus)) in BEmployee>
    assign oiReturnStatus = if (oiReturnStatus  > 0 and viFcReturnSuper = 0) or oiReturnStatus  < 0
        then oiReturnStatus
        else viFcReturnSuper.

    /* Validate that the employee code is unique for each domain */
    <Q-3 assign vlFcQueryRecordsAvailable = EmployeeForDomain (NoCache)
       (input 0, (CompanyId)
        input t_sEmployee.EmployeeCode, (EmployeeCode)
        input t_sEmployee.tc_Rowid, (SkipRowid)
        input viDomainID, (DomainId)) in BEmployee >
    if vlFcQueryRecordsAvailable <> false
    then do:
        assign vcMessage      = trim(substitute(#T-4'The employee code &1 already exists in this domain.':100(63804)T-4#, trim(t_sEmployee.EmployeeCode) ))
               oiReturnStatus = -1.
        <M-5 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tEmployee.EmployeeCode':U (icFieldName), 
            input  t_sEmployee.EmployeeCode (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sEmployee.tc_Rowid (icRowid), 
            input  'QadFin-6584':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BEmployee>
    end.
end.