project QadFinancials > class BDInvoice > method ValidateComponentAllSlspsn

Description

This method is a submethod of ValidateComponentAll.

This method validates the Salesperson.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.ValidateComponentAll


program code (program5/bdinvoice.p)

/* ======================================================================== */
/* IMPORTANT: This method is run from ValidateComponentAll                  */
/* The code in this method is nested within the for each t_sDInvoice        */
/* This can only work when both methods are defined in the same segment (5) */
/* ======================================================================== */

if t_sDInvoice.Journal_ID <> 0 and
           t_sDInvoice.Journal_ID <> ?
        then 
           <Q-49 run JournalPrim (all) (Read) (NoCache)
              (input viCompanyId, (CompanyId)
               input ?, (JournalCode)
               input t_sDInvoice.Journal_ID, (JournalID)
               output dataset tqJournalPrim) in BJournal>

 find first tqJournalPrim where
            tqJournalPrim.tiJournal_ID = t_sDInvoice.Journal_ID
            no-error.

 assign vcJournalCode = if available tqJournalPrim
                        then tqJournalPrim.tcJournalCode
                        else ?.


vcInvoiceRef = string(t_sDInvoice.DInvoicePostingYear, "9999":U) + "/":U + 
               string(t_sDInvoice.DInvoicePostingPeriod,"99":U) +  " ":U + 
               vcJournalCode + " ":U +
               string(t_sDInvoice.DInvoiceVoucher, "999999999":U).

