project QadFinancials > class BPaymentSelection > method ApiConfirmPaymentSelectionPreValidation
Description
Pre validation for confirm and unconfirm. Called from API.
Parameters
iiPaySel_ID | input | integer | |
icActivityCode | input | character | |
oiMaxBatchSize | output | integer | |
oiMinBatchSize | output | integer | |
olIdelProcessingStatus | output | logical | If current PaySel is in processing and idel for a long time. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFitnesse
program code (program3/bpaymentselection.p)
/* Get batch size */
<M-76 run GetBatchSizeForPaySel
(output oiMaxBatchSize (oiMaxBatchSize),
output oiMinBatchSize (oiMinBatchSize),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
/* Pre validation */
<Q-56 run PaySelPayStatusByPaySelID (all) (Read) (NoCache)
(input ?, (CompanyId)
input iiPaySel_ID, (PaySel_ID)
output dataset tqPaySelPayStatusByPaySelID) in BPaymentSelection>
find first tqPaySelPayStatusByPaySelID no-error.
if available tqPaySelPayStatusByPaySelID
then do:
assign vcPaySelStatus = tqPaySelPayStatusByPaySelID.tcPaySelStatus.
/* Status = {&PAYMENTSELECTIONSTATUS-PROCESSING} */
if vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-PROCESSING}
then do:
/* Get last modified PaySelLine */
<Q-26 run PaySelLineLastModifiedByPaySelId (all) (Read) (NoCache)
(input iiPaySel_ID, (PaySel_ID)
output dataset tqPaySelLineLastModifiedByPaySel) in BPaymentSelection>
find last tqPaySelLineLastModifiedByPaySel no-error.
session:timezone = 0.
/* TimeIdle = Current Time - LastUsedTime + (1440 minutes per day difference) */
if available tqPaySelLineLastModifiedByPaySel
then assign viIdleTimeInMinutes = ((Today - tqPaySelLineLastModifiedByPaySel.ttLastModifiedDate) * 1440) +
Round((Time - tqPaySelLineLastModifiedByPaySel.tiLastModifiedTime) / 60, 0).
session:timezone = viTimeOffset.
/* If idel time is more than 40 minutes, ignore the validation */
if viIdleTimeInMinutes > 40
then do:
assign oiReturnStatus = 0
olIdelProcessingStatus = true.
return.
end.
else do:
<M-89 run SetMessage
(input #T-91'You cannot confirm or unconfirm the current payment selection if its status is 'Processing'.':255(112750573)T-91# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-387931':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
end.
/* Status = {&PAYMENTSELECTIONSTATUS-TRANSFERRED} or
{&PAYMENTSELECTIONSTATUS-REGISTERED} or
{&PAYMENTSELECTIONSTATUS-CLOSED} */
else if (vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-TRANSFERRED} or
vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-REGISTERED} or
vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-CLOSED}) and
icActivityCode = {&PAYMENTSELECTIONACTIVITY-REGISTER}
then do:
if vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-TRANSFERRED} then
assign vcMessage = {&PAYMENTSELECTIONSTATUS-TRANSFERRED-TR}.
else if vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-REGISTERED} then
assign vcMessage = {&PAYMENTSELECTIONSTATUS-REGISTERED-TR}.
else if vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-CLOSED} then
assign vcMessage = {&PAYMENTSELECTIONSTATUS-CLOSED-TR}.
<M-78 run SetMessage
(input trim(substitute(#T-60'You cannot confirm the current payment selection if its status is '&1'.':255(49354280)T-60#, vcMessage)) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-142774':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
/* Status = {&PAYMENTSELECTIONSTATUS-INITIAL} or
{&PAYMENTSELECTIONSTATUS-CLOSED} */
else if (vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-INITIAL} or
vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-CLOSED}) and
icActivityCode = {&PAYMENTSELECTIONACTIVITY-UNCONFIRM}
then do:
if vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-INITIAL} then
assign vcMessage = {&PAYMENTSELECTIONSTATUS-INITIAL-TR}.
else if vcPaySelStatus = {&PAYMENTSELECTIONSTATUS-CLOSED} then
assign vcMessage = {&PAYMENTSELECTIONSTATUS-CLOSED-TR}.
<M-97 run SetMessage
(input trim(substitute(#T-53'You cannot unconfirm the current payment selection if its status is '&1'':255(802887833)T-53#, vcMessage)) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-424654':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
/* Warning message validation for unconfirm */
if icActivityCode = {&PAYMENTSELECTIONACTIVITY-UNCONFIRM}
then do:
<M-20 run GetPaymentInstrument
(input tqPaySelPayStatusByPaySelID.tiBankPayFormat_ID (iiBankPayFormatID),
output vcPaymentInstrument (ocPaymentInstrument),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if tqPaySelPayStatusByPaySelID.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-TRANSFERRED} and
vcPaymentInstrument = {&PAYFORMATPAYINSTRUMENT-ELECTRONIC}
then do:
assign vcMessage = trim(#T-44'You are about to Unconfirm a Payment Selection that has status Transferred and a file for bank is already created. Unconfirm will Bounce all the payments. Are you sure to proceed?':255(73481911)T-44#)
oiReturnStatus = 1.
<M-55 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 4 (iiSeverity),
input '':U (icRowid),
input 'qadfin-575562':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end.
assign vlCheckPrinted = false.
<Q-48 run CDocumentByIDAllInfo (all) (Read) (NoCache)
(input ?, (CompanyId)
input iiPaySel_ID, (PaySel_ID)
output dataset tqCDocumentByIDAllInfo) in BCDocument>
for each tqCDocumentByIDAllInfo where
tqCDocumentByIDAllInfo.tiPaySel_ID = iiPaySel_ID and
(tqCDocumentByIDAllInfo.tcCDocumentStatus = {&DOCUMENTSTATUS-INCASSO} or
tqCDocumentByIDAllInfo.tcCDocumentStatus = {&DOCUMENTSTATUS-PAID}) break by tqCDocumentByIDAllInfo.tiCDocumentNumber:
if tqCDocumentByIDAllInfo.tiCDocumentPrePrintedNumber <> 0 and
tqCDocumentByIDAllInfo.tiCDocumentPrePrintedNumber <> ?
then assign vlCheckPrinted = true.
end.
if vlCheckPrinted and
vcPaymentInstrument = {&PAYFORMATPAYINSTRUMENT-CHEQUE}
then do:
assign vcMessage = trim(#T-36'You are about to Unconfirm a Payment Selection with Checks that are already printed. Unconfirm will Bounce all the payments. Are you sure to proceed?':255(591298002)T-36#)
oiReturnStatus = 1.
<M-62 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 4 (iiSeverity),
input '':U (icRowid),
input 'qadfin-586963':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end. /*if vlCheckPrinted */
end. /* if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-UNCONFIRM} */
end. /* if available */
/* If there's warning then return */
if oiReturnStatus = 1
then return.
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 = "ApiConfirmPaymentSelectionPreValidation".
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.apiconfirmpaymentselectionprevalidation.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiPaySel_ID = <parameter value>
vhParameter::icActivityCode = <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.