Skip to content

Commit

Permalink
Removing the TargetInvestmentReached param
Browse files Browse the repository at this point in the history
  • Loading branch information
dangershony committed Feb 11, 2025
1 parent f699da1 commit 4cf8d6c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
18 changes: 0 additions & 18 deletions src/Angor/Client/Models/FounderProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,6 @@ public class FounderProject : Project
public string ProjectInfoEventId { get; set; }
public bool NostrProfileCreated { get; set; }


/// <summary>
/// The total amount of the project that has been invested in,
/// This parameter will only be set once the founder went to the spend page
/// and was able to calaulate to total amount of funds that have been invested in the project.
///
/// The intention is to use this parameter to know if the founder should be forced to release
/// the funds back to the investor by sending signature of a trx that spend coins to the investors address
/// </summary>
public decimal? TotalAvailableInvestedAmount { get; set; }

public DateTime? ReleaseSignaturesTime { get; set; }

public bool TargetInvestmentReached()
{
return TotalAvailableInvestedAmount >= ProjectInfo.TargetAmount;
}

public bool ProjectHasStarted()
{
return DateTime.UtcNow > ProjectInfo.StartDate;
Expand Down
14 changes: 6 additions & 8 deletions src/Angor/Client/Pages/Spend.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}
else
{
@if (!founderProject.TargetInvestmentReached() && founderProject.ProjectHasStarted())
@if (totalInvestedAmount <= founderProject.ProjectInfo.TargetAmount && founderProject.ProjectHasStarted())
{
<div class="alert alert-warning" role="alert">
<h4 class="alert-heading">Target Not Reached</h4>
Expand Down Expand Up @@ -475,6 +475,7 @@
private bool spendSpinner = false;

long totalAvailableInvestedAmount = 0;
long totalInvestedAmount = 0;
int totalInvestedTransactions = 0;
long totalSpentAmount = 0;
int totalSpentTransactions = 0;
Expand Down Expand Up @@ -539,17 +540,20 @@
totalSpentAmount = 0;
totalSpentTransactions = 0;
currentWithdrawableAmount = 0;
totalInvestedAmount = 0;

foreach (var stage in stageDatas)
{
var stageIsActive = stage.Stage.ReleaseDate < DateTime.UtcNow;
var totalStageTransactions = stage.Items.Count();
var investedAmount = stage.Items.Sum(c => c.Amount);
var availableInvestedAmount = stage.Items.Where(c => !c.IsSpent).Sum(c => c.Amount);
var spentStageAmount = stage.Items.Where(c => c.IsSpent).Sum(c => c.Amount);
var spentStageTransactions = stage.Items.Count(c => c.IsSpent);
var daysUntilRelease = (stage.Stage.ReleaseDate - DateTime.UtcNow).Days;
var stageReleasePercentage = stage.Stage.AmountToRelease;

totalInvestedAmount += investedAmount;
totalAvailableInvestedAmount += availableInvestedAmount;
totalInvestedTransactions += totalStageTransactions;
totalSpentAmount += spentStageAmount;
Expand All @@ -560,12 +564,6 @@
currentWithdrawableAmount += availableInvestedAmount;
}
}

if (totalAvailableInvestedAmount != founderProject.TotalAvailableInvestedAmount)
{
founderProject.TotalAvailableInvestedAmount = totalAvailableInvestedAmount;
storage.UpdateFounderProject(founderProject);
}
}

protected override async Task OnAfterRenderAsync(bool firstRender)
Expand Down Expand Up @@ -709,7 +707,7 @@

protected async Task ClaimCoinsCheckPassword(int stageId)
{
if (!founderProject.TargetInvestmentReached())
if (totalInvestedAmount <= founderProject.ProjectInfo.TargetAmount)
{
notificationComponent.ShowErrorMessage("Target investment amount has not been reached, you can only release the funds back to the investors");
return;
Expand Down
12 changes: 3 additions & 9 deletions src/Angor/Client/Pages/Unfunded.razor
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,12 @@

public bool TargetInvestmentReached()
{
if (projectStats != null)
{
var targetReached = projectStats?.AmountInvested >= FounderProject.ProjectInfo.TargetAmount;

Logger.LogInformation($"Indexer stats for target reached = {targetReached} AmountInvested = {projectStats?.AmountInvested} TargetAmount = {FounderProject.ProjectInfo.TargetAmount}");
var targetReached = projectStats?.AmountInvested >= FounderProject.ProjectInfo.TargetAmount;

return targetReached;
}
Logger.LogInformation($"Indexer stats for target reached = {targetReached} AmountInvested = {projectStats?.AmountInvested} TargetAmount = {FounderProject.ProjectInfo.TargetAmount}");

Logger.LogInformation($"None indexer stats for target reached = {FounderProject.TargetInvestmentReached()} AmountInvested = {FounderProject.TotalAvailableInvestedAmount} TargetAmount = {FounderProject.ProjectInfo.TargetAmount}");
return targetReached;

return FounderProject.TargetInvestmentReached();
}

private async Task RefreshSignaturesInternal()
Expand Down

0 comments on commit 4cf8d6c

Please sign in to comment.