project QadFinancials > class BCInvoice > method DefaultValuesReversePeriod
Description
Default values of period
Parameters
| btDate | input-output | date | |
| biYear | input-output | integer | |
| biPeriod | input-output | integer | |
| ilIfNeededDefaultToday | input | logical | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bcinvoice.p)
/* =================================================================================================== */
/* Method : DefaultValuesReversePeriod */
/* Desc : Get posting period for reversing of supplier invoice */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (B) Date Posting date */
/* (B) Year Posting year */
/* (B) Period Posting period */
/* (I) IfNeededDefaultToday This flag controls whether procedure will try to get opened */
/* period for today if period for required date is closed */
/* =================================================================================================== */
assign oiReturnStatus = -98.
/* =================================================================================================== */
/* Validate input parameters */
/* =================================================================================================== */
if btDate = ? and
biYear = ? and
biPeriod = ?
then do:
assign vcMessage = #T-3'You have not entered all the mandatory values.':255(63250)t-3#
vcContext = "Date=&1|Year=&2|Period=&3":U
vcContext = substitute(vcContext, btDate, biYear, biPeriod)
vcContext = replace(vcContext, "|":U, chr(2)).
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7881':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
return.
end.
/* =================================================================================================== */
/* Posting date, year and period */
/* =================================================================================================== */
if (biYear = 0 or biYear = ?) and
(biPeriod = 0 or biPeriod = ?)
then do:
<Q-46 run PeriodByPeriodStartEndDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input btDate, (Date)
input ?, (PeriodId)
input biYear, (PeriodYear)
input biPeriod, (PeriodPeriod)
output dataset tqPeriodByPeriodStartEndDate) in BPeriod >
end. /* if (biYear = 0 or biYear = ? and */
else do:
<Q-1 run PeriodByPeriodStartEndDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (Date)
input ?, (PeriodId)
input biYear, (PeriodYear)
input biPeriod, (PeriodPeriod)
output dataset tqPeriodByPeriodStartEndDate) in BPeriod >
end. /* else do */
find first tqPeriodByPeriodStartEndDate where
tqPeriodByPeriodStartEndDate.tlPeriodIsPostingPurchAllow = true and
tqPeriodByPeriodStartEndDate.tlPeriodIsPostingGLAllowed = true
no-error.
if available tqPeriodByPeriodStartEndDate
then do:
assign btDate = (if tqPeriodByPeriodStartEndDate.ttPeriodStartDate <= btDate and
tqPeriodByPeriodStartEndDate.ttPeriodEndDate >= btDate
then btDate
else tqPeriodByPeriodStartEndDate.ttPeriodStartDate)
biYear = tqPeriodByPeriodStartEndDate.tiPeriodYear
biPeriod = tqPeriodByPeriodStartEndDate.tiPeriodPeriod.
end.
/* If needed period is not defined or is closed, try to get period for today */
else if ilIfNeededDefaultToday = true
then do:
assign btDate = today
biYear = ?
biPeriod = ?.
<Q-2 run PeriodByPeriodStartEndDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input btDate, (Date)
input ?, (PeriodId)
input ?, (PeriodYear)
input ?, (PeriodPeriod)
output dataset tqPeriodByPeriodStartEndDate) in BPeriod >
find first tqPeriodByPeriodStartEndDate where
tqPeriodByPeriodStartEndDate.tlPeriodIsPostingPurchAllow = true and
tqPeriodByPeriodStartEndDate.tlPeriodIsPostingGLAllowed = true
no-error.
if available tqPeriodByPeriodStartEndDate
then assign biYear = tqPeriodByPeriodStartEndDate.tiPeriodYear
biPeriod = tqPeriodByPeriodStartEndDate.tiPeriodPeriod.
end.
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.