Complex types and validations

KEY VALIDATION RULES SUMMARY

Date/Time Validation / Валидация на дати и часове:

  • loaddate/loadtime must be in the future (after submission) / трябва да са в бъдещето
  • receiveddate/receivedtime must be after loaddate/loadtime
  • If transfer: transferdate/transfertime must be between load and received dates
  • If transhipment (initial declaration): transdate/transtime must equal loaddate/loadtime

Quantity Validation / Валидация на количества:

  • quantitynet must be > 0.00
  • quantitygross must be ≥ quantitynet
  • quantitytype: MANDATORY from 01.05.2025 for new goods codes (Order ZMF-237/31.03.2025)

Price Validation / Валидация на цена:

  • MANDATORY and > 0.00 when purpose = 01 (delivery) or purpose = 05 (storage)
  • Currency: BGN until 31.12.2025, EUR from 01.01.2026

Address Validation / Валидация на адреси:

  • For all address fields: either (street AND numb) OR localaddress must be provided
  • ekatte is ALWAYS REQUIRED

Vehicle Registration / Регистрационни номера:

  • regvehicle, regtrailer1, regtrailer2: Only uppercase Latin letters (A-Z) and digits (0-9), no spaces
  • Maximum 15 characters

Conditional Requirements / Условни изисквания:

  • If istransfer = true: transferaddress, transferdate, transfertime, transcarrier become MANDATORY
  • If istranshipment = true: transporttype, transdate, transtime, transaddress become MANDATORY

Contact Information / Контактна информация:

  • cphonecode: Optional '+' followed by digits, spaces, or hyphens (max 10 chars)
  • cpemail: Valid email format required

Declaration / Декларация:

  • iscorrect: Must be true to submit. Confirms criminal liability under Article 313 of the Criminal Code for false information

Complex Types / Комплексни типове

1. Address Types / Типове адреси

addressdetailed / address

Field / Поле Type / Тип Required / Задължително Validation / Валидация Description (BG) Description (EN)
localaddress string Conditional* maxLength: 100 Улица, №, ж.к., бл., вх., ап. Full local address string
street string Conditional* maxLength: 100 Улица Street name
numb string Conditional* maxLength: 5 Номер Street number
ekatte string YES maxLength: 5
pattern: [0-9]{1,5}
ЕКАТТЕ код EKATTE settlement code

*Conditional Rule: Either (street AND numb) OR localaddress must be provided. ekatte is always required.

XML Example:

<loadaddress>
  <street>Main Street</street>
  <numb>15</numb>
  <ekatte>12345</ekatte>
</loadaddress>

<!-- OR -->

<receivedaddress>
  <localaddress>Industrial Zone, Warehouse 5</localaddress>
  <ekatte>54321</ekatte>
</receivedaddress>

2. Shipper / Доставчик

Field / Поле Type / Тип Required / Задължително Validation / Валидация Description (BG) Description (EN)
ident bulstat YES minLength: 9
maxLength: 13
pattern: [0-9]{1,13}
Идентификационен номер Identification number
identtype identtype YES 1=UIC, 2=PIN, 3=FPN, 5=NRA Тип на идентификационен номер Type of identification number

XML Example:

<shipper>
  <ident>123456789</ident>
  <identtype>1</identtype>
</shipper>

3. Carrier / Превозвач

Must provide EITHER reprperson OR reprfirm (not both)

reprperson (Physical Person):

Field / Поле Type / Тип Required / Задължително Validation / Валидация Description (BG) Description (EN)
isperson boolean YES true Флаг за физическо лице Person flag
name string YES maxLength: 200 Име Name
egn egn YES length: 10
pattern: [0-9]{10}
Идентификационен номер Identification number
identtype egntype YES 2=PIN, 3=FPN, 5=NRA, 6=Other Тип на идентификатор ID type

reprfirm (Legal Entity):

Field / Поле Type / Тип Required / Задължително Validation / Валидация Description (BG) Description (EN)
isfirm boolean YES true Флаг за юридическо лице Company flag
name string YES maxLength: 200 Наименование Company name
bulstat vin YES maxLength: 15
pattern: [A-Z0-9\+\*]{1,15}
Идентификационен номер Company ID
identtype vintype YES 1=UIC, 5=NRA, 6=Other, 9=VIN Тип на идентификатор ID type

XML Examples:

