Set/Get of Automation should work
This commit is contained in:
@@ -293,6 +293,12 @@
|
||||
$('body').css('overflow-y', 'hidden');
|
||||
<%=this.DialogAccount.ClientID %>_open();
|
||||
|
||||
<%=this.ToggleAssetAutomation.ClientID%>_initialize(false);
|
||||
$('.DivEditAutomationControls').hide();
|
||||
$('.DivEditNonautomationControls').hide();
|
||||
|
||||
// TODO: Initialize Automation to None, hide controls, set switch to Off and dropbox to option zero
|
||||
|
||||
$('#<%=DropParents.ClientID %>_DropBudgets').combotree('setText', "...");
|
||||
|
||||
setTimeout(function() {
|
||||
@@ -413,6 +419,14 @@
|
||||
parentAccountName = data.ParentAccountName;
|
||||
setAccountTreeId(data.ParentAccountId);
|
||||
|
||||
<%=this.ToggleAssetAutomation.ClientID%>_initialize(data.AutomationData.AutomationEnabled);
|
||||
<%=this.DropAccountAutomationProfile%>_val(data.AutomationData.AutomationProfileId); // will be 0 if not enabled, which gives correct result
|
||||
|
||||
if (data.AutomationData.AutomationEnabled) {
|
||||
$('.DivEditAutomationControls').show();
|
||||
$('.DivEditNonautomationControls').hide();
|
||||
}
|
||||
|
||||
$('span#<%= DropOwner.ClientID %>_SpanPeople span input.textbox-text').css('background-color', '#FFF');
|
||||
$('span#<%= DropOwner.ClientID %>_SpanPeople span input.textbox-text').css('background-image', "url('" + data.AccountOwnerAvatarUrl + "')");
|
||||
$('span#<%= DropOwner.ClientID %>_SpanPeople span input.textbox-text').attr('placeholder', data.AccountOwnerName);
|
||||
@@ -523,15 +537,33 @@
|
||||
|
||||
|
||||
function onToggleChange(newValue, cookie) {
|
||||
if (newValue) {
|
||||
$(".DivEditAutomationControls").slideDown();
|
||||
$(".DivEditNonautomationControls").slideUp();
|
||||
} else {
|
||||
$(".DivEditAutomationControls").slideUp();
|
||||
$(".DivEditNonautomationControls").slideDown();
|
||||
if (cookie == "Automation")
|
||||
{
|
||||
if (newValue) {
|
||||
$(".DivEditAutomationControls").slideDown();
|
||||
$(".DivEditNonautomationControls").slideUp();
|
||||
} else {
|
||||
$(".DivEditAutomationControls").slideUp();
|
||||
$(".DivEditNonautomationControls").slideDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onAutomationProfileChange(oldValue, newValue) {
|
||||
SwarmopsJS.ajaxCall('/Pages/v5/Financial/AccountPlan.aspx/SetAccountAutomationProfile',
|
||||
{
|
||||
accountId: accountId,
|
||||
profileId: <%=this.DropAccountAutomationProfile%>_val()
|
||||
},
|
||||
function(result) {
|
||||
if (result.Success) {
|
||||
accountDirty = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var currentYear = <%=DateTime.Today.Year %>;
|
||||
var firstFiscalYear = <%=CurrentOrganization.FirstFiscalYear %>;
|
||||
var ledgersClosedUntil = <%=CurrentOrganization.Parameters.FiscalBooksClosedUntilYear %>;
|
||||
|
||||
@@ -178,7 +178,17 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
"N0");
|
||||
result.InitialBalance = "N/A"; // unused
|
||||
}
|
||||
result.CurrencyCode = account.Organization.Currency.DisplayCode;
|
||||
|
||||
result.AutomationData = GetAccountAutomationData(account.AutomationProfileId);
|
||||
|
||||
if (result.AutomationData.AutomationEnabled && result.AutomationData.NonPresentationCurrency)
|
||||
{
|
||||
result.CurrencyCode = result.AutomationData.AutomationCurrencyCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.CurrencyCode = authData.CurrentOrganization.Currency.DisplayCode;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -381,83 +391,6 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static ChangeAccountDataResult SetAccountInitialBalanceForex(int accountId, string newInitialBalanceString)
|
||||
{
|
||||
try
|
||||
{
|
||||
const string initialBalanceTransactionTitle = "Initial Balances";
|
||||
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
FinancialAccount account = FinancialAccount.FromIdentity(accountId);
|
||||
|
||||
if (!PrepareAccountChange(account, authData, false) || authData.CurrentOrganization.Parameters.FiscalBooksClosedUntilYear >= authData.CurrentOrganization.FirstFiscalYear)
|
||||
{
|
||||
return new ChangeAccountDataResult
|
||||
{
|
||||
Result = ChangeAccountDataOperationsResult.NoPermission
|
||||
};
|
||||
}
|
||||
|
||||
Int64 desiredInitialBalanceCents = Formatting.ParseDoubleStringAsCents(newInitialBalanceString);
|
||||
|
||||
Int64 currentInitialBalanceCents = account.GetDeltaCents(new DateTime(1900, 1, 1),
|
||||
new DateTime(authData.CurrentOrganization.FirstFiscalYear, 1, 1));
|
||||
|
||||
Int64 deltaCents = desiredInitialBalanceCents - currentInitialBalanceCents;
|
||||
|
||||
// Find or create "Initial Balances" transaction
|
||||
|
||||
FinancialAccountRows testRows = FinancialAccountRows.ForOrganization(authData.CurrentOrganization,
|
||||
new DateTime(1900, 1, 1), new DateTime(authData.CurrentOrganization.FirstFiscalYear, 1, 1));
|
||||
|
||||
FinancialTransaction initialBalancesTransaction = null;
|
||||
|
||||
foreach (FinancialAccountRow row in testRows)
|
||||
{
|
||||
if (row.Transaction.Description == initialBalanceTransactionTitle)
|
||||
{
|
||||
initialBalancesTransaction = row.Transaction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (initialBalancesTransaction == null)
|
||||
{
|
||||
// create transaction
|
||||
|
||||
initialBalancesTransaction = FinancialTransaction.Create(authData.CurrentOrganization.Identity,
|
||||
new DateTime(authData.CurrentOrganization.FirstFiscalYear - 1, 12, 31), initialBalanceTransactionTitle);
|
||||
}
|
||||
|
||||
Dictionary<int, Int64> recalcBase = initialBalancesTransaction.GetRecalculationBase();
|
||||
int equityAccountId = authData.CurrentOrganization.FinancialAccounts.DebtsEquity.Identity;
|
||||
|
||||
if (!recalcBase.ContainsKey(accountId))
|
||||
{
|
||||
recalcBase[accountId] = 0;
|
||||
}
|
||||
if (!recalcBase.ContainsKey(equityAccountId))
|
||||
{
|
||||
recalcBase[equityAccountId] = 0;
|
||||
}
|
||||
|
||||
recalcBase[accountId] += deltaCents;
|
||||
recalcBase[equityAccountId] -= deltaCents;
|
||||
initialBalancesTransaction.RecalculateTransaction(recalcBase, authData.CurrentUser);
|
||||
return new ChangeAccountDataResult
|
||||
{
|
||||
Result = ChangeAccountDataOperationsResult.Changed,
|
||||
NewData = (desiredInitialBalanceCents / 100.0).ToString("N2", CultureInfo.CurrentCulture)
|
||||
};
|
||||
}
|
||||
catch (Exception weirdException)
|
||||
{
|
||||
SupportFunctions.LogException("AccountPlan-SetInitBalance", weirdException);
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
@@ -661,7 +594,6 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
public bool NonPresentationCurrency { get; set; }
|
||||
public bool AutomaticRetrievalPossible { get; set; } // always false for now
|
||||
public string AutomationProfileCustomXml { get; set; } // always empty for now
|
||||
|
||||
public FinancialAccountAutomationProfile Profile { get; set; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user