Skip to content

Commit

Permalink
Merge branch 'develop' into feature/MOOV-3224-batch-payouts
Browse files Browse the repository at this point in the history
  • Loading branch information
donalnofrixion committed May 28, 2024
2 parents 5dffc1a + 6c0d62f commit 8af3495
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/NoFrixion.MoneyMoov/Mapping/CounterpartyMappers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static Counterparty ToCounterparty(this CounterpartyCreate counterpartyCr
EmailAddress = counterpartyCreate.EmailAddress,
PhoneNumber = counterpartyCreate.PhoneNumber,
BeneficiaryID = counterpartyCreate.BeneficiaryID,
Identifier = counterpartyCreate.Identifier?.ToAccountIdentifier(currency)
Identifier = counterpartyCreate.Identifier?.ToAccountIdentifier(currency),
};
}

Expand Down
1 change: 0 additions & 1 deletion src/NoFrixion.MoneyMoov/Models/Payouts/Payout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ public string GetApprovalHash()
Currency +
Math.Round(Amount, 2).ToString() +
Destination.GetApprovalHash() +
//Status.ToString() +
Scheduled.GetValueOrDefault().ToString() +
ScheduleDate?.ToString("o");

Expand Down
93 changes: 49 additions & 44 deletions src/NoFrixion.MoneyMoov/Models/Payouts/PayoutsValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,60 +263,65 @@ public static IEnumerable<ValidationResult> Validate(Payout payout, ValidationCo
yield return new ValidationResult("Destination account required.", new string[] { nameof(payout.Destination) });
}

if (payout.Destination != null && payout.Destination?.Identifier == null)
if (payout.Destination?.AccountID == null && payout.Destination?.BeneficiaryID == null)
{
yield return new ValidationResult("Destination account identifier required.", new string[] { nameof(payout.Destination.Identifier) });
}
// Only validate the identifier details if the account or beneficiary ID is not set.

if (string.IsNullOrEmpty(payout.Destination?.Name))
{
yield return new ValidationResult("Destination account name required.", new string[] { nameof(payout.Destination.Name) });
}
if (payout.Destination != null && payout.Destination?.Identifier == null)
{
yield return new ValidationResult("Destination account identifier required.", new string[] { nameof(payout.Destination.Identifier) });
}

if (payout.Destination?.Name != null && !IsValidAccountName(payout.Destination?.Name ?? string.Empty))
{
yield return new ValidationResult($"Destination account name is invalid. It can only contain alphanumeric characters plus the ' . - & and space characters.",
new string[] { nameof(payout.Destination.Name) });
}
if (string.IsNullOrEmpty(payout.Destination?.Name))
{
yield return new ValidationResult("Destination account name required.", new string[] { nameof(payout.Destination.Name) });
}

if (payout.Destination != null &&
!(payout.Type == AccountIdentifierType.IBAN || payout.Type == AccountIdentifierType.SCAN || payout.Type == AccountIdentifierType.BTC))
{
yield return new ValidationResult("Only destination types of IBAN, SCAN or BTC are supported.", new string[] { nameof(payout.Type) });
}
if (payout.Destination?.Name != null && !IsValidAccountName(payout.Destination?.Name ?? string.Empty))
{
yield return new ValidationResult($"Destination account name is invalid. It can only contain alphanumeric characters plus the ' . - & and space characters.",
new string[] { nameof(payout.Destination.Name) });
}

if (payout.Type == AccountIdentifierType.IBAN && payout.Destination?.Identifier != null &&
string.IsNullOrEmpty(payout.Destination?.Identifier?.IBAN ?? string.Empty))
{
yield return new ValidationResult("The destination account IBAN must be specified for an IBAN payout type.", new string[] { nameof(payout.Destination.Identifier.IBAN) });
}
if (payout.Destination != null &&
!(payout.Type == AccountIdentifierType.IBAN || payout.Type == AccountIdentifierType.SCAN || payout.Type == AccountIdentifierType.BTC))
{
yield return new ValidationResult("Only destination types of IBAN, SCAN or BTC are supported.", new string[] { nameof(payout.Type) });
}

