Parameters
Internal usage
QadFinancials
program code (program3/bexpensenote.p)
empty temp-table tProposedAdvanceLink.
/* LBO 22.8.2005 - Issue 1.7.
for each t_sAdvances:
find first tExpNoteCInvoice where tExpNoteCInvoice.CInvoice_ID = t_sAdvances.tiCInvoice_ID no-error.
if available tExpNoteCInvoice
then assign t_sAdvances.tdOnExpNoteTC = tExpNoteCInvoice.ExpNoteCInvoiceDeductTC.
end.
*/
if ilCleanOnExpNoteTC
then for each t_sAdvances:
assign t_sAdvances.tdOnExpNoteTC = 0.
end.
EXPNOTELINE_BLOCK:
for each t_sExpNoteLineRef where
t_sExpNoteLineRef.ExpNoteLineAmountTC <> 0
by t_sExpNoteLineRef.tcCurrencyCode
by t_sExpNoteLineRef.ExpNoteLineDate
by t_sExpNoteLineRef.ExpNoteLine_ID:
if t_sExpNoteLineRef.ExpNoteLineType = {&EXPENSENOTELINETYPE-DEDUCTIBLE}
then do:
assign vdTotalCompensationTC = 0.
for each t_sAdvances where
t_sAdvances.tcAdvanceCurrencyCode = t_sExpNoteLineRef.tcCurrencyCode and
t_sAdvances.tdOpenBalanceTC - t_sAdvances.tdOnExpNoteTC - t_sAdvances.tdToReturnTC >= 0
by t_sAdvances.ttAdvanceDate:
if t_sExpNoteLineRef.ExpNoteLineAmountTC - vdTotalCompensationTC < 0
then do:
next EXPNOTELINE_BLOCK.
end.
/* create proposed link and update deducted amount */
create tProposedAdvanceLink.
assign tProposedAdvanceLink.tiAdvanceYear = t_sAdvances.tiAdvanceYear
tProposedAdvanceLink.tcAdvanceJournal = t_sAdvances.tcAdvanceJournal
tProposedAdvanceLink.tiAdvanceVoucher = t_sAdvances.tiAdvanceVoucher
tProposedAdvanceLink.tiExpNoteLine_ID = t_sExpNoteLineRef.ExpNoteLine_ID
tProposedAdvanceLink.tiCInvoice_ID = t_sAdvances.tiCInvoice_ID
tProposedAdvanceLink.ttAdvanceDate = t_sAdvances.ttAdvanceDate
tProposedAdvanceLink.tcAdvanceCurrencyCode = t_sAdvances.tcAdvanceCurrencyCode
tProposedAdvanceLink.tdAdvanceExchangeRateTCLC = t_sAdvances.tdAdvanceExchangeRateTCLC
tProposedAdvanceLink.tdAdvanceExchangeRateScaleTCLC = t_sAdvances.tdAdvanceExchangeRateScaleTCLC
tProposedAdvanceLink.tdAmountTC = if (t_sAdvances.tdOpenBalanceTC - t_sAdvances.tdOnExpNoteTC - t_sAdvances.tdToReturnTC) > (t_sExpNoteLineRef.ExpNoteLineAmountTC - vdTotalCompensationTC)
then t_sExpNoteLineRef.ExpNoteLineAmountTC - vdTotalCompensationTC
else t_sAdvances.tdOpenBalanceTC - t_sAdvances.tdOnExpNoteTC - t_sAdvances.tdToReturnTC
tProposedAdvanceLink.tdAmountLC = if t_sExpNoteLineRef.tcCurrencyCode = vcCompanyLC
then tProposedAdvanceLink.tdAmountTC
else tProposedAdvanceLink.tdAmountTC
* tProposedAdvanceLink.tdAdvanceExchangeRateTCLC
* tProposedAdvanceLink.tdAdvanceExchangeRateScaleTCLC
tProposedAdvanceLink.tdAmountLC = /*round(tProposedAdvanceLink.tdAmountLC, viCompanyLCDec).*/
<M-1 RoundAmount
(input tProposedAdvanceLink.tdAmountLC (idUnroundedAmount),
input viCompanyLCid (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>.
assign t_sAdvances.tdOnExpNoteTC = t_sAdvances.tdOnExpNoteTC + tProposedAdvanceLink.tdAmountTC
vdTotalCompensationTC = vdTotalCompensationTC + tProposedAdvanceLink.tdAmountTC
t_sAdvances.tdUnexplainedTC = if t_sAdvances.tlAdvanceReturnRest
then t_sAdvances.tdOpenBalanceTC - t_sAdvances.tdToReturnTC - t_sAdvances.tdOnExpNoteTC
else 0.
/*
if tProposedAdvanceLink.tdAmountTC = 0
then do:
delete tProposedAdvanceLink.
end.
*/
if t_sExpNoteLineRef.ExpNoteLineAmountTC <= vdTotalCompensationTC
then do:
next EXPNOTELINE_BLOCK.
end.
end. /* for each t_sAdvance */
end. /* type deductible */
end. /* for each t_sExpNoteLineRef */