<?xml version="1.0" encoding="UTF-8"?>
<!--
    Descrizione documento:     Foglio di stile per Fattura italiana UBL 2.1
	Versione : 				   1.12
    Prodotto il :              Ottobre 2020
    PProdotto da :             Intercent-ER
    Ambito:                    Intercent-ER - Piloti Peppol
-->
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
                xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
                xmlns:in="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
                xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
                xmlns:cr="http://www.ubl-italia.org/ns/CrossReference" version="2.0"
                exclude-result-prefixes="cac cbc in">
	<xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet">
		<xd:desc>
			<xd:p>
				<xd:b>Created on:</xd:b>
                Oct 05, 2020
			</xd:p>
			<xd:p>
				<xd:b>Author:</xd:b>
                Intercent-ER
			</xd:p>
			<xd:p/>
		</xd:desc>
	</xd:doc>
	<xsl:param name="xclUnitOfMeasureCode"/>
	<xsl:param name="xclPaymentMeansCode"/>
	<xsl:param name="xclProvinceItaliane"/>

	<xsl:decimal-format name="number" decimal-separator="," grouping-separator="."/>
	<xsl:template match="/">
		<html>
			<head>
				<title>FATTURA</title>
				<style type="text/css">
                    .in-body {
                    font-family: serif
                    }
                    .in-box-label {
                    font-family: "Arial", sans-serif;
                    font-style:italic;
                    font-size:72%;
                    margin-left: 1pt;
                    margin-right:1pt;
                    margin-top:1pt
                    }
                    .box-text {
                    font-family: "Arial", sans-serif;
                    font-size:70%;
                    line-height:15pt;
                    margin-left: 1pt;
                    margin-right:1pt
                    }
                    .title-text {
                    font-family:"Arial", sans-serif;
                    font-weight:bold;
                    font-size:90%
                    margin-left:10pt;
                    }
                    .subtitle-text {
                    font-family:"Arial", sans-serif;
                    font-weight:bold;
                    font-size:80%;
                    margin-left: 1pt;
                    margin-right:1pt
                    }
                    .in-table {
                    border-collapse:collapse;
                    border-color: #000000;
                    table-layout:fixed
                    }
                    .in-form-column {
                    width:8.33%
                    }
                    .in-counter-cell {
                    border:none
                    }
                    .in-cell-data {
                    margin-top:0pt;
                    margin-bottom:0pt
                    }
                    .in-cell-data-background {
                    }
                    .in-cell-data-center {
                    text-align:center
                    }
                    .in-cell-base {
                    border:solid;
                    border-width:1pt
                    }
                    .in-cell-end-override {
                    border-right-style:none
                    }
                    .in-cell-after-override {
                    border-bottom-style:none
                    }
                    .in-cell-line-background {
                    background-color:#b8b8b8;
                    font-weight:bold
                    }
                    .in-cell-filler-background {
                    background-color:#e8e8e8
                    }
                    .fixed-height{
                    min-height: 40px;
                    display:block;
                    }
                    .law-warning{
                    font-style: italic;
                    font-size: 70%;
                    }
                    .border-left{
                    border-left: 1px solid;
                    }
                    .no-bottom-border{
                    border-bottom: none;
                    }
                    .allowance-charge{
                    list-style-type: none;
                    padding: 0px;
                    margin: 0px;
                    }
                    .allowance-charge LI{
                    }
                    H1{
                    font-size:120%;
                    font-family: "Arial", sans-serif;
                    }

                    H2{
                    font-family: "Arial", sans-serif;
                    font-size:100%;
                    }

                    H3{
                    font-size:90%;
                    }

                    .padded{
                    padding-top:20px;
                    padding-bottom:10px;
                    display:block;
                    }

                    .riepilogo-fattura{
                    width:100%;
                    border:1px solid black;
                    padding: 0;
                    margin: 0;
                    border-spacing: 0;
                    border-collapse: collapse;
                    }
                    .dati-fattura{
                    width:100%;
                    height:150px;
                    border: none;
                    padding: 0;
                    margin: 0;
                    border-spacing: 0;
                    border-collapse: collapse;
                    }

                    .dati-documento{
                    width:100%;
                    height:50px;
                    border: none;
                    padding: 0;
                    margin: 0;
                    border-spacing: 0;
                    border-collapse: collapse;
                    }

                    .no-border{
                    border:0 !important;
                    }
                    .riepilogo-fattura TD{
                    border:1px solid black;
                    padding: 0;
                    margin: 0;
                    vertical-align: top;
                    }
                    .party-row{
                    height:150px;
                    }

                    .h50{
                    height: 50px;
                    }
                    .h80{
                    height: 80px;
                    }
                    .h100px{
                    height: 100px;
                    }


                    .border-bottom{
                    border-bottom:1px solid black !important;
                    }
                    .border-right{
                    border-right:1px solid black !important;
                    }

                    .border-left{
                    border-left:1px solid black !important;
                    }

                    .party-column{
                    width:50%;
                    }

                    .riepilogo-PDC{
                    width:100%;
                    border:1px solid black;
                    padding: 0;
                    margin: 0;
                    border-spacing: 0;
                    border-collapse: collapse;
                    }
                    .riepilogo-PDC TH{
                    font-family: "Arial", sans-serif;
                    font-size:70%;
                    font-style:italic;
                    border-right:1px solid black;
                    height:30px;
                    }
                    .w-50 {
                    width:50%;
                    }
                    .w-66 {
                    width:67%;
                    }
                    .w-90 {
                    width:90%;
                    }
                    .w-33 {
                    width:33%;
                    }
                    .w-40{
                    width:40%;
                    }
                    .w-30{
                    width:30%;
                    }
                    .w-25{
                    width:25%;
                    }
                    .w-15{
                    width:15%;
                    }
                    .w-10{
                    width:10%;
                    }
                    .w-5{
                    width:5%;
                    }

                    .w-100{
                    width:100%;
                    }


                    .righe-fattura{
                    width:100%;
                    border:1px solid black;
                    padding: 0;
                    margin: 0;
                    border-spacing: 0;
                    border-collapse: collapse;
                    }
                    .righe-fattura TH{
                    font-family: "Arial", sans-serif;
                    font-size:70%;
                    font-style:italic;
                    border-right:1px solid black;
                    height:30px;
                    }

                    .empty-cell-filler{
                    height: 1.5em;
                    }

                    .page-break{ page-break-inside:avoid }

                    table { page-break-inside:auto }
                    tr { page-break-inside:avoid; page-break-after:auto }
                    thead { display:table-header-group }
                    tfoot { display:table-footer-group }

                    .block{
                    display:block;
                    }

                    .h100{
                    height:100%;
                    }

                    .attachment-list{
                    list-style-type: none;
                    }

                    .floatright{
                    float:right;
                    }

                    .float-right{
                    float:right;
                    margin-top:20px;
                    clear:both;
                    }

                    .float-right-last{
                    float:right;
                    margin-bottom: 30px;
                    display:block;
                    clear:both;
                    }

                    .nowraptext{
                    white-space: nowrap;
                    word-break: break-all;
                    }

                    .bold{
                    font-weight:bold;
                    }

                    .margin-right{
                    margin-right:20px;
                    }

                    .header-linea{
                    padding-top: 5px;
                    padding-bottom:3px;
                    margin:0;
                    }

                    .no-margin{
                    margin:0;
                    padding:0;
                    }

                    .font-size-80 {
                    font-size: 80%;
                    }
				</style>
			</head>
			<body class="in-body">
				<div class="page-break">
					<h1>Fattura</h1>
					<h2>Rappresentazione UBL ver.
						<xsl:value-of select="/in:Invoice/cbc:UBLVersionID"/>
					</h2>
					<table class="riepilogo-fattura" summary="riepilogo fattura">
						<tr class="party-row">
							<td class="party-column">
								<h2 class="in-box-label">Fornitore</h2>
								<xsl:call-template name="in-supplier"/>
								<xsl:call-template name="in-customer-assigned-account"/>
							</td>
							<td>
								<table class="dati-fattura" summary="dati fattura">
									<tr class="dati-fattura-row dati-fattura-border">
										<td class="no-border border-right border-bottom h100px w-33 in-cell-filler-background">
											<h2 class="in-box-label">Numero fattura</h2>
											<xsl:call-template name="in-id"/>
										</td>
										<td class="no-border border-right border-bottom h100px w-33 in-cell-filler-background">
											<h2 class="in-box-label">Data fattura</h2>
											<xsl:call-template name="in-date"/>
										</td>
										<td class="no-border border-bottom h100px w-33 in-cell-filler-background">
											<h2 class="in-box-label">Valuta</h2>
											<xsl:call-template name="in-currency"/>
										</td>
									</tr>
									<tr>
										<td class="no-border border-right w-33 h100px">
											<h2 class="in-box-label">Fattura Principale</h2>
											<xsl:if test="/in:Invoice/cac:BillingReference/cac:InvoiceDocumentReference[cbc:DocumentType='FatturaPrincipale']/cbc:ID">
												<div class="box-text">Numero:
													<xsl:value-of
                                                            select="/in:Invoice/cac:BillingReference/cac:InvoiceDocumentReference[cbc:DocumentType='FatturaPrincipale']/cbc:ID"/>
												</div>
											</xsl:if>
											<xsl:if test="/in:Invoice/cac:BillingReference/cac:InvoiceDocumentReference[cbc:DocumentType='FatturaPrincipale']/cbc:IssueDate">
												<div class="box-text">Data:
													<xsl:value-of
                                                            select="/in:Invoice/cac:BillingReference/cac:InvoiceDocumentReference[cbc:DocumentType='FatturaPrincipale']/cbc:IssueDate"/>
												</div>
											</xsl:if>
										</td>
										<td class="no-border w-33 h100px">
											<xsl:call-template name="transport-data"/>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr class="party-row">
							<td>
								<h2 class="in-box-label">Cliente</h2>
								<xsl:call-template name="in-customer"/>
							</td>
							<td>
								<table class="dati-fattura" summary="Note e riferimento amministrativo">
									<tr>
										<td class="no-border border-right w-33 border-bottom">
											<h2 class="in-box-label">Periodo di riferimento</h2>
											<xsl:call-template name="in-invoice-period"/>
										</td>
										<td class="no-border w-33 border-bottom">
											<h2 class="in-box-label">SAL</h2>
											<span class="box-text">
												<xsl:value-of
                                                        select="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType='SAL']/cbc:SAL"/>
											</span>
										</td>
									</tr>
									<tr class="dati-fattura-row h80">
										<td class="no-border" colspan="3">
											<h2 class="in-box-label">Note/Causale Documento</h2>
											<xsl:call-template name="in-note"/>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr class="h50">
							<td>
								<h2 class="in-box-label">Dati del terzo intermediario soggetto emittente</h2>
								<xsl:call-template name="in-serviceprovider">
									<xsl:with-param name="tipoServizio">Emissione</xsl:with-param>
									<xsl:with-param name="showDisclaimer">true</xsl:with-param>
								</xsl:call-template>
							</td>
							<td>
								<table class="dati-documento h100" summary="Dati ordine e contratto">
									<tr>
										<td class="w-33 no-border border-right">
											<h2 class="in-box-label">Dati dell'ordine</h2>
											<xsl:call-template name="document-data">
												<xsl:with-param name="campo" select="/in:Invoice/cac:OrderReference"/>
												<xsl:with-param name="suffix">ordine</xsl:with-param>
												<xsl:with-param name="cup">CUP</xsl:with-param>
												<xsl:with-param name="cig">CIG</xsl:with-param>
												<xsl:with-param name="commessa">CommessaConvenzione</xsl:with-param>
											</xsl:call-template>
