Description
This method Loads PaymentSelection records using Invoice Reference of Payment selecftion, to delete PaySelLine .
Parameters
| icInvoiceReference | input | character | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdpaymentselection.p)
if icInvoiceReference <> ? and icInvoiceReference <> "":U
then do:
<Q-75 run DPaySelPayRefByCode (all) (Read) (NoCache)
(input icInvoiceReference, (Code)
input ?, (CompanyId)
output dataset tqDPaySelPayRefByCode) in BDPaymentSelection>
end.
find first tqDPaySelPayRefByCode no-error.
if not available tqDPaySelPayRefByCode
then do:
assign
vcMessage = #T-35'Could not find Invoice with reference $1':255(35046299)T-35#
oiReturnStatus = -1.
<M-37 run SetMessage
(input vcMessage (icMessage),
input icInvoiceReference (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'qadfin-216085':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
return.
end.
/* Build up a list of pay sel's to update*/
for each tqDPaySelPayRefByCode
where tqDPaySelPayRefByCode.tcDPaySelPayRefCode = icInvoiceReference and
tqDPaySelPayRefByCode.tcDPaySelStatus = {&PAYMENTSELECTIONSTATUS-INITIAL} :
if vcPaySels = "":U
then
assign vcPaySels = string(tqDPaySelPayRefByCode.tiDPaySel_ID).
else
assign vcPaySels = vcPaySels + ',' + string(tqDPaySelPayRefByCode.tiDPaySel_ID).
end.
if vcPaySels = "":U
then return.
<M-86 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input vcPaySels (icObjectIds),
input '' (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
return.
end.
else do:
for each tDPaySelPayRef where
tDPaySelPayRef.DPaySelPayRefCode = icInvoiceReference:
assign tDPaySelPayRef.tc_Status = "D":U.
for each tDPaySelLineStg where
tDPaySelLineStg.DPaySelLineStg_ID = tDPaySelPayRef.DPaySelLineStg_ID:
assign tDPaySelLineStg.tc_Status = "D":U
tDPaySelLineStg.DPaySelLineStgStatus = {&PAYSEL-LINE-STATUS-CANCEL}.
end.
/*Delete PaySelLine only when there is no linked PaySelLineStg to it*/
for each tDPaySelLine where
tDPaySelLine.DPaySelLine_ID = tDPaySelPayRef.DPaySelLine_ID:
assign vlLinkedStage = false .
for each tDPaySelLineStg where
tDPaySelLineStg.DPaySelLine_ID = tDPaySelLine.DPaySelLine_ID:
if tDPaySelLineStg.tc_Status <> "D":U
then do:
assign vlLinkedStage = true.
leave.
end.
else vlLinkedStage = false.
end.
if vlLinkedStage = false
then assign tDPaySelLine.tc_Status = "D":U .
end.
end.
end.
/* Start the Persistence layer of BCinvoice to allow a WriteDirect */
<M-43 run StartPersistence
(output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if viFcReturnSuper <> 0 */
/* Update DInvoiceStageIsSelected since AdditionalUpdates is not correctly handling this for PIBF flow */
for each tDPaySelLineStg where
tDPaySelLineStg.tc_Status = "D":U :
vcWhereStgClause = "for each DInvoiceStage where DInvoiceStage.DInvoiceStage_ID = ":U + string(tDPaySelLineStg.DInvoiceStage_ID).
<M-95 run WriteDirect
(input 'DInvoiceStage':U (icTableName),
input vcWhereStgClause (icPrepare),
input 'DInvoiceStageIsSelected':U (icFieldList),
input 'L':U (icFieldListDataTypes),
input 'false':U (icAbsolute),
input '':U (icIncremental),
input {&TARGETPROCEDURE} (ihClass),
input vcUserLogin (icUserLogin),
output viFcReturnSuper (oiReturnStatus)) in Progress>
end.
<M-93 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
<M-85 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
<M-80 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.