Skip to content

Commit 0100217

Browse files
Merge pull request #605 from nofrixion/MOOV-4658-add-theirreference-to-beneficiary
Added their reference to beneficiary
2 parents 269c077 + c2258e0 commit 0100217

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/NoFrixion.MoneyMoov/Models/Beneficiary/Beneficiary.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ public class Beneficiary : IValidatableObject, IExportableToCsv
112112
public DateTimeOffset? LastAuthorised { get; set; }
113113

114114
public User CreatedBy { get; set; }
115+
116+
/// <summary>
117+
/// The reference that will be used by default as TheirReference when creating payouts to this beneficiary
118+
/// if no TheirReference is specified for the payout.
119+
/// </summary>
120+
[CanBeNull] public string TheirReference { get; set; }
115121

116122
// Don't serialize the events if there are none.
117123
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]

src/NoFrixion.MoneyMoov/Models/Beneficiary/BeneficiaryCreate.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// -----------------------------------------------------------------------------
1616

1717
using System.ComponentModel.DataAnnotations;
18+
using JetBrains.Annotations;
1819

1920
#nullable disable
2021

@@ -46,14 +47,20 @@ public class BeneficiaryCreate : IValidatableObject
4647

4748
[Required(ErrorMessage = "Destination is required.")]
4849
public CounterpartyCreate Destination { get; set; }
50+
51+
/// <summary>
52+
/// Optional reference that will be used by default as TheirReference when creating payouts to this beneficiary
53+
/// if no TheirReference is specified for the payout.
54+
/// </summary>
55+
[CanBeNull] public string TheirReference { get; set; }
4956

5057
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
5158
{
5259
var payout = ToPayout();
5360
payout.Amount = 0.01M;
5461
// Use dummy valid values for references. Beneficiaries can have invalid references as
5562
// they will be forced to fix them when the payout is created.
56-
payout.TheirReference = "GoodRef";
63+
payout.TheirReference = TheirReference ?? "GoodRef";
5764
payout.YourReference = "GoodRef";
5865
return payout.Validate(validationContext);
5966
}
@@ -91,7 +98,8 @@ public Dictionary<string, string> ToDictionary()
9198
{ nameof(ID), ID.ToString() },
9299
{ nameof(MerchantID), MerchantID.ToString() },
93100
{ nameof(Name), Name },
94-
{ nameof(Currency), Currency.ToString() }
101+
{ nameof(Currency), Currency.ToString() },
102+
{ nameof(TheirReference), TheirReference}
95103
};
96104

97105
if (Destination != null)

src/NoFrixion.MoneyMoov/Models/Beneficiary/BeneficiaryUpdate.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public class BeneficiaryUpdate
3333

3434
public Counterparty? Destination { get; set; }
3535

36+
/// <summary>
37+
/// The default reference that will be used by default as TheirReference when creating payouts to this beneficiary
38+
/// if no TheirReference is specified for the payout.
39+
/// </summary>
40+
public string? TheirReference { get; set; }
41+
3642
public NoFrixionProblem Validate()
3743
{
3844
var context = new ValidationContext(this, serviceProvider: null, items: null);

0 commit comments

Comments
 (0)