project QadFinancials > class BPeriod > method ValidateComponentPre
Description
Validations before the ancestor validation code.
Validate module close against unposted transaction.
For a acitivities related to the accounting year set the status for all accounting periods.
When the status is set to 'open' then we indiciate that the period.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bperiod.p)
/* Definitions in the code because of case-sensitive option */
define variable vcTemp as character case-sensitive no-undo.
define variable vcTempTr as character case-sensitive no-undo.
define variable doQadWkfl as com.qad.eefin.bmfgqadwkfl.GetQadWkflRecords no-undo.
assign oiReturnStatus = -98
viLocalReturnStatus = 0
vcListPeriodStatus = {&PERIODSTATUSES}.
VALIDATEPREBLOCK: DO :
/* ======================================================================== */
/* Call a submethod that will hold all Periodic-costing related validations */
/* ======================================================================== */
if vlPeriodicCostingModIsActive = ?
then do:
<M-75 run PeriodicCostingModuleIsActive
(input vcDomainCode (icDomainCode),
output vlPeriodicCostingModIsActive (olPeriodicCostingModuleIsActive),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
end.
if vlPeriodicCostingModIsActive
then do:
<M-24 run ValidateComponentPrePC (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper. /* do not leave the block even in case of errors as we want to gather all errors at once */
end.
/* ================================================== */
/* Validate module close against unposted transaction */
/* ================================================== */
for each t_sPeriod where
t_sPeriod.tc_Status <> "":U:
if(t_sPeriod.PeriodTypeCode <> {&PERIODTYPECODE-NORMAL})
then next.
/* fill calculated fields tcDomainCode and tcEntityCode, because they can be changed on UI */
<Q-2 run CompanyByDomain (all) (Read) (Cache)
(input t_sPeriod.Company_ID, (CompanyId)
input '', (DomainId)
input ?, (Active)
output dataset tqCompanyByDomain) in BCompany >
find first tqCompanyByDomain where
tqCompanyByDomain.tiCompany_ID = t_sPeriod.Company_ID
no-error.
if available tqCompanyByDomain
then Assign t_sPeriod.tcDomainCode = tqCompanyByDomain.tcDomainCode
t_sPeriod.tcEntityCode = tqCompanyByDomain.tcCompanyCode.
find first t_iPeriod where
t_iPeriod.Company_ID = t_sPeriod.Company_ID and
t_iPeriod.PeriodYearPeriod = t_sPeriod.PeriodYearPeriod no-error.
if not available t_iPeriod and t_sPeriod.tc_Status = "D":U then next.
/* Period can't be deleted or closed for postings if unposted transactions still exist */
assign vlPeriodCloseIsAllowed = true.
if t_sPeriod.tc_Status = "D":U or
(t_sPeriod.tc_Status = "C":U and
t_sPeriod.PeriodIsPostingGLAllowed = no and
available t_iPeriod and
t_iPeriod.PeriodIsPostingGLAllowed = yes) or
(t_sPeriod.PeriodIsPostingGLAllowed = no and
t_sPeriod.tc_Status = "N":U)
then do:
<Q-3 assign vlFcQueryRecordsAvailable = TransactionByDateType (NoCache)
(input t_sPeriod.tcDomainCode, (Domain)
input t_sPeriod.tcEntityCode, (Entity)
input '':U, (Type)
input t_sPeriod.PeriodStartDate, (StartDate)
input t_sPeriod.PeriodEndDate, (EndDate)) in BMfgUnpostedTransDetail >
if vlFcQueryRecordsAvailable <> false
then do:
if t_sPeriod.tc_Status = "D":U
then do:
assign vcMessage = trim(substitute(#T-15'Cannot delete GL period &1. Unposted transactions exist.':100(18161)T-15#, string(t_sPeriod.PeriodPeriod)))
viLocalReturnStatus = -1.
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8033':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if t_sPeriod.tc_Status = "D":U */
else assign vlPeriodCloseIsAllowed = false.
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* if t_sPeriod.tc_Status = "D":U or */
else do:
if t_sPeriod.tc_Status = "C":U and vlPeriodCloseIsAllowed
then do:
if (t_sPeriod.PeriodIsPostingSalesAllow = no and
available t_iPeriod and
t_iPeriod.PeriodIsPostingSalesAllow = yes) or
(t_sPeriod.PeriodIsPostingSalesAllow = no and
t_sPeriod.tc_Status = "N":U)
then do:
<Q-5 assign vlFcQueryRecordsAvailable = TransactionByDateType (NoCache)
(input t_sPeriod.tcDomainCode, (Domain)
input t_sPeriod.tcEntityCode, (Entity)
input 'SO':U, (Type)
input t_sPeriod.PeriodStartDate, (StartDate)
input t_sPeriod.PeriodEndDate, (EndDate)) in BMfgUnpostedTransDetail >
if vlFcQueryRecordsAvailable <> false
then assign vlPeriodCloseIsAllowed = false.
end.
if (t_sPeriod.PeriodIsPostingPCAllowed = no and
available t_iPeriod and
t_iPeriod.PeriodIsPostingPCAllowed = yes) or
(t_sPeriod.PeriodIsPostingPCAllowed = no and
t_sPeriod.tc_Status = "N":U)
then do:
<Q-60 assign vlFcQueryRecordsAvailable = TransactionByDateType (NoCache)
(input t_sPeriod.tcDomainCode, (Domain)
input t_sPeriod.tcEntityCode, (Entity)
input 'PC':U, (Type)
input t_sPeriod.PeriodStartDate, (StartDate)
input t_sPeriod.PeriodEndDate, (EndDate)) in BMfgUnpostedTransDetail >
if vlFcQueryRecordsAvailable <> false
then assign vlPeriodCloseIsAllowed = false.
end.
if vlPeriodCloseIsAllowed and
((t_sPeriod.PeriodIsPostingInvAllowed = no and
available t_iPeriod and
t_iPeriod.PeriodIsPostingInvAllowed = yes) or
(t_sPeriod.PeriodIsPostingInvAllowed = no and
t_sPeriod.tc_Status = "N":U))
then do:
<Q-6 assign vlFcQueryRecordsAvailable = TransactionByDateType (NoCache)
(input t_sPeriod.tcDomainCode, (Domain)
input t_sPeriod.tcEntityCode, (Entity)
input 'IC':U, (Type)
input t_sPeriod.PeriodStartDate, (StartDate)
input t_sPeriod.PeriodEndDate, (EndDate)) in BMfgUnpostedTransDetail >
if vlFcQueryRecordsAvailable <> false
then assign vlPeriodCloseIsAllowed = false.
if vlPeriodCloseIsAllowed
then do:
<Q-7 assign vlFcQueryRecordsAvailable = TransactionByDateType (NoCache)
(input t_sPeriod.tcDomainCode, (Domain)
input t_sPeriod.tcEntityCode, (Entity)
input 'WO':U, (Type)
input t_sPeriod.PeriodStartDate, (StartDate)
input t_sPeriod.PeriodEndDate, (EndDate)) in BMfgUnpostedTransDetail >
if vlFcQueryRecordsAvailable <> false
then assign vlPeriodCloseIsAllowed = false.
end. /* if vlPeriodCloseIsAllowed */
end. /* if vlPeriodCloseIsAllowed and */
end. /* if t_sPeriod.tc_Status = "C":U and vlPeriodCloseIsAllowed */
end. /* else do: */
if not vlPeriodCloseIsAllowed
then do:
assign vcMessage = trim(substitute(#T-16'Cannot close GL period &1. Unposted transactions exist.':100(18162)T-16#, string(t_sPeriod.PeriodPeriod)))
viLocalReturnStatus = -1.
<M-8 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8034':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if not vlPeriodCloseIsAllowed */
end. /* for each t_sPeriod where */
empty temp-table tPeriodMarkForPeriod.
empty temp-table tPeriodMarkConv.
/* ================================================== */
/* Specific validations for Year-closing */
/* ================================================== */
if vcActivityCode = {&PERIODACTIVITYCODE-YEARMODIFY}
then do:
for each t_sPeriod where
t_sPeriod.tc_Status ="C":U:
if t_sPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED} or
t_sPeriod.PeriodStatus = {&PERIODSTATUS-LOCKED}
then do :
Find t_iPeriod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid
no-lock no-error.
if available t_iPeriod
then do :
buffer-compare t_sPeriod
Except tc_status tcDomainCode tcEntityCode PeriodIsPostingOtherAllow PeriodIsPostingPCAllowed
To t_iPeriod
Save result in vltsPeriodEqualstiPeriod.
If vltsPeriodEqualstiPeriod = false
Then do :
assign viLocalReturnStatus = -1.
if t_sPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED}
then assign vcMessage = trim(#T-25'The Period Status is Reported.Entity GL Period Report Undo should run first':255(733740290)T-25#).
else
assign vcMessage = trim(#T-26'The Period Status is Locked.Entity,GL Period Unlock should run first':255(73460483)T-26#).
<M-22 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPeriod.PeriodStatus':U (icFieldName),
input t_sPeriod.PeriodStatus (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPeriod.tc_Rowid (icRowid),
input 'QadFin-9770':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* If vltsPeriodEqualstiPeriod = false */
end. /* if avialable t_iPeriod */
end. /* if t_sPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED} or */
end. /* for each t_sPeriod where */
end. /* if vcActivityCode = {&PERIODACTIVITYCODE-YEARMODIFY} */
/* ============================================================================================== */
/* For a activities related to the accounting year set the status for all accounting periods */
/* ============================================================================================== */
for each t_sPeriod by t_sPeriod.PeriodYear by t_sPeriod.PeriodPeriod:
find t_iperiod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid
no-lock no-error.
if vcActivityCode = {&PERIODACTIVITYCODE-LOCKPERIOD}
then assign t_sPeriod.PeriodStatus = {&PERIODSTATUS-LOCKED}.
else if vcActivityCode = {&PERIODACTIVITYCODE-YEARCREATE} or
vcActivityCode = {&PERIODACTIVITYCODE-UNDOLOCKED} or
vcActivityCode = {&PERIODACTIVITYCODE-UNDOREPORTED}
then assign t_sPeriod.PeriodStatus = {&PERIODSTATUS-OPEN}.
else if vcActivityCode = {&PERIODACTIVITYCODE-REPORTPERIOD}
then assign t_sPeriod.PeriodStatus = {&PERIODSTATUS-REPORTED}.
else if vcActivityCode = {&PERIODACTIVITYCODE-YEARFREEZE}
then assign t_sPeriod.PeriodStatus = {&PERIODSTATUS-FROZEN}.
if (not available t_iPeriod and
t_sPeriod.tc_Status = '':U) or
(available t_iPeriod and
t_iPeriod.PeriodStatus <> t_sPeriod.PeriodStatus and
t_sPeriod.tc_Status = '':U)
then assign t_sPeriod.tc_Status = 'C':U.
if vcActivityCode = {&PERIODACTIVITYCODE-REPORTPERIOD}
then do:
assign t_sPeriod.PeriodIsReportChecked = true
t_sPeriod.CMask_ID = ?
t_sPeriod.tcCMaskCode = ""
t_sPeriod.tcCMaskDescription = "".
if t_sPeriod.tc_Status = '':U
then assign t_sPeriod.tc_Status = 'C':U.
end.
if vcActivityCode = {&PERIODACTIVITYCODE-LOCKPERIOD}
then do:
assign t_sPeriod.PeriodClosingDate = today.
if t_sPeriod.tc_Status = '':U
then assign t_sPeriod.tc_Status = 'C':U.
/* When locking a period, make sure also the sub-ledgers are turned off */
assign t_sPeriod.PeriodIsPostingGLAllowed = false
t_sPeriod.PeriodIsPostingPurchAllow = false
t_sPeriod.PeriodIsPostingSalesAllow = false
t_sPeriod.PeriodIsPostingInvAllowed = false
t_sPeriod.PeriodIsPostingOtherAllow = false
t_sPeriod.PeriodIsPostingPCAllowed = false
t_sPeriod.CMask_ID = ?
t_sPeriod.tcCMaskCode = ""
t_sPeriod.tcCMaskDescription = "".
end.
/* update extra fields that are not on UI */
if t_sPeriod.tc_status = "C":U or
t_sPeriod.tc_status = "N":U
then assign t_sPeriod.PeriodYearPeriod = integer(string(t_sPeriod.PeriodYear, "9999":U) + string(t_sPeriod.PeriodPeriod, "99":U)).
if t_sPeriod.tc_Status = "N":U or
(available t_iPeriod and
t_iPeriod.PeriodStatus <> t_sPeriod.PeriodStatus)
then do:
assign vcTemp = t_sPeriod.PeriodStatus
vcTempTr = entry(lookup(vcTemp, vcListPeriodStatus, chr(2)) - (if lookup(vcTemp, vcListPeriodStatus, chr(2)) mod 2 = 0 then 1 else 0),
vcListPeriodStatus, chr(2)) no-error.
/* Create Period Marks When Status Changes */
create tPeriodMarkForPeriod.
assign viPeriodMarkIdSeq = viPeriodMarkIdSeq - 1
tPeriodMarkForPeriod.PeriodMark_ID = viPeriodMarkIdSeq.
assign tPeriodMarkForPeriod.PeriodMarkCode = trim(substitute(#T-18'&1/&2 &3 at &4 &5.':200(3069)T-18#, string(t_sPeriod.PeriodYear), string(t_sPeriod.PeriodPeriod), vcTempTr, string(today), string(time,'HH:MM:SS':U)))
tPeriodMarkForPeriod.tc_Status = 'N':U
tPeriodMarkForPeriod.tc_Rowid = string( viPeriodMarkIdSeq ).
assign tPeriodMarkForPeriod.PeriodMarkDescription = #T-52'Period':255(59682)T-52# + ":" + string(t_sPeriod.PeriodYear) + "/" + string(t_sPeriod.PeriodPeriod) + " " + vcTempTr + " " + string(today) + " " + string(time,'HH:MM:SS':U)
tPeriodMarkForPeriod.PeriodMarkIsActive = true
tPeriodMarkForPeriod.Company_ID = t_sPeriod.Company_ID.
if LENGTH (tPeriodMarkForPeriod.PeriodMarkDescription,"CHARACTER") > 60
then assign tPeriodMarkForPeriod.PeriodMarkDescription = substring (tPeriodMarkForPeriod.PeriodMarkDescription,1,60,"CHARACTER").
create tPeriodMarkConv.
assign tPeriodMarkConv.tiPeriod_ID = t_sPeriod.Period_ID
tPeriodMarkConv.tiPeriodMarkOld_ID = tPeriodMarkForPeriod.PeriodMark_ID.
end.
if vcActivityCode = {&PERIODACTIVITYCODE-LOCKJOURNAL}
then do:
/* Check if there are daybook masks applied to the period. */
if t_sPeriod.CMask_ID <> 0 and
t_sPeriod.CMask_ID <> ?
then do:
assign vlOperationalType = FALSE
vlCustomerInvoice = FALSE
vlRevaluation = FALSE
vlMatching = FALSE.
/* ====================================================================================== */
/* Check the daybook masks daybook list. */
/* Check for operational, customer invoice, revaluation and matching daybooks. */
/* ====================================================================================== */
<Q-54 run CMaskJournalByCmaskByJrnlCtrl (all) (Read) (NoCache)
(input t_sPeriod.CMask_ID, (CMaskId)
input ?, (JournalControl)
input viCompanyId, (CompanyId)
output dataset tqCMaskJournalByCmaskByJrnlCtrl) in BCMask>
for first tqCMaskJournalByCmaskByJrnlCtrl where
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalControl = {&JOURNALCONTROL-LOGISTIC} and
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-JOURNALENTRY}
no-lock:
assign vlOperationalType = TRUE.
end.
for first tqCMaskJournalByCmaskByJrnlCtrl where
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalControl = {&JOURNALCONTROL-LOGISTIC} and
(tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICE} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICECORRECT} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-DEBTORCREDITNOTE} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-DEBTORCREDITNOTECORRECT} )
no-lock:
assign vlCustomerInvoice= TRUE.
end.
for first tqCMaskJournalByCmaskByJrnlCtrl where
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALCREDITOR} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALCREDITORDOC} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALDEBTOR} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALDEBTORDOC} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALFIXEDASSET} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALGL} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALINTERCO} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALINVENTORY} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALPERSONNEL} or
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALVAT}
no-lock:
assign vlRevaluation = TRUE.
end.
for first tqCMaskJournalByCmaskByJrnlCtrl where
tqCMaskJournalByCmaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-CIREC}
no-lock:
assign vlMatching = TRUE.
end.
/* ====================================================================================== */
/* Check the daybook masks daybook group list. */
/* Check for operational, customer invoice, revaluation and matching daybooks that might */
/* be assigned to members of the daybook group list. */
/* Only do this if any of the validation flags is false. Otherwise there is no need to */
/* run the valdiation. */
/* ====================================================================================== */
if vlOperationalType = FALSE or
vlCustomerInvoice = FALSE or
vlRevaluation = FALSE or
vlMatching = FALSE
then do:
<Q-55 run CMaskJrnlGrpByCMaskByJrnlCtrl (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sPeriod.CMask_ID, (CMaskId)
input ?, (JournalControl)
output dataset tqCMaskJrnlGrpByCMaskByJrnlCtrl) in BCMask>
for first tqCMaskJrnlGrpByCMaskByJrnlCtrl where
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalControl = {&JOURNALCONTROL-LOGISTIC} and
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-JOURNALENTRY}
no-lock:
assign vlOperationalType = TRUE.
end.
for first tqCMaskJrnlGrpByCMaskByJrnlCtrl where
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalControl = {&JOURNALCONTROL-LOGISTIC} and
(tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICE} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-DEBTORINVOICECORRECT} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-DEBTORCREDITNOTE} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-DEBTORCREDITNOTECORRECT} )
no-lock:
assign vlCustomerInvoice= TRUE.
end.
for first tqCMaskJrnlGrpByCMaskByJrnlCtrl where
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALCREDITOR} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALCREDITORDOC} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALDEBTOR} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALDEBTORDOC} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALFIXEDASSET} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALGL} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALINTERCO} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALINVENTORY} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALPERSONNEL} or
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-REVALVAT}
no-lock:
assign vlRevaluation = TRUE.
end.
for first tqCMaskJrnlGrpByCMaskByJrnlCtrl where
tqCMaskJrnlGrpByCMaskByJrnlCtrl.tcJournalTypeCode = {&JOURNALTYPE-CIREC}
no-lock:
assign vlMatching = TRUE.
end.
end.
/* ====================================================================================== */
/* This section checks two things: */
/* a) If the daybook mask as operational type daybooks, then make sure that there are */
/* no unposted transactions. */
/* b) If the daybook mask as operational daybooks used for customer invoice postings */
/* then check if the invoice post and print program is being run. */
/* ====================================================================================== */
if vlOperationalType = TRUE
then do:
<Q-36 assign vlFcQueryRecordsAvailable = TransactionByDateType (NoCache)
(input t_sPeriod.tcDomainCode, (Domain)
input t_sPeriod.tcEntityCode, (Entity)
input '':U, (Type)
input t_sPeriod.PeriodStartDate, (StartDate)
input t_sPeriod.PeriodEndDate, (EndDate)) in BMfgUnpostedTransDetail>
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMessage = trim(#T-93'Cannot apply the daybook mask to the GL period. Unposted transactions exist.':100(296383400)T-93#)
viLocalReturnStatus = -1.
<M-59 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-839163':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* if vlOperationalType = TRUE */
if vlCustomerInvoice = TRUE
then do transaction:
<Q-12 run JournalByJournalCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (JournalCode)
output dataset tqJournalByJournalCode) in BJournal>
for each tqJournalByJournalCode
no-lock:
doQadWkfl = new com.qad.eefin.bmfgqadwkfl.GetQadWkflRecords (vcDomainCode, tqJournalByJournalCode.tcJournalCode, 'InProgrs').
if doQadWkfl:Available and doQadWkfl:IsLocked()
then do:
/* Raise error */
assign viLocalReturnStatus = -1
vcMessage = trim(#T-640'Cannot apply the daybook mask to the GL period. Invoice Post and Print is running.':255(207759727)T-640#).
<M-9 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-618725':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if doQadWkfl:Available */
end. /* for each tqJournalByJournalCode */
/* Free up all memory */
finally:
if valid-object(doQadWkfl ) then delete object doQadWkfl no-error.
end finally.
end. /* if vlCustomerInvoice = TRUE */
/* ====================================================================================== */
/* This section checks that in the case of a daybook mask using mathcing type daybooks */
/* that there are no matching postings in the transient layer in the period to which the */
/* daybook mask is being applied. */
/* ====================================================================================== */
if vlMatching = TRUE
then do:
/* Check if there are any transient postings in the current period that use a matching daybook. */
<Q-70 run PostingByJrnlTypebyLayerType (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sPeriod.PeriodPeriod, (Period)
input t_sPeriod.PeriodYear, (PeriodYear)
input {&JOURNALTYPE-CIREC}, (JournalType)
input {&LAYERTYPECODE-TRANSIENT}, (LayerTypeCode)
output dataset tqPostingByJrnlTypebyLayerType) in BPosting>
for first tqPostingByJrnlTypebyLayerType
no-lock:
/* Raise error */
assign viLocalReturnStatus = -1
vcMessage = trim(#T-66'Cannot apply the daybook mask to the GL period. The transient layer contains matching postings for daybook code &1.':255(842287648)T-66#)
vcMessage = substitute(vcMessage, tqPostingByJrnlTypebyLayerType.tcJournalCode).
<M-39 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-388512':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* for first tqPostingByJrnlTypebyLayerType */
end. /* if vlMatching = TRUE */
/* ====================================================================================== */
/* This section checks that in the case of a daybook mask using revaluation type daybooks */
/* that there are no unposted revaluation simulations in the period to which the daybook */
/* mask is being applied. */
/* ====================================================================================== */
if vlRevaluation = TRUE
then do:
<Q-79 run RevalheaderByRevalStatus (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input {&REVALSTATUS-INITIAL}, (RevalStatus)
input t_sPeriod.PeriodYearPeriod, (RevalyearPeriod)
output dataset tqRevalheaderByRevalStatus) in BRevaluation>
for first tqRevalheaderByRevalStatus
no-lock:
/* Raise error */
assign viLocalReturnStatus = -1
vcMessage = trim(#T-73'Cannot apply the daybook mask to the GL period. Unposted revaluation transactions exist.':255(826307969)T-73#).
<M-436 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-390203':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* for first tqRevalheaderByRevalStatus */
end. /* if vlRevaluation = TRUE */
end. /* t_sPeriod.CMask_ID <> 0 */
end. /* if vcActivityCode = {&PERIODACTIVITYCODE-LOCKJOURNAL} */
end. /* for each t_sPeriod by t_sPeriod.PeriodYear by t_sPeriod.PeriodPeriod: */
/* ================================================================== */
/* When the status is set to 'open' then we indiciate that the period */
/* period is not checked (~validated) to set it as reported */
/* ================================================================== */
for each t_sPeriod where
t_sPeriod.PeriodStatus = {&PERIODSTATUS-OPEN} and
t_sPeriod.tc_Status = "C":U :
find t_iperiod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid and
t_iPeriod.PeriodStatus <> {&PERIODSTATUS-OPEN}
no-lock no-error.
if available t_iperiod
then assign t_sPeriod.PeriodIsReportChecked = false.
end. /* for each t_sPeriod where */
/* ========================================================================================================== */
/* When trying to lock a period that is already locked then you get an error based upon the object-security. */
/* As this is a rather technical error, this is confusing for the user - so we provide here a clearer message */
/* Do the same for unlocking a period */
/* ========================================================================================================== */
if vcActivityCode = "LockAccountingPeriod":U
then do :
for each t_sPeriod where
t_sPeriod.PeriodStatus = {&PERIODSTATUS-LOCKED} and
t_sPeriod.tc_Status = "C":U
no-lock ,
each t_iperiod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid and
t_iPeriod.PeriodStatus = {&PERIODSTATUS-LOCKED}
no-lock :
assign vcMessage = trim(substitute(#T-29'Unable to lock period &1 as this period is already locked (entity: &2).':255(496109746)T-29#, string(t_sPeriod.PeriodYear) + "/":U + string(t_sPeriod.PeriodPeriod),t_sPeriod.tcEntityCode))
viLocalReturnStatus = -1.
<M-92 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-377746':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* for each t_sPeriod where */
end. /* if icActivityCode = "LockAccountingPeriod":U */
if vcActivityCode = "UndoLocked":U
then do :
for each t_sPeriod where
t_sPeriod.PeriodStatus = {&PERIODSTATUS-OPEN} and
t_sPeriod.tc_Status = "C":U
no-lock ,
each t_iperiod where
t_iPeriod.tc_Rowid = t_sPeriod.tc_Rowid and
t_iPeriod.PeriodStatus = {&PERIODSTATUS-OPEN}
no-lock :
assign vcMessage = trim(substitute(#T-53'Unable to unlock period &1 as this period is not locked (entity: &2).':255(443820555)T-53#, string(t_sPeriod.PeriodYear) + "/":U + string(t_sPeriod.PeriodPeriod),t_sPeriod.tcEntityCode))
viLocalReturnStatus = -1.
<M-61 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-776292':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* for each t_sPeriod where */
end. /* if icActivityCode = "UndoLocked":U */
END. /* VALIDATEPREBLOCK */
assign oiReturnStatus = viLocalReturnStatus.