{#
!!!!!!!!!!!!!!!! Important note : Tag order is important
#}<?xml version="1.0" encoding="utf-8"?>
<rsm:CrossDomainAcknowledgementAndResponse
	xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100"
	xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
	xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
	xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossDomainAcknowledgementAndResponse:100"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<rsm:ExchangedDocumentContext>
		<ram:BusinessProcessSpecifiedDocumentContextParameter>
			<ram:ID>REGULATED</ram:ID>
		</ram:BusinessProcessSpecifiedDocumentContextParameter>
		<ram:GuidelineSpecifiedDocumentContextParameter>
			<ram:ID>urn.cpro.gouv.fr:1p0:CDV:invoice</ram:ID>
		</ram:GuidelineSpecifiedDocumentContextParameter>
	</rsm:ExchangedDocumentContext>
	<rsm:ExchangedDocument>
		<ram:ID>{{ FAC_ENT.FACT_FOU }}</ram:ID>
		<ram:Name>{{ FAC_ENT.FACT_FOU }}</ram:Name>

		{# <ram:Name>{{ FAC_ENT.FACT_FOU }} status {{ status.label }}</ram:Name>#}
		<ram:IssueDateTime> {# MDT-8 (Date-heure de création du CDV) #}
			<udt:DateTimeString format="204">
				{{- 'now' | date('YmdHis') -}}
			</udt:DateTimeString>
		</ram:IssueDateTime>
		<ram:SenderTradeParty>
			<ram:GlobalID schemeID="0238{# Matricule PPF #}">
				{{- partn.PPFId -}}
			</ram:GlobalID>
			<ram:Name>{{ partn.label }}</ram:Name>
			<ram:RoleCode>WK{# Plateform agréé #}</ram:RoleCode>
		</ram:SenderTradeParty>
		<ram:IssuerTradeParty>
			<ram:GlobalID schemeID="0002{# Siren #}">{{ sender.siren }}</ram:GlobalID>
			<ram:Name>{{ sender.name }}</ram:Name>
			<ram:RoleCode>BY{# BUYER #}</ram:RoleCode>
			<ram:URIUniversalCommunication>
				<ram:URIID schemeID="{{ sender.codeRoutageScheme }}">
					{{- sender.codeRoutage -}}
				</ram:URIID>
			</ram:URIUniversalCommunication>
		</ram:IssuerTradeParty>
		<ram:RecipientTradeParty>
			<ram:GlobalID schemeID="0002{# Siren #}">{{ recipient.siren }}</ram:GlobalID>
			<ram:Name>{{ recipient.name }}</ram:Name>
			<ram:RoleCode>SE</ram:RoleCode>
			<ram:URIUniversalCommunication>
				<ram:URIID schemeID="{{ recipient.codeRoutageScheme }}">
					{{- recipient.codeRoutage -}}
				</ram:URIID>
			</ram:URIUniversalCommunication>
		</ram:RecipientTradeParty>
	</rsm:ExchangedDocument>
	<rsm:AcknowledgementDocument>
		<ram:MultipleReferencesIndicator>
			<udt:Indicator>false</udt:Indicator>
		</ram:MultipleReferencesIndicator>
		<ram:TypeCode>23{# Information - pour les statuts après transmission #}</ram:TypeCode> 
		<ram:IssueDateTime>
			<udt:DateTimeString format="204">{{ 'now' | date('YmdHis') }}</udt:DateTimeString>
		</ram:IssueDateTime>
		<ram:ReferenceReferencedDocument>
			<ram:IssuerAssignedID>{{ FAC_ENT.FACT_FOU }}</ram:IssuerAssignedID>
			<ram:TypeCode>{{ flow.InvoiceTypeCode }}</ram:TypeCode>
			<ram:ReceiptDateTime>
				<udt:DateTimeString format="204">{{ FAC_ENT.DATE_FAFO }}000000</udt:DateTimeString>
			</ram:ReceiptDateTime>
			<ram:FormattedIssueDateTime>
				<qdt:DateTimeString format="102">{{ FAC_ENT.DATE_FAFO }}</qdt:DateTimeString>
			</ram:FormattedIssueDateTime>
			<ram:ProcessConditionCode>{{ status.code }}</ram:ProcessConditionCode>
			<ram:ProcessCondition>{{ status.label }}</ram:ProcessCondition>
			<ram:IssuerTradeParty>
				<ram:GlobalID schemeID="0002">{{ recipient.siren }}</ram:GlobalID>
				<ram:RoleCode>SE</ram:RoleCode>
			</ram:IssuerTradeParty>
			{% if status.reason %} {# En cas d'irrecevabilité/rejet/refus #}
			<ram:SpecifiedDocumentStatus>
				<ram:ReasonCode>{{ status.reason.value }}</ram:ReasonCode>
				<ram:Reason>{{ status.reason | enumToLabel }}</ram:Reason>
				<ram:SequenceNumeric>1</ram:SequenceNumeric>  {# MDT-124-2 (Numéro incremental) : 1 #}
				{% if status.montant %}{# Case : status encaisé (status.code = 212) #}
				<ram:SpecifiedDocumentCharacteristic>
					<ram:Value currencyID="{{ status.devise }}">
						{{- status.montant | number_format(2, '.', '') -}}
					</ram:Value>
				</ram:SpecifiedDocumentCharacteristic>
				{% endif %}
			</ram:SpecifiedDocumentStatus>
			{% endif %}
		</ram:ReferenceReferencedDocument>
	</rsm:AcknowledgementDocument>
</rsm:CrossDomainAcknowledgementAndResponse>