project QadFinancials > class BRecurringEntry > method ValRecEntryEndDate

validation procedure

Description

ValRecEntryEndDate


Parameters


itTargetFieldinputdateValue of the business field to validate.
icTargetFieldNameinputcharacterName of the business field to validate.
icRowidinputcharacterContents of field tc_Rowid, if the target field is a field of a component temp-table.
itRecEntryStartDateinputdateRecEntryStartDate
ilRecEntryIsOpenEndedinputlogicalRecEntryIsOpenEnded
icRecEntryCodeinputcharacterRecEntryCode
icRecEntryFreqinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BRecurringEntry.GenerateCalendar
validation on tRecEntry.RecEntryEndDate


program code (program4/brecurringentry.p)

/* ============================================================== */
/* Start Date should be situated before (or same day) as End Date */
/* ============================================================== */
if itTargetField      <> ? and
   itRecEntryStartDate > itTargetField
then do:
    assign vcMessageRE    = trim(substitute(#T-4'The end date (&1) cannot be before the start date (&2).':150(3503)T-4#, string(itTargetField), string(itRecEntryStartDate) )) + chr(10) +
                            trim(substitute(#T-5'Recurring entry code: &1.':255(3493)T-5#,trim(icRecEntryCode)))
           oiReturnStatus = -1.
    <M-1 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  icTargetFieldName (icFieldName),
                     input  string(itTargetField) (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  icRowid (icRowid),
                     input  'QADFIN-960':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>
end.

/* ======================================================= */
/* If flag Open End is true --> End Date must be blank     */
/* ======================================================= */
if ilRecEntryIsOpenEnded = true and
   itTargetField        <> ?
then do:
    assign vcMessageRE    = trim(substitute(#T-6'You cannot specify the end date (&1) if the Open End field is selected.':150(3504)t-6#, string(itTargetField) )) + chr(10) +
                            trim(substitute(#T-7'Recurring entry code: &1.':255(3493)T-7#,trim(icRecEntryCode)))
           oiReturnStatus = -1.
    <M-2 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  icTargetFieldName (icFieldName),
                     input  string(itTargetField) (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  icRowid (icRowid),
                     input  'QADFIN-961':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>
end.

/* ======================================================= */
/* If flag Open End is false --> End Date can not be blank */
/* ======================================================= */
if ilRecEntryIsOpenEnded = false and
   itTargetField         = ?
then do:
    assign vcMessageRE    = trim(substitute(#T-8'You must specify the end date (&1) if the Open End field is not selected.':150(3505)T-8#, string(itTargetField) )) + chr(10) + 
                            trim(substitute(#T-9'Recurring entry code: &1.':255(3493)T-9#,trim(icRecEntryCode)))
           oiReturnStatus = -1.
    <M-3 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  icTargetFieldName (icFieldName),
                     input  string(itTargetField) (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  icRowid (icRowid),
                     input  'QADFIN-962':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>
end.


/* ===================================================================================== */
/* The EndDate must be the last date of a period when frequency is Period                */
/* ===================================================================================== */
if icRecEntryFreq = {&RECENTRYFREQ-PERIOD} and
   itTargetField  <> ?
then do:
    <Q-10 run PeriodByStartEndDate (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input itTargetField, (Date)
           output dataset tqPeriodByStartEndDate) in BPeriod >
    find tqPeriodByStartEndDate where
         tqPeriodByStartEndDate.tcPeriodTypeCode = {&PERIODTYPECODE-NORMAL}
         no-lock no-error.
    if not available tqPeriodByStartEndDate
    then do:
        assign vcMessageRE    = trim(substitute(#T-13'There is no GL period available yet for the selected end date (&1).':150(71094)T-13#, string(itTargetField) )) + chr(10) +
                                trim(substitute(#T-14'Recurring entry code: &1.':255(3493)T-14#,trim(icRecEntryCode)))
               oiReturnStatus = -1.
        <M-11 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  icTargetFieldName (icFieldName),
                     input  string(itTargetField) (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  icRowid (icRowid),
                     input  'QadFin-8609':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
    end.
    else do:
        if itTargetField <> tqPeriodByStartEndDate.ttPeriodEndDate
        then do:
            assign vcMessageRE    = trim(substitute(#T-15'The end date (&1) must be the last date of a GL period when the frequency is &2.':150(71093)T-15#, string(itTargetField), {&RECENTRYFREQ-PERIOD-TR})) + chr(10) +
                                    trim(substitute(#T-16'Recurring entry code: &1.':255(3493)T-16#,trim(icRecEntryCode)))
                   oiReturnStatus = -1.
            <M-12 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  icTargetFieldName (icFieldName),
                     input  string(itTargetField) (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  icRowid (icRowid),
                     input  'QadFin-8610':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>
        end.
    end.
end.