project QadFinancials > class BBudget > method ValidateComponentCheckUpdates
Description
This method will validate Budgets that had status<>Init when loaded with following restrictions;
- Project and Cost-centre of the budget can no longer be changed
- Company-dependant flag and SharedSet-IDs on budget cannot be changed
- Sequence, Start- and end-date of the existing periods cannot be changed
- Periods cannot be deleted
- Every new company should fit the SharedSet-IDs on the header
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bbudget.p)
/* ============================================================================ */
/* Budgets that had status<>Init when loaded should fit a few restrictions; */
/* - Project and Cost-centre of the budget can no longer be changed */
/* - Company-dependant flag and SharedSet-IDs on budget cannot be changed */
/* - Sequence, Start- and end-date of the existing periods cannot be changed */
/* - Periods cannot be deleted */
/* - Only period-code can be updated */
/* - New periods should be consecutive to the existing ones */
/* - Every new company should fit the SharedSet-IDs on the header */
/* ============================================================================ */
for each t_sBudget where
t_sBudget.tc_Status = "N":U or
t_sBudget.tc_Status = "C":U
no-lock :
/* ======================== */
/* Get the original version */
/* ======================== */
find t_iBudget where
t_iBudget.tc_Rowid = t_sBudget.tc_Rowid
no-lock no-error.
/* ================================ */
/* skip records for furhter testing */
/* ================================ */
if not available t_iBudget or
t_sBudget.BudgetStatus = {&BUDGETSTATUS-INITIAL} or
(available t_iBudget and
t_iBudget.BudgetStatus <> {&BUDGETSTATUS-INITIAL}) or
(available t_iBudget and
t_iBudget.BudgetStatus = {&BUDGETSTATUS-INITIAL} and
t_sBudget.BudgetStatus <> {&BUDGETSTATUS-INITIAL})
then next.
/* =========================================== */
/* Check for not-allowed changes on the header */
/* =========================================== */
if t_iBudget.Project_ID <> t_sBudget.Project_ID
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-16'You cannot update the project (&1) of the budget (&2) if the budget structure has been validated.':255(499)T-16#,t_sBudget.tcProjectCode,t_sBudget.BudgetCode)).
<M-1 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudget.tcProjectCode':U (icFieldName),
input t_sBudget.tcProjectCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudget.tc_Rowid (icRowid),
input 'QADFIN-511':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if t_iBudget.Project_ID <> t_sBudget.Project_ID */
if t_iBudget.CostCentre_ID <> t_sBudget.CostCentre_ID
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-17'You cannot update the cost center (&1) of the budget (&2) if the budget structure has been validated.':255(500)T-17#,t_sBudget.tcCostCentreCode,t_sBudget.BudgetCode)).
<M-2 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudget.tcCostCentreCode':U (icFieldName),
input t_sBudget.tcCostCentreCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudget.tc_Rowid (icRowid),
input 'QADFIN-512':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if t_iBudget.CostCentre_ID <> t_sBudget.CostCentre_ID */
if t_iBudget.BudgetIsCompanyDependent <> t_sBudget.BudgetIsCompanyDependent
then do :
assign oiReturnStatus = (if oiReturnStatus >= 0 then +1 else oiReturnStatus)
vcMessage = trim(substitute(#T-18'Warning. You should not update the entity-dependent indication of the budget (&2) if the budget structure has already been validated.':255(14127)t-18#,t_sBudget.BudgetCode)) + chr(10) +
trim(substitute(#T-32'Rebuild the budget to ensure that your actuals and commitments are still corrected.':255(14109)t-32#)).
<M-3 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudget.BudgetIsCompanyDependent':U (icFieldName),
input string(t_sBudget.BudgetIsCompanyDependent) (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sBudget.tc_Rowid (icRowid),
input 'QADFIN-513':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* t_iBudget.BudgetIsCompanyDependent <> t_sBudget.BudgetIsCompanyDependent */
if t_iBudget.GLSharedSet_ID <> t_sBudget.GLSharedSet_ID or
t_iBudget.DivisionSharedSet_ID <> t_sBudget.DivisionSharedSet_ID or
t_iBudget.ProjectSharedSet_ID <> t_sBudget.ProjectSharedSet_ID or
t_iBudget.CostCentreSharedSet_ID <> t_sBudget.CostCentreSharedSet_ID
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-19'You cannot update the shared set properties of a budget (&1) if the budget structure has been validated.':255(502)T-19#,t_sBudget.BudgetCode)).
<M-4 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudget.BudgetCode':U (icFieldName),
input t_sBudget.BudgetCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudget.tc_Rowid (icRowid),
input 'QADFIN-514':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if t_iBudget.GLSharedSet_ID <> t_sBudget.GLSharedSet_ID or */
/* =========================================== */
/* Perform BudgetPeriod checks */
/* =========================================== */
for each t_sBudgetPeriod where
t_sBudgetPeriod.tc_ParentRowid = t_sBudget.tc_Rowid and
t_sBudgetPeriod.tc_Status <> "":U
no-lock :
if t_sBudgetPeriod.tc_Status = "D":U
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-20'You cannot remove budget periods (&2) if the budget structure has already been validated (budget: &1).':255(503)T-20#,t_sBudget.BudgetCode,t_sBudgetPeriod.BudgetPeriodCode)).
<M-5 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetPeriod.BudgetPeriodCode':U (icFieldName),
input t_sBudgetPeriod.BudgetPeriodCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudgetPeriod.tc_Rowid (icRowid),
input 'QADFIN-515':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if t_sBudgetPeriod.tc_Status = "D":U */
if t_sBudgetPeriod.tc_Status = "C":U
then do :
find t_iBudgetPeriod where
t_iBudgetPeriod.tc_Rowid = t_sBudgetPeriod.tc_Rowid
no-lock no-error.
if available t_iBudgetPeriod and
(t_iBudgetPeriod.BudgetPeriodFromDate <> t_sBudgetPeriod.BudgetPeriodFromDate or
t_iBudgetPeriod.BudgetPeriodTillDate <> t_sBudgetPeriod.BudgetPeriodTillDate or
t_iBudgetPeriod.BudgetPeriodSeq <> t_sBudgetPeriod.BudgetPeriodSeq)
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-21'The update of budget periods is limited to the period code (&2); You cannot update the start date, end date, and sequence if the structure of the budget (&1) has been validated.':255(504)t-21#,t_sBudget.BudgetCode,t_sBudgetPeriod.BudgetPeriodCode)).
<M-6 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetPeriod.BudgetPeriodCode':U (icFieldName),
input t_sBudgetPeriod.BudgetPeriodCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudgetPeriod.tc_Rowid (icRowid),
input 'QADFIN-516':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* available t_iBudgetPeriod and */
end. /* if t_sBudgetPeriod.tc_Status = "C":U */
if t_sBudgetPeriod.tc_Status = "N":U
then do :
find bBudgetPeriod where
bBudgetPeriod.tc_ParentRowid = t_sBudget.tc_Rowid and
bBudgetPeriod.BudgetPeriodSeq = t_sBudgetPeriod.BudgetPeriodSeq - 1 and
bBudgetPeriod.tc_Status <> "D":U
no-lock no-error.
if not available bBudgetPeriod
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-22'A new budget period (code: &1, sequence: &2) should be consecutive to the previous budget period.':200(505)T-22#,t_sBudgetPeriod.BudgetPeriodCode,string(t_sBudgetPeriod.BudgetPeriodSeq))) + chr(10) +
trim(substitute(#T-23'Budget code: &1.':255(506)T-23#,t_sBudget.BudgetCode)).
<M-7 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetPeriod.BudgetPeriodCode':U (icFieldName),
input t_sBudgetPeriod.BudgetPeriodCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudgetPeriod.tc_Rowid (icRowid),
input 'QADFIN-518':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if not available bBudgetPeriod */
else if bBudgetPeriod.BudgetPeriodFromDate <> t_sBudgetPeriod.BudgetPeriodTillDate + 1
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-24'A new budget period (code: &1, start date: &2) should be consecutive to the previous budget period (code: &3, end date: &4).':200(507)T-24#,t_sBudgetPeriod.BudgetPeriodCode,string(t_sBudgetPeriod.BudgetPeriodFromDate),bBudgetPeriod.BudgetPeriodCode,string(bBudgetPeriod.BudgetPeriodTillDate))) + chr(10) +
trim(substitute(#T-25'Budget code: &1.':255(506)T-25#,t_sBudget.BudgetCode)).
<M-8 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetPeriod.BudgetPeriodCode':U (icFieldName),
input t_sBudgetPeriod.BudgetPeriodCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudgetPeriod.tc_Rowid (icRowid),
input 'QADFIN-519':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if bBudgetPeriod.BudgetPeriodFromDate <> t_sBudgetPeriod.BudgetPeriodTillDate + 1 */
end. /* if t_sBudgetPeriod.tc_Status = "N":U */
end. /* for each t_sBudgetPeriod where */
/* ============================================================ */
/* Perform BudgetCompany checks if no errors where detected yet */
/* ============================================================ */
if oiReturnStatus <> 0
then next.
<Q-11 run CompanySSByCompanyIDCodeSSType (Start) in BCompany >
for each t_sBudgetCompany where
t_sBudgetCompany.tc_ParentRowid = t_sBudget.tc_Rowid and
(t_sBudgetCompany.tc_Status = "C":U or
t_sBudgetCompany.tc_Status = "N":U)
no-lock :
assign vcMessage = "":U.
<Q-10 run CompanySSByCompanyIDCodeSSType (all) (Read) (Cache)
(input t_sBudgetCompany.Company_ID, (CompanyId)
input ?, (SharedSetType)
input ?, (CompanyCode)
output dataset tqCompanySSByCompanyIDCodeSSType) in BCompany >
find first tqCompanySSByCompanyIDCodeSSType where
tqCompanySSByCompanyIDCodeSSType.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-GL}
no-lock no-error.
if t_sBudget.GLSharedSet_ID <> 0 and
available tqCompanySSByCompanyIDCodeSSType and
tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID <> t_sBudget.GLSharedSet_ID
then do :
assign oiReturnStatus = -3
vcMessage = trim(substitute(#T-26'The GL shared set of entity &1 differs from the GL shared set of the other entities.':255(508)t-26#,tqCompanySSByCompanyIDCodeSSType.tcCompanyCode)).
end. /* if available tqCompanySSByCompanyIDCodeSSType */
find first tqCompanySSByCompanyIDCodeSSType where
tqCompanySSByCompanyIDCodeSSType.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-DIVISION}
no-lock no-error.
if t_sBudget.DivisionSharedSet_ID <> 0 and
available tqCompanySSByCompanyIDCodeSSType and
tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID <> t_sBudget.DivisionSharedSet_ID
then do :
assign oiReturnStatus = -3
vcMessage = trim(substitute(#T-27'The sub-account shared set of entity &1 differs from the sub-account shared set of entity &2.':255(460)t-27#,tqCompanySSByCompanyIDCodeSSType.tcCompanyCode)).
end. /* if available tqCompanySSByCompanyIDCodeSSType */
find first tqCompanySSByCompanyIDCodeSSType where
tqCompanySSByCompanyIDCodeSSType.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-PROJECT}
no-lock no-error.
if t_sBudget.ProjectSharedSet_ID <> 0 and
available tqCompanySSByCompanyIDCodeSSType and
tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID <> t_sBudget.ProjectSharedSet_ID
then do :
assign oiReturnStatus = -3
vcMessage = trim(substitute(#T-28'The project shared set of entity &1 differs from the project shared set of entity &2.':255(461)t-28#,tqCompanySSByCompanyIDCodeSSType.tcCompanyCode)).
end. /* if available tqCompanySSByCompanyIDCodeSSType */
find first tqCompanySSByCompanyIDCodeSSType where
tqCompanySSByCompanyIDCodeSSType.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-COSTCENTRE}
no-lock no-error.
if t_sBudget.CostCentreSharedSet_ID <> 0 and
available tqCompanySSByCompanyIDCodeSSType and
tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID <> t_sBudget.ProjectSharedSet_ID
then do :
assign oiReturnStatus = -3
vcMessage = trim(substitute(#T-29'The cost center shared set of entity &1 differs from the cost center shared set of entity &2.':255(462)t-29#,tqCompanySSByCompanyIDCodeSSType.tcCompanyCode)).
end. /* if available tqCompanySSByCompanyIDCodeSSType */
if vcMessage <> "":U
then do :
assign oiReturnStatus = -1.
<M-13 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetCompany.tcCompanyCode':U (icFieldName),
input t_sBudgetCompany.tcCompanyCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudgetCompany.tc_Rowid (icRowid),
input 'QADFIN-517':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if vcMessage */
end. /* for each t_sBudgetCompany where */
<Q-12 run CompanySSByCompanyIDCodeSSType (Stop) in BCompany >
end. /* for each t_sBudget where */
/* ========================================================================================================= */
/* For budgets that had status=Operational when loaded: only the ETC-data of the WBS-records can be modified */
/* ========================================================================================================= */
for each t_sBudget where
t_sBudget.tc_Status <> "D":U and
t_sBudget.BudgetStatus = {&BUDGETSTATUS-OPERATIONAL}
no-lock :
/* ======================== */
/* Get the original version */
/* ======================== */
find t_iBudget where
t_iBudget.tc_Rowid = t_sBudget.tc_Rowid
no-lock no-error.
/* ================================ */
/* skip records for furhter testing */
/* ================================ */
if not available t_iBudget or
t_iBudget.BudgetStatus <> {&BUDGETSTATUS-OPERATIONAL}
then next.
if not can-find (first t_sBudgetWBS where
t_sBudgetWBS.tc_ParentRowid = t_sBudget.tc_Rowid and
(t_sBudgetWBS.tc_Status = "C":U or
t_sBudgetWBS.tc_Status = "D":U))
then next.
/* ================================================================================ */
/* Check all changed t_sBudgetWBS-records and compare with the previous version of it */
/* ================================================================================ */
for each t_sBudgetWBS where
t_sBudgetWBS.tc_ParentRowid = t_sBudget.tc_Rowid and
t_sBudgetWBS.tc_Status = "C":U no-lock ,
each t_iBudgetWBS where
t_iBudgetWBS.tc_Rowid = t_sBudgetWBS.tc_Rowid no-lock :
BUFFER-COMPARE t_sBudgetWBS
EXCEPT BudgetWBSComment BudgetWBSStatus tdBudgetWBSCommitTC tdBudgetWBSActualTC tc_status BudgetWBSPercOfComp
BudgetWBSCostRevenue BudgetWBSCostType BudgetWBSOverrunTotal BudgetWBSOverrunYTD BudgetWBSOverrunPeriod
BudgetWBSFDSDefault BudgetWBSFDSFromCode BudgetWBSFDSToCode BudgetWBSFDSCode BudgetWBSFDSList
BudgetWBSTopicDescription BudgetWBSCategory BudgetWBSIsPrintDesc BudgetWBSIsHideOnReport BudgetWBSIsInvertBase
BudgetWBSIsRollUp BudgetWBSIsWithSumLine tcBudgetWBSSeqStr
TO t_iBudgetWBS
SAVE vlBudgetWBSIsTheSame.
if vlBudgetWBSIsTheSame <> true
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-30'Only the ETC and linking information of WBS nodes (&1) can be updated for operational budgets (&2).':255(13753)T-30#,t_sBudgetWBS.BudgetWBSCode,t_sBudget.BudgetCode)).
<M-14 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetWBS.BudgetWBSCode':U (icFieldName),
input t_sBudgetWBS.BudgetWBSCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudgetWBS.tc_Rowid (icRowid),
input 'QADFIN-568':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if vlBudgetWBSIsTheSame <> true */
end. /* for each t_sBudgetWBS where */
/* =========================================== */
/* Check all deleted t_sBudgetWBS-records */
/* =========================================== */
for each t_sBudgetWBS where
t_sBudgetWBS.tc_ParentRowid = t_sBudget.tc_Rowid and
t_sBudgetWBS.tc_Status = "D":U NO-LOCK:
if oiReturnStatus >= 0 then assign oiReturnStatus = +1.
assign vcMessage = trim(substitute(#T-31'Warning. When you have removed the WBS nodes (&1) from an operational budget (&2), you may have to rebuild the budget.':255(13823)t-31#,t_sBudgetWBS.BudgetWBSCode,t_sBudget.BudgetCode)).
<M-15 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetWBS.BudgetWBSCode':U (icFieldName),
input t_sBudgetWBS.BudgetWBSCode (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sBudgetWBS.tc_Rowid (icRowid),
input 'QADFIN-591':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
END. /* for each t_sBudgetWBS where */
end. /* for each t_sBudget where */
if oiReturnStatus < 0
then return.