project QadFinancials > class BDebtor > method GetActivityData
Description
This method is called from the UI to populate the data in the Customer Activity Dashboard tabs
Parameters
icCompanyListID | input | character | |
iiDebtorID | input | integer | |
itDInvoiceStartDate | input | date | |
itDInvoiceEndDate | input | date | |
ilDInvoiceIsOpen | input | logical | |
tDInvoicePay | output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdebtor.p)
/* Get some translations upfront */
if vcDocumentStatusDebtors = ? or
vcDocumentStatusDebtors = '':U
then assign vcDocumentStatusDebtors = {&DOCUMENTSTATUSDEBTORS}.
assign vcDDocumentStatusPaiedTr = {&DOCUMENTSTATUS-PAID-TR}.
empty temp-table tDInvoicePay.
if iiDebtorID <> ? and iiDebtorID <> 0 and
icCompanyListID <> ? and icCompanyListID <> '':U
then do:
/* For each on company list to improve performance */
COMPANYBLOCK:
do viCompanyCnt = num-entries(icCompanyListID, ',':U) to 1 by -1:
assign viTempCompanyID = integer(entry(viCompanyCnt, icCompanyListID)) no-error.
if error-status:error
then do:
assign vcMessage = trim(#T-23'Could not retrieve the company ID from the company ID list.':255(65177)T-23#)
oiReturnStatus = -3.
<M-17 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8455':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
leave COMPANYBLOCK.
end.
/* ================================================================================= */
/* 1- Get the Base currency */
/* ================================================================================= */
<Q-94 run CompanyByCodeCurrActiveID (all) (Read) (NoCache)
(input viTempCompanyID, (CompanyId)
input ?, (CompanyCode)
input ?, (CompanyIsActive)
input ?, (CurrencyID)
output dataset tqCompanyByCodeCurrActiveID) in BCompany>
find first tqCompanyByCodeCurrActiveID where
tqCompanyByCodeCurrActiveID.tiCompany_ID = viTempCompanyID
no-error.
if not available tqCompanyByCodeCurrActiveID
then next.
assign vcBaseCurrencyCode = tqCompanyByCodeCurrActiveID.tcCurrencyCode
vcCompanyCodeTemp = tqCompanyByCodeCurrActiveID.tcCompanyCode.
/* ================================================================================= */
/* 2- Get the Customer Payments */
/* ================================================================================= */
<Q-19 run DDocumentByDebtor (all) (Read) (NoCache)
(input viTempCompanyID, (CompanyId)
input iiDebtorID, (DebtorID)
input itDInvoiceStartDate, (PaymentStartDate)
input itDInvoiceEndDate, (PaymentEndDate)
input ?, (DocumentIsOpen)
output dataset tqDDocumentByDebtor) in BDDocument >
/* get all record from tqDDocumentByDebtor and put it into tDInoivcePayment. */
for each tqDDocumentByDebtor:
/* Get translation for document status */
assign vcStatusTr = "":U.
do viA = num-entries(vcDocumentStatusDebtors, chr(2)) to 1 by -2:
if entry(viA, vcDocumentStatusDebtors, chr(2)) = tqDDocumentByDebtor.tcDDocumentStatus
then do:
assign vcStatusTr = entry(viA - 1, vcDocumentStatusDebtors, chr(2)).
leave.
end.
end.
create tDInvoicePay.
assign tDInvoicePay.tcDocumentNumber = tqDDocumentByDebtor.tcDocumentNumber
tDInvoicePay.tcDDocumentReference = tqDDocumentByDebtor.tcDDocumentReference
tDInvoicePay.tcDDocumentStatus = vcStatusTr
tDInvoicePay.ttDDocumentCreationDate = tqDDocumentByDebtor.ttDDocumentCreationDate
tDInvoicePay.ttDDocumentDueDate = tqDDocumentByDebtor.ttDDocumentDueDate
tDInvoicePay.tdPaymentOriginalAmountTC = tqDDocumentByDebtor.tdPaymentOriginalAmountTC
tDInvoicePay.tcCurrencyCode = tqDDocumentByDebtor.tcCurrencyCode
tDInvoicePay.tdOriginalAmountLC = tqDDocumentByDebtor.tdOriginalAmountLC
tDInvoicePay.tdOriginalAmountTC = tqDDocumentByDebtor.tdOriginalAmountTC
tDInvoicePay.tdOriginalAmountCC = tqDDocumentByDebtor.tdOriginalAmountCC
tDInvoicePay.tdOpenAmountLC = tqDDocumentByDebtor.tdOpenAmountLC
tDInvoicePay.tdOpenAmountCC = tqDDocumentByDebtor.tdOpenAmountCC
tDInvoicePay.tdOpenAmountTC = tqDDocumentByDebtor.tdOpenAmountTC
tDInvoicePay.tiOverdueDays = tqDDocumentByDebtor.tiOverdueDays
tDInvoicePay.tiWeekNumbers = tqDDocumentByDebtor.tiWeekNumbers
tDInvoicePay.tdPaymentAmountTC = tqDDocumentByDebtor.tdDDocumentInvoiceXrefAlloTC
tDInvoicePay.tdDiscountAmountTC = tqDDocumentByDebtor.tdDDocumentInvoiceXrefDiscTC
tDInvoicePay.tdInterestAmount = tqDDocumentByDebtor.tdDDocumentInvoiceXrefIntTC
tDInvoicePay.tcDInvoiceNumber = tqDDocumentByDebtor.tcDInvoiceNumber
tDInvoicePay.ttDInvoicePaymentDate = tqDDocumentByDebtor.ttDInvoicePaymentDate
tDInvoicePay.tcDPaySelCode = tqDDocumentByDebtor.tcDPaySelCode
tDInvoicePay.tcDDocumentSubType = tqDDocumentByDebtor.tcDDocumentSubType
tDInvoicePay.tiDDocument_ID = tqDDocumentByDebtor.tiDDocument_ID
tDInvoicePay.tiDPaySel_ID = tqDDocumentByDebtor.tiDPaySel_ID
tDInvoicePay.tcBaseCurrencyCode = vcBaseCurrencyCode
tDInvoicePay.tcDDocumentBankImpRef = tqDDocumentByDebtor.tcDDocumentBankImpRef
tDInvoicePay.tiDInvoice_ID = tqDDocumentByDebtor.tiDInvoice_ID
tDInvoicePay.tcCurrCompanyCode = vcCompanyCodeTemp.
end. /* for each tqDDocumentByDebtor. */
/* ========================================================================================= */
/* 3- Get the Customer Movements/Activities */
/* For Open invoices, we take the index on Open. */
/* For Closed invoices we take the index on date */
/* ========================================================================================= */
<Q-88 run DInvoiceMovementForInvoice (all) (Read) (NoCache)
(input viTempCompanyID, (CompanyId)
input itDInvoiceStartDate, (InvoiceDateFrom)
input itDInvoiceEndDate, (InvoiceDateTo)
input iiDebtorID, (DebtorID)
input (if ildInvoiceIsOpen = true then true else ?), (InvoiceIsOpenEQUALS)
input {&MOVEMENTTYPE-MOVEMENT}, (InvoiceMovementType)
input {&JOURNALTYPE-DEBTORPAYMENT}, (ExcludeJournalType)
input (if ildInvoiceIsOpen = false then true else ?), (InvoiceIsOpenDIFFERSFROM)
output dataset tqDInvoiceMovementForInvoice) in BDInvoice>
/* get all record from tqDInvoiceMovementForInvoice and append them into tDInvoicePay. */
for each tqDInvoiceMovementForInvoice:
create tDInvoicePay.
assign tDInvoicePay.tcDocumentNumber = tqDInvoiceMovementForInvoice.tcDocumentNumber
tDInvoicePay.tcDDocumentReference = tqDInvoiceMovementForInvoice.tcPostingText
tDInvoicePay.tcDDocumentStatus = vcDDocumentStatusPaiedTr
tDInvoicePay.ttDDocumentCreationDate = tqDInvoiceMovementForInvoice.ttPostingDate
tDInvoicePay.ttDDocumentDueDate = tqDInvoiceMovementForInvoice.Ttdinvoiceduedate
tDInvoicePay.tdPaymentOriginalAmountTC = 0 - (tqDInvoiceMovementForInvoice.tdPaymentAmountTC + tqDInvoiceMovementForInvoice.tdDinvoiceMovementDiscountTC)
tDInvoicePay.tcCurrencyCode = tqDInvoiceMovementForInvoice.tcCurrencyCode
tDInvoicePay.tdOriginalAmountLC = tqDInvoiceMovementForInvoice.tdOriginalAmountLC
tDInvoicePay.tdOriginalAmountTC = tqDInvoiceMovementForInvoice.tdOriginalAmountTC
tDInvoicePay.tdOriginalAmountCC = tqDInvoiceMovementForInvoice.tdOriginalAmountCC
tDInvoicePay.tdOpenAmountLC = tqDInvoiceMovementForInvoice.tdDInvoiceBalanceLC
tDInvoicePay.tdOpenAmountTC = tqDInvoiceMovementForInvoice.tdDInvoiceBalanceTC
tDInvoicePay.tdOpenAmountCC = tqDInvoiceMovementForInvoice.tdDInvoiceBalanceCC
tDInvoicePay.tiOverdueDays = tqDInvoiceMovementForInvoice.tiOverdueDays
tDInvoicePay.tiWeekNumbers = tqDInvoiceMovementForInvoice.tiWeekNumbers
tDInvoicePay.tdPaymentAmountTC = tqDInvoiceMovementForInvoice.tdPaymentAmountTC
tDInvoicePay.tdDiscountAmountTC = tqDInvoiceMovementForInvoice.tdDinvoiceMovementDiscountTC
tDInvoicePay.tcDInvoiceNumber = tqDInvoiceMovementForInvoice.tcDInvoiceNumber
tDInvoicePay.ttDInvoicePaymentDate = tqDInvoiceMovementForInvoice.ttDInvoicePaymentDate
tDInvoicePay.tcDPaySelCode = ""
tDInvoicePay.tcDDocumentSubType = ""
tDInvoicePay.tiPosting_ID = tqDInvoiceMovementForInvoice.tiPosting_ID
tDInvoicePay.tcJournalTypeCode = tqDInvoiceMovementForInvoice.tcJournalTypeCode
tDInvoicePay.tiDInvoice_ID = tqDInvoiceMovementForInvoice.tiDInvoice_ID
tDInvoicePay.tcOIAdjustDescription = tqDInvoiceMovementForInvoice.tcOIAdjustDescription
tDInvoicePay.tcBaseCurrencyCode = vcBaseCurrencyCode
tDInvoicePay.tcCurrCompanyCode = vcCompanyCodeTemp.
end. /* for each tqDInvoiceMovementForInvoice. */
end. /* do viCompanyCnt = num-entries(icCompanyListID, ',':U) to 1 by -1: */
end. /* if iiDebtorID <> ? and iiDebtorID <> 0. */