project QadFinancials > class TConCheck > method TechnicalValidation05CDocument
Description
Submethod of TechnicalValidation for checking CDocument
Parameters
iiCompanyID | input | integer | |
itFromDate | input | date | |
itToDate | input | date | |
oiErrorNumbers | output | integer | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tconcheck.p)
/**********************************************************************************/
/* CheckAPPayments */
/**********************************************************************************/
PUT STREAM sTechOut unformatted " " skip.
PUT STREAM sTechOut unformatted vcPrefix2 + "Start Validation of AP payments (ALL)" skip.
assign vcValidStatus = 'INITIAL,ACCEPTED,PORTFOLIO,INCASSO,DISCONT,BOUNCED,PAID,PAIDCON,VOID'.
assign vcValidType = 'DRAFT,TRANSFER,CHEQUE,PROMISSORYNOTE,SUMMARYSTATEMENT,ELECTRONIC'.
assign vcValidSubType = 'AUT,MAN'.
for each CDocument fields (CDocument.Company_ID CDocument.CDocument_ID) where CDocumentCreationDate >= itFromDate and CDocumentCreationDate <= itToDate
no-lock break by CDocument.Company_ID :
if first-of (CDocument.Company_ID) and not can-find (Company of CDocument)
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";CDocument found with no valid company" skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end.
/* Go through each Company */
for each company no-lock where company.company_id = iiCompanyID:
/* Do some checking on CDocument */
for each CDocument OF company
where CDocument.CDocumentCreationDate >= itFromDate and
CDocument.CDocumentCreationDate <= itToDate no-lock :
if(not can-do(vcValidStatus,CDocument.CDocumentStatus))
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";Invalid document status '" + CDocument.CDocumentStatus + "'." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if(not can-do(vcValidType,CDocument.CDocumentType))
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";Invalid document type '" + CDocument.CDocumentType + "'." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if(not can-do(vcValidSubType,CDocument.CDocumentSubType))
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";Invalid document sub-type '" + CDocument.CDocumentSubType + "'." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if(CDocument.CCollection_ID <> ? and CDocument.CCollection_ID <> 0) then do:
find CCollection of CDocument no-lock no-error.
if not available CCollection
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";No CCollection found." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end.
find Creditor of CDocument no-lock no-error.
if not available Creditor
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";No Creditor found." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
find Currency of CDocument no-lock no-error.
if not available Currency
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";No Currency found." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
find GL of CDocument no-lock no-error.
if not available GL
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";No GL found." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if(CDocument.CreationUsr_ID <> ? and CDocument.CreationUsr_ID <> 0) then do:
find Usr where Usr.Usr_ID = CDocument.CreationUsr_ID no-lock no-error.
if not available Usr
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";No Usr found." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end.
find BankNumber of CDocument no-lock no-error.
if not available BankNumber
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CDocument;" + string (CDocument.CDocument_ID) + ";No BankNumber found." skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end . /* for each cdocument */
end. /* for each company */
PUT STREAM sTechOut unformatted vcPrefix2 + "END Validation of AP payments" skip.