Merge branch 'master' into accountplan

This commit is contained in:
Rick Falkvinge
2014-09-25 20:38:53 +02:00
10 changed files with 6312 additions and 6 deletions
+4
View File
@@ -167,6 +167,10 @@ namespace Swarmops.Backend
OutboundComm.CreateNotification(null, NotificationResource.System_Startup);
// Checking for schemata upgrade
DatabaseMaintenance.UpgradeSchemata();
// Check for existence of installation ID. If not, create one. Warning: has privacy implications when communicated.
if (Persistence.Key["SwarmopsInstallationId"] == string.Empty)
+9 -2
View File
@@ -1,5 +1,12 @@
#!/bin/bash
#Update schemata
cd /home/prod/Smallwebs/Activizr-repo/schemas
echo "Checking for updates to schema..."
svn update
cd /home/packager/swarmops
#Update all files, including this one. Runpos will remain same in possible new version
echo "Checking for updates to packaging process..."
svn update
@@ -38,9 +45,9 @@ echo ""
echo "Notifying developers that new build has packaged for test/deployment..."
if [ "$DROPFOLDER" == "internal" ]; then
echo "The packages (swarmops-frontend-internal, swarmops-backend-internal) are available from repositories now, and can be tested at http://dev.swarmops.com/ as usual. Last 3 commits on 'master':" > deploymsg.txt
echo "$(cat ../lastbuild/swarmops/internal/CommitMessage.txt)" > deploymsg.txt
echo "" >> deploymsg.txt
echo "$(cat ../lastbuild/swarmops/internal/CommitMessage.txt)" >> deploymsg.txt
echo "The packages (swarmops-frontend-internal, swarmops-backend-internal) are available from repositories now, and can be tested at http://dev.swarmops.com/ as usual. Last 3 commits listed above." >> deploymsg.txt
else
echo "NOTE: this is a $DROPFOLDER package bundle. It will deploy automatically to live systems via apt-get upgrade. Yay, we made another sprint!" > deploymsg.txt
fi
+1 -1
View File
@@ -158,7 +158,7 @@ scripts/update-repos swarmops-$PACKAGENAME-latest.deb
if [ "$2" == "" ]; then
echo "Installing INTERNAL BUILD on swarmops-dev for testing..."
dpkg -i swarmops-$PACKAGENAME-latest.deb
sudo dpkg -i --force-confdef swarmops-$PACKAGENAME-latest.deb
fi
echo "Cleaning up..."
File diff suppressed because it is too large Load Diff
+119
View File
@@ -0,0 +1,119 @@
ALTER TABLE `FinancialAccounts`
ADD COLUMN `Active` TINYINT NOT NULL DEFAULT '1' AFTER `Administrative`,
ADD COLUMN `LinkBackward` INT NOT NULL DEFAULT 0 AFTER `Active`,
ADD COLUMN `LinkForward` INT NOT NULL DEFAULT 0 AFTER `LinkBackward`
#
CREATE PROCEDURE `SetFinancialAccountActive`(
IN financialAccountId INTEGER,
IN active TINYINT
)
BEGIN
UPDATE FinancialAccounts SET FinancialAccounts.Active = active
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
END
#
CREATE PROCEDURE `SetFinancialAccountExpensable`(
IN financialAccountId INTEGER,
IN expensable TINYINT
)
BEGIN
UPDATE FinancialAccounts SET FinancialAccounts.Expensable = expensable
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
END
#
CREATE PROCEDURE `SetFinancialAccountAdministrative`(
IN financialAccountId INTEGER,
IN administrative TINYINT
)
BEGIN
UPDATE FinancialAccounts SET FinancialAccounts.Administrative = administrative
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
END
#
CREATE PROCEDURE `SetFinancialAccountLinkBackward`(
IN financialAccountId INTEGER,
IN linkBackward INTEGER
)
BEGIN
UPDATE FinancialAccounts SET FinancialAccounts.LinkBackward = linkBackward
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
END
#
CREATE PROCEDURE `SetFinancialAccountLinkForward`(
IN financialAccountId INTEGER,
IN linkForward INTEGER
)
BEGIN
UPDATE FinancialAccounts SET FinancialAccounts.LinkForward = linkForward
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
END
#
CREATE PROCEDURE `SetFinancialAccountParent`(
IN financialAccountId INTEGER,
IN parentFinancialAccountId INTEGER
)
BEGIN
UPDATE FinancialAccounts SET FinancialAccounts.ParentFinancialAccountId = parentFinancialAccountId
WHERE FinancialAccounts.FinancialAccountId=financialAccountId;
END
#
CREATE PROCEDURE `MoveFinancialTransactionRowRangeToNewAccount`(
IN oldFinancialAccountId INTEGER,
IN newFinancialAccountId INTEGER,
IN startDate DATETIME,
IN endDate DATETIME
)
BEGIN
UPDATE FinancialTransactionRows
JOIN FinancialTransactions ON FinancialTransactions.FinancialTransactionId=FinancialTransactionRows.FinancialTransactionId
SET FinancialTransactionRows.FinancialAccountId=newFinancialAccountId
WHERE FinancialTransactions.DateTime >= startDate AND FinancialTransactions.DateTime < endDate
AND FinancialTransactionRows.FinancialAccountId=oldFinancialAccountId;
END
@@ -99,6 +99,26 @@ namespace Swarmops.Logic.App_GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Your request for a cash advance with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been marked as paid out by the organization&apos;s accountants.
///
///This means you should see the amount on your account shortly..
/// </summary>
internal static string CashAdvance_PaidOut_Body {
get {
return ResourceManager.GetString("CashAdvance_PaidOut_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string CashAdvance_PaidOut_Subject {
get {
return ResourceManager.GetString("CashAdvance_PaidOut_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [ConcernedPersonName] has requested a cash advance of [CurrencyCode] [BudgetAmountFloat] for the purpose of [RequestPurpose]. This money is part of your budget, [BudgetName].
///
@@ -215,6 +235,26 @@ namespace Swarmops.Logic.App_GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been marked as paid out by the organization&apos;s accountants.
///
///This means you should see the amount on your account shortly..
/// </summary>
internal static string ExpenseClaim_PaidOut_Body {
get {
return ResourceManager.GetString("ExpenseClaim_PaidOut_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string ExpenseClaim_PaidOut_Subject {
get {
return ResourceManager.GetString("ExpenseClaim_PaidOut_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The receipts for your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], have been validated by people responsible for keeping the records in order.
///
@@ -275,6 +315,26 @@ namespace Swarmops.Logic.App_GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
///
///This is for information only. You do not need to take action..
/// </summary>
internal static string System_DatabaseSchemaUpgraded_Body {
get {
return ResourceManager.GetString("System_DatabaseSchemaUpgraded_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Swarmops database upgraded.
/// </summary>
internal static string System_DatabaseSchemaUpgraded_Subject {
get {
return ResourceManager.GetString("System_DatabaseSchemaUpgraded_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to An unhandled exception was thrown in Swarmops:
///
@@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CashAdvance_Attested_Body" xml:space="preserve">
<value>Your requested cash advance with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been attested by the budget owner. It will now proceed to payout to you.</value>
@@ -131,6 +131,14 @@ Expect more communication from the budget owner to follow on the matter.</value>
<data name="CashAdvance_Deattested_Subject" xml:space="preserve">
<value>[OrganizationName] Cash Advance DE-attested: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="CashAdvance_PaidOut_Body" xml:space="preserve">
<value>Your request for a cash advance with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been marked as paid out by the organization's accountants.
This means you should see the amount on your account shortly.</value>
</data>
<data name="CashAdvance_PaidOut_Subject" xml:space="preserve">
<value>[OrganizationName] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="CashAdvance_Requested_Body" xml:space="preserve">
<value>[ConcernedPersonName] has requested a cash advance of [CurrencyCode] [BudgetAmountFloat] for the purpose of [RequestPurpose]. This money is part of your budget, [BudgetName].
@@ -181,6 +189,14 @@ Expect more communication to follow on the matter. If you don't hear from record
<data name="ExpenseClaim_Devalidated_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_PaidOut_Body" xml:space="preserve">
<value>Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been marked as paid out by the organization's accountants.
This means you should see the amount on your account shortly.</value>
</data>
<data name="ExpenseClaim_PaidOut_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Validated_Body" xml:space="preserve">
<value>The receipts for your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], have been validated by people responsible for keeping the records in order.
@@ -206,6 +222,14 @@ Please log on to Swarmops at [SystemUrl] to confirm or reject them.</value>
<data name="Receipts_Filed_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed</value>
</data>
<data name="System_DatabaseSchemaUpgraded_Body" xml:space="preserve">
<value>Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
This is for information only. You do not need to take action.</value>
</data>
<data name="System_DatabaseSchemaUpgraded_Subject" xml:space="preserve">
<value>Swarmops database upgraded</value>
</data>
<data name="System_Exception_Body" xml:space="preserve">
<value>An unhandled exception was thrown in Swarmops:
@@ -89,12 +89,14 @@ namespace Swarmops.Logic.Communications.Transmission
Unknown = 0,
System_Startup,
System_Exception,
System_DatabaseSchemaUpgraded,
CashAdvance_Requested,
CashAdvance_Attested,
CashAdvance_Deattested,
CashAdvance_Denied,
CashAdvance_Adjusted,
CashAdvance_Rebudgeted,
CashAdvance_PaidOut,
ExpenseClaim_Created,
ExpenseClaim_Attested,
ExpenseClaim_Deattested,
@@ -103,6 +105,7 @@ namespace Swarmops.Logic.Communications.Transmission
ExpenseClaim_Denied,
ExpenseClaim_Adjusted,
ExpenseClaim_Rebudgeted,
ExpenseClaim_PaidOut,
Payout_Settled,
InboundInvoice_Created,
Receipts_Filed
+6
View File
@@ -6,6 +6,8 @@ using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Financial;
using Swarmops.Database;
using Swarmops.Logic.Communications;
using Swarmops.Logic.Communications.Transmission;
using Swarmops.Logic.Support.LogEntries;
using Swarmops.Logic.Swarm;
using Swarmops.Logic.Structure;
@@ -229,6 +231,8 @@ namespace Swarmops.Logic.Financial
"Cash Advance Paid Out"),
advance.Person, advance);
OutboundComm.CreateNotificationOfFinancialValidation(advance.Budget, advance.Person, (double)advance.AmountCents / 100.0, advance.Description, NotificationResource.CashAdvance_PaidOut);
}
string referenceString = string.Empty;
@@ -289,6 +293,8 @@ namespace Swarmops.Logic.Financial
claim.Repaid = true;
claim.Close();
OutboundComm.CreateNotificationOfFinancialValidation(claim.Budget, claim.Claimer, (double)claim.AmountCents / 100.0, claim.Description, NotificationResource.ExpenseClaim_PaidOut);
}
else if (component[0] == 'a')
{
+39 -1
View File
@@ -5,6 +5,9 @@ using System.Net;
using System.Text;
using Swarmops.Logic.Swarm;
using Swarmops.Database;
using System.Globalization;
using Swarmops.Logic.Communications;
using Swarmops.Logic.Communications.Transmission;
namespace Swarmops.Logic.Support
{
@@ -38,7 +41,7 @@ namespace Swarmops.Logic.Support
using (WebClient client = new WebClient())
{
sql = client.DownloadString("http://packages.swarmops.com/schemas/initialize.sql"); // Hardcoded as security measure - don't want to pass arbitrary sql in from web layer
sql = client.DownloadString("http://packages.swarmops.com/schemata/initialize.sql"); // Hardcoded as security measure - don't want to pass arbitrary sql in from web layer
}
string[] sqlCommands = sql.Split('#'); // in the file, the commands are split by a single # sign. (Semicolons are an integral part of storedprocs, so they can't be used.)
@@ -50,5 +53,40 @@ namespace Swarmops.Logic.Support
SwarmDb.GetDatabaseForWriting().SetKeyValue("DbVersion", "1"); // We're at baseline
}
static public void UpgradeSchemata()
{
int currentDbVersion = Int32.Parse(SwarmDb.GetDatabaseForReading().GetKeyValue("DbVersion"));
int expectedDbVersion = SwarmDb.DbVersion;
string sql;
bool upgraded = false;
while (currentDbVersion < expectedDbVersion)
{
currentDbVersion++;
string fileName = String.Format("http://packages.swarmops.com/schemata/upgrade-{0:D4}.sql", currentDbVersion);
using (WebClient client = new WebClient())
{
sql = client.DownloadString(fileName);
}
string[] sqlCommands = sql.Split('#'); // in the file, the commands are split by a single # sign. (Semicolons are an integral part of storedprocs, so they can't be used.)
foreach (string sqlCommand in sqlCommands)
{
SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommand(sqlCommand.Trim());
}
upgraded = true;
SwarmDb.GetDatabaseForWriting().SetKeyValue("DbVersion", currentDbVersion.ToString(CultureInfo.InvariantCulture)); // Increment after each successful run
}
if (upgraded)
{
OutboundComm.CreateNotification(null, NotificationResource.System_DatabaseSchemaUpgraded);
}
}
}
}