<!-- Physical Person -->
<carrier>
  <reprperson>
    <isperson>true</isperson>
    <name>Ivan Petrov</name>
    <egn>9001011234</egn>
    <identtype>2</identtype>
  </reprperson>
</carrier>

<!-- Legal Entity -->
<carrier>
  <reprfirm>
    <isfirm>true</isfirm>
    <name>Transport Company Ltd</name>
    <bulstat>123456789</bulstat>
    <identtype>1</identtype>
  </reprfirm>
</carrier>

4. Recipient (cr) / Получател

Field / Поле Type / Тип Required / Задължително Validation / Валидация Description (BG) Description (EN)
crident bulstat YES 9-13 digits Идентификационен номер Recipient ID
cridenttype identtype YES 1=UIC, 2=PIN, 3=FPN, 5=NRA Тип на идентификатор ID type
crname string YES maxLength: 200 Име/Наименование Recipient name

XML Example:

<cr>
  <rowenum>
    <crident>987654321</crident>
    <cridenttype>1</cridenttype>
    <crname>Recipient Company Ltd</crname>
    <!-- address and goods data follows -->
  </rowenum>
</cr>

5. Goods / Стоки

Field / Поле Type / Тип Required / Задължително Validation / Валидация Description (BG) Description (EN)
code string YES maxLength: 20 Код на стоката Goods code
quantitytype enum Conditional* кг | м2 | броя Мерна единица Unit of measurement
quantitynet decimal YES > 0.00 Количество нето Net quantity
quantitygross decimal NO ≥ quantitynet Количество бруто Gross quantity
price decimal Conditional** > 0.00 Стойност Price/Value
purpose enum YES 01-07 Предназначение Purpose
purposeother string NO maxLength: 1000 Друго предназначение Other purpose description

*quantitytype: MANDATORY from 01.05.2025 for goods with new codes (Order ZMF-237)
**price: MANDATORY when purpose = 01 (delivery) or 05 (storage)

Purpose Codes:

  • 01 = доставка (delivery)
  • 02 = рекламация (complaint/return)
  • 03 = дарение (donation)
  • 04 = обработка (processing)
  • 05 = режим складиране (storage)
  • 06 = друго (other)
  • 07 = преминаване с претоварни операции (transit with transhipment)

XML Example:

<goods>
  <rowenum>
    <code>GOODS123</code>
    <quantitytype>кг</quantitytype>
    <quantitynet>100.00</quantitynet>
    <quantitygross>110.00</quantitygross>
    <price>25.50</price>
    <purpose>01</purpose>
  </rowenum>
</goods>

6. Transhipment / Претоварване

Field / Поле Type / Тип Required / Задължително Validation / Валидация Description (BG) Description (EN)
istranshipment boolean YES true/false Флаг за претоварване Transhipment flag
transporttype enum Conditional* 1 | 2 | 3 Вид транспорт Transport type
transdate date Conditional* xs:date Дата на претоварване Transhipment date
transtime string Conditional* HH:MM Час на претоварване Transhipment time
transaddress address Conditional* See address type Адрес на претоварване Transhipment address

*Conditional: All fields MANDATORY if istranshipment = true

Transport Types:

  • 1 = Воден (Water)
  • 2 = Железопътен (Rail)
  • 3 = Въздушен (Air)

XML Example:

<transhipment>
  <istranshipment>true</istranshipment>
  <transporttype>2</transporttype>
  <transdate>2025-06-15</transdate>
  <transtime>10:00</transtime>
  <transaddress>
    <localaddress>Railway Station</localaddress>
    <ekatte>12345</ekatte>
  </transaddress>
</transhipment>

📝 Complete XML Example / Пълен XML пример

Basic Internal Transport Declaration

