 dic interpret_single dat;somethingowned;funds;types;units;prd;grp;ass;group;tvd;npr;ce;prot;amts;post;nul;pre;cert;zer;tbl;pr;cov;covs;newcols;splitout;isNpr;srce;lump;date;tab;covno;freq;type;eta;tbon;lv;fv;eve;prices;lpiunits;ii;mdds;etas;tbons;mvrs;covi;ucn;ci;multi;max;i;fnds;tipe;enkey;sumbk
 set up all dictionary variables for a single policy (dic.)

 add polkey to coverage nos
 dat.B.COVNOdat.B.(COVNO+BKEY)
 dat.C.COVNOdat.C.(COVNO+CKEY)
 dat.D.COVNOdat.D.(COVNO+DKEY)
 dat.U.COVNOdat.U.(COVNO+UKEY)
 special for F rec coverages
 max/1,dat.F.COUNT                if no funds set max to 1 not 0 RGC 6 July 2005 bug 06111231 fix
 :For i :In max
     covnodat.F.'COVNO',i
     fndsdat.F.'FUND',i
     'dat.F.COVNO',(i),'covno+(fnds0)dat.F.FKEY'
 :EndFor

 policy
 dic.(Nrds Keys Starts),dat.A.(SRD AKEY START)        allow for multiple policies & diff nrds
 dic.(OrigNRD Nrd)dat.A.(ORIGSRD SRD)
 :If dic.OrigNRD=0
     dic.OrigNRDdic.Nrd                                population of orig nrd appears to be erratic !!
 :EndIf
 dic.Statusstring dat.A.STATUS
 dic.Suspended0
 dic.Indexed'    'string dat.A.INDXBAS
 dic.AnyNotesלdat.W.POLNO
 dic.AnyLifeCover(לdat.L.POLNO)'Y'dat.E.INTEG

 scheme
 dic.SchemeTypestring dat.A.PROD                        #### type conversion for CUPAS?
 dic.Product grpstringdat.A.(PROD GROUP)
 dic.Assurerdic.Product lookupin CONSTANTS.PRODUCTCOMPANIES
 dic.(IsVista IsPM)0                                    n/a
 dic.RuleSet'PERSONAL PENSION'
 assdic.Assurer lookupin #.Policy.CONSTANTS.ASSURERS
 dic.Location''                                         use postcodes when we get some address data
 dic.SchemeTypestring dat.A.PROD                        #### type conversion for CUPAS?
 dic.Product grpstringdat.A.(PROD GROUP)
 dic.(IsVista IsPM)0                    n/a

 dic.Location''                  use postcodes when we get some address data?
 dic.(isGuernsey isJersey)0      PM226: set 'Channel Island' flags (when we can ID)
 dic.(isGuernsey isJersey)(1 1)#.CALCS.PP1_IsCHAN_GJ(dic'')
 dic.RuleSet'PERSONAL PENSION'
 :If /dic.(isGuernsey,isJersey)  dic.RuleSet((1+dic.isJersey)'GUERNSEY ' 'JERSEY '),dic.RuleSet  :EndIf  PM226: channel islands prefix

 dic.Assurerdic.Product lookupin CONSTANTS.PRODUCTCOMPANIES
 assdic.Assurer lookupin #.Policy.CONSTANTS.ASSURERS

 dic.Group'N'BUT'Y'IF(grp.' ')^dat.A.GRPLEFT{(=0)>}dic.ValueDate
 dic.SchemeNameGPP6_LFQ_PRODNAME dic.(Product Group)
dic.Prtype((dic.Group='Y')/'Group '),'Personal Pension'
 dic.ProductType((dic.Group='Y')/'Group '),'Personal Pension'
 dic.GroupName(dic.Group='Y')/DEBdat.A.(GRPNAME1 GRPNAME2 GRPNAME3)

 policyholder
 dic.(Dob StartDate)dat.A.(DOB START)
 dic.(Sex Nino)stringdat.A.(SEX NINO)
dic.Member#.UTILS.DEB,/(stringdat.A.(FORENAME FORENAME2 SURNAME)),' '
 dic.Member#.UTILS.DEB{a b c  a,b,' ',c}stringdat.A.(FORENAME FORENAME2 SURNAME)
 dic.MemberAddressdat.A.(MAILNAME ADD1 ADD2 ADD3 ADD4)
 dic.MemberPostcodedat.A.ADDPC

 agent
