project QadFinancials > class BPeriod > method DataNewMultipleCopyPeriodYear

Description

Method that allows the creation of a new accounting year based on another existing accounting year


Parameters


iiPeriodYearinputintegerthe Accounting Year that you want to create
iiCopyPeriodYearinputintegerthe accounting year where you want to copy from
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bperiod.p)

/* ========================= */
/* Validate input parameters */
/* ========================= */

if iiPeriodYear = 0
then do:
    assign vcMessage      = trim(#T-15'Enter the GL calendar year you want to create.':255(3093)T-15#)
           oiReturnStatus = -1.
           
    <M-1 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-212':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BPeriod>
                     
    return.
end.

if iiCopyPeriodYear = 0
then do:
    assign vcMessage      = trim(#T-16'Enter the GL calendar year you want to copy.':255(3094)T-16#)
           oiReturnStatus = -1.
           
    <M-3 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-213':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BPeriod>
                     
    return.
end.

<Q-2 assign vlFcQueryRecordsAvailable = PeriodByYearPeriod (NoCache)
          (input viCompanyId, (CompanyId)
           input iiCopyPeriodYear, (PeriodYear)
           input ?, (PeriodPeriod)
           input ?, (PeriodId)) in BPeriod >
                                                            
if not vlFcQueryRecordsAvailable
then do:
    assign vcMessage      = trim(#T-17'The GL calendar year you want to copy does not exist.':255(3095)T-17#)
           oiReturnStatus = -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-214':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BPeriod>
                     
    return.
end.

/* ========================================================================================== */
/* First, clear the instance, otherwise problems might occur when executing this method twice */
/* ========================================================================================== */

<M-10 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BPeriod>

if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    return.
end.

/* ================================================================ */
/* Read the Accounting Year to copy                                 */
/* ================================================================ */

<Q-5 run PeriodByYearPeriod (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input iiCopyPeriodYear, (PeriodYear)
           input ?, (PeriodPeriod)
           input ?, (PeriodId)
           output dataset tqPeriodByYearPeriod) in BPeriod >
                             
for each tqPeriodByYearPeriod where
         tqPeriodByYearPeriod.tiCompany_ID = viCompanyId and
         tqPeriodByYearPeriod.tiPeriodYear = iiCopyPeriodYear:
    <M-6 run AddDetailLine (input  'Period':U (icTable), 
                        input  '':U (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BPeriod>
                        
    if viFcReturnSuper <> 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end.
    
    assign tPeriod.PeriodYear                  = iiPeriodYear
           tPeriod.PeriodPeriod                = tqPeriodByYearPeriod.tiPeriodPeriod
           tPeriod.PeriodStartDate             = <M-11 GetDate (input  tqPeriodByYearPeriod.ttPeriodStartDate (itDate), 
               input  iiCopyPeriodYear (iiOldYear), 
               input  iiPeriodYear (iiNewYear)) in BPeriod>
           tPeriod.PeriodEndDate               = <M-12 GetDate (input  tqPeriodByYearPeriod.ttPeriodEndDate (itDate), 
               input  iiCopyPeriodYear (iiOldYear), 
               input  iiPeriodYear (iiNewYear)) in BPeriod>
           tPeriod.PeriodIsPostingGLAllowed    = true /* tqPeriodByYearPeriod.tlPeriodIsPostingGLAllowed    */
           tPeriod.PeriodIsPostingPurchAllow   = true /* tqPeriodByYearPeriod.tlPeriodIsPostingPurchAllow */
           tPeriod.PeriodIsPostingSalesAllow   = true /* tqPeriodByYearPeriod.tlPeriodIsPostingSalesAllow */
           tPeriod.PeriodIsPostingInvAllowed   = true /* tqPeriodByYearPeriod.tlPeriodIsPostingInvAllowed   */
           tPeriod.PeriodIsPostingOtherAllow   = true /* tqPeriodByYearPeriod.tlPeriodIsPostingOtherAllow */
           tPeriod.PeriodTypeCode              = if tqPeriodByYearPeriod.tcPeriodTypeCode = {&PERIODTYPECODE-NORMAL} then
                                                    {&PERIODTYPECODE-CORRECTION}
                                                 else tqPeriodByYearPeriod.tcPeriodTypeCode
           tPeriod.PeriodReportingPeriod       = tqPeriodByYearPeriod.tcPeriodReportingPeriod
           tPeriod.PeriodStatus                = {&PERIODSTATUS-OPEN}.
end. 

/* ============================================================ */
/* validate data - perform external updates - save data         */
/* you don't have to do it here because this method is executed */
/* when they start the period form so when they press save      */
/* the methods will automatically executed                      */
/* ============================================================ */