project QadFinancials > class BCashReport > method RecalculateGLTypeCodeDebtorAmounts
Parameters
iiGLDivisionID | input | integer | |
iiGLByCodeGL_ID | input | integer | |
itLastPostingDate | input | date | |
itPeriodEndDate | input | date | itPeriodEndDate: End date of the period (see calling method for details) |
itLastIntervalDate | input | date | |
iiCashReportCurrency_ID | input | integer | |
icCashReportGLRowid | input | character | |
iiLastActualsSeq | input | integer | |
icCashReportGLCurrencyView | input | character | |
iiCashReportGLCurrency_ID | input | integer | |
icCashReportRowid | input | character | |
iiCashReportNumberOfPeriods | input | integer | |
idCashReportGLAmountLC | input | decimal | |
idCashReportGLAmountTC | input | decimal | |
idCashReportGLAmountCC | input | decimal | |
ilCashReportGLIsCumul | input | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bcashreport.p)
/* Assign the error status to 'Unknown error' */
assign oiReturnStatus = -98.
<Q-3 run DInvoiceByControlGL (Start) in BDInvoice >
<Q-4 run DInvoiceMovementByDate (Start) in BDInvoice >
/********************************************************************************************/
/* Get all the Debtor Invoices that were entered with the specified Debtor Control Account. */
/* Only invoices that were already entered by the ActualsDate and were also still open */
/* after the ActualsDate are taken into consideration. */
/* To further narrow the query, only invoices whose DueDate falls within the range of */
/* the forecast period are considered. */
/********************************************************************************************/
<Q-9 run DInvoiceByControlGL (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input iiGLDivisionID, (DivisionID)
input iiGLByCodeGL_ID, (GLID)
input {&MOVEMENTTYPE-INITIAL}, (MovementType)
input itLastPostingDate, (ToPostingDate)
input itLastIntervalDate, (ToDueDate)
input itLastPostingDate + 1, (FromClosingDate)
output dataset tqDInvoiceByControlGL) in BDInvoice >
for each tqDInvoiceByControlGL :
if tCashReportGL.CashReportGLCurrencyView = {&CURRENCYTYPE-TC} and
tqDInvoiceByControlGL.tiDInvoiceCurrency_ID <> iiCashReportGLCurrency_ID
then next.
if iiGLDivisionID <> 0 and
iiGLDivisionID <> ? and
tqDInvoiceByControlGL.tiDivision_ID <> iiGLDivisionID
then next.
assign
vdInvoiceBalanceLC =
tqDInvoiceByControlGL.tdDInvoiceBalanceDebitLC -
tqDInvoiceByControlGL.tdDInvoiceBalanceCreditLC
vdInvoiceBalanceTC =
tqDInvoiceByControlGL.tdDInvoiceBalanceDebitTC -
tqDInvoiceByControlGL.tdDInvoiceBalanceCreditTC
vdInvoiceBalanceCC =
tqDInvoiceByControlGL.tdDInvoiceBalanceDebitCC -
tqDInvoiceByControlGL.tdDInvoiceBalanceCreditCC.
/************************************************************************************/
/* The Cut-Off period and the optional ActualsDate that were entered by the user */
/* are meant to take a snapshot of the situation at a certain point in time. */
/* Therefore, we need to revert any movements that were made on an invoice during */
/* the forecast period. */
/* For example, a payment that was made during the forecast period (i.e. after the */
/* ActualsDate) will not be shown. Instead, the payment will be "predicted" */
/* to occur at the invoice's DueDate. If the actual payment needs to be shown, */
/* the ActualsDate should be moved to (after) the paydate. */
/************************************************************************************/
if itLastPostingDate > itPeriodEndDate
then do :
<Q-10 run DInvoiceMovementByDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tqDInvoiceByControlGL.tiDInvoice_ID, (InvoiceID)
input itLastPostingDate, (FromPostingDate)
output dataset tqDInvoiceMovementByDate) in BDInvoice >
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
then assign oiReturnStatus = viFcReturnSuper.
for each tqDInvoiceMovementByDate :
if tCashReportGL.CashReportGLCurrencyView = {&CURRENCYTYPE-TC} and
tqDInvoiceMovementByDate.tiCurrency_ID <> iiCashReportCurrency_ID
then next.
assign vdInvoiceBalanceLC = vdInvoiceBalanceLC -
(tqDInvoiceMovementByDate.tdPostingLineDebitLC -
tqDInvoiceMovementByDate.tdPostingLineCreditLC)
vdInvoiceBalanceTC = vdInvoiceBalanceTC -
(tqDInvoiceMovementByDate.tdPostingLineDebitTC -
tqDInvoiceMovementByDate.tdPostingLineCreditTC)
vdInvoiceBalanceCC = vdInvoiceBalanceCC -
(tqDInvoiceMovementByDate.tdPostingLineDebitCC -
tqDInvoiceMovementByDate.tdPostingLineCreditCC).
end. /* for each tqDInvoiceMovementByDate */
end. /* if itLastPostingDate > itPeriodEndDate */
for each tCashReportGLLine where
tCashReportGLLine.tc_Status <> 'D':U and
tCashReportGLLine.tc_ParentRowid = icCashReportGLRowid and
tCashReportGLLine.CashReportGLLineDate >= tqDInvoiceByControlGL.ttDInvoiceDueDate and
tCashReportGLLine.CashReportGLLineCurrView = icCashReportGLCurrencyView
by tCashReportGLLine.CashReportGLLineSeq:
if tCashReportGL.CashReportGLCurrencyView = {&CURRENCYTYPE-TC} and
tCashReportGLLine.Currency_ID <> iiCashReportGLCurrency_ID
then next.
assign tCashReportGLLine.CashReportGLLineLC = tCashReportGLLine.CashReportGLLineLC + vdinvoicebalancelc
tCashReportGLLine.CashReportGLLineTC = tCashReportGLLine.CashReportGLLineTC + vdInvoiceBalanceTC
tCashReportGLLine.CashReportGLLineCC = tCashReportGLLine.CashReportGLLineCC + vdInvoiceBalanceCC.
leave.
end. /* for each tCashReportGLLine where */
end. /* for each tqDInvoiceByControlGL */
if (ilCashReportGLIsCumul)
then do:
<M-11 run ConvertMovementsToBalance
(input icCashReportGLRowid (icParentRowid),
input iiCashReportNumberOfPeriods (iiNumberOfPeriods),
input idCashReportGLAmountLC (idStartBalanceLC),
input idCashReportGLAmountTC (idStartBalanceTC),
input idCashReportGLAmountCC (idStartBalanceCC),
output viFcReturnSuper (oiReturnStatus)) in BCashReport>
end.
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
then assign oiReturnStatus = viFcReturnSuper.
<Q-7 run DInvoiceByControlGL (Stop) in BDInvoice >
<Q-8 run DInvoiceMovementByDate (Stop) in BDInvoice >
/* If the procedure reaches its end correctly and no validation errors were encountered */
/* then assign the return status 'OK' */
if oiReturnStatus = -98 then
assign oiReturnStatus = 0.