From 72aef5f9bdf8daf1c6feea229e17f2bb9927cb48 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 21 Oct 2014 08:12:37 +0200 Subject: [PATCH] Improved tax level precision, import --- Database/Database-TaxLevels.cs | 5 +++-- Logic/Financial/TaxLevels.cs | 15 +++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Database/Database-TaxLevels.cs b/Database/Database-TaxLevels.cs index 16c2fbe1..ef79864b 100644 --- a/Database/Database-TaxLevels.cs +++ b/Database/Database-TaxLevels.cs @@ -40,7 +40,7 @@ namespace Swarmops.Database if (taxLevel < 0) { - return -taxLevel/100.0; // -45 means 45% and should be returned as .45 + return -taxLevel/10000.0; // -4500 means 45% and should be returned as .45 } return taxLevel; @@ -72,13 +72,14 @@ namespace Swarmops.Database AddParameterWithName(command, "taxLevelId", taxLevelId); AddParameterWithName(command, "bracketLow", bracketLow); AddParameterWithName(command, "year", year); - AddParameterWithName(command, "tax", tax < 1.0 ? (int)(-tax * 100) : (int)tax); + AddParameterWithName(command, "tax", tax < 1.0 ? (int)(-tax * 10000) : (int)tax); command.ExecuteNonQuery(); } } + [Obsolete ("We're using a new Year column rather than deleting obsolete tax data", false)] public void DeleteTaxLevels (int countryId) { using (DbConnection connection = GetMySqlDbConnection()) diff --git a/Logic/Financial/TaxLevels.cs b/Logic/Financial/TaxLevels.cs index 1c583742..f56739ad 100644 --- a/Logic/Financial/TaxLevels.cs +++ b/Logic/Financial/TaxLevels.cs @@ -29,13 +29,12 @@ namespace Swarmops.Logic.Financial return taxLevel; } - static public void ImportTaxLevels (Country country, string data) + static public void ImportTaxLevels (Country country, int year, string data) { - // Lock out salary processing - - Persistence.Key["TaxDataImporting"] = "1"; - - int year = DateTime.Today.Year; + if (country.Code != "SE") + { + throw new NotImplementedException("Can't import this country's tax levels yet"); + } string[] lines = data.Split('\n'); // if \r\n is used, the \r will be harmlessly at the end of lines @@ -69,10 +68,6 @@ namespace Swarmops.Logic.Financial SwarmDb.GetDatabaseForWriting().CreateSalaryTaxLevel(country.Identity, taxLevelId, lowerBracket, year, tax); } } - - // Re-enable salary processing - - Persistence.Key["TaxDataImporting"] = "0"; } } }