project QadFinancials > class BDebtor > method ApiGetCustomerInvoicePastDueTotal
Parameters
icDebtorCode | input | character | |
icCurrencyCode | input | character | |
odPastDueTotal | output | decimal | |
odFixedCreditLimit | output | decimal | |
odTurnoverCreditLimit | output | decimal | |
odARBalance | output | decimal | |
odOpenOrdersBalance | output | decimal | |
olCustomerOnCreditHold | output | logical | |
ocCreditRating | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bdebtor.p)
assign
odFixedCreditLimit = 0
odTurnoverCreditLimit = 0
odARBalance = 0
odOpenOrdersBalance = 0
olCustomerOnCreditHold = false
ocCreditRating = "":U
odPastDueTotal = 0
oiReturnStatus = -98.
<Q-16 run DebtorByCreditLimitInfo (all) (Read) (NoCache)
(input viCompanyID, (CompanyId)
input ?, (DebtorId)
input icDebtorCode, (DebtorCode)
output dataset tqDebtorByCreditLimitInfo) in BDebtor >
for first tqDebtorByCreditLimitInfo
where tqDebtorByCreditLimitInfo.tcDebtorCode = icDebtorCode:
/* Maximum Days Overdue check */
if tqDebtorByCreditLimitInfo.tlDebtorIsMaxDaysDueCredLim
then do:
assign
odPastDueTotal = 0
vdInvoiceTotal = 0
vdDinvoiceStageBalance = 0
vtMaxDueDate = today - tqDebtorByCreditLimitInfo.tiDebtorMaxNumDaysCredLim.
<Q-22 run DInvoiceByDebtorIsOpen (all) (Read) (NoCache)
(input ?, (CompanyId)
input tqDebtorByCreditLimitInfo.tiDebtor_ID, (DebtorId)
input true, (DInvoiceIsOpen)
input ?, (DInvoiceType)
output dataset tqDInvoiceByDebtorIsOpen) in BDInvoice >
for each tqDInvoiceByDebtorIsOpen where
tqDInvoiceByDebtorIsOpen.tiDebtor_ID = tqDebtorByCreditLimitInfo.tiDebtor_ID and
tqDInvoiceByDebtorIsOpen.tlDInvoiceIsOpen = true
by tqDInvoiceByDebtorIsOpen.ttDInvoiceDueDate:
if (vtMaxDueDate > tqDInvoiceByDebtorIsOpen.TTDINVOICEDUEDATE)
then do:
if tqDInvoiceByDebtorIsOpen.tcCurrencyCode = icCurrencyCode
then
assign
odPastDueTotal = odPastDueTotal + tqDInvoiceByDebtorIsOpen.tdDInvoiceBalanceTC.
else do:
if not vlStart1
then do:
<Q-23 run CompanyPropertyByCompany (Start) in BCompanyProperty >
assign vlStart1 = true.
end.
<Q-24 run CompanyPropertyByCompany (all) (Read) (NoCache)
(input tqDInvoiceByDebtorIsOpen.tiCompany_ID, (CompanyId)
input ?, (CompanyCode)
input ?, (CurrencyCode)
output dataset tqCompanyPropertyByCompany) in BCompanyProperty >
find first tqCompanyPropertyByCompany
where tqCompanyPropertyByCompany.tiCompany_ID = tqDInvoiceByDebtorIsOpen.tiCompany_ID
no-error.
if available tqCompanyPropertyByCompany and
tqCompanyPropertyByCompany.tcCurrencyCode = tqDInvoiceByDebtorIsOpen.tcCurrencyCode
then
assign odPastDueTotal = odPastDueTotal + tqDInvoiceByDebtorIsOpen.tdDInvoiceBalanceLC.
else do:
<M-72 run GetExchangeRate
(input viCompanyId (iiCompanyID),
input ? (iiFromCurrencyID),
input tqDInvoiceByDebtorIsOpen.tcCurrencyCode (icFromCurrencyCode),
input ? (iiToCurrencyID),
input icCurrencyCode (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input today (itValidityDate),
output vdRate (odExchangeRate),
output vdRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
assign odPastDueTotal = odPastDueTotal +
<M-26 RoundAmount
(input tqDInvoiceByDebtorIsOpen.tdDInvoiceBalanceTC * vdRate * vdRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in business>.
end. /* end if available tqCompanyPropertyByCompany*/
end. /* different currency */
end. /* if tqDInvoiceByDebtorIsOpen.tcCurrencyCode = icCurrencyCode */
end. /* for first */
end. /* if max cred lim days*/
end. /* end tqDebtorByCreditLimitInfo */
if not available(tqDebtorByCreditLimitInfo)
then do:
assign
vcMessageText = trim(#T-28'The specified customer $1 is not defined in the system or is invalid.':255(69145)t-28#).
oiReturnStatus = -1.
<M-27 run SetMessage
(input vcMessageText (icMessage),
input icDebtorCode (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-8271':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
end. /* end no customer found */
/* Call ApiGetCreditData method to get other information */
<M-29 run ApiGetCreditData
(input icDebtorCode (icDebtorCode),
input icCurrencyCode (icCurrencyCode),
output odFixedCreditLimit (odFixedCreditLimit),
output odTurnoverCreditLimit (odTurnoverCreditLimit),
output odARBalance (odARBalance),
output odOpenOrdersBalance (odOpenOrdersBalance),
output olCustomerOnCreditHold (olCustomerOnCreditHold),
output ocCreditRating (ocCreditRating),
output viFcReturnSuper (oiReturnStatus)) in BDebtor>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
if oiReturnStatus = -98
then assign oiReturnStatus = 0.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
define temp-table ttContext no-undo
field propertyQualifier as character
field propertyName as character
field propertyValue as character
index entityContext is primary unique
propertyQualifier
propertyName
index propertyQualifier
propertyQualifier.
define dataset dsContext for ttContext.
define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.
/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
ttContext.propertyValue = "BDebtor".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiGetCustomerInvoicePastDueTotal".
create ttContext.
assign ttContext.propertyName = "applicationId"
ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
ttContext.propertyValue = "".
/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bdebtor.apigetcustomerinvoicepastduetotal.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icDebtorCode = <parameter value>
vhParameter::icCurrencyCode = <parameter value>.
/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").
if not vhServer:connected()
then do:
message "Could not connect AppServer" view-as alert-box error title "Error".
return.
end.
/* Run */
assign vhContextDS = dataset dsContext:handle.
run program/rpcrequestservice.p on vhServer
(input-output dataset-handle vhContextDS by-reference,
output dataset-handle vhExceptionDS,
input dataset-handle vhInputDS by-reference,
input-output dataset-handle vhInputOutputDS by-reference,
output dataset-handle vhOutputDS).
/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).
if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).
/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.
if valid-handle(vhInputDS)
then delete object vhInputDS.
if valid-handle(vhOutputDS)
then delete object vhOutputDS.
if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.