<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.eCotton.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.eCotton.com" elementFormDefault="qualified" id="WarehouseInvoice">

  <xs:annotation>
    <xs:documentation xml:lang="en">
       Version 2 - 06/17/2009
       Based on (and inherits from) the ACSA WarehouseInvoice schema located at http://www.cottonxml.com/XMLSchemas/WarehouseInvoice.xsd
    </xs:documentation>
  </xs:annotation>
  <xs:include schemaLocation="http://www.cottonxml.org/XMLSchemas/Invoice.xsd"/>
  <xs:include schemaLocation="http://www.cottonxml.org/XMLSchemas/WarehouseInvoice.xsd"/>

  <xs:element name="WarehouseInvoice" type="eCottonWarehouseInvoiceType"/>


  <xs:complexType name="eCottonWarehouseInvoiceType">
    <xs:annotation>
      <xs:documentation>The warehouse invoice type represents an invoice for charges related to shipment of cotton stored at a particular warehouse</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="Invoice">
        <xs:sequence>
          <xs:element name="Shipment" type="eCottonShipmentType" minOccurs="1" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation>Shipment info associated with this warehouse invoice.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="ext1:Credits" type="eCottonInvoiceCreditsType" minOccurs="0">
            <xs:annotation>
              <xs:documentation>Any credit already applied on the invoice.</xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="eCottonInvoiceCreditsType">
    <xs:sequence>
      <xs:element name="ext1:CreditComment" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Description of the credit.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:CreditType" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The type of credit: "Item Credit" or "Cash Payment".</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:CreditAmount" type="xs:decimal" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The amount of the credit.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="eCottonShipmentType">
    <xs:sequence>
      <xs:element name="Charge" type="eCottonChargeType" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Any warehouse charges that are associated with the shipment such as receiving, storage, and loading.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Number" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The order number assigned to the shipment by the shipper (a.k.a. Shipper's Order Number)</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Date" type="xs:date" minOccurs="1">
        <xs:annotation>
          <xs:documentation>The date of the shipment.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Mark" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The mark assigned to the shipment by the merchant.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:Bales" type="xs:integer" minOccurs="1">
        <xs:annotation>
          <xs:documentation>The number of bales on the shipment.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:TruckerID" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The TruckerID assigned to the shipment by the warehouse.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:TruckerName" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The name of the trucking company assigned to the shipment by the warehouse.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:ScheduledDate" type="xs:date" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The date the shipment was scheduled to ship.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:StopStorageDate" type="xs:date" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The date at which storage stopped accumulating for the bales.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:ReadyDate" type="xs:date" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The date on which the bales were made ready for shipment.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:PickupPt" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Specifies which loading dock the shipment can be picked up at.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:Miscellaneous" type="eCottonMiscellaneousShipmentInfoType" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Any additional attributes of the shipment.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:Destination" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>The destination of the shipment.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="eCottonMiscellaneousShipmentInfoType">
    <xs:sequence>
      <xs:element name="ext1:Description" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Description of the Miscellaneous info.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ext1:Value" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Value of the Miscellaneous info.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="eCottonChargeType">
    <xs:sequence>
      <xs:element name="StorageRecap" type="StorageRecap" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>The storage recap represents a summary of how long bales were in storage at the warehouse and at what rate they were there for</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Item" type="eCottonChargeItemType" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>The different items associated with the charge.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="eCottonChargeItemType">
    <xs:annotation>
      <xs:documentation>A description of each tariff charge on the invoice.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="Item">
        <xs:sequence>
          <xs:element name="ext1:TariffID" type="xs:string" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation>ID assigned by the warehouse to this particular charge type.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="ext1:UnitType" type="xs:string" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation>Description of the unit of measure for this particular charge type.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="ext1:NumberOfUnits" type="xs:integer" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation>The number of chargeable units.
                                Differs from Quantity for storage-type charges, when Quantity is simply
                                the number of bales (according to ACSA's definition).
                                This times CostPerUnit will always equal the Total.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="ext1:CostPerUnit" type="xs:decimal" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation>The dollar amount charge per chargeable unit.  Will match the warehouse's published tariff.
                                Differs from UnitCost for storage-type charges, when UnitCost is simply the Total divided
                                by the number of bales (according to ACSA's definition), which may not be recognizable.
                                This times NumberOfUnits will always equal the Total.</xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

</xs:schema>
