project QadFinancials > class BPosting > method ValidateComponentReversingPostingCheck
Description
This method does initial checks to see if there are any errors with the original entry that will prevent the reversing entry from being created
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Initial Checks and Setup */
/* Set the status, auto reversal type and check that the auto reversal */
/* posting date is in a future period from the original posting date */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
assign oiReturnStatus = -98
viLocalReturnStatus = 0
viOriginalEntryYearPeriod = 0
viReversingEntryYearPeriod = 0.
<Q-24 run PeriodByStartEndDate (Start) in BPeriod >
POSTINGBLOCK: DO:
For each btsPosting where
btsPosting.PostingIsAutoReversal = true:
/* DO NOT PROCEED IF THE METHOD IS CALLED DURING APPROVE/VERIFY ACTIVITY */
find first t_iPosting where t_iPosting.Posting_ID = btsPosting.Posting_ID no-error.
if available t_iPosting
then do:
if t_iPosting.PostingApproveStatus <> btsPosting.PostingApproveStatus or
t_iPosting.PostingVerifyStatus <> btsPosting.PostingVerifyStatus
then next.
end.
if vcActivityCode = "JournalEntryExcelIntegrationRepair" or
vcActivityCode = "ExcelIntegration"
then do :
if btsPosting.PostingAutoReversalType = {&POSTINGAUTOREVERSALTYPE-REVERSING}
then do:
vcMessage = #T-42'Automatic Reversal Type is equal to Reversing Entry will book a Correction Reversing Entry. Automatic Reversal Type should equal Original Entry for automatic reversing entry':255(769941687)T-42#.
<M-75 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'Posting.PostingAutoReversalType' (icFieldName),
input btsPosting.PostingAutoReversalType (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'qadfin-786941':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = 1.
end. /*if t_sPosting.PostingAutoReversalType */
end. /* If Activity Code = ExcelIntegration or JournalEntryExcelIntegrationRepair */
/* If the posting line is modified and the posting is not the status will be "" */
/* Update the status on the posting so that the change will be picked up */
if btsPosting.tc_Status = "":U
then assign btsPosting.tc_Status = "C":U.
if btsPosting.tc_Status = "C":U
then do:
for each btsPostingLine where btsPostingLine.tc_Status = "":U:
assign btsPostingLine.tc_Status = "C":U.
end.
end.
if btsPosting.tc_Status = "N":U
then assign btsPosting.PostingAutoReversalType = {&POSTINGAUTOREVERSALTYPE-ORIGINAL}.
/* Check that the auto reversal posting date is in a future period */
/* to the original posting date and that that future period exists */
if btsPosting.tc_Status <> "D":U
then do:
if btsPosting.PostingAutoReversalType = {&POSTINGAUTOREVERSALTYPE-ORIGINAL}
then do:
assign vtPostingDate = btsPosting.PostingDate
vtAutoReversalPostingDate = btsPosting.PostingAutoReversalDate.
end.
if btsPosting.PostingAutoReversalType = {&POSTINGAUTOREVERSALTYPE-REVERSING}
then do:
<Q-26 run PostingByPostingId (all) (Read) (NoCache)
(input btsPosting.Company_ID, (CompanyId)
input btsPosting.AutoReversalPosting_ID, (PostingId)
input '':U, (JournalTypeCode)
output dataset tqPostingByPostingId) in BPosting >
find first tqPostingByPostingId where
tqPostingByPostingId.tiPosting_ID = btsPosting.AutoReversalPosting_ID no-error.
if available tqPostingByPostingId
then assign vtPostingDate = tqPostingByPostingId.ttPostingDate
vtAutoReversalPostingDate = btsPosting.PostingDate.
end.
<Q-5 run PeriodByStartEndDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input vtPostingDate, (Date)
output dataset tqPeriodByStartEndDate) in BPeriod >
find first tqPeriodByStartEndDate no-error.
viOriginalEntryYearPeriod = tqPeriodByStartEndDate.tiPeriodYearPeriod.
<Q-4 run PeriodByStartEndDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input vtAutoReversalPostingDate, (Date)
output dataset tqPeriodByStartEndDate) in BPeriod >
find first tqPeriodByStartEndDate no-error.
if available tqPeriodByStartEndDate
then do:
assign viReversingEntryYearPeriod = tqPeriodByStartEndDate.tiPeriodYearPeriod.
end.
else do:
assign vcMsgExplanation = <M-27 GetErrorExplanation
(input btsPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(substitute(#T-22'The Reversal Posting Date (&1) is not in an existing period.':100(999890054)T-22#, vtAutoReversalPostingDate)).
<M-21 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'Reversal Posting Date':U (icFieldName),
input vtAutoReversalPostingDate (icFieldValue),
input 'E':U (icType),
input 1 (iiSeverity),
input btsPosting.tc_Rowid (icRowid),
input 'QadFin-8790':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BPosting>
assign oiReturnStatus = -3.
return.
end.
if viReversingEntryYearPeriod <= viOriginalEntryYearPeriod
then do:
assign vcMsgExplanation = <M-98 GetErrorExplanation
(input btsPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-9 run SetMessage
(input #T-8'The Reversal Posting Date must be in a future GL period':100(71478)T-8# (icMessage),
input '':U (icArguments),
input 'Reversal Posting Date':U (icFieldName),
input vtAutoReversalPostingDate (icFieldValue),
input 'E':U (icType),
input 1 (iiSeverity),
input btsPosting.tc_Rowid (icRowid),
input 'QadFin-8766':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BPosting>
assign oiReturnStatus = -1.
return.
end.
end. /* if btsPosting.tc_Status <> D */
/* You cannot delete a reversing entry directly */
if btsPosting.tc_status = "D":U and
btsPosting.PostingAutoReversalType = {&POSTINGAUTOREVERSALTYPE-REVERSING}
then do:
assign vcMsgExplanation = <M-33 GetErrorExplanation
(input btsPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-16 run SetMessage
(input #T-17'You can only delete a reversing entry by deleting the corresponding original entry':100(999890049)T-17# (icMessage),
input '':U (icArguments),
input 'Original Reference':U (icFieldName),
input btsPosting.PostingOriginatorReference (icFieldValue),
input 'E':U (icType),
input 1 (iiSeverity),
input btsPosting.tc_Rowid (icRowid),
input 'QadFin-8785':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BPosting>
assign oiReturnStatus = -1.
return.
end.
/* Check availability for Auto-reversal Numbering Date */
if btsPosting.PostingAddGLNbrRevDate <> ? and
btsPosting.PostingAutoReversalDate <> ? and
btsPosting.PostingAddGLNbrRevDate < btsPosting.PostingAutoReversalDate
then do:
assign vcMsgExplanation = <M-37 GetErrorExplanation
(input btsPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-28 run SetMessage
(input #T-82'Additional GL Numbering Reversal Date cannot be earlier than Reversal Posting Date':100(253046732)T-82# (icMessage),
input '':U (icArguments),
input 'Reversal Numbering Date':U (icFieldName),
input btsPosting.PostingAddGLNbrRevDate (icFieldValue),
input 'E':U (icType),
input 1 (iiSeverity),
input btsPosting.tc_Rowid (icRowid),
input 'qadfin-670604':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BPosting>
assign oiReturnStatus = -1.
return.
end.
end. /* For each btsPosting */
END. /* POSTINGBLOCK */
<Q-25 run PeriodByStartEndDate (Stop) in BPeriod >
/* Exception Handling */
assign oiReturnStatus = viLocalReturnStatus.