if (payout.Type == AccountIdentifierType.IBAN && payout.Destination?.Identifier != null &&
!ValidateIBAN(payout.Destination?.Identifier?.IBAN ?? string.Empty))
{
yield return new ValidationResult("Destination IBAN is invalid, Please enter a valid IBAN.", new string[] { nameof(payout.Destination.Identifier.IBAN) });
}
if (payout.Type == AccountIdentifierType.IBAN && payout.Destination?.Identifier != null &&
string.IsNullOrEmpty(payout.Destination?.Identifier?.IBAN ?? string.Empty))
{
yield return new ValidationResult("The destination account IBAN must be specified for an IBAN payout type.", new string[] { nameof(payout.Destination.Identifier.IBAN) });
}

if (payout.Type == AccountIdentifierType.IBAN && payout.Currency != CurrencyTypeEnum.EUR)
{
yield return new ValidationResult($"Currency {payout.Currency} cannot be used with IBAN destinations.", new string[] { nameof(payout.Currency) });
}
if (payout.Type == AccountIdentifierType.IBAN && payout.Destination?.Identifier != null &&
!ValidateIBAN(payout.Destination?.Identifier?.IBAN ?? string.Empty))
{
yield return new ValidationResult("Destination IBAN is invalid, Please enter a valid IBAN.", new string[] { nameof(payout.Destination.Identifier.IBAN) });
}

if (payout.Type == AccountIdentifierType.SCAN && payout.Destination?.Identifier != null &&
string.IsNullOrEmpty(payout.Destination?.Identifier?.SortCode))
{
yield return new ValidationResult("Destination sort code required for a SCAN payout type.", new string[] { nameof(payout.Destination.Identifier.SortCode) });
}
if (payout.Type == AccountIdentifierType.IBAN && payout.Currency != CurrencyTypeEnum.EUR)
{
yield return new ValidationResult($"Currency {payout.Currency} cannot be used with IBAN destinations.", new string[] { nameof(payout.Currency) });
}

if (payout.Type == AccountIdentifierType.SCAN && payout.Destination?.Identifier != null &&
string.IsNullOrEmpty(payout.Destination?.Identifier?.AccountNumber))
{
yield return new ValidationResult("Destination account number is required for a SCAN payout type.", new string[] { nameof(payout.Destination.Identifier.AccountNumber) });
}
if (payout.Type == AccountIdentifierType.SCAN && payout.Destination?.Identifier != null &&
string.IsNullOrEmpty(payout.Destination?.Identifier?.SortCode))
{
yield return new ValidationResult("Destination sort code required for a SCAN payout type.", new string[] { nameof(payout.Destination.Identifier.SortCode) });
}

if (payout.Type == AccountIdentifierType.SCAN && payout.Currency != CurrencyTypeEnum.GBP)
{
yield return new ValidationResult($"Currency {payout.Currency} cannot be used with SCAN destinations.", new string[] { nameof(payout.Currency) });
if (payout.Type == AccountIdentifierType.SCAN && payout.Destination?.Identifier != null &&
string.IsNullOrEmpty(payout.Destination?.Identifier?.AccountNumber))
{
yield return new ValidationResult("Destination account number is required for a SCAN payout type.", new string[] { nameof(payout.Destination.Identifier.AccountNumber) });
}

if (payout.Type == AccountIdentifierType.SCAN && payout.Currency != CurrencyTypeEnum.GBP)
{
yield return new ValidationResult($"Currency {payout.Currency} cannot be used with SCAN destinations.", new string[] { nameof(payout.Currency) });
}
}

if (payout.Destination?.Identifier != null)
Expand Down
4 changes: 2 additions & 2 deletions src/NoFrixion.MoneyMoov/NoFrixion.MoneyMoov.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyVersion>1.1.270.0</AssemblyVersion>
<FileVersion>1.1.270.0</FileVersion>
<AssemblyVersion>1.1.271.0</AssemblyVersion>
<FileVersion>1.1.271.0</FileVersion>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);1591</NoWarn>
Expand Down

0 comments on commit 8af3495

Please sign in to comment.