Added hotwallet report
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#tableProfitLoss').treegrid(
|
||||
$('#tableHotwallet').treegrid(
|
||||
{
|
||||
onBeforeExpand: function (foo) {
|
||||
$('span.profitlossdata-collapsed-' + foo.id).fadeOut('fast', function () {
|
||||
@@ -31,8 +31,6 @@
|
||||
$('div.datagrid').css('opacity', 0.4);
|
||||
});
|
||||
|
||||
var currentYear = <%=DateTime.Today.Year %>;
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.content h2 select {
|
||||
@@ -48,17 +46,18 @@
|
||||
|
||||
<h2><asp:Label ID="LabelContentHeader" runat="server" /> <img alt="Loading" src="/Images/Abstract/ajaxloader-blackcircle.gif" ID="imageLoadIndicator" /></h2>
|
||||
<table id="tableHotwallet" title="" class="easyui-treegrid" style="width:680px;height:600px"
|
||||
url="Json-HotwalletData.aspx"
|
||||
url="Json-BitcoinHotwalletData.aspx"
|
||||
rownumbers="false"
|
||||
animate="true"
|
||||
fitColumns="true"
|
||||
showFooter="true"
|
||||
idField="id" treeField="name">
|
||||
<thead>
|
||||
<tr>
|
||||
<th field="derivePath" width="178"><asp:Literal ID="LiteralHeaderDerivationPath" runat="server"/></th>
|
||||
<th field="address" width="80" align="right"><span class="commonHeader" id="headerAddress" style="display:none"><asp:Literal ID="LiteralHeaderAddress" runat="server" /></span><span class="loadingHeader">—</span></th>
|
||||
<th field="derivePath" width="108"><asp:Literal ID="LiteralHeaderDerivationPath" runat="server"/></th>
|
||||
<th field="address" width="170" align="left"><span class="commonHeader" id="headerAddress" style="display:none"><asp:Literal ID="LiteralHeaderAddress" runat="server" /></span><span class="loadingHeader">—</span></th>
|
||||
<th field="balanceMicrocoins" width="80" align="right"><span class="commonHeader" id="headerQ1" style="display:none"><asp:Literal ID="LiteralHeaderMicrocoins" runat="server" /></span><span class="loadingHeader">—</span></th>
|
||||
<th field="balanceFiat" width="80" align="right"><span class="commonHeader" id="headerQ2" style="display:none"><asp:Literal ID="LiteralHeaderFiatValue" runat="server" /></span><span class="loadingHeader">—</span></th>
|
||||
<th field="balanceFiat" width="60" align="right"><span class="commonHeader" id="headerQ2" style="display:none"><asp:Literal ID="LiteralHeaderFiatValue" runat="server" /></span><span class="loadingHeader">—</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-BitcoinHotwalletData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.Json_BitcoinHotwalletData" %>
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Resources;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Security;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
{
|
||||
public partial class Json_BitcoinHotwalletData : DataV5Base
|
||||
{
|
||||
private AuthenticationData _authenticationData;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
PageAccessRequired = new Access(CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read);
|
||||
this._authenticationData = GetAuthenticationDataAndCulture();
|
||||
|
||||
HotBitcoinAddresses addresses = HotBitcoinAddresses.ForOrganization (_authenticationData.CurrentOrganization);
|
||||
|
||||
Response.ContentType = "application/json";
|
||||
Response.Output.WriteLine(FormatJson(addresses));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private string FormatJson(HotBitcoinAddresses addresses)
|
||||
{
|
||||
StringBuilder result = new StringBuilder(16384);
|
||||
|
||||
double conversionRate = 1.0;
|
||||
if (!this._authenticationData.CurrentOrganization.Currency.IsBitcoin)
|
||||
{
|
||||
long fiatCentsPerCoin = new Money(100000000, Currency.Bitcoin).ToCurrency (_authenticationData.CurrentOrganization.Currency).Cents;
|
||||
conversionRate = fiatCentsPerCoin/100000000.0; // on satoshi level
|
||||
}
|
||||
|
||||
result.Append("{\"rows\":[");
|
||||
|
||||
Int64 satoshisTotal = 0;
|
||||
|
||||
foreach (HotBitcoinAddress address in addresses)
|
||||
{
|
||||
result.Append("{");
|
||||
result.AppendFormat (
|
||||
"\"id\":\"{0}\"," +
|
||||
"\"derivePath\":\"{1}\"," +
|
||||
"\"address\":\"{2}\"," +
|
||||
"\"balanceMicrocoins\":\"{3}\"," +
|
||||
"\"balanceFiat\":\"{4}\"",
|
||||
address.Identity,
|
||||
address.DerivationPath,
|
||||
address.Address,
|
||||
(address.BalanceSatoshis/100.0).ToString ("N2"),
|
||||
(address.BalanceSatoshis/100.0*conversionRate).ToString ("N2")
|
||||
);
|
||||
result.Append("},");
|
||||
satoshisTotal += address.BalanceSatoshis;
|
||||
}
|
||||
|
||||
if (addresses.Count > 0)
|
||||
{
|
||||
result.Remove(result.Length - 1, 1); // remove last comma
|
||||
}
|
||||
|
||||
result.Append("],\"footer\":[");
|
||||
|
||||
result.Append("{");
|
||||
|
||||
result.AppendFormat("\"derivePath\":\"TOTAL\",\"balanceMicrocoins\":\"{0}\",\"balanceFiat\":\"{1:N2}\"",
|
||||
(satoshisTotal / 100.0).ToString("N2"), (satoshisTotal / 100.0 * conversionRate).ToString("N2"));
|
||||
|
||||
result.Append("}]}"); // on separate line to suppress warning
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user