Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bpaymentselection.p)
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-REGISTER} or
vcActivityCode = {&PAYMENTSELECTIONACTIVITY-UNCONFIRM}
then do:
for each t_sPaySel where
t_sPaySel.tc_Status = "":U:
assign t_sPaySel.tc_Status = "C":U.
end.
end.
/* Payment selection can not be saved without any open item lines */
for each t_sPaySel where
t_sPaySel.tc_status <> "D":U:
if not can-find(first t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid)
then do:
<M-49 run SetMessage
(input trim(#T-86'The system cannot find lines for collection selection $1. The system cannot continue.':250(1647)T-86#) (icMessage),
input t_sPaySel.PaySelCode (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-856641':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
end.
end.
/* Only one prepayment can be created (FINS-4577)*/
if (vcActivityCode = {&PAYMENTSELECTIONACTIVITY-CREATE} or
vcActivityCode = {&PAYMENTSELECTIONACTIVITY-MODIFY})
then do:
VALIDATIONBLOCK: DO:
for each t_sPaySel where
t_sPaySel.tc_Status <> "D":U:
/* internal index created on paysellineobjecttype */
/* for each used iso find for performance : for each combines indexes, find doesn't */
for each t_sPaySelLine where
t_sPaySelLine.tc_Status <> "D":U and
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENT} :
if t_sPaySelLine.tc_Status = "":U and
not can-find(first t_iPaySelline where
t_iPaySelLine.tc_Rowid = t_sPaySelLine.tc_Rowid and
t_iPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENT})
then next.
for first bt_sPaySelLine where
bt_sPaySelLine.tc_Status <> "D":U and
bt_sPaySelLine.tc_Rowid <> t_sPaySelLine.tc_Rowid and
bt_sPaySelLine.tcCreditorCode = t_sPaySelLine.tcCreditorCode and
bt_sPaySelLine.tcInvoiceCurrencyCode = t_sPaySelLine.tcInvoiceCurrencyCode and
bt_sPaySelLine.BankNumber_ID = t_sPaySelLine.BankNumber_ID and
bt_sPaySelLine.PayFormatTypeCode = t_sPaySelLine.PayFormatTypeCode and
bt_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENT} :
<M-84 run SetMessage
(input trim(#T-13'Only one prepayment can be created per Supplier, Currency, Bank Number and Payment Format':255(193388588)T-13#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-64754':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
leave VALIDATIONBLOCK.
end. /* end for first bt_sPaySelLine */
end. /* end for each t_sPaySelline */
end. /* end for each t_sPaySel */
END. /* VALIDATIONBLOCK */
end. /* end vcActivityCode */
/* Synchronize payment attributes between ref table and component table */
if (vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-REGISTER} and
vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-EXECUTE} and
vcActivityCode <> {&PAYMENTSELECTIONACTIVITY-EXECUTEAGAIN})
then do:
/* Update or create payment selection hader attributes */
for each t_sPaySel where
t_sPaySel.tc_Status <> "D":U,
each tPaySelPayCodeRef where
tPaySelPayCodeRef.tc_ParentRowid = t_sPaySel.tc_Rowid:
/* Find existing tPaySel record */
find first t_sPaySelPayCode where
t_sPaySelPayCode.PayFormatGroup_ID = tPaySelPayCodeRef.PayFormatGroup_ID no-error.
/* If this is new header payment attribute, create it */
if not available t_sPaySelPayCode
then do:
<M-6 run AddDetailLine
(input 'PaySelPayCode':U (icTable),
input t_sPaySel.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
create t_sPaySelPayCode.
buffer-copy tPaySelPayCode to t_sPaySelPayCode.
end. /* If not available tPaySelPayCode */
/* Update existing values */
buffer-copy tPaySelPayCodeRef except PaySel_ID PaySelPayCode_ID tc_Rowid tc_ParentRowid tc_status to t_sPaySelPayCode.
assign t_sPaySelPayCode.PaySelPayCodeValue = tPaySelPayCodeRef.tcPayFormatCodeValue
t_sPaySelPayCode.tcPayFormatCode = tPaySelPayCodeRef.tcPayFormatCodeValue /*FIN_3198*/
t_sPaySelPayCode.tc_Status = (if t_sPaySelPayCode.tc_Status = "":U
then "C":U
else t_sPaySelPayCode.tc_Status).
end.
/* Delete those not used attributes */
for each t_sPaySelPayCode where
not can-find(first tPaySelPayCodeRef where
tPaySelPayCodeRef.PayFormatGroup_ID = t_sPaySelPayCode.PayFormatGroup_ID):
assign t_sPaySelPayCode.tc_Status = "D":U.
end.
end.
/*
* Setup payment attribute value and payment format code ID as follows:
* If attribute value is blank set code ID to zero.
* If attribute value is not blank search for existing attribute value:
* If existing record found then assign code ID from found record
* If existing record not found then assign code ID to zero
*/
<Q-2 run PayFormatCodebyGroupID (Start) in BPaymentFormat >
for each t_sPaySelPayCode where
t_sPaySelPayCode.tc_status = "N":U or
t_sPaySelPayCode.tc_status = "C":U:
if t_sPaySelPayCode.tcPayFormatCode <> ? and
t_sPaySelPayCode.tcPayFormatCode <> "":U
then do:
<Q-3 run PayFormatCodebyGroupID (all) (Read) (NoCache)
(input ?, (PayFormatCodeID)
input t_sPaySelPayCode.tcPayFormatCode, (PayFormatCode)
input t_sPaySelPayCode.PayFormatGroup_ID, (PayFormatGroupID)
output dataset tqPayFormatCodebyGroupID) in BPaymentFormat >
find first tqPayFormatCodebyGroupID no-error.
if available tqPayFormatCodebyGroupID
then assign t_sPaySelPayCode.PayFormatCode_ID = tqPayFormatCodebyGroupID.tiPayFormatCode_ID.
/*t_sPaySelPayCode.PaySelPayCodeValue = "":U.*/ /*FIN-3198*/
else assign t_sPaySelPayCode.PayFormatCode_ID = 0.
end.
end.
<Q-4 run PayFormatCodebyGroupID (Stop) in BPaymentFormat >
<M-5 run ValidateComponentPreBankPayFormat (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if (viFcReturnSuper > 0 and oiReturnStatus = 0) or viFcReturnSuper < 0
then assign oiReturnStatus = viFcReturnSuper.
/* ======================================================================= */
/* Validate GL Period for Supplier Payment selection confirm */
/* ======================================================================= */
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-REGISTER} or
vcActivityCode = {&PAYMENTSELECTIONACTIVITY-UNCONFIRM}
then do:
for each t_sPaysel where (t_sPaySel.tc_Status = "N" or
t_sPaySel.tc_Status = "C"):
<Q-85 run PeriodByStartEndDate (all) (Read) (NoCache)
(input t_sPaySel.Company_ID, (CompanyId)
input t_sPaySel.ttPostingdate, (Date)
output dataset tqPeriodByStartEndDate) in BPeriod >
find first tqPeriodByStartEndDate where
tqPeriodByStartEndDate.ttPeriodStartDate <= t_sPaySel.ttPostingDate and
tqPeriodByStartEndDate.ttPeriodEndDate >= t_sPaySel.ttPostingDate and
tqPeriodByStartEndDate.tcPeriodStatus = {&PERIODSTATUS-OPEN} and
tqPeriodByStartEndDate.tlPeriodIsPostingPurchAllow = true
no-error.
if not available tqPeriodByStartEndDate
then do:
<M-52 run SetMessage
(input trim(#T-74'This GL period is closed for purchase transactions.':250(16607)T-74#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input string(t_sPaySel.ttPostingDate) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-652812':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
end.
end.
/* =============================================================================== */
/* Assign PaySelID on PaySelLineStage to improve the performance of */
/* dataload by using the OverridePrimary construction for reading the data from db */
/* =============================================================================== */
for each t_sPaySel where
t_sPaySel.tc_Status <> "D":U ,
each t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
t_sPaySelLine.tc_Status <> "D":U ,
each t_sPaySelLineStage where
t_sPaySelLineStage.tc_ParentRowid = t_sPaySelLine.tc_Rowid and
t_sPaySelLineStage.PaySel_ID <> t_sPaySel.PaySel_ID and
(t_sPaySelLineStage.tc_Status = "N":U or
t_sPaySelLineStage.tc_Status = "C":U) :
assign t_sPaySelLineStage.PaySel_ID = t_sPaySel.PaySel_ID.
end. /* for each t_sPaySel */
/* ================================================================= */
/* When the status is 'Partially Confirmed', */
/* user can not modify, delete or execute the payment selection */
/* ================================================================= */
for each t_sPaySel where t_sPaySel.tc_Status <> "":
if vcActivityCode = {&PAYMENTSELECTIONACTIVITY-EXECUTE} or
vcActivityCode = {&PAYMENTSELECTIONACTIVITY-MODIFY} or
vcActivityCode = {&PAYMENTSELECTIONACTIVITY-DELETE} then
do:
if t_sPaySel.PaySelStatus = {&PAYMENTSELECTIONSTATUS-PARTIALLY} then assign vcErrorMessage = {&PAYMENTSELECTIONSTATUS-PARTIALLY-TR}.
else if t_sPaySel.PaySelStatus = {&PAYMENTSELECTIONSTATUS-PROCESSING} then assign vcErrorMessage = {&PAYMENTSELECTIONSTATUS-PROCESSING-TR}.
else next.
<M-28 run SetMessage
(input trim(substitute(#T-54'You cannot execute,modify or delete the current payment selection if its status is '&1'.':255(504089010)T-54#, vcErrorMessage)) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-561822':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
assign oiReturnStatus = -1.
return.
end.
end.