project QadFinancials > class BVATPeriod > method DefaultValues

Description

Returns some default values depending on the supplied year.


Parameters


iiYearinputintegerThe year you want default values for. You can supply 0 or ? if you don't know it.
oiYearoutputintegerThe default year
oiPeriodoutputintegerThe default period
otStartDateoutputdateThe default Start Date
otEndDateoutputdateThe default end date
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bvatperiod.p)

<Q-3 run VATPeriodByStartDate (Start) in BVATPeriod >

if iiYear = 0 or
   iiYear = ?
then do:
    <Q-1 run VATPeriodByStartDate (last) (Read) (Cache)
          (input viCompanyId, (CompanyId)
           input ?, (Year)
           input ?, (StartDate)
           output dataset tqVATPeriodByStartDate) in BVATPeriod >
                               
    find first tqVATPeriodByStartDate
               no-error.
               
    assign iiYear = if available tqVATPeriodByStartDate
                    then tqVATPeriodByStartDate.tiVatPeriodYear
                    else year(today).
end.

assign oiYear = iiYear.

for each bVATPeriod where
         bVATPeriod.Company_ID    = viCompanyId and
         bVATPeriod.VATPeriodYear = iiYear
         by bVATPeriod.VATPeriodPeriod desc:
    assign oiPeriod    = bVATPeriod.VATPeriodPeriod + 1
           otStartDate = bVATPeriod.VATPeriodEndDate + 1.
           
    leave.
end.

<Q-2 run VATPeriodByStartDate (last) (Read) (Cache)
          (input viCompanyId, (CompanyId)
           input iiYear, (Year)
           input ?, (StartDate)
           output dataset tqVATPeriodByStartDate) in BVATPeriod >
                               
find first tqVATPeriodByStartDate
           no-error.
           
if available tqVATPeriodByStartDate
then do:
    if tqVATPeriodByStartDate.tiVATPeriodPeriod >= oiPeriod
    then assign oiPeriod    = tqVATPeriodByStartDate.tiVATPeriodPeriod + 1
                otStartDate = tqVATPeriodByStartDate.ttVATPeriodEndDate + 1.
end.
else
if oiPeriod = 0
then assign oiPeriod = 1
            otStartDate = date(1, 1, oiYear).
            
assign otEndDate   = if month(otStartDate) = 12
                     then date(12, 31, year(otStartDate))
                     else date(month(otStartDate) + 1, 1, year(otStartDate)) - 1.
                     
<Q-4 run VATPeriodByStartDate (Stop) in BVATPeriod >