project QadFinancials > class BPosting > method ValidateComponentPostPosting1
Description
Validate Component after ancestor class - Posting validations - part 1
Parameters
blQueryStartedCompPropByCode | input-output | logical | |
blQueryStartedCompanyPrim | 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
vlIsOnlyTemplateCodeModified = false.
if t_sPosting.tc_Status = "C":U
then do:
BUFFER-COMPARE t_sPosting
EXCEPT tc_status LastModifiedDate LastModifiedTime LastModifiedUser
tcTemplateCode tlSaveAsTemplate
TO t_iPosting
SAVE Result in vlPostingIsTheSame.
if vlPostingIsTheSame <> true
then assign vlIsOnlyTemplateCodeModified = true.
end.
/* ================================== */
/* At least 1 Posting Line must exist */
/* ================================== */
if not can-find(first t_sPostingLine where
t_sPostingLine.tc_ParentRowid = t_sPosting.tc_Rowid and
t_sPostingLine.tc_Status <> "D":U)
then do:
assign vcMsgExplanation = <M-19 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-2 run SetMessage
(input trim(#T-57'Every posting must have at least 1 posting line ($1 $2 $3).':250(16584)T-57#) (icMessage),
input string(t_sPosting.PostingYear) + chr(2) + t_sPosting.tcJournalCode + chr(2) + string(t_sPosting.PostingVoucher) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-7286':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* if not can-find(first ... */
/* =================================================== */
/* Journal Validations for Excel Integration activity */
/* =================================================== */
if vcActivityCode = "ExcelIntegration"
then do:
<Q-30 run JournalByJournalLayerType (all) (Read) (Cache)
(input t_sPosting.Journal_ID, (JournalId)
input ?, (JournalCode)
input ?, (CompanyId)
input ?, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal>
find first tqJournalByJournalLayerType where
tqJournalByJournalLayerType.tiJournal_ID = t_sPosting.Journal_ID
no-error.
/* Prohibit the Journal Entries created to Period Costing Daybooks */
if available tqJournalByJournalLayerType
then do:
if tqJournalByJournalLayerType.tcJournalTypeCode = {&JOURNALTYPE-PERIODICCOSTING}
then do:
assign
vcMessage = substitute(trim(#T-56'You are not allowed to load any postings to Periodic Costing daybook &1.':255(722567017)T-56#), t_sPosting.tcJournalCode)
vcMsgExplanation = <M-94 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
viLocalReturnStatus = -1.
<M-86 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 't_sPosting.tcJournalTypeCode' (icFieldName),
input string(tqJournalByJournalLayerType.tcJournalTypeCode) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-403967':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if tqJournalByJournalLayerType.tcJournalTypeCode = {&JOURNALTYPE-PERIODICCOSTING} */
/* Do not allow postings to operational daybooks */
if tqJournalByJournalLayerType.tcJournalControl = {&JOURNALCONTROL-LOGISTIC}
then do:
assign vcMessage = substitute(trim(#T-40'You are not allowed to load any postings to Daybook Controls(s) &1 for activity &2':100(400172614)T-40#),{&JOURNALCONTROL-LOGISTIC-TR},vcActivityCode)
vcMsgExplanation = <M-6 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
viLocalReturnStatus = -1.
<M-33 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 't_sPosting.tcJournalCode' (icFieldName),
input string(tqJournalByJournalLayerType.tcJournalCode) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-149645':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if tqJournalByJournalLayerType.tcJournalControl = {&JOURNALCONTROL-OPERATIONAL} */
end. /* if available tqJournalByJournalCode*/
end. /* if vcActivityCode = "ExcelIntegration" */
/* =================================================== */
/* Only Official Layer should be used for VAT-postings */
/* =================================================== */
if t_sPosting.tcLayerTypeCode <> {&LAYERTYPECODE-OFFICIAL} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-CONSOLIDATION} and
can-find(first t_sPostingLine where
t_sPostingLine.tc_ParentRowid = t_sPosting.tc_Rowid and
t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-VAT})
then do:
assign vcMsgExplanation = <M-95 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-5 run SetMessage
(input trim(#T-32'Tax postings can only be created in the official accounting layer.':100(2731)T-32#) (icMessage),
input '':U (icArguments),
input 'tPosting.tcLayerTypeCode':U (icFieldName),
input t_sPosting.tcLayerTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-7287':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* Only Official Layer should be used for VAT-postings */
/* ======================================================================================= */
/* Get the company property to check if the company is defined as a consolidation company. */
/* If it it a consolidation company, only following journal types are allowed: */
/* JournalEntry, RevalCreditor, RevalCreditorDoc, RevalDebtor, RevalDebtorDoc, */
/* RevalFixedAsset, RevalGL, RevalInterco, RevalInventory, RevalPersonnel, RevalVat, */
/* Consolidation, YearClosing */
/* ======================================================================================= */
if blQueryStartedCompPropByCode = false
then do:
<Q-62 run CompanyPropertyByCompanyCode (Start) in BCompanyProperty >
assign blQueryStartedCompPropByCode = true.
end. /* if blQueryStartedCompPropByCode = false */
<Q-59 run CompanyPropertyByCompanyCode (all) (Read) (Cache)
(input t_sPosting.Company_ID, (CompanyId)
input '':U, (CompanyCode)
input ?, (DomainCode)
output dataset tqCompanyPropertyByCompanyCode) in BCompanyProperty >
find tqCompanyPropertyByCompanyCode where
tqCompanyPropertyByCompanyCode.tiCompany_ID = t_sPosting.Company_ID
no-lock no-error.
if available tqCompanyPropertyByCompanyCode
then do:
if tqCompanyPropertyByCompanyCode.tlCompanyPropertyIsConsolid = true and
(t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-JOURNALENTRY} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALCREDITOR} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALCREDITORDOC} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALDEBTOR} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALDEBTORDOC} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALFIXEDASSET} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALGL} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALINTERCO} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALINVENTORY} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALPERSONNEL} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-CONSOLIDATION} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-DEDUCTION} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-YEARLYCLOSING})
then do:
assign vcMsgExplanation = <M-25 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(#T-61'You can only use the following daybook types in consolidation entities:':200(999890404)T-61#) + chr(10) +
trim({&JOURNALTYPE-JOURNALENTRY-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALCREDITOR-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALCREDITORDOC-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALDEBTOR-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALDEBTORDOC-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALFIXEDASSET-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALGL-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALINTERCO-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALINVENTORY-TR}) + chr(10) +
trim({&JOURNALTYPE-REVALPERSONNEL-TR}) + chr(10) +
trim({&JOURNALTYPE-CONSOLIDATION-TR}) + chr(10) +
trim({&JOURNALTYPE-YEARLYCLOSING-TR})
viLocalReturnStatus = -1.
<M-60 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.tcJournalTypeCode':U (icFieldName),
input t_sPosting.tcJournalTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-7406':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
end. /* if available tqCompanyPropertyByCompanyCode */
/* ================================================================================== */
/* Coompare the current company-id whether this company belongs to the current domain */
/* ================================================================================== */
if t_sPosting.Company_ID <> viCompanyId
then do:
<Q-64 assign vlFcQueryRecordsAvailable = CompanyByDomain (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input viDomainID, (DomainId)
input true, (Active)) in BCompany >
if vlFcQueryRecordsAvailable = false
then do:
assign vcMsgExplanation = <M-18 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(#T-68'You can only create postings in companies that belong to the current domain.':255(59271)T-68#) + chr(10) +
trim(substitute(#T-69'Current domain ID: &1.':200(59272)T-69#,string(viDomainID))) + chr(10) +
trim(substitute(#T-70'Entity ID of the posting: &1.':200(31306)T-70#,string(t_sPosting.Company_ID))) + chr(10) +
trim(substitute(#T-71'Current Domain Code: &1.':200(59273)T-71#,vcDomainCode)).
if blQueryStartedCompanyPrim = false
then do:
<Q-74 run CompanyPrim (Start) in BCompany >
assign blQueryStartedCompanyPrim = true.
end. /* if blQueryStartedCompanyPrim = false */
<Q-65 run CompanyPrim (all) (Read) (Cache)
(input t_sPosting.Company_ID, (LookupCompanyId)
input ?, (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
find tqCompanyPrim where
tqCompanyPrim.tiCompany_ID = t_sPosting.Company_ID
no-lock no-error.
if available tqCompanyPrim
then assign vcMessage = vcMessage + chr(10) +
trim(substitute(#T-72'Entity code of the posting: &1':200(31307)T-72#,tqCompanyPrim.tcCompanyCode)).
<M-66 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.Company_id':U (icFieldName),
input string(t_sPosting.Company_ID) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-7409':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end.
end. /* if iiTargetField <> viCompanyId */
/* ============================================================================== */
/* Validate that specified journal is a financial control daybook and a journal */
/* entries type. Note that this check is only done for UI initiated activities */
/* ============================================================================== */
if (vcActivityCode = "Create":U or
vcActivityCode = "Modify":U) and
(t_sPosting.tc_status = "N":U or
t_sPosting.tc_status = "C":U) and not vlIsOnlyTemplateCodeModified
then do:
/* If only changed the template code, don't validate it. */
<Q-75 run JournalByJournalLayerType (all) (Read) (Cache)
(input t_sPosting.Journal_ID, (JournalId)
input ?, (JournalCode)
input ?, (CompanyId)
input ?, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal >
find first tqJournalByJournalLayerType where
tqJournalByJournalLayerType.tiJournal_ID = t_sPosting.Journal_ID
no-error.
if not available tqJournalByJournalLayerType or
tqJournalByJournalLayerType.tcJournalControl <> {&JOURNALCONTROL-FINANCIAL} or
(tqJournalByJournalLayerType.tcJournalTypeCode <> {&JOURNALTYPE-JOURNALENTRY} and
tqJournalByJournalLayerType.tcJournalTypeCode <> {&JOURNALTYPE-YEARLYCLOSING} and
tqJournalByJournalLayerType.tcJournalTypeCode <> {&JOURNALTYPE-DEDUCTION})
then do:
assign vcMsgExplanation = <M-55 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-77'The daybooks used for manual journal entries must be of daybook control &1 and be of type &2 or &3 or &4.':255(579021421)T-77#,
{&JOURNALCONTROL-FINANCIAL-TR},
{&JOURNALTYPE-JOURNALENTRY-TR},
{&JOURNALTYPE-YEARLYCLOSING-TR},
{&JOURNALTYPE-DEDUCTION-TR}))
viLocalReturnStatus = -1.
<M-76 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'tPosting.tcJournalCode':U (icFieldName),
input t_sPosting.tcJournalCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-7429':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if not available tqJournalByJournalLayerType or */
end. /* if (vcActivityCode = "Create":U or */
/* ================================================================================================================= */
/* Method checks whether - in case the activity is TransientCreate or TransientModify - t_sPosting.tcLayerCode is */
/* effectively Transient. The check on the fact that t_sPosting.tcLayerCode is fileld and its correctness is already */
/* done by the ancestor-code of method ValidateComponent. As this method is a submethod of method ValidateComponent */
/* that is called after the ancestor-code, we can be sure about its value (no neeed to check it here again) */
/* As t_iPosting.tcLayerTypeCode is filled using the RKBF-mechanism, we can slo be sure on that value. */
/* ================================================================================================================= */
if (vcActivityCode = "TransientCreate":U or
vcActivityCode = "TransientModify":U or
vcActivityCode = "TransientReverse") and
t_sPosting.tcLayerTypeCode <> {&LAYERTYPECODE-TRANSIENT} and
(t_sPosting.tc_Status = "N":U or
(t_sPosting.tc_Status = "C":U and
can-find (t_iPosting where
t_iPosting.tc_Rowid = t_sPosting.tc_Rowid and
t_iPosting.tcLayerTypeCode <> t_sPosting.tcLayerTypeCode)))
then do:
assign vcMsgExplanation = <M-163 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-79'This activity only allows you to select daybooks in the transient layer. Posting: &1/&2/&3.':255(63235)T-79#,trim(string(t_sPosting.PostingYear)),trim(t_sPosting.tcJournalCode),trim(string(t_sPosting.PostingVoucher)))) + chr(10) +
trim(substitute(#T-80'The daybook used in the posting should be in the &1 layer.':255(63238)T-80#,{&LAYERTYPECODE-TRANSIENT-TR})).
<M-78 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.tcLayerTypeCode':U (icFieldName),
input t_sPosting.tcLayerTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7430':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if vcActivityCode = "TransientCreate":U or */
/* ====================================================================================== */
/* Check if the template code is filled when the posting is flagged to save as a template */
/* and if the template code is valid when the flag is not set */
/* ====================================================================================== */
if t_sPosting.tlSaveAsTemplate = true and
(t_sPosting.tcTemplateCode = ? or
t_sPosting.tcTemplateCode = '':U)
then do:
assign vcMsgExplanation = <M-63 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(#T-81'You must fill in the template code when saving a journal entry as a template.':255(68539)T-81#)
viLocalReturnStatus = -1.
<M-82 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.tcTemplateCode':U (icFieldName),
input t_sPosting.tcTemplateCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-7675':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if t_sPosting.tlSaveAsTemplate = true and */
else if t_sPosting.tlSaveAsTemplate = false and
(t_sPosting.tcTemplateCode <> ? and
t_sPosting.tcTemplateCode <> '':U)
then do:
assign vcMsgExplanation = <M-16 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<Q-83 run PostingTemplateByCode (all) (Read) (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPosting.tcTemplateCode, (PostingTemplateCode)
output dataset tqPostingTemplateByCode) in BPostingTemplate >
find first tqPostingTemplateByCode no-error.
if not available tqPostingTemplateByCode
then do:
<M-84 run SetMessage
(input #T-85'The posting template code does not exist.':255(69451)T-85# (icMessage),
input '':U (icArguments),
input 'tPosting.tcTemplateCode':U (icFieldName),
input t_sPosting.tcTemplateCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8130':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
end. /* if not available tqPostingTemplateByCode */
end. /* else if t_sPosting.tlSaveAsTemplate = false and */
/* =============================================== */
/* Validations for Chronological Invoice Numbering */
/* =============================================== */
if vlPostingDomainIsChronolNr = true and
t_sPosting.tc_Status ='N' and
(t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-CREDITORINVOICE} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-CREDITORINVOICECORRECT} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-CREDITORCREDITNOTE} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-CREDITORCREDITNOTECORRECT} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORFINANCECHARGE} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICE} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICECORRECT} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORCREDITNOTE} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEDUCTION} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORCREDITNOTECORRECT})
then do:
/* Check if this is an operational customer invoice */
if (t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICE} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICECORRECT} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORCREDITNOTE} or
t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORCREDITNOTECORRECT})
then do:
<Q-48 run JournalByJournalLayerType (all) (Read) (Cache)
(input t_sPosting.Journal_ID, (JournalId)
input ?, (JournalCode)
input ?, (CompanyId)
input ?, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal>
find first tqJournalByJournalLayerType where
tqJournalByJournalLayerType.tiJournal_ID = t_sPosting.Journal_ID and
tqJournalByJournalLayerType.tcJournalControl = {&JOURNALCONTROL-LOGISTIC}
no-error.
if available tqJournalByJournalLayerType
then assign vlIsFinacials = FALSE.
else assign vlIsFinacials = TRUE.
end. /* if (t_sPosting.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICE} .... */
else assign vlIsFinacials = TRUE.
if vlIsFinacials = TRUE
then do:
/* ================== */
/* Warning or Error ? */
/* ================== */
if vcPostingDomainNonChronError = {&NONCHRONOLOGICAL-ERROR}
then assign viNonChronErrorStatus = -1
vcNonChronErrorType = "E":U.
else assign viNonChronErrorStatus = (if viLocalReturnStatus >= 0
then 1
else viLocalReturnStatus)
vcNonChronErrorType = "W":U.
/* ======================================================== */
/* Check if no invoices exist yet with a later posting date */
/* ======================================================== */
<Q-90 assign vlFcQueryRecordsAvailable = PostingForChronolCheck (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPosting.Journal_ID, (JournalId)
input t_sPosting.PostingDate, (PostingDateAfter)) in BPosting >
if vlFcQueryRecordsAvailable <> false
then do:
<Q-42 run PostingForChronolCheck (last) (Read) (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPosting.Journal_ID, (JournalId)
input t_sPosting.PostingDate, (PostingDateAfter)
output dataset tqPostingForChronolCheck) in BPosting >
find last tqPostingForChronolCheck where
tqPostingForChronolCheck.tiCompany_ID = t_sPosting.Company_ID and
tqPostingForChronolCheck.tiJournal_ID = t_sPosting.Journal_ID and
tqPostingForChronolCheck.ttPostingDate > t_sPosting.PostingDate
no-error.
if available tqPostingForChronolCheck
then do:
assign vcMsgExplanation = <M-73 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcDatetemp = <M-43 DisplayDate (input t_sPosting.PostingDate (itDate)) in BPosting>
vcDatetemp1 = <M-51 DisplayDate (input tqPostingForChronolCheck.ttPostingDate (itDate)) in BPosting>.
assign vcMessage = trim(substitute(#T-98'Chronological numbering of invoices is applicable. You must specify a posting date on or after &1.':255(161319626)T-98#,vcDatetemp1,string("99/99/9999")))
viLocalReturnStatus = viNonChronErrorStatus.
<M-88 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.PostingDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input vcNonChronErrorType (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-59627':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if available tqPostingForChronolCheck */
end. /* if vlFcQueryRecordsAvailable <> false */
/* ==================================================================== */
/* The posting date of the posting being created can not be future date */
/* ==================================================================== */
if t_sPosting.PostingDate > today
then do:
assign vcMsgExplanation = <M-44 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
vcDatetemp = <M-21 DisplayDate (input t_sPosting.PostingDate (itDate)) in BPosting>.
assign vcMessage = (if vcPostingDomainNonChronError = {&NONCHRONOLOGICAL-ERROR}
then trim(#T-24'You cannot use a future posting date, because it might create gaps in the chronological numbering of invoices on your system.':255(200197380)T-24#)
else trim(#T-54'Do you really want to use a future posting date? Doing so may create gaps in the chronological numbering of invoices in your system.':255(734078477)T-54#))
viLocalReturnStatus = viNonChronErrorStatus.
<M-67 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.PostingDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input vcNonChronErrorType (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-128521':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if t_sPosting.PostingDate > today */
/* =================================================== */
/* Warning when first posting on a journal in a period */
/* =================================================== */
<Q-10 assign vlFcQueryRecordsAvailable = PostingByCyJournalPeriod (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPosting.Journal_ID, (JournalId)
input t_sPosting.Period_ID, (PeriodId)) in BPosting >
if vlFcQueryRecordsAvailable = false
then do:
assign vcMessage = trim(substitute(#T-52'This is the first invoice posted on this daybook in GL period &1. Have you posted all required invoices for the previous period?':200(623203150)T-52#, trim(string(t_sPosting.PostingYearPeriod)) ))
viLocalReturnStatus = if viLocalReturnStatus >= 0 then 1 else viLocalReturnStatus.
<M-37 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.PostingPeriod':U (icFieldName),
input t_sPosting.PostingPeriod (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-905575':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if vlFcQueryRecordsAvailable = false */
end. /* if vlIsFinacials = TRUE */
end. /* if vlPostingDomainIsChronolNr = true and */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.