Project60 / org.project60.sepa

SEPA direct debit integration with civicrm
19 stars 46 forks source link

PAIN format "pain.008.001.02 without BIC and CdtrSchmId:Nm" doesn't work for Switzerland #639

Closed Detsieber closed 1 year ago

Detsieber commented 1 year ago

SEPA is supporting direct debits from debitor accounts in Switzerland. However, in these cases, other than in any other country, the postal address of the debitor has to be added.

This was already implemented in "pain.008.003.02 (EBICS-3.0 RCUR/CH)".

Therefore, in "pain.008.001.02 without BIC and CdtrSchmId:Nm", directly after

<Nm>{$contribution.display_name}</Nm>

the following code has to be inserted

{if $contribution.ctry eq 'CH'}
          <PstlAdr>
            <Ctry>{$contribution.ctry}</Ctry>
            <AdrLine>{$contribution.street_address}</AdrLine>
            <AdrLine>{$contribution.postal_code} {$contribution.city}</AdrLine>
          </PstlAdr>
{/if}

After our ongoing test is completed, I will add a pull request.

bjendres commented 1 year ago

This structure is already implemented in the pain.008.003.02 with Address (EBICS-3.0) and pain.008.001.02.CH.03 (CH-DD) (in addition pain.008.003.02 (EBICS-3.0 RCUR/CH)) formats. Have you tried those?

bjendres commented 1 year ago

But I understand that you want a mixed mode format, which we have tried to avoid. Our approach was mostly to have different creditors for Swiss people, and/or generally people from abroad.

Detsieber commented 1 year ago

In all use cases I can imagine, we won't have different contribution pages for people from Switzerland. Therefore, all SEPA mandates have to be processed by the same sepa creditor, using the same PAIN format.

I don't see any reason why we shouldn't do so?

bjendres commented 1 year ago

I don't see any reason why we shouldn't do so?

One of the reasons we wanted to separate, is that you then have to force all donors to give an address, even though it's just needed for the swiss donors.

bjendres commented 1 year ago

...and I'm not sure that your mixed file would be valid XML (according to the XSD), but I might be wrong....

Detsieber commented 1 year ago

The address will be generated only, if $contribution.ctry eq 'CH'.

Anyhow, I just patched the affected production system, and we will see...

jensschuppe commented 1 year ago

@Detsieber Could you please file your patch as a PR for a new separate format.

Detsieber commented 1 year ago

@jensschuppe I still don't think it would be necessary to create a new format, for the following reasons:

  1. The current format is disfunctional, since it is not possible to process sepa mandates from switzerland without adding the contributor's address (which is required for Switzerland). The proposed change will only add the contributor's address if the contributor is from Switzerland.
  2. We have tested my PR in a pretty large production environment for2,5 months, everything works well.
  3. Looking deeper into my PR, it would have been better to use an if-statement based on the first two letters of the IBAN instead of contribution.ctry. I can change the PR accordingly.
  4. Most important: Adding a new Format in sepa/templates/Sepa/Formats/ is not enough - there also has to be inserted the according option_value, and maybe other things. Could you please give me a hint which parts of the code I will have to update for adding a new separate format?
jensschuppe commented 1 year ago

Re 4. You may refer to 1e79bdcd39882102aade25edff7a3c3b0e6dd33f for hints on what needs to be done for adding new formats, in short:

I'm closing this question issue as fixed, please continue commenting in your PR (#654), if necessary.