project QadFinancials > class TConCheck > method TechnicalValidation04CHist
Description
Submethod of TechnicalValidation for checking CHist
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)
/**********************************************************************************/
/* IPR_AP_Check_HIST */
/**********************************************************************************/
PUT STREAM sTechOut unformatted " " skip.
PUT STREAM sTechOut unformatted vcPrefix2 + "Start Validation of AP HISTORY (" + STRING (itFromDate) + ")" skip.
IPR_AP_Check_HIST:
do:
ASSIGN viYearPeriod = 0.
FOR FIRST period WHERE period.company_id = iiCompanyID AND
period.PeriodStartDate <= itFromDate AND
Period.PeriodEndDate >= itFromDate
NO-LOCK:
ASSIGN viYearPeriod = Period.PeriodYearPeriod.
END.
if can-find (first QCinvoiceMovement no-lock where QCInvoiceMovement.Company_ID = iiCompanyID
and QCInvoiceMovement.MovementYearPeriod <= viYearPeriod)
then do :
PUT STREAM sTechOut unformatted vcPrefix + "History cannot be checked as there are still records in the daemon queue (QCinvoiceMovement)" skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
leave IPR_AP_Check_HIST.
end.
for each Company no-lock where company.company_id = iiCompanyID:
/* Get sharedset of the company */
for each companysharedset no-lock where companysharedset.company_id = company.company_id,
each sharedset of companysharedset no-lock:
if sharedsettype = {&SHAREDSETTYPE-GL} then
assign viGLShareSetID = sharedset.sharedset_id.
if sharedsettype = {&SHAREDSETTYPE-DIVISION} then
assign viDivisionSharedSetID = sharedset.sharedset_id.
if sharedsettype = {&SHAREDSETTYPE-COSTCENTRE} then
assign viCostCenterSharedSetID = sharedset.sharedset_id.
if sharedsettype = {&SHAREDSETTYPE-PROJECT} then
assign viProjectSharedSetID = sharedset.sharedset_id.
if sharedsettype = {&SHAREDSETTYPE-JOURNAL} then
assign viJournalSharedSetID = sharedset.sharedset_id.
if sharedsettype = {&SHAREDSETTYPE-CREDITOR} then
assign viCreditorSharedSetID = sharedset.sharedset_id.
end. /* end each companysharedset */
/* Check Consisttency of CHist */
for each CHist of Company NO-LOCK WHERE
CHist.CHistYearPeriodFrom = viYearPeriod :
/* Check GL */
find first GL where
GL.GL_ID = CHist.GL_ID and GL.SharedSet_ID = viGLShareSetID no-lock no-error.
if available GL
then do:
if GL.GLType <> 'CREDITORCONTROL'
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (CHist.CHist_ID) + ";CHist found with GL of wrong type" skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end.
else do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (CHist.CHist_ID) + ";GL was not found" skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
/* Check Creditor */
find first Creditor where
Creditor.Creditor_id = CHist.Creditor_ID
AND Creditor.SharedSet_ID = viCreditorSharedSetID no-lock no-error.
if not available Creditor
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (CHist.CHist_ID) + ";Creditor was not found" skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
/* Check Journal */
find first Journal where
Journal.Journal_id = CHist.Journal_ID
AND Journal.SharedSet_ID = viJournalSharedSetID no-lock no-error.
if not available Journal
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (CHist.CHist_ID) + ";Journal was not found" skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
/* Check Division */
if CHist.Division_ID <> 0 and CHist.Division_ID <> ?
then do :
find first Division where
Division.Division_id = CHist.Division_ID
AND Division.SharedSet_ID = viDivisionSharedSetID no-lock no-error.
if not available Division
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (CHist.CHist_ID) + ";Division was not found" skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end.
end. /* for each CHist */
/* Check the balance for each creditor */
for each Creditor where Creditor.SharedSet_ID = viCreditorSharedSetID no-lock:
assign vdBalance1TC = 0 vdBalance2TC = 0 vdBalance3TC = 0 vdBalance4TC = 0
vdBalance1LC = 0 vdBalance2LC = 0 vdBalance3LC = 0 vdBalance4LC = 0
vdBalance1CC = 0 vdBalance2CC = 0 vdBalance3CC = 0 vdBalance4CC = 0.
/* Get the current balance of the creditor using CInvoice */
for each CInvoice where
CInvoice.Company_ID = company.company_id and
CInvoice.creditor_ID = creditor.creditor_id and
CInvoice.CInvoiceIsOpen and
CInvoice.CinvoiceIsInitialStatus = NO
no-lock :
assign vdBalance1TC = vdBalance1TC + CInvoice.CInvoiceBalanceTC
vdBalance1LC = vdBalance1LC + CInvoice.CInvoicebalancelc
vdBalance1CC = vdBalance1CC + CInvoice.CInvoiceBalanceCC.
/* check if CInvoice.CInvoiceBalanceCC is ? */
if CInvoice.CInvoiceBalanceCC = ?
then do:
PUT STREAM sTechOut unformatted vcPrefix + "Error: CInvoice.CInvoiceBalanceCC value is ?, " + "CInvoice_ID=" + string(CInvoice.CInvoice_ID) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end.
/* Get the current balance of the creditor using CHist */
for each CHist where
CHist.Company_ID = company.company_id and
CHist.creditor_ID = creditor.creditor_id
no-lock :
if CHist.CHistYearPeriodTill = 999999
then assign vdBalance2TC = vdBalance2TC + CHist.CHistBalanceTC
vdBalance2LC = vdBalance2LC + CHist.CHistBalanceLC
vdBalance2CC = vdBalance2CC + CHist.CHistBalanceCC.
assign vdBalance3TC = vdBalance3TC + CHist.CHistMovementDebitTC - CHist.CHistMovementCreditTC
vdBalance3LC = vdBalance3LC + CHist.CHistMovementDebitLC - CHist.CHistMovementCreditLC
vdBalance3CC = vdBalance3CC + CHist.CHistMovementDebitCC - CHist.CHistMovementCreditCC.
end. /* for each CHist */
/* Get the current balance of the creditor using DBalance */
for each CBalance where
CBalance.Company_ID = company.company_id and
CBalance.creditor_ID = creditor.creditor_id
no-lock :
assign vdBalance4TC = vdBalance4TC + CBalance.CBalanceTC
vdBalance4LC = vdBalance4LC + CBalance.CBalanceLC
vdBalance4CC = vdBalance4CC + CBalance.CBalanceCC.
end. /* for each DBalance */
if vdBalance1TC <> vdBalance3TC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in TC Amount for this creditor (CInvoice vs CHist): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1TC) + ' * ' + string (vdBalance3TC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdBalance3TC <> vdBalance2TC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in TC Amount for this creditor (CHist vs CHist): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1TC) + ' * ' + string (vdBalance2TC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdBalance1TC <> vdBalance4TC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in TC Amount for this creditor (CInvoice vs CBalance): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1TC) + ' * ' + string (vdBalance4TC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdBalance1LC <> vdBalance3LC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in LC Amount for this creditor (CInvoice vs CHist): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1LC) + ' * ' + string (vdBalance3LC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdBalance3LC <> vdBalance2LC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in LC Amount for this creditor (CHist vs CHist): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1LC) + ' * ' + string (vdBalance2LC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdBalance1LC <> vdBalance4LC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in LC Amount for this creditor (CInvoice vs CBalance): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1LC) + ' * ' + string (vdBalance4LC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdBalance1CC <> ?
then do:
if vdBalance1CC <> vdBalance3CC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in CC Amount for this creditor (CInvoice vs CHist): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1CC) + ' * ' + string (vdBalance3CC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdBalance3CC <> vdBalance2CC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in CC Amount for this creditor (CHist vs CHist): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1CC) + ' * ' + string (vdBalance2CC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdBalance1CC <> vdBalance4CC
then do:
PUT STREAM sTechOut unformatted vcPrefix + "CHist;" + string (creditor.creditor_ID) + ";Mismatch in CC Amount for this creditor (CInvoice vs CBalance): " +
'creditorCode= ' + creditor.creditorCode + ', ' + string (vdBalance1CC) + ' * ' + string (vdBalance4CC) skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end.
end. /* for each ttcreditor */
end. /* for each Company */
end. /* IPR_AP_Check_HIST */
PUT STREAM sTechOut unformatted vcPrefix2 + "END Validation of AP HISTORY" skip.