project QadFinancials > class BDebtor > method ValNormalPaymentCondition

Description

Validates Normal Payment Condition field.
Note: work with t_s tables


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDebtor.PostValidateComponent


program code (program1/bdebtor.p)

/*error: Payment Condition must exist - checked by FC*/
/*error: Payment Condition must be of certain type*/
if t_sDebtor.NormalPaymentCondition_ID <> 0 and 
   t_sDebtor.NormalPaymentCondition_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.NormalPaymentCondition_ID <> t_sDebtor.NormalPaymentCondition_ID )))
then do:
    <Q-4 run PaymentConditionByIdCode (all) (Read) (Cache)
       (input t_sDebtor.NormalPaymentCondition_ID, (PaymentConditionId)
        input ?, (PaymentConditionCode)
        output dataset tqPaymentConditionByIdCode) in BPaymentCondition>

    find first tqPaymentConditionByIdCode no-error.
    /*error: not available tqPaymentConditionByIdCode should be checked by FC*/
    /*error: if > 0 then it must be an existing PaymentCondition of type = "Normal"*/
    if available tqPaymentConditionByIdCode and
       tqPaymentConditionByIdCode.tcPaymentConditionPaymentTyp <> {&PAYMENTCONDITIONPAYMENTTYPE-NORMAL}  and 
       tqPaymentConditionByIdCode.tcPaymentConditionPaymentTyp <> {&PAYMENTCONDITIONPAYMENTTYPE-STAGED}
    then do:
        assign vcPaymentType = trim({&PAYMENTCONDITIONPAYMENTTYPE-NORMAL-TR}) + ", ":U + 
                               trim({&PAYMENTCONDITIONPAYMENTTYPE-STAGED-TR})
               vcMessage     = trim(substitute(#T-7'The normal credit terms code &1 is not of type &2 for customer &3.':200(1669)t-7#, 
                                                trim(tqPaymentConditionByIdCode.tcPaymentConditionCode),
                                                vcPaymentType, 
                                                trim(t_sDebtor.DebtorCode))) + chr(10) +
                               program-name(1)
              oiReturnStatus = -1.
        <M-5 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tDebtor.tcNormalPaymentConditionCode':U (icFieldName),
                     input  t_sDebtor.tcNormalPaymentConditionCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  t_sDebtor.tc_Rowid (icRowid),
                     input  'QADFIN-317':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 tqPaymentConditionByIdCode and
      (tqPaymentConditionByIdCode.tcPaymentConditionPaymentTyp = {&PAYMENTCONDITIONPAYMENTTYPE-NORMAL} or 
       tqPaymentConditionByIdCode.tcPaymentConditionPaymentTyp = {&PAYMENTCONDITIONPAYMENTTYPE-STAGED}) and
       not tqPaymentConditionByIdCode.tlPaymentConditionIsActive
    then do:
        assign vcMessage     = trim(substitute(#T-8'The normal credit terms code &1 is not active for customer &2.':200(1670)t-8#, 
                                                trim(tqPaymentConditionByIdCode.tcPaymentConditionCode),
                                                trim(t_sDebtor.DebtorCode))) + chr(10) + 
                               program-name(1)
              oiReturnStatus = -1.
        <M-6 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tDebtor.tcNormalPaymentConditionCode':U (icFieldName),
                     input  t_sDebtor.tcNormalPaymentConditionCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  t_sDebtor.tc_Rowid (icRowid),
                     input  'QADFIN-318':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BDebtor>
    end.   
end.