More work on Account Plan

This commit is contained in:
Rick Falkvinge
2014-09-13 12:20:04 +02:00
parent 40f5768b68
commit 60fac749f0
4 changed files with 112 additions and 4 deletions
+45
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Interfaces;
using Swarmops.Basic.Types;
@@ -662,6 +663,22 @@ namespace Swarmops.Database
}
public void SetFinancialAccountOpenedYear(int financialAccountId, int openedYear)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("SetFinancialAccountOpenedYear", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "financialAccountId", financialAccountId);
AddParameterWithName(command, "openedYear", openedYear);
command.ExecuteNonQuery();
}
}
public void SetFinancialAccountOwner(int financialAccountId, int ownerPersonId)
{
using (DbConnection connection = GetMySqlDbConnection())
@@ -883,6 +900,34 @@ namespace Swarmops.Database
}
public DateTime GetFinancialAccountFirstTransactionDate(int financialAccountId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command =
GetDbCommand(
"SELECT FinancialTransactions.DateTime FROM FinancialTransactions,FinancialTransactionRows " +
"WHERE FinancialTransactions.FinancialTransactionId=FinancialTransactionRows.FinancialTransactionId " +
"AND FinancialTransactionRows.FinancialAccountId = " + financialAccountId.ToString(CultureInfo.InvariantCulture) + " " +
"ORDER BY FinancialTransactions.DateTime LIMIT 1;", connection);
using (DbDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
return reader.GetDateTime(0);
}
else
{
throw new Exception("No transactions for this account yet"); // need better type here than "Exception"
};
}
}
}
public BasicFinancialTransaction[] GetDependentFinancialTransactions(FinancialDependencyType dependencyType, int foreignId)
{
List<int> transactionIds = new List<int>();