project QadFinancials > class BPosting > method ValidateComponentPostPostingLine2
Description
ValidatePostingLine
Parameters
blQueryStartedGLByPosting | input-output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
POSTINGLINEBLOCK:
do:
if t_sPosting.tc_Status <> "D":U and
(t_sPostingLine.tc_Status = "N":U or
t_sPostingLine.tc_Status = "C":U)
then do:
if blQueryStartedGLByPosting = false
then do:
<Q-155 run GLByPostingValidation (Start) in BGL >
assign blQueryStartedGLByPosting = true.
end. /* if blQueryStartedGLByPosting = false */
<Q-156 run GLByPostingValidation (all) (Read) (Cache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPostingLine.GL_ID, (GLID)
output dataset tqGLByPostingValidation) in BGL >
find first tqGLByPostingValidation where
tqGLByPostingValidation.tiGL_ID = t_SPostingLine.GL_ID
no-error.
if not available tqGLByPostingValidation
then do:
assign vcMsgExplanation = <M-23 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-157 run SetMessage
(input trim(#T-169'GL account ($1) not found.':100(71047)T-169#) (icMessage),
input t_sPostingLine.tcGLCode (icArguments),
input 'tPostingLine.tcGLCode':U (icFieldName),
input t_sPostingLine.tcGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-7347':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
leave POSTINGLINEBLOCK.
end.
assign t_sPostingLine.tcGLTypeCode = tqGLByPostingValidation.tcGLTypeCode.
/* ================================ */
/* Validations based on System Type */
/* ================================ */
if tqGLByPostingValidation.tcGLSystemTypeCode <> "":U and
tqGLByPostingValidation.tcGLSystemTypeCode <> ?
then do:
/* Validation: No postings allowed on GL with systemtype RESULTPREVIOUSYEAR and RESULTCURRENTYEAR */
assign vcMessage = "":U.
if tqGLByPostingValidation.tcGLSystemTypeCode = {&GLSYSTEMTYPE-RESULTPREVIOUSYEAR}
then assign vcMessage = trim(#T-186'You cannot create postings on system accounts of type Result of the Previous Years.':200(64196)t-186#).
if tqGLByPostingValidation.tcGLSystemTypeCode = {&GLSYSTEMTYPE-RESULTCURRENTYEAR}
then assign vcMessage = trim(#T-187' You cannot create postings on system accounts of type Result of the Current Year.':200(64197)t-187#).
if vcMessage <> "":U
then do:
assign vcMsgExplanation = <M-37 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = vcMessage + chr(10) +
trim(substitute(#T-188'Account: &1.':200(64070)T-188#, trim(t_sPostingLine.tcGLCode) ))
viLocalReturnStatus = -1.
<M-185 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcGLCode':U (icFieldName),
input t_sPostingLine.tcGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-7375':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if vcMessage <> "":U */
end. /* if tqGLByPostingValidation.tcGLSystemTypeCode <> "":U and */
if tqGLByPostingValidation.tcGLSystemTypeCode = {&GLSYSTEMTYPE-CROSSCOMP} and
(t_sPosting.tcLayerTypeCode = {&LAYERTYPECODE-MANAGEMENT} or
t_sPosting.tcLayerTypeCode = {&LAYERTYPECODE-TRANSIENT}) and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-PERIODICCOSTING}
then do:
assign vcMsgExplanation = <M-28 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = #T-189'You cannot use a cross-company GL account &1 when posting to the transient or management layers.':255(69670)t-189#
vcMessage = substitute(vcMessage, t_sPostingLine.tcGLCode)
viLocalReturnStatus = -1.
<M-190 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcGLCode':U (icFieldName),
input t_sPostingLine.tcGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-8247':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* tqGLByPostingValidation.tcGLSystemTypeCode == {&GLSYSTEMTYPE-CROSSCOMP} */
COABLOCK:
DO:
/* ================================================================================= */
/* skip coa validations when daybook is of period costing and skipcoavalforPC = true */
/* ================================================================================= */
if t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-PERIODICCOSTING} and
t_sPostingLine.tlSkipCOAValForPeriodCosting = true
then leave POSTINGLINEBLOCK.
/* ============== */
/* Check Division */
/* ============== */
/* The closing and re-open postings should be on GL level only */
if t_sPosting.tcPeriodTypeCode <> {&PERIODTYPECODE-YEARCLOSING}
then do:
if tqGLByPostingValidation.tlGLIsDivisionAccount
then do:
/* Retrieve sub account from default profile */
if t_sPostingLine.Division_ID = 0 or
t_sPostingLine.Division_ID = ? or
t_sPostingLine.tcDivisionCode = ? or
t_sPostingLine.tcDivisionCode = '':U
then do:
if t_sPostingLine.GL_ID <> 0 and t_sPostingLine.GL_ID <> ?
then do:
<Q-202 run GLForPostingLineCreation (all) (Read) (Cache)
(input ?, (CompanyID)
input ?, (GLCode)
input t_sPostingLine.GL_ID, (GLId)
output dataset tqGLForPostingLineCreation) in BGL >
end.
else do:
<Q-92 run GLForPostingLineCreation (all) (Read) (Cache)
(input t_sPostingLine.Company_ID, (CompanyID)
input t_sPostingLine.tcGLCode, (GLCode)
input ?, (GLId)
output dataset tqGLForPostingLineCreation) in BGL >
end.
find first tqGLForPostingLineCreation no-error.
if available tqGLForPostingLineCreation
then do:
if tqGLForPostingLineCreation.tlGLIsDivisionAccount
then do:
if (tqGLForPostingLineCreation.tiDivisionProfile_ID <> 0 and
tqGLForPostingLineCreation.tiDivisionProfile_ID <> ?)
then do:
<Q-204 run GetDivisionFromProfile (all) (Read) (Cache)
(input viCompanyId, (CompanyId)
input tqGLForPostingLineCreation.tiDivisionProfile_ID, (DivisionProfileId)
output dataset tqDivisionFromProfile) in BProfile >
find first tqDivisionFromProfile no-error.
if available tqDivisionFromProfile
then do:
assign t_sPostingLine.Division_ID = tqDivisionFromProfile.tiDivision_ID
t_sPostingLine.tcDivisionCode = tqDivisionFromProfile.tcDivisionCode.
end.
end.
end.
end.
end. /* End of retreive from ...*/
if (t_sPostingLine.Division_ID = 0 or
t_sPostingLine.Division_ID = ? or
t_sPostingLine.tcDivisionCode = ? or
t_sPostingLine.tcDivisionCode = '':U)
then do:
assign vcMsgExplanation = <M-56 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-172'The GL account &1 requires a sub-account code.':150(3232)t-172#, t_sPostingLine.tcGLCode))
viLocalReturnStatus = -1.
<M-143 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcDivisionCode':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-7338':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* end of if t_sPostingLine.Division_ID = 0 */
end. /* end of if tqGLByPostingValidation.tlGLIsDivisionAccount */
end. /* end of if t_sPosting.tcPeriodTypeCode <> {&PERIODTYPECODE-YEARCLOSING} */
if not tqGLByPostingValidation.tlGLIsDivisionAccount
then assign t_sPostingLine.Division_ID = ?.
if not tqGLByPostingValidation.tlGLIsDivisionAccount and
t_sPostingLine.Division_ID <> 0 and
t_sPostingLine.Division_ID <> ?
then do:
assign vcMsgExplanation = <M-91 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-178'You cannot use a sub-account code with GL account &1.':150(65716)t-178#, t_sPostingLine.tcGLCode))
viLocalReturnStatus = -1.
<M-177 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcDivisionCode':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-7350':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
end. /* COABLOCK */
end. /* if t_sPosting.tc_Status <> "D":U and */
end. /* POSTINGLINEBLOCK */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.