project QadFinancials > class BYearClosing > method ValidateComponentAllCheckBalance
Description
ValidateComponentAllCheckBalance
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/byearclosing.p)
/* =============================================================================== */
/* Check if P&L & Balance Sheets are in balance */
/* IMPORTANT: This method is called from within the for each t_sYearClosing. */
/* So this record is available in this method. */
/* This can only be done when both methods are within the same segment. */
/* =============================================================================== */
/* =============================================== */
/* Get last accounting period of the selected year */
/* =============================================== */
<Q-1 run PeriodByYearPeriod (last) (Read) (NoCache)
(input t_sYearClosing.Company_ID, (CompanyId)
input t_sYearClosing.YearClosingAccountingYear, (PeriodYear)
input 0, (PeriodPeriod)
input 0, (PeriodId)
output dataset tqPeriodByYearPeriod) in BPeriod >
find last tqPeriodByYearPeriod where
tqPeriodByYearPeriod.tiCompany_ID = t_sYearClosing.Company_ID and
tqPeriodByYearPeriod.tiPeriodYear = t_sYearClosing.YearClosingAccountingYear
no-lock no-error.
if not available tqPeriodByYearPeriod
then do:
assign vcMessage = trim(substitute(#T-2'No GL periods are defined for GL calendar year &1.':200(20421)t-2# , trim(string(t_sYearClosing.YearClosingAccountingYear)) ))
oiReturnStatus = -1.
<M-3 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tYearClosing.YearClosingAccountingYear':U (icFieldName),
input string(t_sYearClosing.YearClosingAccountingYear) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sYearClosing.tc_Rowid (icRowid),
input 'QadFin-4645':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
return.
end.
/* ================================================================== */
/* Summarize the Movements in the history file for the Official Layer */
/* ================================================================== */
<M-64 run CalculateBalanceDIRECT
(input t_sYearClosing.Company_ID (iiCompanyID),
input t_sYearClosing.tcLayerTypeCode (icLayerTypeCode),
input (tqPeriodByYearPeriod.tiPeriodYear * 100) (iiYearPeriodFrom),
input (tqPeriodByYearPeriod.tiPeriodYear * 100) + tqPeriodByYearPeriod.tiPeriodPeriod (iiYearPeriodTill),
output vdSumMovemntDebitLC (odSumMovemntDebitLC),
output vdSumMovemntDebitCC (odSumMovemntDebitCC),
output vdSumMovemntCreditLC (odSumMovemntCreditLC),
output vdSumMovemntCreditCC (odSumMovemntCreditCC),
output vdSumMovemntPLDebitLC (odSumMovemntPLDebitLC),
output vdSumMovemntPLDebitCC (odSumMovemntPLDebitCC),
output vdSumMovemntPLCreditLC (odSumMovemntPLCreditLC),
output vdSumMovemntPLCreditCC (odSumMovemntPLCreditCC),
output viPostingHistRecordsRead (oiPostingHistRecordsRead),
input t_sYearClosing.tcLayerCode (icLayerCode),
output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
/* ================== */
/* Check the balances */
/* ================== */
if vdSumMovemntDebitLC <> vdSumMovemntCreditLC
then do:
assign vcMessage = trim(substitute(#T-5'The total BC balance of all postings in the GL calendar year should be zero. (Debit = &1 / Credit = &2)':200(20422)T-5#, trim(string(vdSumMovemntDebitLC)), trim(string(vdSumMovemntCreditLC)) ))
oiReturnStatus = -1.
<M-6 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tYearClosing.YearClosingAccountingYear':U (icFieldName),
input string(t_sYearClosing.YearClosingAccountingYear) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sYearClosing.tc_Rowid (icRowid),
input 'QadFin-4646':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
end.
if vdSumMovemntDebitCC <> vdSumMovemntCreditCC
then do:
assign vcMessage = trim(substitute(#T-8'The total SC balance of all postings in the GL calendar year should be zero. (Debit = &1 / Credit = &2)':200(20423)t-8#, trim(string(vdSumMovemntDebitCC)), trim(string(vdSumMovemntCreditCC)) ))
oiReturnStatus = -1.
<M-7 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tYearClosing.YearClosingAccountingYear':U (icFieldName),
input string(t_sYearClosing.YearClosingAccountingYear) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sYearClosing.tc_Rowid (icRowid),
input 'QadFin-4647':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
end.
if t_sYearClosing.YearClosingIsTransPLToBal = false
then do:
if vdSumMovemntPLDebitLC <> vdSumMovemntPLCreditLC
then do:
assign vcMessage = trim(substitute(#T-10'You cannot run Year-End Closing if the PL accounts are not balanced in the base currency. (Debit = &1 / Credit = &2)':200(55965)t-10#, trim(string(vdSumMovemntPLDebitLC)), trim(string(vdSumMovemntPLCreditLC)) ))
oiReturnStatus = -1.
<M-9 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tYearClosing.YearClosingAccountingYear':U (icFieldName),
input string(t_sYearClosing.YearClosingAccountingYear) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sYearClosing.tc_Rowid (icRowid),
input 'QadFin-4648':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
end.
if vdSumMovemntPLDebitCC <> vdSumMovemntPLCreditCC
then do:
assign vcMessage = trim(substitute(#T-12'You cannot run Year-End Closing if the PL accounts are not balanced in the Statutory currency. (Debit = &1 / Credit = &2)':200(55966)t-12#, trim(string(vdSumMovemntPLDebitCC)), trim(string(vdSumMovemntPLCreditCC)) ))
oiReturnStatus = -1.
<M-11 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tYearClosing.YearClosingAccountingYear':U (icFieldName),
input string(t_sYearClosing.YearClosingAccountingYear) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sYearClosing.tc_Rowid (icRowid),
input 'QadFin-4649':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
end.
end. /* if t_sYearClosing.YearClosingIsTransPLToBal = false */