Started work on tax forms / plugins

This commit is contained in:
Rick Falkvinge
2015-02-05 17:23:40 +01:00
parent 4e46ca3e83
commit e96f9a6702
16 changed files with 707 additions and 15 deletions
+15
View File
@@ -370,6 +370,12 @@
<EmbeddedResource Include="App_GlobalResources\af-ZA\Logic.Communications.Transmission.NotificationPayload.af-ZA.resx" />
<EmbeddedResource Include="App_GlobalResources\af-ZA\Logic.Financial.FinancialTransactionTagSetTypesStock.af-ZA.resx" />
<EmbeddedResource Include="App_GlobalResources\af-ZA\Logic.Swarm.DashboardTodos.af-ZA.resx" />
<EmbeddedResource Include="App_GlobalResources\ar-SA\Logic.Communications.Transmission.DefaultCommTemplates.ar-SA.resx" />
<EmbeddedResource Include="App_GlobalResources\ar-SA\Logic.Communications.Transmission.MailPayload.ar-SA.resx" />
<EmbeddedResource Include="App_GlobalResources\ar-SA\Logic.Communications.Transmission.NotificationPayload.ar-SA.resx" />
<EmbeddedResource Include="App_GlobalResources\ar-SA\Logic.Financial.FinancialTransactionTagSetTypesStock.ar-SA.resx" />
<EmbeddedResource Include="App_GlobalResources\ar-SA\Logic.Swarm.DashboardTodos.ar-SA.resx" />
<EmbeddedResource Include="App_GlobalResources\ar-SA\ParticipantTitles.ar-SA.resx" />
<EmbeddedResource Include="App_GlobalResources\da-DK\Logic.Communications.Transmission.NotificationPayload.da-DK.resx" />
<EmbeddedResource Include="App_GlobalResources\da-DK\Logic.Financial.FinancialTransactionTagSetTypesStock.da-DK.resx" />
<EmbeddedResource Include="App_GlobalResources\da-DK\Logic.Swarm.DashboardTodos.da-DK.resx" />
@@ -385,6 +391,12 @@
<EmbeddedResource Include="App_GlobalResources\fr-FR\Logic.Communications.Transmission.NotificationPayload.fr-FR.resx" />
<EmbeddedResource Include="App_GlobalResources\fr-FR\Logic.Financial.FinancialTransactionTagSetTypesStock.fr-FR.resx" />
<EmbeddedResource Include="App_GlobalResources\fr-FR\Logic.Swarm.DashboardTodos.fr-FR.resx" />
<EmbeddedResource Include="App_GlobalResources\hi-IN\Logic.Communications.Transmission.DefaultCommTemplates.hi-IN.resx" />
<EmbeddedResource Include="App_GlobalResources\hi-IN\Logic.Communications.Transmission.MailPayload.hi-IN.resx" />
<EmbeddedResource Include="App_GlobalResources\hi-IN\Logic.Communications.Transmission.NotificationPayload.hi-IN.resx" />
<EmbeddedResource Include="App_GlobalResources\hi-IN\Logic.Financial.FinancialTransactionTagSetTypesStock.hi-IN.resx" />
<EmbeddedResource Include="App_GlobalResources\hi-IN\Logic.Swarm.DashboardTodos.hi-IN.resx" />
<EmbeddedResource Include="App_GlobalResources\hi-IN\ParticipantTitles.hi-IN.resx" />
<EmbeddedResource Include="App_GlobalResources\is-IS\Logic.Communications.Transmission.NotificationPayload.is-IS.resx" />
<EmbeddedResource Include="App_GlobalResources\is-IS\Logic.Financial.FinancialTransactionTagSetTypesStock.is-IS.resx" />
<EmbeddedResource Include="App_GlobalResources\is-IS\Logic.Swarm.DashboardTodos.is-IS.resx" />
@@ -432,9 +444,12 @@
<EmbeddedResource Include="App_GlobalResources\ru-RU\Logic.Communications.Transmission.NotificationPayload.ru-RU.resx" />
<EmbeddedResource Include="App_GlobalResources\ru-RU\Logic.Financial.FinancialTransactionTagSetTypesStock.ru-RU.resx" />
<EmbeddedResource Include="App_GlobalResources\ru-RU\Logic.Swarm.DashboardTodos.ru-RU.resx" />
<EmbeddedResource Include="App_GlobalResources\sv-SE\Logic.Communications.Transmission.DefaultCommTemplates.sv-SE.resx" />
<EmbeddedResource Include="App_GlobalResources\sv-SE\Logic.Communications.Transmission.MailPayload.sv-SE.resx" />
<EmbeddedResource Include="App_GlobalResources\sv-SE\Logic.Communications.Transmission.NotificationPayload.sv-SE.resx" />
<EmbeddedResource Include="App_GlobalResources\sv-SE\Logic.Financial.FinancialTransactionTagSetTypesStock.sv-SE.resx" />
<EmbeddedResource Include="App_GlobalResources\sv-SE\Logic.Swarm.DashboardTodos.sv-SE.resx" />
<EmbeddedResource Include="App_GlobalResources\sv-SE\ParticipantTitles.sv-SE.resx" />
<EmbeddedResource Include="App_GlobalResources\zh-CN\Logic.Communications.Transmission.NotificationPayload.zh-CN.resx" />
<EmbeddedResource Include="App_GlobalResources\zh-CN\Logic.Financial.FinancialTransactionTagSetTypesStock.zh-CN.resx" />
<EmbeddedResource Include="App_GlobalResources\zh-CN\Logic.Swarm.DashboardTodos.zh-CN.resx" />
+17
View File
@@ -555,4 +555,21 @@
<data name="Error_AjaxCallException" xml:space="preserve">
<value>There was a general, unspecified error contacting the Swarmops server. Is the network still operational and the server available?</value>
</data>
<data name="Global_Month" xml:space="preserve">
<value>Month</value>
</data>
<data name="Global_View" xml:space="preserve">
<value>View</value>
<comment>As in "inspect"</comment>
</data>
<data name="Global_Year" xml:space="preserve">
<value>Year</value>
</data>
<data name="Global_YearMonth" xml:space="preserve">
<value>Year/Month</value>
</data>
<data name="Global_YearX" xml:space="preserve">
<value>Year {0}</value>
<comment>As in "the year X".</comment>
</data>
</root>
+6
View File
@@ -399,4 +399,10 @@
<data name="Menu5_Ugly_Todo" xml:space="preserve">
<value>This is a temporary menu. Yes it's ugly now.</value>
</data>
<data name="Menu5_Ledgers_TaxForms" xml:space="preserve">
<value>Tax Forms</value>
</data>
<data name="Menu5_Ledgers_TaxForms_Payroll" xml:space="preserve">
<value>Payroll Tax Forms</value>
</data>
</root>
@@ -342,6 +342,33 @@
<data name="PayOutMoney_PayoutUndone" xml:space="preserve">
<value>Payout #{0:N0} was undone and everything restored.</value>
</data>
<data name="PayrollTaxForms_AdditiveTax" xml:space="preserve">
<value>Additive Tax</value>
<comment>If applicable, translate to local legal tax term</comment>
</data>
<data name="PayrollTaxForms_DeductedTax" xml:space="preserve">
<value>Deducted Tax</value>
<comment>If applicable, translate to local legal tax term</comment>
</data>
<data name="PayrollTaxForms_GrossPay" xml:space="preserve">
<value>Gross Paycheck</value>
</data>
<data name="PayrollTaxForms_Info" xml:space="preserve">
<value>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.</value>
</data>
<data name="PayrollTaxForms_PageTitle" xml:space="preserve">
<value>Payroll Tax Forms</value>
</data>
<data name="PayrollTaxForms_TaxFormsHeader" xml:space="preserve">
<value>Monthly Tax Forms For {0} For</value>
<comment>The {0} is the organization name. A country selector follows (imagine a "France" tacked on to the end).</comment>
</data>
<data name="PayrollTaxForms_TotalCost" xml:space="preserve">
<value>Total Cost</value>
</data>
<data name="PayrollTaxForms_TotalTax" xml:space="preserve">
<value>Total Tax</value>
</data>
<data name="RequestCashAdvance_Amount" xml:space="preserve">
<value>Advance amount (in {0})</value>
<comment>{0} is the currency.</comment>
@@ -574,4 +574,31 @@
<value>Projected Profit {0}</value>
<comment>"Projected" as in "Budgeted". {0} is year.</comment>
</data>
<data name="TaxForms_Payroll_AdditiveTax" xml:space="preserve">
<value>Additive Tax</value>
<comment>If applicable, translate to local legal tax term</comment>
</data>
<data name="TaxForms_Payroll_DeductedTax" xml:space="preserve">
<value>Deducted Tax</value>
<comment>If applicable, translate to local legal tax term</comment>
</data>
<data name="TaxForms_Payroll_GrossPay" xml:space="preserve">
<value>Gross Paycheck</value>
</data>
<data name="TaxForms_Payroll_Info" xml:space="preserve">
<value>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.</value>
</data>
<data name="TaxForms_Payroll_PageTitle" xml:space="preserve">
<value>Payroll Tax Forms</value>
</data>
<data name="TaxForms_Payroll_TaxFormsMonthlyHeader" xml:space="preserve">
<value>Monthly Tax Forms For</value>
<comment>The {0} is the organization name. A country selector follows (imagine a "France" tacked on to the end).</comment>
</data>
<data name="TaxForms_Payroll_TotalCost" xml:space="preserve">
<value>Total Cost</value>
</data>
<data name="TaxForms_Payroll_TotalTax" xml:space="preserve">
<value>Total Tax</value>
</data>
</root>
+2 -1
View File
@@ -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();
}
+37 -2
View File
@@ -242,6 +242,16 @@
<Permissions />
<Type>Disabled</Type>
<Children />
<MainMenuItem>
<ResourceKey>Financial_Payroll_TaxForms</ResourceKey>
<UserLevel>3</UserLevel>
<Permissions />
<ImageUrl />
<NavigateUrl>/Pages/v5/Financial/ViewPayrollTaxForms.aspx</NavigateUrl>
<Type>Link</Type>
<Children />
</MainMenuItem>
</MainMenuItem>
<MainMenuItem>
@@ -341,8 +351,33 @@
<Type>Separator</Type>
<Children />
</MainMenuItem>
<MainMenuItem>
<MainMenuItem>
<ResourceKey>Ledgers_TaxForms</ResourceKey>
<UserLevel>3</UserLevel>
<Permissions />
<Type>Submenu</Type>
<Children>
<MainMenuItem>
<ResourceKey>Ledgers_TaxForms_Payroll</ResourceKey>
<UserLevel>3</UserLevel>
<Permissions />
<ImageUrl />
<NavigateUrl>/Pages/v5/Ledgers/TaxForms/PayrollForms.aspx</NavigateUrl>
<Type>Link</Type>
<Children />
</MainMenuItem>
</Children>
</MainMenuItem>
<MainMenuItem>
<UserLevel>3</UserLevel>
<Type>Separator</Type>
<Children />
</MainMenuItem>
<MainMenuItem>
<ResourceKey>Ledgers_UploadBankFiles</ResourceKey>
<UserLevel>3</UserLevel>
<Permissions />
@@ -0,0 +1 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-Payroll-TaxFormData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Ledgers.TaxForms.Json_PayrollData" %>
@@ -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<int, SalaryData> data = GetSalaryData();
List<string> yearElements = new List<string>();
while (_minKey < yearLoop * 1000) // at least one more year with data
{
List<string> monthElements = new List<string>();
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<int, SalaryData> GetSalaryData()
{
Dictionary<int, SalaryData> result = new Dictionary<int, SalaryData>();
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<string> 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("<img src=\"{0}\" class=\"{1}\" yearmonth=\"{2}\" height=\"24px\" width=\"24px\" />",
"/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<YearlyReportLine> lines)
{
Dictionary<string, string> localizeMap = new Dictionary<string, string>();
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<YearlyReportLine> reportLines)
{
List<string> elements = new List<string>();
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,
"\"<span class=\\\"profitlossdata-collapsed-{0}\\\"><strong>&Sigma;</strong> {1:N0}</span><span class=\\\"profitlossdata-expanded-{0}\\\" style=\\\"display:none\\\">&nbsp;</span>\"",
accountId, treeValue/100.00);
}
return string.Format (CultureInfo.CurrentCulture,
"\"<span class=\\\"profitlossdata-collapsed-{0}\\\"><strong>&Sigma;</strong> {1:N0}</span><span class=\\\"profitlossdata-expanded-{0}\\\" style=\\\"display:none\\\">{2:N0}</span>\"",
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
}
}
}
@@ -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" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<script type="text/javascript" src="/Scripts/fancybox/jquery.fancybox-1.3.4.js"></script>
<script type="text/javascript" src="/Scripts/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="/Scripts/jquery.snipe.js"></script>
<link rel="stylesheet" type="text/css" href="/Scripts/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript">
$(document).ready(function () {
$('#tableTaxData').treegrid(
{
onLoadSuccess: function () {
$('div.datagrid').css('opacity', 1);
$('#imageLoadIndicator').hide();
$('span.loadingHeader').hide();
var selectedCountry = $('#<%=DropCountries.ClientID %>').val();
$('span.commonHeader').show();
$('img.IconFormMonth').click(function() {
var yearMonth = $(this).attr("yearmonth");
$('a#LinkFancyBox').attr("href", "/Plugins-Stock/TaxForms/" + selectedCountry + "/MonthlyTaxForm-" + selectedCountry + ".aspx?YearMonth=" + yearMonth + "&Country=" + selectedCountry);
$('a#LinkFancyBox').click();
});
}
});
$("a.FancyBox_Gallery").fancybox({
'overlayShow': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'image',
'opacity': true
});
$('#<%=DropCountries.ClientID %>').change(function () {
var selectedCountry = $('#<%=DropCountries.ClientID %>').val();
$('#tableProfitLoss').treegrid({ url: 'Json-Payroll-TaxFormData.aspx?Country=' + selectedCountry });
$('#imageLoadIndicator').show();
$('div.datagrid').css('opacity', 0.4);
$('#tableTaxData').treegid('reload');
});
$('div.datagrid').css('opacity', 0.4);
});
var currentYear = <%=DateTime.Today.Year %>;
</script>
<style>
.content h2 select {
font-size: 16px;
font-weight: bold;
color: #1C397E;
letter-spacing: 1px;
}
.IconFormYear, .IconFormMonth {
cursor: pointer;
}
.IconFormYear {
display: none;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<h2><asp:Label ID="LabelContentHeader" runat="server" /> <asp:DropDownList runat="server" ID="DropCountries"/>&nbsp;<img alt="Loading" src="/Images/Abstract/ajaxloader-blackcircle.gif" ID="imageLoadIndicator" /></h2>
<table id="tableTaxData" title="" class="easyui-treegrid" style="width:680px;height:600px"
url="Json-Payroll-TaxFormData.aspx?Country=SE"
rownumbers="false"
animate="true"
fitColumns="true"
idField="id" treeField="yearMonth">
<thead>
<tr>
<th field="yearMonth" width="168"><asp:Literal ID="LiteralTimePeriod" runat="server"/></th>
<th field="grossPay" width="90" align="right"><asp:Literal runat="server" ID="LiteralGrossPay" /></th>
<th field="additiveTax" width="90" align="right"><asp:Literal ID="LiteralAdditiveTax" runat="server" /></th>
<th field="costTotal" width="90" align="right"><asp:Literal ID="LiteralCostTotal" runat="server" /></th>
<th field="deductedTax" width="90" align="right"><asp:Literal ID="LiteralDeductedTax" runat="server" /></th>
<th field="taxTotal" width="90" align="right"><asp:Literal ID="LiteralTaxTotal" runat="server" /></th>
<th field="forms" width="40" align="center"><asp:Literal ID="LiteralFormsIcons" runat="server" /></th>
</tr>
</thead>
</table>
<!-- a href link for FancyBox to trigger on -->
<div style="display:none">
<a href="HiddenLink" id="LinkFancyBox" rel="FancyBox" class="FancyBox_Gallery"></a>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
</asp:Content>
@@ -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;
}
}
}
+6 -1
View File
@@ -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);
}
-11
View File
@@ -1,11 +0,0 @@
<?xml version="1.0"?>
<!--
The only override for the Pages/Public, Style, Images, and Security folders is that no authentication is required.
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>
Binary file not shown.

After

Width:  |  Height:  |  Size: 646 KiB

@@ -0,0 +1 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MonthlyTaxForm-SE.aspx.cs" Inherits="Swarmops.Plugins.Stock.TaxForms.MonthlyTaxFormSE" %>
@@ -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;
}
}
}