<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
  <CstmrCdtTrfInitn>
    <GrpHdr>
      <MsgId><%= @virement_remise.token.upcase %>MSG</MsgId>
      <CreDtTm><%= @virement_remise.created_at.utc.iso8601 %></CreDtTm>
      <NbOfTxs><%= @virement_remise.virements.count %></NbOfTxs>
      <CtrlSum><%= @virement_remise.amount %></CtrlSum>
      <InitgPty>
        <Nm>Olwen Capital SAS</Nm>
      </InitgPty>
    </GrpHdr>
    <PmtInf>
      <PmtInfId><%= @virement_remise.token.upcase %>PMT</PmtInfId>
      <PmtMtd>TRF</PmtMtd>
      <BtchBookg>false</BtchBookg>
      <NbOfTxs><%= @virement_remise.virements.count %></NbOfTxs>
      <CtrlSum><%= '%.2f' % @virement_remise.amount %></CtrlSum>
      <PmtTpInf>
        <SvcLvl>
          <Cd>SEPA</Cd>
        </SvcLvl>
      </PmtTpInf>
      <ReqdExctnDt><%= @virement_remise.created_at.strftime("%Y-%m-%d") %></ReqdExctnDt>
      <Dbtr>
        <Nm>OLWEN CAPTIAL SAS</Nm>
      </Dbtr>
      <DbtrAcct>
        <Id>
          <IBAN>FR7617806004840411148064353</IBAN>
        </Id>
      </DbtrAcct>
      <DbtrAgt>
        <FinInstnId>
          <BIC>AGRIFRPP878</BIC>
        </FinInstnId>
      </DbtrAgt>
      <ChrgBr>SLEV</ChrgBr>
       <% @virement_remise.virements.each do |virement| %>
      <CdtTrfTxInf>
              <PmtId>
                <EndToEndId><%= virement.token.upcase %> COMMISSION SIDEPLACE</EndToEndId>
              </PmtId>
              <Amt>
                <InstdAmt Ccy="EUR"><%= '%.2f' % virement.amount_ttc %></InstdAmt>
              </Amt>
              
              <Cdtr>
                <Nm><%= virement.name_for_edi.upcase %></Nm>
              </Cdtr>
              <CdtrAcct>
                <Id>
                  <IBAN><%= virement.customer_rib.iban.upcase %></IBAN>
                </Id>
              </CdtrAcct>
              <RmtInf>
                <Ustrd><%= virement.token.upcase %> COMMISSION SIDEPLACE</Ustrd>
              </RmtInf>
      </CdtTrfTxInf>
      <% end %>
      

    </PmtInf>
  </CstmrCdtTrfInitn>
</Document>