if t_sDInvoice.tc_Status = "N":U or t_sDInvoice.tc_Status = "C":U
then do:
    if t_sDInvoice.DInvoiceSlsPsn1 <> "":U and t_sDInvoice.DInvoiceSlsPsn1 <> ?
    then do:
         <Q-26 assign vlFcQueryRecordsAvailable = SalesPersonBySalesPerson (NoCache)
            (input vcDomainCode, (DomainCode)
             input t_sDInvoice.DInvoiceSlsPsn1, (Salespsn)) in BMfgSalesPerson >
         if vlFcQueryRecordsAvailable = false
         then do:
              assign oiReturnStatus = -1
                     vcMsg = trim(substitute(#T-27'The salesperson (&1) specified in the invoice (&2) is not defined in the system.':255(977827730)T-27#, t_sDInvoice.DInvoiceSlsPsn1,vcInvoiceRef)).
              <M-28 run SetMessage
                 (input  vcMsg (icMessage), 
                  input  '':U (icArguments), 
                  input  'tDInvoice.DInvoiceSlsPsn1':U (icFieldName), 
                  input  t_sDInvoice.DInvoiceSlsPsn1 (icFieldValue), 
                  input  'E':U (icType), 
                  input  3 (iiSeverity), 
                  input  t_sDInvoice.tc_Rowid (icRowid), 
                  input  'QadFin-8079':U (icFcMsgNumber), 
                  input  '':U (icFcExplanation), 
                  input  '':U (icFcIdentification), 
                  input  '':U (icFcContext), 
                  output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
         end. /* if vlFcQueryRecordsAvailable = false */
    end. /* if t_sDInvoice.DInvoiceSlsPsn1 <> "":U */

    if t_sDInvoice.DInvoiceSlsPsn2 <> "":U and t_sDInvoice.DInvoiceSlsPsn2 <> ?
    then do:
         <Q-29 assign vlFcQueryRecordsAvailable = SalesPersonBySalesPerson (NoCache)
            (input vcDomainCode, (DomainCode)
             input t_sDInvoice.DInvoiceSlsPsn2, (Salespsn)) in BMfgSalesPerson >
         if vlFcQueryRecordsAvailable = false
         then do:
              assign oiReturnStatus = -1
                     vcMsg = trim(substitute(#T-31'The salesperson (&1) specified in the invoice (&2) is not defined in the system.':255(977827730)T-31#, t_sDInvoice.DInvoiceSlsPsn2,vcInvoiceRef)).
              <M-30 run SetMessage
                 (input  vcMsg (icMessage), 
                  input  '':U (icArguments), 
                  input  'tDInvoice.DInvoiceSlsPsn2':U (icFieldName), 
                  input  t_sDInvoice.DInvoiceSlsPsn2 (icFieldValue), 
                  input  'E':U (icType), 
                  input  3 (iiSeverity), 
                  input  t_sDInvoice.tc_Rowid (icRowid), 
                  input  'QadFin-8080':U (icFcMsgNumber), 
                  input  '':U (icFcExplanation), 
                  input  '':U (icFcIdentification), 
                  input  '':U (icFcContext), 
                  output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
         end. /* if vlFcQueryRecordsAvailable = false */
    end. /* if t_sDInvoice.DInvoiceSlsPsn2 <> "":U */

    if t_sDInvoice.DInvoiceSlsPsn3 <> "":U and t_sDInvoice.DInvoiceSlsPsn3 <> ?
    then do:
         <Q-32 assign vlFcQueryRecordsAvailable = SalesPersonBySalesPerson (NoCache)
            (input vcDomainCode, (DomainCode)
             input t_sDInvoice.DInvoiceSlsPsn3, (Salespsn)) in BMfgSalesPerson >
         if vlFcQueryRecordsAvailable = false
         then do:
              assign oiReturnStatus = -1
                     vcMsg = trim(substitute(#T-34'The salesperson (&1) specified in the invoice (&2) is not defined in the system.':255(977827730)T-34#, t_sDInvoice.DInvoiceSlsPsn3,vcInvoiceRef)).
              <M-33 run SetMessage
                 (input  vcMsg (icMessage), 
                  input  '':U (icArguments), 
                  input  'tDInvoice.DInvoiceSlsPsn3':U (icFieldName), 
                  input  t_sDInvoice.DInvoiceSlsPsn3 (icFieldValue), 
                  input  'E':U (icType), 
                  input  3 (iiSeverity), 
                  input  t_sDInvoice.tc_Rowid (icRowid), 
                  input  'QadFin-8081':U (icFcMsgNumber), 
                  input  '':U (icFcExplanation), 
                  input  '':U (icFcIdentification), 
                  input  '':U (icFcContext), 
                  output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
         end. /* if vlFcQueryRecordsAvailable = false */
    end. /* if t_sDInvoice.DInvoiceSlsPsn3 <> "":U */

    if t_sDInvoice.DInvoiceSlsPsn4 <> "":U and t_sDInvoice.DInvoiceSlsPsn4 <> ?
    then do:
         <Q-35 assign vlFcQueryRecordsAvailable = SalesPersonBySalesPerson (NoCache)
            (input vcDomainCode, (DomainCode)
             input t_sDInvoice.DInvoiceSlsPsn4, (Salespsn)) in BMfgSalesPerson >
         if vlFcQueryRecordsAvailable = false
         then do:
              assign oiReturnStatus = -1
                     vcMsg = trim(substitute(#T-37'The salesperson (&1) specified in the invoice (&2) is not defined in the system.':255(977827730)T-37#, t_sDInvoice.DInvoiceSlsPsn4,vcInvoiceRef)).
              <M-36 run SetMessage
                 (input  vcMsg (icMessage), 
                  input  '':U (icArguments), 
                  input  'tDInvoice.DInvoiceSlsPsn4':U (icFieldName), 
                  input  t_sDInvoice.DInvoiceSlsPsn4 (icFieldValue), 
                  input  'E':U (icType), 
                  input  3 (iiSeverity), 
                  input  t_sDInvoice.tc_Rowid (icRowid), 
                  input  'QadFin-8082':U (icFcMsgNumber), 
                  input  '':U (icFcExplanation), 
                  input  '':U (icFcIdentification), 
                  input  '':U (icFcContext), 
                  output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
         end. /* if vlFcQueryRecordsAvailable = false */
    end. /* if t_sDInvoice.DInvoiceSlsPsn4 <> "":U */
end. /* if t_sDInvoice.tcStatus = "N":U or "C":U */