project QadFinancials > class BBudget > method BudgetCheckInfoResolveReadDB
Description
This submethod of method BudgetCheckInfoResolve will read all required budgets: result = tBudgetByBudgetIDCodeStatus and return in case there are no budgets read.
Parameters
ilOnlyHandleCommitOnlineBudgets | input | logical | OnlyHandleCommitOnlineBudgets |
ilOnlyHandleActualOnlineBudgets | input | logical | OnlyHandleActualOnlineBudgets |
ilCalledFromBudgetCheck | input | logical | CalledFromBudgetCheck |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program8/bbudget.p)
/* ===================================================================== */
/* Return in case no info is passed of the system does not allow budgets */
/* Empty output temp-table */
/* ===================================================================== */
empty temp-table tBudgetByBudgetIDCodeStatus.
if not can-find (first tBudgetCheckInfo) or
vlSysPropertyIsWithBudget = false or
(ilCalledFromBudgetCheck = true and
vlSysPropertyIsBudOLCheckGL = false and
vlSysPropertyIsBudOLCheckPrj = false and
vlSysPropertyIsBudOLCheckCC = false)
then do :
assign oiReturnStatus = 0.
return.
end. /* if not can-find (first tBudgetCheckInfo) */
/* ============================================================= */
/* Auto assign the BudgetCheckInfoID in case they are all empty */
/* ============================================================= */
if not can-find (first tBudgetCheckInfo where
tBudgetCheckInfo.tiBudgetCheckInfoID <> 0 and
tBudgetCheckInfo.tiBudgetCheckInfoID <> ?)
then for each tBudgetCheckInfo :
assign viCounter = viCounter + 1
tBudgetCheckInfo.tiBudgetCheckInfoID = viCounter.
end. /* for each */
/* ========================================================================================= */
/* Read the budgets based on the system-settings for OL-check (if started from budget-check) */
/* Read the budgets based on the input-table and on the existing budgets (all cases) */
/* ========================================================================================= */
/* =========== */
/* Global */
/* =========== */
/* Set flag default true */
assign vlIncludeGlobalBudgets = true.
/* Turn flag off in case no ol-check is needed */
if (ilCalledFromBudgetCheck = true and
vlSysPropertyIsBudOLCheckGL = false)
then assign vlIncludeGlobalBudgets = false.
/* Turn flag off in case there are no global budgets */
if vlIncludeGlobalBudgets = true
then do :
<Q-3 assign vlFcQueryRecordsAvailable = BudgetByBudgetIDCodeStatus (NoCache)
(input ?, (BudgetID)
input ?, (BudgetCode)
input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
input ?, (CompanyId)
input ?, (ProjectCode)
input ?, (CostCentreCode)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleActualOnlineBudgets = true then true else ?), (BudgetIsCheckActualOnLine)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleCommitOnlineBudgets = true then true else ?), (BudgetIsCheckCommitOnLine)
input ?, (BudgetIsAutoRollUp)
input ?, (ProjectID)
input ?, (CostCentreID)
input {&BUDGETTYPE-GLOBAL}, (BudgetType)) in BBudget >
if vlFcQueryRecordsAvailable = false
then assign vlIncludeGlobalBudgets = false.
end. /* if vlIncludeGlobalBudgets = true */
/* Action1: no global budgets are handled */
if vlIncludeGlobalBudgets = false
then for each tBudgetCheckInfo where
(tBudgetCheckInfo.tiProjectID = ? or
tBudgetCheckInfo.tiProjectID = 0) and
(tBudgetCheckInfo.tiCostCentreID = ? or
tBudgetCheckInfo.tiCostCentreID = 0) :
delete tBudgetCheckInfo.
end. /* for each */
/* Action2: read all global budgets */
else do :
<Q-6 run BudgetByBudgetIDCodeStatus (all) (Read) (NoCache)
(input ?, (BudgetID)
input ?, (BudgetCode)
input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
input ?, (CompanyId)
input ?, (ProjectCode)
input ?, (CostCentreCode)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleActualOnlineBudgets = true then true else ?), (BudgetIsCheckActualOnLine)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleCommitOnlineBudgets = true then true else ?), (BudgetIsCheckCommitOnLine)
input ?, (BudgetIsAutoRollUp)
input ?, (ProjectID)
input ?, (CostCentreID)
input {&BUDGETTYPE-GLOBAL}, (BudgetType)
output dataset tqBudgetByBudgetIDCodeStatus) in BBudget >
for each tqBudgetByBudgetIDCodeStatus no-lock :
/* Read the companies that are linked to the budget and only continue in case one of these linked companies matches one of the companies in the input temp-table (tBudgetCheckInfo) */
assign vlLinkedCompanyFound = false.
<Q-17 run BudgetCompanyByBudgetID (all) (Read) (NoCache)
(input ?, (CompanyId)
input tqBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID)
output dataset tqBudgetCompanyByBudgetID) in BBudget >
for each tqBudgetCompanyByBudgetID :
if can-find (first tBudgetCheckInfo where
tBudgetCheckInfo.tiCompanyId = tqBudgetCompanyByBudgetID.tiCompany_ID)
then do :
assign vlLinkedCompanyFound = true.
Leave.
end. /* if can-find (first tqBudgetCompanyByBudgetID where */
end. /* for each tqBudgetCompanyByBudgetID */
if vlLinkedCompanyFound = false
then next.
/* Create a record in the resulting temp-table of this method */
create tBudgetByBudgetIDCodeStatus.
buffer-copy tqBudgetByBudgetIDCodeStatus to tBudgetByBudgetIDCodeStatus.
end. /* for each tqBudgetByBudgetIDCodeStatus */
end. /* if vlIncludeGlobalBudgets = true */
/* =========== */
/* Project */
/* =========== */
if not can-find (first tBudgetCheckInfo where
tBudgetCheckInfo.tiProjectID <> 0 and
tBudgetCheckInfo.tiProjectID <> ?)
then assign vlIncludeProjectBudgets = false.
else do :
/* Set flag default true */
assign vlIncludeProjectBudgets = true.
/* Turn flag off in case no ol-check is needed */
if (ilCalledFromBudgetCheck = true and
vlSysPropertyIsBudOLCheckPrj = false)
then assign vlIncludeProjectBudgets = false.
/* Turn flag off in case there are no Project budgets */
if vlIncludeProjectBudgets = true
then do :
<Q-7 assign vlFcQueryRecordsAvailable = BudgetByBudgetIDCodeStatus (NoCache) (input ?, (BudgetID)
input ?, (BudgetCode)
input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
input ?, (CompanyId)
input ?, (ProjectCode)
input ?, (CostCentreCode)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleActualOnlineBudgets = true then true else ?), (BudgetIsCheckActualOnLine)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleCommitOnlineBudgets = true then true else ?), (BudgetIsCheckCommitOnLine)
input ?, (BudgetIsAutoRollUp)
input ?, (ProjectID)
input ?, (CostCentreID)
input {&BUDGETTYPE-PROJECT}, (BudgetType)) in BBudget >
if vlFcQueryRecordsAvailable = false
then assign vlIncludeProjectBudgets = false.
end. /* if vlIncludeProjectBudgets = true */
/* Action1: no Project budgets are handled */
if vlIncludeProjectBudgets = false
then do :
if vlIncludeGlobalBudgets = false /* only remove them in case they cannot be used for global-budgets as well */
then for each tBudgetCheckInfo where
tBudgetCheckInfo.tiProjectID <> 0 and
tBudgetCheckInfo.tiProjectID <> ? :
delete tBudgetCheckInfo.
end. /* for each */
end. /* if vlIncludeProjectBudgets = false */
/* Action2: read all Project budgets */
else do :
/* For every project separately: Read the budget if it was not yet read */
for each tBudgetCheckInfo where
tBudgetCheckInfo.tiProjectID <> 0 and
tBudgetCheckInfo.tiProjectID <> ?:
/* Avoid duplicates */
if can-find (first tBudgetByBudgetIDCodeStatus where
tBudgetByBudgetIDCodeStatus.tiProject_ID = tBudgetCheckInfo.tiProjectID)
then next.
/* db-read */
empty temp-table tqBudgetByBudgetIDCodeStatus.
<Q-8 run BudgetByBudgetIDCodeStatus (all) (Read) (NoCache)
(input ?, (BudgetID)
input ?, (BudgetCode)
input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
input ?, (CompanyId)
input ?, (ProjectCode)
input ?, (CostCentreCode)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleActualOnlineBudgets = true then true else ?), (BudgetIsCheckActualOnLine)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleCommitOnlineBudgets = true then true else ?), (BudgetIsCheckCommitOnLine)
input ?, (BudgetIsAutoRollUp)
input tBudgetCheckInfo.tiProjectID, (ProjectID)
input ?, (CostCentreID)
input {&BUDGETTYPE-PROJECT}, (BudgetType)
output dataset tqBudgetByBudgetIDCodeStatus) in BBudget >
/* tBudgetByBudgetIDCodeStatus must contains all the read budgets */
for each tqBudgetByBudgetIDCodeStatus no-lock :
create tBudgetByBudgetIDCodeStatus.
buffer-copy tqBudgetByBudgetIDCodeStatus to tBudgetByBudgetIDCodeStatus.
end. /* for each tqBudgetByBudgetIDCodeStatus */
end. /* for each tBudgetCheckInfo where */
end. /* if vlIncludeProjectBudgets = true */
end. /* Not if not can-find (first tBudgetCheckInfo where */
/* =========== */
/* CostCentre */
/* =========== */
if not can-find (first tBudgetCheckInfo where
tBudgetCheckInfo.tiCostCentreID <> 0 and
tBudgetCheckInfo.tiCostCentreID <> ?)
then assign vlIncludeCostCentreBudgets = false.
else do :
/* Set flag default true */
assign vlIncludeCostCentreBudgets = true.
/* Turn flag off in case no ol-check is needed */
if (ilCalledFromBudgetCheck = true and
vlSysPropertyIsBudOLCheckCC = false)
then assign vlIncludeCostCentreBudgets = false.
/* Turn flag off in case there are no CostCentre budgets */
if vlIncludeCostCentreBudgets = true
then do :
<Q-9 assign vlFcQueryRecordsAvailable = BudgetByBudgetIDCodeStatus (NoCache) (input ?, (BudgetID)
input ?, (BudgetCode)
input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
input ?, (CompanyId)
input ?, (ProjectCode)
input ?, (CostCentreCode)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleActualOnlineBudgets = true then true else ?), (BudgetIsCheckActualOnLine)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleCommitOnlineBudgets = true then true else ?), (BudgetIsCheckCommitOnLine)
input ?, (BudgetIsAutoRollUp)
input ?, (ProjectID)
input ?, (CostCentreID)
input {&BUDGETTYPE-COSTCENTRE}, (BudgetType)) in BBudget >
if vlFcQueryRecordsAvailable = false
then assign vlIncludeCostCentreBudgets = false.
end. /* if vlIncludeCostCentreBudgets = true */
/* Action1: no CostCentre budgets are handled */
if vlIncludeCostCentreBudgets = false
then do :
if vlIncludeGlobalBudgets = false /* only remove them in case they cannot be used for global-budgets as well */
then for each tBudgetCheckInfo where
tBudgetCheckInfo.tiCostCentreID <> 0 and
tBudgetCheckInfo.tiCostCentreID <> ? :
delete tBudgetCheckInfo.
end. /* for each */
end. /* if vlIncludeCostCentreBudgets = false */
/* Action2: read all CostCentre budgets */
else do :
/* For every Costcentre separately: Read the budget if it was not yet read */
for each tBudgetCheckInfo where
tBudgetCheckInfo.tiCostCentreID <> 0 and
tBudgetCheckInfo.tiCostCentreID <> ? :
/* Avoid duplicates */
if can-find (first tBudgetByBudgetIDCodeStatus where
tBudgetByBudgetIDCodeStatus.tiCostCentre_ID = tBudgetCheckInfo.tiCostCentreID)
then next.
/* db-read */
empty temp-table tqBudgetByBudgetIDCodeStatus.
<Q-10 run BudgetByBudgetIDCodeStatus (all) (Read) (NoCache)
(input ?, (BudgetID)
input ?, (BudgetCode)
input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
input ?, (CompanyId)
input ?, (ProjectCode)
input ?, (CostCentreCode)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleActualOnlineBudgets = true then true else ?), (BudgetIsCheckActualOnLine)
input (if ilCalledFromBudgetCheck = true and ilOnlyHandleCommitOnlineBudgets = true then true else ?), (BudgetIsCheckCommitOnLine)
input ?, (BudgetIsAutoRollUp)
input ?, (ProjectID)
input tBudgetCheckInfo.tiCostCentreID, (CostCentreID)
input {&BUDGETTYPE-COSTCENTRE}, (BudgetType)
output dataset tqBudgetByBudgetIDCodeStatus) in BBudget >
/* tBudgetByBudgetIDCodeStatus must contains all the read budgets */
for each tqBudgetByBudgetIDCodeStatus no-lock :
create tBudgetByBudgetIDCodeStatus.
buffer-copy tqBudgetByBudgetIDCodeStatus to tBudgetByBudgetIDCodeStatus.
end. /* for each tqBudgetByBudgetIDCodeStatus */
end. /* for each tBudgetCheckInfo where */
end. /* if vlIncludeCostCentreBudgets = true */
end. /* Not if not can-find (first tBudgetCheckInfo where */