This commit is contained in:
Falkvinge
2017-05-10 11:25:04 +02:00
parent 8897477e81
commit b0c60e3c49
4 changed files with 20 additions and 13 deletions
+2 -10
View File
@@ -308,26 +308,18 @@ namespace Swarmops.Frontend.Socket
public static void RecalculateOrganizationProfitLoss(Organization organization)
{
Int64 annualProfitLossCents = GetOrganizationProfitLossCents(organization);
Int64 annualProfitLossCents = organization.GetProfitLossCents();
JObject json = new JObject();
json["MessageType"] = "AnnualProfitLossCents";
json["ProfitLossCents"] = annualProfitLossCents.ToString();
json["ProfitLossCents"] = annualProfitLossCents.ToString(CultureInfo.InvariantCulture);
json["OrganizationId"] = organization.Identity;
BroadcastToOrganization(organization, json);
}
public static Int64 GetOrganizationProfitLossCents(Organization organization)
{
FinancialAccounts allPLAccounts = FinancialAccounts.ForOrganization(organization,
FinancialAccountType.Result);
DateTime thisYearStart = new DateTime(DateTime.UtcNow.Year, 1, 1);
DateTime thisYearEnd = new DateTime(thisYearStart.Year + 1, 1, 1);
return -allPLAccounts.GetDeltaCents(thisYearStart, thisYearEnd); // negative because of accounting of P&L accounts
}
public static void BroadcastToOrganization(Organization organization, JObject message)
+2 -2
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -68,9 +69,8 @@ namespace Swarmops.Frontend.Socket
JObject json = new JObject();
json ["MessageType"] = json["messageType"] = "AnnualProfitLossCents";
json["ProfitLossCents"] = FrontendLoop.GetOrganizationProfitLossCents(this._authority.Organization).ToString();
json["ProfitLossCents"] = this._authority.Organization.GetProfitLossCents().ToString(CultureInfo.InvariantCulture);
json["OrganizationId"] = this._authority.Organization.Identity;
json["Instant"] = "1"; // instant update, no odometer rolling for init
this.Send(json.ToString());
}
+15
View File
@@ -1005,6 +1005,21 @@ namespace Swarmops.Logic.Structure
}
public Int64 GetProfitLossCents (int year = 0)
{
if (year == 0)
{
year = DateTime.UtcNow.Year;
}
FinancialAccounts allPLAccounts = Swarmops.Logic.Financial.FinancialAccounts.ForOrganization(this,
FinancialAccountType.Result);
DateTime thisYearStart = new DateTime(year, 1, 1);
DateTime thisYearEnd = new DateTime(year + 1, 1, 1);
return -allPLAccounts.GetDeltaCents(thisYearStart, thisYearEnd); // negative because of accounting of P&L accounts
}
public string VanityDomain
{
get { return OptionalData.GetOptionalDataString(ObjectOptionalDataType.OrgVanityDomain); }
+1 -1
View File
@@ -227,7 +227,7 @@
<div class="box" style="background-image: url(/Images/Other/coins-background-istockphoto.jpg); background-size: 700px">
<div class="content">
<div class="odometer-wrapper">
<div class="elementFloatFar odometer odometer-currency" id="odoProfitLossToDate">0.001</div><div class="odometer-label"><asp:Label runat="server" ID="MasterLabelDashboardProfitLoss">Profit To Date XYZ</asp:Label></div>
<div class="elementFloatFar odometer odometer-currency" id="odoProfitLossToDate"><%= (CurrentOrganization.GetProfitLossCents() / 100.0 + 0.001).ToString(CultureInfo.InvariantCulture) %></div><div class="odometer-label"><asp:Label runat="server" ID="MasterLabelDashboardProfitLoss">Profit To Date XYZ</asp:Label></div>
</div>
</div>
</div>