Description
This method is used to get the information( like status, execution date,Document Type, Currency Code,GL code ) of an existing payment selection
Parameters
icPaySelCode | input | character | PaySelCode |
oiPaySel_ID | output | integer | |
ocPaySelStatus | output | character | PaySelStatus |
otPaySelDate | output | date | PaySelDate |
ocCDocumentType | output | character | PaySelPaymentMeans |
ocCurrencyCode | output | character | Currency Code |
odPaySelTotalAmountBC | output | decimal | PaySelTotalAmountBC |
ocGLCode | output | character | |
ocBankNumberFormatted | output | character | |
oiCurrencyNumOfDecimals | output | integer | CurrencyNumOfDecimals |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bpaymentselection.p)
empty temp-table tExchangeRates.
<Q-1 run PaySelByCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input icPaySelCode, (PaySelCode)
output dataset tqPaySelByCode) in BPaymentSelection >
find first tqPaySelByCode no-error.
if available tqPaySelByCode
then do:
<M-23 run GetPaymentInstrument
(input tqPaySelByCode.tiBankPayFormat_ID (iiBankPayFormatID),
output ocCDocumentType (ocPaymentInstrument),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
for first tqBankPayFormatByID no-lock:
assign ocCDocumentType = tqBankPayFormatByID.tcPayFormatTypePayInstrument.
end.
assign oiPaySel_ID = tqPaySelByCode.tiPaySel_ID
ocPaySelStatus = tqPaySelByCode.tcPaySelStatus
otPaySelDate = tqPaySelByCode.ttPaySelDate
ocCurrencyCode = if tqPaySelByCode.tcCurrencyCode = "":U and
tqPaySelByCode.tlGLIsLocalCurrency = true
then vcCompanyLC
else tqPaySelByCode.tcCurrencyCode
ocGLCode = tqPaySelByCode.tcGLCode
oiCurrencyNumOfDecimals = if ocCurrencyCode = vcCompanyLC
then viCompanyLCDec
else tqPaySelByCode.tiCurrencyNumberOfDecimals.
/* defect 10249-0373 sdo begin */
/* now use bankpayformat->banknumber to get formattedBankNumber */
<Q-24 run BankPayFormatByID (all) (Read) (NoCache)
(input tqPaySelByCode.tiBankPayFormat_ID, (BankPayFormatId)
input viCompanyId, (CompanyId)
output dataset tqBankPayFormatByID) in BBankPayFormat >
for each tqBankPayFormatByID where
tqBankPayFormatByID.tiBankPayFormat_ID = tqPaySelByCode.tiBankPayFormat_ID
no-lock:
assign ocBankNumberFormatted = tqBankPayFormatByID.tcBankNumberFormatted.
end.
/* defect 10249-0373 end */
<Q-18 run PaySelLineByParentObject (all) (Read) (NoCache)
(input ?, (CompanyId)
input tqPaySelByCode.tiPaySel_ID, (PayselId)
output dataset tqPaySelLineByParentObject) in BPaymentSelection >
assign odPaySelTotalAmountBC = 0.
<Q-63 run CurrencyPrim (Start) in BCurrency >
for each tqPaySelLineByParentObject:
if tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICE} or
tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICECORR} or
tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTE} or
tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTECORR} or
tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} or
tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-ADJUSTMENT}
then do:
assign viInvoiceCurrency_ID = tqPaySelLineByParentObject.tiCInvoiceCurrency_ID
vdInvoiceExchangeRate = tqPaySelLineByParentObject.tdCInvoiceExchangeRate
vdInvoiceRateScale = tqPaySelLineByParentObject.tdCInvoiceRateScale
vtInvoiceDate = tqPaySelLineByParentObject.ttCInvoiceDate.
end. /* if tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICE} or */
if tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} or
tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCNCORR}
then do:
assign viInvoiceCurrency_ID = tqPaySelLineByParentObject.tiDInvoiceCurrency_ID
vdInvoiceExchangeRate = tqPaySelLineByParentObject.tdDInvoiceExchangeRate
vdInvoiceRateScale = tqPaySelLineByParentObject.tdDInvoiceRateScale
vtInvoiceDate = tqPaySelLineByParentObject.ttDInvoiceDate.
end. /* if tqPaySelLineByParentObject.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} or */
<Q-70 run CurrencyPrim (all) (Read) (NoCache)
(input ?, (CurrencyCode)
input viInvoiceCurrency_ID, (Currency_ID)
output dataset tqCurrencyPrim) in BCurrency >
find first tqCurrencyPrim no-error.
if tqCurrencyPrim.tcCurrencyCode <> ocCurrencyCode and
tqCurrencyPrim.tcCurrencyCode <> "":U and
tqCurrencyPrim.tcCurrencyCode <> ? and
ocCurrencyCode <> "":U and
ocCurrencyCode <> ?
then do:
if ocCurrencyCode <> vcCompanyLC
then do:
assign vhFcComponent = ?.
find first tExchangeRates where
tExchangeRates.tcFromCurrencyCode = ocCurrencyCode and
tExchangeRates.tcToCurrencyCode = vcCompanyLC and
tExchangeRates.ttValidityDate = vtInvoiceDate no-error.
if not available tExchangeRates
then do:
<M-85 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input ocCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input vtInvoiceDate (itValidityDate),
output vdExchangeRate (odExchangeRate),
output vdExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
create tExchangeRates.
assign tExchangeRates.tcFromCurrencyCode = ocCurrencyCode
tExchangeRates.tcToCurrencyCode = vcCompanyLC
tExchangeRates.ttValidityDate = vtInvoiceDate
tExchangeRates.tdExchangeRate = vdExchangeRate
tExchangeRates.tdExchangeRateScale = vdExchangeRateScale.
end.
assign vdExchangeRate = if tExchangeRates.tdExchangeRate <> 0 and
tExchangeRates.tdExchangeRate <> ? and
vdInvoiceExchangeRate <> 0 and
vdInvoiceExchangeRate <> ?
then (vdInvoiceExchangeRate / tExchangeRates.tdExchangeRate / tExchangeRates.tdExchangeRateScale)
else 0
vdExchangeRateScale = tExchangeRates.tdExchangeRateScale.
end. /* if ocCurrencyCode <> vcCompanyLC */
else assign vdExchangeRate = vdInvoiceExchangeRate
vdExchangeRateScale = vdInvoiceRateScale.
assign odPaySelTotalAmountBC = odPaySelTotalAmountBC + <M-46 RoundAmount
(input tqPaySelLineByParentObject.tdPaySelLineAmountTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount),
input ? (iiCurrencyID),
input ocCurrencyCode (icCurrencyCode)) in BPaymentSelection>.
end. /* if tqCurrencyPrim.tcCurrencyCode <> ocCurrencyCode and */
else assign odPaySelTotalAmountBC = /* when the currency of the paysel is the same as the invoice,then you have to put the payselamount in it */
odPaySelTotalAmountBC + <M-35 RoundAmount
(input tqPaySelLineByParentObject.tdPaySelLineAmountTC (idUnroundedAmount),
input ? (iiCurrencyID),
input ocCurrencyCode (icCurrencyCode)) in BPaymentSelection>.
end. /* for each tqPaySelLineByParentObject*/
<Q-83 run CurrencyPrim (Stop) in BCurrency >
end. /* if available tqPaySelByCode */
empty temp-table tExchangeRates.
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 = "ApiGetPaySelInfo".
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.apigetpayselinfo.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icPaySelCode = <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.