Merge pull request #4976 from chimp1984/remove-ngn-from-transferwise

[1.5.2] Remove NGN (Nigerian Naira) as their central bank blocked Transferwise
This commit is contained in:
sqrrm 2020-12-19 23:30:38 +01:00 committed by GitHub
commit 245e736bc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View file

@ -301,7 +301,6 @@ public class CurrencyUtil {
new FiatCurrency("MAD"),
new FiatCurrency("NPR"),
new FiatCurrency("NZD"),
new FiatCurrency("NGN"),
new FiatCurrency("NOK"),
new FiatCurrency("PKR"),
new FiatCurrency("PEN"),

View file

@ -97,12 +97,25 @@ public abstract class PaymentAccount implements PersistablePayload {
}
public static PaymentAccount fromProto(protobuf.PaymentAccount proto, CoreProtoResolver coreProtoResolver) {
PaymentAccount account = PaymentAccountFactory.getPaymentAccount(PaymentMethod.getPaymentMethodById(proto.getPaymentMethod().getId()));
String paymentMethodId = proto.getPaymentMethod().getId();
List<TradeCurrency> tradeCurrencies = proto.getTradeCurrenciesList().stream()
.map(TradeCurrency::fromProto)
.collect(Collectors.toList());
// We need to remove NGN for Transferwise
Optional<TradeCurrency> ngnTwOptional = tradeCurrencies.stream()
.filter(e -> paymentMethodId.equals(PaymentMethod.TRANSFERWISE_ID))
.filter(e -> e.getCode().equals("NGN"))
.findAny();
// We cannot remove it in the stream as it would cause a concurrentModificationException
ngnTwOptional.ifPresent(tradeCurrencies::remove);
PaymentAccount account = PaymentAccountFactory.getPaymentAccount(PaymentMethod.getPaymentMethodById(paymentMethodId));
account.getTradeCurrencies().clear();
account.setId(proto.getId());
account.setCreationDate(proto.getCreationDate());
account.setAccountName(proto.getAccountName());
account.getTradeCurrencies().addAll(proto.getTradeCurrenciesList().stream().map(TradeCurrency::fromProto).collect(Collectors.toList()));
account.getTradeCurrencies().addAll(tradeCurrencies);
account.setPaymentAccountPayload(coreProtoResolver.fromProto(proto.getPaymentAccountPayload()));
if (proto.hasSelectedTradeCurrency())