<?xml version="1.0" encoding="UTF-8"?>
<!-- ===== Copyright Notice ===== -->
<!--  
 Copyright (C) Elektronički Računi d.o.o 2019. All Rights Reserved.

Elektronički Računi d.o.o  takes no position regarding the validity or scope of any 
  intellectual property or other rights that might be claimed to pertain 
  to the implementation or use of the technology described in this 
  document or the extent to which any license under such rights 
  might or might not be available; neither does it represent that it has 
  made any effort to identify any such rights. 

This document and translations of it may be copied and furnished to 
  others, in whole or in part, for the purpose of integration with
  Moj eRačun network, provided that the above copyright notice and this 
  paragraph are included on all such copies and derivative works. 
  Other usages of the document or its translations are prohibited.
  However, this document itself may not be modified in any way, 
  such as by removing the copyright notice or references to 
  OASIS or Elektronički računi d.o.o., 
 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:xs="http://www.w3.org/2001/XMLSchema" 
 xmlns:exthr ="urn:invoice:hr:schema:xsd:CommonExtensionComponents-1"
 xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" 
 xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" 
 xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"  
 xmlns:i="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" 
 exclude-result-prefixes=" i" 
 xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
	
	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
	
	<xsl:variable name="supplierCompanyId">
		<xsl:choose>
			<xsl:when test="//cac:AccountingSupplierParty/cac:Party/cbc:EndpointID[@schemeID='9934']">
				<xsl:apply-templates select="//cac:AccountingSupplierParty/cac:Party/cbc:EndpointID" mode="CompanyID" />
			</xsl:when>
			<xsl:when test="//cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyID and (string-length(normalize-space(//cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyID)) = 11)">
				<xsl:apply-templates select="//cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyID" mode="SchemeID" />
			</xsl:when>
			<xsl:when test="//cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID[starts-with(text(), '9934:')]">
				<xsl:apply-templates select="//cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID" mode="PartyID2CompanyID" />
			</xsl:when>
			<xsl:when test="//cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID[starts-with(text(), 'HR')]">
				<xsl:apply-templates select="//cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID" mode="TaxID2CompanyID" />
			</xsl:when>
			<xsl:when test="//cac:AccountingSupplierParty/cac:Party/cbc:EndpointID">
				<xsl:apply-templates select="//cac:AccountingSupplierParty/cac:Party/cbc:EndpointID" mode="CompanyID" />
			</xsl:when>

		</xsl:choose>

	</xsl:variable>
	
	<xsl:variable name="customerCompanyId">
		<xsl:choose>
			<xsl:when test="//cac:AccountingCustomerParty/cac:Party/cbc:EndpointID[@schemeID='9934']">
				<xsl:apply-templates select="//cac:AccountingCustomerParty/cac:Party/cbc:EndpointID" mode="CompanyID" />
			</xsl:when>
			<xsl:when test="//cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyID and (string-length(normalize-space(//cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyID)) = 11)">
				<xsl:apply-templates select="//cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyID" mode="SchemeID" />
			</xsl:when>
			<xsl:when test="//cac:AccountingCustomerParty/cac:Party/cac:PartyIdentification/cbc:ID[starts-with(text(), '9934:')]">
				<xsl:apply-templates select="//cac:AccountingCustomerParty/cac:Party/cac:PartyIdentification/cbc:ID" mode="PartyID2CompanyID" />
			</xsl:when>
			<xsl:when test="//cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID[starts-with(text(), 'HR')]">
				<xsl:apply-templates select="//cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID" mode="TaxID2CompanyID" />
			</xsl:when>
			<xsl:when test="//cac:AccountingCustomerParty/cac:Party/cbc:EndpointID">
				<xsl:apply-templates select="//cac:AccountingCustomerParty/cac:Party/cbc:EndpointID" mode="CompanyID" />
			</xsl:when>

		</xsl:choose>

	</xsl:variable>



	
	<xsl:template match="/">
					<xsl:apply-templates select="//i:Invoice" />
	</xsl:template>
	
	<xsl:template match="i:Invoice">
		
		<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
		    xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2"
		    xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2"
		    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		
			
			<ext:UBLExtensions>
				<xsl:call-template name="UBLExtensionInvoiceIssuer"/>
				<xsl:call-template name="UBLExtensionIssuePlace"/>
			    <xsl:call-template name="UBLExtensionIssuerLogo"/>
			</ext:UBLExtensions>
			<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
			<cbc:CustomizationID>
			    <xsl:value-of select="'urn:invoice.hr:ubl-2.1-customizations:HRInvoice'"/>
			</cbc:CustomizationID>

			<!--<xsl:apply-templates select="cbc:ProfileID" />-->
			<cbc:ProfileID>MojEracunInvoice</cbc:ProfileID>
			<xsl:copy-of select="cbc:ID" />
			<cbc:CopyIndicator>false</cbc:CopyIndicator>
			<xsl:copy-of select="cbc:IssueDate" />
			<!--<xsl:apply-templates select="cbc:Note" mode="IssueTime" />-->
			<xsl:copy-of select="cbc:IssueTime"/>

			<!--<xsl:apply-templates select="cac:PaymentMeans/cbc:PaymentDueDate" />-->
			<xsl:copy-of select="cbc:InvoiceTypeCode"/>
			<xsl:copy-of select="cbc:Note"/>
		    <xsl:copy-of select="cbc:TaxPointDate"/>
			<xsl:copy-of select="cbc:DocumentCurrencyCode" />
		    <xsl:copy-of select="cbc:TaxCurrencyCode"/>
			<xsl:copy-of select="cbc:AccountingCost" />
		    <xsl:copy-of select="cbc:BuyerReference"/>
			<xsl:copy-of select="cac:InvoicePeriod" />
			<xsl:copy-of select="cac:OrderReference" />
		    <xsl:copy-of select="cac:BillingReference" />
			<xsl:copy-of select="cac:DespatchDocumentReference" />			
			<xsl:copy-of select="cac:ReceiptDocumentReference" />
		    <xsl:copy-of select="cac:OriginatorDocumentReference"/>
			<xsl:copy-of select="cac:ContractDocumentReference" />
			<xsl:copy-of select="cac:AdditionalDocumentReference"/>
			
			<xsl:copy-of select="cac:ProjectReference" />
			
			<xsl:copy-of select="cac:AccountingSupplierParty" />
			<xsl:copy-of select="cac:AccountingCustomerParty" />
			
			<xsl:copy-of select="cac:PayeeParty" />
		    <xsl:copy-of select="cac:BuyerCustomerParty" />
		    <xsl:copy-of select="cac:SellerSupplierParty" />
		    <xsl:copy-of select="cac:TaxRepresentativeParty" />
			<xsl:copy-of select="cac:Delivery" />
		    <xsl:copy-of select="cac:DeliveryTerms" />
			<xsl:apply-templates select="cac:PaymentMeans" />
			<xsl:copy-of select="cac:PaymentTerms" />
			
			<xsl:apply-templates select="cac:AllowanceCharge" />
			
			<xsl:apply-templates select="cac:TaxTotal" />
			<xsl:copy-of select="cac:LegalMonetaryTotal" />

			<xsl:apply-templates select="cac:InvoiceLine" />
		
		</Invoice>
	
	</xsl:template>
    <xsl:template match="cac:InvoiceLine">
        <cac:InvoiceLine>
            <xsl:copy-of select="cbc:ID"/>
            <xsl:copy-of select="cbc:UUID"/>
            <xsl:copy-of select="cbc:Note"/>
            <xsl:copy-of select="cbc:InvoicedQuantity"/>
            <xsl:copy-of select="cbc:LineExtensionAmount"/>
            <xsl:copy-of select="cbc:TaxPointDate"/>
            <xsl:copy-of select="cbc:AccountingCost"/>
            <xsl:copy-of select="cac:InvoicePeriod"/>
            <xsl:copy-of select="cac:OrderLineReference"/>
            <xsl:copy-of select="cac:DespatchLineReference"/>
            <xsl:copy-of select="cac:ReceiptLineReference"/>
            <xsl:copy-of select="cac:BillingReference"/>
            <xsl:copy-of select="cac:DocumentReference"/>
            <xsl:copy-of select="cac:Delivery"/>
            <xsl:copy-of select="cac:AllowanceCharge"/>
            <xsl:apply-templates select="cac:TaxTotal"/>
            <xsl:apply-templates select="cac:Item"/>
            <xsl:copy-of select="cac:Price"/>
        </cac:InvoiceLine>
    </xsl:template>
    <xsl:template match="cac:Item">
        <xsl:param name="additionalItemIdentification" select="cac:AdditionalItemIdentification/cbc:ID"/>
        <cac:Item>
            <xsl:copy-of select="cbc:Description"/>
            <xsl:copy-of select="cbc:PackQuantity"/>
            <xsl:copy-of select="cbc:PackSizeNumeric"/>
            <xsl:copy-of select="cbc:Name"/>
            <xsl:copy-of select="cac:BuyersItemIdentification"/>
            <xsl:copy-of select="cac:SellersItemIdentification"/>
            <xsl:copy-of select="cac:ManufacturersItemIdentification"/>
            <xsl:call-template name="AdditionalItemIdentification">
                <xsl:with-param name="additionalItemIdentification"/>
            </xsl:call-template>
            <xsl:copy-of select="cac:OriginCountry"/>
            <xsl:copy-of select="cac:HazardousItem"/>
            <xsl:copy-of select="cac:AdditionalItemProperty"/>
            <xsl:copy-of select="cac:ItemInstance"/>
        </cac:Item>
    </xsl:template>
    <xsl:template name="AdditionalItemIdentification">
        <xsl:param name="additionalItemIdentification"/>
        <cac:AdditionalItemIdentification>
            <cbc:ID>
                <xsl:value-of select="$additionalItemIdentification"/>
            </cbc:ID>
        </cac:AdditionalItemIdentification>
    </xsl:template>
    <xsl:template name="UBLExtensionIssuerLogo">		
        <ext:UBLExtension>
            <cbc:ID>HRINVOICE1</cbc:ID>
            <cbc:Name>IssuerLogoData</cbc:Name>
            <ext:ExtensionAgencyID>FINA</ext:ExtensionAgencyID>
            <ext:ExtensionAgencyName>FINA</ext:ExtensionAgencyName>
            <ext:ExtensionAgencyURI>FINA</ext:ExtensionAgencyURI>
            <ext:ExtensionURI>urn:invoice:hr:issuerlogo</ext:ExtensionURI>
            <ext:ExtensionReasonCode>MandatoryField</ext:ExtensionReasonCode>
            <ext:ExtensionReason>BASE64 logotipa tvrtke</ext:ExtensionReason>
            <ext:ExtensionContent>
                <exthr:IssuerLogo>
                    <xsl:value-of select="//ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/ext:IssuerLogo"/>
                </exthr:IssuerLogo>
            </ext:ExtensionContent>
        </ext:UBLExtension>
        
    </xsl:template>
	<xsl:template name="UBLExtensionIssuePlace">		
		<ext:UBLExtension>
			<cbc:ID>HRINVOICE1</cbc:ID>
			<cbc:Name>InvoiceIssuePlaceData</cbc:Name>
			<ext:ExtensionAgencyID>MINGORP</ext:ExtensionAgencyID>
			<ext:ExtensionAgencyName>MINGORP</ext:ExtensionAgencyName>
			<ext:ExtensionAgencyURI>MINGORP</ext:ExtensionAgencyURI>
			<ext:ExtensionURI>urn:invoice:hr:issueplace</ext:ExtensionURI>
			<ext:ExtensionReasonCode>MandatoryField</ext:ExtensionReasonCode>
			<ext:ExtensionReason>Mjesto izdavanja računa prema Pravilniku o PDV-u</ext:ExtensionReason>
			<ext:ExtensionContent>
				<exthr:InvoiceIssuePlace>
				    <xsl:choose>
				        <xsl:when test="normalize-space(//ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/ext:InvoiceIssuePlace) != ''">
				            <xsl:value-of select="//ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/ext:InvoiceIssuePlace"/>
				        </xsl:when>
				    </xsl:choose>
					<xsl:value-of select="//cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:CityName" />
				</exthr:InvoiceIssuePlace>
			</ext:ExtensionContent>
		</ext:UBLExtension>
		
	</xsl:template>
	
	<xsl:template name="UBLExtensionInvoiceIssuer">
		<ext:UBLExtension>
			<cbc:ID>HRINVOICE1</cbc:ID>
			<cbc:Name>InvoiceIssuerData</cbc:Name>
			<ext:ExtensionAgencyID>FINA</ext:ExtensionAgencyID>
			<ext:ExtensionAgencyName>FINA</ext:ExtensionAgencyName>
			<ext:ExtensionAgencyURI>FINA</ext:ExtensionAgencyURI>
			<ext:ExtensionURI>urn:invoice:hr:issuer</ext:ExtensionURI>
			<ext:ExtensionReasonCode>MandatoryField</ext:ExtensionReasonCode>
			<ext:ExtensionReason>Podaci o izdavatelju prema Zakonu o trgovačkim društvima</ext:ExtensionReason>
			<ext:ExtensionContent>
				<exthr:InvoiceIssuer>
					<xsl:choose>
					    <xsl:when test="normalize-space(//ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/ext:InvoiceIssuer) != ''">
					        <xsl:value-of select="//ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/ext:InvoiceIssuer"/>
					    </xsl:when>
						<xsl:when test="//cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyLegalForm"><xsl:value-of select="//cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:CompanyLegalForm"/></xsl:when>
						<xsl:when test="//cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:RegistrationName"><xsl:value-of select="//cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:RegistrationName"/></xsl:when>
						<xsl:otherwise><xsl:value-of select="//cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name"/></xsl:otherwise>
					</xsl:choose>
				</exthr:InvoiceIssuer>
			</ext:ExtensionContent>
		</ext:UBLExtension>
		
	</xsl:template>

	
	<xsl:template match="cbc:BuyerReference" >
		<cac:AdditionalDocumentReference>
			<cbc:ID><xsl:value-of select="."/></cbc:ID>
			<cbc:DocumentType>Referenca na kupca</cbc:DocumentType>
		</cac:AdditionalDocumentReference>
	</xsl:template>
	<xsl:template match="cac:TaxTotal">
	
		<cac:TaxTotal>
			<xsl:copy-of select="cbc:TaxAmount" />
			<xsl:apply-templates select="cac:TaxSubtotal" mode="TaxTotal" />
		
		</cac:TaxTotal>
	
	
	</xsl:template>
	
	
	
	<xsl:template match="cac:TaxSubtotal" mode="TaxTotal" >
		<cac:TaxSubtotal>
			<xsl:copy-of select="cbc:TaxableAmount" />
			<xsl:copy-of select="cbc:TaxAmount" />
			<xsl:apply-templates select="cac:TaxCategory" mode="TaxTotal" />
		
		</cac:TaxSubtotal>
	
	</xsl:template>
    <xsl:template match="cac:TaxCategory" mode="TaxTotal">
        <xsl:param name="taxCategoryId" select="cbc:ID"/>
        <cac:TaxCategory>
            <xsl:copy-of select="cbc:ID"/>
            <xsl:apply-templates select="cbc:Name" mode="TaxCategory"/>
            <xsl:copy-of select="cbc:Percent"/>
            <xsl:copy-of select="TaxExemptionReason"/>
            <xsl:apply-templates select="cac:TaxScheme" mode="TaxTotal">
                <xsl:with-param name="taxCategoryId"></xsl:with-param>
            </xsl:apply-templates>
        </cac:TaxCategory>
    </xsl:template>
    <xsl:template match="cac:TaxScheme" mode="TaxTotal">
        <xsl:param name="taxCategoryId"/>
        <cac:TaxScheme>
            <cbc:ID>
            <xsl:choose>
                <xsl:when test="$taxCategoryId = 'E' or $taxCategoryId ='O' ">
                    <xsl:value-of select="'FRE'"/>
                </xsl:when>
                <xsl:otherwise><xsl:value-of select="'VAT'"/></xsl:otherwise>
            </xsl:choose>
            </cbc:ID>
            <xsl:copy-of select="cbc:Name"/>
            <xsl:copy-of select="cbc:TaxTypeCode"/>
        </cac:TaxScheme>
    </xsl:template>
    <xsl:template match="cbc:Name" mode="TaxCategory">
        <cbc:Name>
            <xsl:choose>
                <xsl:when test="normalize-space(.) = 'OSLOBOĐENO_POREZA'">OP</xsl:when>
                <xsl:when test="normalize-space(.) = 'NEOPOREZIVO'">NO</xsl:when>
                <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
            </xsl:choose>
        </cbc:Name>
    </xsl:template>

	<xsl:template match="cac:AllowanceCharge">
		<cac:AllowanceCharge>
			<xsl:copy-of select="cbc:ChargeIndicator" />
			<xsl:copy-of select="cbc:AllowanceChargeReasonCode" />
			<xsl:copy-of select="cbc:AllowanceChargeReason" />
			<xsl:copy-of select="cbc:MultiplierFactorNumeric" />
			<xsl:copy-of select="cbc:Amount" />
			<xsl:copy-of select="cbc:BaseAmount" />
		    <xsl:choose>
		        <xsl:when test="cac:TaxCategory">
		            <xsl:copy-of select="cac:TaxCategory"/>
		        </xsl:when>
		        <xsl:otherwise>
		            <xsl:call-template name="AllowanceChargeTaxCategory"/>
		        </xsl:otherwise>
		    </xsl:choose>	
		</cac:AllowanceCharge>
	
	</xsl:template>
    <!--Wand fix-->
    <xsl:template name="AllowanceChargeTaxCategory">
        <cac:TaxCategory>
            <cbc:ID>S</cbc:ID>
            <cbc:Name>PDV</cbc:Name>
            <cbc:Percent>25</cbc:Percent>
            <cac:TaxScheme>
                <cbc:Name>VAT</cbc:Name>
                <cbc:TaxTypeCode>StandardRated</cbc:TaxTypeCode>
            </cac:TaxScheme>
        </cac:TaxCategory>
    </xsl:template>
	
	<xsl:template match="cac:PaymentMeans" >
		<cac:PaymentMeans>
			<xsl:copy-of select="cbc:PaymentMeansCode" />
			<xsl:copy-of select="cbc:PaymentDueDate"/>
			<cbc:PaymentChannelCode listAgencyName="CEN/BII">IBAN</cbc:PaymentChannelCode>
			<xsl:apply-templates select="cbc:PaymentID" mode="InstructionID" />
			<xsl:copy-of select="cbc:InstructionNote" />
		    <xsl:copy-of select="cac:CardAccount" />
			<xsl:copy-of select="cac:PayeeFinancialAccount"/>
		    <xsl:copy-of select="cac:PaymentMandate" />
			
		
		</cac:PaymentMeans>
	
	</xsl:template>
	
	<xsl:template match="cac:PaymentMandate" >
		<cac:PaymentMandate>
			<xsl:apply-templates select="cbc:ID" />
			<xsl:apply-templates select="cac:PayeeFinancialAccount" mode="PaymentMandate" />
		
		</cac:PaymentMandate>	
	
	</xsl:template>
	
	<xsl:template match="cac:PayeeFinancialAccount" mode="PaymentMandate" >
		<cac:PayeeFinancialAccount>
			<xsl:apply-templates select="cbc:ID" />
			<xsl:apply-templates select="/i:Invoice/cbc:DocumentCurrencyCode" mode="CurrencyCode" />

		</cac:PayeeFinancialAccount>
	
	</xsl:template>
	
	<xsl:template match="cbc:DocumentCurrencyCode" mode="CurrencyCode" >		<cbc:CurrencyCode listID="ISO 4217 Alpha" listAgencyID="5" listURI="http://docs.oasis-open.org/ubl/os-UBL-2.1/cl/gc/default/CurrencyCode-2.1.gc">
			<xsl:value-of select="." />
		</cbc:CurrencyCode>
	</xsl:template>
	
	<xsl:template match="cac:PayeeFinancialAccount" mode="PaymentMeans">
		<cac:PayeeFinancialAccount>
			<xsl:apply-templates select="cbc:ID" />
			<xsl:apply-templates select="cbc:Name" />
			<xsl:apply-templates select="/i:Invoice/cbc:DocumentCurrencyCode" mode="CurrencyCode" />
			<xsl:apply-templates select="cac:FinancialInstitutionBranch" />
		
		</cac:PayeeFinancialAccount>
	
	</xsl:template>
	

	
	<xsl:template match="cac:FinancialInstitutionBranch">
		<cac:FinancialInstitutionBranch>
			<cac:FinancialInstitution>
				<xsl:apply-templates select="cbc:ID" />
			
			</cac:FinancialInstitution>
		</cac:FinancialInstitutionBranch>
	
	</xsl:template>
	
	<xsl:template match="cac:CardAccount" >
		<cac:CardAccount>
			<xsl:apply-templates select="cbc:PrimaryAccountNumberID" />
			<xsl:apply-templates select="cbc:NetworkID" />
			<xsl:apply-templates select="cbc:HolderName" />
		
		</cac:CardAccount>
	
	</xsl:template>
	
	
	<xsl:template match="cbc:PaymentID" mode="InstructionID" >
		<cbc:InstructionID>
			<xsl:value-of select="concat(.,' ', ../cbc:InstructionID)"/>
		</cbc:InstructionID>
		
	</xsl:template>
	
	<xsl:template match="cbc:DueDate" mode="PaymentDueDate" >
		<cbc:PaymentDueDate>
			<xsl:value-of select="." />
		</cbc:PaymentDueDate>
	</xsl:template>
	
	<xsl:template match="cbc:PaymentMeansCode" >
		<xsl:variable name="codeVal">
			<xsl:value-of select="." />
		</xsl:variable>
		<cbc:PaymentMeansCode listID="UN/ECE 4461" listAgencyID="6" listName="PaymentMeansCode" listVersionID="D10B" listURI="http://docs.oasis-open.org/ubl/os-UBL-2.1/cl/gc/default/PaymentMeansCode-2.1.gc" listSchemeURI="urn:un:unece:uncefact:codelist:standard:UNECE:PaymentMeansCode:D10B">
			<xsl:choose>
				<xsl:when test="normalize-space($codeVal) = '30'">42</xsl:when>
				<xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
			</xsl:choose>
		
		</cbc:PaymentMeansCode>
	
	</xsl:template>	
	
	<xsl:template match="cac:ProjectReference" >
		<cac:AdditionalDocumentReference>
			<xsl:apply-templates select="cbc:ID" mode="ID" />
			<cbc:DocumentType>Referenca na projekt</cbc:DocumentType>
		</cac:AdditionalDocumentReference>
	
	</xsl:template>
	
	<xsl:template match="cac:OriginatorDocumentReference" >
		<cac:AdditionalDocumentReference>
			<xsl:apply-templates select="cbc:ID" mode="ID" />
			<cbc:DocumentType>Referenca na zahtjev za ponudom</cbc:DocumentType>
		</cac:AdditionalDocumentReference>
	
	</xsl:template>
	<xsl:template match="cac:BillingReference" >
		<cac:AdditionalDocumentReference>
			<cbc:ID><xsl:value-of select="./cac:InvoiceDocumentReference/cbc:ID"/></cbc:ID>
			<cbc:DocumentType>Referenca na prethodni račun</cbc:DocumentType>
		</cac:AdditionalDocumentReference>	
	</xsl:template>
	<xsl:template match="cac:OrderReference/cbc:SalesOrderID">
		<cac:AdditionalDocumentReference>
			<cbc:ID><xsl:value-of select="."/></cbc:ID>
			<cbc:DocumentType>SalesOrderID</cbc:DocumentType>
		</cac:AdditionalDocumentReference>
		
	</xsl:template>
	
</xsl:stylesheet>
