Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,11 @@ describe('VirtualIbanService', () => {
expect(yapealVibanProvider.reserveViban).not.toHaveBeenCalled();
});

it('getActiveForUserAndCurrency keeps the merge-base selection semantics without excluding Frick', async () => {
it('getActiveForUserAndCurrency only considers rows whose bank still receives', async () => {
// A customer can hold several active rows per currency - a retired Yapeal EUR IBAN next to a
// working Frick one. findOne has no ORDER BY, so without this filter the retired row can win,
// the caller sees "found, but the bank does not receive", and with no collection-account
// fallback left the request fails outright. That hit every holder of a retired Yapeal EUR IBAN.
jest.spyOn(virtualIbanRepo, 'findOne').mockResolvedValue(null);

await service.getActiveForUserAndCurrency(userData, 'CHF');
Expand All @@ -1386,6 +1390,7 @@ describe('VirtualIbanService', () => {
where: {
userData: { id: 7 },
currency: { name: 'CHF' },
bank: { receive: true },
active: true,
status: VirtualIbanStatus.ACTIVE,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ export class VirtualIbanService {
where: {
userData: { id: userData.id },
currency: { name: currencyName },
// A customer can hold several active rows for one currency - e.g. an old Yapeal EUR IBAN
// alongside a newer Frick one. Rows whose bank no longer receives must not be returned: this
// is a findOne without an ORDER BY, so a retired row can win over a working one, and the
// caller then sees "IBAN found, bank does not receive" and gives up. Since the collection
// account is no longer a fallback, that surfaced as PersonalIbanIssuanceFailed for every
// customer holding a retired Yapeal EUR IBAN.
bank: { receive: true },
active: true,
status: VirtualIbanStatus.ACTIVE,
},
Expand Down