Work on create tx, org sequence#
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Swarmops.Database
|
||||
/// </summary>
|
||||
public static int DbVersionExpected
|
||||
{
|
||||
get { return 34; }
|
||||
get { return 35; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,28 @@
|
||||
<!-- TODO: Add nice autocomplete stuff -->
|
||||
|
||||
<% if (this.Layout == LayoutDirection.Vertical) { %><div class="stacked-input-control"><% } %>
|
||||
<asp:TextBox ID="Input" runat="server" CssClass="alignRight" /><asp:HiddenField ID="NativeCurrency" runat="server"/><asp:HiddenField ID="NativeAmount" runat="server" />
|
||||
<% if (this.Layout == LayoutDirection.Vertical) { %></div><% } %>
|
||||
<asp:TextBox ID="TextInput" runat="server" CssClass="alignRight" /><asp:HiddenField ID="NativeCurrency" runat="server"/><asp:HiddenField ID="NativeAmount" runat="server" />
|
||||
<% if (this.Layout == LayoutDirection.Vertical) { %></div><% } %>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function <%=this.ClientID%>_focus() {
|
||||
$('#<%=this.TextInput.ClientID%>').focus();
|
||||
}
|
||||
|
||||
function <%=this.ClientID%>_setValue(newValue) {
|
||||
$('#<%=this.TextInput.ClientID%>').val(newValue);
|
||||
}
|
||||
|
||||
function <%=this.ClientID%>_val() {
|
||||
return $('#<%=this.TextInput.ClientID%>').val();
|
||||
}
|
||||
|
||||
function <%=this.ClientID%>_initialize(initValue) {
|
||||
_initVal_<%=this.TextInput.ClientID%> = initValue;
|
||||
<%=this.ClientID%>_setValue(initValue);
|
||||
// <%=this.ClientID%>_enable();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -13,13 +13,13 @@ namespace Swarmops.Frontend.Controls.Financial {
|
||||
public partial class CurrencyTextBox {
|
||||
|
||||
/// <summary>
|
||||
/// Input control.
|
||||
/// TextInput control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox Input;
|
||||
protected global::System.Web.UI.WebControls.TextBox TextInput;
|
||||
|
||||
/// <summary>
|
||||
/// NativeCurrency control.
|
||||
|
||||
@@ -13,6 +13,17 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#spanActionAddTransaction').click(function() {
|
||||
if (canWriteRows) {
|
||||
<%=this.DialogCreateTx.ClientID%>_open();
|
||||
<%=this.TextCreateTxDateTime.ClientID%>_focus();
|
||||
<%=this.TextAmountNewTransaction.ClientID%>_initialize('<%=(0.0).ToString("N2")%>');
|
||||
<%=this.TextCreateTxDateTime.ClientID%>_initialize('<%=DateTime.UtcNow.ToShortDateString() + " " + DateTime.UtcNow.ToShortTimeString()%>');
|
||||
} else {
|
||||
alertify.error("You do not have sufficient authority to create transactions.");
|
||||
}
|
||||
});
|
||||
|
||||
$('#gridLedgers').datagrid(
|
||||
{
|
||||
onLoadSuccess: function() {
|
||||
@@ -354,10 +365,34 @@
|
||||
</DialogCode>
|
||||
</Swarmops5:ModalDialog>
|
||||
|
||||
|
||||
<Swarmops5:ModalDialog ID="DialogCreateTx" runat="server">
|
||||
<DialogCode>
|
||||
<h2><asp:Label runat="server" ID="LabelCreateTxDialogHeader">Creating Transaction</asp:Label></h2>
|
||||
<div class="entryFields">
|
||||
<Swarmops5:AjaxTextBox ID="TextCreateTxDateTime" runat="server"/>
|
||||
<Swarmops5:AjaxTextBox ID="TextCreateTxDescription" runat="server"/>
|
||||
<Swarmops5:ComboBudgets ID="DropBudgetsNewTransaction" ListType="All" runat="server"/>
|
||||
<Swarmops5:CurrencyTextBox ID="TextAmountNewTransaction" runat="server"/>
|
||||
<input type="button" class="NoInputFocus buttonAccentColor" value="Create XYZ"/>
|
||||
</div>
|
||||
<div class="entryLabels">
|
||||
Date and Time XYZ<br/>
|
||||
Description XYZ<br/>
|
||||
First transaction row's account<br/>
|
||||
First transaction row's amount
|
||||
</div>
|
||||
</DialogCode>
|
||||
</Swarmops5:ModalDialog>
|
||||
|
||||
|
||||
</asp:Content>
|
||||
|
||||
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
|
||||
<asp:Panel runat="server" ID="PanelCreateTxVisible">
|
||||
<h2 class="blue">ACTIONS<span class="arrow"></span></h2>
|
||||
<div class="box"><span id="spanActionAddTransaction">Add Transaction</span></div>
|
||||
|
||||
</asp:Panel>
|
||||
</asp:Content>
|
||||
|
||||
@@ -299,5 +299,68 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelTrackedTransactionHeader;
|
||||
|
||||
/// <summary>
|
||||
/// DialogCreateTx control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Swarmops.Frontend.Controls.Base.ModalDialog DialogCreateTx;
|
||||
|
||||
/// <summary>
|
||||
/// LabelCreateTxDialogHeader control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelCreateTxDialogHeader;
|
||||
|
||||
/// <summary>
|
||||
/// TextCreateTxDateTime control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Swarmops.Frontend.Controls.Base.AjaxTextBox TextCreateTxDateTime;
|
||||
|
||||
/// <summary>
|
||||
/// TextCreateTxDescription control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Swarmops.Frontend.Controls.Base.AjaxTextBox TextCreateTxDescription;
|
||||
|
||||
/// <summary>
|
||||
/// DropBudgetsNewTransaction control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Swarmops.Controls.Financial.ComboBudgets DropBudgetsNewTransaction;
|
||||
|
||||
/// <summary>
|
||||
/// TextAmountNewTransaction control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Swarmops.Frontend.Controls.Financial.CurrencyTextBox TextAmountNewTransaction;
|
||||
|
||||
/// <summary>
|
||||
/// PanelCreateTxVisible control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Panel PanelCreateTxVisible;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user