project QadFinancials > class BCashReport > method RecalculateGLTypeCodeCreditorAmounts
Parameters
iiGLDivisionID | input | integer | |
iiGLByCodeGL_ID | input | integer | |
itLastPostingDate | input | date | |
itPeriodEndDate | input | date | vtPeriodEndDate: End date of the period (see calling method( |
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-4 run CInvoiceByControlGL (Start) in BCInvoice >
<Q-5 run CInvoiceMovementByDate (Start) in BCInvoice >
/********************************************************************************************/
/* Get all the Creditor 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-8 run CInvoiceByControlGL (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input iiGLDivisionID, (DivisionID)
input itLastPostingDate, (FromClosingDate)
input iiGLByCodeGL_ID, (GLID)
input {&MOVEMENTTYPE-INITIAL}, (MovementType)
input itLastIntervalDate, (ToDueDate)
input itLastPostingDate, (ToPostingDate)
output dataset tqCInvoiceByControlGL) in BCInvoice >
for each tqCInvoiceByControlGL :
if tCashReportGL.CashReportGLCurrencyView = {&CURRENCYTYPE-TC} and
tqCInvoiceByControlGL.tiCInvoiceCurrency_ID <> iiCashReportGLCurrency_ID
then next.
if iiGLDivisionID <> 0 and
iiGLDivisionID <> ? and
tqCInvoiceByControlGL.tiDivision_ID <> iiGLDivisionID
then next.
assign vdInvoiceBalanceLC = tqCInvoiceByControlGL.tdCInvoiceBalanceDebitLC
- tqCInvoiceByControlGL.tdCInvoiceBalanceCreditLC
vdInvoiceBalanceTC = tqCInvoiceByControlGL.tdCInvoiceBalanceDebitTC
- tqCInvoiceByControlGL.tdCInvoiceBalanceCreditTC
vdInvoiceBalanceCC = tqCInvoiceByControlGL.tdCInvoiceBalanceDebitCC
- tqCInvoiceByControlGL.tdCInvoiceBalanceCreditCC.
/************************************************************************************/
/* 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-9 run CInvoiceMovementByDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input itLastPostingDate, (FromPostingDate)
input tqCInvoiceByControlGL.tiCInvoice_ID, (InvoiceID)
output dataset tqCInvoiceMovementByDate) in BCInvoice >
for each tqCInvoiceMovementByDate :
if tCashReportGL.CashReportGLCurrencyView = {&CURRENCYTYPE-TC} and
tqCInvoiceMovementByDate.tiCurrency_ID <> iiCashReportGLCurrency_ID
then next.
assign vdInvoiceBalanceLC = vdInvoiceBalanceLC
+ (tqCInvoiceMovementByDate.tdPostingLineDebitLC
- tqCInvoiceMovementByDate.tdPostingLineCreditLC) * -1
vdInvoiceBalanceTC = vdInvoiceBalanceTC
+ (tqCInvoiceMovementByDate.tdPostingLineDebitTC
- tqCInvoiceMovementByDate.tdPostingLineCreditTC) * -1
vdInvoiceBalanceCC = vdInvoiceBalanceCC
+ (tqCInvoiceMovementByDate.tdPostingLineDebitCC
- tqCInvoiceMovementByDate.tdPostingLineCreditCC) * -1.
end. /* for each tqCInvoiceMovementByDate */
end. /* if itLastPostingDate > itPeriodEndDate */
for each tCashReportGLLine where
tCashReportGLLine.tc_Status <> 'D':U and
tCashReportGLLine.tc_ParentRowid = icCashReportGLRowid and
tCashReportGLLine.CashReportGLLineDate >= tqCInvoiceByControlGL.ttCInvoiceDueDate and
tCashReportGLLine.CashReportGLLineCurrView = icCashReportGLCurrencyView
by tCashReportGLLine.CashReportGLLineSeq:
if tCashReportGL.CashReportGLCurrencyView = {&CURRENCYTYPE-TC} and
tCashReportGLLine.Currency_ID <> iiCashReportGLCurrency_ID
then next.
/* Decrease the receivables with the predicted Creditor payment. */
assign tCashReportGLLine.CashReportGLLineLC = tCashReportGLLine.CashReportGLLineLC
+ vdInvoiceBalanceLC
tCashReportGLLine.CashReportGLLineTC = tCashReportGLLine.CashReportGLLineTC
+ vdInvoiceBalanceTC
tCashReportGLLine.CashReportGLLineCC = tCashReportGLLine.CashReportGLLineCC
+ vdInvoiceBalanceCC.
leave.
end.
end. /* for each tqCInvoiceByControlGL */
if (ilCashReportGLIsCumul)
then do:
<M-10 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-6 run CInvoiceByControlGL (Stop) in BCInvoice >
<Q-7 run CInvoiceMovementByDate (Stop) in BCInvoice >
/* 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.