diff --git a/Basic/Basic.csproj b/Basic/Basic.csproj
index 0176444e..f3b71c1e 100644
--- a/Basic/Basic.csproj
+++ b/Basic/Basic.csproj
@@ -68,6 +68,7 @@
+
@@ -97,7 +98,6 @@
-
diff --git a/Basic/Enums/OrganizationFinancialAccountType.cs b/Basic/Enums/OrganizationFinancialAccountType.cs
index d1541bca..5a244dc6 100644
--- a/Basic/Enums/OrganizationFinancialAccountType.cs
+++ b/Basic/Enums/OrganizationFinancialAccountType.cs
@@ -94,6 +94,14 @@ namespace Swarmops.Basic.Enums
///
/// When closing books, this is the yearly result (balanced against DebtsEquity)
///
- CostsYearlyResult // multi-account type
+ CostsYearlyResult, // multi-account type
+ ///
+ /// Dimension 2 - default income account
+ ///
+ IncomeTypeUnspecified,
+ ///
+ /// Dimensione 2 - default cost account
+ ///
+ CostTypeUnspecified
};
}
diff --git a/Basic/Types/BasicFinancialAccount.cs b/Basic/Types/BasicFinancialAccount.cs
deleted file mode 100644
index c314ae6c..00000000
--- a/Basic/Types/BasicFinancialAccount.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Swarmops.Basic.Enums;
-using Swarmops.Basic.Interfaces;
-
-namespace Swarmops.Basic.Types
-{
- public class BasicFinancialAccount : IHasIdentity
- {
- public BasicFinancialAccount (int financialAccountId, string name, FinancialAccountType accountType,
- int organizationId, int parentFinancialAccountId, int ownerPersonId)
- {
- this.financialAccountId = financialAccountId;
- this.name = name;
- this.accountType = accountType;
- this.organizationId = organizationId;
- this.ownerPersonId = ownerPersonId;
- this.parentFinancialAccountId = parentFinancialAccountId;
- }
-
- public BasicFinancialAccount (BasicFinancialAccount original) :
- this(original.Identity, original.name, original.accountType, original.organizationId, original.parentFinancialAccountId, original.ownerPersonId)
- {
- // Empty copy constructor
- }
-
-
- private int financialAccountId;
- private string name;
- private int organizationId;
- private FinancialAccountType accountType;
- private int ownerPersonId;
- private int parentFinancialAccountId;
-
- public int FinancialAccountId
- {
- get { return this.financialAccountId; }
- }
-
- public string Name
- {
- get { return this.name; }
- }
-
- public int OrganizationId
- {
- get { return this.organizationId; }
- }
-
- public FinancialAccountType AccountType
- {
- get { return this.accountType; }
- }
-
- public int OwnerPersonId
- {
- get { return this.ownerPersonId; }
- }
-
- public int ParentFinancialAccountId
- {
- get { return this.parentFinancialAccountId; }
- }
-
- #region IHasIdentity Members
-
- public int Identity
- {
- get { return this.financialAccountId; }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Basic/Types/Financial/BasicFinancialAccount.cs b/Basic/Types/Financial/BasicFinancialAccount.cs
new file mode 100644
index 00000000..ca07a1ef
--- /dev/null
+++ b/Basic/Types/Financial/BasicFinancialAccount.cs
@@ -0,0 +1,51 @@
+using Swarmops.Basic.Enums;
+using Swarmops.Basic.Interfaces;
+
+namespace Swarmops.Basic.Types.Financial
+{
+ public class BasicFinancialAccount : IHasIdentity
+ {
+ public BasicFinancialAccount (int financialAccountId, string name, FinancialAccountType accountType,
+ int organizationId, int parentFinancialAccountId, int ownerPersonId,
+ int dimension, bool open, int openedYear, int closedYear)
+ {
+ this.FinancialAccountId = financialAccountId;
+ this.Name = name;
+ this.AccountType = accountType;
+ this.OrganizationId = organizationId;
+ this.OwnerPersonId = ownerPersonId;
+ this.ParentFinancialAccountId = parentFinancialAccountId;
+ this.Dimension = dimension;
+ this.Open = open;
+ this.OpenedYear = openedYear;
+ this.ClosedYear = closedYear;
+ }
+
+ public BasicFinancialAccount (BasicFinancialAccount original) :
+ this(original.Identity, original.Name, original.AccountType, original.OrganizationId, original.ParentFinancialAccountId, original.OwnerPersonId, original.Dimension, original.Open, original.OpenedYear, original.ClosedYear)
+ {
+ // Empty copy constructor
+ }
+
+
+ public int FinancialAccountId { get; private set; }
+ public string Name { get; private set; }
+ public int OrganizationId { get; private set; }
+ public FinancialAccountType AccountType { get; private set; }
+ public int OwnerPersonId { get; protected set; }
+ public int ParentFinancialAccountId { get; private set; }
+ public int Dimension { get; protected set; }
+ public bool Open { get; protected set; }
+ public int OpenedYear { get; protected set; }
+ public int ClosedYear { get; protected set; }
+
+ #region IHasIdentity Members
+
+ public int Identity
+ {
+ get { return this.FinancialAccountId; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Database/Database-Financials.cs b/Database/Database-Financials.cs
index 668e16f2..e00d75dd 100644
--- a/Database/Database-Financials.cs
+++ b/Database/Database-Financials.cs
@@ -5,6 +5,7 @@ using System.Data.Common;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Interfaces;
using Swarmops.Basic.Types;
+using Swarmops.Basic.Types.Financial;
// This is the first part of Database to fully use MySql.
@@ -12,7 +13,12 @@ namespace Swarmops.Database
{
public partial class SwarmDb
{
- public int CreateFinancialAccount (int pOrganizationId, string pName, FinancialAccountType pAccountType, int pParentFinancialAccountId)
+ private const string financialAccountFieldSequence =
+ " FinancialAccountId,Name,OrganizationId,AccountType,ParentFinancialAccountId," + // 0-4
+ " OwnerPersonId,Dimension,Open,OpenedYear,ClosedYear " + // 5-9
+ " FROM FinancialAccounts ";
+
+ public int CreateFinancialAccount(int pOrganizationId, string pName, FinancialAccountType pAccountType, int pParentFinancialAccountId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
@@ -31,7 +37,26 @@ namespace Swarmops.Database
}
- public BasicFinancialAccount GetFinancialAccount (int financialAccountId)
+ public void SetFinancialAccountDimension(int financialAccountId, int dimension)
+ {
+ // This is only intended to be used when creating the account, and never used once in use.
+
+ using (DbConnection connection = GetMySqlDbConnection())
+ {
+ connection.Open();
+
+ DbCommand command = GetDbCommand("SetFinancialAccountDimension", connection);
+ command.CommandType = CommandType.StoredProcedure;
+
+ AddParameterWithName(command, "financialAccountId", financialAccountId);
+ AddParameterWithName(command, "dimension", dimension);
+
+ command.ExecuteNonQuery();
+ }
+ }
+
+
+ public BasicFinancialAccount GetFinancialAccount(int financialAccountId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
@@ -39,7 +64,7 @@ namespace Swarmops.Database
DbCommand command =
GetDbCommand(
- "SELECT FinancialAccountId,Name,OrganizationId,AccountType,ParentFinancialAccountId,OwnerPersonId From FinancialAccounts WHERE FinancialAccountId=" +
+ "SELECT " + financialAccountFieldSequence + " WHERE FinancialAccountId=" +
financialAccountId + ";", connection);
using (DbDataReader reader = command.ExecuteReader())
@@ -68,7 +93,7 @@ namespace Swarmops.Database
DbCommand command =
GetDbCommand(
- "SELECT FinancialAccountId,Name,OrganizationId,AccountType,ParentFinancialAccountId,OwnerPersonId From FinancialAccounts WHERE OrganizationId=" +
+ "SELECT " + financialAccountFieldSequence + " WHERE OrganizationId=" +
organizationId + " ORDER BY AccountType, Name;", connection);
using (DbDataReader reader = command.ExecuteReader())
@@ -93,7 +118,7 @@ namespace Swarmops.Database
DbCommand command =
GetDbCommand(
- "SELECT FinancialAccountId,Name,OrganizationId,AccountType,ParentFinancialAccountId,OwnerPersonId From FinancialAccounts WHERE OwnerPersonId=" +
+ "SELECT " + financialAccountFieldSequence + " WHERE OwnerPersonId=" +
ownerPersonId + " ORDER BY Name;", connection);
using (DbDataReader reader = command.ExecuteReader())
@@ -118,7 +143,7 @@ namespace Swarmops.Database
DbCommand command =
GetDbCommand(
- "SELECT FinancialAccountId,Name,OrganizationId,AccountType,ParentFinancialAccountId,OwnerPersonId From FinancialAccounts WHERE FinancialAccountId IN (" +
+ "SELECT " + financialAccountFieldSequence + " WHERE FinancialAccountId IN (" +
JoinIds(financialAccountIds) + ") ORDER BY AccountType, Name;", connection);
using (DbDataReader reader = command.ExecuteReader())
@@ -679,8 +704,12 @@ namespace Swarmops.Database
var accountType = (FinancialAccountType) reader.GetInt32(3);
int parentFinancialAccountId = reader.GetInt32(4);
int ownerPersonId = reader.GetInt32(5);
+ int dimension = reader.GetInt32(6);
+ bool open = reader.GetBoolean(7);
+ int openedYear = reader.GetInt32(8);
+ int closedYear = reader.GetInt32(9);
- return new BasicFinancialAccount(accountId, name, accountType, organizationId, parentFinancialAccountId, ownerPersonId);
+ return new BasicFinancialAccount(accountId, name, accountType, organizationId, parentFinancialAccountId, ownerPersonId, dimension, open, openedYear, closedYear);
}
private BasicFinancialAccountRow ReadFinancialAccountRowFromDataReader (DbDataReader reader)
@@ -957,7 +986,7 @@ namespace Swarmops.Database
DbCommand command =
GetDbCommand(
- "SELECT FinancialAccountId,Name,OrganizationId,AccountType,ParentFinancialAccountId,OwnerPersonId FROM FinancialAccounts WHERE ParentFinancialAccountId = " + parentFinancialAccountId.ToString() +
+ "SELECT " + financialAccountFieldSequence + " WHERE ParentFinancialAccountId = " + parentFinancialAccountId.ToString() +
" ORDER BY \"Name\"", connection);
using (DbDataReader reader = command.ExecuteReader())
diff --git a/Logic/Financial/FinancialAccount.cs b/Logic/Financial/FinancialAccount.cs
index ab2caf77..7505f3dc 100644
--- a/Logic/Financial/FinancialAccount.cs
+++ b/Logic/Financial/FinancialAccount.cs
@@ -1,6 +1,7 @@
using System;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
+using Swarmops.Basic.Types.Financial;
using Swarmops.Database;
using Swarmops.Logic.Interfaces;
using Swarmops.Logic.Swarm;
@@ -111,6 +112,19 @@ namespace Swarmops.Logic.Financial
}
}
+ public int Dimension
+ {
+ get { return base.Dimension; }
+ set
+ {
+ if (base.Dimension != value)
+ {
+ SwarmDb.GetDatabaseForWriting().SetFinancialAccountDimension(this.Identity, value);
+ base.Dimension = value;
+ }
+ }
+ }
+
public Person Owner
{
get
diff --git a/Logic/Financial/FinancialAccounts.cs b/Logic/Financial/FinancialAccounts.cs
index 3e4bd6f7..a167e351 100644
--- a/Logic/Financial/FinancialAccounts.cs
+++ b/Logic/Financial/FinancialAccounts.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
+using Swarmops.Basic.Types.Financial;
using Swarmops.Database;
using Swarmops.Logic.Swarm;
using Swarmops.Logic.Structure;
diff --git a/Logic/Financial/OrganizationFinancialAccounts.cs b/Logic/Financial/OrganizationFinancialAccounts.cs
index 0243ac8c..b4afe813 100644
--- a/Logic/Financial/OrganizationFinancialAccounts.cs
+++ b/Logic/Financial/OrganizationFinancialAccounts.cs
@@ -182,6 +182,17 @@ namespace Swarmops.Logic.Financial
get { return this[OrganizationFinancialAccountType.IncomeSales]; }
}
+ public FinancialAccount IncomeTypeUnspecified
+ {
+ // dimension 2
+ get { return this[OrganizationFinancialAccountType.IncomeTypeUnspecified]; }
+ }
+
+ public FinancialAccount CostTypeUnspecified
+ {
+ // dimension 2
+ get { return this[OrganizationFinancialAccountType.CostTypeUnspecified]; }
+ }
public FinancialAccounts CostsConferences
{
diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs
index 1bc4888e..74cffbf2 100644
--- a/Logic/Structure/Organization.cs
+++ b/Logic/Structure/Organization.cs
@@ -265,6 +265,17 @@ namespace Swarmops.Logic.Structure
FinancialAccounts[OrganizationFinancialAccountType.IncomeSales] =
FinancialAccount.Create(this.Identity, "Sales", FinancialAccountType.Income, 0);
+ // 2-dimension base accounts
+
+ FinancialAccount incomeUnspecified = FinancialAccount.Create(this.Identity, "Unspecified Income", FinancialAccountType.Income, 0);
+ incomeUnspecified.Dimension = 2;
+ FinancialAccounts[OrganizationFinancialAccountType.IncomeTypeUnspecified] = incomeUnspecified;
+
+ FinancialAccount costUnspecified = FinancialAccount.Create(this.Identity, "Unspecified Cost", FinancialAccountType.Cost, 0);
+ costUnspecified.Dimension = 2;
+ FinancialAccounts[OrganizationFinancialAccountType.CostTypeUnspecified] = costUnspecified;
+
+
// Then, create various cost accounts that are probably needed, or that could be used as a starting point
FinancialAccount.Create(this.Identity, "Offices", FinancialAccountType.Cost, 0);
diff --git a/Logic/Support/SingularFactory.cs b/Logic/Support/SingularFactory.cs
index 764730fe..a1bc35c4 100644
--- a/Logic/Support/SingularFactory.cs
+++ b/Logic/Support/SingularFactory.cs
@@ -53,7 +53,7 @@ namespace Swarmops.Logic.Support
case "Swarmops.Basic.Types.BasicInboundInvoice":
return InboundInvoice.FromBasic((BasicInboundInvoice) basic);
- case "Swarmops.Basic.Types.BasicFinancialAccount":
+ case "Swarmops.Basic.Types.Financial.BasicFinancialAccount":
return FinancialAccount.FromBasic((BasicFinancialAccount)basic);
case "Swarmops.Basic.Types.BasicFinancialTransaction":
diff --git a/Site5/App_GlobalResources/Pages.Financial.resx b/Site5/App_GlobalResources/Pages.Financial.resx
index 0a0dc0f3..82075be1 100644
--- a/Site5/App_GlobalResources/Pages.Financial.resx
+++ b/Site5/App_GlobalResources/Pages.Financial.resx
@@ -190,6 +190,44 @@
Salary #{0} for {1} was DE-attested. It will not be paid out unless attested again.
When somebody undoes a previous attestation.
+
+ Expense claim amount (in {0})
+ {0} is the currency.
+
+
+ Account Number
+
+
+ Clearing Number
+
+
+ Bank Name
+
+
+ Budget
+
+
+ Cost Type
+ This is the 2nd bookkeeping dimension.
+
+
+ Description
+
+
+ Your Bank Details
+
+
+ Upload Receipt Image Files
+
+
+ If you have made a purchase on behalf of the organization using your private funds, you will likely want reimbursement for that by filing an <em>expense claim</em>. You do that here by uploading the receipts and selecting the budget they should be charged to. If you have previously received a cash advance for this purchase, this is where you clear the organization's loan to you by submitting receipts.
+
+
+ Request Money Back For Expense
+
+
+ Receipt Files:
+
Amount
Amount to be paid out
diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master
index 95cdc94b..c868412d 100644
--- a/Site5/Master-v5.master
+++ b/Site5/Master-v5.master
@@ -7,7 +7,7 @@
-
+
@@ -151,7 +151,7 @@
-
+
diff --git a/Site5/Pages/v5/Financial/FileExpenseClaim.aspx b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx
new file mode 100644
index 00000000..7048b79c
--- /dev/null
+++ b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx
@@ -0,0 +1,96 @@
+<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="FileExpenseClaim.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.FileExpenseClaim" %>
+<%@ Register src="~/Controls/v5/UI/ExternalScripts.ascx" tagname="ExternalScripts" tagprefix="Swarmops5" %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs
new file mode 100644
index 00000000..8d3106c1
--- /dev/null
+++ b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs
@@ -0,0 +1,120 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using Swarmops.Logic.Financial;
+
+namespace Swarmops.Frontend.Pages.v5.Financial
+{
+ public partial class FileExpenseClaim : PageV5Base
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!this.CurrentOrganization.IsEconomyEnabled)
+ {
+ Response.Redirect("/Pages/v5/Financial/EconomyNotEnabled.aspx", true);
+ return;
+ }
+
+ this.PageTitle = Resources.Pages.Financial.FileExpenseClaim_PageTitle;
+ this.PageIcon = "iconshock-moneyback";
+ this.InfoBoxLiteral = Resources.Pages.Financial.FileExpenseClaim_Info;
+
+ if (!Page.IsPostBack)
+ {
+ // Prime bank details
+
+ this.TextBank.Text = this.CurrentUser.BankName;
+ this.TextClearing.Text = this.CurrentUser.BankClearing;
+ this.TextAccount.Text = this.CurrentUser.BankAccount;
+ this.TextAmount.Text = 0.ToString("N2");
+ this.TextAmount.Focus();
+
+ Localize();
+ }
+ }
+
+
+ private void Localize()
+ {
+ this.LabelAmount.Text = string.Format(Resources.Pages.Financial.FileExpenseClaim_Amount,
+ CurrentOrganization.Currency.Code);
+ this.LabelPurpose.Text = Resources.Pages.Financial.FileExpenseClaim_Description;
+ this.LabelBudget.Text = Resources.Pages.Financial.FileExpenseClaim_Budget;
+ this.LabelHeaderBankDetails.Text = Resources.Pages.Financial.FileExpenseClaim_HeaderBankDetails;
+ this.LabelBankName.Text = Resources.Pages.Financial.FileExpenseClaim_BankName;
+ this.LabelBankClearing.Text = Resources.Pages.Financial.FileExpenseClaim_BankClearing;
+ this.LabelBankAccount.Text = Resources.Pages.Financial.FileExpenseClaim_BankAccount;
+
+ this.LiteralErrorAmount.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Amount;
+ this.LiteralErrorPurpose.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Purpose;
+ this.LiteralErrorBudget.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Budget;
+ this.LiteralErrorBankName.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankName;
+ this.LiteralErrorBankClearing.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankClearing;
+ this.LiteralErrorBankAccount.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankAccount;
+ }
+
+
+ protected void ButtonRequest_Click(object sender, EventArgs e)
+ {
+ // The data has been validated client-side already. We'll throw unfriendly exceptions if invalid data is passed here.
+
+ double amount = Double.Parse(this.TextAmount.Text, NumberStyles.Number);
+ // parses in current culture - intentional
+ Int64 amountCents = (Int64) amount*100;
+
+ string description = this.TextPurpose.Text;
+
+ FinancialAccount budget = FinancialAccount.FromIdentity(Int32.Parse(this.Request.Form["DropBudgets"]));
+
+ // sanity check
+
+ if (budget.Organization.Identity != CurrentOrganization.Identity)
+ {
+ throw new InvalidOperationException("Budget-organization mismatch; won't file cash advance");
+ }
+
+ // Store bank details for current user
+
+ CurrentUser.BankName = this.TextBank.Text;
+ CurrentUser.BankClearing = this.TextClearing.Text;
+ CurrentUser.BankAccount = this.TextAccount.Text;
+
+ // Create cash advance
+
+ CashAdvance cashAdvance = CashAdvance.Create(CurrentOrganization, CurrentUser, CurrentUser, amountCents,
+ budget,
+ description);
+
+ // Create success message
+ /*
+ string successMessage = string.Format(Resources.Pages.Financial.FileExpenseClaim_SuccessMessagePartOne,
+ HttpUtility.HtmlEncode(CurrentUser.Name),
+ HttpUtility.HtmlEncode(description), CurrentOrganization.Currency.Code,
+ (double) (amountCents/100.0));
+
+ if (budget.OwnerPersonId != CurrentUser.Identity)
+ {
+ successMessage += "
" + Resources.Pages.Financial.FileExpenseClaim_SuccessMessagePartTwo +
+ "
";
+ }
+ else
+ {
+ successMessage += "
" +
+ Resources.Pages.Financial.FileExpenseClaim_SuccessMessagePartTwoOwnBudget +
+ "
";
+ // TODO: Auto-attest
+ }
+
+ Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode(successMessage)));
+ */
+
+ // Redirect to dashboard
+
+ Response.Redirect("/", true);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Site5/Pages/v5/Financial/RequestCashAdvance.aspx b/Site5/Pages/v5/Financial/RequestCashAdvance.aspx
index bbb4a5e4..bb69328e 100644
--- a/Site5/Pages/v5/Financial/RequestCashAdvance.aspx
+++ b/Site5/Pages/v5/Financial/RequestCashAdvance.aspx
@@ -8,7 +8,8 @@