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

	<xs:annotation>
		<xs:documentation>
			EAMXML.org Representation of Purchase Order
		</xs:documentation>
	</xs:annotation>	
	
	<xs:include schemaLocation="Audit.xsd"/>
	<xs:include schemaLocation="Supplier.xsd"/>
	<xs:include schemaLocation="Person.xsd"/>
	<xs:include schemaLocation="Address.xsd"/>
	<xs:include schemaLocation="StorageLocation.xsd"/>
	<xs:include schemaLocation="CommonTypes.xsd"/>
	<xs:include schemaLocation="UserDefined.xsd"/>
	
	<xs:element name="PurchaseOrder" type="PurchaseOrderType"/>
	<xs:complexType name="PurchaseOrderType">
		<xs:sequence>
			<xs:element name="SiteId" type="xs:string" minOccurs="0"/>
			<xs:element name="Type" type="xs:string" minOccurs="0"/>
			<xs:element name="Status" type="xs:string" minOccurs="0"/>
			<xs:element name="AuditTrail" type="AuditType" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="Supplier" type="SupplierType" minOccurs="0"/>
			<xs:element name="PurchasingOfficer" type="PersonType" minOccurs="0"/>
			<xs:element name="DeliveryLocation" type="AddressType" minOccurs="0"/>
			<xs:element name="OrderDateTime" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="NumberOfItems" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="NumberOfItemsCompleted" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="AuthorizedBy" type="PersonType" minOccurs="0"/>
			<xs:element name="AuthorizedDateTime" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="AuthorizedStatus" type="xs:string" minOccurs="0"/>
			<xs:element name="CompletedDateTime" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="StorageLocation" type="StorageLocationType" minOccurs="0"/>
			<xs:element name="FreightCode" type="xs:string" minOccurs="0"/>
			<xs:element name="UserDefined" type="UserDefinedType" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="PurchaseOrderItems" minOccurs="1" maxOccurs="1">
				<xs:complexType>
					<xs:sequence minOccurs="0" maxOccurs="unbounded">
						<xs:element name="PurchaseOrderItem" type="PurchaseOrderItemType"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>

		</xs:sequence>
		<xs:attribute name="Id" type="xs:string"/>
	</xs:complexType>
	<xs:complexType name="PurchaseOrderItemType">
		<xs:sequence>
			<xs:element name="Type" type="xs:string" minOccurs="0"/>
			<xs:element name="Status" type="xs:string" minOccurs="0"/>
			<xs:element name="CreationMethod" type="xs:string" minOccurs="0"/>
			<xs:element name="AuthorizedBy" type="PersonType" minOccurs="0"/>
			<xs:element name="AuthorizedDateTime" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="AuthorizedStatus" type="xs:string" minOccurs="0"/>
			<xs:element name="ApprovedQuantity" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="ApprovedValue" type="xs:decimal" minOccurs="0"/>
			<xs:element name="ApprovedDateTime" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="DueDateTime" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="ShippedDateTime" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="ReceivedDateTime" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="ReceivedQuantityOnsite" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="ReceivedQuantityOffsite" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="PurchaseUnitOfMeasure" type="UnitOfMeasureType" minOccurs="0"/>
			<xs:element name="IssueUnitOfMeasure" type="UnitOfMeasureType" minOccurs="0"/>
			<xs:element name="StorageLocation" type="StorageLocationType" minOccurs="0"/>
			<xs:element name="OriginalQuantity" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="OriginalNetPrice" type="xs:decimal" minOccurs="0"/>
			<xs:element name="CurrentQuantity" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="CurrentNetPrice" type="xs:decimal" minOccurs="0"/>
			<xs:element name="ReturnQuantity" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="ReturnNetPrice" type="xs:decimal" minOccurs="0"/>
			<xs:element name="InvoicedQuantity" type="xs:unsignedInt" minOccurs="0"/>
			<xs:element name="GrossPrice" type="xs:decimal" minOccurs="0"/>
			<xs:element name="PriceDiscountPercentage" type="xs:decimal" minOccurs="0"/>
			<xs:element name="CurrencyCode" type="xs:string" minOccurs="0"/>
			<xs:element name="UserDefined" type="UserDefinedType" minOccurs="0" maxOccurs="unbounded"/>

		</xs:sequence>
		<xs:attribute name="Id" type="xs:string"/>
	</xs:complexType>
	
	<xs:complexType name="PurchaseOrderIdType">
		<xs:annotation>
				<xs:documentation>
						Used as a lightweight version of PurchaseOrder whenever only the ID is necessary
				</xs:documentation>
		</xs:annotation>
		<xs:attribute name="Id" type="xs:string" use="required"/>
	</xs:complexType>
	
	<xs:complexType name="PurchaseOrderItemIdType">
		<xs:annotation>
				<xs:documentation>
						Used as a lightweight version of PurchaseOrderItem whenever only the ID is necessary
				</xs:documentation>
		</xs:annotation>
		<xs:attribute name="Id" type="xs:string" use="required"/>
	</xs:complexType>
</xs:schema>

