project QadFinancials > class BDebtor > method ValCnControlGLProfile

Description

Validates Debtor Control Account for Credit Notes.
Note: work with t_s tables here


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*/
/*error: Profile must be of certain type*/
if t_sDebtor.CnControlGLProfile_ID <> 0 and t_sDebtor.CnControlGLProfile_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.CnControlGLProfile_ID <> t_sDebtor.CnControlGLProfile_ID )))
then do:
    <Q-2 run ProfileById (all) (Read) (Cache)
       (input t_sDebtor.CnControlGLProfile_ID, (Profile_ID)
        output dataset tqProfileById) in BProfile>

    find first tqProfileById no-error.
    if available tqProfileById and
       tqProfileById.tcProfileTypeCode <> {&PROFILETYPECODE-DEBTORACCOUNT}
    then do:
        assign vcMessage     = trim(substitute(#T-5'The customer control account profile (credit note) &1 is not of type &2 for customer &3.':200(1678)t-5#, 
                                                trim(tqProfileById.tcProfileCode),
                                                trim({&PROFILETYPECODE-DEBTORACCOUNT-TR}), 
                                                trim(t_sDebtor.DebtorCode))) + chr(10) +
                               program-name(1)
              oiReturnStatus = -1.
        <M-3 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tDebtor.tcCnControlGLProfileCode':U (icFieldName),
                     input  t_sDebtor.tcCnControlGLProfileCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  t_sDebtor.tc_Rowid (icRowid),
                     input  'QADFIN-315':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BDebtor>       
    end.   

    if available tqProfileById and
       tqProfileById.tcProfileTypeCode = {&PROFILETYPECODE-DEBTORACCOUNT} and
       not tqProfileById.tlProfileIsActive
    then do:
        assign vcMessage     = trim(substitute(#T-6'The customer control account profile (credit note) &1 is not active for customer &2.':200(1679)t-6#, 
                                                trim(tqProfileById.tcProfileCode),
                                                trim(t_sDebtor.DebtorCode))) + chr(10) + 
                               program-name(1)
              oiReturnStatus = -1.
        <M-4 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tDebtor.tcCnControlGLProfileCode':U (icFieldName),
                     input  t_sDebtor.tcCnControlGLProfileCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  t_sDebtor.tc_Rowid (icRowid),
                     input  'QADFIN-316':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BDebtor>
    end.   
end.