                   PRIVATE cKolPokPosition
PRIVATE cStr1,cStr2,cStr3,cResult,cResult1,cResult2,i ,cResult61
PRIVATE aArr,aArr1,i, i1,ArrLen,Arrlen1,kd_stran,kd_stran1, KD_, adr1
PRIVATE cPrizPeriod,PrVidDok, doc_up ,ArrLen61,aArr61, n_listr6
PRIVATE ArrLen81, aArr81, cResult81, n_listr8
SetKolPokTo("П",0)
i := 0
PRIVATE cDokPredst
Private cPrizAdr,cTelSluzh,cINNFL,cINNRuk,cINNBuh,cGrazhdRuk
Private cFIOBuh,cGrazhdBuh,cFIOUpPred,cInnUpPred,cGrazhdUpPred,cFIORuk


// Сведения о налогоплательщике.
IF UvNalUL()
 // Налогоплательщик - ЮЛ.
 // Сведения об организации

     // О Российской.
WriteStr("НаимЮЛПол:"+UserParam("000014"),"O")
WriteStr("ИННЮЛ:"+UserParam("000016"),"O")
WriteStr("КППЮЛ:"+UserParam("000017"),"O")
WriteStr('ТелНП:'+GetData('ТелНП','C'),"О")
///
WriteStr("###","S")
 // Сведения о руководстве организации.
cFIORuk := UserParam("000049")
WriteStr("ФИОРук:"+UserParam("000049"),"O")
IF cFIORuk= ",,"
SayAndWait('Укажите в пользовательском справочнике Фамилию, Имя, Отчество руководителя')
Endif
doc_up:=GetData('УпПред','С')
WriteStr('УпПред:'+GetData('УпПред','С'),'О')
if !EMPTY(doc_up)
    WriteStr("ДокУпПред:"+UserParam("000078"),"У")
 endif
WriteSTR("###","S")
ELSE

cStr1 := GetData("МН1","С")
cStr2 := GetData("МН2","С")
cStr3 := GetData("МН3","С")
cResult := cStr1+cStr2+cStr3

WriteStr("ФИО:"+UserParam("000036"),"O")
cINNFL := UserParam("000037")
WriteStr("ИННФЛ:"+UserParam("000037"),"O")
WriteStr('ТелНП:'+GetData('ТелНП','C'),"О")
doc_up:=GetData('УпПред','С')
WriteStr('УпПред:'+GetData('УпПред','С'),'О')
if !EMPTY(doc_up)
    WriteStr("ДокУпПред:"+UserParam("000078"),"У")
 endif
WriteStr("###","S")
ENDIF

SetRound(0)
WriteStr("ПризФОтч:1","О")
WriteStr("КНД:1151001","О")
WriteStr("НаимФОтч:НАЛОГОВАЯ ДЕКЛАРАЦИЯ ПО НАЛОГУ НА ДОБАВЛЕННУЮ СТОИМОСТЬ","Н")
WriteStr("ВерФОтч:3.00006","О")
WriteStr("ПериодВерОтч:13.12.2006,","О")
PrVidDok:=Getdata("ВД","С")
WriteStr("ПризВидДок:"+GETDATA("ВД","С"),"О")
IF PrVidDok="3"
WriteStr('НомерКорр:'+GetData("НОМЕРКОРР","С"),"У")
ENDIF
WriteStr('ПризПериодОтч:'+GetData('НП','С'),'О')
WriteStr('НомерПериодОтч:'+GetData('НКМ','С'),'О')
WriteStr('ГодПериодОтч:'+GetData('Щ','C'),'О')
WriteStr("ОКЕИ:383","О")
cKolPokPosition := WriteStr("КолПокФОтч:","О")
WriteStr("###","S")
WriteStr('П000010001000:'+GetData('КБК','C'),"П")
WriteStr('П000010002000:'+GetData('ОКАТО','C'),"П")
WriteStr('П000010003000:'+GetData('ОКВЭД','C'),"П")
WriteStr('П000010004000:'+GetData('C330','N'),"П")
WriteStr('П000010005000:'+GetData('C340','N'),"П")

WriteStr("###","S")

