diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx
index faffdf14..90dc9def 100644
--- a/Site5/App_GlobalResources/Pages.Ledgers.resx
+++ b/Site5/App_GlobalResources/Pages.Ledgers.resx
@@ -124,6 +124,10 @@
P&L for {0} for
The {0} is the organization name. The year number follows this string.
+
+ ProfitLoss
+ Must ONLY contain A-Z, a-z characters - nothing accented!
+
The P&L is an overview of income and expenditures, which are grouped by budgets or cost/income type. The sum of all income and expenditure is the yearly result. You may also want to look at the <a href="BalanceSheet.aspx">balance sheet</a> which is the overview of assets and debts.
diff --git a/Site5/Images/Icons/iconshock-downarrow-16px.png b/Site5/Images/Icons/iconshock-downarrow-16px.png
new file mode 100644
index 00000000..c6c7f757
Binary files /dev/null and b/Site5/Images/Icons/iconshock-downarrow-16px.png differ
diff --git a/Site5/Images/Icons/iconshock-downarrow-40px.png b/Site5/Images/Icons/iconshock-downarrow-40px.png
new file mode 100644
index 00000000..f0f46cae
Binary files /dev/null and b/Site5/Images/Icons/iconshock-downarrow-40px.png differ
diff --git a/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx b/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx
new file mode 100644
index 00000000..eff5552d
--- /dev/null
+++ b/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx
@@ -0,0 +1 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Csv-ProfitLossData.aspx.cs" Inherits="Pages_v5_Ledgers_Csv_ProfitLossData" %>
diff --git a/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx.cs b/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx.cs
new file mode 100644
index 00000000..bd985e65
--- /dev/null
+++ b/Site5/Pages/v5/Ledgers/Csv-ProfitLossData.aspx.cs
@@ -0,0 +1,106 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using Activizr.Basic.Enums;
+using Activizr.Logic.Financial;
+using Activizr.Logic.Pirates;
+using Activizr.Logic.Security;
+using Activizr.Logic.Structure;
+using System.Globalization;
+
+public partial class Pages_v5_Ledgers_Csv_ProfitLossData : System.Web.UI.Page
+{
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ // Current authentication
+
+ string identity = HttpContext.Current.User.Identity.Name;
+ string[] identityTokens = identity.Split(',');
+
+ string userIdentityString = identityTokens[0];
+ string organizationIdentityString = identityTokens[1];
+
+ int currentUserId = Convert.ToInt32(userIdentityString);
+ int currentOrganizationId = Convert.ToInt32(organizationIdentityString);
+
+ Person currentUser = Person.FromIdentity(currentUserId);
+ Authority authority = currentUser.GetAuthority();
+ Organization currentOrganization = Organization.FromIdentity(currentOrganizationId);
+
+ // Get culture
+
+ string cultureString = "en-US";
+ HttpCookie cookie = Request.Cookies["PreferredCulture"];
+
+ if (cookie != null)
+ {
+ cultureString = cookie.Value;
+ }
+
+ _renderCulture = new CultureInfo(cultureString);
+
+ // Get current year
+
+ _year = DateTime.Today.Year;
+
+ string yearParameter = Request.QueryString["Year"];
+
+ if (!string.IsNullOrEmpty(yearParameter))
+ {
+ _year = Int32.Parse(yearParameter); // will throw if non-numeric - don't matter for app
+ }
+
+ YearlyReport report = YearlyReport.Create(currentOrganization, _year, FinancialAccountType.Result);
+
+ Response.ClearContent();
+ Response.ClearHeaders();
+ Response.ContentType = "text/plain";
+ Response.AppendHeader("Content-Disposition", "attachment;filename=" + Resources.Pages.Ledgers.ProfitLossStatement_DownloadFileName + _year.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.Today.ToString("yyyyMMdd") + ".csv");
+
+ if (_year == DateTime.Today.Year)
+ {
+ Response.Output.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"", Resources.Pages.Ledgers.ProfitLossStatement_AccountName, Resources.Pages.Ledgers.ProfitLossStatement_LastYear,
+ Resources.Pages.Ledgers.ProfitLossStatement_Q1, Resources.Pages.Ledgers.ProfitLossStatement_Q2, Resources.Pages.Ledgers.ProfitLossStatement_Q3, Resources.Pages.Ledgers.ProfitLossStatement_Q4,
+ Resources.Pages.Ledgers.ProfitLossStatement_Ytd);
+ }
+ else
+ {
+ Response.Output.WriteLine("\"{0}\",\"{1}\",\"{6}-{2}\",\"{6}-{3}\",\"{6}-{4}\",\"{6}-{5}\",\"{6}\"", Resources.Pages.Ledgers.ProfitLossStatement_AccountName, _year-1,
+ Resources.Pages.Ledgers.ProfitLossStatement_Q1, Resources.Pages.Ledgers.ProfitLossStatement_Q2, Resources.Pages.Ledgers.ProfitLossStatement_Q3, Resources.Pages.Ledgers.ProfitLossStatement_Q4,
+ _year);
+ }
+
+ RecurseCsvReport(report.ReportLines, string.Empty);
+
+ Response.End();
+ }
+
+ private int _year = 2012;
+ private CultureInfo _renderCulture;
+
+ private void RecurseCsvReport (List reportLines, string accountPrefix)
+ {
+ foreach (YearlyReportLine line in reportLines)
+ {
+ Response.Output.WriteLine("\"{0}{1}\",{2},{3},{4},{5},{6},{7}",
+ accountPrefix, line.AccountName,
+ line.AccountValues.PreviousYear / -100.0,
+ line.AccountValues.Quarters[0] / -100.0,
+ line.AccountValues.Quarters[1] / -100.0,
+ line.AccountValues.Quarters[2] / -100.0,
+ line.AccountValues.Quarters[3] / -100.0,
+ line.AccountValues.ThisYear / -100.0);
+
+
+ if (line.Children.Count > 0)
+ {
+ RecurseCsvReport(line.Children, "-" + accountPrefix);
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx b/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx
index c7a8a0af..28aab6ec 100644
--- a/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx
+++ b/Site5/Pages/v5/Ledgers/ProfitLossStatement.aspx
@@ -29,6 +29,9 @@
$('span.loadingHeader').hide();
var selectedYear = $('#<%=DropYears.ClientID %>').val();
+
+ $('div#linkDownloadReport').attr("onclick", "document.location='Csv-ProfitLossData.aspx?Year=" + selectedYear + "';");
+ $('#spanDownloadText').text('<%=Resources.Pages.Ledgers.ProfitLossStatement_DownloadFileName %>' + selectedYear + "-<%=DateTime.Today.ToString("yyyyMMdd") %>.csv");
if (selectedYear == currentYear)
{
@@ -74,6 +77,9 @@
color: #1C397E;
letter-spacing: 1px;
}
+ table.datagrid-ftable {
+ font-weight: 500;
+ }
@@ -99,5 +105,16 @@
+
+
+
+
+
+
+
ProfitLossxxxx-yyyymmdd.csv
+
+
+
+