Ajax Dropdown seems functional; added VAT Frequency

This commit is contained in:
Rick Falkvinge
2017-11-14 23:02:24 +01:00
parent 719fbd391a
commit 0ed08c36a4
6 changed files with 94 additions and 7 deletions
+1
View File
@@ -200,6 +200,7 @@ namespace Swarmops.Common.Enums
/// True if the organization declares inbound/outbound Value Added Tax
/// </summary>
OrgValueAddedTaxEnabled,
OrgValueAddedTaxFrequency,
OrgFinancialMailName,
OrgFinancialMailAddress,
+1 -1
View File
@@ -24,7 +24,7 @@ namespace Swarmops.Logic.Financial
// foreach organization, if organization is VAT enabled
Organization organization = Organization.FromIdentity(8); // HACK TEMPORARY HACK
int reportMonthInterval = 1; // TODO: READ FROM ORG PARAMETERS
int reportMonthInterval = organization.VatReportFrequencyMonths;
// Get the list of previous VAT reports
+17
View File
@@ -1091,6 +1091,23 @@ namespace Swarmops.Logic.Structure
}
}
public int VatReportFrequencyMonths
{
get
{
int frequency = OptionalData.GetOptionalDataInt(ObjectOptionalDataType.OrgValueAddedTaxFrequency);
if (frequency == 0)
{
return 12; // default to annual (the frequency is in months)
}
return frequency;
}
set
{
OptionalData.SetOptionalDataInt(ObjectOptionalDataType.OrgValueAddedTaxFrequency, value);
}
}
public Document LogoLandscape
{
get
+67 -3
View File
@@ -2,6 +2,7 @@
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="Swarmops.Common.Enums" %>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#<%=this.ClientID %>_DropControl').combobox({
@@ -10,11 +11,74 @@
width: 324,
panelAlign: '<%= Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft? "right": "left" %>',
panelWidth: 300<%
if (!String.IsNullOrEmpty(this.OnClientChange))
if (!String.IsNullOrEmpty(this.OnClientChange) || !String.IsNullOrEmpty(this.AjaxCallbackUrl))
{
Response.Write(",\r\nonChange: function(newVal, oldVal) { ");
if (string.IsNullOrEmpty(AjaxCallbackUrl))
{
// Only client-side notification, no server involved
Response.Write(this.OnClientChange + "(oldVal, newVal);");
}
else
{
Response.Write("$('#" + this.ClientID + "_DropControl + span.combo > input').css('background-color', '#FFFFA0');"); // set background yellow indicating processing
Response.Write(
@"var jsonData = {}; " +
@"jsonData.newValue = " + this.ClientID + "_val(); " +
@"jsonData.cookie = '" + this.Cookie + "'; " +
@"SwarmopsJS.ajaxCall(" +
@"'" + this.AjaxCallbackUrl + "'," +
@"jsonData," +
@"$.proxy(function(msg) { " +
@" if (msg.Success == false) { " +
@" if (msg.DisplayMessage != null) { " +
@" alertify.error(msg.DisplayMessage); " +
@" } else { " +
@" alertify.error(SwarmopsJS.unescape('" + this.Localized_AjaxGeneralErrorSettingValue + "')); " +
@" } " +
@" $('#" + this.ClientID + "_DropControl + span.combo > input').css('background-color', '#FFA0A0'); " + // set background red indicating error "
@" } else { " +
@" if (msg.DisplayMessage != null) { " +
@" alertify.log(msg.DisplayMessage); " +
@" } " +
@" $('#" + this.ClientID + "_DropControl + span.combo > input').css('background-color', '#E0FFE0'); "); // set background green indicating success
if (!string.IsNullOrEmpty(this.OnClientChange))
{
// There should be a callback as well once the server call returns with success
if (string.IsNullOrEmpty (this.Cookie))
{
Response.Write(",\r\nonChange: function(newVal, oldVal) { " + this.OnClientChange + "(newVal, oldVal); }");
Response.Write (this.OnClientChange + "(msg.NewValue);"); // JavaScript callback on successful change
}
else
{
Response.Write (this.OnClientChange + "(msg.NewValue, '" + this.Cookie + "');"); // JavaScript callback on successful change
}
}
Response.Write(
@" } " +
@" $('#" + this.ClientID + "_DropControl + span.combo > input').animate({ backgroundColor: '#FFFFFF' }, 250); " + // animate background back to white
@" }, this), " +
@" $.proxy(function(msg) { " +
@" alertify.error(SwarmopsJS.unescape('" + this.Localized_AjaxCallException + "')); " +
// @" $(this).val(_initVal_" + this.TextInput.ClientID + "); " + // TODO: Need failure scenario
@" $('#" + this.ClientID + "_DropControl + span.combo > input').css('background-color', '#FFA0A0'); " +
@" $('#" + this.ClientID + "_DropControl + span.combo > input').animate({ backgroundColor: '#FFFFFF' }, 250); " +
@" }, this) " +
@");"); // ends the SwarmopsJS.ajaxCall
}
Response.Write(" }"); // ends the onChange function
}
%>
});
-2
View File
@@ -1,8 +1,6 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.Admin.OrgSettings" CodeBehind="OrgSettings.aspx.cs" CodeFile="OrgSettings.aspx.cs" %>
<%@ Import Namespace="Swarmops.Frontend" %>
<%@ Register tagPrefix="Swarmops5" tagName="FileUpload" src="~/Controls/v5/Base/FileUpload.ascx" %>
<%@ Register tagPrefix="Swarmops5" tagName="DropDown" src="~/Controls/v5/Base/DropDown.ascx" %>
<%@ Register tagPrefix="Swarmops5" tagName="AjaxTextBox" src="~/Controls/v5/Base/AjaxTextBox.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
+8 -1
View File
@@ -141,6 +141,7 @@ namespace Swarmops.Frontend.Pages.Admin
org.FinancialAccounts.IncomeCurrencyFluctuations.Active);
result.AccountsVat = (org.FinancialAccounts.AssetsVatInbound != null &&
org.FinancialAccounts.AssetsVatInbound.Active);
result.VatReportPeriod = org.VatReportFrequencyMonths;
result.ParticipantFinancials = org.ParticipantFinancialsEnabled;
result.PaypalAccountAddress = org.PaypalAccountMailAddress;
@@ -479,6 +480,12 @@ namespace Swarmops.Frontend.Pages.Admin
authenticationData.CurrentOrganization.TaxPaymentOcr = result.NewValue;
break;
case "VatReportFrequency":
result.Success = true;
result.NewValue = newValue;
authenticationData.CurrentOrganization.VatReportFrequencyMonths = Int32.Parse(newValue);
break;
default:
throw new NotImplementedException("Unknown cookie in StoreCallback");
}
@@ -503,7 +510,7 @@ namespace Swarmops.Frontend.Pages.Admin
public bool AccountPaypal;
public bool AccountsForex;
public bool AccountsVat;
public int VatReportingPeriod;
public int VatReportPeriod;
public bool ParticipantFinancials;
public string PaypalAccountAddress;