project QadFinancials > class BDInvoice > method ValidateComponentPreValidateBank
Description
This method is submethod of ValidateComponentPre.
This method fills some necessary fields on Debtor Invoice Bank records.
Parameters
blStartPayFormatTypeByType | input-output | logical | is query tqPayFormatTypeByType already started or not ? |
blStartBankNumberPrim | input-output | logical | Is query tqBankNumberPrim already started or not ? |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bdinvoice.p)
/* ======================================================================== */
/* IMPORTANT: This method is run from ValidateComponentPreValidate */
/* The code in this method is nested within the for each t_sDInvoice */
/* This can only work when both methods are defined in the same segment (5) */
/* ======================================================================== */
/* ================================================================================= */
/* Assign DInvoiceBank.BankNumber_ID (mandatory) based on DInvoiceBank.tcBankNumber, */
/* DInvoiceBank.tcBankNumberExtension, DInvoiceBank.tiParentObject_ID */
/* ================================================================================= */
for each t_sDInvoiceBank where
(t_sDInvoiceBank.tc_Status = "N":U or
t_sDInvoiceBank.tc_Status = "C":U) and
t_sDInvoiceBank.tc_ParentRowid = t_sDInvoice.tc_Rowid:
if t_sDInvoiceBank.tc_Status = "N":U and t_sDInvoice.tdDInvoiceOriginalTC <> 0 and t_sDInvoiceBank.DInvoiceBankToPayTC = 0
then do:
assign vcMessage = trim(substitute(#T-11'The payment amount TC is zero for bank &1.':150(59552)t-11#, t_sDInvoiceBank.tcBankNumber))
oiReturnStatus = -1.
<M-12 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-5943':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end.
/* AP payment is only allowed for credit notes that has a flag DInvoiceIsPaymentAllowed is true */
if t_sDInvoiceBank.tcPayFormatTypeCode <> ? and t_sDInvoiceBank.tcPayFormatTypeCode <> "":U
then do:
if not blStartPayFormatTypeByType
then do:
<Q-16 run PayFormatTypeByType (Start) in BPaymentFormat >
assign blStartPayFormatTypeByType = true.
end.
<Q-13 run PayFormatTypeByType (all) (Read) (NoCache)
(input t_sDInvoiceBank.tcPayFormatTypeCode, (PayFormatTypeCode)
output dataset tqPayFormatTypeByType) in BPaymentFormat >
find first tqPayFormatTypeByType where
tqPayFormatTypeByType.tcPayFormatTypeCode = t_sDInvoiceBank.tcPayFormatTypeCode no-error.
if available tqPayFormatTypeByType and tqPayFormatTypeByType.tcPayFormatTypeModule = {&PAYFORMATMODULE-AP}
then do:
if t_sDInvoice.DInvoiceType <> {&INVOICETYPE-CREDITNOTE} or
t_sDInvoice.DInvoiceIsPaymentAllowed = false
then do:
assign vcMessage = trim(substitute(#T-14'You can only specify the AP payment format for payable credit notes.':150(62340)t-14#,t_sDInvoiceBank.tcPayFormatTypeCode))
oiReturnStatus = -1.
<M-15 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tDInvoiceBank.tcPayFormatTypeCode':U (icFieldName),
input t_sDInvoiceBank.tcPayFormatTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6345':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end.
end.
end.
assign t_sDInvoiceBank.tcBankNumber = replace(t_sDInvoiceBank.tcBankNumber," ":U,"":U)
t_sDInvoiceBank.tcBankNumber = replace(t_sDInvoiceBank.tcBankNumber,".":U,"":U)
t_sDInvoiceBank.tcBankNumber = replace(t_sDInvoiceBank.tcBankNumber,"/":U,"":U)
t_sDInvoiceBank.tcBankNumber = replace(t_sDInvoiceBank.tcBankNumber,"-":U,"":U).
find first t_iDInvoiceBank where
t_iDInvoiceBank.tc_Rowid = t_sDInvoiceBank.tc_Rowid
no-lock no-error.
assign t_sDInvoiceBank.tiParentObject_ID = t_sDInvoice.Debtor_ID.
/* only do something when values are changed */
if available t_iDInvoiceBank and
t_iDInvoiceBank.tcBankNumber = t_sDInvoiceBank.tcBankNumber and
t_iDInvoiceBank.tcBankNumberExtension = t_sDInvoiceBank.tcBankNumberExtension and
t_iDInvoiceBank.tiParentObject_ID = t_sDInvoiceBank.tiParentObject_ID and
t_iDInvoiceBank.tiBankPayFormat_ID = t_sDInvoiceBank.tiBankPayFormat_ID and
t_iDInvoiceBank.BankNumber_ID = t_sDInvoiceBank.BankNumber_ID
then next.
if (t_sDInvoiceBank.BankNumber_ID = ? or
t_sDInvoiceBank.BankNumber_ID = 0) and
(t_sDInvoiceBank.tcBankNumber = "":U or
t_sDInvoiceBank.tcBankNumber = ? or
t_sDInvoiceBank.tiParentObject_ID = 0 or
t_sDInvoiceBank.tiParentObject_ID = ?)
then do:
assign t_sDInvoiceBank.BankNumber_ID = 0
vcMessage = trim(#T-5'You must enter the bank account number.':255(1050)T-5#)
vcMessage = vcMessage + chr(10) + trim(substitute(#T-6'Bank number extension: &1, Parent Object ID: &2.':255(59534)t-6#,t_sDInvoiceBank.tcBankNumberExtension,string(t_sDInvoiceBank.tiParentObject_ID)))
oiReturnStatus = -1.
<M-2 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tDInvoiceBank.tcBankNumber':U (icFieldName),
input t_sDInvoiceBank.tcBankNumber (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDInvoiceBank.tc_Rowid (icRowid),
input 'QADFIN-4471':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end.
/* Changing of bank is not allowed for a DInvoiceBank row */
else if t_sDInvoiceBank.BankNumber_ID = ? or t_sDInvoiceBank.BankNumber_ID = 0
then do:
if t_sDInvoiceBank.tc_Status = "N":U or
(t_sDInvoiceBank.tc_Status = "C":U and
can-find (t_iDInvoiceBank where
t_iDInvoiceBank.tc_Rowid = t_sDInvoiceBank.tc_Rowid and
(t_iDInvoiceBank.tcBankNumber <> t_sDInvoiceBank.tcBankNumber or
t_iDInvoiceBank.tcBankNumberExtension <> t_sDInvoiceBank.tcBankNumberExtension or
t_iDInvoiceBank.tiBankPayFormat_ID <> t_sDInvoiceBank.tiBankPayFormat_ID or
t_iDInvoiceBank.tiParentObject_ID <> t_sDInvoiceBank.tiParentObject_ID) ))
then do:
if not blStartBankNumberPrim
then do:
<Q-18 run BankNumberPrim (Start) in BBankNumber >
assign blStartBankNumberPrim = true.
end.
<Q-7 run BankNumberPrim (all) (Read) (NoCache)
(input ?, (BankNumberId)
input t_sDInvoiceBank.tiParentObject_ID, (ParentObjectId)
input t_sDInvoiceBank.tcBankNumber, (BankNumber)
input t_sDInvoiceBank.tcBankNumberExtension, (BankNumberExtension)
input t_sDInvoiceBank.tiBankPayFormat_ID, (BankPayFormatID)
output dataset tqBankNumberPrim) in BBankNumber >
find first tqBankNumberPrim no-lock no-error.
if not available tqBankNumberPrim
then do:
assign vcMessage = trim(substitute(#T-8'No bank number (&1) was defined for this entity.':250(57136)t-8#,t_sDInvoiceBank.tcBankNumber))
vcMessage = vcMessage + chr(10) + trim(substitute(#T-9'Bank number extension: &1, Parent Object ID: &2.':255(59534)t-9#,t_sDInvoiceBank.tcBankNumberExtension,string(t_sDInvoiceBank.tiParentObject_ID)))
oiReturnStatus = -1.
<M-10 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-5821':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end.
else assign t_sDInvoiceBank.BankNumber_ID = tqBankNumberPrim.tiBankNumber_ID.
end.
end.
end. /* end of for each */