<!-- 											<xsl:if test="/in:Invoice/cac:AdditionalDocumentReference[cbc:DocumentType='OrdineAggiuntivo'] and /in:Invoice/cac:OrderReference">
												<hr/>
											</xsl:if>
											<xsl:if test="/in:Invoice/cac:AdditionalDocumentReference[cbc:DocumentType='OrdineAggiuntivo']">
												<xsl:call-template name="document-data">
													<xsl:with-param name="campo"
                                                                    select="/in:Invoice/cac:AdditionalDocumentReference[cbc:DocumentType='OrdineAggiuntivo']"/>
													<xsl:with-param name="suffix">ordine</xsl:with-param>
													<xsl:with-param name="cup">CUP</xsl:with-param>
													<xsl:with-param name="cig">CIG</xsl:with-param>
													<xsl:with-param name="commessa">CommessaConvenzione</xsl:with-param>
												</xsl:call-template>
											</xsl:if> -->
										</td>
										<td class="w-33 no-border border-right">
											<h2 class="in-box-label">Dati del contratto</h2>
											<xsl:call-template name="document-data">
												<xsl:with-param name="campo"
                                                                select="/in:Invoice/cac:ContractDocumentReference"/>
												<xsl:with-param name="suffix">contratto</xsl:with-param>
												<xsl:with-param name="cup">CUP_CONTRATTO</xsl:with-param>
												<xsl:with-param name="cig">CIG_CONTRATTO</xsl:with-param>
												<xsl:with-param name="commessa">CommessaConvenzione_CONTRATTO</xsl:with-param>
							 
											</xsl:call-template>
										</td>
										<td class="w-33 no-border">
											<h2 class="in-box-label">Dati della convenzione</h2>
											<xsl:call-template name="document-data">
												<xsl:with-param name="campo"
                                                                select="/in:Invoice/cac:OriginatorDocumentReference"/>
												<xsl:with-param name="suffix">convenzione</xsl:with-param>
												<xsl:with-param name="cup">CUP_CONVENZIONE</xsl:with-param>
												<xsl:with-param name="cig">CIG_CONVENZIONE</xsl:with-param>
												<xsl:with-param name="commessa">CommessaConvenzione_CONVENZIONE</xsl:with-param>
							 
											</xsl:call-template>
										</td>

									</tr>
								</table>
							</td>

						</tr>
						<tr class="h50">
							<td>
								<h2 class="in-box-label">Dati del trasmittente</h2>
								<xsl:call-template name="in-serviceprovider">
									<xsl:with-param name="tipoServizio">Trasmissione</xsl:with-param>
								</xsl:call-template>
							</td>
							<td>
								<table class="dati-documento h100" summary="Dati trasporto e documenti di trasporto">
									<tr>
										<td class="w-33 no-border border-right">
											<h2 class="in-box-label">Dati delle fatture collegate</h2>
											<xsl:call-template name="document-data">
												<xsl:with-param name="campo"
                                                                select="/in:Invoice/cac:BillingReference/cac:InvoiceDocumentReference"/>
												<xsl:with-param name="suffix">fatture collegate</xsl:with-param>
												<xsl:with-param name="cup">CUP_FATTURE_COLLEGATE</xsl:with-param>
												<xsl:with-param name="cig">CIG_FATTURE_COLLEGATE</xsl:with-param>
												<xsl:with-param name="commessa">CommessaConvenzione_FATTURE_COLLEGATE</xsl:with-param>
							 
											</xsl:call-template>
										</td>
										<td class="w-33 no-border border-right">
											<h2 class="in-box-label">Dati della ricezione</h2>
											<xsl:call-template name="document-data">
												<xsl:with-param name="campo"
                                                                select="/in:Invoice/cac:ReceiptDocumentReference"/>
												<xsl:with-param name="suffix">ricezione</xsl:with-param>
												<xsl:with-param name="cup">CUP_RICEZIONE</xsl:with-param>
												<xsl:with-param name="cig">CIG_RICEZIONE</xsl:with-param>
												<xsl:with-param name="commessa">CommessaConvenzione_RICEZIONE</xsl:with-param>
							 
											</xsl:call-template>
										</td>
										<td class="w-33 no-border">
											<h2 class="in-box-label">Dati del documento di trasporto</h2>
											<div class="box-text">
												<xsl:for-each select="/in:Invoice/cac:DespatchDocumentReference">
													<xsl:value-of select="cbc:ID"/>
													<xsl:if test="cbc:IssueDate">
														<xsl:text> (</xsl:text>
														<xsl:value-of select="cbc:IssueDate"/>
														<xsl:text>)</xsl:text>
													</xsl:if>
													<xsl:text>, </xsl:text>
												</xsl:for-each>
											</div>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</div>
				<div class="page-break">
					<h1>Righe Fattura</h1>
					<table class="righe-fattura" summary="righe fattura">
						<thead>
							<tr>
								<th scope="col" class="in-cell-filler-background">Nome / Descrizione / Note</th>
								<th scope="col" class="in-cell-filler-background">Cod. Articolo</th>
								<th scope="col" class="in-cell-filler-background">Quantità</th>
								<th scope="col" class="in-cell-filler-background">UdM</th>
								<th scope="col" class="in-cell-filler-background">Periodo di Riferimento</th>
								<th scope="col" class="in-cell-filler-background">Ordine di Acquisto</th>
								<th scope="col" class="in-cell-filler-background">Altri Riferimenti</th>
								<th scope="col" class="in-cell-filler-background">Centro di Costo</th>
								<th scope="col" class="in-cell-filler-background">Prezzo Unitario</th>
								<th scope="col" class="in-cell-filler-background">Sconti / Maggiorazioni</th>
								<th scope="col" class="in-cell-filler-background">Imponibile</th>
								<th scope="col" class="in-cell-filler-background">IVA%</th>
							</tr>
						</thead>
						<tbody>
							<xsl:for-each select="/in:Invoice/cac:InvoiceLine">
								<tr>

									<!-- Nome/Descrizione/Note -->
									<td class="in-cell-base">
										<div class="box-text">
											<div class="no-margin">
												<xsl:value-of select="cac:Item/cbc:Name"/>
												<xsl:if test="cac:Item/cbc:Description">
													<xsl:value-of select="cac:Item/cbc:Description"/>
												</xsl:if>
												<span style="width: 0.7em; display: inline-block;"/>
												<xsl:value-of select="cbc:Note"/>
												<xsl:if test="cac:Item/cac:AdditionalItemIdentification or cac:Item/cac:AdditionalItemProperty">
													<ul style="border:0;margin:0;padding:0">

														<xsl:for-each select="cac:Item/cac:AdditionalItemProperty">
															<li style="list-style-type:none;">
																<xsl:value-of select="cbc:Name"/>:
																<xsl:call-template name="format-pipe">
																	<xsl:with-param name="value">
																		<xsl:value-of select="./cbc:Value"/>
																	</xsl:with-param>
																</xsl:call-template>
															</li>
														</xsl:for-each>
													</ul>
												</xsl:if>
											</div>
										</div>
										<xsl:call-template name="dati-collegati-linea"/>

										<xsl:if test="cac:DocumentReference[./cbc:DocumentType='ESTREMI_CONTRATTO']/cbc:ID">
											<div class="box-text nowraptext" align="left">
                                                Estremi contratto:
												<xsl:value-of
                                                        select="cac:DocumentReference[./cbc:DocumentType='ESTREMI_CONTRATTO']/cbc:ID"/>
											</div>
											<div class="box-text nowraptext" align="left">
                                                Data:
												<xsl:value-of
                                                        select="cac:DocumentReference[./cbc:DocumentType='ESTREMI_CONTRATTO']/cbc:IssueDate"/>
											</div>
										</xsl:if>

										<xsl:if test="cac:DocumentReference[./cbc:DocumentType='ESTREMI_CONVENZIONE']/cbc:ID">
											<div class="box-text nowraptext" align="left">
                                                Estremi convenzione:
												<xsl:value-of
                                                        select="cac:DocumentReference[./cbc:DocumentType='ESTREMI_CONVENZIONE']/cbc:ID"/>
											</div>
											<div class="box-text nowraptext" align="left">
                                                Data:
												<xsl:value-of
                                                        select="cac:DocumentReference[./cbc:DocumentType='ESTREMI_CONVENZIONE']/cbc:IssueDate"/>
											</div>
										</xsl:if>
									</td>

									<!-- Cod. Articolo -->
									<td class="in-cell-base in-cell-data-center">
										<xsl:if test="cac:Item/cac:SellersItemIdentification">
											<div class="box-text">
												<xsl:value-of select="cac:Item/cac:SellersItemIdentification/cbc:ID"/>
											</div>
										</xsl:if>
										<xsl:if test="cac:Item/cac:StandardItemIdentification">
											<div class="box-text">
												<xsl:value-of
                                                        select="cac:Item/cac:StandardItemIdentification/cbc:ID/@schemeID"/>:
												<xsl:value-of select="cac:Item/cac:StandardItemIdentification/cbc:ID"/>
											</div>
										</xsl:if>
										<xsl:if test="cac:Item/cac:AdditionalItemIdentification">
											<xsl:for-each select="cac:Item/cac:AdditionalItemIdentification">
												<div class="box-text">
													<xsl:value-of select="cbc:ID/@schemeID"/>:
													<xsl:value-of select="cbc:ID"/>
												</div>
											</xsl:for-each>
										</xsl:if>
										<xsl:if test="cac:Item/cac:CommodityClassification">
											<xsl:for-each select="cac:Item/cac:CommodityClassification">
												<div class="box-text">
													<xsl:value-of select="cbc:CommodityCode/@listID"/>:
													<xsl:value-of select="cbc:CommodityCode"/>
												</div>
												<div class="box-text">
													<xsl:value-of select="cbc:ItemClassificationCode/@listID"/>:
													<xsl:value-of select="cbc:ItemClassificationCode"/>
												</div>
											</xsl:for-each>
										</xsl:if>
									</td>

									<!-- Quantità -->
									<td class="in-cell-base  in-cell-data-center">
										<div class="box-text" align="right">
											<xsl:value-of select="cbc:InvoicedQuantity"/>
										</div>
									</td>

									<!-- UdM -->
									<td class="in-cell-base  in-cell-data-center">
										<div class="box-text">
											<xsl:value-of
                                                    select="if (document($xclUnitOfMeasureCode)//Value[@ColumnRef='xname']/SimpleValue[../../Value[@ColumnRef='code']/SimpleValue=current()/cbc:InvoicedQuantity/@unitCode]) then document($xclUnitOfMeasureCode)//Value[@ColumnRef='xname']/SimpleValue[../../Value[@ColumnRef='code']/SimpleValue=current()/cbc:InvoicedQuantity/@unitCode][1] else cbc:InvoicedQuantity/@unitCode"/>
										</div>
									</td>

									<!-- Periodo di riferimento -->
									<td class="in-cell-base  in-cell-data-center">
										<xsl:if test="cac:InvoicePeriod">
											<div class="box-text">
												<xsl:value-of select="cac:InvoicePeriod/cbc:StartDate"/> -
												<xsl:value-of select="cac:InvoicePeriod/cbc:EndDate"/>
											</div>
										</xsl:if>
									</td>

									<!-- Ordine di Acquisto -->
									<td class="in-cell-base">
										<xsl:for-each select="cac:OrderLineReference">
											<xsl:if test="cbc:LineID">
												<div class="box-text">Riga
													<xsl:value-of select="cbc:LineID"/> -
													<xsl:value-of select="cac:OrderReference/cbc:ID"/> (<xsl:value-of
                                                            select="cac:OrderReference/cbc:IssueDate"/>)
												</div>
											</xsl:if>
										</xsl:for-each>
										<xsl:if test="cac:DocumentReference[./cbc:DocumentType='CIG']/cbc:ID">
											<div class="box-text nowraptext" align="left">
                                                CIG:
												<xsl:value-of
                                                        select="cac:DocumentReference[./cbc:DocumentType='CIG']/cbc:ID"/>
											</div>
										</xsl:if>
										<xsl:if test="cac:DocumentReference[./cbc:DocumentType='CUP']/cbc:ID">
											<div class="box-text nowraptext" align="left">
                                                CUP:
												<xsl:value-of
                                                        select="cac:DocumentReference[./cbc:DocumentType='CUP']/cbc:ID"/>
											</div>
										</xsl:if>
										<xsl:if test="cac:DocumentReference[./cbc:DocumentType='CommessaConvenzione']/cbc:ID">
											<div class="box-text nowraptext" align="left">
                                                Commessa Convenzione:
												<xsl:value-of
                                                        select="cac:DocumentReference[./cbc:DocumentType='CommessaConvenzione']/cbc:ID"/>
											</div>
										</xsl:if>
									</td>

									<!-- Altri riferimenti -->
									<td class="in-cell-base">
										<div>
											<ul style="border:0;margin:0;padding:0">
												<li style="list-style-type:none;">
													<xsl:for-each select="cac:DespatchLineReference">
														<div class="box-text">Riga DDT:
															<xsl:value-of select="cbc:LineID"/> -
															<xsl:value-of select="cac:DocumentReference/cbc:ID"/>
                                                            (<xsl:value-of
                                                                    select="cac:DocumentReference/cbc:IssueDate"/>)
														</div>
													</xsl:for-each>
												</li>
												<li style="list-style-type:none;">
													<xsl:for-each select="cac:BillingReference">
														<div class="box-text">Fattura/NdC associata:
															<xsl:value-of select="cac:InvoiceDocumentReference/cbc:ID"/>
                                                            (<xsl:value-of
                                                                    select="cac:InvoiceDocumentReference/cbc:IssueDate"/>)
														</div>
													</xsl:for-each>
												</li>
											</ul>
										</div>
									</td>

									<!-- Centro di Costo -->
									<td class="in-cell-base  in-cell-data-center">
										<div class="box-text" align="right">
											<xsl:value-of select="cbc:AccountingCost"/>
										</div>
									</td>

									<!-- Prezzo Unitario -->
									<td class="in-cell-base  in-cell-data-center">
										<div class="box-text" align="right">
											<xsl:call-template name="format-amount">
												<xsl:with-param name="amount">
													<xsl:value-of select="cac:Price/cbc:PriceAmount"/>
												</xsl:with-param>
											</xsl:call-template>
										</div>
									</td>

									<!-- Sconti / Maggiorazioni -->
									<td class="in-cell-base  in-cell-data-center">
										<div class="box-text" align="right">
											<ul class="allowance-charge">
												<xsl:for-each select="cac:AllowanceCharge">
													<li>
														<xsl:call-template name="allowance-charge">
															<xsl:with-param name="amount">
																<xsl:value-of select="cbc:Amount"/>
															</xsl:with-param>
															<xsl:with-param name="charge-indicator">
																<xsl:value-of select="cbc:ChargeIndicator"/>
															</xsl:with-param>
														</xsl:call-template>
													</li>
												</xsl:for-each>
											</ul>
										</div>
									</td>

									<!-- Importo Imponibile -->
									<td class="in-cell-base  in-cell-data-center">
										<div class="box-text" align="right">
											<xsl:call-template name="format-amount">
												<xsl:with-param name="amount">
													<xsl:value-of select="cbc:LineExtensionAmount"/>
												</xsl:with-param>
											</xsl:call-template>
										</div>
									</td>

									<!-- IVA% -->
									<td class="in-cell-base in-cell-data-center">
										<xsl:if test="cac:Item/cac:ClassifiedTaxCategory/cbc:Percent">
											<div class="box-text" align="right">
												<xsl:call-template name="format-amount">
													<xsl:with-param name="amount">
														<xsl:value-of
                                                                select="cac:Item/cac:ClassifiedTaxCategory/cbc:Percent"/>
													</xsl:with-param>
												</xsl:call-template>
											</div>
										</xsl:if>
									</td>
								</tr>
							</xsl:for-each>
						</tbody>
					</table>
				</div>
				<div class="page-break">
					<h1>Riepilogo Piano dei Conti</h1>
					<table id="riepilogo-PDC" class="riepilogo-PDC" summary="Riepilogo PDC">
						<thead>
							<tr>
								<th scope="col" class="w-40 in-cell-filler-background">Centro di Costo</th>
								<th scope="col" class="w-30 in-cell-filler-background">Totale Imponibile</th>
								<th scope="col" class="w-30 in-cell-filler-background">Totale Imposte</th>
							</tr>
						</thead>
						<tbody>
							<xsl:if test="not(/in:Invoice/cac:InvoiceLine/cbc:AccountingCost)">
								<tr>
									<td class="in-cell-base in-cell-data-center empty-cell-filler">
										<span class="box-text"/>
									</td>
									<td class="in-cell-base  in-cell-data-center empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
									<td class="in-cell-base  in-cell-data-center empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
								</tr>
							</xsl:if>
							<xsl:for-each-group select="/in:Invoice/cac:InvoiceLine" group-by="cbc:AccountingCost">
								<tr>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text">
											<xsl:value-of select="current-grouping-key()"/>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text" align="right">
											<xsl:call-template name="format-amount">
												<xsl:with-param name="amount">
													<xsl:value-of
                                                            select="sum(current-group()/cbc:LineExtensionAmount/xs:decimal(.))"/>
													<!--<xsl:value-of select="current-group()/cbc:LineExtensionAmount"/>-->
												</xsl:with-param>
											</xsl:call-template>
										</div>
									</td>
									<td class="in-cell-base">
										<div class="box-text" align="right">
											<xsl:call-template name="format-amount">
												<xsl:with-param name="amount">
													<xsl:value-of
                                                            select="sum(for $i in current-group() return $i/cac:Item/cac:ClassifiedTaxCategory/cbc:Percent * $i/cbc:LineExtensionAmount div 100)"/>
												</xsl:with-param>
											</xsl:call-template>
										</div>
									</td>
								</tr>
							</xsl:for-each-group>
						</tbody>
					</table>
				</div>
				<xsl:if test="/in:Invoice/cac:WithholdingTaxTotal">
					<div class="page-break">
						<h1>Dati Ritenuta</h1>
						<table id="datiritenuta" class="riepilogo-PDC" summary="Dati Ritenuta">
							<thead>
								<tr>
									<th scope="col" class="w-25 in-cell-filler-background">Tipo Ritenuta</th>
									<th scope="col" class="w-25 in-cell-filler-background">Importo</th>
									<th scope="col" class="w-25 in-cell-filler-background">Aliquota</th>
									<th scope="col" class="w-25 in-cell-filler-background">Causale Pagamento</th>
								</tr>
							</thead>
							<tbody>

								<xsl:for-each select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension">

									<xsl:variable name="extensionURI" select="ext:ExtensionURI" />
									<xsl:variable name="extensionContent" select="ext:ExtensionContent" />

									<xsl:if test="starts-with($extensionURI, 'urn:www.ubl-italia.org:spec:fatturapa:xref:tipo_ritenuta')">
										<tr>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:variable name="RTCode">
														<xsl:value-of
                                                                select="$extensionContent/cr:XCode"/>
													</xsl:variable>
													<xsl:choose>
														<xsl:when test="normalize-space($RTCode) = 'RT01'">
                                                            Ritenuta di acconto persone fisiche (RT01)
														</xsl:when>
														<xsl:when test="normalize-space($RTCode) = 'RT02'">
                                                            Ritenuta di acconto persone giuridiche (RT02)
														</xsl:when>
														<xsl:when test="normalize-space($RTCode) = 'RT03'">
                                                            Contributo INPS (RT03)
														</xsl:when>
														<xsl:when test="normalize-space($RTCode) = 'RT04'">
                                                            Contributo ENASARCO (RT04)
														</xsl:when>
														<xsl:when test="normalize-space($RTCode) = 'RT05'">
                                                            Contributo ENPAM (RT05)
														</xsl:when>
														<xsl:when test="normalize-space($RTCode) = 'RT06'">
                                                            Altro contributo previdenziale (RT06)
														</xsl:when>
													</xsl:choose>
												</div>
											</td>

											<xsl:variable name="indexCounter">
												<xsl:choose>
													<xsl:when test="string-length($extensionURI) &gt; 58">
														<xsl:value-of select="substring($extensionURI, 59)"/>
													</xsl:when>
													<xsl:otherwise>1</xsl:otherwise>
												</xsl:choose>
											</xsl:variable>

											<xsl:variable name="currentHoldingTaxTotal" select="/in:Invoice/cac:WithholdingTaxTotal[number($indexCounter)]"/>

											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:call-template name="format-amount">
														<xsl:with-param name="amount">
															<xsl:value-of
                                                                    select="$currentHoldingTaxTotal/cbc:TaxAmount"/>
														</xsl:with-param>
													</xsl:call-template>
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:value-of
                                                                    select="$currentHoldingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:Percent"/>
                                                    %
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:value-of
                                                            select="$currentHoldingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:TaxTypeCode"/>
												</div>
											</td>
										</tr>
									</xsl:if>
								</xsl:for-each>
							</tbody>
						</table>
					</div>
				</xsl:if>

				<xsl:if test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI='urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa'] or
