project QadFinancials > class BPaymentSelection > method ValidateComponentPostReference

Description

submethod of ValidateComponentPost : add validation that the reference must be unique of a prepayment for supplier and year


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program4/bpaymentselection.p)

for each t_sPaySel where
         t_sPaySel.tc_Status <> "D":U and
         year(t_sPaySel.PaySelDate) = year(today),
    each t_sPaySelLine where
         t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
        (t_sPaySelLine.tc_Status      = "N":U or
         t_sPaySelLine.tc_Status      = "C":U) :

    if t_sPaySelLine.tcExternalNumber <> "":U and
       t_sPaySelLine.tcExternalNumber <> ?
    then do:
        assign vlError = false.

        for each bPaySel where
                 year(bPaySel.PaySelDate) = year(today),
            each bPaySelLine where
                 bPaySelLine.tc_ParentRowid      = bPaySel.tc_Rowid and
                 bPaySelLine.tcCreditorCode      = t_sPaySelLine.tcCreditorCode and
                 bPaySelLine.tcExternalNumber    = t_sPaySelLine.tcExternalNumber and
                 bPaySelLine.PayFormatTypeCode   = {&PAYMENTSELECTIONTYPE-PREPAYMENT} and
                 bPaySelLine.tc_Rowid            <> t_sPaySelLine.tc_Rowid :
            assign vlError = true.
            leave.
        end.

        if not vlError
        then do:
             <Q-95 assign vlFcQueryRecordsAvailable = PaySelLineByRefCreditorYear (NoCache)
                (input t_sPaySel.Company_ID, (CompanyId)
                 input t_sPaySelLine.tcCreditorCode, (CreditorCode)
                 input t_sPaySelLine.tcExternalNumber, (Reference)
                 input t_sPaySelLine.tc_Rowid, (SkipRowId)
                 input year(t_sPaySel.PaySelDate), (Year)
                 input {&PAYMENTSELECTIONTYPE-PREPAYMENT}, (ObjectType)) in BPaymentSelection >
             assign vlError = vlFcQueryRecordsAvailable <> false.
        end.

        if vlError
        then do:
             <M-86 run SetMessage
                (input  trim(#T-20'A Prepayment with this reference already exists for this supplier. Please enter a unique reference.':255(207771413)T-20#) (icMessage), 
                 input  '':U (icArguments), 
                 input  't_PaySelLine.tcExternalNumber':U (icFieldName), 
                 input  t_sPaySelLine.tcExternalNumber (icFieldValue), 
                 input  'E':U (icType), 
                 input  3 (iiSeverity), 
                 input  t_sPaySelLine.tc_Rowid (icRowid), 
                 input  'QadFin-211235':U (icFcMsgNumber), 
                 input  '':U (icFcExplanation), 
                 input  '':U (icFcIdentification), 
                 input  '':U (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
             assign oiReturnStatus = -1.
        end.
    end.
end.