Improved tax level precision, import

This commit is contained in:
Rick Falkvinge
2014-10-21 08:12:37 +02:00
parent fb24670135
commit 72aef5f9bd
2 changed files with 8 additions and 12 deletions
+3 -2
View File
@@ -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())
+5 -10
View File
@@ -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";
}
}
}