/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI='urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa::1'] or
/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI='urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa::2']">

					<div class="page-break">
						<h1>Dati Cassa Previdenziale</h1>
						<table id="dati-cassa" class="riepilogo-PDC" summary="Dati Cassa Previdenziale">
							<thead>
								<tr>
									<th scope="col" class="w-10 in-cell-filler-background">Tipo Cassa</th>
									<th scope="col" class="w-10 in-cell-filler-background">Aliquota Cassa</th>
									<th scope="col" class="w-15 in-cell-filler-background">Importo</th>
									<th scope="col" class="w-15 in-cell-filler-background">Imponibile</th>
									<th scope="col" class="w-10 in-cell-filler-background">Aliquota IVA</th>
									<th scope="col" class="w-10 in-cell-filler-background">Ritenuta</th>
									<th scope="col" class="w-15 in-cell-filler-background">Natura</th>
									<th scope="col" class="w-15 in-cell-filler-background">Riferimento Amministrazione
									</th>
								</tr>
							</thead>
							<tbody>
								<xsl:for-each select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionURI">
									<xsl:variable name="uri-corrente" select="."/>
									<xsl:if test="starts-with($uri-corrente, 'urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa') and
                                                                              not(starts-with($uri-corrente, 'urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa:aliquota_iva'))">
										<xsl:variable name="indice">
											<xsl:choose>
												<xsl:when
                                                        test="starts-with($uri-corrente, 'urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa::')">
													<xsl:value-of
                                                            select="concat('*',substring-after($uri-corrente,'contributo_cassa'))"/>
												</xsl:when>
												<xsl:when
                                                        test="$uri-corrente = 'urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa'">
													<xsl:value-of select="concat('*','')"/>
												</xsl:when>
											</xsl:choose>
										</xsl:variable>
										<tr>

											<td class="in-cell-base  in-cell-data-center">

												<div class="box-text" align="right">
													<xsl:value-of
                                                            select="../ext:ExtensionContent/cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:TaxTypeCode"/>
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:call-template name="format-amount">
														<xsl:with-param name="amount">
															<xsl:value-of
                                                                    select="../ext:ExtensionContent/cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:Percent"/>
														</xsl:with-param>
													</xsl:call-template>
                                                    %
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:call-template name="format-amount">
														<xsl:with-param name="amount">
															<xsl:value-of
                                                                    select="../ext:ExtensionContent/cac:TaxTotal/cbc:TaxAmount"/>
														</xsl:with-param>
													</xsl:call-template>
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:call-template name="format-amount">
														<xsl:with-param name="amount">
															<xsl:value-of
                                                                    select="../ext:ExtensionContent/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount"/>
														</xsl:with-param>
													</xsl:call-template>
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:call-template name="format-amount">
														<xsl:with-param name="amount">
															<xsl:choose>
																<xsl:when test="starts-with($indice,'*')">
																	<xsl:choose>
																		<xsl:when
                                                                                test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa:aliquota_iva',substring-after($indice,'*'))]/ext:ExtensionContent">
																			<xsl:value-of
                                                                                    select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa:aliquota_iva',substring-after($indice,'*'))]/ext:ExtensionContent/cbc:Percent"/>
																		</xsl:when>

																		<xsl:otherwise>
                                                                            22
																		</xsl:otherwise>
																	</xsl:choose>
																</xsl:when>

															</xsl:choose>
														</xsl:with-param>
													</xsl:call-template>
                                                    %
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:choose>
														<xsl:when test="starts-with($indice,'*')">
															<xsl:choose>
																<xsl:when
                                                                        test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa:ritenuta',substring-after($indice,'*'))]/ext:ExtensionContent">
																	<xsl:choose>
																		<xsl:when
                                                                                test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:contributo_cassa:ritenuta',substring-after($indice,'*'))]/ext:ExtensionContent/cbc:TaxEvidenceIndicator='true'">
                                                                            Sì
																		</xsl:when>
																		<xsl:otherwise>
                                                                            No
																		</xsl:otherwise>
																	</xsl:choose>
																</xsl:when>
															</xsl:choose>
														</xsl:when>

													</xsl:choose>
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
													<xsl:choose>
														<xsl:when test="starts-with($indice,'*')">
															<xsl:value-of
                                                                    select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:xref:contributo_cassa:natura_iva',substring-after($indice,'*'))]/ext:ExtensionContent/cr:XCode"/>
														</xsl:when>
													</xsl:choose>
												</div>
											</td>
											<td class="in-cell-base  in-cell-data-center">
												<div class="box-text" align="right">
                                                    ???
												</div>
											</td>
										</tr>
									</xsl:if>
								</xsl:for-each>

							</tbody>
						</table>
					</div>
				</xsl:if>


				<div class="page-break">
					<h1>Subtotali</h1>
					<h3 class="box-text">Riepilogo per imposta</h3>
					<xsl:for-each select="/in:Invoice/cac:TaxTotal">
						<xsl:for-each-group select="cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme" group-by="cbc:ID">
							<h3 class="box-text">
								<xsl:if test="current-grouping-key() = 'VAT'">IVA</xsl:if>
								<xsl:if test="not(current-grouping-key() = 'VAT')">
									<xsl:value-of select="current-grouping-key()"/>
								</xsl:if>
								<xsl:if test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI='urn:www.ubl-italia.org:spec:fatturapa:esigibilita_iva']/ext:ExtensionContent/cbc:TaxTypeCode">
									<span style="padding-left: 40px">Esigibilità:
										<xsl:variable name="EI">
											<xsl:value-of
                                                    select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI='urn:www.ubl-italia.org:spec:fatturapa:esigibilita_iva']/ext:ExtensionContent/cbc:TaxTypeCode"/>
										</xsl:variable>
										<xsl:value-of
                                                select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI='urn:www.ubl-italia.org:spec:fatturapa:esigibilita_iva']/ext:ExtensionContent/cbc:TaxTypeCode"/>
										<xsl:choose>
											<xsl:when test="$EI='I'">
                                                (esigibilità immediata)
											</xsl:when>
											<xsl:when test="$EI='D'">
                                                (esigibilità differita)
											</xsl:when>
											<xsl:when test="$EI='S'">
                                                (split payment)
											</xsl:when>
											<xsl:otherwise>
												<span>
													<i>(!!! codice non previsto !!!)</i>
												</span>
											</xsl:otherwise>
										</xsl:choose>
									</span>
								</xsl:if>
							</h3>
						</xsl:for-each-group>


						<table id="subtotali" class="riepilogo-PDC" summary="Subtotali">
							<thead>
								<tr>
									<th scope="col" class="w-20 in-cell-filler-background">Imponibile</th>
									<th scope="col" class="w-25 in-cell-filler-background">Natura</th>
									<th scope="col" class="w-5 in-cell-filler-background">IVA%</th>
									<th scope="col" class="w-10 in-cell-filler-background">Imposta</th>
									<th scope="col" class="w-10 in-cell-filler-background">Arrotondamento</th>
									<th scope="col" class="w-10 in-cell-filler-background">Spese Accessorie</th>
								</tr>
							</thead>
							<tbody>
								<xsl:for-each select="cac:TaxSubtotal">
									<tr>

										<!-- Imponibile -->
										<td class="in-cell-base  in-cell-data-center">
											<div class="box-text" align="right">
												<xsl:call-template name="format-amount">
													<xsl:with-param name="amount">
														<xsl:value-of select="cbc:TaxableAmount"/>
													</xsl:with-param>
												</xsl:call-template>
											</div>
										</td>

										<!-- Natura -->
										<td class="in-cell-base  in-cell-data-center">
											<div align="left">
												<span class="box-text">
													<xsl:variable name="index">
														<xsl:value-of select="position()"/>
													</xsl:variable>
													<xsl:if test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:xref:natura_riepilogo::',$index)]/ext:ExtensionContent/cr:XCode">
														<xsl:value-of
                                                                select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:xref:natura_riepilogo::',$index)]/ext:ExtensionContent/cr:XCode"/>
													</xsl:if>
													<xsl:choose>
														<xsl:when test="cac:TaxCategory/cbc:ID = 'E'">
                                                            N4
														</xsl:when>
														<xsl:when test="cac:TaxCategory/cbc:ID = 'AE'">
                                                            N6
														</xsl:when>
														<xsl:when test="cac:TaxCategory/cbc:ID = 'Z'">
                                                            N3
														</xsl:when>
													</xsl:choose>
													<xsl:if test="(cac:TaxCategory/cbc:TaxExemptionReasonCode or cac:TaxCategory/cbc:TaxExemptionReason)">
                                                        : Esentasse
														<xsl:if test="(cac:TaxCategory/cbc:TaxExemptionReason)">,
                                                            causale esenzione: "<xsl:apply-templates mode="line"
                                                                                                     select="cac:TaxCategory/cbc:TaxExemptionReason"/>
                                                            "
														</xsl:if>
														<xsl:if test="(cac:TaxCategory/cbc:TaxExemptionReasonCode)">
                                                            (codice causale esenzione:<xsl:apply-templates mode="line"
                                                                                                           select="cac:TaxCategory/cbc:TaxExemptionReasonCode"/>
                                                            )
														</xsl:if>

													</xsl:if>
												</span>
											</div>
										</td>

										<!-- IVA% -->
										<td class="in-cell-base  in-cell-data-center">
											<xsl:if test="cac:TaxCategory/cbc:Percent">
												<span class="box-text">
													<xsl:call-template name="format-amount">
														<xsl:with-param name="amount">
															<xsl:value-of select="cac:TaxCategory/cbc:Percent"/>
														</xsl:with-param>
													</xsl:call-template>
												</span>
											</xsl:if>
										</td>

										<!-- Imposta -->
										<td class="in-cell-base  in-cell-data-center">
											<div class="box-text" align="right">
												<xsl:call-template name="format-amount">
													<xsl:with-param name="amount">
														<xsl:value-of select="cbc:TaxAmount"/>
													</xsl:with-param>
												</xsl:call-template>
											</div>
										</td>

										<!-- Arrotondamento -->
										<td class="in-cell-base  in-cell-data-center">
											<div class="box-text" align="right">
												<xsl:variable name="index">
													<xsl:value-of select="position()"/>
												</xsl:variable>
												<xsl:call-template name="format-amount">
													<xsl:with-param name="amount">
														<xsl:value-of
                                                                select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:arrotondamento_riepilogo::',$index)]/ext:ExtensionContent/cbc:Amount"/>
													</xsl:with-param>
												</xsl:call-template>
											</div>
										</td>

										<!-- Spese Accessorie -->
										<td class="in-cell-base  in-cell-data-center">
											<div class="box-text" align="right">
												<xsl:variable name="index">
													<xsl:value-of select="position()"/>
												</xsl:variable>
												<xsl:call-template name="format-amount">
													<xsl:with-param name="amount">
														<xsl:value-of
                                                                select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI=concat('urn:www.ubl-italia.org:spec:fatturapa:spese_accessorie_riepilogo::',$index)]/ext:ExtensionContent/cbc:Amount"/>
													</xsl:with-param>
												</xsl:call-template>
											</div>
										</td>

									</tr>
								</xsl:for-each>
							</tbody>
						</table>
					</xsl:for-each>

					<xsl:if test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension//ext:ExtensionURI = 'urn:www.ubl-italia.org:spec:fatturapa:bollo'">
						<div class="page-break">
							<h1>Bollo</h1>
							<xsl:if test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI = 'urn:www.ubl-italia.org:spec:fatturapa:bollo']/ext:ExtensionContent/cbc:TaxAmount and /in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI = 'urn:www.ubl-italia.org:spec:fatturapa:bollo']/ext:ExtensionContent/cbc:TaxAmount != 0 ">
								<h3 class="box-text" style="margin-bottom:10px">
                                    Importo bollo:
									<xsl:value-of
                                            select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI = 'urn:www.ubl-italia.org:spec:fatturapa:bollo']/ext:ExtensionContent/cbc:TaxAmount"/>
                                    EUR
								</h3>
							</xsl:if>
							<span class="law-warning">Bollo assolto virtualmente in ottemperanza all'art. 6, comma 2,
                                del DM 17 Giugno 2014
							</span>
						</div>
					</xsl:if>

				</div>
				<div class="page-break">
					<h1>Modalità  di pagamento</h1>
					<table id="info-pagamento" class="riepilogo-PDC" summary="Info pagamento">
						<thead>
							<tr>
								<th scope="col" class="w-20 in-cell-filler-background">Modalità di pagamento</th>
								<th scope="col" class="w-50 in-cell-filler-background">Estremi Pagamento</th>
								<th scope="col" class="w-15 in-cell-filler-background">Codice Pagamento</th>
								<th scope="col" class="w-15 in-cell-filler-background">Data Scadenza Pagamento</th>
							</tr>
						</thead>
						<tbody>
							<xsl:if test="not(/in:Invoice/cac:PaymentMeans)">
								<tr>
									<td class="in-cell-base  in-cell-data-center empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
									<td class="in-cell-base in-cell-data-center empty-cell-filler">
										<span class="box-text"/>
									</td>
									<td class="in-cell-base empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
									<td class="in-cell-base  in-cell-data-center empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>

								</tr>
							</xsl:if>

							<xsl:for-each select="/in:Invoice/cac:PaymentMeans">
								<tr>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text" align="left">
											<xsl:variable name="MP">
												<xsl:choose>
													<xsl:when test="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI = 'urn:www.ubl-italia.org:spec:fatturapa:modalita_pagamento']">
														<xsl:value-of select="/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI = 'urn:www.ubl-italia.org:spec:fatturapa:modalita_pagamento']/ext:ExtensionContent/cbc:TypeCode" />
													</xsl:when>
													<xsl:otherwise>
														<xsl:value-of
                                                                    select="if (/in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI = concat('urn:www.ubl-italia.org:spec:fatturapa:xref:modalita_pagamento::',current()/cbc:PaymentMeansCode)]/ext:ExtensionContent/cr:XCode) then /in:Invoice/ext:UBLExtensions/ext:UBLExtension[ext:ExtensionURI = concat('urn:www.ubl-italia.org:spec:fatturapa:xref:modalita_pagamento::',current()/cbc:PaymentMeansCode)]/ext:ExtensionContent/cr:XCode else (if (document($xclPaymentMeansCode)//Value[@ColumnRef='xcode']/SimpleValue[../../Value[@ColumnRef='code']/SimpleValue=current()/cbc:PaymentMeansCode]) then document($xclPaymentMeansCode)//Value[@ColumnRef='xcode']/SimpleValue[../../Value[@ColumnRef='code']/SimpleValue=current()/cbc:PaymentMeansCode][1] else 'MP05')"/>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:variable>
											<xsl:value-of select="$MP"/>
											<xsl:choose>
												<xsl:when test="$MP='MP01'">(contanti)</xsl:when>
												<xsl:when test="$MP='MP02'">(assegno)</xsl:when>
												<xsl:when test="$MP='MP03'">(assegno circolare)</xsl:when>
												<xsl:when test="$MP='MP04'">(contanti presso Tesoreria)</xsl:when>
												<xsl:when test="$MP='MP05'">(bonifico)</xsl:when>
												<xsl:when test="$MP='MP06'">(vaglia cambiario)</xsl:when>
												<xsl:when test="$MP='MP07'">(bollettino bancario)</xsl:when>
												<xsl:when test="$MP='MP08'">(carta di credito)</xsl:when>
												<xsl:when test="$MP='MP09'">(RID)</xsl:when>
												<xsl:when test="$MP='MP10'">(RID utenze)</xsl:when>
												<xsl:when test="$MP='MP11'">(RID veloce)</xsl:when>
												<xsl:when test="$MP='MP12'">(RIBA)</xsl:when>
												<xsl:when test="$MP='MP13'">(MAV)</xsl:when>
												<xsl:when test="$MP='MP14'">(quietanza erario)</xsl:when>
												<xsl:when test="$MP='MP15'">(giroconto su conti di contabilit
                                                        speciale)
												</xsl:when>
												<xsl:when test="$MP='MP16'">(domiciliazione bancaria)</xsl:when>
												<xsl:when test="$MP='MP17'">(domiciliazione postale)</xsl:when>
												<xsl:when test="$MP='MP18'">(bollettino di c/c postale)</xsl:when>
												<xsl:when test="$MP='MP19'">(SEPA Direct Debit)</xsl:when>
												<xsl:when test="$MP='MP20'">(SEPA Direct Debit CORE)</xsl:when>
												<xsl:when test="$MP='MP21'">(SEPA Direct Debit B2B)</xsl:when>
												<xsl:when test="$MP='MP22'">(Trattenuta su somme già riscosse)
												</xsl:when>
												<xsl:when test="$MP='MP23'">(PagoPA)</xsl:when>
												<xsl:when test="$MP=''"/>
												<xsl:otherwise>
													<span>(!!! codice non previsto !!!)</span>
												</xsl:otherwise>
											</xsl:choose>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text" align="left">
											<xsl:if test="cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cac:FinancialInstitution/cbc:Name">
												<span class="block">Istituto finanziario:
													<xsl:value-of
                                                            select="cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cac:FinancialInstitution/cbc:Name"/>
												</span>
											</xsl:if>
											<xsl:if test="cac:PayeeFinancialAccount/cbc:ID">
												<span class="block">IBAN:
													<xsl:value-of select="cac:PayeeFinancialAccount/cbc:ID"/>
												</span>
											</xsl:if>
											<xsl:if test="cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cac:FinancialInstitution/cbc:ID[@schemeID='ABI']">
												<span class="block">ABI:
													<xsl:value-of
                                                            select="cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cac:FinancialInstitution/cbc:ID[@schemeID='ABI']"/>
												</span>
											</xsl:if>
											<xsl:if test="cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cbc:ID[@schemeID='CAB']">
												<span class="block">CAB:
													<xsl:value-of
                                                            select="cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cbc:ID[@schemeID='CAB']"/>
												</span>
											</xsl:if>
											<xsl:if test="cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cac:FinancialInstitution/cbc:ID[@schemeID='BIC']">
												<span class="block">BIC:
													<xsl:value-of
                                                            select="cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cac:FinancialInstitution/cbc:ID[@schemeID='BIC']"/>
												</span>
											</xsl:if>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text">
											<xsl:value-of select="./cbc:PaymentID"/>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text">
											<xsl:value-of select="./cbc:PaymentDueDate"/>
										</div>
									</td>
								</tr>
							</xsl:for-each>
						</tbody>
					</table>
				</div>
				<div class="page-break">
					<h1>Termini di Pagamento</h1>
					<table id="termini-pagamento" class="riepilogo-PDC" summary="Termini pagamento">
						<thead>
							<tr>
								<th scope="col" class="w-20 in-cell-filler-background">Termine di Pagamento</th>
								<th scope="col" class="w-15 in-cell-filler-background">Sconto Pagamento Anticipato</th>
								<th scope="col" class="w-15 in-cell-filler-background">Data Limite Pagamento
                                    Anticipato
								</th>
								<th scope="col" class="w-15 in-cell-filler-background">Penalità Pagamenti Ritardati</th>
								<th scope="col" class="w-15 in-cell-filler-background">Decorrenza Penalità </th>
								<th scope="col" class="w-50 in-cell-filler-background">Importo Pagamento</th>
							</tr>
						</thead>
						<tbody>
							<xsl:if test="not(/in:Invoice/cac:PaymentTerms)">
								<tr>
									<td class="in-cell-base  in-cell-data-center empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
									<td class="in-cell-base in-cell-data-center empty-cell-filler">
										<span class="box-text"/>
									</td>
									<td class="in-cell-base empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
									<td class="in-cell-base  in-cell-data-center empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
									<td class="in-cell-base  in-cell-data-center empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
									<td class="in-cell-base  in-cell-data-center empty-cell-filler">
										<span class="box-text empty-cell-filler"/>
									</td>
								</tr>
							</xsl:if>

							<xsl:for-each select="/in:Invoice/cac:PaymentTerms">
								<tr>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text">
											<xsl:value-of select="cbc:Note"/>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text" align="right">
											<xsl:call-template name="format-amount">
												<xsl:with-param name="amount">
													<xsl:value-of select="cbc:SettlementDiscountAmount"/>
												</xsl:with-param>
											</xsl:call-template>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text">
											<xsl:value-of select="cac:SettlementPeriod/cbc:EndDate"/>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text" align="right">
											<xsl:call-template name="format-amount">
												<xsl:with-param name="amount">
													<xsl:value-of select="cbc:PenaltyAmount"/>
												</xsl:with-param>
											</xsl:call-template>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text">
											<xsl:value-of select="cac:PenaltyPeriod/cbc:StartDate"/>
										</div>
									</td>
									<td class="in-cell-base in-cell-data-center">
										<div class="box-text" align="right">
											<xsl:call-template name="format-amount">
												<xsl:with-param name="amount">
													<xsl:value-of select="cbc:Amount"/>
												</xsl:with-param>
											</xsl:call-template>
										</div>
									</td>
								</tr>
							</xsl:for-each>
						</tbody>
					</table>
				</div>
				<xsl:for-each select="/in:Invoice/cac:AllowanceCharge">
					<div class="page-break float-right">
						<h1>
							<xsl:if test="cbc:ChargeIndicator eq 'false'">
                                Sconto:
							</xsl:if>
							<xsl:if test="cbc:ChargeIndicator eq 'true'">
                                Maggiorazione:
							</xsl:if>
							<xsl:call-template name="format-amount">
								<xsl:with-param name="amount">
									<xsl:value-of select="cbc:Amount"/>
								</xsl:with-param>
							</xsl:call-template>
							<xsl:text>  </xsl:text>
							<xsl:value-of select="cbc:Amount/@currencyID"/>
						</h1>
					</div>
				</xsl:for-each>
				<div class="page-break float-right-last">
					<h1>Totale Documento:
						<xsl:call-template name="format-amount">
							<xsl:with-param name="amount">
								<xsl:value-of select="/in:Invoice/cac:LegalMonetaryTotal/cbc:PayableAmount"/>
							</xsl:with-param>
						</xsl:call-template>
						<xsl:text>  </xsl:text>
						<xsl:value-of select="/in:Invoice/cac:LegalMonetaryTotal/cbc:PayableAmount/@currencyID"/>
					</h1>

				</div>
				<xsl:if test="in:Invoice/cac:AdditionalDocumentReference/cac:Attachment/cbc:EmbeddedDocumentBinaryObject">
					<xsl:variable name="NumAllegati">
						<xsl:value-of
                                select="count(in:Invoice/cac:AdditionalDocumentReference/cac:Attachment/cbc:EmbeddedDocumentBinaryObject)"/>
					</xsl:variable>
					<div class="box-text">
						<h2>
							<xsl:if test="$NumAllegati =1 ">E' presente un allegato:</xsl:if>
							<xsl:if test="$NumAllegati &gt;1">Sono presenti
								<xsl:value-of select="$NumAllegati"/> allegati:
							</xsl:if>
						</h2>
						<ul class="attachment-list">
							<xsl:for-each
                                    select="in:Invoice/cac:AdditionalDocumentReference/cac:Attachment/cbc:EmbeddedDocumentBinaryObject">
								<li style="list-style-type:disc">
									<xsl:value-of select="../../cbc:DocumentType"/>
									<xsl:if test="../../cac:Attachment/cbc:EmbeddedDocumentBinaryObject/@mimeCode">
                                        (<xsl:value-of
                                            select="../../cac:Attachment/cbc:EmbeddedDocumentBinaryObject/@mimeCode"/>)
									</xsl:if>
								</li>
							</xsl:for-each>
						</ul>
					</div>
				</xsl:if>
			</body>
		</html>
	</xsl:template>

	<xsl:template name="in-id">
		<span class="box-text">
			<xsl:apply-templates mode="line" select="/in:Invoice/cbc:ID"/>
		</span>
		<xsl:if test="/in:Invoice/cbc:ID/@schemeID='art73dpr633/72'">
			<div class="box-text">
                Art. 73 DPR 633/72: SI
			</div>
		</xsl:if>
	</xsl:template>

	<xsl:template name="in-date">
		<span class="box-text">
			<xsl:apply-templates mode="line" select="/in:Invoice/cbc:IssueDate"/>
		</span>
	</xsl:template>
	<xsl:template name="in-currency">
		<span class="box-text">
			<xsl:apply-templates mode="line" select="/in:Invoice/cbc:DocumentCurrencyCode"/>
		</span>
	</xsl:template>


	<xsl:template name="in-note">
		<ul style="border:0;padding:0;margin:0">
			<xsl:for-each select="/in:Invoice/cbc:Note">
				<span class="box-text" style="border:0;padding:0;margin:0">
					<li style="list-style-type:none">
						<xsl:value-of select="current()"/>
					</li>
				</span>
			</xsl:for-each>
		</ul>
	</xsl:template>

	<xsl:template name="in-customer-assigned-account">
		<xsl:if test="/in:Invoice/cac:AccountingSupplierParty/cbc:CustomerAssignedAccountID">
			<span class="box-text">Riferimento amministrativo:
				<xsl:value-of select="/in:Invoice/cac:AccountingSupplierParty/cbc:CustomerAssignedAccountID"/>
			</span>
		</xsl:if>
	</xsl:template>

	<xsl:template name="in-invoice-period">
		<xsl:if test="/in:Invoice/cac:InvoicePeriod">
			<span class="box-text">
				<xsl:value-of select="/in:Invoice/cac:InvoicePeriod/cbc:StartDate"/> -
				<xsl:value-of select="/in:Invoice/cac:InvoicePeriod/cbc:EndDate"/>
			</span>
		</xsl:if>
	</xsl:template>

	<xsl:template name="in-supplier">
		<xsl:call-template name="in-party">
			<xsl:with-param name="party" select="/in:Invoice/cac:AccountingSupplierParty/cac:Party"/>
		</xsl:call-template>
		<xsl:if test="/in:Invoice/cac:AdditionalDocumentReference[cbc:DocumentType='EORI CedentePrestatore']/cbc:ID">
			<div class="box-text">Codice EORI:
				<xsl:value-of
                        select="/in:Invoice/cac:AdditionalDocumentReference[cbc:DocumentType='EORI CedentePrestatore']/cbc:ID"/>
			</div>
		</xsl:if>
	</xsl:template>
	<xsl:template name="in-serviceprovider">
		<xsl:param name="tipoServizio"/>
		<xsl:param name="showDisclaimer"/>
		<xsl:if test="/in:Invoice/cac:AccountingSupplierParty/cac:Party/cac:ServiceProviderParty[cbc:ServiceType=$tipoServizio]/cac:Party">
			<xsl:call-template name="in-party">
				<xsl:with-param name="party"
                                select="/in:Invoice/cac:AccountingSupplierParty/cac:Party/cac:ServiceProviderParty[cbc:ServiceType=$tipoServizio]/cac:Party"/>
			</xsl:call-template>
			<xsl:if test="$showDisclaimer">
				<div class="box-text">
					<span class="law-warning">Fattura emessa per conto del cedente o prestatore art.21 secondo comma
                        lettera n) DPR 633/72
					</span>
				</div>
			</xsl:if>
		</xsl:if>
	</xsl:template>
	<xsl:template name="in-customer">
		<xsl:call-template name="in-party">
			<xsl:with-param name="party" select="/in:Invoice/cac:AccountingCustomerParty/cac:Party"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template name="address">
		<xsl:param name="address"/>
		<xsl:if test="$address/cbc:StreetName">
			<xsl:value-of select="$address/cbc:StreetName"/>
		</xsl:if>
		<xsl:if test="$address/cbc:PostalZone">
			<xsl:value-of select="$address/cbc:PostalZone"/>
		</xsl:if>
		<xsl:if test="$address/cbc:CityName">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="$address/cbc:CityName"/>
		</xsl:if>
		<xsl:if test="$address/cbc:CountrySubentity or $address/cac:Country/cbc:IdentificationCode">
			<xsl:text> (</xsl:text>
			<xsl:value-of select="$address/cbc:CountrySubentity"/>
			<xsl:text> </xsl:text>
			<xsl:value-of
                select="$address/cac:Country/cbc:IdentificationCode"/>)
		</xsl:if>
	</xsl:template>
	<xsl:template name="in-party">
		<xsl:param name="party"/>
		<div class="box-text">
			<xsl:if test="$party/cac:PartyName/cbc:Name">
				<xsl:value-of select="$party/cac:PartyName/cbc:Name"/>
			</xsl:if>
			<xsl:if test="$party/cac:Person/cbc:FirstName">
				<xsl:value-of select="$party/cac:Person/cbc:FirstName"/>
			</xsl:if>
			<xsl:if test="$party/cac:Person/cbc:FamilyName">
				<span style="min-width:1em;display:inline-block;"/>
				<xsl:value-of select="$party/cac:Person/cbc:FamilyName"/>
			</xsl:if>
		</div>
		<div class="box-text">
			<xsl:call-template name="address">
				<xsl:with-param name="address" select="$party/cac:PostalAddress"/>
			</xsl:call-template>
		</div>
		<div class="box-text">
			<xsl:if test="$party/cac:PartyTaxScheme/cbc:CompanyID[contains(@schemeID,':VAT')]">
				<span>P. IVA:
					<xsl:value-of select="$party/cac:PartyTaxScheme/cbc:CompanyID[contains(@schemeID,':VAT')]"/>
				</span>
				<br/>
			</xsl:if>
			<xsl:if test="$party/cac:Person/cbc:ID">
				<span>CF:
					<xsl:value-of select="$party/cac:Person/cbc:ID"/>
				</span>
				<br/>
			</xsl:if>
			<xsl:if test="$party/cac:PartyTaxScheme/cbc:CompanyID[@schemeID='IT:CF']">
				<span>CF:
					<xsl:value-of select="$party/cac:PartyTaxScheme/cbc:CompanyID[@schemeID='IT:CF']"/>
				</span>
				<br/>
			</xsl:if>
			<xsl:if test="$party/cac:PartyTaxScheme/cac:TaxScheme/cbc:TaxTypeCode">
				<span>Regime Fiscale:
					<xsl:value-of select="$party/cac:PartyTaxScheme/cac:TaxScheme/cbc:TaxTypeCode"/>
				</span>
				<br/>
			</xsl:if>
			<xsl:if test="$party/cac:PartyLegalEntity">
				<span>Reg. Imprese di:
					<xsl:value-of
                            select="document($xclProvinceItaliane)//Value[@ColumnRef='name']/SimpleValue[../../Value[@ColumnRef='code']/SimpleValue=$party/cac:PartyLegalEntity/cac:RegistrationAddress/cbc:CityName]"/>
                    n.
					<xsl:value-of select="$party/cac:PartyLegalEntity/cbc:CompanyID"/>
				</span>
				<br/>
			</xsl:if>
			<xsl:if test="$party/cac:PartyLegalEntity/cbc:CorporateStockAmount">
				<span>Capitale sociale:
					<xsl:value-of select="$party/cac:PartyLegalEntity/cbc:CorporateStockAmount"/>
				</span>
				<br/>
			</xsl:if>
			<xsl:if test="$party/cac:PartyIdentification/cbc:ID[@schemeID='IT:IPA']">
				<span>Codice IPA:
					<xsl:value-of select="$party/cac:PartyIdentification/cbc:ID[@schemeID='IT:IPA']"/>
				</span>
				<br/>
			</xsl:if>

			<xsl:choose>
				<xsl:when test="$party/cac:PartyLegalEntity/cbc:SoleProprietorshipIndicator">
					<span>Tipo proprietario: SU (Socio Unico)</span>
					<br/>
				</xsl:when>
				<xsl:otherwise>
					<span>Tipo proprietario: SM (più soci)</span>
					<br/>
				</xsl:otherwise>
			</xsl:choose>

			<xsl:choose>
				<xsl:when test="$party/cac:PartyLegalEntity/cbc:CompanyLiquidationStatusCode = 'LN'">
					<span>Stato di liquidazione: Non in liquidazione</span>
					<br/>
				</xsl:when>
				<xsl:when test="$party/cac:PartyLegalEntity/cbc:CompanyLiquidationStatusCode = 'LS'">
					<span>Stato di liquidazione: In liquidazione</span>
					<br/>
				</xsl:when>
				<xsl:otherwise>
				</xsl:otherwise>
			</xsl:choose>

			<xsl:if test="$party/cac:Contact/cbc:Telephone">
				<span>Telefono:
					<xsl:value-of select="$party/cac:Contact/cbc:Telephone"/>
				</span>
				<br/>
			</xsl:if>
			<xsl:if test="$party/cac:Contact/cbc:Telefax">
				<span>Fax:
					<xsl:value-of select="$party/cac:Contact/cbc:Telefax"/>
				</span>
				<br/>
			</xsl:if>
			<xsl:if test="$party/cac:Contact/cbc:ElectronicMail">
				<span>Email:
					<xsl:value-of select="$party/cac:Contact/cbc:ElectronicMail"/>
				</span>
				<br/>
			</xsl:if>
		</div>
	</xsl:template>
	<xsl:template name="format-pipe">
		<xsl:param name="value"/>
		<xsl:if test="$value and $value != ''">
			<xsl:for-each select="tokenize($value,'\|')">
				<xsl:if test=". != ''">
					<xsl:sequence select="."/>
				</xsl:if>
			</xsl:for-each>
		</xsl:if>
	</xsl:template>
	<xsl:template name="format-amount">
		<xsl:param name="amount"/>
		<xsl:if test="$amount and $amount != ''">
			<!-- Se contiene la mantissa fai "number", sennò "xs:decimal". -->
			<xsl:choose>
				<xsl:when test="matches($amount, '^\-?[\d\.,]*[Ee][+\-]*\d*$')">
					<span nowrap="nowrap">
						<xsl:value-of select="format-number(number($amount), '#.##0,00########', 'number')"/>
					</span>
				</xsl:when>
				<xsl:otherwise>
					<span nowrap="nowrap">
						<xsl:value-of select="format-number(xs:decimal($amount), '#.##0,00########', 'number')"/>
					</span>
				</xsl:otherwise>
			</xsl:choose>
			<!--<span nowrap="nowrap">
               <xsl:value-of select="format-number(xs:decimal($amount), '#.##0,00########', 'number')"/>
            </span> -->
		</xsl:if>
	</xsl:template>
	<xsl:template name="allowance-charge">
		<xsl:param name="charge-indicator"/>
		<xsl:param name="amount"/>
		<xsl:if test="$charge-indicator = 'false'">-</xsl:if>
		<xsl:call-template name="format-amount">
			<xsl:with-param name="amount">
				<xsl:value-of select="$amount"/>
			</xsl:with-param>
		</xsl:call-template>
	</xsl:template>
	<xsl:template name="transport-data">
		<h2 class="in-box-label">Dati del trasporto</h2>
		<xsl:if test="/in:Invoice/cac:Delivery/cac:Shipment/cbc:GrossWeightMeasure">
			<div class="box-text">Peso lordo:
				<xsl:value-of select="/in:Invoice/cac:Delivery/cac:Shipment/cbc:GrossWeightMeasure"/>
			</div>
		</xsl:if>
		<xsl:if test="/in:Invoice/cac:Delivery/cac:Shipment/cbc:NetWeightMeasure">
			<div class="box-text">Peso netto:
				<xsl:value-of select="/in:Invoice/cac:Delivery/cac:Shipment/cbc:NetWeightMeasure"/>
			</div>
		</xsl:if>
		<xsl:if test="/in:Invoice/cac:Delivery/cac:DeliveryLocation/cac:Address">
			<div class="box-text">Indirizzo di resa:
				<xsl:call-template name="address">
					<xsl:with-param name="address" select="/in:Invoice/cac:Delivery/cac:DeliveryLocation/cac:Address"/>
				</xsl:call-template>
			</div>
		</xsl:if>
	</xsl:template>
	<xsl:template name="document-data">
		<xsl:param name="campo"/>
		<xsl:param name="suffix"/>
		<xsl:param name="cup"/>
		<xsl:param name="cig"/>
		<xsl:param name="commessa"/>
		<xsl:if test="$campo/cbc:ID">
			<div class="box-text">Identificativo:
				<xsl:value-of select="$campo/cbc:ID"/> (<xsl:value-of select="$campo/cbc:IssueDate"/>) <xsl:text> </xsl:text>
				<xsl:if test="/in:Invoice/cac:AdditionalDocumentReference[cbc:DocumentType='OrdineAggiuntivo'] and /in:Invoice/cac:OrderReference">
				<xsl:for-each
					select="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType='OrdineAggiuntivo']">
					<xsl:value-of select="cbc:ID"/><xsl:text> (</xsl:text><xsl:value-of select="cbc:IssueDate"/><xsl:text>) </xsl:text>
				</xsl:for-each>
				</xsl:if>
			</div>
		</xsl:if>
