Description
This method returns the proposed payment selection lines (the information of these lines come from the invoice).
The input values can be used to drive and limited the returned values.
Parameters
ilIsInitialLoad | input | logical | IsInitialLoad |
iiBankPayFormatID | input | integer | |
ilShowAll | input | logical | ShowAll |
itDueDate | input | date | DueDate |
icPaymentSelectionDue | input | character | PaymentSelectionDue |
icCurrencyCode | input | character | Currency Code |
icDivisionCode | input | character | Sub-Account Code |
icCountryCode | input | character | BusinessRelationCountryCode |
icBusinessRelationCode | input | character | Business Relation Code |
icFromBusinessRelationCode | input | character | From BusinessRelationCode |
icToBusinessRelationCode | input | character | To BusinessRelationCode |
icBusinessRelationType | input | character | BusinessRelationType |
ilBusinessRelationIsInterco | input | logical | Business Relation Interco |
icPaymentGroupCode | input | character | Payment Group Code |
icCorporateGroupCode | input | character | |
ilAllEntities | input | logical | |
ilIsWithBank | input | logical | |
iiPaySelID | input | integer | |
itPaySelDate | input | date | PaySelDate |
icPaySelCurrCode | input | character | PaySelCurrCode |
iiMaxNumberOfLinesToReturn | input | integer | MaxNumberOfLinesToReturn: If this parameter is filled (meaning it is not zero and not null) then the output parameter tProposedLine will not contain more lines than the number filled in here |
iiCInvoiceID | input | integer | If this parameter is filled then this indicates only the data of a single CInvoice needs to be retrived |
tProposedLine | output | temp-table | Proposed Line |
tProposedLineStage | output | temp-table | Temp-table holding the Stage details of tProposedLine |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bpaymentselection.p)
/* ========================= */
/* Set default return status */
/* Start Block */
/* ========================= */
assign oiReturnStatus = -98
viLocalReturn = 0.
MAINAPIPROCESSINGBLOCK: DO :
/* ======================== */
/* Clear the output tables */
/* Set initial values */
/* ======================== */
empty temp-table tProposedLine.
empty temp-table tProposedLineStage.
assign viNumberOfAdditions = viNumberOfAdditions + 1 /* Data-item on class level */
icBusinessRelationType = {&PAYMENTSELECTIONRELATION-CREDITOR}. /* Only handle the supplier side for now */
/* ============================================================= */
/* Validate/Normalise/Convert version-spepcific input parameters */
/* ============================================================= */
if icFromBusinessRelationCode <> "":U and
icFromBusinessRelationCode <> ? and
icFromBusinessRelationCode = icToBusinessRelationCode and
(icBusinessRelationCode = "":U or
icBusinessRelationCode = ?)
then assign icBusinessRelationCode = icFromBusinessRelationCode.
if icFromBusinessRelationCode <> "":U and
icFromBusinessRelationCode <> ? and
icToBusinessRelationCode <> "":U and
icToBusinessRelationCode <> ? and
icFromBusinessRelationCode > icToBusinessRelationCode
then do :
assign vcMessage = trim(substitute(#T-58'To-Business-Relation (&2) cannot precede From-Business-Relation (&1).':255(27495021)T-58#,icFromBusinessRelationCode,icToBusinessRelationCode))
viLocalReturn = -1.
<M-39 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 1 (iiSeverity),
input '':U (icRowid),
input 'qadfin-90044':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
Leave MAINAPIPROCESSINGBLOCK.
end. /* if icFromBusinessRelationCode <> "":U and */
if iiMaxNumberOfLinesToReturn = ?
then assign iiMaxNumberOfLinesToReturn = 0.
/* ======================================================================================================================= */
/* Parameter ilIsInitialLoad is only true when you open an existing Supplier Payment Selection so the existing PaySelLines */
/* are returned without having the user to press the search-btn on the filter-area */
/* Parameter ilIsInitialLoad is false in all other cases: this is when the user pressed the search-btn on the filter-area. */
/* ======================================================================================================================= */
if ilIsInitialLoad = true
then do:
<M-62 run GetToPayObjectsInitLoadFromInst
(input iiPaySelID (iiPaySel_ID),
input icPaySelCurrCode (icPaySelCurrCode),
input itPaySelDate (itPaySelDate),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end. /* if ilIsInitialLoad = true */
else do:
/* Creditor */
if icBusinessRelationType = {&PAYMENTSELECTIONRELATION-CREDITOR} or
icBusinessRelationType = ? or
icBusinessRelationType = "":U
then do:
<M-79 run GetToPayObjectsForCInvoice
(input icPaymentSelectionDue (icPaymentSelectionDue),
input ilShowAll (ilShowAll),
input itDueDate (itDueDate),
input icCurrencyCode (icCurrencyCode),
input icDivisionCode (icDivisionCode),
input icBusinessRelationCode (icBusinessRelationCode),
input icFromBusinessRelationCode (icFromBusinessRelationCode),
input icToBusinessRelationCode (icToBusinessRelationCode),
input ilBusinessRelationIsInterco (ilBusinessRelationIsInterco),
input icPaymentGroupCode (icPaymentGroupCode),
input icCountryCode (icCountryCode),
input itPaySelDate (itPaySelDate),
input if ilIsWithBank then iiBankPayFormatId else ? (iiBankPayFormatID),
input ilAllEntities (ilAllEntities),
input ilIsWithBank (ilIsWithBanks),
input icCorporateGroupCode (icCorporateGroupCode),
input iiMaxNumberOfLinesToReturn (iiMaxNumberOfLinesToReturn),
input iiCInvoiceID (iiCInvoiceID),
input 0 (iiPaySel_ID),
input '' (icBankNumberFormatted),
input '' (icPaymentReference),
input ? (itDisCountRefDueDate),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAINAPIPROCESSINGBLOCK.
end. /* if icBusinessRelationType = {&PAYMENTSELECTIONRELATION-CREDITOR} or */
end. /* Not if ilIsInitialLoad = true */
/* ====================================================================== */
/* Indicate for all lines if there are multiple lines for the same object */
/* ====================================================================== */
for each tProposedLine
group by tProposedLine.tiObject_ID:
accumulate tProposedLine.tiObject_ID (count by tProposedLine.tiObject_ID).
if last-of(tProposedLine.tiObject_ID) and
(accum count by tProposedLine.tiObject_ID (tProposedLine.tiObject_ID)) > 1
then do:
for each btProposedLine where
btProposedLine.tiObject_ID = tProposedLine.tiObject_ID:
assign btProposedLine.tlIsMultiple = true.
end. /* for each btProposedLine where */
end. /* if last-of(tProposedLine.tiObject_ID) and */
end. /* for each tProposedLine */
/* ====================================================================== */
/* Call a submethod that will do some more specific assignements etc */
/* ====================================================================== */
<M-75 run GetToPayObjectsCheck (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAINAPIPROCESSINGBLOCK.
/* ====================================================================== */
/* Assign the amounts in base-currency for all lines */
/* ====================================================================== */
for each tProposedLine where
tProposedLine.tdPaymentAmountTC <> 0:
/* Assign tProposedLine.tdPaymentAmountBC and optionally get the rate */
if tProposedLine.tcInvoiceCurrencyCode <> icPaySelCurrCode and
tProposedLine.tcInvoiceCurrencyCode <> "":U and
tProposedLine.tcInvoiceCurrencyCode <> ? and
icPaySelCurrCode <> "":U and
icPaySelCurrCode <> ?
then do:
if icPayselCurrCode <> vcCompanyLC
then do:
<M-37 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input icPaySelCurrCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input tProposedLine.ttInvoiceDate (itValidityDate),
output vdExchangeRate (odExchangeRate),
output vdExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAINAPIPROCESSINGBLOCK.
assign vdExchangeRate = if vdExchangeRate <> 0 and
vdExchangeRate <> ? and
tProposedLine.tdInvoiceRate <> 0 and
tProposedLine.tdInvoiceRate <> ?
then (tProposedLine.tdInvoiceRate / vdExchangeRate / vdExchangeRateScale)
else 0.
end. /* if icPayselCurrCode <> vcCompanyLC */
else if tProposedLine.tcInvoiceCompanyCode <> vcCompanyCode
then do:
<M-20 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input tProposedLine.tcInvoiceCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input tProposedLine.ttInvoiceDate (itValidityDate),
output vdExchangeRate (odExchangeRate),
output vdExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0
then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAINAPIPROCESSINGBLOCK.
end. /* if tProposedLine.tcInvoiceCompanyCode <> vcCompanyCode */
else assign vdExchangeRate = tProposedLine.tdInvoiceRate
vdExchangeRateScale = tProposedLine.tdInvoiceRateScale.
assign tProposedLine.tdPaymentAmountBC = <M-36 RoundAmount
(input tProposedLine.tdPaymentAmountTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount),
input ? (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BPaymentSelection>.
end. /* if tProposedLine.tcInvoiceCurrencyCode <> icPaySelCurrCode and */
else assign tProposedLine.tdPaymentAmountBC = tProposedLine.tdPaymentAmountTC.
/* Assign the signed BC-amount and the Allocated-Amount */
assign tProposedLine.tdPaymentAmountSignBC = tProposedLine.tdPaymentAmountBC
* (if tProposedLine.tcPaymentAmntBCDebitCreditAbbr = vcCreditTR
then -1
else 1).
tProposedLine.tdAllocatedAmount = tProposedLine.tdPaymentAmountTC + tProposedLine.tdDiscountTC.
end. /* for each tProposedLine where */
/* ============================================= */
/* Assign the original TC- and BC-payment-amount */
/* Assign the signed TC-payment-amount */
/* ============================================= */
for each tProposedLine:
/* Set the signed payment-amount */
if tProposedLine.tcPaymentAmntDebitCreditAbbr = vcCreditTR
then assign tProposedLine.tdPaymentSignedAmtTC = - tProposedLine.tdPaymentAmountTC.
else assign tProposedLine.tdPaymentSignedAmtTC = tProposedLine.tdPaymentAmountTC.
/* Two extra fields were created to store the Payment Amount. This way, the normal payment amount fields can be changed on UI without loosing the original values */
assign tProposedLine.tdOriginalPaymentAmountTC = tProposedLine.tdPaymentAmountTC
tProposedLine.tdOriginalPaymentAmountBC = tProposedLine.tdPaymentAmountBC.
end. /* For each tProposedLine: */
END. /* MAINAPIPROCESSINGBLOCK */
/* ========================= */
/* Set return status */
/* ========================= */
assign oiReturnStatus = viLocalReturn.
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 = "BPaymentSelection".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiGetToPayObjectsV01".
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/bpaymentselection.apigettopayobjectsv01.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::ilIsInitialLoad = <parameter value>
vhParameter::iiBankPayFormatID = <parameter value>
vhParameter::ilShowAll = <parameter value>
vhParameter::itDueDate = <parameter value>
vhParameter::icPaymentSelectionDue = <parameter value>
vhParameter::icCurrencyCode = <parameter value>
vhParameter::icDivisionCode = <parameter value>
vhParameter::icCountryCode = <parameter value>
vhParameter::icBusinessRelationCode = <parameter value>
vhParameter::icFromBusinessRelationCode = <parameter value>
vhParameter::icToBusinessRelationCode = <parameter value>
vhParameter::icBusinessRelationType = <parameter value>
vhParameter::ilBusinessRelationIsInterco = <parameter value>
vhParameter::icPaymentGroupCode = <parameter value>
vhParameter::icCorporateGroupCode = <parameter value>
vhParameter::ilAllEntities = <parameter value>
vhParameter::ilIsWithBank = <parameter value>
vhParameter::iiPaySelID = <parameter value>
vhParameter::itPaySelDate = <parameter value>
vhParameter::icPaySelCurrCode = <parameter value>
vhParameter::iiMaxNumberOfLinesToReturn = <parameter value>
vhParameter::iiCInvoiceID = <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.