project QadFinancials > class BDebtorBalance > method RebuildHistoryValidateInputCheckDaemon
Description
RebuildHistoryValidateInputCheckDaemon: submethod of RebuildHistory: method that removes (part of) the history and raises new daemon-requests for the entered selection criteria.
Parameters
bcCompanyCode | input-output | character | |
bcDebtorCode | input-output | character | |
bcCurrencyCode | input-output | character | |
biFromPeriodYear | input-output | integer | |
biFromPeriodPeriod | input-output | integer | |
oiResolvedCompanyID | output | integer | ResolvedCompanyID: Company-ID in case the CompanyCode is filled and it points to a valid company |
oiResolvedDebtorID | output | integer | DebtorID: only filled in case the icCompanyCode and icDebtorCode is filled |
oiResolvedCurrencyID | output | integer | ResolvedCurrencyID: CurrencyID: only filled in case icCurrencyCode is filled |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program8/bdebtorbalance.p)
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* ========================================================================================= */
/* Input parameter validations: */
/* - Company and currency should exist when filled */
/* - Customer wherefor you want to do the rebuild (Optional) */
/* (note that in case icCompanyCode was filled, the customer shoudl exist for that company) */
/* - Period-year from where you want to do the rebuild (Optional) */
/* (note that in case icCompanyCode was filled, the period should exist for that company) */
/* - Period-period from where you want to do the rebuild (Optional) */
/* (note that in case icCompanyCode was filled, the period should exist for that company) */
/* (note that this paramater can only be filled in case period-year was also filled) */
/* ========================================================================================= */
if bcCompanyCode = ? then assign bcCompanyCode = "":U.
if bcDebtorCode = ? then assign bcDebtorCode = "":U.
if bcCurrencyCode = ? then assign bcCurrencyCode = "":U.
if biFromPeriodYear = ? then assign biFromPeriodYear = 0.
if biFromPeriodPeriod = ? then assign biFromPeriodPeriod = 0.
/* ======= */
/* Company */
/* ======= */
if bcCompanyCode <> "":U
then do :
<Q-32 run CompanyPrim (all) (Read) (NoCache)
(input ?, (LookupCompanyId)
input bcCompanyCode, (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
Find tqCompanyPrim no-error.
if not available tqCompanyPrim
then do :
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-47'The specified entity code (&1) is not defined in the system.':255(65582)T-47#,bcCompanyCode)).
<M-33 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7209':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtorBalance>
end. /* if not available tqCompanyPrim */
else assign oiResolvedCompanyID = tqCompanyPrim.tiCompany_ID.
end. /* if icCompanyCode <> "":U */
/* ========= */
/* Debtor */
/* ========= */
if bcDebtorCode <> "":U
then do :
assign vcMessage = "":U.
if bcCompanyCode <> "":U and
available tqCompanyPrim
then do :
<Q-58 run DebtorPrim (all) (Read) (NoCache)
(input tqCompanyPrim.tiCompany_ID, (CompanyId)
input bcDebtorCode, (DebtorCode)
input ?, (Debtor_ID)
output dataset tqDebtorPrim) in BDebtor >
Find tqDebtorPrim no-error. /* no First-option as it should be unique */
if not available tqDebtorPrim
then assign vcMessage = trim(substitute(#T-48'The customer (&1) and the entity code (&2) combination is not defined in the system.':255(65607)T-48#,trim(bcDebtorCode),trim(bcCompanyCode))).
else assign oiResolvedDebtorID = tqDebtorPrim.tiDebtor_ID.
end. /* if bcCompanyCode <> "":U and */
else do :
<Q-60 run DebtorPrim (all) (Read) (NoCache)
(input ?, (CompanyId)
input bcDebtorCode, (DebtorCode)
input ?, (Debtor_ID)
output dataset tqDebtorPrim) in BDebtor >
Find first tqDebtorPrim no-error. /* First-option as it should not be unique */
if not available tqDebtorPrim
then assign vcMessage = trim(substitute(#T-49'The customer (&1) is not defined in the system.':255(65608)T-49#,trim(bcDebtorCode))).
else do:
find tqDebtorPrim no-error.
if available tqDebtorPrim
then assign oiResolvedDebtorID = tqDebtorPrim.tiDebtor_ID.
end. /*ELSE IF NOT AVAILABLE tqDebtorPrim*/
end. /* Not if bcCompanyCode <> "":U and */
if vcMessage <> "":U
then do :
assign viLocalReturnStatus = -1.
<M-36 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7210':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtorBalance>
end. /* if vcMessage <> "":U */
end. /* if bcDebtorCode <> "":U */
/* ========= */
/* Currency */
/* ========= */
assign oiResolvedCurrencyID = 0.
if bcCurrencyCode<> '':U
then do :
<Q-37 run CurrencyPrim (all) (Read) (NoCache)
(input bcCurrencyCode, (CurrencyCode)
input ?, (Currency_ID)
output dataset tqCurrencyPrim) in BCurrency >
Find tqCurrencyPrim no-error.
if not available tqCurrencyPrim
then do :
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-50'The specified currency code $1 is not defined in the system or is invalid.':100(3844)T-50#,bcCurrencyCode)).
<M-38 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7211':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtorBalance>
end. /* if not available tqCompanyPrim */
else assign oiResolvedCurrencyID = tqCurrencyPrim.tiCurrency_ID.
end.
/* ============= */
/* Year - Period */
/* ============= */
if biFromPeriodPeriod <> 0 and
biFromPeriodYear = 0
then do :
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-51'You can only specify a GL period (&1) if the GL calendar year is also specified.':255(65583)T-51#,trim(string(biFromPeriodPeriod)))).
<M-39 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7212':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtorBalance>
end. /* if biFromPeriodPeriod <> 0 and */
else do :
if biFromPeriodYear <> 0
then do :
assign vcMessage = "":U.
if bcCompanyCode <> "":U and
available tqCompanyPrim
then do :
<Q-40 run PeriodPrim (all) (Read) (NoCache)
(input tqCompanyPrim.tiCompany_ID, (CompanyId)
input ?, (PeriodId)
input biFromPeriodYear, (PeriodYear)
input biFromPeriodPeriod, (PeriodPeriod)
output dataset tqPeriodPrim) in BPeriod >
if biFromPeriodPeriod = 0
then do :
Find first tqPeriodPrim no-error.
if not available tqPeriodPrim
then assign vcMessage = trim(substitute(#T-52'The specified combination of the year (&1) and the entity code (&2) is not defined in the system.':255(65589)T-52#,trim(string(biFromPeriodYear)),trim(bcCompanyCode))).
end. /* if biFromPeriodPeriod = 0 */
else do :
Find tqPeriodPrim no-error. /* no First-option as it should be unique */
if not available tqPeriodPrim
then assign vcMessage = trim(substitute(#T-53'The combination of the year period (&1-&2) and the entity code (&3) is not defined in the system. ':255(65586)T-53#,trim(string(biFromPeriodYear)),trim(string(biFromPeriodPeriod)),trim(bcCompanyCode))).
end. /* Not if biFromPeriodPeriod = 0 */
end. /* if bcCompanyCode <> "":U and */
else do :
<Q-41 run PeriodPrim (all) (Read) (NoCache)
(input ?, (CompanyId)
input ?, (PeriodId)
input biFromPeriodYear, (PeriodYear)
input biFromPeriodPeriod, (PeriodPeriod)
output dataset tqPeriodPrim) in BPeriod >
Find first tqPeriodPrim no-error.
if not available tqPeriodPrim
then do :
if biFromPeriodPeriod = 0
then assign vcMessage = trim(substitute(#T-54'The specified GL calendar year (&1) is not defined in the system.':255(65590)T-54#,trim(string(biFromPeriodYear)))).
else assign vcMessage = trim(substitute(#T-55'The specified combination of the year and GL period (&1-&2) is not defined in the system.':255(65591)T-55#,trim(string(biFromPeriodYear)),trim(string(biFromPeriodPeriod)))).
end. /* Not if biFromPeriodPeriod = 0 */
end. /* Not if bcCompanyCode <> "":U and */
if vcMessage <> "":U
then do :
assign viLocalReturnStatus = -1.
<M-42 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7213':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtorBalance>
end. /* if vcMessage <> "":U */
end. /* if biFromPeriodYear <> 0 */
end. /* Not if biFromPeriodPeriod <> 0 and */
/* ================================================================= */
/* Raise an error in case there still are QCinvoiceMovement records */
/* Raise an error in case the daemon is running */
/* ================================================================= */
<Q-61 assign vlFcQueryRecordsAvailable = QDInvoiceMovementByAllFrgnKeys (NoCache)
(input oiResolvedCompanyID, (CompanyId)
input oiResolvedDebtorID, (Debtor)
input oiResolvedCurrencyID, (Currency)
input ?, (Project)
input ?, (CostCentre)
input ?, (Division)
input ?, (GL)
input ?, (Journal)
input ?, (Period)) in BQDInvoiceMovement >
if vlFcQueryRecordsAvailable <> false
then do :
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-56'Cannot start the rebuild. There are current queue records waiting to be processed by the daemon or queue records of incorrectly processed daemon requests.':255(65594)T-56#)).
vcContextInfo = "oiResolvedCompanyID=" + string (oiResolvedCompanyID) +
",oiResolvedDebtorID=" + string (oiResolvedDebtorID) +
",oiResolvedCurrencyID=" + string (oiResolvedCurrencyID).
<M-44 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7214':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContextInfo (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtorBalance>
end. /* if vlFcQueryRecordsAvailable <> false */
<Q-45 assign vlFcQueryRecordsAvailable = DaemonInfoLimited (NoCache)
(input ?, (DaemonId)
input {&BALANCEDAEMON}, (DaemonName)
input ?, (DaemonStatus)
input {&DAEMONSTATUS-INACTIVE}, (DaemonStatusDiffersFrom)) in BBaseDaemon >
if vlFcQueryRecordsAvailable <> false
then do :
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-57'Cannot start the rebuild because the Balance daemon is still running. Stop the Balance daemon.':255(69264)T-57#)).
<M-46 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7215':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtorBalance>
end. /* if vlFcQueryRecordsAvailable <> false */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.