project QadFinancials > class BAPMatching > method ValidateComponentPostAPM1
validation procedure
Parameters
blStartPeriodByStartEndDateStat | input-output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bapmatching.p)
/* ============================================================================================= */
/* Note: this method is executed for all t_sAPMatching regardless their value of tc_status */
/* ============================================================================================= */
/* ========================== */
/* Set default return-status */
/* ========================== */
assign oiReturnStatus = -98.
/* ========================================================== */
/* Check for record-availability */
/* If not available: major error and return */
/* ========================================================== */
if not available t_sAPMatching
then do :
assign oiReturnStatus = -3
vcMsgAPMatching = trim(substitute(#T-89'Internal error: no AP matching record is available.':255(56009)T-89#)).
<M-88 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5691':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Return.
end. /* if not available t_sAPMatching */
/* ========================================================== */
/* Get the initial values - at the moment the data was loaded */
/* If not available: major error and return */
/* ========================================================== */
if can-do("C,D":U, t_sAPMatching.tc_Status)
then do:
find t_iAPMatching where
t_iAPMatching.tc_Rowid = t_sAPMatching.tc_Rowid
no-error.
if not available t_iAPMatching
then do:
assign vcMsgAPMatching = trim(substitute(#T-69'Internal error. The system cannot find the initial values for the AP matching record with row ID &1.':250(56067)t-69#,t_sAPmatching.tc_Rowid))
oiReturnStatus = -3.
<M-50 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input '':U (icType),
input '':U (iiSeverity),
input t_sAPMatching.tc_Rowid (icRowid),
input 'QadFin-5682':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Return.
end. /* if not available t_iAPMatching */
end. /* if can-do("C,D":U, t_sAPMatching.tc_Status) */
/* ============================================================================================================================= */
/* The Journal is mandatory on a Finished posting as the BCinvocie uses this information to state its allocation-status */
/* (omitting this validation would result in an error on the allocation status of the invoice and that is not a correct message) */
/* ============================================================================================================================= */
if t_sAPMatching.APMatchingStatus = {&APMATCHINGSTATUS-FINISHED} and
(t_sAPMatching.Journal_ID = 0 or
t_sAPMatching.Journal_ID = ?)
then do :
assign vcMsgAPMatching = trim(substitute(#T-118'The daybook is mandatory for finished Receiver Matchings. Date and invoice of the matching: &1-&2 / &3 / &4.':250(64262)t-118#,string(t_sAPMatching.APMatchingDate),string(t_sAPMatching.tiCInvoicePostingYear),t_sAPMatching.tcCInvoiceJournalCode,string(t_sAPMatching.tiCInvoiceVoucher))).
viLocalReturnStatus = -1.
<M-117 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input 'tAPMatching.tcJournalCode':U (icFieldName),
input t_sAPMatching.tcJournalCode (icFieldValue),
input '':U (icType),
input '':U (iiSeverity),
input t_sAPMatching.tc_Rowid (icRowid),
input 'QadFin-6731':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* if available t_iAPMatching and */
/* ====================================================== */
/* No actions are allowed on a Finished receiver matching */
/* ====================================================== */
if t_sAPMatching.tc_Status <> "N" and
t_sAPMatching.APMatchingStatus = {&APMATCHINGSTATUS-FINISHED} and
t_iAPMatching.APMatchingStatus = {&APMATCHINGSTATUS-FINISHED} and
can-find (first t_sAPMatchingLn where
t_sAPMatchingLn.tc_ParentRowid = t_sAPMatching.tc_Rowid and
t_sAPMatchingLn.tc_Status <> "":U )
then do :
assign vcMsgAPMatching = trim(substitute(#T-91'You cannot delete or modify a finished receiver matching. The date and invoice of the matching are: &1-&2 / &3 / &4.':250(56070)t-91#,string(t_sAPMatching.APMatchingDate),string(t_sAPMatching.tiCInvoicePostingYear),t_sAPMatching.tcCInvoiceJournalCode,string(t_sAPMatching.tiCInvoiceVoucher))).
viLocalReturnStatus = -1.
<M-90 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input 'tAPMatching.tiCInvoiceVoucher':U (icFieldName),
input string(t_sAPMatching.tiCInvoiceVoucher) (icFieldValue),
input '':U (icType),
input '':U (iiSeverity),
input t_sAPMatching.tc_Rowid (icRowid),
input 'QadFin-5697':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* if available t_iAPMatching and */
/* ==================================================== */
/* A matching can only be done in the logged-in company */
/* ==================================================== */
if t_sAPMatching.Company_ID <> viCompanyId and
(t_sAPMatching.tc_Status = "C":U or
t_sAPMatching.tc_Status = "N":U)
then do:
assign vcMsgAPMatching = trim(substitute(#T-79'Receiver matching can only be performed in the current entity.':250(56076)t-79#,t_sAPMatching.tcJournalCode)) + chr(10) +
trim(substitute(#T-80'Entity ID of the matching: &1.':213(56077)T-80#,string(t_sAPMatching.Company_ID))) + chr(10) +
trim(substitute(#T-81'Entity ID and code of the current entity: &1 / &2.':213(56078)T-81#,string(viCompanyId),vcCompanyCode))
viLocalReturnStatus = -1.
<M-59 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input 'tAPMatching.Company_ID':U (icFieldName),
input string(t_sAPMatching.Company_ID) (icFieldValue),
input '':U (icType),
input '':U (iiSeverity),
input t_sAPMatching.tc_Rowid (icRowid),
input 'QadFin-5688':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* t_sAPMatching.Company_ID <> viCompanyId */
/* ============================================= */
/* Posting_ID cannot be filled when not finished */
/* ============================================= */
if t_sAPMatching.APMatchingStatus = {&APMATCHINGSTATUS-INITIAL} and
t_sAPMatching.Posting_ID <> 0 and
t_sAPMatching.Posting_ID <> ? and
(t_sAPMatching.tc_Status = "N":U or
t_sAPMatching.tc_Status = "C":U)
then do:
assign vcMsgAPMatching = trim(substitute(#T-70'No posting is created for initial matchings. Daybook: &1 / matching date: &2.':250(56456)t-70#,t_sAPMatching.tcJournalCode,string(t_sAPMatching.APMatchingDate)))
viLocalReturnStatus = -1.
<M-51 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input 'tAPMatching.tcJournalCode':U (icFieldName),
input t_sAPMatching.tcJournalCode (icFieldValue),
input '':U (icType),
input '':U (iiSeverity),
input t_sAPMatching.tc_Rowid (icRowid),
input 'QadFin-5683':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* if t_sAPMatching.APMatchingStatus = {&APMATCHINGSTATUS-INITIAL} and */
/* ================================================================ */
/* Matching Date should fit the period-dates of the selected period */
/* Other checks on the period are in method ValPeriod */
/* ================================================================ */
if t_sAPMatching.tc_Status = "N":U or
(t_sAPMatching.tc_Status = "C":U and
(t_sAPMatching.Period_ID <> t_iAPMatching.Period_ID or
t_sAPMatching.APMatchingDate <> t_iAPMatching.APMatchingDate))
then do:
<Q-67 assign vlFcQueryRecordsAvailable = PeriodByStartEndDateStatus (Cache)
(input ?, (CompanyId)
input t_sAPMatching.APMatchingDate, (Date)
input ?, (PeriodStatus)
input t_sAPMatching.Period_ID, (PeriodId)
input ?, (PeriodIsPostingGLAllowed)) in BPeriod >
if vlFcQueryRecordsAvailable = false
then do:
assign vcDatetemp = <M-29 DisplayDate (input t_sAPMatching.APMatchingDate (itDate)) in BAPMatching>.
assign vcMsgAPMatching = trim(substitute(#T-71'The matching date (&1) must be between the start and end date of the selected GL period.':231(56057)t-71#,vcDatetemp))
viLocalReturnStatus = -1.
<M-52 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input 'tAPMatching.APMatchingDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input '':U (icType),
input '':U (iiSeverity),
input t_sAPMatching.tc_Rowid (icRowid),
input 'QadFin-5684':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* if vlFcQueryRecordsAvailable = false */
end. /* if t_sAPMatching.tc_Status = "N":U or */
/* ======================================================================== */
/* Set return-status = OK or any other value from within the previous code */
/* ======================================================================== */
assign oiReturnStatus = viLocalReturnStatus.