dic.AgentAddressdat.A.(AGNAME AGADD1 AGADD2 AGADD3 AGADD4)
 dic.AgentNamAdddat.A.(AGNAME AGADD1 AGADD2 AGADD3 AGADD4)
 dic.AgentPostCodedat.A.AGADDPC
 dic.AgentCommission0

 payment history
 dic.PaidToDate100dat.A.NXTDUE                       CCYYMM
 freq'MA'dat.B.FREQ
 dic.RpFreqfreq/'MA'                                     RP frequency M or A, ' 'in none
 dic.RegPmtFlag/freq                                   are/were there any regular payments?
 dic.SpecDepFlag'S'dat.B.FREQ                        are there any SPs?
 :If dic.RegPmtFlag
     dic.LastRegPmtAmtdat.A.(GROSSER+GROSSME)
     :If 0=dat.A.NXTDUE
         dic.LastRegPmtDatedat.A.LASTPURCH
     :Else
         dic.LastRegPmtDate(freq/1 12)#.UTILS.DATEADDMTHSdat.A.NXTDUE
     :EndIf
 :Else
     dic.(LastRegPmtAmt LastRegPmtDate)0
 :EndIf

 :With dic
     PaidToDateFlag(PaidToDate0.01ValueDate1003#.UTILS.QTS)^Status'CURR'            PaidToDateflag removed
     DirDebActiveRegPmtFlag^PaidToDateFlag              guess whether DirDeb is active    as it was confusing users
     DirDebActiveRegPmtFlag^(PaidToDate0.01ValueDate1003#.UTILS.QTS)^Status'CURR'    GA : 22dec2005
 :EndWith

 previous transfer table
 tvd amts cert prot post ce srce lump covsdat.C.(COVSTRT PREMIUM AMTCERT AMTPROT PRTVPOST CASHEQ SOURCE LUMPSUM COVNO)

 srceTranslateCupasTVSource srce

 :If dic.IsPtt׽tvd

     npr0.01ט0.5+100amts-prot+ce        non-protected rights   (rounded to nearest p)
     pre0.01ט0.5+100prot+ce-post        PR pre                 (rounded to nearest p)
     nul zer(npr)'' 0                  default values

     dic.PttWidesrce tvd tvd amts npr pre post(certlump)zer covs
 :Else
     dic.PttWide0 10''
 :EndIf

 newcols{(),}  suffix replicated elements of  as new cols to cut table 
     from B records (RPs and SPs: no protected rights)
 tbl0 3 newcols dat.B.(COVNO CBSTRT PREMIUM/'S'=FREQ)

 from C records (transfers)
 cov datedat.C.(COVNO COVSTRT)
 prdat.C.(AMTPROT+CASHEQ)           protected rights
 nprdat.C.PREMIUM-pr                non-protected rights

 tbl,0 5 newcols cov date npr/npr
 tbl,1 5 newcols cov date pr/pr

 tbltbl    add dummy reason code rjp 14dec2004

 'PAYTS'dic.NS''
 dic.PAYTS.(COVCON EFFECTDATE GROSSPAYMENT PROT ACTIVITY RSNCOD)tbl

 assets
 funds units types prices lpiunits'FUND' 'UNITS' 'TYPE' 'PRICE' 'LPIUN'collectdat.F
 somethingownedunits>0

 dic.(InPAF InUWP InSNF)somethingowned.^funds.#.CUPAS.CONSTANTS.(PSI_PAF_FUNDS PSI_WP_FUNDS PSI_SAFETYNET_FUNDS)
 dic.(IsPr IsNpr)somethingowned.^(types'PROT').=1 0

 tab'TYPE' 'UNVAL' 'TBON' 'LPIUNV' 'LPITB' 'MDDSC' 'LPIMDD' 'MVADJ' 'LPIMVA' 'ETADJ' 'LPIETA'xtract dat.F
 :If dic.InSNF
    ii(fundsPSI_SAFETYNET_FUNDS)/funds
     ii(funds#.CUPAS.CONSTANTS.PSI_SAFETYNET_FUNDS)/funds       gil : 23dec2005
     tab.UNVAL[ii](tab.UNVAL[ii])units[ii]#.CUPAS.CONSTANTS.SNFFLOOR
     tab.LPIUNV[ii](tab.LPIUNV[ii])lpiunits[ii]#.CUPAS.CONSTANTS.SNFFLOOR
 :EndIf
 isNpr'ORD 'stringtab.TYPE
 splitout{ defined inline to bind reference to isNpr
 split out and sum: NPR PRpre PRpost
 from  total  LPI
     tot lpi(+/)              #### why elements not scalar or length-1?
     nprtot+.isNpr
    pre post+/(1 0.tot~isNpr)+1 1.lpi
     pre post+/(1 0.tot~isNpr)+1 1.lpi~isNpr  bug 27143227  fix RGC/RJP 28/10/2005
    pre post{(10*-)ט0.5+(10*)׸}2     Round to 2dp 200503\24103020 bug fix RGC  24/3/2005
     npr pre post
 }
 fvtab.UNVAL splitout tab.LPIUNV
 eve+/dat.E.(EVEORD EVEPROT)
 eveׄfv[1],+/fv[2 3]                       ensure rebate is 0 if fv 0 : PAG : 01/11/05
 dic.EVEseve[1],eve[2]{׾+/}fv[2 3]      EVE adjustments for all policies combined
 dic.POLEVEs,dat.E.EVEORD                  EVE npr adjustment for each policy
 dic.GrossFundValuestab.(UNVAL+TBON)splitout tab.(LPIUNV+LPITB)
 dic.MDDstab.MDDSC splitout tab.LPIMDD
 dic.MVRstab.MVADJ splitout tab.LPIMVA
 dic.SPPstab.ETADJ splitout tab.LPIETA      but use  calcSPP -- when?
 dic.TBONstab.TBON splitout tab.LPITB

 dic.PAYTS.(Loy nprTfrFV Eve)(dic.PAYTS.COVCON)0
 dic PSI_DATA_CUR dat
 dic.LOYs(dat.A.AKEY)PSI_CALC_LOY dic                   calc loyalty bonus amounts

covs freq type mdds etas tbons mvrs'COVNO' 'FREQ' 'TYPE' 'MDDSC' 'ETADJ' 'TBON' 'MVADJ'collectdat.F
 covs freq type mdds etas tbons mvrs(,/)'COVNO' 'FREQ' 'TYPE' 'MDDSC' 'ETADJ' 'TBON' 'MVADJ'collectdat.F    clean up nesting
 :With dic
     :With PAYTS
       :If /lv(freq,'SING')^type,'ORD '
        :If /lv'SING' 'ORD 'freq type
            ucnlv/covscovs
            ci((~PROT)/COVCON)ucn
           ci(lvci+/PROT)/ci                remove adjustments (ie no coverage associated)
            ci(lvci+/~PROT)/ci               200503\18083631 bug fix RGC/RJP 18/3/2005
            ci(#.UTILS.WHERE~PROT)[ci]
            cov(COVCON)99
            cov[ci]lv/ucn
           covicov.=covs
           mdd SPP Tbon mvrcovi{+/[2]}mdds etas tbons mvrs
            mdd SPP Tbon mvr(mdds etas tbons mvrs)+.covs.=cov
        :Else
            mddSPPTbonmvr(COVCON)0
        :EndIf
         tipetype'PROT'                          convert to logical                      sjt 13apr05
         enkey10                                convert to key                          sjt 13apr05
         sumbk{(2)+.(enkey 2).=enkey }     sum (2) by keys  and [1 2]          sjt 13apr05
         mdd SPP Tbon mvrCOVCON PROT sumbk covs tipe mdds etas tbons mvrs/'SING'freq  sjt 13apr05
     :EndWith
     NprTfrFV NprTfrMVR NprTfrMDDPAYTS.(((~PROT)^ACTIVITY=5)+.׳nprTfrFV mvr mdd)
 :EndWith
 200503\18083631 bug fix RGC/RJP 18/3/2005
 200503\24103020 bug fix RGC  24/3/2005
 200504\131250   bug fix SJT  13apr2005 : failing to separate PR/NPR sums in PAYTS
 20050606        bug fix SJT  06jun05 : removed spurious space from Member
 200507\06111231 bug fix RGC  06jly05 : if no funds set max to 1 not 0
 T30_PM226:
 bug 27143227  fix RGC/RJP 28/10/2005
 ensure eve rebate is 0 if fv 0 : PAG : 01/11/05
 added default for AgentCommission as this is now screenscraped for L70 : gil : 17jan2006