project QadFinancials > class BPeriod > method ValidateComponentPost
Description
Validates if it is not possible to set a GL priod to reported if the previous period is not marked ad reported.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bperiod.p)
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* validations for lockjournalperiod activity */
if vcActivityCode = {&PERIODACTIVITYCODE-LOCKJOURNAL}
then do:
for each t_sPeriod where
t_sPeriod.tc_Status <> "":U:
/* check that the period is open before applying a daybook mask */
if t_sPeriod.PeriodStatus <> {&PERIODSTATUS-OPEN}
then do:
assign oiReturnStatus = -1.
<M-42 run SetMessage
(input #T-69'The GL period must be open.':255(39895174)T-69# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'qadfin-756291':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
return.
end.
/* check that the closing mask code is active */
<Q-28 run CMaskByCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sPeriod.tcCMaskCode, (CMaskCode)
output dataset tqCMaskByCode) in BCMask>
find first tqCMaskByCode where tqCMaskByCode.tcCMaskCode = t_sPeriod.tcCMaskCode and
tqCMaskByCode.tlCMaskIsActive = false no-error.
if available tqCMaskByCode
then do:
assign oiReturnStatus = -1.
<M-66 run SetMessage
(input #T-9'The daybook mask is inactive.':255(257762004)T-9# (icMessage),
input '':U (icArguments),
input 'tPeriod.tcCMaskCode':U (icFieldName),
input t_sPeriod.tcCMaskCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'qadfin-345819':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
return.
end. /* if available tqCMaskByCode */
end. /* for each t_sPeriod where */
end. /* if vcActivityCode = {&PERIODACTIVITYCODE-LOCKJOURNAL */
/* Validation of It is not possible to set a GL period to reported if the previous period is not marked as reported. */
if vcActivityCode = {&PERIODACTIVITYCODE-REPORTPERIOD}
then do:
for each t_sPeriod where
t_sPeriod.tc_Status <> "":U:
<Q-33 assign vlFcQueryRecordsAvailable = PeriodByYearPeriodForPrevStat (NoCache)
(input t_sPeriod.Company_ID, (CompanyId)
input t_sPeriod.PeriodPeriod, (PeriodPeriod)
input t_sPeriod.PeriodYear, (PeriodYear)) in BPeriod >
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMessage = trim(#T-16'You cannot set a GL period to Reported if the previous period is not marked as reported.':100(65761)T-16#)
viLocalReturnStatus = -1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.PeriodPeriod':U (icFieldName),
input t_sPeriod.PeriodPeriod (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-8050':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if tqPeriodByYearPeriod.tlPeriodIsReportChecked = false */
end. /* for each t_sPeriod where t_sPeriod.tc_Status <> "":U: */
end. /* if vcActivityCode = {&PERIODACTIVITYCODE-REPORTPERIOD} */
/* A Period cannot be set to Reported or Frozen if recurring entries still have to be executed */
for each t_sPeriod where
t_sPeriod.tc_Status = "C":U or
t_sPeriod.tc_Status = "N":U
no-lock :
if t_sPeriod.tc_status = "C":U and
(t_sPeriod.PeriodStatus = {&PERIODSTATUS-FROZEN} or
t_sPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED}) and
can-find(t_iPeriod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid and
t_iPeriod.PeriodStatus <> t_sPeriod.PeriodStatus)
then do:
<Q-5 assign vlFcQueryRecordsAvailable = RecEntryLineByTillPostingDate (Cache)
(input t_sPeriod.Company_ID, (CompanyId)
input t_sPeriod.PeriodEndDate, (TillAccountingDate)
input '':U, (PostingTemplateCode)
input '':U, (RecEntryFreq)
input '':U, (RecEntryUpdate)
input '':U, (JournalCode)
input {&RECENTRYLINESTATUS-WAITING}, (RecEntryLineStatus)
input true, (RecEntryIsActive)
input '':U, (RecEntryCode)) in BRecurringEntry >
if not vlFcQueryRecordsAvailable = false
then do:
assign vcMessage = trim(substitute(#T-17'GL period (&1) cannot be set as Reported or Frozen when it contains unposted recurring entries.':255(3071)T-17#, trim(string(t_sPeriod.PeriodYear) + '/':U + string(t_sPeriod.PeriodPeriod, '99':U)) ))
viLocalReturnStatus = -1.
<M-6 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.PeriodStatus':U (icFieldName),
input t_sPeriod.PeriodStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-8051':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if not vlFcQueryRecordsAvailable = false */
end. /* if t_sPeriod.tc_status = "C":U and */
/* A Period cannot be set to Reported or Frozen if the CheckForReported has not yet been executed */
if t_sPeriod.PeriodIsReportChecked = false and
(t_sPeriod.PeriodStatus = {&PERIODSTATUS-FROZEN} or
t_sPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED})
then do:
assign vcMessage = trim(substitute(#T-18'GL periods (&1) cannot be set to Reported or Frozen before validation is complete. Use the period closing function to do this validation':255(3072)T-18#,string(t_sPeriod.PeriodYear) + "/":U + string(t_sPeriod.PeriodPeriod)))
viLocalReturnStatus = -1.
<M-7 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.PeriodStatus':U (icFieldName),
input t_sPeriod.PeriodStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-8052':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if t_sPeriod.PeriodIsReportChecked = false */
/* Modify of Year, Period, Startdate and Enddate isonly allowed */
/* if there is no posting on the period yet */
if t_sPeriod.tc_Status = "C":U and
can-find (first t_iPeriod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid and
(t_iPeriod.PeriodYear <> t_sPeriod.PeriodYear or
t_iPeriod.PeriodPeriod <> t_sPeriod.PeriodPeriod or
t_iPeriod.PeriodStartDate <> t_sPeriod.PeriodStartDate or
t_iPeriod.PeriodEndDate <> t_sPeriod.PeriodEndDate))
then do:
<Q-8 assign vlFcQueryRecordsAvailable = PostingByPeriodPeriodMark (NoCache)
(input t_sPeriod.Company_ID, (CompanyId)
input t_sPeriod.Period_ID, (PeriodID)
input t_sPeriod.PeriodMark_ID, (PeriodMarkID)) in BPosting >
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMessage = trim(#T-19'Posting found for this GL period with this period mark: cannot update GL calendar year, GL period, start/end date.':255(3074)T-19#) + chr(10) +
trim(substitute(#T-20'GL period: &1/&2':255(3075)T-20#,string(t_sPeriod.PeriodYear),string(t_sPeriod.PeriodPeriod))) + chr(10) +
trim(substitute(#T-21'Period mark: &1.':255(3076)T-21#,string(t_sPeriod.tcPeriodMarkCode)))
viLocalReturnStatus = -1.
<M-9 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.tcPeriodMarkCode':U (icFieldName),
input t_sPeriod.tcPeriodMarkCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-8053':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if av tqPostingByPeriodPeriodMark */
end. /* if t_sPeriod.tc_Status = "C":U and */
/* GL period can not re-open if next period status is reported or frozen */
if t_sPeriod.tc_Status = "C":U
then do:
if t_sPeriod.PeriodStatus = {&PERIODSTATUS-OPEN} and
can-find (t_iPeriod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid and
(t_iPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED} or
t_iPeriod.PeriodStatus = {&PERIODSTATUS-FROZEN}))
then do:
<Q-29 assign vlFcQueryRecordsAvailable = PeriodNextPeriodForPeriodStat (NoCache)
(input t_sPeriod.Company_ID, (CompanyId)
input t_sPeriod.PeriodPeriod, (PeriodPeriod)
input t_sPeriod.PeriodYear, (PeriodYear)) in BPeriod >
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMessage = trim(#T-30'It is not possible to re-open a GL period if the next period is set as reported or frozen.':250(999890152)T-30#).
viLocalReturnStatus = -1.
<M-31 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.PeriodPeriod':U (icFieldName),
input t_sPeriod.PeriodPeriod (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-8898':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* if ( t_iPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED} or */
end. /* if t_sPeriod.tc_Status = "C":U */
/* The PeriodTypeCode cannot be set from 'YearClosing' to 'Normal' or 'Correction' */
/* The PeriodTypeCode can only be set 'Normal' or 'Correction' to 'YearClosing' by the closing process */
/* The closing-process should set 'BPeriodIsCalledFromTheClosingProcess' = true before this is executed */
/* This setting should be done in the session-component using a Call to Session.SetLogicalValue */
if t_sPeriod.tc_Status = "C":U
then do:
find t_iPeriod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid
no-lock no-error.
if not available t_iPeriod then next.
if t_iPeriod.PeriodTypeCode = {&PERIODTYPECODE-YEARCLOSING} and
(t_sPeriod.PeriodTypeCode = {&PERIODTYPECODE-NORMAL} or
t_sPeriod.PeriodTypeCode = {&PERIODTYPECODE-CORRECTION})
then do :
assign vcMessage = trim(substitute(#T-22'The GL period type cannot be set to &1 or &2 because the previous value was &3.':255(3078)T-22#,{&PERIODTYPECODE-NORMAL-TR},{&PERIODTYPECODE-CORRECTION-TR},{&PERIODTYPECODE-YEARCLOSING-TR})) + chr(10) +
trim(substitute(#T-23'GL period: &1/&2':255(3075)T-23#,string(t_sPeriod.PeriodYear),string(t_sPeriod.PeriodPeriod)))
viLocalReturnStatus = -1.
<M-10 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.PeriodTypeCode':U (icFieldName),
input t_sPeriod.PeriodTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-8054':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if t_iPeriod.PeriodTypeCode = {&PERIODTYPECODE-YEARCLOSING} and */
if t_sPeriod.PeriodTypeCode = {&PERIODTYPECODE-YEARCLOSING} and
(t_iPeriod.PeriodTypeCode = {&PERIODTYPECODE-NORMAL} or
t_iPeriod.PeriodTypeCode = {&PERIODTYPECODE-CORRECTION})
then do :
<I-11 {bFcOpenInstance
&CLASS = "Session"}>
<M-12 run GetLogicalValue
(input 'BPeriodIsCalledFromTheClosing':U (icName),
output vlBPeriodIsCalledFromTheClosing (olValue),
output viSessionReturnStatus (oiReturnStatus)) in Session>
<I-13 {bFcCloseInstance
&CLASS = "Session"}>
if viSessionReturnStatus <> 0 or
vlBPeriodIsCalledFromTheClosing = false
then do :
assign vcMessage = trim(substitute(#T-24'The GL period type cannot be set to &1 because the previous value was &2 or &3.':255(3079)T-24#,{&PERIODTYPECODE-YEARCLOSING-TR},{&PERIODTYPECODE-NORMAL-TR},{&PERIODTYPECODE-CORRECTION-TR})) + chr(10) +
trim(#T-25'This change is only allowed for the closing process.':255(3080)T-25#) + chr(10) +
trim(substitute(#T-26'GL period: &1/&2':255(3075)T-26#,string(t_sPeriod.PeriodYear),string(t_sPeriod.PeriodPeriod)))
viLocalReturnStatus = -1.
<M-14 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.PeriodTypeCode':U (icFieldName),
input t_sPeriod.PeriodTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-8055':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if viSessionReturnStatus <> 0 or */
end. /* if t_iPeriod.PeriodTypeCode = {&PERIODTYPECODE-YEARCLOSING} and */
end. /* if t_sPeriod.tc_Status = "C":U */
end. /* for each t_sPeriod */
/* cannot be deleted when status is not open */
for each t_sPeriod where
t_sPeriod.tc_Status = "D":U
no-lock:
if t_sPeriod.PeriodStatus <> {&PERIODSTATUS-OPEN}
then do:
assign vcMessage = trim(substitute(#T-27'Cannot delete the GL period. Period status is not &1.':255(3073)T-27#, {&PERIODSTATUS-OPEN-TR}))
viLocalReturnStatus = -1.
<M-15 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.PeriodStatus':U (icFieldName),
input t_sPeriod.PeriodStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-8056':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* not open */
end. /* for each t_sPeriod where */
/* GL Consistency check: set batch flag to true when reporting the period */
for each t_sPeriod where
t_sPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED} and
t_sPeriod.tc_Status = 'C':U:
find first t_iPeriod where
t_iPeriod.Period_ID = t_sPeriod.Period_ID and
t_iPeriod.PeriodStatus = {&PERIODSTATUS-LOCKED} no-error.
if available t_iPeriod
then do:
/* call method BConCheck.ValidateComponentPostConCheck*/
<M-77 run ValidateComponentPostConCheck (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and viLocalReturnStatus >= 0)
then assign viLocalReturnStatus = viFcReturnSuper.
end.
end. /* for each t_sPeriod */
assign oiReturnStatus = viLocalReturnStatus.