project QadFinancials > class BBudget > method ValidateComponentBudgetLinkFigure
Description
This method will do valdiations once there are actuals and commitments linked to a budget.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bbudget.p)
/* ================================================================================================== */
/* BudgetPeriods cannot be updated/removed once there are actuals/commitments for the budget --> */
/* (Raising the end-date of the last budgetperiod will only result in a warning - others in an error) */
/* BudgetWBS cannot be updated/removed/created once there are actuals/commitments for the budget */
/* Warning in case a BudgetWBSItem is created for a BudgetWBS that already has got actuals/comm. */
/* ================================================================================================== */
/* =============================================================================== */
/* Go through all unchanged and through all changed budgets (skip New and Deleted) */
/* =============================================================================== */
for each t_sBudget where
t_sBudget.tc_Status <> "D":U and
t_sBudget.tc_Status <> "N":U
no-lock :
/* ===================================================================== */
/* Check whether we should continue (continue in case we have any action */
/* on a BudgetWBS and in case we have a changed or deleted BudgetPeriod */
/* ===================================================================== */
assign vlFcQueryRecordsAvailable = false.
if can-find (first t_sBudgetPeriod where
t_sBudgetPeriod.tc_ParentRowid = t_sBudget.tc_Rowid and
(t_sBudgetPeriod.tc_Status = "C":U or
t_sBudgetPeriod.tc_Status = "D":U)) or
can-find (first t_sBudgetWBS where
t_sBudgetWBS.tc_ParentRowid = t_sBudget.tc_Rowid and
t_sBudgetWBS.tc_Status <> "":U)
then do :
<Q-1 assign vlFcQueryRecordsAvailable = BudgetLinkByBudgetPerWBS (NoCache)
(input ?, (BudgetLinkID)
input t_sBudget.Budget_ID, (BudgetID)
input ?, (BudgetWBSID)
input ?, (FromBudgetPeriodID)
input ?, (ToBudgetPeriodID)) in BBudgetLink >
end. /* if can-find */
if vlFcQueryRecordsAvailable = false
then next.
/* ================================ */
/* Error / Warning on the BudgetWBS */
/* ================================ */
Find first t_sBudgetWBS where
t_sBudgetWBS.tc_ParentRowid = t_sBudget.tc_Rowid and
t_sBudgetWBS.tc_Status <> "":U
no-error.
if available t_sBudgetWBS
then do :
if oiReturnStatus >= 0 then assign oiReturnStatus = +1.
assign vcMessage = trim(substitute(#T-18'Warning. Actuals or commitments were found for this budget (&1). You may have to run the budget rebuild after you create, modify, or delete budget WBS nodes (&2).':255(13820)t-18#,t_sBudget.BudgetCode,t_sBudgetWBS.BudgetWBSCode)).
<M-17 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-3055':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if av t_sBudgetWBS */
/* ===================================== */
/* Errors on deleted BudgetPeriod */
/* ===================================== */
find first t_sBudgetPeriod where
t_sBudgetPeriod.tc_ParentRowid = t_sBudget.tc_Rowid and
t_sBudgetPeriod.tc_Status = "D":U
no-error.
if available t_sBudgetPeriod
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-10'Actuals or commitments were found for this budget (&1). The system was unable to delete budget period nodes (&2).':255(589)t-10#,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-2869':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if av t_sBudgetPeriod */
/* ===================================== */
/* Errors on changed BudgetPeriod */
/* ===================================== */
for each t_sBudgetPeriod where
t_sBudgetPeriod.tc_ParentRowid = t_sBudget.tc_Rowid and
t_sBudgetPeriod.tc_Status = "C":U ,
each t_iBudgetPeriod where
t_iBudgetPeriod.tc_Rowid = t_sBudgetPeriod.tc_Rowid :
if t_sBudgetPeriod.BudgetPeriodCode <> t_iBudgetPeriod.BudgetPeriodCode or
t_sBudgetPeriod.BudgetPeriodSeq <> t_iBudgetPeriod.BudgetPeriodSeq or
t_sBudgetPeriod.BudgetPeriodFromDate <> t_iBudgetPeriod.BudgetPeriodFromDate or
t_sBudgetPeriod.BudgetPeriodTillDate < t_iBudgetPeriod.BudgetPeriodTillDate
then do :
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-11'Actuals or commitments found for this budget (&1): for the budget period nodes, you can only modify the end date of the last period into a later date.':255(590)T-11#,t_sBudget.BudgetCode)) + chr(10) +
trim(substitute(#T-12'Budget period: &1.':200(591)T-12#,t_sBudgetPeriod.BudgetPeriodCode)).
<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-2871':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if t_sBudgetPeriod.BudgetPeriodCode = t_iBudgetPeriod.BudgetPeriodCode and */
end. /* for each t_sBudgetPeriod where */
/* ===================================== */
/* Hold the highest seq for next checks */
/* ===================================== */
assign viHighestBudgetPeriodSeq = 0.
for each t_sBudgetPeriod where
t_sBudgetPeriod.tc_ParentRowid = t_sBudget.tc_Rowid and
t_sBudgetPeriod.tc_Status <> "D":U :
if t_sBudgetPeriod.BudgetPeriodSeq > viHighestBudgetPeriodSeq
then assign viHighestBudgetPeriodSeq = t_sBudgetPeriod.BudgetPeriodSeq.
end. /* for each t_sBudgetPeriod where */
for each t_iBudgetPeriod where
t_iBudgetPeriod.tc_ParentRowid = t_sBudget.tc_Rowid,
each t_sBudgetPeriod where
t_sBudgetPeriod.tc_Rowid = t_iBudgetPeriod.tc_Rowid and
t_sBudgetPeriod.tc_Status <> "D":U :
if t_sBudgetPeriod.BudgetPeriodSeq > viHighestBudgetPeriodSeq
then assign viHighestBudgetPeriodSeq = t_sBudgetPeriod.BudgetPeriodSeq.
end. /* for each t_sBudgetPeriod where */
/* ============================================= */
/* Warnings on changes on the last BudgetPeriod */
/* ============================================= */
for each t_sBudgetPeriod where
t_sBudgetPeriod.BudgetPeriodSeq = viHighestBudgetPeriodSeq and
t_sBudgetPeriod.tc_Status = "C":U,
each t_iBudgetPeriod where
t_iBudgetPeriod.tc_Rowid = t_sBudgetPeriod.tc_Rowid :
if t_sBudgetPeriod.BudgetPeriodCode = t_iBudgetPeriod.BudgetPeriodCode and
t_sBudgetPeriod.BudgetPeriodSeq = t_iBudgetPeriod.BudgetPeriodSeq and
t_sBudgetPeriod.BudgetPeriodFromDate = t_iBudgetPeriod.BudgetPeriodFromDate and
t_sBudgetPeriod.BudgetPeriodTillDate > t_iBudgetPeriod.BudgetPeriodTillDate
then do :
if oiReturnStatus >= 0 then assign oiReturnStatus = +1.
assign vcMessage = trim(substitute(#T-13'Warning. You modified the end date of the last budget period (&1) to a later date although the budget already has actuals or commitments. You must rebuild the budget (&2) to ensure the actuals and commitments are correct.':255(592)t-13#,trim(t_sBudgetPeriod.BudgetPeriodCode),trim(t_sBudget.BudgetCode))) + chr(10) +
trim(#T-14'Are you sure you want to save your changes?':255(593)T-14#).
<M-7 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetPeriod.BudgetPeriodCode':U (icFieldName),
input t_sBudgetPeriod.BudgetPeriodCode (icFieldValue),
input 'W':U (icType),
input 4 (iiSeverity),
input t_sBudgetPeriod.tc_Rowid (icRowid),
input 'QADFIN-2870':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* if t_sBudgetPeriod.BudgetPeriodCode = t_iBudgetPeriod.BudgetPeriodCode and */
end. /* for each t_sBudgetPeriod where */
end. /* for each t_sBudget */