// обработка массива
aArr := GetData("02","A")
I := 2
IF !EMPTY(aArr)
   ArrLen := LEN(aArr)
   cResult:= "AAA"
   While (i <= ArrLen).AND.!EMPTY(Alltrim(cResult))

      WriteStr('П000020001000:'+DoStr(aArr[i][1]),"П")
      WriteStr('П000020002000:'+DoStr(aArr[i][2]),"П")
      WriteStr('П000020003000:'+DoStr(aArr[i][3]),"П")
      WriteStr('П000020004000:'+DoStr(aArr[i][4]),"П")
      WriteStr('П000020005000:'+DoStr(aArr[i][5]),"П")
      WriteStr('П000020006000:'+DoStr(aArr[i][6]),"П")
      WriteStr('П000020007000:'+DoStr(aArr[i][7]),"П")
      WriteStr('П000020008000:'+DoStr(aArr[i][8]),"П")
      WriteStr('П000020009000:'+DoStr(aArr[i][9]),"П")
      WriteStr('П000020010000:'+DoStr(aArr[i][10]),"П")
      WriteStr('П000020011000:'+DoStr(aArr[i][11]),"П")
      WriteStr('П000020012000:'+DoStr(aArr[i][12]),"П")
      WriteStr('П000020013000:'+DoStr(aArr[i][13]),"П")

      WriteSTR("###","S")
      i := i+1
      IF i <= ArrLen
         cResult:= ArrToString(aArr[i])
      ENDIF
   ENDDO
ENDIF


WriteStr('П000030001004:'+GetData('А010','N'),"П")
WriteStr('П000030001005:'+GetData('Р210074105','N'),"П")
WriteStr('П000030001006:'+GetData('Б010','N'),"П")
WriteStr('П000030002004:'+GetData('А020','N'),"П")
WriteStr('П000030002005:'+GetData('Р210074905','N'),"П")
WriteStr('П000030002006:'+GetData('Б020','N'),"П")
WriteStr('П000030003004:'+GetData('А030','N'),"П")
WriteStr('П000030003005:'+GetData('Р210075705','N'),"П")
WriteStr('П000030003006:'+GetData('Б030','N'),"П")
WriteStr('П000030004004:'+GetData('А040','N'),"П")
WriteStr('П000030004005:'+GetData('Р210076505','C'),"П")
WriteStr('П000030004006:'+GetData('Б040','N'),"П")
WriteStr('П000030005004:'+GetData('А050','N'),"П")
WriteStr('П000030005005:'+GetData('Р210077305','C'),"П")
WriteStr('П000030005006:'+GetData('Б050','N'),"П")
WriteStr('П000030006004:'+GetData('А060','N'),"П")
WriteStr('П000030006005:'+GetData('Р210078105','C'),"П")
WriteStr('П000030006006:'+GetData('Б060','N'),"П")
WriteStr('П000030007004:'+GetData('А070','N'),"П")
WriteStr('П000030007006:'+GetData('Б070','N'),"П")
WriteStr('П000030008004:'+GetData('А080','N'),"П")
WriteStr('П000030008006:'+GetData('Б080','N'),"П")
WriteStr('П000030009004:'+GetData('А090','N'),"П")
WriteStr('П000030009006:'+GetData('Б090','N'),"П")
WriteStr('П000030010004:'+GetData('А100','N'),"П")
WriteStr('П000030010006:'+GetData('Б100','N'),"П")
WriteStr('П000030011004:'+GetData('А110','N'),"П")
WriteStr('П000030011005:'+GetData('Р210082905','N'),"П")
WriteStr('П000030011006:'+GetData('Б110','N'),"П")
WriteStr('П000030012004:'+GetData('А120','N'),"П")
WriteStr('П000030012005:'+GetData('Р210082105','C'),"П")
WriteStr('П000030012006:'+GetData('Б120','N'),"П")
WriteStr('П000030013004:'+GetData('А130','N'),"П")
WriteStr('П000030013005:'+GetData('Р210085305','C'),"П")
WriteStr('П000030013006:'+GetData('Б130','N'),"П")
WriteStr('П000030014004:'+GetData('А140','N'),"П")
WriteStr('П000030014005:'+GetData('Р210083705','C'),"П")
WriteStr('П000030014006:'+GetData('Б140','N'),"П")
WriteStr('П000030015004:'+GetData('А150','N'),"П")
WriteStr('П000030015005:'+GetData('Р210084505','C'),"П")
WriteStr('П000030015006:'+GetData('Б150','N'),"П")
WriteStr('П000030016004:'+GetData('А160','N'),"П")
WriteStr('П000030016005:'+GetData('Р210088505','C'),"П")
WriteStr('П000030016006:'+GetData('Б160','N'),"П")
WriteStr('П000030017004:'+GetData('А170','N'),"П")
WriteStr('П000030017005:'+GetData('Р210086105','C'),"П")
WriteStr('П000030017006:'+GetData('Б170','N'),"П")
WriteStr('П000030018004:'+GetData('А180','N'),"П")
WriteStr('П000030018006:'+GetData('Б180','N'),"П")
WriteStr('П000030019006:'+GetData('Б190','N'),"П")
WriteStr('П000030020006:'+GetData('б200','N'),"П")
WriteStr('П000030021006:'+GetData('Б210','N'),"П")
WriteStr('П000030022004:'+GetData('А220','N'),"П")
WriteStr('П000030023004:'+GetData('А230','N'),"П")
WriteStr('П000030024004:'+GetData('А240','N'),"П")
WriteStr('П000030025004:'+GetData('А250','N'),"П")
WriteStr('П000030026004:'+GetData('А260','N'),"П")
WriteStr('П000030027004:'+GetData('А270','N'),"П")
WriteStr('П000030028004:'+GetData('А280','N'),"П")
WriteStr('П000030029004:'+GetData('А290','N'),"П")
WriteStr('П000030030004:'+GetData('А300','N'),"П")
WriteStr('П000030031004:'+GetData('А310','N'),"П")
WriteStr('П000030032004:'+GetData('А320','N'),"П")
WriteStr('П000030033004:'+GetData('А330','N'),"П")
WriteStr('П000030034004:'+GetData('А340','N'),"П")
WriteStr('П000030035004:'+GetData('А350','N'),"П")
WriteStr('П000030036004:'+GetData('А360','N'),"П")

