project QadFinancials > class BBudget > method ApiCheckBudgetMessages

Description

This method will check LTE amount/quantity, LTD amount/quantity, Period amount/quantity and raise errors/warning based on figures.


Parameters


icWBSTotalCallerReferenceinputcharacterWBSTotalCallerReference: Current action authors
idWBSTotalTCinputdecimalWBSTotalTC: Current action amount
idWBSTotalQTYinputdecimalWBSTotalQTY: Current action quantity
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBudget.ApiCheckBudget


program code (program8/bbudget.p)

/* ============================================== */
/* Prerequisites :                                */
/* Available records: tBudgetCheckInfo            */
/*                    tBudgetCheckInfoWBS         */
/*                    tBudgetMail (optional)      */
/* ============================================== */

assign oiReturnStatus = -98.

/* ==================================== */
/* Check LTE Amount                     */
/* ==================================== */
if tBudgetCheckInfoWBS.tcBudgetWBSOverrunTotal <> {&BUDGETOVERRUN-NONE} and 
   tBudgetCheckInfoWBS.tdAmountBudgetLTE < tBudgetCheckInfoWBS.tdAmountActualLTE + tBudgetCheckInfoWBS.tdAmountCommitLTE + idWBSTotalTC
then do :
    assign vcMessage = trim(substitute(#T-7'The LTE amount of the budget has been exceeded (&1/&2).':255(469)T-7#,tBudgetCheckInfoWBS.tcBudgetWBSCode,tBudgetCheckInfoWBS.tcBudgetCode)) + chr(10) + 
                       trim(substitute(#T-8'Budget: &1.':255(470)T-8#,string(tBudgetCheckInfoWBS.tcBudgetCode))) + chr(10) + 
                       trim(substitute(#T-9'Budget WBS: &1.':255(471)T-9#,string(tBudgetCheckInfoWBS.tcBudgetWBSCode))) + chr(10) + 
                       trim(substitute(#T-10'Budgeted amount: &1.':255(472)T-10#,string(tBudgetCheckInfoWBS.tdAmountBudgetLTE))) + chr(10) + 
                       trim(substitute(#T-11'Actual amount: &1.':255(473)T-11#,string(tBudgetCheckInfoWBS.tdAmountActualLTE))) + chr(10) + 
                       trim(substitute(#T-12'Committed amount: &1.':255(474)T-12#,string(tBudgetCheckInfoWBS.tdAmountCommitLTE))) + chr(10) + 
                       trim(substitute(#T-13'Current action amount: &1.':255(475)T-13#,string(idWBSTotalTC))) + chr(10) + 
                       trim(substitute(#T-14'Current action authors: &1.':255(476)T-14#,string(icWBSTotalCallerReference))).
    <M-1 run SetMessage (input  vcMessage (icMessage),
                         input  '':U (icArguments),
                         input  '':U (icFieldName),
                         input  '':U (icFieldValue),
                         input  (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunTotal = {&BUDGETOVERRUN-ERROR} then 'E':U else 'W':U) (icType),
                         input  3 (iiSeverity),
                         input  '':U (icRowid),
                         input  'QADFIN-3332':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
    if (oiReturnStatus = -98 or oiReturnStatus >= 0)
    then assign oiReturnStatus = (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunTotal = {&BUDGETOVERRUN-ERROR} then -1 else 1).
    /* update e-mailbody */
    if available tBudgetMail and 
       ((oiReturnStatus < 0 and tBudgetCheckInfoWBS.tlBudgetIsSendError) or
        (oiReturnStatus > 0 and tBudgetCheckInfoWBS.tlBudgetIsSendWarning))
    then assign tBudgetMail.tcBudgetMailBody = tBudgetMail.tcBudgetMailBody + vcMessage + chr(10) + chr(10).
end. /* if */


/* ==================================== */
/* Check LTE Quantity                   */
/* ==================================== */
if tBudgetCheckInfoWBS.tcBudgetWBSOverrunTotal <> {&BUDGETOVERRUN-NONE} and 
   tBudgetCheckInfoWBS.tdQtyBudgetLTE < tBudgetCheckInfoWBS.tdQtyActualLTE + tBudgetCheckInfoWBS.tdQtyCommitLTE + idWBSTotalQTY
then do :
    assign vcMessage = trim(substitute(#T-15'The LTE quantity of the budget has been exceeded (&1/&2).':255(477)T-15#,tBudgetCheckInfoWBS.tcBudgetWBSCode,tBudgetCheckInfoWBS.tcBudgetCode)) + chr(10) + 
                       trim(substitute(#T-16'Budget: &1.':255(470)T-16#,string(tBudgetCheckInfoWBS.tcBudgetCode))) + chr(10) + 
                       trim(substitute(#T-17'Budget WBS: &1.':255(471)T-17#,string(tBudgetCheckInfoWBS.tcBudgetWBSCode))) + chr(10) + 
                       trim(substitute(#T-18'Budgeted quantity: &1.':255(478)T-18#,string(tBudgetCheckInfoWBS.tdQtyBudgetLTE))) + chr(10) + 
                       trim(substitute(#T-19'Actual quantity: &1.':255(479)T-19#,string(tBudgetCheckInfoWBS.tdQtyActualLTe))) + chr(10) + 
                       trim(substitute(#T-20'Committed quantity: &1.':255(480)T-20#,string(tBudgetCheckInfoWBS.tdQtyCommitLTE))) + chr(10) + 
                       trim(substitute(#T-21'Current action quantity: &1.':255(481)T-21#,string(idWBSTotalQTY))) + chr(10) + 
                       trim(substitute(#T-22'Current action authors: &1.':255(482)T-22#,string(icWBSTotalCallerReference))).
    <M-2 run SetMessage
          (input  vcMessage (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunTotal = {&BUDGETOVERRUN-ERROR} then 'E':U else 'W':U) (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-3333':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BBudget>
    if (oiReturnStatus = -98 or oiReturnStatus >= 0)
    then assign oiReturnStatus = (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunTotal = {&BUDGETOVERRUN-ERROR} then -1 else 1).
    /* update e-mailbody */
    if available tBudgetMail and 
       ((oiReturnStatus < 0 and tBudgetCheckInfoWBS.tlBudgetIsSendError) or
        (oiReturnStatus > 0 and tBudgetCheckInfoWBS.tlBudgetIsSendWarning))
    then assign tBudgetMail.tcBudgetMailBody = tBudgetMail.tcBudgetMailBody + vcMessage + chr(10) + chr(10).
end. /* if */


/* ==================================== */
/* Check LTD Amount                     */
/* ==================================== */
if tBudgetCheckInfoWBS.tcBudgetWBSOverrunYTD <> {&BUDGETOVERRUN-NONE} and 
   tBudgetCheckInfoWBS.tdAmountBudgetLTD < tBudgetCheckInfoWBS.tdAmountActualLTD + tBudgetCheckInfoWBS.tdAmountCommitLTD + idWBSTotalTC
then do :
    assign vcMessage = trim(substitute(#T-23'The LTD amount of the budget has been exceeded (&1/&2).':255(483)T-23#,tBudgetCheckInfoWBS.tcBudgetWBSCode,tBudgetCheckInfoWBS.tcBudgetCode)) + chr(10) + 
                       trim(substitute(#T-24'Budget: &1.':255(470)T-24#,string(tBudgetCheckInfoWBS.tcBudgetCode))) + chr(10) + 
                       trim(substitute(#T-25'Budget WBS: &1.':255(471)T-25#,string(tBudgetCheckInfoWBS.tcBudgetWBSCode))) + chr(10) + 
                       trim(substitute(#T-26'Budgeted amount: &1.':255(472)T-26#,string(tBudgetCheckInfoWBS.tdAmountBudgetLTD))) + chr(10) + 
                       trim(substitute(#T-27'Actual amount: &1.':255(473)T-27#,string(tBudgetCheckInfoWBS.tdAmountActualLTD))) + chr(10) + 
                       trim(substitute(#T-28'Committed amount: &1.':255(474)T-28#,string(tBudgetCheckInfoWBS.tdAmountCommitLTD))) + chr(10) + 
                       trim(substitute(#T-29'Current action amount: &1.':255(475)T-29#,string(idWBSTotalTC))) + chr(10) + 
                       trim(substitute(#T-30'Current action authors: &1.':255(476)T-30#,string(icWBSTotalCallerReference))).
    <M-3 run SetMessage (input  vcMessage (icMessage),
                 input  '':U (icArguments),
                 input  '':U (icFieldName),
                 input  '':U (icFieldValue),
                 input  (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunYTD = {&BUDGETOVERRUN-ERROR} then 'E':U else 'W':U) (icType),
                 input  3 (iiSeverity),
                 input  '':U (icRowid),
                 input  'QADFIN-3334':U (icFcMsgNumber),
                 input  '' (icFcExplanation),
                 input  '' (icFcIdentification),
                 input  '' (icFcContext),
                 output viFcReturnSuper (oiReturnStatus)) in BBudget>
    if (oiReturnStatus = -98 or oiReturnStatus >= 0)
    then assign oiReturnStatus = (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunYTD = {&BUDGETOVERRUN-ERROR} then -1 else 1).
    /* update e-mailbody */
    if available tBudgetMail and 
       ((oiReturnStatus < 0 and tBudgetCheckInfoWBS.tlBudgetIsSendError) or
        (oiReturnStatus > 0 and tBudgetCheckInfoWBS.tlBudgetIsSendWarning))
    then assign tBudgetMail.tcBudgetMailBody = tBudgetMail.tcBudgetMailBody + vcMessage + chr(10) + chr(10).
end. /* if */


/* ==================================== */
/* Check LTD Quantity                   */
/* ==================================== */
if tBudgetCheckInfoWBS.tcBudgetWBSOverrunYTD <> {&BUDGETOVERRUN-NONE} and 
   tBudgetCheckInfoWBS.tdQtyBudgetLTD < tBudgetCheckInfoWBS.tdQtyActualLTD + tBudgetCheckInfoWBS.tdQtyCommitLTD + idWBSTotalQTY
then do :
    assign vcMessage = trim(substitute(#T-31'The LTD quantity of the budget has been exceeded (&1/&2).':255(484)T-31#,tBudgetCheckInfoWBS.tcBudgetWBSCode,tBudgetCheckInfoWBS.tcBudgetCode)) + chr(10) + 
                       trim(substitute(#T-32'Budget: &1.':255(470)T-32#,string(tBudgetCheckInfoWBS.tcBudgetCode))) + chr(10) + 
                       trim(substitute(#T-33'Budget WBS: &1.':255(471)T-33#,string(tBudgetCheckInfoWBS.tcBudgetWBSCode))) + chr(10) + 
                       trim(substitute(#T-34'Budgeted quantity: &1.':255(478)T-34#,string(tBudgetCheckInfoWBS.tdQtyBudgetLTD))) + chr(10) + 
                       trim(substitute(#T-35'Actual quantity: &1.':255(479)T-35#,string(tBudgetCheckInfoWBS.tdQtyActualLTD))) + chr(10) + 
                       trim(substitute(#T-36'Committed quantity: &1.':255(480)T-36#,string(tBudgetCheckInfoWBS.tdQtyCommitLTD))) + chr(10) + 
                       trim(substitute(#T-37'Current action quantity: &1.':255(481)T-37#,string(idWBSTotalQTY))) + chr(10) + 
                       trim(substitute(#T-38'Current action authors: &1.':255(482)T-38#,string(icWBSTotalCallerReference))).
    <M-4 run SetMessage (input  vcMessage (icMessage),
                         input  '':U (icArguments),
                         input  '':U (icFieldName),
                         input  '':U (icFieldValue),
                         input  (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunYTD = {&BUDGETOVERRUN-ERROR} then 'E':U else 'W':U) (icType),
                         input  3 (iiSeverity),
                         input  '':U (icRowid),
                         input  'QADFIN-3335':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
    if (oiReturnStatus = -98 or oiReturnStatus >= 0)
    then assign oiReturnStatus = (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunYTD = {&BUDGETOVERRUN-ERROR} then -1 else 1).
    /* update e-mailbody */
    if available tBudgetMail and 
       ((oiReturnStatus < 0 and tBudgetCheckInfoWBS.tlBudgetIsSendError) or
        (oiReturnStatus > 0 and tBudgetCheckInfoWBS.tlBudgetIsSendWarning))
    then assign tBudgetMail.tcBudgetMailBody = tBudgetMail.tcBudgetMailBody + vcMessage + chr(10) + chr(10).
end. /* if */


/* ==================================== */
/* Check Period Amount                  */
/* ==================================== */
if tBudgetCheckInfoWBS.tcBudgetWBSOverrunPeriod <> {&BUDGETOVERRUN-NONE} and 
   tBudgetCheckInfoWBS.tdAmountBudgetPeriod < tBudgetCheckInfoWBS.tdAmountActualPeriod + tBudgetCheckInfoWBS.tdAmountCommitPeriod + idWBSTotalTC
then do :
    assign vcMessage = trim(substitute(#T-39'The period amount of the budget has been exceeded (&1/&2).':255(485)T-39#,tBudgetCheckInfoWBS.tcBudgetWBSCode,tBudgetCheckInfoWBS.tcBudgetCode)) + chr(10) + 
                       trim(substitute(#T-40'Budget: &1.':255(470)T-40#,string(tBudgetCheckInfoWBS.tcBudgetCode))) + chr(10) + 
                       trim(substitute(#T-41'Budget WBS: &1.':255(471)T-41#,string(tBudgetCheckInfoWBS.tcBudgetWBSCode))) + chr(10) + 
                       trim(substitute(#T-42'Budgeted amount: &1.':255(472)T-42#,string(tBudgetCheckInfoWBS.tdAmountBudgetPeriod))) + chr(10) + 
                       trim(substitute(#T-43'Actual amount: &1.':255(473)T-43#,string(tBudgetCheckInfoWBS.tdAmountActualPeriod))) + chr(10) + 
                       trim(substitute(#T-44'Committed amount: &1.':255(474)T-44#,string(tBudgetCheckInfoWBS.tdAmountCommitPeriod))) + chr(10) + 
                       trim(substitute(#T-45'Current action amount: &1.':255(475)T-45#,string(idWBSTotalTC))) + chr(10) + 
                       trim(substitute(#T-46'Current action authors: &1.':255(476)T-46#,string(icWBSTotalCallerReference))).
    <M-5 run SetMessage (input  vcMessage (icMessage),
                         input  '':U (icArguments),
                         input  '':U (icFieldName),
                         input  '':U (icFieldValue),
                         input  (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunPeriod = {&BUDGETOVERRUN-ERROR} then 'E':U else 'W':U) (icType),
                         input  3 (iiSeverity),
                         input  '':U (icRowid),
                         input  'QADFIN-3336':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
    if (oiReturnStatus = -98 or oiReturnStatus >= 0)
    then assign oiReturnStatus = (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunPeriod = {&BUDGETOVERRUN-ERROR} then -1 else 1).
    /* update e-mailbody */
    if available tBudgetMail and 
       ((oiReturnStatus < 0 and tBudgetCheckInfoWBS.tlBudgetIsSendError) or
        (oiReturnStatus > 0 and tBudgetCheckInfoWBS.tlBudgetIsSendWarning))
    then assign tBudgetMail.tcBudgetMailBody = tBudgetMail.tcBudgetMailBody + vcMessage + chr(10) + chr(10).
end. /* if */


/* ==================================== */
/* Check Period Quantity                */
/* ==================================== */
if tBudgetCheckInfoWBS.tcBudgetWBSOverrunPeriod <> {&BUDGETOVERRUN-NONE} and 
   tBudgetCheckInfoWBS.tdQtyBudgetPeriod < tBudgetCheckInfoWBS.tdQtyActualPeriod + tBudgetCheckInfoWBS.tdQtyCommitPeriod + idWBSTotalQTY
then do :
    assign vcMessage = trim(substitute(#T-47'The period quantity of the budget has been exceeded (&1/&2).':255(486)T-47#,tBudgetCheckInfoWBS.tcBudgetWBSCode,tBudgetCheckInfoWBS.tcBudgetCode)) + chr(10) + 
                       trim(substitute(#T-48'Budget: &1.':255(470)T-48#,string(tBudgetCheckInfoWBS.tcBudgetCode))) + chr(10) + 
                       trim(substitute(#T-49'Budget WBS: &1.':255(471)T-49#,string(tBudgetCheckInfoWBS.tcBudgetWBSCode))) + chr(10) + 
                       trim(substitute(#T-50'Budgeted quantity: &1.':255(478)T-50#,string(tBudgetCheckInfoWBS.tdQtyBudgetPeriod))) + chr(10) + 
                       trim(substitute(#T-51'Actual quantity: &1.':255(479)T-51#,string(tBudgetCheckInfoWBS.tdQtyActualPeriod))) + chr(10) + 
                       trim(substitute(#T-52'Committed quantity: &1.':255(480)T-52#,string(tBudgetCheckInfoWBS.tdQtyCommitPeriod))) + chr(10) + 
                       trim(substitute(#T-53'Current action quantity: &1.':255(481)T-53#,string(idWBSTotalQTY))) + chr(10) + 
                       trim(substitute(#T-54'Current action authors: &1.':255(482)T-54#,string(icWBSTotalCallerReference))).
    <M-6 run SetMessage (input  vcMessage (icMessage),
                 input  '':U (icArguments),
                 input  '':U (icFieldName),
                 input  '':U (icFieldValue),
                 input  (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunPeriod = {&BUDGETOVERRUN-ERROR} then 'E':U else 'W':U) (icType),
                 input  3 (iiSeverity),
                 input  '':U (icRowid),
                 input  'QADFIN-3337':U (icFcMsgNumber),
                 input  '' (icFcExplanation),
                 input  '' (icFcIdentification),
                 input  '' (icFcContext),
                 output viFcReturnSuper (oiReturnStatus)) in BBudget>
    if (oiReturnStatus = -98 or oiReturnStatus >= 0)
    then assign oiReturnStatus = (if tBudgetCheckInfoWBS.tcBudgetWBSOverrunPeriod = {&BUDGETOVERRUN-ERROR} then -1 else 1).
    /* update e-mailbody */
    if available tBudgetMail and 
       ((oiReturnStatus < 0 and tBudgetCheckInfoWBS.tlBudgetIsSendError) or
        (oiReturnStatus > 0 and tBudgetCheckInfoWBS.tlBudgetIsSendWarning))
    then assign tBudgetMail.tcBudgetMailBody = tBudgetMail.tcBudgetMailBody + vcMessage + chr(10) + chr(10).
end. /* if */    


if oiReturnStatus = -98
then assign oiReturnStatus = 0.