Display fiat amount previews in Transaction Details page (#6610)

* Code cleanup

* Preparing model to include data needed for fiat display

* Displaying fiat amount and allowing switching between it and BTC

* Restoring parts removed by vibe coding

* Making ToFiatAmount method work for in wider variety of cases

* Tweaks for display and negative values

* Calculating amounts on serverside and simplifying

* Fix warnings

---------

Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
rockstardev
2025-03-08 06:33:19 -06:00
committed by GitHub
parent 71dbfd9f28
commit 9dcf8d3251
4 changed files with 199 additions and 109 deletions

View File

@@ -15,7 +15,7 @@ namespace BTCPayServer.Models.WalletViewModels
{
public bool Positive { get; set; }
public string Destination { get; set; }
public string Balance { get; set; }
public StringAmounts Balance { get; set; }
public IEnumerable<TransactionTagModel> Labels { get; set; } = new List<TransactionTagModel>();
}
@@ -24,7 +24,7 @@ namespace BTCPayServer.Models.WalletViewModels
public int Index { get; set; }
public string Error { get; set; }
public bool Positive { get; set; }
public string BalanceChange { get; set; }
public StringAmounts BalanceChange { get; set; }
public IEnumerable<TransactionTagModel> Labels { get; set; } = new List<TransactionTagModel>();
}
public class AmountViewModel
@@ -34,7 +34,7 @@ namespace BTCPayServer.Models.WalletViewModels
}
public AmountViewModel ReplacementBalanceChange { get; set; }
public bool HasErrors => Inputs.Count == 0 || Inputs.Any(i => !string.IsNullOrEmpty(i.Error));
public string BalanceChange { get; set; }
public StringAmounts BalanceChange { get; set; }
public bool CanCalculateBalance { get; set; }
public bool Positive { get; set; }
public List<DestinationViewModel> Destinations { get; set; } = new List<DestinationViewModel>();
@@ -50,5 +50,7 @@ namespace BTCPayServer.Models.WalletViewModels
Inputs[(int)err.InputIndex].Error = err.Message;
}
}
public record StringAmounts(string CryptoAmount, string FiatAmount);
}
}