WriteStr("###","S")
// обработка массива
aArr := GetData("03","A")
I := 2
IF !EMPTY(aArr)
ArrLen := LEN(aArr)
cResult:= "AAA"
While (i <= ArrLen).AND.!EMPTY(Alltrim(cResult))

WriteStr("П000040001002:"+DoStr(aArr[i][1]),"П")
WriteStr("П000040001003:"+DoStr(aArr[i][2]),"П")
WriteStr("П000040001004:"+DoStr(aArr[i][3]),"П")
WriteStr("П000040001005:"+DoStr(aArr[i][4]),"П")

WriteSTR("###","S")
i := i+1
IF i <= ArrLen
cResult:= ArrToString(aArr[i])
ENDIF
ENDDO
ENDIF

WriteStr('П000040002004:'+GetData('Р03ВД1606','N'),"П")
WriteStr('П000040002005:'+GetData('Р03ВЕ1607','N'),"П")

WriteStr("###","S")

aArr := GetData("05","A")
I := 2
IF !EMPTY(aArr)
ArrLen := LEN(aArr)
cResult:= "AAA"
While (i <= ArrLen).AND.!EMPTY(Alltrim(cResult))

WriteStr("П000050001001:"+DoStr(aArr[i][1]),"П")
WriteStr("П000050001002:"+DoStr(aArr[i][2]),"П")
WriteStr("П000050001004:"+DoStr(aArr[i][4]),"П")
WriteStr("П000050001005:"+DoStr(aArr[i][5]),"П")
WriteStr("П000050001006:"+DoStr(aArr[i][6]),"П")

WriteSTR("###","S")
i := i+1
IF i <= ArrLen
cResult:= ArrToString(aArr[i])
ENDIF
ENDDO
ENDIF

WriteStr('П000050002002:'+GetData('Р02И0102','N'),"П")
WriteStr('П000050002004:'+GetData('Р02И0104','N'),"П")
WriteStr('П000050002005:'+GetData('Р02И0105','N'),"П")
WriteStr('П000050002006:'+GetData('Р02И0107','N'),"П")
WriteStr('П000050003000:'+GetData('ИТОГО5_030','N'),"П")

WriteStr("###","S")
//nkv_6: = GetData('КВ_Р6','C')

 // обработка массива  61 и 6