<?xml version="1.0" encoding="WINDOWS-1251"?>
<decHfrInternal>
  <part1>
    <!-- Shipper -->
    <shipper>
      <ident>123456789</ident>
      <identtype>1</identtype>
    </shipper>
    
    <!-- Vehicle (OPTIONAL) -->
    <regvehicle>CA1234AB</regvehicle>
    
    <!-- Transfer flag (REQUIRED) -->
    <istransfer>false</istransfer>
    
    <!-- Loading address -->
    <loadaddress>
      <street>Main Street</street>
      <numb>15</numb>
      <ekatte>12345</ekatte>
    </loadaddress>
    
    <!-- Loading date and time -->
    <loaddate>2025-06-15</loaddate>
    <loadtime>10:00</loadtime>
    
    <!-- Recipient data -->
    <cr>
      <rowenum>
        <crident>987654321</crident>
        <cridenttype>1</cridenttype>
        <crname>Recipient Company Ltd</crname>
        
        <!-- Delivery addresses -->
        <address>
          <rowenum>
            <receivedaddress>
              <localaddress>Industrial Zone, Warehouse 5</localaddress>
              <ekatte>54321</ekatte>
            </receivedaddress>
            
            <receiveddate>2025-06-15</receiveddate>
            <receivedtime>16:00</receivedtime>
            
            <!-- Goods -->
            <goods>
              <rowenum>
                <code>GOODS123</code>
                <quantitytype>кг</quantitytype>
                <quantitynet>100.00</quantitynet>
                <quantitygross>110.00</quantitygross>
                <price>25.50</price>
                <purpose>01</purpose>
              </rowenum>
            </goods>
          </rowenum>
        </address>
      </rowenum>
    </cr>
    
    <!-- Contact information -->
    <cname>John Smith</cname>
    <cphonecode>+359</cphonecode>
    <cphone>888123456</cphone>
    <cpemail>contact@example.com</cpemail>
    
    <!-- Declarator -->
    <dname>Jane Doe</dname>
    <iscorrect>true</iscorrect>
  </part1>
</decHfrInternal>

Example with Transfer / Пример с претоварване

<?xml version="1.0" encoding="WINDOWS-1251"?>
<decHfrInternal>
  <part1>
    <shipper>
      <ident>123456789</ident>
      <identtype>1</identtype>
    </shipper>
    
    <!-- Carrier -->
    <carrier>
      <reprfirm>
        <isfirm>true</isfirm>
        <name>First Carrier Ltd</name>
        <bulstat>111222333</bulstat>
        <identtype>1</identtype>
      </reprfirm>
    </carrier>
    
    <regvehicle>CA1111BB</regvehicle>
    
    <!-- Transfer enabled -->
    <istransfer>true</istransfer>
    
    <!-- Transfer details -->
    <transferaddress>
      <street>Transfer Hub Street</street>
      <numb>50</numb>
      <ekatte>99999</ekatte>
    </transferaddress>
    <transferdate>2025-06-15</transferdate>
    <transfertime>13:00</transfertime>
    
    <!-- Second carrier -->
    <transcarrier>
      <reprfirm>
        <isfirm>true</isfirm>
        <name>Second Carrier Ltd</name>
        <bulstat>555666777</bulstat>
        <identtype>1</identtype>
      </reprfirm>
    </transcarrier>
    
    <transregvehicle>CA2222CC</transregvehicle>
    
    <loadaddress>
      <street>Start Street</street>
      <numb>1</numb>
      <ekatte>11111</ekatte>
    </loadaddress>
    
    <loaddate>2025-06-15</loaddate>
    <loadtime>08:00</loadtime>
    
    <cr>
      <rowenum>
        <crident>987654321</crident>
        <cridenttype>1</cridenttype>
        <crname>Recipient Company Ltd</crname>
        
        <address>
          <rowenum>
            <receivedaddress>
              <street>End Street</street>
              <numb>100</numb>
              <ekatte>22222</ekatte>
            </receivedaddress>
            
            <receiveddate>2025-06-15</receiveddate>
            <receivedtime>18:00</receivedtime>
            
            <goods>
              <rowenum>
                <code>GOODS456</code>
                <quantitytype>броя</quantitytype>
                <quantitynet>50</quantitynet>
                <quantitygross>55</quantitygross>
                <price>100.00</price>
                <purpose>01</purpose>
              </rowenum>
            </goods>
          </rowenum>
        </address>
      </rowenum>
    </cr>
    
    <cname>Maria Ivanova</cname>
    <cphonecode>+359</cphonecode>
    <cphone>888999000</cphone>
    <cpemail>maria@example.com</cpemail>
    
    <dname>Peter Georgiev</dname>
    <iscorrect>true</iscorrect>
  </part1>
</decHfrInternal>

Document Information:

  • Schema Version: 5.0
  • Schema File: decHfr_internal_v5_restrict.xsd
  • Encoding: WINDOWS-1251
  • Purpose: Internal transport (Bulgaria → Bulgaria)