✨ Open fund total amount of splits
This commit is contained in:
@@ -475,6 +475,7 @@ public class PaymentService(
|
||||
List<Guid> recipientAccountIds,
|
||||
string currency,
|
||||
decimal totalAmount,
|
||||
int amountOfSplits,
|
||||
Shared.Models.FundSplitType splitType,
|
||||
string? message = null,
|
||||
Duration? expiration = null)
|
||||
@@ -506,6 +507,7 @@ public class PaymentService(
|
||||
Currency = currency,
|
||||
TotalAmount = totalAmount,
|
||||
RemainingAmount = totalAmount,
|
||||
AmountOfSplits = amountOfSplits,
|
||||
SplitType = splitType,
|
||||
Message = message,
|
||||
ExpiredAt = now.Plus(expiration ?? Duration.FromHours(24)),
|
||||
@@ -582,14 +584,12 @@ public class PaymentService(
|
||||
if (fund.RemainingAmount <= 0)
|
||||
return 0;
|
||||
|
||||
// For open mode funds: use percentage-based calculation
|
||||
// For open mode funds: calculate amount per split
|
||||
if (fund.IsOpen)
|
||||
{
|
||||
const decimal percentagePerClaim = 0.1m; // 10% of remaining amount per claim
|
||||
const decimal minimumAmount = 0.01m; // Minimum 0.01 per claim
|
||||
|
||||
var calculatedAmount = Math.Max(fund.RemainingAmount * percentagePerClaim, minimumAmount);
|
||||
return Math.Min(calculatedAmount, fund.RemainingAmount);
|
||||
// Calculate amount per split: TotalAmount / AmountOfSplits
|
||||
var amountPerSplit = fund.TotalAmount / fund.AmountOfSplits;
|
||||
return Math.Max(amountPerSplit, 0.01m); // Minimum 0.01 per claim
|
||||
}
|
||||
// For closed mode funds: use split type calculation
|
||||
else
|
||||
|
||||
@@ -254,6 +254,7 @@ public class WalletController(
|
||||
[Required] public List<Guid> RecipientAccountIds { get; set; } = new();
|
||||
[Required] public string Currency { get; set; } = null!;
|
||||
[Required] public decimal TotalAmount { get; set; }
|
||||
[Required] public int AmountOfSplits { get; set; }
|
||||
[Required] public FundSplitType SplitType { get; set; }
|
||||
public string? Message { get; set; }
|
||||
public int? ExpirationHours { get; set; } // Optional: hours until expiration
|
||||
@@ -283,6 +284,7 @@ public class WalletController(
|
||||
recipientAccountIds: request.RecipientAccountIds,
|
||||
currency: request.Currency,
|
||||
totalAmount: request.TotalAmount,
|
||||
amountOfSplits: request.AmountOfSplits,
|
||||
splitType: request.SplitType,
|
||||
message: request.Message,
|
||||
expiration: expiration
|
||||
@@ -395,4 +397,4 @@ public class WalletController(
|
||||
return BadRequest(err.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user