Description
Add code here to initialize the calculated fields of the class temp-tables after loading existing records from the application database.
Parameters
oiReturnStatus | output | integer | |
Internal usage
QadFinancials
program code (program/bexpensenote.p)
<ANCESTOR-CODE>
for each tExpNote where tExpNote.ExpNoteStatusCode = {&EXPENSENOTESTATUS-OPEN}:
if tExpNote.Currency_ID <> ? and
tExpNote.Currency_ID <> 0
then do:
find first tCachedExchangeRate where
tCachedExchangeRate.tiFromCurrency_ID = viCompanyLCId and
tCachedExchangeRate.tiToCurrency_ID = tExpNote.Currency_ID and
tCachedExchangeRate.tcExchangeRateType = {&EXCHANGERATETYPE-CASH} and
tCachedExchangeRate.ttDate = today
no-error.
if not available tCachedExchangeRate
then do:
<M-94 run GetExchangeRate
(input tExpNote.Company_ID (iiCompanyID),
input viCompanyLCId (iiFromCurrencyID),
input ? (icFromCurrencyCode),
input tExpNote.Currency_ID (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-CASH} (icExchangeRateTypeCode),
input today (itValidityDate),
output vdMultiplyExchangeRate (odExchangeRate),
output vdExchangeRateScaleFactor (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BExpenseNote>
create tCachedExchangeRate.
assign tCachedExchangeRate.tiFromCurrency_ID = viCompanyLCId
tCachedExchangeRate.tiToCurrency_ID = tExpNote.Currency_ID
tCachedExchangeRate.tcExchangeRateType = {&EXCHANGERATETYPE-CASH}
tCachedExchangeRate.ttDate = today
tCachedExchangeRate.tdExchangeRateScaleFactor = vdExchangeRateScaleFactor
tCachedExchangeRate.tdMultiplyExchangeRate = vdMultiplyExchangeRate.
end.
assign tExpNote.ExpNoteRateLCXC = tCachedExchangeRate.tdMultiplyExchangeRate
tExpNote.ExpNoteRateScale = tCachedExchangeRate.tdExchangeRateScaleFactor.
end.
end.
assign vlQueryStarted = false.
for each tExpNoteLine:
if not tExpNoteLine.ExpNoteLineIsProvenRate and
tExpNoteLine.Currency_ID <> ? and
tExpNoteLine.Currency_ID <> 0 and
can-find(first tExpNote where tExpNote.ExpNote_ID = tExpNoteLine.ExpNote_ID and
tExpNote.ExpNoteStatusCode = {&EXPENSENOTESTATUS-OPEN})
then do:
find first tCachedExchangeRate where
tCachedExchangeRate.tiFromCurrency_ID = tExpNoteLine.Currency_ID and
tCachedExchangeRate.tiToCurrency_ID = viCompanyLCId and
tCachedExchangeRate.tcExchangeRateType = {&EXCHANGERATETYPE-CASH} and
tCachedExchangeRate.ttDate = if tExpNoteLine.ExpNoteLineDate = ? then today else tExpNoteLine.ExpNoteLineDate
no-error.
if not available tCachedExchangeRate
then do:
<M-85 run GetExchangeRate
(input tExpNote.Company_ID (iiCompanyID),
input tExpNoteLine.Currency_ID (iiFromCurrencyID),
input ? (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-CASH} (icExchangeRateTypeCode),
input if tExpNoteLine.ExpNoteLineDate = ? then today else tExpNoteLine.ExpNoteLineDate (itValidityDate),
output vdMultiplyExchangeRate (odExchangeRate),
output vdExchangeRateScaleFactor (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BExpenseNote>
create tCachedExchangeRate.
assign tCachedExchangeRate.tiFromCurrency_ID = tExpNoteLine.Currency_ID
tCachedExchangeRate.tiToCurrency_ID = viCompanyLCId
tCachedExchangeRate.tcExchangeRateType = {&EXCHANGERATETYPE-CASH}
tCachedExchangeRate.ttDate = if tExpNoteLine.ExpNoteLineDate = ? then today else tExpNoteLine.ExpNoteLineDate
tCachedExchangeRate.tdExchangeRateScaleFactor = vdExchangeRateScaleFactor
tCachedExchangeRate.tdMultiplyExchangeRate = vdMultiplyExchangeRate.
end.
assign tExpNoteLine.ExpNoteLineLCRate = tCachedExchangeRate.tdMultiplyExchangeRate
tExpNoteLine.ExpNoteLineLCScale = tCachedExchangeRate.tdExchangeRateScaleFactor.
end.
/* SAF */
find first tExpNoteLineSaf
where tExpNoteLineSaf.ExpNoteLine_ID = tExpNoteLine.ExpNoteLine_ID and
tExpNoteLineSaf.SafStructure_ID <> ? and
tExpNoteLineSaf.SafStructure_ID <> 0
no-error.
if available tExpNoteLineSaf
then do:
<Q-8 run SafStructurePrim (all) (Read) (NoCache)
(input tExpNoteLineSaf.SafStructure_ID, (SafStructureID)
input ?, (SafStructureCode)
output dataset tqSafStructurePrim) in BSafStructure >
find first tqSafStructurePrim no-error.
if available tqSafStructurePrim
then assign tExpNoteLine.tcSafStructureCode = tqSafStructurePrim.tcSafStructureCode.
end.
for each tExpNoteLineSaf where tExpNoteLineSaf.ExpNoteLine_ID = tExpNoteLine.ExpNoteLine_ID:
<Q-9 run SafPrim (all) (Read) (NoCache)
(input tExpNoteLineSaf.Saf_ID, (SafID)
input ?, (SafCode)
input ?, (SafConceptCode)
output dataset tqSafPrim) in BSaf >
find first tqSafPrim no-error.
if available tqSafPrim
then do:
case tExpNoteLineSaf.ExpNoteLineSafInputSeq:
when 1 then assign tExpNoteLine.tcSAFCode1 = tqSafPrim.tcSafCode
tExpNoteLine.tcSAFConcept1 = tqSafPrim.tcSafConceptCode.
when 2 then assign tExpNoteLine.tcSAFCode2 = tqSafPrim.tcSafCode
tExpNoteLine.tcSAFConcept2 = tqSafPrim.tcSafConceptCode.
when 3 then assign tExpNoteLine.tcSAFCode3 = tqSafPrim.tcSafCode
tExpNoteLine.tcSAFConcept3 = tqSafPrim.tcSafConceptCode.
when 4 then assign tExpNoteLine.tcSAFCode4 = tqSafPrim.tcSafCode
tExpNoteLine.tcSAFConcept4 = tqSafPrim.tcSafConceptCode.
when 5 then assign tExpNoteLine.tcSAFCode5 = tqSafPrim.tcSafCode
tExpNoteLine.tcSAFConcept5 = tqSafPrim.tcSafConceptCode.
end case.
end.
end.
if tExpNoteLine.tcGLCode <> "":U and
tExpNoteLine.tcGLCode <> ? and
tExpNoteLine.tcGLCode <> "?":U
then do:
<Q-10 run GLByCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tExpNoteLine.tcGLCode, (GLCode)
output dataset tqGLByCode) in BGL >
find first tqGLByCode no-error.
if available tqGLByCode
then assign tExpNoteLine.tlGLIsDivisionAccount = tqGLByCode.tlGLIsDivisionAccount.
else assign tExpNoteLine.tlGLIsDivisionAccount = true.
end.
else assign tExpNoteLine.tlGLIsDivisionAccount = true.
end.