Code cleanup

This commit is contained in:
Rick Falkvinge
2015-03-05 13:06:48 +01:00
parent 3dea0efc3d
commit 76ad02489b
2 changed files with 220 additions and 198 deletions
+99 -102
View File
@@ -1,5 +1,5 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="InspectLedgers.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.InspectLedgers" %>
<%@ Import Namespace="System.Net.Mime" %>
<%@ Import Namespace="Resources" %>
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="CurrencyTextBox" Src="~/Controls/v5/Financial/CurrencyTextBox.ascx" %>
@@ -54,7 +54,7 @@
$('#gridTransaction').datagrid({
onLoadSuccess: function() {
// Dynamic reloading screws up resizing for some reason, so we'll have to resize the tx grid manually.
var heightBody = $('div#divModalCover table.datagrid-btable').height();
@@ -69,15 +69,15 @@
}
});
$('#<%=DropYears.ClientID %>').change(function () {
$('#<%= DropYears.ClientID %>').change(function() {
reloadData();
});
$('#<%=DropMonths.ClientID %>').change(function () {
$('#<%= DropMonths.ClientID %>').change(function() {
reloadData();
});
$("#IconCloseEdit").click(function () {
$("#IconCloseEdit").click(function() {
$('#divModalCover').fadeOut();
if (transactionDirty) {
@@ -90,11 +90,11 @@
addTransactionRow();
});
currentYear = $('#<%=DropYears.ClientID %>').val();
currentYear = $('#<%= DropYears.ClientID %>').val();
$('div.datagrid').css('opacity', 0.4);
});
var accountId = 0;
var transactionId = 0;
var transactionDirty = false;
@@ -105,12 +105,12 @@
}
function addTransactionRow() {
var amountString = $('#<%=TextInsertAmount.ClientID%>_Input').val();
var amountString = $('#<%= TextInsertAmount.ClientID %>_Input').val();
var rowAccountId = 0;
var selectedAccountNode = $('#<%=this.BudgetAddRow.ClientID%>_DropBudgets').combotree('tree').tree('getSelected');
var selectedAccountNode = $('#<%= BudgetAddRow.ClientID %>_DropBudgets').combotree('tree').tree('getSelected');
if (selectedAccountNode == null || selectedAccountNode.id < 1) {
alertify.error (unescape('<asp:Literal ID="LiteralErrorAddRowSelectAccount" runat="server" />'));
alertify.error(unescape('<asp:Literal ID="LiteralErrorAddRowSelectAccount" runat="server" />');
return;
}
@@ -134,25 +134,24 @@
$('#gridTransaction').datagrid('reload');
prefillUnbalancedAmount();
} else {
alertify.error("<%= Resources.Global.Error_AjaxCallException %>");
alertify.error("<%= Global.Error_AjaxCallException %>");
}
},
error: function(msg) {
alertify.error("<%= Resources.Global.Error_AjaxCallException %>");
alertify.error("<%= Global.Error_AjaxCallException %>");
}
});
}
}
}
function reloadData()
{
var selectedYear = $('#<%=DropYears.ClientID %>').val();
var selectedMonth = $('#<%=DropMonths.ClientID %>').val();
function reloadData() {
var selectedYear = $('#<%= DropYears.ClientID %>').val();
var selectedMonth = $('#<%= DropMonths.ClientID %>').val();
currentYear = selectedYear;
closedLedgers = (currentYear <= ledgersClosedUntil);
currentYear = selectedYear;
closedLedgers = (currentYear <= ledgersClosedUntil);
$('#gridLedgers').datagrid({ url: 'Json-InspectLedgerData.aspx?Year=' + selectedYear + "&Month=" + selectedMonth + "&AccountId=" + accountId});
$('#gridLedgers').datagrid({ url: 'Json-InspectLedgerData.aspx?Year=' + selectedYear + "&Month=" + selectedMonth + "&AccountId=" + accountId });
$('#imageLoadIndicator').show();
$('div.datagrid').css('opacity', 0.4);
@@ -173,105 +172,102 @@
dataType: "json",
success: function(msg) {
if (msg.d.length > 1) {
$('#<%=this.TextInsertAmount.ClientID%>_Input').val(msg.d);
$('#<%= TextInsertAmount.ClientID %>_Input').val(msg.d);
} else {
alertify.error("<%= Resources.Global.Error_AjaxCallException %>");
alertify.error("<%= Global.Error_AjaxCallException %>");
}
},
error: function(msg) {
alertify.error("<%= Resources.Global.Error_AjaxCallException %>");
}
});
alertify.error("<%= Global.Error_AjaxCallException %>");
}
});
}
function onInspectTransaction(transactionId) {
window.scrollTo(0, 0);
$('body').css('overflow-y', 'hidden');
$('#divModalCover').fadeIn();
$('span#spanModalTransactionId').text(transactionId);
function onInspectTransaction(transactionId) {
window.scrollTo(0, 0);
$('body').css('overflow-y', 'hidden');
$('#divModalCover').fadeIn();
$('span#spanModalTransactionId').text(transactionId);
$('#gridTransaction').datagrid({ url: 'Json-InspectLedgerTxData.aspx?TxId=' + transactionId });
$('#gridTransaction').datagrid({ url: 'Json-InspectLedgerTxData.aspx?TxId=' + transactionId });
var jsonData = {};
jsonData.txId = transactionId;
var jsonData = {};
jsonData.txId = transactionId;
if (canWriteRows && !closedLedgers) {
prefillUnbalancedAmount();
}
if (canWriteRows && !closedLedgers) {
prefillUnbalancedAmount();
}
if (canSeeDetail || canWriteRows) {
$.ajax({
type: "POST",
url: "/Pages/v5/Ledgers/InspectLedgers.aspx/GetTransactionTracking",
data: $.toJSON(jsonData),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
if (msg.d.length > 1) {
$('#divTransactionTrackingDetails').html(msg.d);
$('#divTransactionTrackingDetails').show();
$('#divEditTransaction').hide();
if (canSeeDetail || canWriteRows) {
$.ajax({
type: "POST",
url: "/Pages/v5/Ledgers/InspectLedgers.aspx/GetTransactionTracking",
data: $.toJSON(jsonData),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
if (msg.d.length > 1) {
$('#divTransactionTrackingDetails').html(msg.d);
$('#divTransactionTrackingDetails').show();
$('#divEditTransaction').hide();
$("a.FancyBox_Gallery").fancybox({
'overlayShow': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'image',
'opacity': true
});
$("a.FancyBox_Gallery").fancybox({
'overlayShow': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'image',
'opacity': true
});
$("a.linkViewDox").click(function() {
$("a.FancyBox_Gallery[rel='" + $(this).attr("objectId") + "']").first().click();
});
$("a.linkViewDox").click(function() {
$("a.FancyBox_Gallery[rel='" + $(this).attr("objectId") + "']").first().click();
});
} else {
$('#divTransactionTracking').hide();
} else {
$('#divTransactionTracking').hide();
if (canWriteRows && !closedLedgers) {
$('#divEditTransaction').show();
} else {
$('#divEditTransaction').hide();
}
}
},
error: function(msg) {
alertify.error("<%= Resources.Global.Error_AjaxCallException %>");
if (canWriteRows && !closedLedgers) {
$('#divEditTransaction').show();
} else {
$('#divEditTransaction').hide();
}
}
},
error: function(msg) {
alertify.error("<%= Global.Error_AjaxCallException %>");
}
});
} else {
$('#divEditTransaction').hide();
$('#divTransactionTracking').hide();
}
} else {
$('#divEditTransaction').hide();
$('#divTransactionTracking').hide();
}
}
function onFlagTransaction(transactionId) {
alertify.log('<asp:Label ID="LabelFlagNotAvailable" runat="server" />');
}
function onFlagTransaction(transactionId) {
alertify.log('<asp:Label ID="LabelFlagNotAvailable" runat="server" />');
}
// the variables below only handle the cosmetics and not actual access
var canSeeDetail = <asp:Literal ID="LiteralDetailAccess" runat="server" />;
var canWriteRows = <asp:Literal ID="LiteralWriteAccess" runat="server" />;
var canAuditTx = <asp:Literal ID="LiteralAuditAccess" runat="server" />;
// the variables below only handle the cosmetics and not actual access
var canSeeDetail = <asp:Literal ID="LiteralDetailAccess" runat="server" />;
var canWriteRows = <asp:Literal ID="LiteralWriteAccess" runat="server" />;
var canAuditTx = <asp:Literal ID="LiteralAuditAccess" runat="server" />;
var ledgersClosedUntil = <asp:Literal ID="LiteralLedgersClosedUntil" runat="server" />;
var currentYear = 0;
var ledgersClosedUntil = <asp:Literal ID="LiteralLedgersClosedUntil" runat="server" />;
var currentYear = 0;
var closedLedgers = false;
</script>
</script>
<style type="text/css">
.datagrid-row-selected,.datagrid-row-over{
background:transparent;
}
table.datagrid-ftable {
font-weight: 500;
}
.datagrid-row-selected, .datagrid-row-over { background: transparent; }
table.datagrid-ftable { font-weight: 500; }
.LocalIconInspect, .LocalIconFlag {
cursor:pointer;
cursor: pointer;
position: relative;
top: 4px;
}
@@ -281,19 +277,20 @@
animation: blink 0.5s linear infinite;
}
@keyframes blink {
0% { color: darkred; }
100% { color: red; }
}
@-webkit-keyframes blink {
@keyframes blink {
0% { color: darkred; }
100% { color: red; }
}
span.hiddenDocLinks {
display: none;
@-webkit-keyframes blink {
0% { color: darkred; }
100% { color: red; }
}
span.hiddenDocLinks { display: none; }
</style>
</asp:Content>
@@ -301,9 +298,9 @@
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<h2><asp:Label ID="LabelHeaderInspect" runat="server" /> <Swarmops5:ComboBudgets ID="DropBudgets" OnClientSelect="onAccountSelected" ListType="All" runat="server" /> <asp:Label ID="LabelHeaderInspectFor" runat="server" /> <asp:DropDownList runat="server" ID="DropYears"/> <asp:DropDownList runat="server" ID="DropMonths"/></h2>
<h2><asp:Label ID="LabelHeaderInspect" runat="server" /> <Swarmops5:ComboBudgets ID="DropBudgets" OnClientSelect=" onAccountSelected " ListType="All" runat="server" /> <asp:Label ID="LabelHeaderInspectFor" runat="server" /> <asp:DropDownList runat="server" ID="DropYears"/> <asp:DropDownList runat="server" ID="DropMonths"/></h2>
<table id="gridLedgers" class="easyui-datagrid" style="width:680px;height:500px"
<table id="gridLedgers" class="easyui-datagrid" style="width: 680px; height: 500px"
data-options="rownumbers:false,singleSelect:false,nowrap:false,fitColumns:true,fit:false,showFooter:false,loading:false,selectOnCheck:true,checkOnSelect:true,url:'Json-InspectLedgerData.aspx'"
idField="id">
<thead>
@@ -322,9 +319,9 @@
<div id="divModalCover" class="modalcover">
<div id="divModalBox" class="box modal">
<div class="content" style="overflow:hidden">
<div class="content" style="overflow: hidden">
<div class="divIconCloseModal"><img id="IconCloseEdit" src="/Images/Icons/iconshock-cross-16px.png" /></div><h2><asp:Literal ID="LiteralEditHeader" runat="server"/></h2>
<table id="gridTransaction" class="easyui-datagrid" style="width:910px"
<table id="gridTransaction" class="easyui-datagrid" style="width: 910px"
data-options="rownumbers:false,singleSelect:false,nowrap:false,fitColumns:true,fit:true,showFooter:false,loading:false,selectOnCheck:true,checkOnSelect:true,url:'Json-InspectLedgerTxData.aspx'"
idField="id">
<thead>
+121 -96
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Web;
using System.Web.Services;
using System.Web.UI.WebControls;
@@ -10,22 +9,21 @@ using Swarmops.Common.Enums;
using Swarmops.Common.Interfaces;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
namespace Swarmops.Frontend.Pages.v5.Ledgers
{
public partial class InspectLedgers : PageV5Base
{
protected void Page_Load(object sender, EventArgs e)
protected void Page_Load (object sender, EventArgs e)
{
if (!CurrentOrganization.IsEconomyEnabled)
{
Response.Redirect("/Pages/v5/Financial/EconomyNotEnabled.aspx", true);
Response.Redirect ("/Pages/v5/Financial/EconomyNotEnabled.aspx", true);
return;
}
PageAccessRequired = new Access(CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read);
PageAccessRequired = new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read);
DbVersionRequired = 0; // base schema is fine
PageTitle = Resources.Pages.Ledgers.InspectLedgers_PageTitle;
InfoBoxLiteral = Resources.Pages.Ledgers.InspectLedgers_Info;
@@ -39,28 +37,28 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
while (year >= firstYear)
{
this.DropYears.Items.Add(year.ToString(CultureInfo.InvariantCulture));
this.DropYears.Items.Add (year.ToString (CultureInfo.InvariantCulture));
year--;
}
for (int monthNumber = 1; monthNumber <= 12; monthNumber++)
{
this.DropMonths.Items.Add(new ListItem(new DateTime(2014, monthNumber, 1).ToString("MMM"),
monthNumber.ToString(CultureInfo.InvariantCulture))); // will autolocalize
this.DropMonths.Items.Add (new ListItem (new DateTime (2014, monthNumber, 1).ToString ("MMM"),
monthNumber.ToString (CultureInfo.InvariantCulture))); // will autolocalize
}
this.DropMonths.Items.Add(new ListItem(Global.Global_Q1, "21"));
this.DropMonths.Items.Add (new ListItem (Global.Global_Q1, "21"));
// quarters and all-year are coded as fake month numbers
this.DropMonths.Items.Add(new ListItem(Global.Global_Q2, "22"));
this.DropMonths.Items.Add(new ListItem(Global.Global_Q3, "23"));
this.DropMonths.Items.Add(new ListItem(Global.Global_Q4, "24"));
this.DropMonths.Items.Add(new ListItem(Global.Global_AllYear, "31"));
this.DropMonths.Items.Add (new ListItem (Global.Global_Q2, "22"));
this.DropMonths.Items.Add (new ListItem (Global.Global_Q3, "23"));
this.DropMonths.Items.Add (new ListItem (Global.Global_Q4, "24"));
this.DropMonths.Items.Add (new ListItem (Global.Global_AllYear, "31"));
this.DropYears.SelectedIndex = 0;
this.DropMonths.SelectedValue = today.Month.ToString(CultureInfo.InvariantCulture);
this.DropMonths.SelectedValue = today.Month.ToString (CultureInfo.InvariantCulture);
}
RegisterControl(EasyUIControl.DataGrid | EasyUIControl.Tree);
RegisterControl (EasyUIControl.DataGrid | EasyUIControl.Tree);
Localize();
}
@@ -92,15 +90,15 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
// if write access
if (
CurrentUser.HasAccess(new Access(CurrentOrganization, AccessAspect.BookkeepingDetails,
CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails,
AccessType.Write)))
{
this.LiteralEditHeader.Text = Resources.Pages.Ledgers.InspectLedgers_EditingTransactionX;
this.LabelAddRowAccount.Text = Resources.Global.Financial_Account;
this.LabelAddRowAmount.Text = Resources.Global.Financial_Amount;
this.LabelAddRowAccount.Text = Global.Financial_Account;
this.LabelAddRowAmount.Text = Global.Financial_Amount;
this.LiteralErrorAddRowSelectAccount.Text =
Resources.Pages.Ledgers.InspectLedgers_TxDetail_ErrorAddRowNoAccount;
this.LiteralAddRowButton.Text = Resources.Global.Global_Add;
this.LiteralAddRowButton.Text = Global.Global_Add;
}
else // read access, at a minimum of AccessAspect.Bookkeeping
{
@@ -110,15 +108,16 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
// Access helpers to JavaScript (these don't actually determine access, but help in UI prettiness)
this.LiteralAuditAccess.Text =
(CurrentUser.HasAccess(new Access(CurrentOrganization, AccessAspect.Auditing, AccessType.Write)))
(CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Auditing, AccessType.Write)))
? "true"
: "false";
this.LiteralWriteAccess.Text =
(CurrentUser.HasAccess(new Access(CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Write)))
(CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Write)))
? "true"
: "false";
this.LiteralDetailAccess.Text =
(CurrentUser.HasAccess(new Access(CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read)))
(CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails,
AccessType.Read)))
? "true"
: "false";
@@ -126,32 +125,32 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
}
[WebMethod]
public static bool AddTransactionRow(int txId, int accountId, string amountString)
public static bool AddTransactionRow (int txId, int accountId, string amountString)
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
if (
!authData.CurrentUser.HasAccess(new Access(authData.CurrentOrganization,
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
AccessAspect.Bookkeeping, AccessType.Write)))
{
return false; // fail
}
FinancialTransaction transaction = FinancialTransaction.FromIdentity(txId);
FinancialTransaction transaction = FinancialTransaction.FromIdentity (txId);
if (authData.CurrentOrganization.Parameters.FiscalBooksClosedUntilYear >= transaction.DateTime.Year)
{
return false; // can't edit closed books
}
FinancialAccount account = FinancialAccount.FromIdentity(accountId);
FinancialAccount account = FinancialAccount.FromIdentity (accountId);
Double amountFloat = Double.Parse(amountString);
Int64 amountCents = (Int64)(amountFloat * 100.0);
Double amountFloat = Double.Parse (amountString);
Int64 amountCents = (Int64) (amountFloat*100.0);
if (account.OrganizationId != authData.CurrentOrganization.Identity)
{
throw new InvalidOperationException("Account/Organization mismatch");
throw new InvalidOperationException ("Account/Organization mismatch");
}
if (amountCents == 0)
@@ -159,41 +158,41 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
return false;
}
transaction.AddRow(account, amountCents, authData.CurrentUser);
transaction.AddRow (account, amountCents, authData.CurrentUser);
return true;
}
[WebMethod]
public static string GetUnbalancedAmount(int txId)
public static string GetUnbalancedAmount (int txId)
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
if (
!authData.CurrentUser.HasAccess(new Access(authData.CurrentOrganization,
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
AccessAspect.Bookkeeping, AccessType.Read)))
{
return string.Empty; // leave no clue to an attacker why the call failed
}
FinancialTransaction transaction = FinancialTransaction.FromIdentity(txId);
FinancialTransaction transaction = FinancialTransaction.FromIdentity (txId);
return (-transaction.Rows.AmountCentsTotal / 100.0).ToString("N2");
return (-transaction.Rows.AmountCentsTotal/100.0).ToString ("N2");
}
[WebMethod]
public static string GetTransactionTracking(int txId)
public static string GetTransactionTracking (int txId)
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
if (
!authData.CurrentUser.HasAccess(new Access(authData.CurrentOrganization,
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
AccessAspect.BookkeepingDetails, AccessType.Read)))
{
return string.Empty; // leave no clue to an attacker why the call failed
}
FinancialTransaction transaction = FinancialTransaction.FromIdentity(txId);
FinancialTransaction transaction = FinancialTransaction.FromIdentity (txId);
IHasIdentity dependency = transaction.Dependency;
@@ -202,19 +201,19 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
return string.Empty;
}
return GetTrackingDetails(dependency);
return GetTrackingDetails (dependency);
}
private static string GetTrackingDetails(object someObject)
private static string GetTrackingDetails (object someObject)
{
string objectType = someObject.GetType().Name;
switch (objectType)
{
case "Payout":
Payout payout = (Payout)someObject;
Payout payout = (Payout) someObject;
string result =
String.Format(Resources.Pages.Ledgers.InspectLedgers_TxDetail_ThisIsPayoutX, payout.Identity) +
String.Format (Resources.Pages.Ledgers.InspectLedgers_TxDetail_ThisIsPayoutX, payout.Identity) +
" ";
List<string> subValidations = new List<string>();
@@ -224,16 +223,24 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
{
if (payout.DependentExpenseClaims.Count == 1)
{
subResults.Add("<strong>" + String.Format(Resources.Global.Financial_ExpenseClaimSpecificationWithClaimer, payout.DependentExpenseClaims[0].Identity, HttpUtility.HtmlEncode(payout.DependentExpenseClaims[0].Claimer.Name)) + ".</strong>");
subResults.Add ("<strong>" +
String.Format (Global.Financial_ExpenseClaimSpecificationWithClaimer,
payout.DependentExpenseClaims[0].Identity,
HttpUtility.HtmlEncode (payout.DependentExpenseClaims[0].Claimer.Name)) +
".</strong>");
}
else
{
subResults.Add("<strong>" + String.Format(Resources.Global.Financial_ExpenseClaimsSpecificationWithClaimer, Formatting.GenerateRangeString(payout.DependentExpenseClaims.Identities), HttpUtility.HtmlEncode(payout.DependentExpenseClaims[0].Claimer.Name)) + ".</strong>");
subResults.Add ("<strong>" +
String.Format (Global.Financial_ExpenseClaimsSpecificationWithClaimer,
Formatting.GenerateRangeString (payout.DependentExpenseClaims.Identities),
HttpUtility.HtmlEncode (payout.DependentExpenseClaims[0].Claimer.Name)) +
".</strong>");
}
foreach (ExpenseClaim claim in payout.DependentExpenseClaims)
{
subValidations.Add(GetObjectDetails(claim));
subValidations.Add (GetObjectDetails (claim));
}
}
@@ -241,11 +248,16 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
{
if (payout.DependentCashAdvancesPayback.Count == 1)
{
subResults.Add("<strong>" + String.Format(Resources.Global.Financial_CashAdvancePaybackSpecification, payout.DependentCashAdvancesPayback[0].Identity) + ".</strong>");
subResults.Add ("<strong>" +
String.Format (Global.Financial_CashAdvancePaybackSpecification,
payout.DependentCashAdvancesPayback[0].Identity) + ".</strong>");
}
else
{
subResults.Add("<strong>" + String.Format(Resources.Global.Financial_CashAdvancePaybacksSpecification, Formatting.GenerateRangeString(payout.DependentExpenseClaims.Identities)) + ".</strong>");
subResults.Add ("<strong>" +
String.Format (Global.Financial_CashAdvancePaybacksSpecification,
Formatting.GenerateRangeString (payout.DependentExpenseClaims.Identities)) +
".</strong>");
}
}
@@ -255,16 +267,21 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
if (payout.DependentCashAdvancesPayout.Count == 1)
{
subResults.Add("<strong>" + String.Format(Resources.Global.Financial_CashAdvanceLongSpecificationWithRecipient, advance0.Identity, advance0.Person.Name) + ".</strong>");
subResults.Add ("<strong>" +
String.Format (Global.Financial_CashAdvanceLongSpecificationWithRecipient,
advance0.Identity, advance0.Person.Name) + ".</strong>");
}
else
{
subResults.Add("<strong>" + String.Format(Resources.Global.Financial_CashAdvancesLongSpecificationWithRecipient, Formatting.GenerateRangeString(payout.DependentExpenseClaims.Identities), advance0.Person.Name) + ".</strong>");
subResults.Add ("<strong>" +
String.Format (Global.Financial_CashAdvancesLongSpecificationWithRecipient,
Formatting.GenerateRangeString (payout.DependentExpenseClaims.Identities),
advance0.Person.Name) + ".</strong>");
}
foreach (CashAdvance advance in payout.DependentCashAdvancesPayout)
{
subValidations.Add(GetObjectDetails(advance));
subValidations.Add (GetObjectDetails (advance));
}
}
@@ -274,11 +291,11 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
InboundInvoice invoice = payout.DependentInvoices[0];
subResults.Add("<strong>" + String.Format(
Resources.Global.Financial_InboundInvoiceSpecificationWithSender, invoice.Identity,
subResults.Add ("<strong>" + String.Format (
Global.Financial_InboundInvoiceSpecificationWithSender, invoice.Identity,
invoice.Supplier) + "</strong>");
subValidations.Add(GetObjectDetails(invoice));
subValidations.Add (GetObjectDetails (invoice));
}
if (payout.DependentSalariesNet.Count > 0)
@@ -287,12 +304,13 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
Salary salary = payout.DependentSalariesNet[0];
subResults.Add("<strong>" +
String.Format(Resources.Global.Financial_SalaryDualSpecificationWithRecipient,
salary.Identity, salary.PayoutDate, HttpUtility.HtmlEncode(salary.PayrollItem.PersonCanonical)) +
subResults.Add ("<strong>" +
String.Format (Global.Financial_SalaryDualSpecificationWithRecipient,
salary.Identity, salary.PayoutDate,
HttpUtility.HtmlEncode (salary.PayrollItem.PersonCanonical)) +
"</strong>");
subValidations.Add(GetObjectDetails(salary));
subValidations.Add (GetObjectDetails (salary));
}
if (payout.DependentSalariesTax.Count > 0)
@@ -301,35 +319,39 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
if (payout.DependentSalariesTax.Count == 1)
{
subResults.Add("<strong>" +
String.Format(Resources.Global.Financial_SalaryTaxDualSpecification, salary0.Identity, salary0.PayoutDate) + "</strong>");
subResults.Add ("<strong>" +
String.Format (Global.Financial_SalaryTaxDualSpecification, salary0.Identity,
salary0.PayoutDate) + "</strong>");
}
else
{
subResults.Add("<strong>" +
String.Format(Resources.Global.Financial_SalariesTaxSpecification, salary0.PayoutDate) + "</strong>");
subResults.Add ("<strong>" +
String.Format (Global.Financial_SalariesTaxSpecification, salary0.PayoutDate) +
"</strong>");
}
}
result +=
String.Join(" " + Resources.Pages.Ledgers.InspectLedgers_TxDetail_CombinedWith + " ",
subResults) + ". " + String.Format(Resources.Pages.Ledgers.InspectLedgers_TxDetail_PaidOutBy, payout.CreatedByPerson.Canonical);
String.Join (" " + Resources.Pages.Ledgers.InspectLedgers_TxDetail_CombinedWith + " ",
subResults) + ". " +
String.Format (Resources.Pages.Ledgers.InspectLedgers_TxDetail_PaidOutBy,
payout.CreatedByPerson.Canonical);
return "<p>" + result + "</p><p>" + String.Join("</p><p>", subValidations) + "</p>";
return "<p>" + result + "</p><p>" + String.Join ("</p><p>", subValidations) + "</p>";
case "ExpenseClaim":
case "CashAdvance":
case "InboundInvoice":
case "Salary":
return "<p>" + GetObjectDetails((IHasIdentity)someObject) + "</p>";
return "<p>" + GetObjectDetails ((IHasIdentity) someObject) + "</p>";
default:
return "Unimplemented dependency type: " + objectType;
}
}
private static string GetValidationDetails(FinancialValidations validations)
private static string GetValidationDetails (FinancialValidations validations)
{
string result = string.Empty;
@@ -337,12 +359,14 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
{
if (validation.ValidationType == FinancialValidationType.Attestation)
{
result += String.Format(Resources.Pages.Ledgers.InspectLedgers_TxDetail_AttestedByX + ". ", validation.Person.Canonical,
result += String.Format (Resources.Pages.Ledgers.InspectLedgers_TxDetail_AttestedByX + ". ",
validation.Person.Canonical,
validation.DateTime);
}
if (validation.ValidationType == FinancialValidationType.Validation)
{
result += String.Format(Resources.Pages.Ledgers.InspectLedgers_TxDetail_ValidatedByX + ". ", validation.Person.Canonical,
result += String.Format (Resources.Pages.Ledgers.InspectLedgers_TxDetail_ValidatedByX + ". ",
validation.Person.Canonical,
validation.DateTime);
}
}
@@ -350,7 +374,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
return result;
}
private static string GetDocumentDetails(Documents documents, IHasIdentity identifiableObject)
private static string GetDocumentDetails (Documents documents, IHasIdentity identifiableObject)
{
string docLink = string.Empty;
string objectIdString = identifiableObject.GetType().Name + identifiableObject.Identity;
@@ -362,62 +386,63 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
}
return "Documents were uploaded by " + documents[0].UploadedByPerson.Canonical + " at " +
documents[0].UploadedDateTime.ToString("yyyy-MMM-dd HH:mm") +
". <a href='#' class='linkViewDox' objectId='" + objectIdString + "'>View documents.</a><span class='hiddenDocLinks'>" + docLink + "</span>";
documents[0].UploadedDateTime.ToString ("yyyy-MMM-dd HH:mm") +
". <a href='#' class='linkViewDox' objectId='" + objectIdString +
"'>View documents.</a><span class='hiddenDocLinks'>" + docLink + "</span>";
}
private static string GetObjectDetails(IHasIdentity identifiableObject)
private static string GetObjectDetails (IHasIdentity identifiableObject)
{
switch (identifiableObject.GetType().Name)
{
case "ExpenseClaim":
ExpenseClaim claim = (ExpenseClaim)identifiableObject;
ExpenseClaim claim = (ExpenseClaim) identifiableObject;
return "<strong>" +
String.Format(Resources.Global.Financial_ExpenseClaimLongSpecification, claim.Identity) +
String.Format (Global.Financial_ExpenseClaimLongSpecification, claim.Identity) +
":</strong> " + claim.Organization.Currency.Code + " " +
(claim.AmountCents / 100.0).ToString("N2") + ". " +
HttpUtility.HtmlEncode(GetValidationDetails(claim.Validations)) + " " +
GetDocumentDetails(claim.Documents, claim);
(claim.AmountCents/100.0).ToString ("N2") + ". " +
HttpUtility.HtmlEncode (GetValidationDetails (claim.Validations)) + " " +
GetDocumentDetails (claim.Documents, claim);
case "CashAdvance":
CashAdvance advance = (CashAdvance)identifiableObject;
CashAdvance advance = (CashAdvance) identifiableObject;
return "<strong>" +
String.Format(Resources.Global.Financial_CashAdvanceSpecification, advance.Identity) +
String.Format (Global.Financial_CashAdvanceSpecification, advance.Identity) +
":</strong> " + advance.Organization.Currency.Code + " " +
(advance.AmountCents / 100.0).ToString("N2") + ". " +
HttpUtility.HtmlEncode(GetValidationDetails(advance.Validations));
(advance.AmountCents/100.0).ToString ("N2") + ". " +
HttpUtility.HtmlEncode (GetValidationDetails (advance.Validations));
case "InboundInvoice":
InboundInvoice invoice = (InboundInvoice)identifiableObject;
InboundInvoice invoice = (InboundInvoice) identifiableObject;
return "<strong>" +
String.Format(Resources.Global.Financial_InboundInvoiceSpecification, invoice.Identity) +
String.Format (Global.Financial_InboundInvoiceSpecification, invoice.Identity) +
":</strong> " + invoice.Organization.Currency.Code + " " +
(invoice.AmountCents / 100.0).ToString("N2") + ". " +
GetValidationDetails(invoice.Validations) + " " +
GetDocumentDetails(invoice.Documents, invoice);
(invoice.AmountCents/100.0).ToString ("N2") + ". " +
GetValidationDetails (invoice.Validations) + " " +
GetDocumentDetails (invoice.Documents, invoice);
case "Salary":
Salary salary = (Salary)identifiableObject;
Salary salary = (Salary) identifiableObject;
return "<strong>" +
String.Format(Resources.Global.Financial_SalaryIdentity, salary.Identity) +
String.Format (Global.Financial_SalaryIdentity, salary.Identity) +
":</strong> " +
String.Format(Resources.Pages.Ledgers.InspectLedgers_TxDetail_SalaryDetail,
String.Format (Resources.Pages.Ledgers.InspectLedgers_TxDetail_SalaryDetail,
salary.PayrollItem.Organization.Currency.Code,
salary.BaseSalaryCents / 100.0, // base salary
(salary.GrossSalaryCents - salary.BaseSalaryCents) / 100.0, // before-tax adjustments
salary.GrossSalaryCents / 100.0, // before-tax adjusted salary
salary.SubtractiveTaxCents / 100.0, // tax deduction
salary.BaseSalaryCents/100.0, // base salary
(salary.GrossSalaryCents - salary.BaseSalaryCents)/100.0, // before-tax adjustments
salary.GrossSalaryCents/100.0, // before-tax adjusted salary
salary.SubtractiveTaxCents/100.0, // tax deduction
(salary.NetSalaryCents + salary.SubtractiveTaxCents -
salary.GrossSalaryCents) / 100.0, // after-tax adjustments
salary.NetSalaryCents / 100.0) + // actual payout amount
" " + GetValidationDetails(salary.Validations);
salary.GrossSalaryCents)/100.0, // after-tax adjustments
salary.NetSalaryCents/100.0) + // actual payout amount
" " + GetValidationDetails (salary.Validations);
default:
throw new NotImplementedException("Unhandled object type in GetObjectDetails: " +
throw new NotImplementedException ("Unhandled object type in GetObjectDetails: " +
identifiableObject.GetType().Name);
}
}