<?xml version="1.0" encoding="Windows-1252"?>
<xs:schema xmlns:doc="urn:schemas-basda-org:schema-extensions:documentation" xmlns:ns="urn:OECD:StandardAuditFile-Tax:PT_1.01_01" xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.01_01" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:OECD:StandardAuditFile-Tax:PT_1.01_01" version="1.01_01" id="SAF-T_PT" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:documentation>
      <doc:Title>Standard Audit File - Portuguese Version</doc:Title>
      <doc:Subject>Standard Audit File - Portuguese Version</doc:Subject>
      <doc:Copyright>Copyright OECD</doc:Copyright>
      <doc:Version>
        <doc:Number>1.01_01</doc:Number>
        <doc:Status>Production</doc:Status>
      </doc:Version>
      <doc:Author>AT</doc:Author>
      <doc:ModificationDate>2013-01-01</doc:ModificationDate>
    </xs:documentation>
  </xs:annotation>
  <!-- Estrutura do ficheiro SAFT-PT-->
  <xs:element name="AuditFile">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" ref="Header" />
        <xs:element name="MasterFiles">
          <xs:complexType>
            <xs:choice maxOccurs="unbounded">
              <xs:element ref="GeneralLedger" />
              <xs:element ref="Customer" />
              <xs:element ref="Supplier" />
              <xs:element ref="Product" />
              <xs:element ref="TaxTable" />
            </xs:choice>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" ref="GeneralLedgerEntries" />
        <xs:element minOccurs="0" ref="SourceDocuments" />
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="CustomerIDConstraint">
      <xs:selector xpath="ns:MasterFiles/ns:Customer" />
      <xs:field xpath="ns:CustomerID" />
    </xs:unique>
    <xs:unique name="SupplierIDConstraint">
      <xs:selector xpath="ns:MasterFiles/ns:Supplier" />
      <xs:field xpath="ns:SupplierID" />
    </xs:unique>
    <xs:unique name="ProductCodeConstraint">
      <xs:selector xpath="ns:MasterFiles/ns:Product" />
      <xs:field xpath="ns:ProductCode" />
    </xs:unique>
    <xs:unique name="InvoiceNoConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:SalesInvoices/ns:Invoice" />
      <xs:field xpath="ns:InvoiceNo" />
    </xs:unique>
    <xs:keyref name="InvoiceCustomerIDConstraint" refer="CustomerIDConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:SalesInvoices/ns:Invoice" />
      <xs:field xpath="ns:CustomerID" />
    </xs:keyref>
    <xs:keyref name="InvoiceProductCodeConstraint" refer="ProductCodeConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:SalesInvoices/ns:Invoice/ns:Line" />
      <xs:field xpath="ns:ProductCode" />
    </xs:keyref>
  </xs:element>
  <!-- Estrutura de cabeçalho (AuditFile.Header) -->
  <xs:element name="Header">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="AuditFileVersion" />
        <xs:element ref="CompanyID" />
        <xs:element name="TaxRegistrationNumber" type="SAFPTPortugueseVatNumber" />
        <xs:element ref="TaxAccountingBasis" />
        <xs:element ref="CompanyName" />
        <xs:element minOccurs="0" ref="BusinessName" />
        <xs:element ref="CompanyAddress" />
        <xs:element ref="FiscalYear" />
        <xs:element ref="StartDate" />
        <xs:element ref="EndDate" />
        <xs:element name="CurrencyCode" type="SAFPTCurrencyCode" />
        <xs:element ref="DateCreated" />
        <xs:element ref="TaxEntity" />
        <xs:element ref="ProductCompanyTaxID" />
        <xs:element ref="SoftwareCertificateNumber" />
        <xs:element ref="ProductID" />
        <xs:element ref="ProductVersion" />
        <xs:element minOccurs="0" ref="HeaderComment" />
        <xs:element minOccurs="0" ref="Telephone" />
        <xs:element minOccurs="0" ref="Fax" />
        <xs:element minOccurs="0" ref="Email" />
        <xs:element minOccurs="0" ref="Website" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- Ficheiros Mestre (AuditFile.MasterFiles) -->
  <!--    Estrutura do Plano de Contas (AuditFile.MasterFiles.GeneralLedger)-->
  <xs:element name="GeneralLedger">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="AccountID" type="SAFPTGLAccountID" />
        <xs:element ref="AccountDescription" />
        <xs:element ref="OpeningDebitBalance" />
        <xs:element ref="OpeningCreditBalance" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!--    Estrutura de Cliente (AuditFile.MasterFiles.Customer) -->
  <xs:element name="Customer">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="CustomerID" />
        <xs:element ref="AccountID" />
        <xs:element ref="CustomerTaxID" />
        <xs:element ref="CompanyName" />
        <xs:element minOccurs="0" ref="Contact" />
        <xs:element ref="BillingAddress" />
        <xs:element minOccurs="0" ref="ShipToAddress" />
        <xs:element minOccurs="0" ref="Telephone" />
        <xs:element minOccurs="0" ref="Fax" />
        <xs:element minOccurs="0" ref="Email" />
        <xs:element minOccurs="0" ref="Website" />
        <xs:element ref="SelfBillingIndicator" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!--    Estrutura de Fornecedor (AuditFile.MasterFiles.Supplier) -->
  <xs:element name="Supplier">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="SupplierID" />
        <xs:element ref="AccountID" />
        <xs:element ref="SupplierTaxID" />
        <xs:element ref="CompanyName" />
        <xs:element minOccurs="0" ref="Contact" />
        <xs:element name="BillingAddress" type="SupplierAddressStructure" />
        <xs:element minOccurs="0" name="ShipFromAddress" type="SupplierAddressStructure" />
        <xs:element minOccurs="0" ref="Telephone" />
        <xs:element minOccurs="0" ref="Fax" />
        <xs:element minOccurs="0" ref="Email" />
        <xs:element minOccurs="0" ref="Website" />
        <xs:element ref="SelfBillingIndicator" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!--    Estrutura de produto (AuditFile.MasterFiles.Product)-->
  <xs:element name="Product">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="ProductType" />
        <xs:element ref="ProductCode" />
        <xs:element minOccurs="0" ref="ProductGroup" />
        <xs:element ref="ProductDescription" />
        <xs:element ref="ProductNumberCode" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!--    Estrutura de Impostos (AuditFile.MasterFiles.TaxTable) -->
  <xs:element name="TaxTable">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="unbounded" ref="TaxTableEntry" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!--    Estrutura de Imposto -->
  <xs:element name="TaxTableEntry">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="TaxType" />
        <xs:element ref="TaxCountryRegion" />
        <xs:element ref="TaxCode" />
        <xs:element name="Description" type="SAFPTtextTypeMandatoryMax255Car" />
        <xs:element minOccurs="0" ref="TaxExpirationDate" />
        <xs:choice>
          <xs:element ref="TaxPercentage" />
          <xs:element ref="TaxAmount" />
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- Estrutura de Movimentos Contabilisticos (AuditFile.GeneralLedgerEntries)-->
  <xs:element name="GeneralLedgerEntries">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="NumberOfEntries" />
        <xs:element ref="TotalDebit" />
        <xs:element ref="TotalCredit" />
        <xs:element minOccurs="0" maxOccurs="unbounded" name="Journal">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="JournalID" />
              <xs:element ref="Description" />
              <xs:element minOccurs="0" maxOccurs="unbounded" name="Transaction">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element ref="TransactionID" />
                    <xs:element name="Period" type="SAFPTAccountingPeriod" />
                    <xs:element ref="TransactionDate" />
                    <xs:element minOccurs="0" ref="SourceID" />
                    <xs:element ref="Description" />
                    <xs:element ref="DocArchivalNumber" />
                    <xs:element ref="TransactionType" />
                    <xs:element ref="GLPostingDate" />
                    <xs:element minOccurs="0" ref="CustomerID" />
                    <xs:element minOccurs="0" ref="SupplierID" />
                    <xs:element minOccurs="1" maxOccurs="unbounded" name="Line">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="RecordID" />
                          <xs:element name="AccountID" type="SAFPTGLAccountID" />
                          <xs:element minOccurs="0" ref="SourceDocumentID" />
                          <xs:element ref="SystemEntryDate" />
                          <xs:element ref="Description" />
                          <xs:choice maxOccurs="1">
                            <xs:element ref="DebitAmount" />
                            <xs:element ref="CreditAmount" />
                          </xs:choice>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="JournalIdConstraint">
      <xs:selector xpath="ns:Journal" />
      <xs:field xpath="ns:JournalID" />
    </xs:unique>
    <xs:unique name="TransactionIdConstraint">
      <xs:selector xpath="ns:Journal/ns:Transaction" />
      <xs:field xpath="ns:TransactionID" />
    </xs:unique>
  </xs:element>
  <!-- Estrutura de Documentos Comerciais (AuditFile.SourceDocuments)-->
  <xs:element name="SourceDocuments">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" name="SalesInvoices">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="NumberOfEntries" />
              <xs:element ref="TotalDebit" />
              <xs:element ref="TotalCredit" />
              <xs:element maxOccurs="unbounded" name="Invoice">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element ref="InvoiceNo" />
                    <xs:element ref="InvoiceStatus" />
                    <xs:element ref="Hash" />
                    <xs:element minOccurs="0" ref="HashControl" />
                    <xs:element minOccurs="0" ref="Period" />
                    <xs:element ref="InvoiceDate" />
                    <xs:element ref="InvoiceType" />
                    <xs:element ref="SelfBillingIndicator" />
                    <xs:element ref="SystemEntryDate" />
                    <xs:element minOccurs="0" ref="TransactionID" />
                    <xs:element ref="CustomerID" />
                    <xs:element minOccurs="0" maxOccurs="1" ref="ShipTo" />
                    <xs:element minOccurs="0" maxOccurs="1" ref="ShipFrom" />
                    <xs:element maxOccurs="unbounded" name="Line">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="LineNumber" />
                          <xs:element minOccurs="0" maxOccurs="unbounded" ref="OrderReferences" />
                          <xs:element ref="ProductCode" />
                          <xs:element ref="ProductDescription" />
                          <xs:element ref="Quantity" />
                          <xs:element ref="UnitOfMeasure" />
                          <xs:element ref="UnitPrice" />
                          <xs:element ref="TaxPointDate" />
                          <xs:element minOccurs="0" ref="References" />
                          <xs:element ref="Description" />
                          <xs:choice>
                            <xs:element ref="DebitAmount" />
                            <xs:element ref="CreditAmount" />
                          </xs:choice>
                          <xs:element minOccurs="0" ref="Tax" />
                          <xs:element minOccurs="0" ref="TaxExemptionReason" />
                          <xs:element minOccurs="0" ref="SettlementAmount" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="DocumentTotals">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="TaxPayable" />
                          <xs:element ref="NetTotal" />
                          <xs:element ref="GrossTotal" />
                          <xs:element minOccurs="0" ref="Currency" />
                          <xs:element minOccurs="0" ref="Settlement" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- ESTRUTURAS DE SUPORTE -->
  <!-- Estrutura de Taxa -->
  <xs:element name="Tax">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="TaxType" />
        <xs:element ref="TaxCountryRegion" />
        <xs:element ref="TaxCode" />
        <xs:choice>
          <xs:element ref="TaxPercentage" />
          <xs:element ref="TaxAmount" />
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- Estrutura de Moradas -->
  <xs:complexType name="AddressStructure">
    <xs:sequence>
      <xs:element minOccurs="0" ref="BuildingNumber" />
      <xs:element minOccurs="0" ref="StreetName" />
      <xs:element ref="AddressDetail" />
      <xs:element ref="City" />
      <xs:element ref="PostalCode" />
      <xs:element minOccurs="0" ref="Region" />
      <xs:element ref="Country" />
    </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de Moradas para Fornecedores-->
  <xs:complexType name="SupplierAddressStructure">
    <xs:sequence>
      <xs:element minOccurs="0" ref="BuildingNumber" />
      <xs:element minOccurs="0" ref="StreetName" />
      <xs:element ref="AddressDetail" />
      <xs:element ref="City" />
      <xs:element ref="PostalCode" />
      <xs:element minOccurs="0" ref="Region" />
      <xs:element name="Country" type="SupplierCountry" />
    </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de Moradas para Portugal-->
  <xs:complexType name="AddressStructurePT">
    <xs:sequence>
      <xs:element minOccurs="0" ref="BuildingNumber" />
      <xs:element minOccurs="0" ref="StreetName" />
      <xs:element ref="AddressDetail" />
      <xs:element ref="City" />
      <xs:element name="PostalCode" type="PostalCodePT" />
      <xs:element minOccurs="0" ref="Region" />
      <xs:element fixed="PT" name="Country" />
    </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de entregas de produtos -->
  <xs:complexType name="ShippingPointStructure">
    <xs:sequence>
      <xs:element minOccurs="0" ref="DeliveryID" />
      <xs:element minOccurs="0" ref="DeliveryDate" />
      <xs:element minOccurs="0" ref="Address" />
    </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de Nota de Crédito -->
  <xs:element name="CreditNote">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="Reference" />
        <xs:element minOccurs="0" ref="Reason" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- Estrutura de valor monetário -->
  <xs:element name="Currency">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="CurrencyCode" />
        <xs:choice>
          <xs:element minOccurs="0" ref="CurrencyCreditAmount" />
          <xs:element minOccurs="0" ref="CurrencyDebitAmount" />
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- Estrutura de Referências a Encomendas-->
  <xs:element name="OrderReferences">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="OriginatingON" />
        <xs:element minOccurs="0" ref="OrderDate" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- Estrutura de Referências a Notas de Crédito-->
  <xs:element name="References">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="CreditNote" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- Estrutura de Acordo entre Cliente e Fornecedor-->
  <xs:element name="Settlement">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" name="SettlementDiscount" type="SAFPTtextTypeMandatoryMax30Car" />
        <xs:element minOccurs="0" name="SettlementAmount" type="SAFmonetaryType" />
        <xs:element minOccurs="0" name="SettlementDate" type="SAFdateType" />
        <xs:element minOccurs="0" ref="PaymentMechanism" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- ELEMENTOS SIMPLES -->
  <xs:element name="StreetName" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="SupplierID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="SupplierTaxID" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="TaxAmount" type="SAFmonetaryType" />
  <xs:element name="TaxEntity" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="TaxExemptionReason" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="TaxExpirationDate" type="SAFdateType" />
  <xs:element name="TaxPayable" type="SAFmonetaryType" />
  <xs:element name="TaxPercentage" type="SAFdecimalType" />
  <xs:element name="TaxPointDate" type="SAFdateType" />
  <xs:element name="TaxVerificationDate" type="SAFdateType" />
  <xs:element name="Telephone" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="TotalCredit" type="SAFmonetaryType" />
  <xs:element name="TotalDebit" type="SAFmonetaryType" />
  <xs:element name="TransactionDate" type="SAFdateType" />
  <xs:element name="TransactionID" type="SAFPTTransactionID" />
  <xs:element name="UnitOfMeasure" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="UnitPrice" type="SAFmonetaryType" />
  <xs:element name="Website" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="ShipToAddress" type="AddressStructure" />
  <xs:element name="StartDate" type="SAFPTDateSpan" />
  <xs:element name="Region" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="ShipFrom" type="ShippingPointStructure" />
  <xs:element name="ShipFromAddress" type="AddressStructure" />
  <xs:element name="ShipTo" type="ShippingPointStructure" />
  <xs:element name="ProductCode" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="ProductDescription" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="ProductID" type="SAFPTProductID" />
  <xs:element name="ProductVersion" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="Quantity" type="SAFdecimalType" />
  <xs:element name="Reason" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="RecordID" type="SAFPTtextTypeMandatoryMax10Car" />
  <xs:element name="Reference" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="OriginatingON" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="NetTotal" type="SAFmonetaryType" />
  <xs:element name="NumberOfEntries" type="xs:integer" />
  <xs:element name="OpeningCreditBalance" type="SAFmonetaryType" />
  <xs:element name="OpeningDebitBalance" type="SAFmonetaryType" />
  <xs:element name="OrderDate" type="SAFdateType" />
  <xs:element name="CompanyName" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="BusinessName" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="InvoiceDate" type="SAFdateType" />
  <xs:element name="LineNumber" type="xs:integer" />
  <xs:element name="ProductCompanyTaxID" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="SoftwareCertificateNumber" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="HeaderComment" type="SAFPTtextTypeMandatoryMax255Car" />
  <xs:element name="GrossTotal" type="SAFmonetaryType" />
  <xs:element name="GLPostingDate" type="SAFdateTimeType" />
  <xs:element name="Email" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="EndDate" type="SAFPTDateSpan" />
  <xs:element name="Fax" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="CustomerID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="CustomerTaxID" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="DateCreated" type="SAFPTDateSpan" />
  <xs:element name="DebitAmount" type="SAFmonetaryType" />
  <xs:element name="DeliveryDate" type="SAFdateType" />
  <xs:element name="DeliveryID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="Description" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="ProductGroup" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="ProductNumberCode" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="CurrencyCreditAmount" type="SAFmonetaryType" />
  <xs:element name="CurrencyDebitAmount" type="SAFmonetaryType" />
  <xs:element name="BillingAddress" type="AddressStructure" />
  <xs:element name="BuildingNumber" type="SAFPTtextTypeMandatoryMax10Car" />
  <xs:element name="City" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="CompanyAddress" type="AddressStructurePT" />
  <xs:element name="Contact" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="CreditAmount" type="SAFmonetaryType" />
  <xs:element name="Address" type="AddressStructure" />
  <xs:element name="SettlementAmount" type="SAFmonetaryType" />
  <xs:element name="SystemEntryDate" type="SAFdateTimeType" />
  <xs:element name="SourceDocumentID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="SourceID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="AccountDescription" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="AddressDetail" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="JournalID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="Hash" type="SAFPTtextTypeMandatoryMax200Car" />
  <xs:element name="HashControl" type="SAFPTtextTypeMandatoryMax40Car" />
  <xs:element name="PostalCode" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="DocArchivalNumber" type="SAFTPTDocArchivalNumber" />
  <!-- ELEMENTOS SIMPLES COM RESTRIÇÕES ADICIONAIS-->
  <!-- Tipo de Imposto -->
  <xs:element name="TaxType">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="IVA" />
        <xs:enumeration value="IS" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="TaxCode">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="RED|INT|NOR|ISE|OUT|([0-9.])*" />
        <xs:minLength value="1" />
        <xs:maxLength value="10" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Código de Imposto -->
  <xs:element name="TaxCountryRegion">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="AF|AX|AL|DZ|AS|AD|AO|AI|AQ|AG|AR|AM|AW|AU|AT|AZ|BS|BH|BD|BB|BY|BE|BZ|BJ|BM|BT|BO|BA|BW|BV|BR|IO|BN|BG|BF|BI|KH|CM|CA|CV|KY|CF|TD|CL|CN|CX|CC|CO|KM|CG|CD|CK|CR|CI|HR|CU|CY|CZ|DK|DJ|DM|DO|EC|EG|SV|GQ|ER|EE|ET|FK|FO|FJ|FI|FR|GF|PF|TF|GA|GM|GE|DE|GH|GI|GR|GL|GD|GP|GU|GT|GG|GN|GW|GY|HT|HM|VA|HN|HK|HU|IS|IN|ID|IR|IQ|IE|IM|IL|IT|JM|JP|JE|JO|KZ|KE|KI|KP|KR|KW|KG|LA|LV|LB|LS|LR|LY|LI|LT|LU|MO|MK|MG|MW|MY|MV|ML|MT|MH|MQ|MR|MU|YT|MX|FM|MD|MC|MN|ME|MS|MA|MZ|MM|NA|NR|NP|NL|AN|NC|NZ|NI|NE|NG|NU|NF|MP|NO|OM|PK|PW|PS|PA|PG|PY|PE|PH|PN|PL|PT|PR|QA|RE|RO|RU|RW|BL|SH|KN|LC|MF|PM|VC|WS|SM|ST|SA|SN|RS|SC|SL|SG|SK|SI|SB|SO|ZA|GS|ES|LK|SD|SR|SJ|SZ|SE|CH|SY|TW|TJ|TZ|TH|TL|TG|TK|TO|TT|TN|TR|TM|TC|TV|UG|UA|AE|GB|US|UM|UY|UZ|VU|VE|VN|VG|VI|WF|EH|YE|ZM|ZW|PT-AC|PT-MA" />
        <xs:minLength value="2" />
        <xs:maxLength value="5" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Código único do documento -->
  <xs:element name="InvoiceNo">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="[^ ]+ [^/ ]+\/[0-9]+" />
        <xs:minLength value="1" />
        <xs:maxLength value="60" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Código da Conta -->
  <xs:element name="AccountID">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="(([1-8][0-9a-zA-Z]*)|Desconhecido)" />
        <xs:minLength value="1" />
        <xs:maxLength value="30" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Tipos de produto -->
  <xs:element name="ProductType">
    <xs:annotation>
      <xs:documentation>Restrição: Tipo de produto: P - Produtos, S - Serviços, O - Outros, I - Impostos, taxas e encargos parafiscais</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="P" />
        <xs:enumeration value="S" />
        <xs:enumeration value="O" />
        <xs:enumeration value="I" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Meio de pagamento -->
  <xs:element name="PaymentMechanism">
    <xs:annotation>
      <xs:documentation>Restrição: Meio de pagamento: NU - Numerário, CH - Cheque, CC - Cartão de Crédito, CD - Cartão de Débito, TB - Transferência Bancária, TR - Ticket Restaurante</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="NU" />
        <xs:enumeration value="CH" />
        <xs:enumeration value="CD" />
        <xs:enumeration value="CC" />
        <xs:enumeration value="TB" />
        <xs:enumeration value="TR" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Tipos de Movimento Contabilistico -->
  <xs:element name="TransactionType">
    <xs:annotation>
      <xs:documentation>Restrição: Tipificação dos movimentos contabilísticos - N - Normal, R - Regularizações do período de tributação, A - Apuramento de resultados, J - Movimentos de Ajustamento </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="N" />
        <xs:enumeration value="R" />
        <xs:enumeration value="A" />
        <xs:enumeration value="J" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Ano Fiscal -->
  <xs:element name="FiscalYear">
    <xs:simpleType>
      <xs:restriction base="xs:integer">
        <xs:minInclusive value="2000" />
        <xs:maxInclusive value="9999" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Identificador de Auto-Facturação -->
  <xs:element name="SelfBillingIndicator">
    <xs:simpleType>
      <xs:restriction base="xs:integer">
        <xs:minInclusive value="0" />
        <xs:maxInclusive value="1" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Estado do documento -->
  <xs:element name="InvoiceStatus">
    <xs:annotation>
      <xs:documentation>N para Normal, A para Anulado, F para Facturado, S para autofacturação</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="N" />
        <xs:enumeration value="S" />
        <xs:enumeration value="A" />
        <xs:enumeration value="F" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Código do país (ISO 3166 1-alpha-2) -->
  <xs:element name="Country">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="AD|AE|AF|AG|AI|AL|AM|AO|AQ|AR|AS|AT|AU|AW|AX|AZ|BA|BB|BD|BE|BF|BG|BH|BI|BJ|BL|BM|BN|BO|BQ|BR|BS|BT|BV|BW|BY|BZ|CA|CC|CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|CR|CU|CV|CW|CX|CY|CZ|DE|DJ|DK|DM|DO|DZ|EC|EE|EG|EH|ER|ES|ET|FI|FJ|FK|FM|FO|FR|GA|GB|GD|GE|GF|GG|GH|GI|GL|GM|GN|GP|GQ|GR|GS|GT|GU|GW|GY|HK|HM|HN|HR|HT|HU|ID|IE|IL|IM|IN|IO|IQ|IR|IS|IT|JE|JM|JO|JP|KE|KG|KH|KI|KM|KN|KP|KR|KW|KY|KZ|LA|LB|LC|LI|LK|LR|LS|LT|LU|LV|LY|MA|MC|MD|ME|MF|MG|MH|MK|ML|MM|MN|MO|MP|MQ|MR|MS|MT|MU|MV|MW|MX|MY|MZ|NA|NC|NE|NF|NG|NI|NL|NO|NP|NR|NU|NZ|OM|PA|PE|PF|PG|PH|PK|PL|PM|PN|PR|PS|PT|PW|PY|QA|RE|RO|RS|RU|RW|SA|SB|SC|SD|SE|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SR|SS|ST|SV|SX|SY|SZ|TC|TD|TF|TG|TH|TJ|TK|TL|TM|TN|TO|TR|TT|TV|TW|TZ|UA|UG|UM|US|UY|UZ|VA|VC|VE|VG|VI|VN|VU|WF|WS|XK|YE|YT|ZA|ZM|ZW|Desconhecido|" />
        <xs:minLength value="2" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Código da moeda (ISO 4217) -->
  <xs:element name="CurrencyCode">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="AED|AFN|ALL|AMD|ANG|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BGN|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYR|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HRK|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LTL|LVL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRO|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLL|SOS|SRD|SSP|STD|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|USS|UYI|UYU|UZS|VEF|VND|VUV|WST|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XDR|XFU|XOF|XPD|XPF|XPT|XSU|XUA|YER|ZAR|ZMW|ZWL|EEK|SKK|TMM|ZMK|ZWD|ZWR|" />
        <xs:length value="3" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Tipo de sistema que exportou o SAFT -->
  <xs:element name="TaxAccountingBasis">
    <xs:annotation>
      <xs:documentation>C para Contabilidade, F para Facturação, I para Contabilidade-Facturação, P para Facturação Parcial, S para Autofacturação</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="C" />
        <xs:enumeration value="F" />
        <xs:enumeration value="I" />
        <xs:enumeration value="S" />
        <xs:enumeration value="P" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Identificação da empresa que exportou o SAFT-->
  <xs:element name="CompanyID">
    <xs:annotation>
      <xs:documentation>Obtém-se pela concatenação da Conservatória do Registo Comercial com o número do registo comercial separados pelo carácter espaço. Nos casos em que não existe o registo comercial, deve ser indicado o NIF.</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="([0-9])+|([a-zA-Z0-9\-/_ ]+ [0-9]+)" />
        <xs:minLength value="1" />
        <xs:maxLength value="50" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Tipo de documento -->
  <xs:element name="InvoiceType">
    <xs:annotation>
      <xs:documentation>
        Restrição: Tipos de Documento (FT-Factura, FS-Factura simplificada, FR-Factura-recibo, ND-Nota de débito, NC-Nota de Crédito,VD-Venda a dinheiro, TV-Talão de Venda,
        TD-Talão de devolução,AA-Alienação Activos,DA-Devolução Activos, RP-Prémio ou Recibo Prémio, RE-Estorno ou Recibo de Estorno, CS-Imputação a Co-Seguradoras,
        LD-Imputação a Co-Seguradora Líder, RA-Resseguro Aceite)
      </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="FT" />
        <xs:enumeration value="FS" />
        <xs:enumeration value="FR" />
        <xs:enumeration value="ND" />
        <xs:enumeration value="NC" />
        <xs:enumeration value="VD" />
        <xs:enumeration value="TV" />
        <xs:enumeration value="TD" />
        <xs:enumeration value="AA" />
        <xs:enumeration value="DA" />
        <!-- Menções para o sector segurador-->
        <xs:enumeration value="RP" />
        <xs:enumeration value="RE" />
        <xs:enumeration value="CS" />
        <xs:enumeration value="LD" />
        <xs:enumeration value="RA" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Periodo contabilistico do documento -->
  <xs:element name="Period">
    <xs:simpleType>
      <xs:restriction base="xs:integer">
        <xs:minInclusive value="1" />
        <xs:maxInclusive value="12" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="AuditFileVersion">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="1.01_01" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- TIPOS DE DADOS BASE SAFT Portugal -->
  <xs:simpleType name="SAFPTCurrencyCode">
    <xs:restriction base="xs:string">
      <xs:pattern value="EUR" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTDateSpan">
    <xs:restriction base="xs:date">
      <xs:minInclusive value="2000-01-01" />
      <xs:maxInclusive value="9999-12-31" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTProductID">
    <xs:restriction base="xs:string">
      <xs:pattern value="\w+(\s\w+)*/\w+(\s\w+)*" />
      <xs:minLength value="3" />
      <xs:maxLength value="255" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTTransactionID">
    <xs:restriction base="xs:string">
      <xs:pattern value="[1-9][0-9]{3}-[01][0-9]-[0-3][0-9] [^ ]{1,30} [^ ]{1,20}" />
      <xs:minLength value="1" />
      <xs:maxLength value="70" />
    </xs:restriction>
  </xs:simpleType>
  <!-- Código do país (ISO 3166 1-alpha-2) -->
  <xs:simpleType name="SupplierCountry">
    <xs:restriction base="xs:string">
      <xs:pattern value="AD|AE|AF|AG|AI|AL|AM|AO|AQ|AR|AS|AT|AU|AW|AX|AZ|BA|BB|BD|BE|BF|BG|BH|BI|BJ|BL|BM|BN|BO|BQ|BR|BS|BT|BV|BW|BY|BZ|CA|CC|CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|CR|CU|CV|CW|CX|CY|CZ|DE|DJ|DK|DM|DO|DZ|EC|EE|EG|EH|ER|ES|ET|FI|FJ|FK|FM|FO|FR|GA|GB|GD|GE|GF|GG|GH|GI|GL|GM|GN|GP|GQ|GR|GS|GT|GU|GW|GY|HK|HM|HN|HR|HT|HU|ID|IE|IL|IM|IN|IO|IQ|IR|IS|IT|JE|JM|JO|JP|KE|KG|KH|KI|KM|KN|KP|KR|KW|KY|KZ|LA|LB|LC|LI|LK|LR|LS|LT|LU|LV|LY|MA|MC|MD|ME|MF|MG|MH|MK|ML|MM|MN|MO|MP|MQ|MR|MS|MT|MU|MV|MW|MX|MY|MZ|NA|NC|NE|NF|NG|NI|NL|NO|NP|NR|NU|NZ|OM|PA|PE|PF|PG|PH|PK|PL|PM|PN|PR|PS|PT|PW|PY|QA|RE|RO|RS|RU|RW|SA|SB|SC|SD|SE|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SR|SS|ST|SV|SX|SY|SZ|TC|TD|TF|TG|TH|TJ|TK|TL|TM|TN|TO|TR|TT|TV|TW|TZ|UA|UG|UM|US|UY|UZ|VA|VC|VE|VG|VI|VN|VU|WF|WS|XK|YE|YT|ZA|ZM|ZW|" />
      <xs:length value="2" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTGLAccountID">
    <xs:restriction base="xs:string">
      <xs:pattern value="(([1-8][0-9a-zA-Z]*))" />
      <xs:minLength value="1" />
      <xs:maxLength value="30" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTAccountingPeriod">
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="1" />
      <xs:maxInclusive value="16" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFTPTDocArchivalNumber">
    <xs:restriction base="xs:string">
      <xs:pattern value="[^ ]{1,20}" />
      <xs:minLength value="1" />
      <xs:maxLength value="20" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTPortugueseVatNumber">
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="100000000" />
      <xs:maxInclusive value="999999999" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax10Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="10" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax20Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="20" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax3Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="3" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax30Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="30" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMax40Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="0" />
      <xs:maxLength value="40" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax50Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="50" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax40Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="40" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax60Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="60" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax70Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="70" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax255Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="255" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax200Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="200" />
    </xs:restriction>
  </xs:simpleType>
  <!-- Código Postal Português -->
  <xs:simpleType name="PostalCodePT">
    <xs:restriction base="xs:string">
      <xs:pattern value="([0-9]{4}-[0-9]{3})" />
    </xs:restriction>
  </xs:simpleType>
  <!-- TIPOS DE DADOS BASE SAFT OCDE-->
  <xs:simpleType name="SAFdateTimeType">
    <xs:restriction base="xs:dateTime" />
  </xs:simpleType>
  <xs:simpleType name="SAFdateType">
    <xs:restriction base="xs:date" />
  </xs:simpleType>
  <xs:simpleType name="SAFdecimalType">
    <xs:restriction base="xs:decimal" />
  </xs:simpleType>
  <xs:simpleType name="SAFmonetaryType">
    <xs:restriction base="xs:decimal" />
  </xs:simpleType>
</xs:schema>