No announcement yet.

How to Sepa Bank

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to Sepa Bank


    it's a job, but you can adapt get sepa.xml for bank. (work on belgium with 2 different bank so i imagine with other!? )
    there are 2 think important : (sorry my english explain so )
    1) sepa is grouped => accounting see only total amount
    2) sepa is not grouped => accounting see all different amount for all different acount

    in the past i have used : \Sepa\CreditTransfer (github)
    now i use : \Digitick\Sepa. (github)

    here my sample : not grouped amount, so each transaction is individual in one xml

    PHP Code:

    namespace Espo\Custom\Jobs;


    use \
    use \
    use \
    Digitick\Sepa\TransferFile\Factory\TransferFileFacadeFactory as TransferFileFacadeFactory;
    use \
    Digitick\Sepa\PaymentInformation as PaymentInformation;
    use \
    Digitick\Sepa\GroupHeader as GroupHeader;

    ConventionJobs implements Job

        public function 
    __construct(EntityManager $entityManagerLog $logServiceFactory $serviceFactory)
    $this->em $entityManager;
    $this->log $log;
    $this->serviceFactory $serviceFactory;

        private function 
    createSEPA($conventionId) : void

    $convention $this->em->getEntity('Convention'$conventionId);

    $fileId "data/upload/" .$convention->get('file')->id;
    $integration $this->em->getEntity('Integration''XXXXX');
    $transferList $this->em->getRepository('Transfer')->where([
    'AND' => [
    'status' => 'New',
    'amount>' => 0,
    'conventionId' => $conventionId

    $header = new GroupHeaderdate('Y-m-d-H-i-s'), 'XXX-' .$conventionId);
    $customerCredit TransferFileFacadeFactory::createCustomerCredit($convention->id'XXXXX''pain.001.001.03');

    $executionDate $convention->get('executionDate');

    $nbPayment 1;
    $i 1;
    $total 0.0;

    $transferList as $transfer){
                if (
    $transfer->get('status') == 'Closed') continue;

    $amount floatval(number_format($transfer->get('amount') ,2));
    $ibanNumber preg_replace'/[\W]/'''$transfer->get('ibanNumber'));
    $bic $transfer->get('bic');
    $name $transfer->get('name');

    $total += $amount;

    $customerCredit->addPaymentInfo$transfer->id .'-' .$i, [
    'id'                      => $transfer->id .'-' .$i,
    'debtorName'              => $integration->get('entreprise'),
    'debtorAccountIBAN'       => $integration->get('ibanNumber'),
    'debtorAgentBIC'          => $integration->get('bic'),
    'batchBooking'            => false,
    'dueDate'                 => new \DateTime$executionDate )

    $customerCredit->addTransfer($transfer->id .'-' .$i, [
    'amount'                  => $amount 100,
    'creditorIban'            => $ibanNumber,
    'creditorBic'             => $bic,
    'creditorName'            => $name,
    'remittanceInformation'   => 'XXX ' .$convention->get('name')

    'status' => 'Closed',
    'executionDate' => $executionDate,
    'xmlNumber' => $convention->get('name') .'-' .$i,


    $xml $customerCredit->asXML();

    $attachmentId $this->saveAttachment($xml,  'Sepa.xml'$conventionId'Convention' 'bank');
    $convention->set(['bankId' => $attachmentId]);


    Last edited by item; 11-23-2022, 05:54 PM.

  • #2
    Hello Item

    Thank You very much for sharing your working Model. I am novice in this field and like to ask you some base questions.
    1. What is the source for this script. Is this some custom Entity in Espocrm.
    2- What are steeps to follow up to get this script to work

    Can you pleas give some additional explanations what are fundation for this script (entities, job...)
    In my case I have two lines of data in EspoCRM (one for Receiver and other for Sender) table and I must transform it into sepa UPn payment Order - xml file and save it in custom folder. I do understand this script does work like I wish. I am also EU area so this script should be fine for me to



    • #3
      my english is poor so i will try to explain ours situation :
      we need pay ours "nurses" (+-200) each month... so i have create a custom entity "Convention", each month = one Convention.
      all Payroll of the month is related to one Convention of the month. (of course)
      after that, in Convention i have a enum field and a sepa as file type..
      when user set enum field to ready in Convention Entity, job search all related Payroll to the convention .. and create sepa.xml and put in sepa field in convention.
      after that, user can download the sepa.xml (and we have a backup in Convention) and import to bank.

      you need to install \Digitick\Sepa library from github, see Emillod how to Video in this forum, he have make a video how make custom extention vendor library
      you have sample there

      PHP Code:

      use \Digitick\Sepa\TransferFile\Factory\TransferFileFacadeFactory as TransferFileFacadeFactory;
      use \
      Digitick\Sepa\PaymentInformation as PaymentInformation;
      use \
      Digitick\Sepa\GroupHeader as GroupHeader;

      $header = new GroupHeaderdate('Y-m-d-H-i-s'), 'JAKOV-' .$conventionId);
      $customerCredit TransferFileFacadeFactory::createCustomerCredit($convention->id'JAKOB''pain.001.001.03');
      ​​$i 1;
      $customerCredit->addPaymentInfo$transfer->id .'-' .$i, [
      'id'                      => $transfer->id .'-' .$i,
      'debtorName'              => 'JAKOV',
      'debtorAccountIBAN'       => 'JAKOV IBAN',
      'debtorAgentBIC'          => 'JAKOV BIC',
      'batchBooking'            => false,
      'dueDate'                 => new \DateTime'PAYEMENT DATE' )

      $customerCredit->addTransfer('oneUniqueIdSoYouCanCheckInFuturIfProblem' .'-' .$i, [
      'amount'                  => $amount 100// need always 2 decimal in sepa, else bank not import
      'creditorIban'            => $ibanNumber,  // iban who you pay
      'creditorBic'             => $bic// bic who you pay, not required, can be blank i think,
      'creditorName'            => $name// the name of the personne
      'remittanceInformation'   => 'JAKOB ' .$convention->get('name')  // it's communication .. so as convention is the month for us, 202211 for sample
      So with this sample, you have one sepa file with one amount for one person

      2- What are steeps to follow up to get this script to work ?

      all depand how you will work, you can put this script in a controller, custom button.. and get sepa.. i have choose to have always the file in crm, so if in futur problem.. i see to my boss -> look the file in crm !
      Last edited by item; 11-23-2022, 10:06 PM. Reason: githib link


      • #4
        From reading this and understand our country banking system I try to give an alternative uses case below (example only).

        1) EspoCRM get add with the Employee Pay Hour and Work Hours.
        2) End of the Month, this code get use by CRON
        3) This code create a new file with all these data (Bank account details, how much is being paid and the employee name, etc)
        4) The Accountant (or the person doing payment), download this XML file.
        5) They log in their bank account (SEPA) and upload this XML file (the XML must follow the bank guidelines which I am assuming it does) to make mass payment.
        6) They check if they have enough money and click Submit. All Employee get paid.


        In our country we also support CSV so we don't need a complex XML file. And we don't have 200 employee to worry about either.


        • #5
          Thank you item for a new custom code. I can understand all your Logic. I think your case is also usable for my purposes. In my Case I will also create custom entity Payment order with all field, that are needet in xml code. If I understand your code gets this date out from Entity "Convention". When user/workflow fill populate specific Status Enum Field, code for xml file generation is triggered an xml is saved in specific Folder. Then this file will be manualy imported to the Bank or bank Client automatisation will do it automaticali (this is payable service in our Country). I understand espocrm in his country is workflow a bit different. In our Countri (SI). There is push in all areas to go digital via .xml (eInvoice.xml and sepa payment orders.xml are the mainstream in this Field


          • espcrm
            espcrm commented
            Editing a comment
            Maybe you can adopt to your system and share your version.

            Also, you pinged wrong person. espocrm is the official (dead) account. I'm just another user like you.