project QadFinancials > class BDebtor > method ValSalesAccountGLProfile

validation procedure

Description

Validates sales Account GL Profile


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDebtor.PostValidateComponent


program code (program1/bdebtor.p)

/*error: Profile must exist - checked by FC*/
/*error: Profile must be of certain type*/
if t_sDebtor.SalesAccountGLProfile_ID <> 0 and 
   t_sDebtor.SalesAccountGLProfile_ID <> ? and 
   (t_sDebtor.tc_Status = "N":U or 
    (t_sDebtor.tc_Status = "C" and 
     can-find (t_iDebtor where 
               t_iDebtor.tc_Rowid                  = t_sDebtor.tc_Rowid and 
               t_iDebtor.SalesAccountGLProfile_ID <> t_sDebtor.SalesAccountGLProfile_ID )))
then do:
    <Q-1 run ProfileById (all) (Read) (Cache)
       (input t_sDebtor.SalesAccountGLProfile_ID, (Profile_ID)
        output dataset tqProfileById) in BProfile>

    find first tqProfileById no-error.
    /*error: not available tqProfileById should be checked by FC*/
    /*error: if > 0 then it must be an existing profile of type = "BankAccount"*/
    if available tqProfileById and
       tqProfileById.tcProfileTypeCode <> {&PROFILETYPECODE-SALESACCOUNT}
    then do:
        assign vcMessage     = trim(substitute(#T-4'The Sales Account profile &1 is not of type &2 for the customer &3.':200(31297)t-4#, 
                                                trim(tqProfileById.tcProfileCode),
                                                trim({&PROFILETYPECODE-SALESACCOUNT-TR}), 
                                                trim(t_sDebtor.DebtorCode))) + chr(10) +
                               program-name(1)
              oiReturnStatus = -1.
        <M-2 run SetMessage (input  vcMessage (icMessage), 
                     input  '':U (icArguments), 
                     input  'tDebtor.tcSalesAccountGLProfileCode':U (icFieldName), 
                     input  t_sDebtor.tcSalesAccountGLProfileCode (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  t_sDebtor.tc_Rowid (icRowid), 
                     input  'QADFIN-321':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BDebtor>       
    end.    
    /*error: if > 0 and exists then should be active*/
    if available tqProfileById and
       tqProfileById.tcProfileTypeCode = {&PROFILETYPECODE-SALESACCOUNT} and
       not tqProfileById.tlProfileIsActive
    then do:
        assign vcMessage     = trim(substitute(#T-5'The Sales Account profile &1 is not active for the customer &2.':200(31298)t-5#, 
                                                trim(tqProfileById.tcProfileCode),
                                                trim(t_sDebtor.DebtorCode))) + chr(10) + 
                               program-name(1)
              oiReturnStatus = -1.
        <M-3 run SetMessage (input  vcMessage (icMessage), 
                     input  '':U (icArguments), 
                     input  'tDebtor.tcSalesAccountGLProfileCode':U (icFieldName), 
                     input  t_sDebtor.tcSalesAccountGLProfileCode (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  t_sDebtor.tc_Rowid (icRowid), 
                     input  'QADFIN-322':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BDebtor>
    end.   
end.