<?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.02_01" xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:OECD:StandardAuditFile-Tax:PT_1.02_01" version="1.02_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.02_01</doc:Number>
        <doc:Status>Production</doc:Status>
      </doc:Version>
      <doc:Author>Autoridade Tributária e Aduaneira</doc:Author>
      <doc:ModificationDate>2013-07-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:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" ref="GeneralLedger" />
              <xs:element minOccurs="0" maxOccurs="unbounded" ref="Customer" />
              <xs:element minOccurs="0" maxOccurs="unbounded" ref="Supplier" />
              <xs:element minOccurs="0" maxOccurs="unbounded" ref="Product" />
              <xs:element minOccurs="0" ref="TaxTable" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" ref="GeneralLedgerEntries" />
        <xs:element minOccurs="0" ref="SourceDocuments" />
      </xs:sequence>
    </xs:complexType>
    <!-- Constraint-->
    <xs:unique name="AccountIDConstraint">
      <xs:selector xpath="ns:MasterFiles/ns:GeneralLedger" />
      <xs:field xpath="ns:AccountID" />
    </xs:unique>
    <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:keyref name="GeneralLedgerEntriesAccountIDConstraint" refer="AccountIDConstraint">
      <xs:selector xpath="ns:GeneralLedgerEntries/ns:Journal/ns:Transaction/ns:Line" />
      <xs:field xpath="ns:AccountID" />
    </xs:keyref>
    <xs:keyref name="GeneralLedgerEntriesCustomerIDConstraint" refer="CustomerIDConstraint">
      <xs:selector xpath="ns:GeneralLedgerEntries/ns:Journal/ns:Transaction" />
      <xs:field xpath="ns:CustomerID" />
    </xs:keyref>
    <xs:keyref name="GeneralLedgerEntriesSupplierIDConstraint" refer="SupplierIDConstraint">
      <xs:selector xpath="ns:GeneralLedgerEntries/ns:Journal/ns:Transaction" />
      <xs:field xpath="ns:SupplierID" />
    </xs:keyref>
    <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:unique name="DocumentNumberConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:MovementOfGoods/ns:StockMovement" />
      <xs:field xpath="ns:DocumentNumber" />
    </xs:unique>
    <xs:keyref name="StockMovementCustomerIDConstraint" refer="CustomerIDConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:MovementOfGoods/ns:StockMovement" />
      <xs:field xpath="ns:CustomerID" />
    </xs:keyref>
    <xs:keyref name="StockMovementSupplierIDConstraint" refer="SupplierIDConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:MovementOfGoods/ns:StockMovement" />
      <xs:field xpath="ns:SupplierID" />
    </xs:keyref>
    <xs:keyref name="StockMovementProductCodeConstraint" refer="ProductCodeConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:MovementOfGoods/ns:StockMovement/ns:Line" />
      <xs:field xpath="ns:ProductCode" />
    </xs:keyref>
    <xs:unique name="WorkDocumentDocumentNumberConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:WorkingDocuments/ns:WorkDocument" />
      <xs:field xpath="ns:DocumentNumber" />
    </xs:unique>
    <xs:keyref name="WorkDocumentDocumentCustomerIDConstraint" refer="CustomerIDConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:WorkingDocuments/ns:WorkDocument" />
      <xs:field xpath="ns:CustomerID" />
    </xs:keyref>
    <xs:keyref name="WorkDocumentDocumentProductCodeConstraint" refer="ProductCodeConstraint">
      <xs:selector xpath="ns:SourceDocuments/ns:WorkingDocuments/ns:WorkDocument/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 fixed="EUR" name="CurrencyCode" />
        <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:element ref="ClosingDebitBalance" />
        <xs:element ref="ClosingCreditBalance" />
        <xs:element ref="GroupingCategory" />
        <xs:element minOccurs="0" name="GroupingCode" type="SAFPTGLAccountID" />
      </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" maxOccurs="unbounded" 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" maxOccurs="unbounded" 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 ref="SourceID" />
                    <xs:element ref="Description" />
                    <xs:element ref="DocArchivalNumber" />
                    <xs:element ref="TransactionType" />
                    <xs:element ref="GLPostingDate" />
                    <xs:choice>
                      <xs:element minOccurs="0" ref="CustomerID" />
                      <xs:element minOccurs="0" ref="SupplierID" />
                    </xs:choice>
                    <xs:element minOccurs="2" 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 minOccurs="0" maxOccurs="unbounded" name="Invoice">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element ref="InvoiceNo" />
                    <!-- Estrutura da situação do documento -->
                    <xs:element name="DocumentStatus">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="InvoiceStatus" />
                          <!-- Na exportação de dados relativos a exercícios anteriores em que esta informação seja desconhecida, este campo deverá ser preenchido com a data do documento e hora como 00:00:00 -->
                          <xs:element ref="InvoiceStatusDate" />
                          <xs:element minOccurs="0" ref="Reason" />
                          <xs:element ref="SourceID" />
	                  <xs:element ref="SourceBilling" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <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="SourceID" />
                    <xs:element minOccurs="0" ref="EACCode" />
                    <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 minOccurs="0" maxOccurs="1" ref="MovementEndTime" />
                    <xs:element minOccurs="0" maxOccurs="1" ref="MovementStartTime" />
                    <xs:element maxOccurs="unbounded" name="Line">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="LineNumber" />
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="OrderReferences" type="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" maxOccurs="unbounded" name="References" type="References" />
                          <xs:element ref="Description" />
                          <xs:choice>
                            <xs:element ref="DebitAmount" />
                            <xs:element ref="CreditAmount" />
                          </xs:choice>
                          <xs:element name="Tax" type="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" name="Currency" type="Currency" />
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="Settlement" type="Settlement" />
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="Payment" type="Payment"/>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element minOccurs="0" maxOccurs="unbounded" name="WithholdingTax" type="WithholdingTax"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" name="MovementOfGoods">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="NumberOfMovementLines" />
              <xs:element ref="TotalQuantityIssued" />
              <xs:element minOccurs="0" maxOccurs="unbounded" name="StockMovement">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element ref="DocumentNumber" />
                    <!-- Estrutura da situação do documento -->
                    <xs:element name="DocumentStatus">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="MovementStatus" />
                          <!-- Na exportação de dados relativos a exercícios anteriores em que esta informação seja desconhecida, este campo deverá ser preenchido com a data do documento e hora como 00:00:00 -->
                          <xs:element ref="MovementStatusDate" />
                          <xs:element minOccurs="0" ref="Reason" />
                          <xs:element ref="SourceID" />
	                  <xs:element ref="SourceBilling" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element ref="Hash" />
                    <xs:element minOccurs="0" ref="HashControl" />
                    <xs:element minOccurs="0" ref="Period" />
                    <xs:element ref="MovementDate" />
                    <xs:element ref="MovementType" />
                    <xs:element ref="SystemEntryDate" />
                    <xs:element minOccurs="0" ref="TransactionID" />
                    <xs:choice>
                      <xs:element ref="CustomerID" />
                      <xs:element ref="SupplierID" />
                    </xs:choice>
                    <xs:element ref="SourceID" />
                    <xs:element minOccurs="0" ref="EACCode" />
                    <xs:element minOccurs="0" ref="MovementComments" />
                    <xs:element minOccurs="0" maxOccurs="1" ref="ShipTo" />
                    <xs:element minOccurs="0" maxOccurs="1" ref="ShipFrom" />
                    <xs:element minOccurs="0" maxOccurs="1" ref="MovementEndTime" />
                    <xs:element maxOccurs="1" ref="MovementStartTime" />
                    <!-- Nos documentos resumo (MovementStatus "R"), na ausência de informação concreta, a hora de inicio de transporte (MovementStartTime) pode ser indicada com a concatenação da data constante no campo MovementDate com a hora 00:00:00-->
                    <xs:element minOccurs="0" maxOccurs="1" ref="ATDocCodeID" />
                    <xs:element maxOccurs="unbounded" name="Line">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="LineNumber" />
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="OrderReferences" type="OrderReferences" />
                          <xs:element ref="ProductCode" />
                          <xs:element ref="ProductDescription" />
                          <xs:element ref="Quantity" />
                          <xs:element ref="UnitOfMeasure" />
                          <xs:element ref="UnitPrice" />
                          <xs:element ref="Description" />
                          <xs:choice>
                            <xs:element ref="DebitAmount" />
                            <xs:element ref="CreditAmount" />
                          </xs:choice>
                          <xs:element minOccurs="0" name="Tax" type="MovementTax" />
                          <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" name="Currency" type="Currency" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" name="WorkingDocuments">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="NumberOfEntries" />
              <xs:element ref="TotalDebit" />
              <xs:element ref="TotalCredit" />
              <xs:element minOccurs="0" maxOccurs="unbounded" name="WorkDocument">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element ref="DocumentNumber" />
                    <!-- Estrutura da situação do documento -->
                    <xs:element name="DocumentStatus">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="WorkStatus" />
                          <!-- Na exportação de dados relativos a exercícios anteriores em que esta informação seja desconhecida, este campo deverá ser preenchido com a data do documento e hora como 00:00:00 -->
                          <xs:element ref="WorkStatusDate" />
                          <xs:element minOccurs="0" ref="Reason" />
                          <xs:element ref="SourceID" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element ref="Hash" />
                    <xs:element minOccurs="0" ref="HashControl" />
                    <xs:element minOccurs="0" ref="Period" />
                    <xs:element ref="WorkDate" />
                    <xs:element ref="WorkType" />
                    <xs:element ref="SourceID" />
                    <xs:element minOccurs="0" ref="EACCode" />
                    <xs:element ref="SystemEntryDate" />
                    <xs:element ref="CustomerID" />
                    <xs:element maxOccurs="unbounded" name="Line">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="LineNumber" />
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="OrderReferences" type="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 ref="Description" />
                          <xs:choice>
                            <xs:element ref="DebitAmount" />
                            <xs:element ref="CreditAmount" />
                          </xs:choice>
                          <xs:element minOccurs="0" name="Tax" type="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" name="Currency" type="Currency" />
                        </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 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 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 valor monetário -->
  <!-- Este elemento apenas deve ser gerado quando a moeda original do documento for diferente de euro -->
  <xs:complexType name="Currency">
      <xs:sequence>
        <xs:element ref="CurrencyCode" />
        <xs:element ref="CurrencyAmount" />
        <xs:element minOccurs="0" ref="ExchangeRate" />
      </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de Taxa de documentos de movimentação de mercadorias-->
  <xs:complexType name="MovementTax">
    <xs:sequence>
      <xs:element name="TaxType" type="SAFTPTMovementTaxType" />
      <xs:element ref="TaxCountryRegion" />
      <xs:element name="TaxCode" type="SAFTPTMovementTaxCode" />
      <xs:element ref="TaxPercentage" />
    </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de Referências ao documento de origem-->
  <xs:complexType name="OrderReferences">
      <xs:sequence>
        <xs:element minOccurs="0" ref="OriginatingON" />
        <xs:element minOccurs="0" ref="OrderDate" />
      </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de pagamentos-->
  <xs:complexType name="Payment">
      <xs:sequence>
        <xs:element ref="PaymentMechanism" />
        <xs:element name="PaymentAmount" type="SAFmonetaryType" />
        <xs:element name="PaymentDate" type="SAFdateType" />
      </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de referências a outros documentos em documentos retificativos de faturas-->
  <xs:complexType name="References">
      <xs:sequence>
        <xs:element minOccurs="0" ref="Reference" />
        <xs:element minOccurs="0" ref="Reason" />
      </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de Acordos entre cliente e fornecedor-->
  <xs:complexType name="Settlement">
      <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" name="PaymentTerms" type="SAFPTtextTypeMandatoryMax100Car" />
      </xs:sequence>
  </xs:complexType>
  <!-- Estrutura de entregas de produtos -->
  <xs:complexType name="ShippingPointStructure">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" ref="DeliveryID" />
      <xs:element minOccurs="0" ref="DeliveryDate" />
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element minOccurs="0" ref="WarehouseID" />
        <xs:element minOccurs="0" ref="LocationID" />
      </xs:sequence>
      <xs:element minOccurs="0" ref="Address" />
    </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 Taxa -->
  <xs:complexType name="Tax">
      <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>
  <!-- Estrutura de Retenção na fonte-->
  <xs:complexType name="WithholdingTax">
      <xs:sequence>
        <xs:element minOccurs="0" ref="WithholdingTaxType" />
        <xs:element minOccurs="0" name="WithholdingTaxDescription" type="SAFPTtextTypeMandatoryMax60Car" />
        <xs:element name="WithholdingTaxAmount" type="SAFmonetaryType" />
      </xs:sequence>
  </xs:complexType>
  <!-- ELEMENTOS SIMPLES -->
  <xs:element name="AccountDescription" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="Address" type="AddressStructure" />
  <xs:element name="AddressDetail" type="SAFPTtextTypeMandatoryMax100Car" />
  <xs:element name="ATDocCodeID" type="SAFPTtextTypeMandatoryMax200Car" />
  <xs:element name="BillingAddress" type="AddressStructure" />
  <xs:element name="BuildingNumber" type="SAFPTtextTypeMandatoryMax10Car" />
  <xs:element name="BusinessName" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="City" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="ClosingCreditBalance" type="SAFmonetaryType" />
  <xs:element name="ClosingDebitBalance" type="SAFmonetaryType" />
  <xs:element name="CompanyAddress" type="AddressStructurePT" />
  <xs:element name="CompanyName" type="SAFPTtextTypeMandatoryMax100Car" />
  <xs:element name="Contact" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="CreditAmount" type="SAFmonetaryType" />
  <xs:element name="CurrencyAmount" type="SAFmonetaryType" />
  <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="SAFPTtextTypeMandatoryMax200Car" />
  <xs:element name="DocArchivalNumber" type="SAFTPTDocArchivalNumber" />
  <xs:element name="Email" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="EndDate" type="SAFPTDateSpan" />
  <xs:element name="ExchangeRate" type="SAFdecimalType" />
  <xs:element name="Fax" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="GLPostingDate" type="SAFdateTimeType" />
  <xs:element name="GrossTotal" type="SAFmonetaryType" />
  <xs:element name="Hash" type="SAFPTtextTypeMandatoryMax172Car" />
  <xs:element name="HashControl" type="SAFPTtextTypeMandatoryMax40Car" />
  <xs:element name="HeaderComment" type="SAFPTtextTypeMandatoryMax255Car" />
  <xs:element name="InvoiceDate" type="SAFdateType" />
  <xs:element name="InvoiceStatusDate" type="SAFdateTimeType" />
  <xs:element name="JournalID" type="SAFPTJournalID" />
  <xs:element name="LineNumber" type="xs:nonNegativeInteger" />
  <xs:element name="LocationID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="MovementComments" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="MovementDate" type="SAFdateType" />
  <xs:element name="MovementEndTime" type="SAFdateTimeType" />
  <xs:element name="MovementStartTime" type="SAFdateTimeType" />
  <xs:element name="MovementStatusDate" type="SAFdateTimeType" />
  <xs:element name="NetTotal" type="SAFmonetaryType" />
  <xs:element name="NumberOfEntries" type="xs:nonNegativeInteger" />
  <xs:element name="NumberOfMovementLines" type="xs:nonNegativeInteger" />
  <xs:element name="OpeningCreditBalance" type="SAFmonetaryType" />
  <xs:element name="OpeningDebitBalance" type="SAFmonetaryType" />
  <xs:element name="OrderDate" type="SAFdateType" />
  <xs:element name="OriginatingON" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="PostalCode" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="ProductCode" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="ProductCompanyTaxID" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="ProductDescription" type="SAFPTtextTypeMandatoryMax200Car" />
  <xs:element name="ProductGroup" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="ProductID" type="SAFPTProductID" />
  <xs:element name="ProductNumberCode" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="ProductVersion" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="Quantity" type="SAFdecimalType" />
  <xs:element name="Reason" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="RecordID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="Reference" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="Region" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="SettlementAmount" type="SAFmonetaryType" />
  <xs:element name="ShipFrom" type="ShippingPointStructure" />
  <xs:element name="ShipFromAddress" type="AddressStructure" />
  <xs:element name="ShipTo" type="ShippingPointStructure" />
  <xs:element name="ShipToAddress" type="AddressStructure" />
  <xs:element name="SoftwareCertificateNumber" type="xs:nonNegativeInteger" />
  <xs:element name="SourceDocumentID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="SourceID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="StartDate" type="SAFPTDateSpan" />
  <xs:element name="StreetName" type="SAFPTtextTypeMandatoryMax90Car" />
  <xs:element name="SupplierID" type="SAFPTtextTypeMandatoryMax30Car" />
  <xs:element name="SupplierTaxID" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="SystemEntryDate" type="SAFdateTimeType" />
  <xs:element name="TaxAmount" type="SAFmonetaryType" />
  <xs:element name="TaxEntity" type="SAFPTtextTypeMandatoryMax20Car" />
  <xs:element name="TaxExemptionReason" type="SAFPTPortugueseTaxExemption" />
  <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="TotalQuantityIssued" type="SAFdecimalType" />
  <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="WarehouseID" type="SAFPTtextTypeMandatoryMax50Car" />
  <xs:element name="Website" type="SAFPTtextTypeMandatoryMax60Car" />
  <xs:element name="WorkDate" type="SAFdateType" />
  <xs:element name="WorkStatusDate" type="SAFdateTimeType" />
  <!-- ELEMENTOS SIMPLES COM RESTRIÇÕES ADICIONAIS-->
  <!-- Código da Conta -->
  <xs:element name="AccountID">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="(([0-9a-zA-Z\-/._+*]*)|Desconhecido)" />
        <xs:minLength value="1" />
        <xs:maxLength value="30" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="AuditFileVersion">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="1.02_01" />
      </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]{9})+|([a-zA-Z0-9\-/_&#0227;&#0195;&#0245;&#0213;&#0233;&#0201;&#0234;&#0202;&#0224;&#0192;&#0225;&#0193;&#0243;&#0211;&#0231;&#0199;&#0237;&#0205;&#0250;&#0218;&#0186;&#0170;&amp; ]+ [0-9/]+)" />
        <xs:minLength value="1" />
        <xs:maxLength value="50" />
      </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">
    <!-- Não consta o EUR por não existirem situações que requeiram este código de moeda -->
    <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>
  <!-- Código único do documento de movimentação de mercadorias e de conferência-->
  <xs:element name="DocumentNumber">
    <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 CAE -->
  <xs:element name="EACCode">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="(([0-9]*))" />
        <xs:length value="5" />
      </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>
  <!-- Categoria da conta -->
  <xs:element name="GroupingCategory">
    <xs:annotation>
      <xs:documentation>GR para conta de 1º grau da contabilidade geral, GA para conta agregadora ou integradora da contabilidade geral, GM para conta de movimento da contabilidade geral, AR para conta de 1º grau da contabilidade analítica, AA para conta agregadora ou integradora da contabilidade analítica, AM para conta de movimento da contabilidade analítica </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="GR" />
        <xs:enumeration value="GA" />
        <xs:enumeration value="GM" />
        <xs:enumeration value="AR" />
        <xs:enumeration value="AA" />
        <xs:enumeration value="AM" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Código único do documento de venda -->
  <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>
  <!-- Estado do documento SalesInvoices -->
  <xs:element name="InvoiceStatus">
    <xs:annotation>
      <xs:documentation>N para Normal, S para autofaturação, A para anulado, R para documento de resumo doutros documentos criados noutras aplicações e gerado nesta aplicação, F para faturado </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="R" />
        <xs:enumeration value="F" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Tipo de documento de venda-->
  <xs:element name="InvoiceType">
    <xs:annotation>
      <xs:documentation>
        Restrição:  FT-Fatura nos termos do art.º 36º do CIVA, FS-Fatura simplificada nos termos do art.º 40º do CIVA, FR-Fatura-Recibo, ND-Nota de débito, NC-Nota de Crédito,VD-Venda a dinheiro (a), TV-Talão de Venda (a), TD-Talão de devolução (a), AA-Alienação Activos (a),DA-Devolução Activos (a), 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. (a) Para dados até 2012-12-31
      </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>
  <!-- Estado do documento MovementOfGoods -->
  <xs:element name="MovementStatus">
    <xs:annotation>
      <xs:documentation>N para Normal, T por conta de terceiros, A para Anulado, R para documento de resumo doutros documentos criados noutras aplicações e gerado nesta aplicação. </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="N" />
        <xs:enumeration value="T" />
        <xs:enumeration value="A" />
        <xs:enumeration value="R" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Tipo de documento de movimentação de mercadorias-->
  <xs:element name="MovementType">
    <xs:annotation>
      <xs:documentation>
        Restrição: Tipos de Documento (GR para Guia de remessa, GT para Guia de transporte, GA para Guia de movimentação de ativos próprios, GC para Guia de consignação, GD para Guia ou nota de devolução)
      </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="GR" />
        <xs:enumeration value="GT" />
        <xs:enumeration value="GA" />
        <xs:enumeration value="GC" />
        <xs:enumeration value="GD" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Meio de pagamento-->
  <xs:element name="PaymentMechanism">
    <xs:annotation>
      <xs:documentation>
         Restrição: Meio de pagamento (CC para Cartão de Crédito, CD para Cartão de Débito, CH para Cheque, CS para Compensação de saldos em conta corrente, LC para Letra comercial, MB para Multibanco, NU para Numerário, PR para Permuta, TB para Transferência Bancária, TR para Ticket Restaurante)
      </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="CC" />
        <xs:enumeration value="CD" />
        <xs:enumeration value="CH" />
        <xs:enumeration value="CS" />
        <xs:enumeration value="LC" />
        <xs:enumeration value="MB" />
        <xs:enumeration value="NU" />
        <xs:enumeration value="PR" />
        <xs:enumeration value="TB" />
        <xs:enumeration value="TR" />
      </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>
  <!-- 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 excepto IVA e IS uma vez que se encontram reflectidos na tabela de impostos</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>
  <!-- Identificador de Autofaturaçã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>
  <!-- Origem do documento -->
  <xs:element name="SourceBilling">
    <xs:annotation>
      <xs:documentation>P para documento produzido na aplicação, I para documento integrado e produzido noutra aplicação, M para documento proveniente de recuperação de emissão manual </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="P" />
        <xs:enumeration value="I" />
        <xs:enumeration value="M" />
      </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 Faturação incluindo os documentos de transporte, I para Contabilidade-Faturação incluindo os documentos de transporte, S para Autofaturação, E – Faturação, incluindo documentos de transporte, emitida por terceiros, P para Faturação parcial incluindo os documentos de transporte</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="E" />
        <xs:enumeration value="P" />
      </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.])*|NS" />
        <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="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|PT-AC|PT-MA" />
        <xs:minLength value="2" />
        <xs:maxLength value="5" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Tipo de Imposto -->
  <xs:element name="TaxType">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="IVA" />
        <xs:enumeration value="IS" />
        <xs:enumeration value="NS" />
      </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>
  <!-- Código do tipo de imposto retido -->
  <xs:element name="WithholdingTaxType">
    <xs:annotation>
      <xs:documentation>Restrição: IRS para Imposto Sobre o Rendimento das Pessoas Singulares, IRC para Imposto Sobre o Rendimento das Pessoas colectivas, IS para Imposto de selo </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="IRS" />
        <xs:enumeration value="IRC" />
        <xs:enumeration value="IS" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Estado do documento WorkingDocuments -->
  <xs:element name="WorkStatus">
    <xs:annotation>
      <xs:documentation>N para Normal, A para Anulado, F para faturado (quando para este documento também existe na tabela 4.1. o correspondente do tipo fatura ou fatura simplificada) </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="N" />
        <xs:enumeration value="A" />
        <xs:enumeration value="F" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- Tipo de documento de conferência de entrega de mercadorias ou da prestação de serviços -->
  <xs:element name="WorkType">
    <xs:annotation>
      <xs:documentation>
        Restrição: DC para documentos suscetíveis de apresentação ao cliente para conferência de entrega de mercadorias ou da prestação de serviços
      </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="DC" />
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <!-- 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:minInclusive value="0.00" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFmonetaryType">
    <xs:restriction base="xs:decimal">
      <xs:minInclusive value="0.00" />
    </xs:restriction>
  </xs:simpleType>
  <!-- TIPOS DE DADOS BASE SAFT Portugal -->
  <!-- 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>
  <!-- Periodo do movimento contabilístico -->
  <xs:simpleType name="SAFPTAccountingPeriod">
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="1" />
      <xs:maxInclusive value="16" />
    </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="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="SAFPTGLAccountID">
    <xs:restriction base="xs:string">
      <xs:pattern value="(([0-9a-zA-Z\-/._+*]*))" />
      <xs:minLength value="1" />
      <xs:maxLength value="30" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTJournalID">
    <xs:restriction base="xs:string">
      <xs:pattern value="[^ ]{1,30}" />
      <xs:minLength value="1" />
      <xs:maxLength value="30" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFTPTMovementTaxCode">
    <xs:restriction base="xs:string">
      <xs:pattern value="RED|INT|NOR|ISE|OUT|NS" />
      <xs:minLength value="1" />
      <xs:maxLength value="3" />
    </xs:restriction>
  </xs:simpleType>
  <!-- Tipo de Imposto da Tabela MovementOfGoods-->
  <xs:simpleType name="SAFTPTMovementTaxType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="IVA" />
      <xs:enumeration value="NS" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTPortugueseTaxExemption">
    <xs:restriction base="xs:string">
      <xs:minLength value="6" />
      <xs:maxLength value="60" />
    </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="SAFPTProductID">
    <xs:restriction base="xs:string">
      <xs:pattern value="[^/]+/[^/]+" />
      <xs:minLength value="3" />
      <xs:maxLength value="255" />
    </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="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="SAFPTtextTypeMandatoryMax30Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="30" />
    </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="SAFPTtextTypeMandatoryMax50Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="50" />
    </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="SAFPTtextTypeMandatoryMax90Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="90" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax100Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="100" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax172Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="172" />
    </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>
  <xs:simpleType name="SAFPTtextTypeMandatoryMax255Car">
    <xs:restriction base="xs:string">
      <xs:minLength value="1" />
      <xs:maxLength value="255" />
    </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="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:schema>