project QadFinancials > class BPeriod > method YearClosingClosePeriods
Description
YearClosingClosePeriods: This public method will be run from BYearClosing.AdditionalUpdatesClosePeriods and will close all periods in the selected year and will set the opening period in the next year to 'LOCKED'.
Parameters
iiCompanyID | input | integer | Entity ID |
iiYearClosingAccountingYear | input | integer | Year Closing Accounting Year |
icLayerTypeCode | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bperiod.p)
/* ========================================= */
/* Retrieve all periods of the selected year */
/* ========================================= */
assign vcListPeriods = '':U.
<Q-1 run PeriodByYearPeriod (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input iiYearClosingAccountingYear, (PeriodYear)
input 0, (PeriodPeriod)
input 0, (PeriodId)
output dataset tqPeriodByYearPeriod) in BPeriod >
for each tqPeriodByYearPeriod where
tqPeriodByYearPeriod.tiCompany_ID = iiCompanyID and
tqPeriodByYearPeriod.tiPeriodYear = iiYearClosingAccountingYear:
find tPeriod where
tPeriod.Period_ID = tqPeriodByYearPeriod.tiPeriod_ID
no-lock no-error.
if not available tPeriod
then assign vcListPeriods = vcListPeriods + string(tqPeriodByYearPeriod.tiPeriod_ID) + chr(4).
end. /* for each tqPeriodByYearPeriod ... */
/* =============================== */
/* Find period 0 for the next year */
/* =============================== */
if not can-find(tPeriod where
tPeriod.Company_ID = iiCompanyID and
tPeriod.PeriodYear = iiYearClosingAccountingYear + 1 and
tPeriod.PeriodPeriod = 0)
then do:
<Q-2 run PeriodPrim (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input 0, (PeriodId)
input iiYearClosingAccountingYear + 1, (PeriodYear)
input 0, (PeriodPeriod)
output dataset tqPeriodPrim) in BPeriod >
find tqPeriodPrim where
tqPeriodPrim.tiCompany_ID = iiCompanyID and
tqPeriodPrim.tiPeriodYear = iiYearClosingAccountingYear + 1 and
tqPeriodPrim.tiPeriodPeriod = 0
no-lock no-error.
if not available tqPeriodPrim
then do:
assign vcMessage = trim(substitute(#T-3'Could not find period 0 for GL calendar year &1.':200(20432)T-3#, trim(string(iiYearClosingAccountingYear + 1)) ))
oiReturnStatus = -1.
<M-4 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-4655':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
return.
end.
assign vcListPeriods = vcListPeriods + string(tqPeriodPrim.tiPeriod_ID) + chr(4).
end.
if vcListPeriods <> '':U and vcListPeriods <> ?
then assign vcListPeriods = substring(vcListPeriods, 1, length(vcListPeriods, "Character":U) - 1, "Character":U).
/* ======== */
/* DataLoad */
/* ======== */
<M-5 run DataLoad (input '':U (icRowids),
input vcListPeriods (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
then do:
assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
/* ============================================== */
/* Set all periods of the selected year to FROZEN */
/* ============================================== */
for each tPeriod where
tPeriod.Company_ID = iiCompanyID and
tPeriod.PeriodYear = iiYearClosingAccountingYear and
tPeriod.tc_Status <> 'D':U and
icLayerTypeCode = {&LAYERTYPECODE-OFFICIAL}:
assign tPeriod.PeriodStatus = {&PERIODSTATUS-FROZEN}
tPeriod.PeriodIsReportChecked = true
tPeriod.tc_Status = (if tPeriod.tc_Status = '':U
then 'C':U
else tPeriod.tc_Status).
end. /* for each tPeriod ... */
/* =================================================== */
/* Set the opening period of the next year to 'LOCKED' */
/* =================================================== */
find tPeriod where
tPeriod.Company_ID = iiCompanyID and
tPeriod.PeriodYear = iiYearClosingAccountingYear + 1 and
tPeriod.PeriodPeriod = 0
no-error.
if available tPeriod
then assign tPeriod.PeriodStatus = {&PERIODSTATUS-LOCKED}
tPeriod.tc_Status = (if tPeriod.tc_Status = '':U
then 'C':U
else tPeriod.tc_Status).