Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bpaymentselection.p)
/* ===================================================================================== */
/* This method validated and calculated all data when bank Payment Format is changed */
/* ===================================================================================== */
assign oiReturnStatus = -98
vlQCI = false
vlQDI = false
vlQBPF = false.
empty temp-table tBankNumberChange.
empty temp-table tBankNumberCreate.
empty temp-table tCInvoiceBankNumberUpdate.
empty temp-table tDInvoiceBankNumberUpdate.
for each t_sPaySel where
t_sPaySel.tc_Status = 'C':U:
find first t_iPaySel where
t_iPaySel.tc_Rowid = t_sPaySel.tc_Rowid
no-error.
if not available t_iPaySel
then do:
assign vcMessage = trim(substitute(#T-77'The system cannot find initial values for payment selection $1.':250(65691)t-77#, t_sPaySel.PaySelCode))
oiReturnStatus = -1.
<M-78 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':u (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPaySel.tc_Rowid (icRowid),
input 'QadFin-7531':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
next.
end.
if t_iPaySel.PaySelStatus <> {&PAYMENTSELECTIONSTATUS-INITIAL} and
t_iPaySel.BankPayFormat_ID <> t_sPaySel.BankPayFormat_ID
then do:
assign vcMessage = trim(#T-39'You can only modify the bank number when the Payment Selection Status is set to Initial.':255(65689)t-39#)
oiReturnStatus = -1.
<M-40 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'PaySel.PaySelStatus':U (icFieldName),
input t_sPaySel.PaySelStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7530':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end.
/* Validate entity of new BankNumber and PayFormatType */
if not vlQBPF
then do:
<Q-70 run BankPayFormatByID (Start) in BBankPayFormat>
assign vlQBPF = true.
end.
<Q-71 run BankPayFormatByID (all) (Read) (NoCache)
(input t_sPaySel.BankPayFormat_ID, (BankPayFormatId)
input ?, (CompanyId)
output dataset tqBankPayFormatByID) in BBankPayFormat >
find first tqBankPayFormatByID no-error.
if available tqBankPayFormatByID
then do:
if t_sPaySel.Company_ID <> tqBankPayFormatByID.tiCompany_ID
then do:
assign oiReturnStatus = -1.
<M-25 run SetMessage
(input trim(#T-4'The bank number must belong to the same entity as the payment selection.':255(65682)t-4#) (icMessage),
input '':U (icArguments),
input 'tPaySel.tcBankNumber':U (icFieldName),
input t_sPaySel.tcBankNumber (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7529':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end. /* if t_sPaySel.Company_ID <> tqBankPayFormatByID.tiCompany_ID */
end. /* if available tqBankPayFormatByID */
/* Validate Payment Format equality */
if t_iPaySel.BankPayFormat_ID <> t_sPaySel.BankPayFormat_ID
then do:
<Q-74 run BankPayFormatByID (all) (Read) (NoCache)
(input t_iPaySel.BankPayFormat_ID, (BankPayFormatId)
input ?, (CompanyId)
output dataset tqBankPayFormatByID) in BBankPayFormat >
find first tqBankPayFormatByID no-error.
if available tqBankPayFormatByID
then assign vcoldPayFormatTypeCode = tqBankPayFormatByID.tcPayFormatTypeCode.
if vcoldPayFormatTypeCode <> t_sPaySel.tcPayFormatTypeCode
then do:
<Q-8 assign vlFcQueryRecordsAvailable = PayFormatGroupPrim (NoCache)
(input ?, (PayFormatGroupID)
input t_sPaySel.tcPayFormatTypeCode, (PayFormatTypeCode)
input ?, (PayFormatGroupSequence)) in BPaymentFormat >
if vlFcQueryRecordsAvailable <> false
then do:
assign oiReturnStatus = -1.
<M-9 run SetMessage
(input trim(#T-2'The new payment format for this payment selection cannot be defined with Payment Attributes.':255(65695)t-2#) (icMessage),
input '':U (icArguments),
input 'PayFormatType':U (icFieldName),
input t_sPaySel.tcPayFormatTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7527':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end.
else do:
<Q-76 assign vlFcQueryRecordsAvailable = PayFormatGroupPrim (NoCache)
(input ?, (PayFormatGroupID)
input vcoldPayFormatTypeCode, (PayFormatTypeCode)
input ?, (PayFormatGroupSequence)) in BPaymentFormat >
if vlFcQueryRecordsAvailable = true or
vlFcQueryRecordsAvailable = ?
then do :
assign oiReturnStatus = 1.
<M-24 run SetMessage
(input trim(#T-3'The new payment format for this payment selection has no Payment Attributes. The values for the attributes of the old payment format will be deleted.':255(65694)t-3#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7528':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end.
end. /* else do */
end. /* if t_iPaySel.tcPayFormatTypeCode <> t_sPaySel.tcPayFormatTypeCode */
/* Check whether there is missing definition of supplier/customer bank number with changed bank payment format.*/
/* Validate Supplier */
/* Run the CInvoice query a PaySel line of that type exists */
if can-find(first t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} and
t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-DEBTORCNCORR} and
t_sPaySelLine.PaySelLineParentObject_ID <> 0 and
t_sPaySelLine.PaySelLineParentObject_ID <> ?)
then do:
if not vlQCI
then do:
<Q-43 run PaySelLineByPaySelIDCInvoice (Start) in BPaymentSelection >
assign vlQCI = true.
end.
<Q-42 run PaySelLineByPaySelIDCInvoice (all) (Read) (NoCache)
(input t_sPaySel.PaySel_ID, (PaySelID)
input ?, (CompanyId)
input t_sPaySel.BankPayFormat_ID, (BankPayFormatID)
output dataset tqPaySelLineByPaySelIDCInvoice) in BPaymentSelection>
end.
for each t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} and
t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-DEBTORCNCORR} and
t_sPaySelLine.PaySelLineParentObject_ID <> 0 and
t_sPaySelLine.PaySelLineParentObject_ID <> ?
break by t_sPaySelLine.tcCreditorCode
by t_sPaySelLine.BankNumber_ID:
if first-of(t_sPaySelLine.BankNumber_ID)
then do:
/* assign the original bank number back */
find first t_iPaySelLine where t_iPaySelLine.tc_Rowid = t_sPaySelLine.tc_Rowid
no-error.
if available t_iPaySelLine
then assign t_sPaySelLine.BankNumber_ID = t_iPaySelLine.BankNumber_ID.
<Q-86 run BankNumberByID (all) (Read) (NoCache)
(input t_iPaySelLine.BankNumber_ID, (BankNumber_ID)
input t_iPaySel.Company_ID, (CompanyId)
output dataset tqBankNumberByID) in BBankNumber>
find first tqBankNumberByID no-error.
if available tqBankNumberByID
then do:
find first tqPaySelLineByPaySelIDCInvoice where
tqPaySelLineByPaySelIDCInvoice.tiPaySelLine_ID = t_sPaySelLine.PaySelLine_ID and
tqPaySelLineByPaySelIDCInvoice.tcBankNumber = tqBankNumberByID.tcBankNumber and
tqPaySelLineByPaySelIDCInvoice.tlBankNumberIsActive = True no-error.
end. /* if available tqBankNumberByID */
/* BankNumber with changed format not exist create */
if not available tqPaySelLineByPaySelIdCInvoice
then do:
find first tqPaySelLineByPaySelIdCInvoice where
tqPaySelLineByPaySelIDCInvoice.tiPaySelLine_ID = t_sPaySelLine.PaySelLine_ID and
tqPaySelLineByPaySelIDCInvoice.tcBankNumber = tqBankNumberByID.tcBankNumber and
tqPaySelLineByPaySelIDCInvoice.tcBankNumberExtension = tqBankNumberByID.tcBankNumberExtension and
tqPaySelLineByPaySelIDCInvoice.tcBankNumberValidation = tqBankNumberByID.tcBankNumberValidation and
tqPaySelLineByPaySelIDCInvoice.tlBankNumberIsActive <> True
no-error.
if available tqPaySelLineByPaySelIdCInvoice
then do:
assign oiReturnStatus = -1.
<M-17 run SetMessage
(input trim (#T-61'Bank number must be one of the active bank account numbers defined for the current entity':255(8543006)T-61#) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-712345':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
end.
else do:
find first tBankNumberCreate where
tBankNumberCreate.tiOldBankNumberID = t_sPaySelLine.BankNumber_ID
no-error.
if not available tBankNumberCreate
then do:
create tBankNumberCreate.
assign tBankNumberCreate.tiBankPayFormatID = t_sPaySel.BankPayFormat_ID
tBankNumberCreate.tiOldBankNumberID = t_sPaySelLine.BankNumber_ID
tBankNumberCreate.tlIsFormatTypeChanged = (vcoldPayFormatTypeCode <> t_sPaySel.tcPayFormatTypeCode)
tBankNumberCreate.tlIsBankNumberDefault = false.
end.
end.
end. /* find first tqPaySelLineCInvoiceByPaySelId where */
/* BankNumber with changed format exist change to it */
else do:
find first tBankNumberChange where
tBankNumberChange.tiOldBankNumberID = t_sPaySelLine.BankNumber_ID
no-error.
if not available tBankNumberChange
then do:
create tBankNumberChange.
assign tBankNumberChange.tiBankPayFormatID = t_sPaySel.BankPayFormat_ID
tBankNumberChange.tiOldBankNumberID = t_sPaySelLine.BankNumber_ID
tBankNumberChange.tiNewBankNumberID = tqPaySelLineByPaySelIDCInvoice.tiBankNumber_ID
tBankNumberChange.tlIsFormatTypeChanged = (vcoldPayFormatTypeCode <> t_sPaySel.tcPayFormatTypeCode)
tBankNumberChange.tlIsBankNumberDefault = false.
end.
end.
end.
end. /* for each t_sPaySelLine where */
/* Validate Customer */
if can-find(first t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
(t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCNCORR}) and
t_sPaySelLine.PaySelLineParentObject_ID <> 0 and
t_sPaySelLine.PaySelLineParentObject_ID <> ?)
then do:
if not vlQDI
then do:
<Q-44 run PaySelLineByPaySelIDDInvoice (Start) in BPaymentSelection >
assign vlQDI = true.
end.
<Q-45 run PaySelLineByPaySelIDDInvoice (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sPaySel.BankPayFormat_ID, (BankPayFormatID)
input t_sPaySel.PaySel_ID, (PaySelID)
output dataset tqPaySelLineByPaySelIDDInvoice) in BPaymentSelection >
end.
for each t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
(t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCNCORR}) and
t_sPaySelLine.PaySelLineParentObject_ID <> 0 and
t_sPaySelLine.PaySelLineParentObject_ID <> ?
break by t_sPaySelLine.tcDebtorCode
by t_sPaySelLine.BankNumber_ID:
if first-of(t_sPaySelLine.tcDebtorCode) and first-of(t_sPaySelLine.BankNumber_ID)
then do:
/* assign the original bank number back */
find first t_iPaySelLine where t_iPaySelLine.tc_Rowid = t_sPaySelLine.tc_Rowid
no-error.
if available t_iPaySelLine
then assign t_sPaySelLine.BankNumber_ID = t_iPaySelLine.BankNumber_ID.
find first tqPaySelLineByPaySelIDDInvoice where
tqPaySelLineByPaySelIDDInvoice.tiPaySelLine_ID = t_sPaySelLine.PaySelLine_ID
no-error.
if not available tqPaySelLineByPaySelIdDInvoice
/* BankNumber with changed format not exist create */
then do:
find first tBankNumberCreate where
tBankNumberCreate.tiOldBankNumberID = t_sPaySelLine.BankNumber_ID
no-error.
if not available tBankNumberCreate
then do:
create tBankNumberCreate.
assign tBankNumberCreate.tiBankPayFormatID = t_sPaySel.BankPayFormat_ID
tBankNumberCreate.tiOldBankNumberID = t_sPaySelLine.BankNumber_ID
tBankNumberCreate.tlIsFormatTypeChanged = (vcoldPayFormatTypeCode <> t_sPaySel.tcPayFormatTypeCode).
end.
end. /* find first tqPaySelLineDInvoiceByPaySelId where */
/* BankNumber with changed format exist change to it */
else do:
find first tBankNumberChange where
tBankNumberChange.tiOldBankNumberID = t_sPaySelLine.BankNumber_ID
no-error.
if not available tBankNumberChange
then do:
create tBankNumberChange.
assign tBankNumberChange.tiBankPayFormatID = t_sPaySel.BankPayFormat_ID
tBankNumberChange.tiOldBankNumberID = t_sPaySelLine.BankNumber_ID
tBankNumberChange.tiNewBankNumberID = tqPaySelLineByPaySelIDDInvoice.tiBankNumber_ID
tBankNumberChange.tlIsFormatTypeChanged = (vcoldPayFormatTypeCode <> t_sPaySel.tcPayFormatTypeCode).
end.
end.
end.
end. /* for each t_sPaySelLine where */
/* Invoke the CreateBankNumberAsCopy */
if can-find(first tBankNumberCreate)
then do:
if viBBankNumberPaySelID = 0 or viBBankNumberPaySelID = ?
then do:
<I-53 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BBankNumber"}>
assign vlbanknumberStartedFromPaySel = true.
end.
else do:
<I-54 {bFcOpenInstance
&CLASS = "BBankNumber"}>
end.
<M-55 run CreateBankNumberAsCopy
(input-output tBankNumberCreate (tBankNumberToCreate),
input true (ilClearData),
output viExternalReturnStatus (oiReturnStatus)) in BBankNumber>
<I-58 {bFcCloseInstance
&CLASS = "BBankNumber"}>
if viExternalReturnStatus < 0 or (viExternalReturnStatus > 0 and oiReturnStatus = -98)
then assign oiReturnStatus = viExternalReturnStatus.
if viExternalReturnStatus < 0
then do:
<M-57 run StopExternalInstances (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
return.
end.
end.
/*Invoked the UpdateCInvoiceBankNumber and UpdateDInvoicebanknumber and update the Payment selection lines */
for each t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} and
t_sPaySelLine.PaySelLineObjectType <> {&PAYMENTSELECTIONTYPE-DEBTORCNCORR} and
t_sPaySelLine.PaySelLineParentObject_ID <> 0 and
t_sPaySelLine.PaySelLineParentObject_ID <> ?:
find first tBankNumberCreate where
tBankNumberCreate.tiOldBankNumberId = t_sPaySelLine.BankNumber_ID
no-error.
if available tBankNumberCreate
then do:
create tCInvoiceBankNumberUpdate.
assign tCInvoiceBankNumberUpdate.tiOldBankNumberId = tBankNumberCreate.tiOldBankNumberId
tCInvoiceBankNumberUpdate.tiNewBankNumberId = tBankNumberCreate.tiNewBankNumberId
tCInvoiceBankNumberUpdate.tiCInvoiceId = t_sPaySelLine.PaySelLineParentObject_ID
tCInvoiceBankNumberUpdate.tdCInvoiceBankToPayTC = t_sPaySelLine.PaySelLineAmountTC + abs(t_sPaySelLine.PaySelLineDiscountTC)
tCInvoiceBankNumberUpdate.tcCurrentPaymSelLineRowId = t_sPaySelLine.tc_Rowid
tCInvoiceBankNumberUpdate.tlPayFormatChanged = tBankNumberCreate.tlIsFormatTypeChanged.
/* update payment selection lines with new bankNumbers */
assign t_sPaySelLine.BankNumber_ID = tBankNumberCreate.tiNewBankNumberId
t_sPaySelLine.PayFormatTypeCode = t_sPaySel.tcPayFormatTypeCode
t_sPaySelLine.tc_Status ='C':U
t_sPaySelLine.tlProposedLineIsSelected= true.
end.
else do:
find first tBankNumberChange where
tBankNumberChange.tiOldBankNumberId = t_sPaySelLine.BankNumber_ID
no-error.
if available tBankNumberChange
then do:
create tCInvoiceBankNumberUpdate.
assign tCInvoiceBankNumberUpdate.tiOldBankNumberId = tBankNumberChange.tiOldBankNumberId
tCInvoiceBankNumberUpdate.tiNewBankNumberId = tBankNumberChange.tiNewBankNumberId
tCInvoiceBankNumberUpdate.tiCInvoiceId = t_sPaySelLine.PaySelLineParentObject_ID
tCInvoiceBankNumberUpdate.tdCInvoiceBankToPayTC = t_sPaySelLine.PaySelLineAmountTC + abs(t_sPaySelLine.PaySelLineDiscountTC)
tCInvoiceBanknumberUpdate.tcCurrentPaymSelLineRowId = t_sPaySelLine.tc_Rowid
tCInvoiceBankNumberUpdate.tlPayFormatChanged = tBankNumberChange.tlIsFormatTypeChanged.
/* update payment selection Lines with changed banknumbers */
assign t_sPaySelLine.BankNumber_ID = tBankNumberChange.tiNewBankNumberId
t_sPaySelLine.PayFormatTypeCode = t_sPaySel.tcPayFormatTypeCode
t_sPaySelLine.tc_Status = 'C':U
t_sPaySelLine.tlProposedLineIsSelected = true.
end.
end.
end.
if can-find(first tCInvoiceBankNumberUpdate)
then do:
if viBCInvoicePaySelID = 0 or viBCInvoicePaySelID = ?
then do:
<I-59 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BCInvoice"}>
assign vlBCInvIsStartedFromPaySel = true.
end.
else do:
<I-60 {bFcOpenInstance
&CLASS = "BCInvoice"}>
end.
<M-62 run UpdateCInvoiceBankNumber
(input true (ilClearData),
input false (ilTransferUnallocatedAmount),
input tCInvoicebankNumberUpdate (tUpdateCInvoiceBankNumber),
output viExternalReturnStatus (oiReturnStatus)) in BCInvoice>
<I-63 {bFcCloseInstance
&CLASS = "BCInvoice"}>
if viExternalReturnStatus < 0 or (viExternalReturnStatus > 0 and oiReturnStatus = -98)
then assign oiReturnStatus = viExternalReturnStatus.
if viExternalReturnStatus < 0
then do:
<M-64 run StopExternalInstances (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
return.
end.
end.
for each t_sPaySelLine where
t_sPaySelLine.tc_ParentRowid = t_sPaySel.tc_Rowid and
(t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCNCORR}) and
t_sPaySelLine.PaySelLineParentObject_ID <> 0 and
t_sPaySelLine.PaySelLineParentObject_ID <> ?:
find first tBankNumberCreate where
tBankNumberCreate.tiOldBankNumberId = t_sPaySelLine.BankNumber_ID
no-error.
if available tBankNumberCreate
then do:
create tDInvoiceBankNumberUpdate.
assign tDInvoiceBankNumberUpdate.tiOldBankNumberId = tBankNumberCreate.tiOldBankNumberId
tDInvoiceBankNumberUpdate.tiNewBankNumberId = tBankNumberCreate.tiNewBankNumberId
tDInvoiceBankNumberUpdate.tiDInvoiceId = t_sPaySelLine.PaySelLineParentObject_ID
tDInvoiceBankNumberUpdate.tdDInvoiceBankToPayTC = t_sPaySelLine.PaySelLineAmountTC + abs(t_sPaySelLine.PaySelLineDiscountTC)
tDInvoiceBankNumberUpdate.tcCurrentPaymSelLineRowId = t_sPaySelLine.tc_Rowid
tDInvoiceBankNumberUpdate.tlPayFormatChanged = tBankNumberCreate.tlIsFormatTypeChanged.
/* update payment selection lines with new bankNumbers */
assign t_sPaySelLine.BankNumber_ID = tBankNumberCreate.tiNewBankNumberId
t_sPaySelLine.PayFormatTypeCode = t_sPaySel.tcPayFormatTypeCode
t_sPaySelLine.tc_Status = 'C':U
t_sPaySelLine.tlProposedLineIsSelected= true.
end.
else do:
find first tBankNumberChange where
tBankNumberChange.tiOldBankNumberId = t_sPaySelLine.BankNumber_ID
no-error.
if available tBankNumberChange
then do:
create tDInvoiceBankNumberUpdate.
assign tDInvoiceBankNumberUpdate.tiOldBankNumberId = tBankNumberChange.tiOldBankNumberId
tDInvoiceBankNumberUpdate.tiNewBankNumberId = tBankNumberChange.tiNewBankNumberId
tDInvoiceBankNumberUpdate.tiDInvoiceId = t_sPaySelLine.PaySelLineParentObject_ID
tDInvoiceBankNumberUpdate.tdDInvoiceBankToPayTC = t_sPaySelLine.PaySelLineAmountTC + abs(t_sPaySelLine.PaySelLineDiscountTC)
tDInvoiceBankNumberUpdate.tcCurrentPaymSelLineRowId = t_sPaySelLine.tc_Rowid
tDInvoiceBankNumberUpdate.tlPayFormatChanged = tBankNumberChange.tlIsFormatTypeChanged.
/* update payment selection Lines with changed banknumbers */
assign t_sPaySelLine.BankNumber_ID = tBankNumberChange.tiNewBankNumberId
t_sPaySelLine.PayFormatTypeCode = t_sPaySel.tcPayFormatTypeCode
t_sPaySelLine.tc_Status ='C':U
t_sPaySelLine.tlProposedLineIsSelected= true.
end.
end.
end.
if can-find(first tDInvoiceBankNumberUpdate)
then do:
if viBDInvoicePaySelID = 0 or viBDInvoicePaySelID = ?
then do:
<I-65 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BDInvoice"}>
assign vlBDInvIsStartedFromPaySel = true.
end.
else do:
<I-66 {bFcOpenInstance
&CLASS = "BDInvoice"}>
end.
<M-67 run UpdateDInvoiceBankNumber
(input true (ilClearData),
input false (ilTransferUnallocatedAmount),
input tDInvoiceBankNumberUpdate (tUpdateDInvoiceBankNumber),
output viExternalReturnStatus (oiReturnStatus)) in BDInvoice>
<I-68 {bFcCloseInstance
&CLASS = "BDInvoice"}>
if viExternalReturnStatus < 0 or (viExternalReturnStatus > 0 and oiReturnStatus = -98)
then assign oiReturnStatus = viExternalReturnStatus.
if viExternalReturnStatus < 0
then do:
<M-69 run StopExternalInstances (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
return.
end.
end.
end. /* if tqPaySelByCode.tiBankPayFormat_ID <> t_sPaySel.BankPayFormat_ID */
end. /* for each t_sPaySel where t_sPaySel.tc_Status = 'C':U:*/
if vlQCI
then do:
<Q-48 run PaySelLineByPaySelIDCInvoice (Stop) in BPaymentSelection >
end.
if vlQDI
then do:
<Q-49 run PaySelLineByPaySelIDDInvoice (Stop) in BPaymentSelection >
end.
if vlQBPF
then do:
<Q-73 run BankPayFormatByID (Stop) in BBankPayFormat >
end.
if oiReturnStatus = -98
then assign oiReturnStatus = 0.