diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj
index 20454f37..95d2c649 100644
--- a/Logic/Logic.csproj
+++ b/Logic/Logic.csproj
@@ -370,6 +370,12 @@
+
+
+
+
+
+
@@ -385,6 +391,12 @@
+
+
+
+
+
+
@@ -432,9 +444,12 @@
+
+
+
diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx
index 91f1161c..0e0c3102 100644
--- a/Site5/App_GlobalResources/Global.resx
+++ b/Site5/App_GlobalResources/Global.resx
@@ -555,4 +555,21 @@
There was a general, unspecified error contacting the Swarmops server. Is the network still operational and the server available?
+
+ Month
+
+
+ View
+ As in "inspect"
+
+
+ Year
+
+
+ Year/Month
+
+
+ Year {0}
+ As in "the year X".
+
\ No newline at end of file
diff --git a/Site5/App_GlobalResources/Menu5.resx b/Site5/App_GlobalResources/Menu5.resx
index 66e73be0..2ccad533 100644
--- a/Site5/App_GlobalResources/Menu5.resx
+++ b/Site5/App_GlobalResources/Menu5.resx
@@ -399,4 +399,10 @@
This is a temporary menu. Yes it's ugly now.
+
+ Tax Forms
+
+
+ Payroll Tax Forms
+
\ No newline at end of file
diff --git a/Site5/App_GlobalResources/Pages.Financial.resx b/Site5/App_GlobalResources/Pages.Financial.resx
index bfebcdd7..9973baba 100644
--- a/Site5/App_GlobalResources/Pages.Financial.resx
+++ b/Site5/App_GlobalResources/Pages.Financial.resx
@@ -342,6 +342,33 @@
Payout #{0:N0} was undone and everything restored.
+
+ Additive Tax
+ If applicable, translate to local legal tax term
+
+
+ Deducted Tax
+ If applicable, translate to local legal tax term
+
+
+ Gross Paycheck
+
+
+ View cheat sheets (completed tax forms) for the organization payroll, which are easy for you to copy to your actual tax forms, or possibly even print as is. Performance and actual forms vary by country and sometimes depend on third-party code and plugins.
+
+
+ Payroll Tax Forms
+
+
+ Monthly Tax Forms For {0} For
+ The {0} is the organization name. A country selector follows (imagine a "France" tacked on to the end).
+
+
+ Total Cost
+
+
+ Total Tax
+
Advance amount (in {0})
{0} is the currency.
diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx
index b5782a54..8c28b248 100644
--- a/Site5/App_GlobalResources/Pages.Ledgers.resx
+++ b/Site5/App_GlobalResources/Pages.Ledgers.resx
@@ -574,4 +574,31 @@
Projected Profit {0}
"Projected" as in "Budgeted". {0} is year.
+
+ Additive Tax
+ If applicable, translate to local legal tax term
+
+
+ Deducted Tax
+ If applicable, translate to local legal tax term
+
+
+ Gross Paycheck
+
+
+ View cheat sheets (completed tax forms) for the organization payroll, which are easy for you to copy to your actual tax forms, or possibly even print as is. Performance and actual forms vary by country and sometimes depend on third-party code and plugins.
+
+
+ Payroll Tax Forms
+
+
+ Monthly Tax Forms For
+ The {0} is the organization name. A country selector follows (imagine a "France" tacked on to the end).
+
+
+ Total Cost
+
+
+ Total Tax
+
\ No newline at end of file
diff --git a/Site5/Controls/v5/Base/AjaxTextBox.ascx.cs b/Site5/Controls/v5/Base/AjaxTextBox.ascx.cs
index 108463f1..f80fc618 100644
--- a/Site5/Controls/v5/Base/AjaxTextBox.ascx.cs
+++ b/Site5/Controls/v5/Base/AjaxTextBox.ascx.cs
@@ -20,8 +20,9 @@ namespace Swarmops.Frontend.Controls.v5.Base
set { this.TextInput.Text = value; }
}
- public void Focus()
+ public override void Focus()
{
+ base.Focus();
this.TextInput.Focus();
}
diff --git a/Site5/MainMenu-v5.xml b/Site5/MainMenu-v5.xml
index a68df664..2d3bd3dd 100644
--- a/Site5/MainMenu-v5.xml
+++ b/Site5/MainMenu-v5.xml
@@ -242,6 +242,16 @@
Disabled
+
+ Financial_Payroll_TaxForms
+ 3
+
+
+ /Pages/v5/Financial/ViewPayrollTaxForms.aspx
+ Link
+
+
+
@@ -341,8 +351,33 @@
Separator
-
-
+
+
+ Ledgers_TaxForms
+ 3
+
+ Submenu
+
+
+ Ledgers_TaxForms_Payroll
+ 3
+
+
+ /Pages/v5/Ledgers/TaxForms/PayrollForms.aspx
+ Link
+
+
+
+
+
+
+
+ 3
+ Separator
+
+
+
+
Ledgers_UploadBankFiles
3
diff --git a/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx b/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx
new file mode 100644
index 00000000..09971071
--- /dev/null
+++ b/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx
@@ -0,0 +1 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-Payroll-TaxFormData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.TaxForms.Json_PayrollData" %>
diff --git a/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx.cs b/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx.cs
new file mode 100644
index 00000000..569a9abe
--- /dev/null
+++ b/Site5/Pages/v5/Ledgers/TaxForms/Json-Payroll-TaxFormData.aspx.cs
@@ -0,0 +1,217 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using Swarmops.Basic.Enums;
+using Swarmops.Logic.Financial;
+using Swarmops.Logic.Structure;
+
+namespace Swarmops.Frontend.Pages.v5.Ledgers.TaxForms
+{
+ public partial class Json_PayrollData : DataV5Base
+ {
+ private AuthenticationData _authenticationData;
+ private Country _country;
+ private int _minKey = 999999;
+ private int _currentYear = DateTime.UtcNow.Year;
+
+ protected void Page_Load (object sender, EventArgs e)
+ {
+ // Get auth data
+
+ this._authenticationData = GetAuthenticationDataAndCulture();
+
+ // Get current year
+
+ int yearLoop = _currentYear;
+
+ // Country asked for
+
+ this._country = Country.FromCode (Request["Country"]);
+
+ Response.ContentType = "application/json";
+
+ Dictionary data = GetSalaryData();
+
+ List yearElements = new List();
+ while (_minKey < yearLoop * 1000) // at least one more year with data
+ {
+ List monthElements = new List();
+ SalaryData yearData = new SalaryData();
+
+ for (int month = 12; month >= 1; month--)
+ {
+ int key = yearLoop*100 + month;
+ if (data.ContainsKey (key))
+ {
+ monthElements.Add (WriteElement (key, new DateTime (yearLoop, month, 1).ToString("yyyy MMMM"), data [key]));
+ yearData.GrossSalaryCents += data[key].GrossSalaryCents;
+ yearData.AdditiveTaxCents += data[key].DeductedTaxCents;
+ yearData.DeductedTaxCents += data[key].AdditiveTaxCents;
+ }
+ }
+
+ if (monthElements.Count > 0)
+ {
+ yearElements.Add (WriteElement (yearLoop, String.Format (Resources.Global.Global_YearX, yearLoop), yearData, monthElements));
+ }
+
+ yearLoop--;
+ }
+
+ Response.Output.WriteLine ("[" + String.Join (",", yearElements) + "]");
+
+ Response.End();
+ }
+
+
+ private Dictionary GetSalaryData()
+ {
+ Dictionary result = new Dictionary();
+ Salaries salaries = Salaries.ForOrganization(_authenticationData.CurrentOrganization, true);
+
+ foreach (Salary salary in salaries)
+ {
+ int monthKey = salary.PayoutDate.Year*100 + salary.PayoutDate.Month;
+
+ if (!result.ContainsKey (monthKey))
+ {
+ result[monthKey] = new SalaryData();
+ }
+
+ result[monthKey].GrossSalaryCents += salary.GrossSalaryCents;
+ result[monthKey].AdditiveTaxCents += salary.AdditiveTaxCents;
+ result[monthKey].DeductedTaxCents += salary.SubtractiveTaxCents;
+
+ if (monthKey < _minKey)
+ {
+ _minKey = monthKey;
+ }
+ }
+
+ return result;
+ }
+
+
+
+ private string WriteElement (int key, string title, SalaryData data, List children = null)
+ {
+ string element = string.Format("\"id\":\"{0}\",\"yearMonth\":\"{1}\"", key,
+ JsonSanitize(title));
+
+ string imageClass = "IconFormMonth";
+
+ if (children != null)
+ {
+ element += String.Format (",\"state\":\"{0}\",\"children\":{1}",
+ key == this._currentYear ? "open" : "closed",
+ "[" + String.Join (",", children) + "]");
+
+ imageClass = "IconFormYear";
+ }
+
+ string image = String.Format("
",
+ "/Images/Flags/" + _country.Code.ToLower() + "-24px.png", imageClass, key);
+
+ element += String.Format(",\"grossPay\":\"{0:N0}\",\"additiveTax\":\"{1:N0}\",\"deductedTax\":\"{2:N0}\",\"costTotal\":\"{3:N0}\",\"taxTotal\":\"{4:N0}\",\"forms\":\"{5}\"",
+ data.GrossSalaryCents / 100.0, data.AdditiveTaxCents / 100.0, data.DeductedTaxCents / 100.0, (data.GrossSalaryCents + data.AdditiveTaxCents) / 100.0,
+ (data.AdditiveTaxCents + data.DeductedTaxCents) / 100.0, image.Replace ("\"", "\\\""));
+
+ return "{" + element + "}";
+ }
+
+
+
+ private void LocalizeRoot (List lines)
+ {
+ Dictionary localizeMap = new Dictionary();
+
+ localizeMap["%ASSET_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.BalanceSheet_Assets;
+ localizeMap["%DEBT_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.BalanceSheet_Debt;
+ localizeMap["%INCOME_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.ProfitLossStatement_Income;
+ localizeMap["%COST_ACCOUNTGROUP%"] = Resources.Pages.Ledgers.ProfitLossStatement_Costs;
+
+ foreach (YearlyReportLine line in lines)
+ {
+ if (localizeMap.ContainsKey (line.AccountName))
+ {
+ line.AccountName = localizeMap[line.AccountName];
+ }
+ }
+ }
+
+
+ private string RecurseReport (List reportLines)
+ {
+ List elements = new List();
+
+ foreach (YearlyReportLine line in reportLines)
+ {
+ string element = string.Format ("\"id\":\"{0}\",\"monthYear\":\"{1}\"", line.AccountId,
+ JsonSanitize (line.AccountName));
+
+ if (line.Children.Count > 0)
+ {
+ element += ",\"lastYear\":" +
+ JsonDualString (line.AccountId, line.AccountTreeValues.PreviousYear,
+ line.AccountValues.PreviousYear);
+
+ for (int quarter = 1; quarter <= 4; quarter++)
+ {
+ element += string.Format (",\"q{0}\":", quarter) +
+ JsonDualString (line.AccountId, line.AccountTreeValues.Quarters[quarter - 1],
+ line.AccountValues.Quarters[quarter - 1]);
+ }
+
+ element += ",\"ytd\":" +
+ JsonDualString (line.AccountId, line.AccountTreeValues.ThisYear,
+ line.AccountValues.ThisYear);
+
+
+ element += ",\"state\":\"closed\",\"children\":" + RecurseReport (line.Children);
+ }
+ else
+ {
+ element += string.Format (CultureInfo.CurrentCulture, ",\"lastYear\":\"{0:N0}\"",
+ (double) line.AccountValues.PreviousYear/100.0);
+
+ for (int quarter = 1; quarter <= 4; quarter++)
+ {
+ element += string.Format (CultureInfo.CurrentCulture, ",\"q{0}\":\"{1:N0}\"", quarter,
+ line.AccountValues.Quarters[quarter - 1]/100.0);
+ }
+
+ element += string.Format (CultureInfo.CurrentCulture, ",\"ytd\":\"{0:N0}\"",
+ (double) line.AccountValues.ThisYear/100.0);
+ }
+
+ elements.Add ("{" + element + "}");
+ }
+
+ return "[" + String.Join (",", elements.ToArray()) + "]";
+ }
+
+
+ private string JsonDualString (int accountId, Int64 treeValue, Int64 singleValue)
+ {
+ if (treeValue != 0 && singleValue == 0)
+ {
+ return string.Format (CultureInfo.CurrentCulture,
+ "\"Σ {1:N0} \"",
+ accountId, treeValue/100.00);
+ }
+ return string.Format (CultureInfo.CurrentCulture,
+ "\"Σ {1:N0}{2:N0}\"",
+ accountId, treeValue/100.0, singleValue/100.0);
+ }
+
+
+ private class SalaryData
+ {
+ public Int64 GrossSalaryCents { get; set; }
+ public Int64 AdditiveTaxCents { get; set; }
+ public Int64 DeductedTaxCents { get; set; }
+ // all others can be inferred from these three
+ }
+ }
+}
\ No newline at end of file
diff --git a/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx b/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx
new file mode 100644
index 00000000..059dd36a
--- /dev/null
+++ b/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx
@@ -0,0 +1,106 @@
+<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PayrollForms.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.TaxForms.PayrollForms" %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx.cs b/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx.cs
new file mode 100644
index 00000000..309067bb
--- /dev/null
+++ b/Site5/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Globalization;
+using System.Web.UI.WebControls;
+
+namespace Swarmops.Frontend.Pages.v5.Ledgers.TaxForms
+{
+ public partial class PayrollForms : PageV5Base
+ {
+ protected void Page_Load (object sender, EventArgs e)
+ {
+ if (!CurrentOrganization.IsEconomyEnabled)
+ {
+ Response.Redirect ("/Pages/v5/Financial/EconomyNotEnabled.aspx", true);
+ return;
+ }
+
+ PageIcon = "iconshock-treasure";
+ PageTitle = Resources.Pages.Financial.PayrollTaxForms_PageTitle;
+ InfoBoxLiteral = Resources.Pages.Financial.PayrollTaxForms_Info;
+
+ if (!Page.IsPostBack)
+ {
+ // TODO: DETERMINE COUNTRIES ON PAYROLL
+
+ this.DropCountries.Items.Add (new ListItem(Resources.GeographyNames.Country_SE, "SE"));
+
+ Localize();
+ }
+
+ EasyUIControlsUsed = EasyUIControl.DataGrid | EasyUIControl.Tree;
+ }
+
+
+ private void Localize()
+ {
+ this.LabelContentHeader.Text = Resources.Pages.Ledgers.TaxForms_Payroll_TaxFormsMonthlyHeader;
+ this.LiteralAdditiveTax.Text = Resources.Pages.Ledgers.TaxForms_Payroll_AdditiveTax;
+ this.LiteralCostTotal.Text = Resources.Pages.Ledgers.TaxForms_Payroll_TotalCost;
+ this.LiteralDeductedTax.Text = Resources.Pages.Ledgers.TaxForms_Payroll_DeductedTax;
+ this.LiteralFormsIcons.Text = Resources.Global.Global_View;
+ this.LiteralGrossPay.Text = Resources.Pages.Ledgers.TaxForms_Payroll_GrossPay;
+ this.LiteralTaxTotal.Text = Resources.Pages.Ledgers.TaxForms_Payroll_TotalTax;
+ this.LiteralTimePeriod.Text = Resources.Global.Global_YearMonth;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Site5/Pages/v5/User/SelectLanguage.aspx.cs b/Site5/Pages/v5/User/SelectLanguage.aspx.cs
index d682c51d..946e4197 100644
--- a/Site5/Pages/v5/User/SelectLanguage.aspx.cs
+++ b/Site5/Pages/v5/User/SelectLanguage.aspx.cs
@@ -28,7 +28,7 @@ namespace Swarmops.Frontend.Pages.v5.User
private void PopulateRepeater()
{
- string[] availableCultures = {"sv-SE", "nl-NL", "ru-RU"};
+ string[] availableCultures = {"ar-SA", "sv-SE", "nl-NL", "ru-RU"};
Array.Sort (availableCultures);
// sort by locale string, and that's ok, that happens to give the same result as sorting on country name
@@ -49,6 +49,11 @@ namespace Swarmops.Frontend.Pages.v5.User
newLanguage.IconUrl = "/Images/Flags/uk-64px.png";
// use "uk" for en-GB and en-US rather than "gb" or "us"
}
+ else if (cultureId.StartsWith ("ar"))
+ {
+ newLanguage.IconUrl = "/Images/Flags/ae-64px.png";
+ // The culture is ar-SA but we're not giving Saudi Arabia the light of day here
+ }
availableLanguages.Add (newLanguage);
}
diff --git a/Site5/Pages/v5/User/web.config b/Site5/Pages/v5/User/web.config
deleted file mode 100644
index 188a433d..00000000
--- a/Site5/Pages/v5/User/web.config
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE-2010.png b/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE-2010.png
new file mode 100644
index 00000000..ba3964af
Binary files /dev/null and b/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE-2010.png differ
diff --git a/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE.aspx b/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE.aspx
new file mode 100644
index 00000000..3e16807a
--- /dev/null
+++ b/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE.aspx
@@ -0,0 +1 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MonthlyTaxForm-SE.aspx.cs" Inherits="Swarmops.Plugins.Stock.TaxForms.MonthlyTaxFormSE" %>
diff --git a/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE.aspx.cs b/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE.aspx.cs
new file mode 100644
index 00000000..a78d4faa
--- /dev/null
+++ b/Site5/Plugins-Stock/TaxForms/SE/MonthlyTaxForm-SE.aspx.cs
@@ -0,0 +1,199 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using Swarmops.Logic.Financial;
+using Swarmops.Logic.Structure;
+
+namespace Swarmops.Plugins.Stock.TaxForms
+{
+ public partial class MonthlyTaxFormSE : DataV5Base
+ {
+ protected void Page_Load (object sender, EventArgs e)
+ {
+ string monthString = Request.QueryString["YearMonth"];
+ AuthenticationData authData = GetAuthenticationDataAndCulture();
+ Organization organization = authData.CurrentOrganization;
+
+ int year = Int32.Parse (monthString.Substring (0, 4));
+ int month = Int32.Parse (monthString.Substring (4)); // never mind input checking
+
+ int[] yearBreakpoints = { 1938, year-65, year-26 };
+ double[] taxRates = {10.21, 15.49, 31.42}; // will need to adapt this when some of the rates change
+
+ SalaryTaxData data = GetSalaryData (year, month, organization, yearBreakpoints);
+
+ Response.ContentType = "image/png";
+
+ int formVersion = 2015;
+ if (year < 2015)
+ {
+ formVersion = 2010;
+ }
+
+ Image form = Image.FromFile (MapPath (".") + "/MonthlyTaxForm-SE-" + formVersion + ".png"); // the "." says "in same folder as this file"
+
+ CultureInfo swedishCulture = CultureInfo.CreateSpecificCulture ("sv-SE");
+ monthString = new DateTime(year, month, 1).ToString("MMMM yyyy", swedishCulture);
+
+ string sansFontName = "Liberation Sans";
+ string courierFontName = "Liberation Mono";
+ if (Debugger.IsAttached)
+ {
+ sansFontName = "Arial"; // yeahyeah...
+ courierFontName = "Courier New";
+ }
+
+ using (Graphics graphics = Graphics.FromImage (form))
+ {
+ StringFormat rightAlign = new StringFormat();
+ rightAlign.Alignment = StringAlignment.Far;
+
+ Font fontHandwriting = new Font (courierFontName, 64, FontStyle.Bold);
+ Font fontPreprinted = new Font (courierFontName, 30, FontStyle.Bold);
+ Font fontPreprintedSmall = new Font (courierFontName, 24, FontStyle.Bold);
+ Font fontPreprintedSans = new Font (sansFontName, 30, FontStyle.Bold);
+
+ Brush brushHandwriting = Brushes.Blue;
+ Brush brushPreprinted = Brushes.Red;
+ Brush brushPreprintedDiscreet = Brushes.DarkRed;
+
+ graphics.CompositingQuality = CompositingQuality.HighQuality;
+ graphics.SmoothingMode = SmoothingMode.AntiAlias;
+
+ // Draw the header and monthname - things to pay attention to
+
+ graphics.DrawString (organization.Name, fontPreprinted, brushPreprinted, 150, 170);
+
+ if (year <= 2014)
+ {
+ graphics.DrawString (monthString, fontPreprinted, brushPreprinted, 680, 292);
+ graphics.DrawString (monthString, fontPreprinted, brushPreprinted, 620, 1460);
+ graphics.DrawString (String.Format ("{0,4}-{1:D2}-{2:D2}", year, month + 1, 12), fontPreprinted,
+ brushPreprinted, 820, 160);
+ graphics.DrawString ("xxxxxx-xxxx", fontPreprinted, brushPreprinted, 1110, 160);
+ }
+ else // the latest revision of the tax form
+ {
+ graphics.DrawString (monthString, fontPreprintedSans, brushPreprinted, 670, 287);
+ graphics.DrawString (monthString, fontPreprintedSans, brushPreprinted, 610, 1455);
+ graphics.DrawString (String.Format ("{0,4}-{1:D2}-{2:D2}", year, month + 1, 12), fontPreprinted,
+ brushPreprinted, 820, 160);
+ graphics.DrawString ("xxxxxx-xxxx", fontPreprinted, brushPreprinted, 1110, 160);
+ }
+
+ // Draw the years and tax rates and other on-form constants more discreetly
+
+ graphics.DrawString (taxRates[2].ToString ("F2", swedishCulture), fontPreprintedSmall,
+ brushPreprintedDiscreet, 828, 731);
+ graphics.DrawString (taxRates[1].ToString ("F2", swedishCulture), fontPreprintedSmall,
+ brushPreprintedDiscreet, 828, 798);
+ graphics.DrawString (taxRates[0].ToString ("F2", swedishCulture), fontPreprintedSmall,
+ brushPreprintedDiscreet, 828, 865);
+
+ graphics.DrawString (string.Format ("{0} - {1}", yearBreakpoints[1], yearBreakpoints[2] - 1),
+ fontPreprintedSmall, brushPreprintedDiscreet, 200, 731);
+ graphics.DrawString (string.Format ("{0} -", yearBreakpoints[2] - 1),
+ fontPreprintedSmall, brushPreprintedDiscreet, 200, 798);
+ graphics.DrawString (string.Format ("{0}", yearBreakpoints[1] - 1),
+ fontPreprintedSmall, brushPreprintedDiscreet, 252, 861);
+
+ // Draw the actual numbers
+
+ graphics.DrawString (data.SalaryTotal.ToString ("F0"), fontHandwriting, brushHandwriting, 792, 358,
+ rightAlign); // Salary total sub
+ graphics.DrawString (data.SalaryTotal.ToString ("F0"), fontHandwriting, brushHandwriting, 792, 558,
+ rightAlign); // Salary total total
+
+ for (int ageBracket = 0; ageBracket <= 2; ageBracket++)
+ {
+ if (data.Salary[ageBracket] > 0.0)
+ {
+ graphics.DrawString (data.Salary[ageBracket].ToString ("F0"), fontHandwriting, brushHandwriting,
+ 792, 692 + ageBracket*67, rightAlign); // Salary
+ graphics.DrawString (data.TaxAdditive[ageBracket].ToString ("F0"), fontHandwriting,
+ brushHandwriting, 1510, 692 + ageBracket*67, rightAlign); // Employer's fee
+ }
+ }
+
+ graphics.DrawString(data.SalaryTotal.ToString("F0"), fontHandwriting, brushHandwriting, 792, 1524,
+ rightAlign); // Salary total again
+ graphics.DrawString (data.SalaryTotal.ToString ("F0"), fontHandwriting, brushHandwriting, 792, 1725,
+ rightAlign); // Salary total again
+ graphics.DrawString(data.TaxAdditiveTotal.ToString("F0"), fontHandwriting, brushHandwriting, 1510,
+ 1326, rightAlign); // Emp fee total
+ graphics.DrawString (data.TaxSubtractiveTotal.ToString ("F0"), fontHandwriting, brushHandwriting, 1510, 1525,
+ rightAlign); // Deducted main
+ graphics.DrawString (data.TaxSubtractiveTotal.ToString ("F0"), fontHandwriting, brushHandwriting, 1510, 1726,
+ rightAlign); // Deducted total
+ graphics.DrawString (data.TaxTotal.ToString ("F0"), fontHandwriting, brushHandwriting, 1510, 1793,
+ rightAlign); // Tax cost total
+ }
+
+ using (Stream responseStream = Response.OutputStream)
+ {
+ form.Save (responseStream, ImageFormat.Png);
+ }
+
+ }
+
+
+
+ private class SalaryTaxData
+ {
+ public SalaryTaxData()
+ {
+ Salary = new double[3];
+ TaxAdditive = new double[3];
+ }
+
+ public double[] Salary;
+ public double SalaryTotal;
+ public double TaxSubtractiveTotal;
+ public double[] TaxAdditive;
+ public double TaxAdditiveTotal;
+ public double TaxTotal;
+ }
+
+
+ private SalaryTaxData GetSalaryData (int year, int month, Organization organization, int[] yearBreakpoints)
+ {
+ SalaryTaxData result = new SalaryTaxData();
+
+ Salaries salaries = Salaries.ForOrganization (organization, true);
+
+ foreach (Salary salary in salaries)
+ {
+ if (salary.PayoutDate.Year == year && salary.PayoutDate.Month == month)
+ {
+ int employeeBirthYear = salary.PayrollItem.Person.Birthdate.Year;
+ int ageBracket = 0; // main
+ if (employeeBirthYear >= yearBreakpoints[2])
+ {
+ ageBracket = 1; // youth rebate
+ }
+ else if (employeeBirthYear < yearBreakpoints[1])
+ {
+ ageBracket = 2; // pensioners
+ }
+
+ result.Salary[ageBracket] += salary.GrossSalaryCents/100.0;
+ result.SalaryTotal += salary.GrossSalaryCents/100.0;
+ result.TaxSubtractiveTotal += salary.SubtractiveTaxCents/100.0;
+ result.TaxAdditive[ageBracket] += salary.AdditiveTaxCents/100.0;
+ result.TaxAdditiveTotal += salary.AdditiveTaxCents/100.0;
+ result.TaxTotal += salary.TaxTotalCents/100.0;
+ }
+ }
+
+ return result;
+ }
+ }
+}
\ No newline at end of file