diff --git a/Database/Configuration.cs b/Database/Configuration.cs index bc95612e..16c9a3e2 100644 --- a/Database/Configuration.cs +++ b/Database/Configuration.cs @@ -14,7 +14,7 @@ namespace Swarmops.Database /// public static int DbVersionExpected { - get { return 34; } + get { return 35; } } diff --git a/Database/Database-Financials.cs b/Database/Database-Financials.cs index bd2602de..537a930d 100644 --- a/Database/Database-Financials.cs +++ b/Database/Database-Financials.cs @@ -1048,6 +1048,23 @@ namespace Swarmops.Database } + + + public void SetFinancialTransactionOrganizationSequenceId(int financialTransactionId) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetFinancialTransactionOrganizationSequenceId", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "financialTransactionId", financialTransactionId); + + command.ExecuteNonQuery(); + } + } + public void SetFinancialTransactionForeignId(int financialTransactionId, FinancialForeignIdType foreignIdType, string foreignId) { using (DbConnection connection = GetMySqlDbConnection()) diff --git a/Logic/Financial/FinancialTransaction.cs b/Logic/Financial/FinancialTransaction.cs index 2df9e42f..3d749481 100644 --- a/Logic/Financial/FinancialTransaction.cs +++ b/Logic/Financial/FinancialTransaction.cs @@ -62,7 +62,10 @@ namespace Swarmops.Logic.Financial return null; // This was a dupe -- already imported, as determined by ImportHash } - return FromIdentityAggressive (transactionId); + FinancialTransaction newTx = FromIdentityAggressive (transactionId); + newTx.SetOrganizationSequenceId(); + + return newTx; } @@ -70,7 +73,11 @@ namespace Swarmops.Logic.Financial { int transactionId = SwarmDb.GetDatabaseForWriting() .CreateFinancialTransaction (organizationId, dateTime, description); - return FromIdentityAggressive (transactionId); + + FinancialTransaction newTx = FromIdentityAggressive(transactionId); + newTx.SetOrganizationSequenceId(); + + return newTx; } public static FinancialTransaction Create (Organization organization, DateTime dateTime, string description) @@ -86,7 +93,7 @@ namespace Swarmops.Logic.Financial { return FinancialTransactionRows.FromArray ( - SwarmDb.GetDatabaseForReading().GetFinancialTransactionRows (Identity)); + SwarmDb.GetDatabaseForReading().GetFinancialTransactionRows (this.Identity)); } } @@ -470,5 +477,15 @@ namespace Swarmops.Logic.Financial currentTransactionData[row.FinancialAccountId] += row.AmountCents; } } + + internal void SetOrganizationSequenceId() + { + if (this.Identity == 0) + { + throw new ArgumentOutOfRangeException("Cannot set the sequence number for a null transaction"); + } + + SwarmDb.GetDatabaseForWriting().SetFinancialTransactionOrganizationSequenceId(this.Identity); + } } } \ No newline at end of file diff --git a/Site/Controls/v5/Financial/CurrencyTextBox.ascx b/Site/Controls/v5/Financial/CurrencyTextBox.ascx index 5fdbdd1a..af8168a3 100644 --- a/Site/Controls/v5/Financial/CurrencyTextBox.ascx +++ b/Site/Controls/v5/Financial/CurrencyTextBox.ascx @@ -4,5 +4,28 @@ <% if (this.Layout == LayoutDirection.Vertical) { %>
<% } %> - - <% if (this.Layout == LayoutDirection.Vertical) { %>
<% } %> \ No newline at end of file + + <% if (this.Layout == LayoutDirection.Vertical) { %><% } %> + + + diff --git a/Site/Controls/v5/Financial/CurrencyTextBox.ascx.cs b/Site/Controls/v5/Financial/CurrencyTextBox.ascx.cs index 39db0411..0e4a2a50 100644 --- a/Site/Controls/v5/Financial/CurrencyTextBox.ascx.cs +++ b/Site/Controls/v5/Financial/CurrencyTextBox.ascx.cs @@ -13,7 +13,7 @@ namespace Swarmops.Frontend.Controls.Financial { protected void Page_Load (object sender, EventArgs e) { - this.Input.Attributes["role"] = "note"; // disable Lastpass trying to autofill + this.TextInput.Attributes["role"] = "note"; // disable Lastpass trying to autofill if (this.Layout == LayoutDirection.Unknown) { @@ -27,7 +27,7 @@ namespace Swarmops.Frontend.Controls.Financial { return (Int64) (InternalValue * 100.0 + 0.5); // the +0.5 is to compensate for floating point errors. And yes, THEY HAPPEN. } - set { this.Input.Text = (value / 100.0).ToString("N2", CultureInfo.CurrentCulture); } + set { this.TextInput.Text = (value / 100.0).ToString("N2", CultureInfo.CurrentCulture); } } public Int64 Metacents // Metacents are cents of cents, so four decimals to the currency unit. @@ -36,7 +36,7 @@ namespace Swarmops.Frontend.Controls.Financial { return (Int64)(InternalValue * 10000.0 + 0.5); // the +0.5 is to compensate for floating point errors. And yes, THEY HAPPEN. } - set { this.Input.Text = (value / 10000.0).ToString("N4", CultureInfo.CurrentCulture); } + set { this.TextInput.Text = (value / 10000.0).ToString("N4", CultureInfo.CurrentCulture); } } [Obsolete ("Use Cents or Metacents", true)] @@ -52,7 +52,7 @@ namespace Swarmops.Frontend.Controls.Financial // Try to parse the Double in two steps: first as a Culture.CurrentCulture, and if that doesn't work out, as a Culture.InvariantCulture. double outParse = 0.0; - string contents = Input.Text; + string contents = this.TextInput.Text; if (Double.TryParse (contents, NumberStyles.AllowThousands | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out outParse)) { @@ -76,7 +76,7 @@ namespace Swarmops.Frontend.Controls.Financial public new void Focus() { - this.Input.Focus(); + this.TextInput.Focus(); } } } \ No newline at end of file diff --git a/Site/Controls/v5/Financial/CurrencyTextBox.ascx.designer.cs b/Site/Controls/v5/Financial/CurrencyTextBox.ascx.designer.cs index 34c5585e..8d306db8 100644 --- a/Site/Controls/v5/Financial/CurrencyTextBox.ascx.designer.cs +++ b/Site/Controls/v5/Financial/CurrencyTextBox.ascx.designer.cs @@ -13,13 +13,13 @@ namespace Swarmops.Frontend.Controls.Financial { public partial class CurrencyTextBox { /// - /// Input control. + /// TextInput control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.TextBox Input; + protected global::System.Web.UI.WebControls.TextBox TextInput; /// /// NativeCurrency control. diff --git a/Site/Pages/v5/Ledgers/InspectLedgers.aspx b/Site/Pages/v5/Ledgers/InspectLedgers.aspx index 3ea07781..594552ee 100644 --- a/Site/Pages/v5/Ledgers/InspectLedgers.aspx +++ b/Site/Pages/v5/Ledgers/InspectLedgers.aspx @@ -13,6 +13,17 @@