aArr61 := GetData("61","A")
I := 2
IF !EMPTY(aArr61)
   ArrLen61 := LEN(aArr61)
   cResult61:= "AAA"
   While (i <= ArrLen61).AND.!EMPTY(Alltrim(cResult61))
      WriteStr('П000060001000:'+DoStr(aArr61[i][1]),"П")
      WriteStr('П000060002000:'+DoStr(aArr61[i][2]),"П")
      WriteStr('П000060003000:'+DoStr(aArr61[i][3]),"П")
      WriteStr('П000060004000:'+DoStr(aArr61[i][4]),"П")
      n_listr6:=DoStr(aArr61[i][4])
      WriteStr("###","S")
// обработка массива  6
      aArr := GetData("06","A")
      i1 :=2
      IF !EMPTY(aArr)
           ArrLen := LEN(aArr)
           cResult:= "AAA"
         While (i1 <= ArrLen).AND.!EMPTY(Alltrim(cResult))
            If n_listr6=DoStr(aArr[i1][4])
               WriteStr("П000060005001:"+DoStr(aArr[i1][1]),"П")
               WriteStr("П000060005002:"+DoStr(aArr[i1][2]),"П")
               WriteStr("П000060005003:"+DoStr(aArr[i1][3]),"П")
               WriteSTR("###","S")
            endif
            i1 := i1+1
            IF i1 <= ArrLen
                 cResult:= ArrToString(aArr[i1])
            ENDIF
          ENDDO
      ENDIF
        WriteStr('П000060006003:'+DoStr(aArr61[i][5]),"П")
        WriteStr("###","S")
      i := i+1
        IF i <= ArrLen61
            cResult:= ArrToString(aArr61[i])
        ENDIF

   ENDDO
ENDIF



// обработка массива
aArr := GetData("07","A")
I := 2
IF !EMPTY(aArr)
ArrLen := LEN(aArr)
cResult:= "AAA"
While (i <= ArrLen).AND.!EMPTY(Alltrim(cResult))

WriteStr("П000070001001:"+DoStr(aArr[i][1]),"П")
WriteStr("П000070001002:"+DoStr(aArr[i][2]),"П")
WriteStr("П000070001003:"+DoStr(aArr[i][3]),"П")
WriteStr("П000070001004:"+DoStr(aArr[i][4]),"П")
WriteStr("П000070001005:"+DoStr(aArr[i][5]),"П")

WriteSTR("###","S")
i := i+1
IF i <= ArrLen
cResult:= ArrToString(aArr[i])
ENDIF
ENDDO
ENDIF

WriteStr('П000070002002:'+GetData('Р03И1602','N'),"П")
WriteStr('П000070002003:'+GetData('Р03И1603','N'),"П")
WriteStr('П000070002004:'+GetData('Р03И1604','N'),"П")
WriteStr('П000070002005:'+GetData('Р03И1605','N'),"П")
WriteStr('П000070003005:'+GetData('ИТОГО7_030','N'),"П")
WriteStr('П000070004005:'+GetData('ИТОГО7_040','N'),"П")
WriteSTR("###","S")

//nkv_8: = GetData('КВ_Р8','C')
// обработка массива  81 и 8
aArr81 := GetData("81","A")
I := 2
IF !EMPTY(aArr81)
   ArrLen81 := LEN(aArr81)
   cResult81:= "AAA"
While (i <= ArrLen81).AND.!EMPTY(Alltrim(cResult81))
      WriteStr('П000080001000:'+DoStr(aArr81[i][1]),"П")
      WriteStr('П000080002000:'+DoStr(aArr81[i][2]),"П")
      WriteStr('П000080003000:'+DoStr(aArr81[i][3]),"П")
      WriteStr('П000080004000:'+DoStr(aArr81[i][4]),"П")
      n_listr8:=DoStr(aArr81[i][4])
      WriteStr("###","S")
// обработка массива  8
      aArr := GetData("08","A")
      i1 :=2
      IF !EMPTY(aArr)
           ArrLen := LEN(aArr)
           cResult:= "AAA"
         While (i1 <= ArrLen).AND.!EMPTY(Alltrim(cResult))
            If n_listr8=DoStr(aArr[i1][4])
               WriteStr("П000080005001:"+DoStr(aArr[i1][1]),"П")
               WriteStr("П000080005002:"+DoStr(aArr[i1][2]),"П")
               WriteStr("П000080005003:"+DoStr(aArr[i1][3]),"П")
               WriteSTR("###","S")
            endif
            i1 := i1+1
            IF i1 <= ArrLen
                 cResult:= ArrToString(aArr[i1])
            ENDIF
          ENDDO
      ENDIF
        WriteStr('П000080006003:'+DoStr(aArr81[i][5]),"П")
        WriteStr("###","S")
      i := i+1
        IF i <= ArrLen81
            cResult:= ArrToString(aArr81[i])
        ENDIF

   ENDDO
