<?xml version='1.0' encoding='UTF-8' ?>
<!-- Stand: 01.12.2020 - 15:08 Uhr -->
<rsm:CrossIndustryInvoice xmlns:a="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:10" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
<rsm:ExchangedDocumentContext>
<ram:GuidelineSpecifiedDocumentContextParameter>
<ram:ID>urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0</ram:ID>
</ram:GuidelineSpecifiedDocumentContextParameter>
</rsm:ExchangedDocumentContext>
<rsm:ExchangedDocument>
<ram:ID><![CDATA[{{ Report.InvoiceNumber }}]]></ram:ID>
<!-- Rechnungsnummer -->
<ram:TypeCode>326</ram:TypeCode>
<ram:IssueDateTime>
<udt:DateTimeString format="102">{{ Report.CreationDate | Datum: 'yyyyMMdd' }}</udt:DateTimeString>
<!-- Rechnungsdatum -->
</ram:IssueDateTime>
</rsm:ExchangedDocument>
{% capture query %}
SELECT
ISNULL(Delivery.dDatum, ISNULL(payment.dDatum, Invoice.dErstellt)) AS dDatum
FROM dbo.tRechnung AS Invoice
OUTER APPLY (
SELECT MAX(dErstellt) AS dDatum from tLieferschein WHERE tLieferschein.kBestellung = Invoice.tBestellung_kBestellung
) AS Delivery
OUTER APPLY (
SELECT MAX(dDatum) AS dDatum from tZahlung WHERE tZahlung.kBestellung = Invoice.tBestellung_kBestellung
) AS Payment
WHERE Invoice.kRechnung = {{ Report.InternalId | SqlEscape }}
{% endcapture -%}\
{% assign result = query | DirectQueryScalar %}\
{% assign serviceDate = result | Datum: 'yyyyMMdd' %}\
<rsm:SupplyChainTradeTransaction>
<!-- *********************************************************************************************** -->
<!-- Rechnungspositionen -->
<!-- *********************************************************************************************** -->
{% for position in Report.InvoicePosition -%}
{% if position.NetPricePerUnit >= 0 -%}
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>{% if position.Sorting == null %}{{ position.InternalId }}{% else %}{{ position.Sorting }}{% endif -%}</ram:LineID>
<!-- lfd. Nummer -->
</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:SellerAssignedID><![CDATA[{{ position.SKU }}]]></ram:SellerAssignedID>
<!-- Artikelnummer -->
<ram:Name><![CDATA[{{ position.Name | PrepareFilename }}]]></ram:Name>
<!-- Artikelbezeichnung -->
<ram:Description><![CDATA[{{ InvoicePosition.Note | PrepareFilename }}]]></ram:Description>
<!-- Artikelbeschreibung -->
</ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount>{{ position.NetPricePerUnit | Nummer : '0.0000', 'en-US' }}</ram:ChargeAmount>
<!-- Netto-Einzelpreis der Position -->
<ram:BasisQuantity unitCode="C62">{{ position.Quantity | Nummer : '0.0000', 'en-US' }}</ram:BasisQuantity>
<!-- Basis-Menge -->
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="C62">{{ position.Quantity | Nummer : '0.0000', 'en-US' }}</ram:BilledQuantity>
<!-- Menge berechnet / Mengenbezeichnung -->
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
<!-- Abrechnung auf Positionsebene -->
<ram:TypeCode>VAT</ram:TypeCode>
{% if Report.ExemptFromVAT == 'ExemptFromVATnotEU' -%}
<ram:ExemptionReason>Mehrwertsteuerbefreiung außerhalb der EU</ram:ExemptionReason> <!-- Grund der Steuerbefreiung (auf Positionsebene -->
<ram:CategoryCode>G</ram:CategoryCode> <!-- Steuerkategorie -->
<ram:RateApplicablePercent>0</ram:RateApplicablePercent> <!-- Steuersatz -->
{% endif -%}
{% if Report.ExemptFromVAT == 'IGL' -%}
<ram:ExemptionReason>Mehrwertsteuerbefreiung für die innergemeinschaftliche Lieferung von Waren und Dienstleistungen in der EU</ram:ExemptionReason> <!-- Grund der Steuerbefreiung (auf Positionsebene -->
<ram:CategoryCode>K</ram:CategoryCode> <!-- Steuerkategorie -->
<ram:RateApplicablePercent>0</ram:RateApplicablePercent> <!-- Steuersatz -->
{% endif -%}
{% if Report.ExemptFromVAT == 'ReverseCharge' -%}
<ram:ExemptionReason>Mehrwertsteuerbefreiung</ram:ExemptionReason> <!-- Grund der Steuerbefreiung (auf Positionsebene -->
<ram:CategoryCode>AE</ram:CategoryCode> <!-- Steuerkategorie -->
<ram:RateApplicablePercent>0</ram:RateApplicablePercent> <!-- Steuersatz -->
{% endif -%}
{% if Report.ExemptFromVAT == '' -%}
<ram:CategoryCode>S</ram:CategoryCode> <!-- Steuerkategorie -->
<ram:RateApplicablePercent>{{ position.VATRate | Nummer : '0.00', 'en-US' }}</ram:RateApplicablePercent> <!-- Steuersatz -->
{% endif -%}
</ram:ApplicableTradeTax> <!-- Abrechnung auf Positionsebene -->
{% if Report.ExemptFromVAT == 'IGL' or Report.ExemptFromVAT == 'ReverseCharge' -%}
<ram:BillingSpecifiedPeriod>
<ram:StartDateTime>
<udt:DateTimeString format="102">{{ serviceDate }}</udt:DateTimeString>
</ram:StartDateTime>
<ram:EndDateTime>
<udt:DateTimeString format="102">{{ serviceDate }}</udt:DateTimeString>
</ram:EndDateTime>
</ram:BillingSpecifiedPeriod>
{% endif -%}
<ram:SpecifiedTradeSettlementLineMonetarySummation>
<!-- Gesamtbetrag netto (auf Positionsebene) -->
{% if Report.ExemptFromVAT == 'ExemptFromVATnotEU' or Report.ExemptFromVAT == 'IGL' or Report.ExemptFromVAT == 'ReverseCharge' -%}
<ram:LineTotalAmount>{{ position.TotalGrossPrice | Nummer : '0.0000', 'en-US' }}</ram:LineTotalAmount>
{% endif -%}
{% if Report.ExemptFromVAT == '' -%}
<ram:LineTotalAmount>{{ position.TotalNetPrice | Nummer : '0.0000', 'en-US' }}</ram:LineTotalAmount>
{% endif -%}
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<!-- ENDE Rechnungsposition -->
{% endif -%}
{% endfor -%}
<!-- *********************************************************************************************** -->
<!-- *********************************************************************************************** -->
<!-- VERTRAGSANGABEN -->
<!-- *********************************************************************************************** -->
<!-- *********************************************************************************************** -->
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>{% capture query -%}
SELECT TOP(1) BuyerReference.cValue
FROM dbo.trechnung
JOIN
(
SELECT tBestellungAttribute.kBestellung,
CASE WHEN tBestellungAttribute.cName = 'Leitweg-ID' THEN 2 ELSE 1 END AS nPriority,
tBestellungAttribute.cValue
FROM dbo.tBestellungAttribute
WHERE tBestellungAttribute.cName IN ('Leitweg-ID', 'BuyerReference')
AND LEN(ISNULL(tBestellungAttribute.cValue, '')) > 0
UNION ALL
SELECT tBestellung.kBestellung,
CASE WHEN tAttributSprache.cName = 'Leitweg-ID' THEN 4 ELSE 3 END AS nPriority,
tKundeEigenesFeld.cWertVarchar AS cValue
FROM Kunde.tKundeEigenesFeld
JOIN dbo.tBestellung ON tKundeEigenesFeld.kKunde = tBestellung.tKunde_kKunde
JOIN dbo.tAttributSprache ON tKundeEigenesFeld.kAttribut = tAttributSprache.kAttribut
WHERE tAttributSprache.cName IN ('Leitweg-ID', 'BuyerReference')
AND LEN(ISNULL(tKundeEigenesFeld.cWertVarchar, '')) > 0
UNION ALL
SELECT tBestellung.kBestellung,
5 AS nPriority,
tkunde.cKundenNr AS cValue
FROM dbo.tkunde
JOIN dbo.tBestellung ON tkunde.kKunde = tBestellung.tKunde_kKunde
) AS BuyerReference ON trechnung.tBestellung_kBestellung = BuyerReference.kBestellung
WHERE trechnung.kRechnung = {{ Report.InternalId | SqlEscape }}
ORDER BY BuyerReference.nPriority ASC
{% endcapture -%}\
{% assign result = query | DirectQueryScalar -%}\
{{ result }}</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name><![CDATA[{{ Report.Company.CompanyName | PrepareFilename }}]]></ram:Name>
<ram:SpecifiedLegalOrganization>
<ram:ID schemeID="0088">0</ram:ID>
</ram:SpecifiedLegalOrganization>
<ram:DefinedTradeContact>
{%- if Report.Company.ManagingDirector != "" -%}
<ram:PersonName>{{ Report.Company.ManagingDirector }}</ram:PersonName>
{% else -%}
<ram:PersonName>{{ Report.Company.CompanyName }}</ram:PersonName>
{% endif -%}
<ram:TelephoneUniversalCommunication>
<ram:CompleteNumber>{{ Report.Company.Phone }}</ram:CompleteNumber>
</ram:TelephoneUniversalCommunication>
<ram:EmailURIUniversalCommunication>
<ram:URIID>{{ Report.Company.Email }}</ram:URIID>
</ram:EmailURIUniversalCommunication>
</ram:DefinedTradeContact>
<ram:PostalTradeAddress>
<ram:PostcodeCode><![CDATA[{{ Report.Company.PostalCode }}]]></ram:PostcodeCode>
<ram:LineOne><![CDATA[{{ Report.Company.Address | PrepareFilename }}]]></ram:LineOne>
<ram:CityName><![CDATA[{{ Report.Company.City | PrepareFilename }}]]></ram:CityName>
<ram:CountryID><![CDATA[{{ Report.Company.CountryISO }}]]></ram:CountryID>
</ram:PostalTradeAddress>
{%- if Report.ValueAddedTaxId != "" -%}
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">{{ Report.ValueAddedTaxId }}</ram:ID>
</ram:SpecifiedTaxRegistration>
{% else -%}
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="FC">{{ Report.Company.FederalTaxId | Replace: "/", "" | Replace: " ", "" | Replace: "-", "" | Replace: "|", "" | Replace: "\\", "" }}</ram:ID>
</ram:SpecifiedTaxRegistration>
{% endif -%}
</ram:SellerTradeParty>
<!-- *********************************************************************************************** -->
<!-- DATEN ZUM RECHNUNGSEMPFÄNGER (bei Ausgangsrechnungen) -->
<!-- *********************************************************************************************** -->
<ram:BuyerTradeParty>
<ram:ID><![CDATA[{{ Report.Customer.CustomerNumber }}]]></ram:ID> <!-- Kundennummer -->
<ram:Name><![CDATA[{% if Report.InvoiceBillToAddress.Company != null and Report.InvoiceBillToAddress.Company != empty -%}
{{ Report.InvoiceBillToAddress.Company | PrepareFilename }} \
{% if Report.InvoiceBillToAddress.CompanySupplement != null and Report.InvoiceBillToAddress.CompanySupplement != empty -%}
{{ Report.InvoiceBillToAddress.CompanySupplement | PrepareFilename }}\
{% endif -%}
{% else -%}
{% if Report.InvoiceBillToAddress.Title != null and Report.InvoiceBillToAddress.Title != empty -%}
{{ Report.InvoiceBillToAddress.Title | PrepareFilename }} \
{% endif -%}
{% if Report.InvoiceBillToAddress.FirstName != null and Report.InvoiceBillToAddress.FirstName != empty -%}
{{ Report.InvoiceBillToAddress.FirstName | PrepareFilename }} \
{% endif -%}
{% if Report.InvoiceBillToAddress.LastName != null and Report.InvoiceBillToAddress.LastName != empty -%}
{{ Report.InvoiceBillToAddress.LastName | PrepareFilename }}\
{% endif -%}
{% endif -%}]]></ram:Name><!-- Name des Kunden -->
<ram:DefinedTradeContact>
<ram:EmailURIUniversalCommunication>
<ram:URIID><![CDATA[{{ Report.InvoiceBillToAddress.EmailAddress | PrepareFilename }}]]></ram:URIID>
<!-- E-Mail des Kunden -->
</ram:EmailURIUniversalCommunication>
</ram:DefinedTradeContact>
<ram:PostalTradeAddress>
<ram:PostcodeCode>{{ Report.InvoiceBillToAddress.PostalCode }}</ram:PostcodeCode>
<!-- PLZ des Kunden -->
<ram:LineOne><![CDATA[{{ Report.InvoiceBillToAddress.Address | PrepareFilename }}]]></ram:LineOne>
<!-- Strasse des Kunden -->
<ram:LineTwo><![CDATA[{{ Report.InvoiceBillToAddress.AddressSupplement | PrepareFilename }}]]></ram:LineTwo>
<!-- Postfach des Kunden -->
<ram:CityName><![CDATA[{{ Report.InvoiceBillToAddress.City | PrepareFilename}}]]></ram:CityName>
<!-- Ort des Kunden -->
<ram:CountryID>{{ Report.InvoiceBillToAddress.CountryISO }}</ram:CountryID>
<!-- Land des Kunden -->
</ram:PostalTradeAddress>
{% if Report.InvoiceBillToAddress != null and Report.InvoiceBillToAddress.ValueAddedTaxId != empty -%}
<ram:SpecifiedTaxRegistration>
{%- capture query %}
SELECT ISNUMERIC ('{{ Report.InvoiceBillToAddress.ValueAddedTaxId | Replace: "/", "" | Replace: " ", "" | Replace: "-", "" | Replace: "|", "" | Replace: "\\", "" | SqlEscape }}')
{%- endcapture -%}\
{%- assign result = query | DirectQueryScalar %}
{%- if result == 0 -%}
<ram:ID schemeID="VA">{{ Report.InvoiceBillToAddress.ValueAddedTaxId | Replace: "/", "" | Replace: " ", "" | Replace: "-", "" | Replace: "|", "" | Replace: "\\", "" }}</ram:ID>
{%- else -%}
<ram:ID schemeID="FC">{{ Report.InvoiceBillToAddress.ValueAddedTaxId | Replace: "/", "" | Replace: " ", "" | Replace: "-", "" | Replace: "|", "" | Replace: "\\", "" }}</ram:ID>
{%- endif -%}
<!-- Steuernummer / USt-ID des Kunden -->
</ram:SpecifiedTaxRegistration>
{% endif -%}
</ram:BuyerTradeParty>
<ram:BuyerOrderReferencedDocument>
<ram:IssuerAssignedID>
{% capture query -%}
SELECT tBestellung.cBestellNr AS Auftragsnummer
FROM dbo.trechnung
JOIN dbo.tBestellung ON trechnung.tBestellung_kBestellung = tBestellung.kBestellung
WHERE trechnung.kRechnung = {{ Report.InternalId | SqlEscape }}
{% endcapture -%}\
{% assign result = query | DirectQueryScalar -%}\
<![CDATA[{{ result }}]]>
</ram:IssuerAssignedID>
</ram:BuyerOrderReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
<!-- *********************************************************************************************** -->
<!-- LIEFERANGABEN -->
<!-- *********************************************************************************************** -->
<ram:ApplicableHeaderTradeDelivery>
<ram:ShipToTradeParty>
<!-- abweichender Warenempfänger-->
<ram:Name><![CDATA[{% if Report.InvoiceShipToAddress.Company != null and Report.InvoiceShipToAddress.Company != empty -%}
{{ Report.InvoiceShipToAddress.Company | PrepareFilename }} \
{% if Report.InvoiceShipToAddress.CompanySupplement != null and Report.InvoiceShipToAddress.CompanySupplement != empty -%}
{{ Report.InvoiceShipToAddress.CompanySupplement | PrepareFilename }}\
{% endif -%}
{% else -%}
{% if Report.InvoiceShipToAddress.Title != null and Report.InvoiceShipToAddress.Title != empty -%}
{{ Report.InvoiceShipToAddress.Title | PrepareFilename }} \
{% endif -%}
{% if Report.InvoiceShipToAddress.FirstName != null and Report.InvoiceShipToAddress.FirstName != empty -%}
{{ Report.InvoiceShipToAddress.FirstName | PrepareFilename }} \
{% endif -%}
{% if Report.InvoiceShipToAddress.LastName != null and Report.InvoiceShipToAddress.LastName != empty -%}
{{ Report.InvoiceShipToAddress.LastName | PrepareFilename }}\
{% endif -%}
{% endif -%}]]></ram:Name>
<ram:PostalTradeAddress>
<ram:PostcodeCode>{{ Report.InvoiceShipToAddress.PostalCode }}</ram:PostcodeCode>
<ram:LineOne><![CDATA[{{ Report.InvoiceShipToAddress.Address | PrepareFilename }}]]></ram:LineOne>
<ram:CityName><![CDATA[{{ Report.InvoiceShipToAddress.City | PrepareFilename }}]]></ram:CityName>
<ram:CountryID>{{ Report.InvoiceShipToAddress.CountryISO }}</ram:CountryID>
<!-- (abw.) Empfängerland -->
</ram:PostalTradeAddress>
</ram:ShipToTradeParty>
{% if Report.ExemptFromVAT != 'IGL' and Report.ExemptFromVAT != 'ReverseCharge' -%}
<ram:ActualDeliverySupplyChainEvent>
<ram:OccurrenceDateTime>
<udt:DateTimeString format="102">{{ serviceDate }}</udt:DateTimeString>
<!-- tatsächlicher Lieferungszeitpunkt (pro Rechnung) -->
</ram:OccurrenceDateTime>
</ram:ActualDeliverySupplyChainEvent>
{% endif -%}
</ram:ApplicableHeaderTradeDelivery>
<!-- *********************************************************************************************** -->
<!-- ZAHLUNGSANGABEN -->
<!-- *********************************************************************************************** -->
<ram:ApplicableHeaderTradeSettlement>
{% assign firstPayment = Report.InvoicePayments | First %}
<ram:PaymentReference><![CDATA[{{ firstPayment.ExternalTransactionId }}]]></ram:PaymentReference> <!-- Zahlungsreferenz -->
<ram:InvoiceCurrencyCode>{{ Report.CurrencyISO}}</ram:InvoiceCurrencyCode> <!-- Währung -->
<ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>57</ram:TypeCode>
<!-- Zahlungsart -->
<ram:Information><![CDATA[{{ InvoicePayments.Name }}]]></ram:Information>
<ram:PayeePartyCreditorFinancialAccount>
<ram:IBANID>{{ Company.IBAN }}</ram:IBANID>
<ram:AccountName>{{ Company.BankName }}</ram:AccountName>
<ram:ProprietaryID>{{ Company.IBAN }}</ram:ProprietaryID>
</ram:PayeePartyCreditorFinancialAccount>
</ram:SpecifiedTradeSettlementPaymentMeans>
<!-- *********************************************************************************************** -->
<!-- ANGABEN ZUR STEUER (1:N) -->
<!-- *********************************************************************************************** -->
{% assign VATSum = 0.0 %}\
{% for totals in Report.TotalsInvoice -%}
{% assign VATSum = VATSum | Plus: totals.VATSum %}\
<ram:ApplicableTradeTax>
{% if Report.ExemptFromVAT == 'ExemptFromVATnotEU' -%}
<ram:CalculatedAmount>0</ram:CalculatedAmount> <!-- Steuerbetrag -->
<ram:TypeCode>VAT</ram:TypeCode> <!-- Steuerart -->
<ram:ExemptionReason>Mehrwertsteuerbefreiung außerhalb der EU</ram:ExemptionReason> <!-- Grund der Steuerbefreiung (auf Positionsebene) -->
<ram:BasisAmount>{{ totals.GrossPriceTotal | Nummer : '0.00', 'en-US' }}</ram:BasisAmount> <!-- Steuerbasisbetrag -->
<ram:CategoryCode>G</ram:CategoryCode> <!-- Steuerkategorie -->
<ram:RateApplicablePercent>0</ram:RateApplicablePercent> <!-- Steuersatz -->
{% endif -%}
{% if Report.ExemptFromVAT == 'IGL' -%}
<ram:CalculatedAmount>0</ram:CalculatedAmount> <!-- Steuerbetrag -->
<ram:TypeCode>VAT</ram:TypeCode> <!-- Steuerart -->
<ram:ExemptionReason>Mehrwertsteuerbefreiung für die innergemeinschaftliche Lieferung von Waren und Dienstleistungen in der EU</ram:ExemptionReason> <!-- Grund der Steuerbefreiung (auf Positionsebene) -->
<ram:BasisAmount>{{ totals.GrossPriceTotal | Nummer : '0.00', 'en-US' }}</ram:BasisAmount> <!-- Steuerbasisbetrag -->
<ram:CategoryCode>K</ram:CategoryCode> <!-- Steuerkategorie -->
<ram:RateApplicablePercent>0</ram:RateApplicablePercent> <!-- Steuersatz -->
{% endif -%}
{% if Report.ExemptFromVAT == 'ReverseCharge' -%}
<ram:CalculatedAmount>0</ram:CalculatedAmount> <!-- Steuerbetrag -->
<ram:TypeCode>VAT</ram:TypeCode> <!-- Steuerart -->
<ram:ExemptionReason>Mehrwertsteuerbefreiung</ram:ExemptionReason> <!-- Grund der Steuerbefreiung (auf Positionsebene) -->
<ram:BasisAmount>{{ totals.GrossPriceTotal | Nummer : '0.00', 'en-US' }}</ram:BasisAmount> <!-- Steuerbasisbetrag -->
<ram:CategoryCode>AE</ram:CategoryCode> <!-- Steuerkategorie -->
<ram:RateApplicablePercent>0</ram:RateApplicablePercent> <!-- Steuersatz -->
{% endif -%}
{% if Report.ExemptFromVAT == '' -%}
<ram:CalculatedAmount>{{ totals.VATSum | Nummer: '0.00','en-US' }}</ram:CalculatedAmount> <!-- Steuerbetrag -->
<ram:TypeCode>VAT</ram:TypeCode> <!-- Steuerart -->
<ram:BasisAmount>{{ totals.NetPriceTotal | Nummer : '0.00', 'en-US' }}</ram:BasisAmount> <!-- Steuerbasisbetrag -->
<ram:CategoryCode>S</ram:CategoryCode> <!-- Steuerkategorie -->
<ram:RateApplicablePercent>{{ totals.VATRate | Nummer: '0.00','en-US' }}</ram:RateApplicablePercent> <!-- Steuersatz -->
{% endif -%}
</ram:ApplicableTradeTax>
{% if Report.ExemptFromVAT == 'IGL' -%}
<ram:BillingSpecifiedPeriod>
<ram:StartDateTime>
<udt:DateTimeString format="102">{{ serviceDate }}</udt:DateTimeString>
</ram:StartDateTime>
<ram:EndDateTime>
<udt:DateTimeString format="102">{{ serviceDate }}</udt:DateTimeString>
</ram:EndDateTime>
</ram:BillingSpecifiedPeriod>
{% endif -%}
{% endfor -%}
<!-- *********************************************************************************************** -->
<!-- GUTSCHEINE/RABATTE -->
<!-- *********************************************************************************************** -->
{% for position in Report.InvoicePosition -%}
{% if position.NetPricePerUnit < 0 -%}
{% assign NetPricePerUnit = position.NetPricePerUnit | Times: -1 %}
<ram:SpecifiedTradeAllowanceCharge>
<ram:ChargeIndicator>
<udt:Indicator>false</udt:Indicator>
</ram:ChargeIndicator>
<ram:ActualAmount>{{ NetPricePerUnit | Nummer : '0.00', 'en-US' }}</ram:ActualAmount>
<ram:ReasonCode>95</ram:ReasonCode>
<ram:Reason><![CDATA[{{ position.Name | PrepareFilename}}]]></ram:Reason>
<ram:CategoryTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>{{ position.VATRate | Nummer : '0.00', 'en-US' }}</ram:RateApplicablePercent>
</ram:CategoryTradeTax>
</ram:SpecifiedTradeAllowanceCharge>
{% endif -%}
{% endfor -%}
<!-- *********************************************************************************************** -->
<!-- ZAHLUNGSBEDINGUNGEN -->
<!-- *********************************************************************************************** -->
<ram:SpecifiedTradePaymentTerms>
<!-- 1. Zahlungsbedinung -->
<ram:DueDateDateTime>
<udt:DateTimeString format="102">{{ Report.InvoicePaymentInformation.TransferDueDate | Datum: 'yyyyMMdd' }}</udt:DateTimeString>
<!-- Netto-Fälligkeit -->
</ram:DueDateDateTime>
</ram:SpecifiedTradePaymentTerms>
<!-- *********************************************************************************************** -->
<!-- BELEGSUMMEN -->
<!-- *********************************************************************************************** -->
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
{% if Report.ExemptFromVAT == 'ExemptFromVATnotEU' or Report.ExemptFromVAT == 'IGL' or Report.ExemptFromVAT == 'ReverseCharge' -%}
<ram:LineTotalAmount>{{ Report.TotalGrossPrice | Nummer : '0.00', 'en-US' }}</ram:LineTotalAmount> <!-- Summe Rechnungspositionen -->
<ram:TaxBasisTotalAmount>{{ Report.TotalGrossPrice | Nummer : '0.00', 'en-US' }}</ram:TaxBasisTotalAmount> <!-- Rechnungssumme ohne USt -->
<ram:TaxTotalAmount currencyID="{{ Report.CurrencyISO }}">0</ram:TaxTotalAmount> <!-- Steuergesamtbetrag -->
<ram:GrandTotalAmount>{{ Report.TotalGrossPrice | Nummer : '0.00', 'en-US' }}</ram:GrandTotalAmount> <!-- Rechnungsbetrag brutto -->
{% endif -%}
{% if Report.ExemptFromVAT == '' -%}
<ram:LineTotalAmount>{{ Report.TotalNetPrice | Nummer : '0.00', 'en-US' }}</ram:LineTotalAmount> <!-- Summe Rechnungspositionen -->
<ram:TaxBasisTotalAmount>{{ Report.TotalNetPrice | Nummer : '0.00', 'en-US' }}</ram:TaxBasisTotalAmount> <!-- Rechnungssumme ohne USt -->
<ram:TaxTotalAmount currencyID="{{ Report.CurrencyISO }}">{{ VATSum | Nummer: '0.00','en-US' }}</ram:TaxTotalAmount> <!-- Steuergesamtbetrag -->
<ram:GrandTotalAmount>{{ Report.TotalNetPrice | Plus: VATSum | Nummer : '0.00', 'en-US' }}</ram:GrandTotalAmount> <!-- Rechnungsbetrag brutto -->
{% endif -%}
{% assign totalPayment = 0.0 -%}
{% for InvoicePayment in Report.InvoicePayments -%}
{% assign totalPayment = totalPayment | Plus: InvoicePayment.Value -%}
{% endfor -%}
<ram:TotalPrepaidAmount>{{ totalPayment | Nummer : '0.00', 'en-US' }}</ram:TotalPrepaidAmount> <!-- erhaltene / geleistete Anzahlungen -->
<ram:DuePayableAmount>{{ Report.TotalNetPrice | Plus: VATSum | Minus: totalPayment | Nummer : '0.00', 'en-US' }}</ram:DuePayableAmount> <!-- Zahlbetrag -->
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
<!-- *********************************************************************************************** -->
<!-- SONSTIGES -->
<!-- *********************************************************************************************** -->
<ram:ReceivableSpecifiedTradeAccountingAccount>
<ram:ID>{{ Report.Customer.AccountsReceivableNumber }}</ram:ID>
<!-- Debitorenkontonummer - 9 - stelliges Personenkonto -->
</ram:ReceivableSpecifiedTradeAccountingAccount>
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>