project QadFinancials > class BBillReport > method CaculateBalanceOpenItems
Description
This method is also used by first bill. It will calculate the opening balance on the date of mock previous bill. First, get the current opening balance of all invoice in the same customer, currency, bill date and entity, and then minus the posting amount of these invoices from mock previous bill date to current date.
Parameters
iiDebtorId | input | integer | |
iiCurrencyId | input | integer | |
itPreBillDate | input | date | |
odBalance | output | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bbillreport.p)
/* =================================================================================== */
/* Get all open invoices of the debtor */
/* =================================================================================== */
assign vdBalanceTC = 0
vdrollbackbalancetc = 0.
<Q-94 run DInvoiceAfterClosingDate (all) (Read) (NoCache)
(input viBillCompany_ID, (CompanyId)
input iiDebtorId, (DebtorId)
input iiCurrencyId, (CurrencyId)
input itPreBillDate, (AgingDate)
output dataset tqDInvoiceAfterClosingDate) in BBillReport>
for each tqDInvoiceAfterClosingDate
break by tqDInvoiceAfterClosingDate.tiDinvoice_ID:
/* All Invoice Opening Balance */
if tqDInvoiceAfterClosingDate.tcDInvoiceType <> {&INVOICETYPE-ADJUSTMENT} and
tqDInvoiceAfterClosingDate.tcDInvoiceType <> {&INVOICETYPE-DEDUCTION} then
do:
vdBalanceTC = vdBalanceTC + tqDInvoiceAfterClosingDate.tdDInvoiceBalanceDebitTC - tqDInvoiceAfterClosingDate.tdDInvoiceBalanceCreditTC.
<Q-20 run GetDInvoiceMovementByPostDate (all) (Read) (NoCache)
(input viBillCompany_ID, (CompanyId)
input tqDInvoiceAfterClosingDate.tiDInvoice_ID, (DInvoiceId)
input itPreBillDate, (PostDate)
output dataset tqGetDInvoiceMovementByPostDate) in BBillReport>
/* Get the posting movement amount */
for each tqGetDInvoiceMovementByPostDate:
vdrollbackbalancetc = vdrollbackbalancetc + tqGetDInvoiceMovementByPostDate.tdPostingLineDebitTC - tqGetDInvoiceMovementByPostDate.tdPostingLineCreditTC.
end.
end.
end.
assign odBalance = vdBalanceTC - vdrollbackbalancetc.