project QadFinancials > class BDInvoice > method UpdateDInvoiceBank
Description
Update the Bank number of Customer invoice when the own bank number of customer payment changed
Parameters
Internal usage
QadFinancials
program code (program5/bdinvoice.p)
assign oiReturnStatus = -98.
for each tUpdateDInvoiceBankNumber:
if not can-find (first tDInvoice where
tDInvoice.DInvoice_ID = tUpdateDInvoiceBankNumber.tiDInvoiceId)
then assign vcListDInvoiceIds = if vcListDInvoiceIds = "":U
then string(tUpdateDInvoiceBankNumber.tiDInvoiceId)
else
if lookup(string(tUpdateDInvoiceBankNumber.tiDInvoiceId), vcListDInvoiceIds, chr(4)) = 0
then vcListDInvoiceIds + chr(4) + string (tUpdateDInvoiceBankNumber.tiDInvoiceId)
else vcListDInvoiceIds.
end.
if vcListDInvoiceIds <> "":U
then do:
<M-3 run DataLoad
(input '':U (icRowids),
input vcListDinvoiceIds (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do :
assign vcMessage = trim(substitute(#T-6'Data could not be loaded: unable to load the list of customer invoices (&1).':100(1795)T-6#, replace(vcListDInvoiceIds, chr(4), ",":U))).
<M-7 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8879':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
return.
end. /* if oiReturnStatus < 0 */
end. /* if viFcReturnSuper <> 0 */
end. /* if vcListDInvoiceIds <> "":U */
for each tUpdateDInvoiceBankNumber:
find first tDInvoice where
tDInvoice.DInvoice_ID = tUpdateDInvoiceBankNumber.tiDInvoiceId
no-error.
if not available tDInvoice
then do:
assign vcMessage = trim(#T-2'The invoice was not found. The system cannot update it.':100(65684)t-2#).
<M-8 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8880':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
Next.
end. /* if not available tDInvoice */
if can-find (first tDInvoiceBank where
tDInvoiceBank.tc_ParentRowid = tDInvoice.tc_Rowid and
tDInvoiceBank.tc_Status <> "D":U and
tDInvoiceBank.BankNumber_ID = tUpdateDInvoiceBankNumber.tiOldBankNumberId)
then do:
find first tDInvoiceBank where
tDInvoiceBank.tc_ParentRowid = tDInvoice.tc_Rowid and
tDInvoiceBank.tc_Status <> "D":U and
tDInvoiceBank.BankNumber_ID = tUpdateDInvoiceBankNumber.tiNewBankNumberId
no-lock no-error.
/*Same bankNumber found, consolidate to the new banknumber and delete the old one */
if available tDInvoiceBank
then do:
assign tDInvoiceBank.DInvoiceBankToPayTC = tDInvoiceBank.DInvoiceBankToPayTC + tUpdateDInvoiceBankNumber.tdDInvoiceBankToPayTC
tDInvoiceBank.tlValidatePayment = false.
if tDInvoiceBank.tc_Status = "":U
then assign tDInvoiceBank.tc_Status = "C":U.
find first tDInvoiceBank where
tDInvoiceBank.tc_ParentRowid = tDInvoice.tc_Rowid and
tDInvoiceBank.tc_Status <> "D":U and
tDInvoiceBank.BankNumber_ID = tUpdateDInvoiceBankNumber.tiOldBankNumberId
no-lock no-error.
if available tDInvoiceBank
then do:
if tDInvoiceBank.tc_Status = "N":U
then delete tDInvoiceBank.
else assign tDInvoiceBank.tc_Status = "D":U.
end.
end.
else do:
find first tDInvoiceBank where
tDInvoiceBank.tc_ParentRowid = tDInvoice.tc_Rowid and
tDInvoiceBank.tc_Status <> "D":U and
tDInvoiceBank.BankNumber_ID = tUpdateDInvoiceBankNumber.tiOldBankNumberId
no-lock no-error.
assign tDInvoiceBank.BankNumber_ID = tUpdateDInvoiceBankNumber.tiNewBankNumberId.
assign tDInvoiceBank.tc_Status = if tDInvoiceBank.tc_Status = "":U then "C":U else tDInvoiceBank.tc_Status.
/* delete the Payment attributes if Payformat changed */
if tUpdateDInvoiceBankNumber.tlPayFormatChanged
then do:
for each tDInvoiceBankPayCode where
tDInvoiceBankPayCode.tc_ParentRowid = tDInvoiceBank.tc_Rowid and
tDInvoiceBankPayCode.tc_Status <> "D":U:
if tDInvoiceBankPayCode.tc_Status = "N":U
then delete tDInvoiceBankPayCode.
else assign tDInvoiceBankPayCode.tc_Status = "D":U.
end.
end.
end.
end.
end.
if oiReturnStatus = -98
then assign oiReturnStatus = 0.