Added vanity domains, open ledger domains

This commit is contained in:
Rick Falkvinge
2015-02-26 10:03:21 +01:00
parent b5a99fe500
commit f02751944b
17 changed files with 323 additions and 61 deletions
@@ -1,6 +1,7 @@
using System;
using Swarmops.Basic.Types.Financial;
using Swarmops.Database;
using Swarmops.Logic.Swarm;
namespace Swarmops.Logic.Financial
{
@@ -45,6 +46,19 @@ namespace Swarmops.Logic.Financial
get { return Account.Name; }
}
public Person CreatedByPerson
{
get
{
if (base.CreatedByPersonId > 0)
{
return Person.FromIdentity (base.CreatedByPersonId);
}
return null;
}
}
[Obsolete ("Do not use. Use Int64 AmountCents.", true)]
public decimal Amount
{
+12 -2
View File
@@ -37,10 +37,20 @@ namespace Swarmops.Logic.Security
Unknown = 0,
/// <summary>
/// Access to underlying ledgers
/// Basic access to underlying ledgers
/// </summary>
Bookkeeping,
/// <summary>
/// Detailed access to underlying ledgers (documents, descriptions)
/// </summary>
BookkeepingDetails,
/// <summary>
/// Access to auditing working material (redflagged transactions, etc)
/// </summary>
Auditing,
/// <summary>
/// Access to regular accounting
/// </summary>
@@ -54,7 +64,7 @@ namespace Swarmops.Logic.Security
/// <summary>
/// Access to personal details about people in an organization
/// </summary>
PersonData,
PersonalData,
/// <summary>
/// Access to change organization's fundamental operating parameters
+20
View File
@@ -939,6 +939,26 @@ namespace Swarmops.Logic.Structure
return new DateTime (year, 12, 31, 23, 59, 59, 999);
}
public DateTime GetStartOfFiscalYear (int year)
{
// Returns the first millisecond of the fiscal year. For now, this is limited to calendar years; the function
// exists for future expandability.
return new DateTime (year, 1, 1, 0, 0, 0, 0);
}
public string VanityDomain
{
get { return OptionalData.GetOptionalDataString(ObjectOptionalDataType.OrgVanityDomain); }
set { OptionalData.SetOptionalDataString(ObjectOptionalDataType.OrgVanityDomain, value); }
}
public string OpenLedgersDomain
{
get { return OptionalData.GetOptionalDataString(ObjectOptionalDataType.OrgOpenLedgersDomain); }
set { OptionalData.SetOptionalDataString(ObjectOptionalDataType.OrgOpenLedgersDomain, value); }
}
}
}
+4
View File
@@ -576,4 +576,8 @@
<value>(vacant)</value>
<comment>For unassigned positions</comment>
</data>
<data name="Global_DefineToEnable" xml:space="preserve">
<value>define to enable</value>
<comment>shown as watermark on some edit boxes</comment>
</data>
</root>
@@ -157,6 +157,9 @@
<value>{0} numbering</value>
<comment>The {0} is the membership, ambassadorship, etc.</comment>
</data>
<data name="EditOrganization_OpenLedgersDomain" xml:space="preserve">
<value>Open Ledgers Domain</value>
</data>
<data name="EditOrganization_PageTitle" xml:space="preserve">
<value>Edit Organization</value>
</data>
@@ -194,6 +197,9 @@
<value>Renewal cost (in {0})</value>
<comment>The {0} is the operating currency (USD etc).</comment>
</data>
<data name="EditOrganization_VanityDomain" xml:space="preserve">
<value>Vanity Domain</value>
</data>
<data name="SystemSettings_AdminAddress" xml:space="preserve">
<value>Admin Notifications From Address</value>
</data>
@@ -609,4 +609,22 @@
<value>Inspecting Transaction #&lt;span id="spanModalTransactionId"&gt;12345&lt;/span&gt;</value>
<comment>The transaction id is replaced client-side on display</comment>
</data>
<data name="InspectLedgers_AccountName" xml:space="preserve">
<value>Account name</value>
</data>
<data name="InspectLedgers_BalancedTransaction" xml:space="preserve">
<value>Balance is correct:</value>
</data>
<data name="InspectLedgers_EmptyTransaction" xml:space="preserve">
<value>(No transaction data)</value>
</data>
<data name="InspectLedgers_LoggedByInitials" xml:space="preserve">
<value>Initials</value>
</data>
<data name="InspectLedgers_LoggedDate" xml:space="preserve">
<value>Logged</value>
</data>
<data name="InspectLedgers_UnbalancedTransaction" xml:space="preserve">
<value>Transaction is &lt;span class="spanAnnoyingBlink"&gt;UNBALANCED&lt;/span&gt;:</value>
</data>
</root>
@@ -176,4 +176,10 @@
<data name="ListFindPeople_TooManyHits" xml:space="preserve">
<value>The result set contains over a thousand people (display limited to a thousand). Please refine your search?</value>
</data>
<data name="Positions_AssignPerson" xml:space="preserve">
<value>Assign person...</value>
</data>
<data name="Positions_CreateNewPosition" xml:space="preserve">
<value>Create new position...</value>
</data>
</root>
+4 -8
View File
@@ -41,20 +41,16 @@ namespace Swarmops.Frontend.Automation
string localizedPositionName = position.Localized (positionNode.Data.MaxCount != 1);
PositionAssignments assignments = position.Assignments;
string parentName = string.Empty;
if (positionNode.Parent != null)
{
parentName = positionNode.Parent.Data.Localized();
}
string expires = string.Empty;
string assignedName = Resources.Global.Swarm_Vacant;
string assignedName = Resources.Global.Swarm_Vacant + "<br/>Testing line 2<br/>Testing line 3";
if (assignments.Count > 0)
{
assignedName = assignments[0].Person.Canonical;
}
string element = string.Format("\"id\":\"{0}\",\"positionTitle\":\"{1}\",\"assignedName\":\"{2}\",\"reportsTo\":\"{3}\"",
position.Identity, JsonSanitize (localizedPositionName), JsonSanitize (assignedName), JsonSanitize (parentName));
string element = string.Format("\"id\":\"{0}\",\"positionTitle\":\"{1}\",\"assignedName\":\"{2}\",\"expires\":\"{3}\"",
position.Identity, JsonSanitize (localizedPositionName), JsonSanitize (assignedName), JsonSanitize (expires));
// TODO: Add all assignments after the first one right here
+13
View File
@@ -2,6 +2,7 @@
<%@ Import Namespace="Resources" %>
<%@ Register tagPrefix="Swarmops5" tagName="FileUpload" src="~/Controls/v5/Base/FileUpload.ascx" %>
<%@ Register tagPrefix="Swarmops5" tagName="DropDown" src="~/Controls/v5/Base/DropDown.ascx" %>
<%@ Register tagPrefix="Swarmops5" tagName="AjaxTextBox" src="~/Controls/v5/Base/AjaxTextBox.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
@@ -190,6 +191,18 @@
SMTP server (default if blank)
</div>
</div>
<div title="<img src='/Images/Icons/iconshock-star-gold-64px.png' />">
<h2>Premium Features</h2>
<div class="entryFields">
<Swarmops5:AjaxTextBox runat="server" ID="TextVanityDomain" />&#8203;<br/>
<Swarmops5:AjaxTextBox runat="server" ID="TextOpenLedgersDomain" />&#8203;<br/>
</div>
<div class="entryLabels">
<asp:Label ID="LabelVanityDomain" runat="server" /><br/>
<asp:Label ID="LabelOpenLedgersDomain" runat="server" /><br/>
</div>
</div>
</div>
</asp:Content>
+46
View File
@@ -1,10 +1,15 @@
using System;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Web.Services;
using System.Web.UI.WebControls;
using Swarmops.Common.Enums;
using Swarmops.Frontend.Controls.v5.Base;
using Swarmops.Logic.Communications;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
namespace Swarmops.Frontend.Pages.v5.Admin
@@ -53,6 +58,13 @@ namespace Swarmops.Frontend.Pages.v5.Admin
this.LabelMemberNumber.Text =
String.Format (Resources.Pages.Admin.EditOrganization_MemberNumberStyle, participantship);
// Premium features
this.LabelVanityDomain.Text = Resources.Pages.Admin.EditOrganization_VanityDomain;
this.LabelOpenLedgersDomain.Text = Resources.Pages.Admin.EditOrganization_OpenLedgersDomain;
this.TextVanityDomain.Placeholder = Resources.Global.Global_DefineToEnable;
this.TextOpenLedgersDomain.Placeholder = Resources.Global.Global_DefineToEnable;
this.DropMembersWhen.Items.Clear();
this.DropMembersWhen.Items.Add (new ListItem ("Application submitted", "Application"));
this.DropMembersWhen.Items.Add (new ListItem ("Application approved", "ApplicationApproval"));
@@ -368,6 +380,40 @@ namespace Swarmops.Frontend.Pages.v5.Admin
}
[WebMethod]
static public AjaxTextBox.CallbackResult StoreCallback(string newValue, string cookie)
{
AjaxTextBox.CallbackResult result = new AjaxTextBox.CallbackResult();
AuthenticationData authenticationData = GetAuthenticationDataAndCulture();
if (!authenticationData.CurrentUser.HasAccess (new Access (authenticationData.CurrentOrganization, AccessAspect.Administration, AccessType.Write)))
{
result.ResultCode = AjaxTextBox.CodeNoPermission;
return result;
}
switch (cookie)
{
case "VanityDomain":
result.NewData = newValue.Trim();
result.ResultCode = AjaxTextBox.CodeSuccess;
authenticationData.CurrentOrganization.VanityDomain = result.NewData;
break;
case "OpenLedgersDomain":
result.NewData = newValue.Trim();
result.ResultCode = AjaxTextBox.CodeSuccess;
authenticationData.CurrentOrganization.OpenLedgersDomain = result.NewData;
break;
default:
throw new NotImplementedException("Unknown cookie in StoreCallback");
}
return result;
}
public class CallResult
{
public bool Success { get; set; }
@@ -138,6 +138,13 @@ namespace Swarmops.Frontend.Pages.v5.Admin
static public AjaxTextBox.CallbackResult StoreCallback(string newValue, string cookie)
{
AjaxTextBox.CallbackResult result = new AjaxTextBox.CallbackResult();
AuthenticationData authData = GetAuthenticationDataAndCulture();
if (!authData.CurrentUser.HasAccess (new Access (AccessAspect.System, AccessType.Write)))
{
result.ResultCode = AjaxTextBox.CodeNoPermission;
return result; // fail silently
}
switch (cookie)
{
+1 -1
View File
@@ -603,7 +603,7 @@
<div id="divModalCover" class="modalcover">
<div id="divModalBox" class="box modal">
<div class="content">
<div style="float:right;margin-top: 2px;margin-right: -5px"><img id="IconCloseEdit" src="/Images/Icons/iconshock-cross-16px.png" /></div><h2 id="HeaderModal"><asp:Literal ID="LiteralHeaderEditingAccount" runat="server"/></h2>
<div class="divIconCloseModal"><img id="IconCloseEdit" src="/Images/Icons/iconshock-cross-16px.png" /></div><h2 id="HeaderModal"><asp:Literal ID="LiteralHeaderEditingAccount" runat="server"/></h2>
<div id="DivModalFields" class="entryFields"><input type="text" id="TextAccountName" />&nbsp;<br />
<Swarmops5:ComboBudgets ID="DropParents" runat="server" OnClientLoaded="onAccountTreeLoaded" OnClientSelect="onAccountTreeSelect" />&nbsp;<br/>
<div id="DivEditProfitLossControls">&nbsp;<br/>
+61 -48
View File
@@ -4,46 +4,50 @@
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<script type="text/javascript">
$(document).ready(function () {
$(document).ready(function() {
$('#gridLedgers').datagrid(
{
onLoadSuccess: function () {
$('div.datagrid').css('opacity', 1);
$('#imageLoadIndicator').hide();
$('span.loadingHeader').hide();
$('#gridLedgers').datagrid(
{
onLoadSuccess: function() {
$('div.datagrid').css('opacity', 1);
$('#imageLoadIndicator').hide();
$('span.loadingHeader').hide();
// Merge inbound, outbound balances
var rowCount = $('#gridLedgers').datagrid('getRows').length;
if (rowCount > 0) {
$('#gridLedgers').datagrid('mergeCells', {
index: 0,
field: 'description',
colspan: 3
});
$('#gridLedgers').datagrid('mergeCells', {
index: rowCount-1,
field: 'description',
colspan: 3
});
//$('#gridOutstandingAccounts').dataGrid('mergeCells', {index: rowCount, field:'id', colspan: 5});
// Footer cells could not be merged in datagrid :(
// Merge inbound, outbound balances
}
var rowCount = $('#gridLedgers').datagrid('getRows').length;
if (rowCount > 0) {
$('#gridLedgers').datagrid('mergeCells', {
index: 0,
field: 'description',
colspan: 3
});
$('#gridLedgers').datagrid('mergeCells', {
index: rowCount - 1,
field: 'description',
colspan: 3
});
//$('#gridOutstandingAccounts').dataGrid('mergeCells', {index: rowCount, field:'id', colspan: 5});
// Footer cells could not be merged in datagrid :(
// Enable various actions on icon
}
$('img.LocalIconFlag').click(function () {
transactionId = $(this).attr("txId");
onFlagTransaction("Add Tx Id here");
});
$('img.LocalIconInspect').click(function () {
transactionId = $(this).attr("txId");
onInspectTransaction(transactionId);
});
}
});
// Enable various actions on icon
$('img.LocalIconFlag').click(function() {
transactionId = $(this).attr("txId");
onFlagTransaction("Add Tx Id here");
});
$('img.LocalIconInspect').click(function() {
transactionId = $(this).attr("txId");
onInspectTransaction(transactionId);
});
}
});
$('#gridTransaction').datagrid({
onLoadSuccess: function() {}
});
$('#<%=DropYears.ClientID %>').change(function () {
reloadData();
@@ -94,7 +98,7 @@
$('body').css('overflow-y', 'hidden');
$('#divModalCover').fadeIn();
alertify.log ('<asp:Label ID="LabelInspectNotAvailable" runat="server" />');
$('#gridTransaction').datagrid({ url: 'Json-InspectLedgerTxData.aspx?TxId=' + transactionId });
}
function onFlagTransaction(transactionId) {
@@ -118,6 +122,16 @@
position: relative;
top: 4px;
}
.spanAnnoyingBlink {
animation: blink 0.5s linear infinite;
}
@keyframes blink {
0% { color: darkred; }
100% { color: red; }
}
</style>
</asp:Content>
@@ -148,20 +162,19 @@
<div id="divModalBox" class="box modal">
<div class="content">
<div class="divIconCloseModal"><img id="IconCloseEdit" src="/Images/Icons/iconshock-cross-16px.png" /></div><h2><asp:Literal ID="LiteralEditHeader" runat="server"/></h2>
<table id="Table1" class="easyui-datagrid" style="width:100%;height:300px"
data-options="rownumbers:false,singleSelect:false,nowrap:false,fitColumns:true,fit:false,showFooter:false,loading:false,selectOnCheck:true,checkOnSelect:true,url:'Json-InspectLedgerData.aspx'"
<table id="gridTransaction" class="easyui-datagrid" style="width:100%;height:240px"
data-options="rownumbers:false,singleSelect:false,nowrap:false,fitColumns:true,fit:false,showFooter:false,loading:false,selectOnCheck:true,checkOnSelect:true,url:'Json-InspectTransactionData.aspx'"
idField="id">
<thead>
<tr>
<th data-options="field:'id',width:50,align:'right'"><asp:Label ID="Label1" runat="server" Text="ID#"/></th>
<th data-options="field:'datetime',width:90,sortable:true"><asp:Label ID="Label2" runat="server" Text="XYZ DateTime" /></th>
<th data-options="field:'description',width:270"><asp:Label ID="Label3" runat="server" Text="XYZ Description" /></th>
<th data-options="field:'deltaPos',width:70,align:'right'"><asp:Label ID="Label4" runat="server" Text="XYZ Debit" /></th>
<th data-options="field:'deltaNeg',width:70,align:'right'"><asp:Label ID="Label5" runat="server" Text="XYZ Credit" /></th>
<th data-options="field:'balance',width:80,align:'right'"><asp:Label ID="Label6" runat="server" Text="XYZ Balance" /></th>
</tr>
<thead>
<tr>
<th data-options="field:'accountName',width:270"><asp:Label ID="LabelGridHeaderAccountName" runat="server" Text="XYZ Description" /></th>
<th data-options="field:'deltaPos',width:70,align:'right'"><asp:Label ID="LabelGridHeaderDeltaPositive2" runat="server" Text="XYZ Debit" /></th>
<th data-options="field:'deltaNeg',width:70,align:'right'"><asp:Label ID="LabelGridHeaderDeltaNegative2" runat="server" Text="XYZ Credit" /></th>
<th data-options="field:'dateTime',width:90"><asp:Label ID="LabelGridHeaderDateTimeEntered" runat="server" Text="XYZ DateTime" /></th>
<th data-options="field:'initials',width:50"><asp:Label ID="LabelGridHeaderInitials" runat="server" Text="ID#"/></th>
</tr>
</thead>
</table>
</table>
<div id="DivModalFields" class="entryFields">
ModalFields
</div>
@@ -68,8 +68,13 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
this.LabelGridHeaderDescription.Text = Global.Global_Description;
this.LabelGridHeaderId.Text = Resources.Pages.Ledgers.InspectLedgers_TransactionId;
this.LabelGridHeaderAccountName.Text = Resources.Pages.Ledgers.InspectLedgers_AccountName;
this.LabelGridHeaderDateTimeEntered.Text = Resources.Pages.Ledgers.InspectLedgers_LoggedByInitials;
this.LabelGridHeaderDeltaNegative2.Text = Global.Ledgers_Credit;
this.LabelGridHeaderDeltaPositive2.Text = Global.Ledgers_Debit;
this.LabelGridHeaderInitials.Text = Resources.Pages.Ledgers.InspectLedgers_LoggedByInitials;
this.LabelFlagNotAvailable.Text = Resources.Pages.Ledgers.InspectLedgers_FlaggingNotAvailable;
this.LabelInspectNotAvailable.Text = Resources.Pages.Ledgers.InspectLedgers_InspectNotAvailable;
// if write access
@@ -0,0 +1 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-InspectLedgerTxData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.Json_InspectLedgerTxData" %>
@@ -0,0 +1,103 @@
using System;
using System.Globalization;
using System.Text;
using Swarmops.Common.Enums;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
namespace Swarmops.Frontend.Pages.v5.Ledgers
{
public partial class Json_InspectLedgerTxData : DataV5Base
{
protected void Page_Load (object sender, EventArgs e)
{
Response.ContentType = "application/json";
string transactionIdString = Request.QueryString["TxId"];
string emptyResponse = "[{\"id\":\"-\",\"accountName\":\"" +
JsonSanitize (Resources.Pages.Ledgers.InspectLedgers_EmptyTransaction) + "\"}]";
if (string.IsNullOrEmpty (transactionIdString) || transactionIdString == "undefined")
{
Response.Output.WriteLine (emptyResponse);
Response.End();
}
int transactionId = Int32.Parse (transactionIdString);
DateTime dawnOfMankind = new DateTime (1901, 1, 1);
// no org will ever import bookkeeping from before this date
if (transactionId <= 0)
{
Response.Output.WriteLine (emptyResponse);
Response.End();
}
FinancialTransaction transaction = FinancialTransaction.FromIdentity (transactionId);
if (transaction.OrganizationId != CurrentOrganization.Identity)
{
throw new UnauthorizedAccessException ("All the nopes in the world");
}
if (!CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
{
throw new UnauthorizedAccessException ("Access denied because security tokens say so");
}
bool listDetails = false;
if (CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
{
listDetails = true;
}
FinancialTransactionRows rows = transaction.Rows;
// SIGNOFF: CONTINUE HERE BUILDING JSON DATA FOR TRANSACTION
StringBuilder result = new StringBuilder (16384);
foreach (FinancialTransactionRow row in rows)
{
string creditString = string.Empty;
string debitString = string.Empty;
if (row.AmountCents < 0)
{
creditString = String.Format ("{0:N0}", row.AmountCents/100.0);
}
else if (row.AmountCents > 0)
{
debitString = String.Format ("{0:N0}", row.AmountCents/100.0);
}
string actionHtml = String.Format (
"<img src=\"/Images/Icons/iconshock-magnifyingglass-16px.png\" class=\"LocalIconInspect\" txId=\"{0}\" />&nbsp;<img src=\"/Images/Icons/iconshock-flag-white-16px.png\" class=\"LocalIconFlag\" txId=\"{0}\" />",
row.FinancialTransactionId.ToString (CultureInfo.InvariantCulture));
result.Append ("{" + String.Format (
"\"id\":\"{0}\",\"dateTime\":\"{1:MMM-dd HH:mm}\",\"accountName\":\"{2}\"," +
"\"deltaPos\":\"{3}\",\"deltaNeg\":\"{4}\",\"initials\":\"{5}\"",
row.FinancialTransactionId,
row.CreatedDateTime,
JsonSanitize (row.AccountName),
debitString,
creditString,
row.CreatedByPerson.Initials) + "},");
}
if (rows.Count == 0)
{
// If there are no transactions in this time period, say so
result.Append ("{\"description\":\"" +
JsonSanitize (Resources.Pages.Ledgers.InspectLedgers_NoTransactions) + "\"},");
}
Response.Output.WriteLine ("[" + result.ToString().TrimEnd (',') + "]");
Response.End();
}
}
}
@@ -20,7 +20,7 @@ namespace Swarmops.Frontend.Pages.Swarm
Geography geography = Geography.FromIdentity (geographyId);
if (
!CurrentUser.HasAccess (new Access (CurrentOrganization, geography, AccessAspect.PersonData,
!CurrentUser.HasAccess (new Access (CurrentOrganization, geography, AccessAspect.PersonalData,
AccessType.Read)))
{
throw new UnauthorizedAccessException ("nope");