ENDIF

// обработка массива
   aArr := GetData("01","A")
   I := 2
IF !EMPTY(aArr)
   ArrLen := LEN(aArr)
   cResult:= "AAA"
   While (i <= ArrLen).AND.!EMPTY(Alltrim(cResult))

      WriteStr("П000090001001:"+DoStr(aArr[i][1]),"П")
      WriteStr("П000090001002:"+DoStr(aArr[i][2]),"П")
      WriteStr("П000090001003:"+DoStr(aArr[i][3]),"П")
      WriteStr("П000090001004:"+DoStr(aArr[i][4]),"П")

      WriteSTR("###","S")
      i := i+1
      IF i <= ArrLen
          cResult:= ArrToString(aArr[i])
      ENDIF
   ENDDO
ELSE
      WriteStr("П000090001001:"+GetData('Р04ВА0101','N'),"П")
      WriteStr("П000090001002:"+GetData('Р04ВБ0101','N'),"П")
      WriteStr("П000090001003:"+GetData('Р04ВВ0101','N'),"П")
      WriteStr("П000090001004:"+GetData('Р04ВГ0101','N'),"П")
ENDIF

 WriteStr('П000090002002:'+GetData('Р04ВБ020','N'),"П")
 WriteStr('П000090002003:'+GetData('Р04ВВ020','N'),"П")
 WriteStr('П000090002004:'+GetData('Р04ВГ020','N'),"П")
 WriteStr('П000090003000:'+GetData('0ВА030','N'),"П")

WriteStr("###","S")

WriteStr('П000100000100:'+GetData('СПРГОД','N'),"П")

// обработка массива
aArr := GetData("12","A")
I := 2
IF !EMPTY(aArr)
ArrLen := LEN(aArr)
cResult:= "AAA"
While (i <= ArrLen).AND.!EMPTY(Alltrim(cResult))




  adr1 := DoStr(aArr[i][2])+','+DoStr(aArr[i][3])+','+DoStr(aArr[i][4])+','+DoStr(aArr[i][5])+','+DoStr(aArr[i][6])+','+DoStr(aArr[i][7])+','+DoStr(aArr[i][8])+','+DoStr(aArr[i][9])+','+DoStr(aArr[i][1])


  IF alltrim(adr1)<>''
      WriteStr('П000100001000:'+substr(UserParam("000021"),1,3)+','+adr1,"П")
  else
      WriteStr('П000100001000:',"П")
  endif


WriteSTR("###","S")
i := i+1
IF i <= ArrLen
cResult:= ArrToString(aArr[i])
ENDIF
ENDDO
ENDIF
// обработка массива
aArr := GetData("10","A")
I := 2
IF !EMPTY(aArr)
ArrLen := LEN(aArr)

cResult:= "AAA"
While (i <= ArrLen).AND.!EMPTY(Alltrim(cResult))
   WriteStr("П000100002001:"+DoStr(aArr[i][1]),"П")
   WriteStr("П000100002002:"+DoStr(aArr[i][2]),"П")
   WriteStr("П000100002003:"+DoStr(aArr[i][3]),"П")
   WriteStr("П000100002004:"+DoStr(aArr[i][4]),"П")
   WriteStr("П000100002005:"+DoStr(aArr[i][5]),"П")
   WriteStr("П000100002006:"+DoStr(aArr[i][6]),"П")
   WriteStr("П000100002007:"+DoStr(aArr[i][7]),"П")
   WriteStr("П000100002008:"+DoStr(aArr[i][8]),"П")
   WriteStr("П000100002009:"+DoStr(aArr[i][9]),"П")
   WriteStr("П000100002010:"+DoStr(aArr[i][10]),"П")
   WriteStr("П000100002011:"+DoStr(aArr[i][11]),"П")

  WriteSTR("###","S")
i := i+1
IF i <= ArrLen
cResult:= ArrToString(aArr[i])
ENDIF
ENDDO
ENDIF
// Конец раздела

WriteStrEX(cKolPokPosition,GetKolPok())
WriteSTR("@@@","S")
WriteSTR("===","S")