<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="se/skatteverket/hunten/ansokan/1.0" xmlns:app="se/skatteverket/hunten/ansokan/1.0"
    xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

    <complexType name="HtArendeTYPE">
        <annotation>
            <documentation>Uppgifter om den du begär utbetalning för</documentation>
        </annotation>
        <sequence>
            <element name="kopare" minOccurs="1" maxOccurs="1" nillable="false" block="extension">
                <annotation>
                    <documentation>Köparens organisationsnummer/personnummer, obligatorisk</documentation>
                </annotation>
                <simpleType>
                    <restriction base="string">
                        <length value="12"></length>
                        <pattern value="\d+"></pattern>
                    </restriction>
                </simpleType>
            </element>
            <element name="betalningsdatum" minOccurs="1" maxOccurs="1" nillable="false">
                <annotation>
                    <documentation>Datum för betalning, obligatorisk, anges enligt följande exempel 2019-07-01
                    </documentation>
                </annotation>
                <simpleType>
                    <restriction base="date">
                        <minInclusive value="2009-07-01"></minInclusive>
                        <pattern value="(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])"></pattern>
                    </restriction>
                </simpleType>
            </element>
            <element name="faktureratBelopp" minOccurs="1" maxOccurs="1" nillable="false">
                <annotation>
                    <documentation>Pris för arbetet, (arbetskostnaden), obligatorisk</documentation>
                </annotation>
                <simpleType>
                    <restriction base="long">
                        <maxInclusive value="99999999999"></maxInclusive>
                        <minInclusive value="2"></minInclusive>
                    </restriction>
                </simpleType>
            </element>
            <element name="betaltBelopp" minOccurs="1" maxOccurs="1" nillable="false">
                <annotation>
                    <documentation>Belopp du fått betalt för arbetet, obligatorisk</documentation>
                </annotation>
                <simpleType>
                    <restriction base="long">
                        <minInclusive value="1"></minInclusive>
                        <maxInclusive value="99999999999"></maxInclusive>
                    </restriction>
                </simpleType>
            </element>
            <element name="begartBelopp" minOccurs="1" maxOccurs="1" nillable="false">
                <annotation>
                    <documentation>Belopp du begär, obligatorisk</documentation>
                </annotation>
                <simpleType>
                    <restriction base="long">
                        <minInclusive value="1"></minInclusive>
                        <maxInclusive value="99999999999"></maxInclusive>
                    </restriction>
                </simpleType>
            </element>
        </sequence>
    </complexType>


    <complexType name="HtRotArendeTYPE">
        <complexContent>
            <extension base="app:HtArendeTYPE">
                <sequence>
                    <element name="fastighetsbeteckning" minOccurs="1" maxOccurs="1" nillable="false">
                        <annotation>
                            <documentation>Fastighets/Lägenhetsbeteckning, obligatorisk
                                uppgift</documentation>
                        </annotation>
                        <simpleType>
                            <restriction base="string">
                                <maxLength value="40"></maxLength>
                                <minLength value="1"></minLength>
                            </restriction>
                        </simpleType>
                    </element>
                    <element name="brfOrgNr" minOccurs="0" maxOccurs="1" block="extension">
                        <annotation>
                            <documentation>Bostadsrättsförenings Organisationsnummer, ska fyllas i
                                om ROT-avdraget avser en lägenhet</documentation>
                        </annotation>
                        <simpleType>
                            <restriction base="string">
                                <pattern value="[\d]*"></pattern>
                                <minLength value="0"></minLength>
                                <maxLength value="12"></maxLength>
                            </restriction>
                        </simpleType>
                    </element> 
                 </sequence>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="HtHushallArendeTYPE">
        <complexContent>
            <extension base="app:HtArendeTYPE" />
        </complexContent>
    </complexType>

    <complexType name="HtHushallAnsokanTYPE">
        <sequence>

            <element name="arenden" type="app:HtHushallArendeTYPE" minOccurs="1" maxOccurs="unbounded" />
        </sequence>
    </complexType>
    <complexType name="HtRotAnsokanTYPE">
        <sequence>
            <element name="arenden" type="app:HtRotArendeTYPE" minOccurs="1" maxOccurs="unbounded" />
        </sequence>
    </complexType>

    <complexType name="HtAnsokanTYPE">
        <sequence>
            <element name="ansokningsNummer" maxOccurs="1" minOccurs="1" nillable="false">
                <annotation>
                    <documentation>Nummer på ansökan, obligatorisk uppgift</documentation>
                </annotation>
                <simpleType>
                    <restriction base="string">
                        <maxLength value="10"></maxLength>
                        <minLength value="1"></minLength>
                        <pattern value="\w+"></pattern>
                    </restriction>
                </simpleType>
            </element>
            <choice maxOccurs="1" minOccurs="0">
                <element name="rotAnsokan" type="app:HtRotAnsokanTYPE" />
                <element name="hushallAnsokan" type="app:HtHushallAnsokanTYPE" />
            </choice>
        </sequence>
    </complexType>

    <element name="HtAnsokan" type="app:HtAnsokanTYPE"></element>
</schema>

