<?xml version="1.0" encoding="UTF-8"?>
<!--
  Jakamo Quotation extension for UBL 2.3 Quotation documents.

  Jakamo writes the Quotation documents when an RFQ that was created through the API is completed, one for
  each quotation the suppliers submitted, and the quotation queue hands them out. The features that UBL 2.3
  Quotation has no element for are carried in a UBL extension in this namespace: the award of each line and
  the answers to the RFQ questions.

  This schema is published so that you can validate the messages you receive. Every Quotation Jakamo queues
  is valid against this schema and against the OASIS UBL 2.3 schemas.
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:jak="urn:jakamo:quotation:2"
            targetNamespace="urn:jakamo:quotation:2"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="2.0">

  <!-- ===== Document extension ===== -->

  <xsd:element name="Quotation" type="jak:QuotationType">
    <xsd:annotation>
      <xsd:documentation>
        The Jakamo data of a quotation. Goes in the ExtensionContent of a UBLExtension of the Quotation
        document, in a UBLExtension whose ExtensionURI is urn:jakamo:quotation:2.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:complexType name="QuotationType">
    <xsd:sequence>
      <xsd:element name="Answer" type="jak:AnswerType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>
            The answer of the supplier to an RFQ question asked once for the whole RFQ. The answers to the
            questions asked for each line are in the jak:QuotationLine of the line.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <!-- ===== Line extension ===== -->

  <xsd:element name="QuotationLine" type="jak:QuotationLineType">
    <xsd:annotation>
      <xsd:documentation>
        The Jakamo data of one quotation line. Goes in the ExtensionContent of a UBLExtension of the
        QuotationLine.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:complexType name="QuotationLineType">
    <xsd:sequence>
      <xsd:element name="QuotedIndicator" type="xsd:boolean" minOccurs="1" maxOccurs="1">
        <xsd:annotation>
          <xsd:documentation>
            Did the supplier quote the line. A line that was not quoted has no price and is never awarded.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="AwardedIndicator" type="xsd:boolean" minOccurs="1" maxOccurs="1">
        <xsd:annotation>
          <xsd:documentation>Was the line awarded to the supplier.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="Answer" type="jak:AnswerType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>The answer of the supplier to an RFQ question asked for each line.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <!-- ===== Types ===== -->

  <xsd:complexType name="AnswerType">
    <xsd:sequence>
      <xsd:element name="QuestionID" type="jak:ShortTextType" minOccurs="1" maxOccurs="1">
        <xsd:annotation>
          <xsd:documentation>
            The identifier of the question. For an RFQ created through the JSON API it is the QuestionId
            the question was given there.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="QuestionText" type="jak:TextType" minOccurs="1" maxOccurs="1">
        <xsd:annotation>
          <xsd:documentation>The text of the question.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="Value" type="jak:TextType" minOccurs="1" maxOccurs="1">
        <xsd:annotation>
          <xsd:documentation>
            The answer as text. A question the supplier did not answer has no jak:Answer.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:simpleType name="ShortTextType">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
      <xsd:maxLength value="500"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="TextType">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1"/>
    </xsd:restriction>
  </xsd:simpleType>

</xsd:schema>