<!-- 		<xsl:if test="$campo/cbc:IssueDate">
			<div class="box-text">Data:
				<xsl:value-of select="$campo/cbc:IssueDate"/> <xsl:text> </xsl:text>
				<xsl:if test="/in:Invoice/cac:AdditionalDocumentReference[cbc:DocumentType='OrdineAggiuntivo'] and /in:Invoice/cac:OrderReference"> 
				<xsl:value-of select="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType='OrdineAggiuntivo']/cbc:IssueDate"/>
				</xsl:if>
			</div>
		</xsl:if> -->
		<xsl:if test="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType=$commessa]/cbc:ID">
			<div class="box-text">Codice Commessa Convenzione:
				<xsl:value-of select="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType=$commessa]/cbc:ID"/>
			</div>
		</xsl:if>
		<xsl:if test="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType=$cig]/cbc:ID">
			<div class="box-text">Codice CIG:
				<xsl:value-of select="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType=$cig]/cbc:ID"/>
			</div>
		</xsl:if>
		<xsl:if test="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType=$cup]/cbc:ID">
			<div class="box-text">Codice CUP:
				<xsl:value-of select="/in:Invoice/cac:AdditionalDocumentReference[./cbc:DocumentType=$cup]/cbc:ID"/>
			</div>
		</xsl:if>
	</xsl:template>

	<xsl:template name="dato-collegato-linea">
		<xsl:param name="titolo"/>
		<xsl:param name="nomeCig"/>
		<xsl:param name="nomeCup"/>
		<xsl:param name="nomeCommessaConvenzione"/>
		<xsl:if test="cac:DocumentReference[./cbc:DocumentType=$nomeCig]/cbc:ID or cac:DocumentReference[./cbc:DocumentType=$nomeCup]/cbc:ID or cac:DocumentReference[./cbc:DocumentType=$nomeCommessaConvenzione]/cbc:ID">
			<div class="box-text no-margin" align="left">
				<h3 class="header-linea">
					<xsl:value-of select="$titolo"/>
				</h3>
				<xsl:if test="cac:DocumentReference[./cbc:DocumentType=$nomeCig]/cbc:ID">
					<xsl:call-template name="dato-linea">
						<xsl:with-param name="dato">
							<xsl:value-of select="cac:DocumentReference[./cbc:DocumentType=$nomeCig]/cbc:ID"/>
						</xsl:with-param>
						<xsl:with-param name="label">CIG</xsl:with-param>
					</xsl:call-template>
				</xsl:if>
				<xsl:if test="cac:DocumentReference[./cbc:DocumentType=$nomeCup]/cbc:ID">
					<xsl:call-template name="dato-linea">
						<xsl:with-param name="dato">
							<xsl:value-of select="cac:DocumentReference[./cbc:DocumentType=$nomeCup]/cbc:ID"/>
						</xsl:with-param>
						<xsl:with-param name="label">CUP</xsl:with-param>
					</xsl:call-template>
				</xsl:if>
				<xsl:if test="cac:DocumentReference[./cbc:DocumentType=$nomeCommessaConvenzione]/cbc:ID">
					<xsl:call-template name="dato-linea">
						<xsl:with-param name="dato">
							<xsl:value-of
                                    select="cac:DocumentReference[./cbc:DocumentType=$nomeCommessaConvenzione]/cbc:ID"/>
						</xsl:with-param>
						<xsl:with-param name="label">Commessa Convenzione</xsl:with-param>
					</xsl:call-template>
				</xsl:if>
			</div>
		</xsl:if>
	</xsl:template>
	<xsl:template name="dato-linea">
		<xsl:param name="dato"/>
		<xsl:param name="label"/>
		<xsl:if test="$dato">
			<span class="margin-right">
				<span class="bold margin">
					<xsl:value-of select="$label"/>:
				</span>
				<xsl:value-of select="$dato"/>
			</span>
		</xsl:if>
	</xsl:template>

	<xsl:template name="dati-collegati-linea">
		<xsl:call-template name="dato-collegato-linea">
			<xsl:with-param name="titolo">Contratto</xsl:with-param>
			<xsl:with-param name="nomeCig">CIG_CONTRATTO</xsl:with-param>
			<xsl:with-param name="nomeCup">CUP_CONTRATTO</xsl:with-param>
			<xsl:with-param name="nomeCommessaConvenzione">CommessaConvenzione_CONTRATTO</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="dato-collegato-linea">
			<xsl:with-param name="titolo">Convenzione</xsl:with-param>
			<xsl:with-param name="nomeCig">CIG_CONVENZIONE</xsl:with-param>
			<xsl:with-param name="nomeCup">CUP_CONVENZIONE</xsl:with-param>
			<xsl:with-param name="nomeCommessaConvenzione">CommessaConvenzione_CONVENZIONE</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="dato-collegato-linea">
			<xsl:with-param name="titolo">Ricezione</xsl:with-param>
			<xsl:with-param name="nomeCig">CIG_RICEZIONE</xsl:with-param>
			<xsl:with-param name="nomeCup">CUP_RICEZIONE</xsl:with-param>
			<xsl:with-param name="nomeCommessaConvenzione">CommessaConvenzione_RICEZIONE</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="dato-collegato-linea">
			<xsl:with-param name="titolo">Fatture Collegate</xsl:with-param>
			<xsl:with-param name="nomeCig">CIG_FATTURE_COLLEGATE</xsl:with-param>
			<xsl:with-param name="nomeCup">CUP_FATTURE_COLLEGATE</xsl:with-param>
			<xsl:with-param name="nomeCommessaConvenzione">CommessaConvenzione_FATTURE_COLLEGATE</xsl:with-param>
		</xsl:call-template>
	</xsl:template>

</xsl:stylesheet>