-
-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More details in reference when paying out with WISE #10630
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend separating the two information (e.g. with a -
character), otherwise it could mess up with collectives that have numbers in their names (e.g. "collective75" + Expense 42563 = "collective7542563").
For the rest, I'll let @kewitz give a proper review.
let reference = `${expense.collective.slug.toUpperCase().substring(0, 3)}${expense.id}`; // MAX 10 chars for the US | ||
switch (country) { | ||
case 'GBP': // max 18 chars | ||
reference = `${expense.collective.slug.toUpperCase().substring(0, 10)}${expense.id}`; | ||
break; | ||
case 'EUR': // max 35 chars | ||
reference = `${expense.collective.slug.substring(0, 25)}${expense.id}`; | ||
break; | ||
case 'USD': // max 10 chars | ||
reference = `${expense.collective.slug.toUpperCase().substring(0, 3)}${expense.id}`; | ||
break; | ||
case 'MXN': // max 100 chars | ||
reference = `${expense.collective.slug.substring(0, 100)}${expense.id}`; | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The substring should always be substring(0, maxLength - expense.id.toString().length)
. Looks like this was considered for some (GBP, EUR, USD) but not MXN
Xavier, I suggest addressing this in the frontend (PayExpenseModal), where we implemented the Wise reference validation and allow fiscal hosts to customize reference value. I would happily implement this. Could you give a bit more information on the core problem this addresses? Or why isn't the expense id enough? |
Fixes opencollective/opencollective#7765
I'd recommend fetching the requirements first and applying the provided regex to verify the validity of the reference.
See https://docs.wise.com/api-docs/api-reference/transfer#transfer-requirements
In case of validation error, it's ok to fall back to just the
expense.id
.