Various work items

This commit is contained in:
Rick Falkvinge
2018-11-14 13:59:52 +01:00
parent 5db19f22cd
commit e934435432
15 changed files with 372 additions and 33 deletions
+1
View File
@@ -58,6 +58,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Types\Common\BlockchainHash.cs" />
<Compile Include="Types\Common\ReportRequirement.cs" />
<Compile Include="Types\Financial\BasicExpenseClaimGroup.cs" />
<Compile Include="Types\Financial\BasicHotBitcoinAddress.cs" />
<Compile Include="Types\Financial\BasicHotBitcoinAddressUnspent.cs" />
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Swarmops.Basic.Types.Common
{
public enum ReportRequirement
{
Unknown = 0,
/// <summary>
/// a report (of the discussed type) is required for this time period
/// </summary>
Required,
/// <summary>
/// a report (of the discussed type) is NOT required for this time period
/// </summary>
NotRequired,
/// <summary>
/// A report (of the discussed type) has already been completed for this time period
/// </summary>
Completed
}
}
+9 -2
View File
@@ -16,10 +16,17 @@ namespace Swarmops.Logic.Financial
public ExternalBankDataProfile Profile { get; set; }
public ExternalBankDataRecord[] Records { get; private set; }
public void LoadData (TextReader reader, Organization organization, Currency expectedCurrency)
public void LoadData (TextReader textReader, FinancialAccount automatedAccount)
{
/*
CsvHelper.Configuration.Configuration config = new CsvHelper.Configuration.Configuration();
config.HasHeaderRecord = true;
CsvReader csvReader = new CsvReader(textReader, config);
string data = reader.ReadToEnd();
LoadData (data, organization, expectedCurrency);
LoadData (data, organization, expectedCurrency);*/
}
public void LoadData (string data, Organization organization, Currency accountCurrency)
+64
View File
@@ -4,6 +4,7 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Swarmops.Basic.Types.Common;
using Swarmops.Basic.Types.Financial;
using Swarmops.Common.Enums;
using Swarmops.Common.Interfaces;
@@ -61,6 +62,69 @@ namespace Swarmops.Logic.Financial
return FromIdentityAggressive(vatReportId);
}
public static ReportRequirement IsRequired(Organization organization, int year, int month)
{
// If org isn't VAT enabled, the report is never required
if (!organization.VatEnabled)
{
return ReportRequirement.NotRequired;
}
DateTime nowUtc = DateTime.UtcNow;
int reportMonthInterval = organization.VatReportFrequencyMonths;
// Get the list of previous VAT reports
VatReports reports = VatReports.ForOrganization(organization, true);
if (reports.Count == 0)
{
DateTime firstReportGenerationTime =
new DateTime(organization.FirstFiscalYear, 1, 1).AddMonths(reportMonthInterval); // construct VAT report on the first day of the new month
if (nowUtc > firstReportGenerationTime)
{
// It's time to generate the first report
return ReportRequirement.Required;
}
}
else // if reports.Count > 0
{
reports.Sort(VatReports.VatReportSorterByDate);
DateTime lastReport = new DateTime(reports.Last().YearMonthStart / 100, reports.Last().YearMonthStart % 100,
1);
// If we generated a report in the present month, say we've done so already
if (lastReport.Year == nowUtc.Year && lastReport.Month == nowUtc.Month)
{
return ReportRequirement.Completed;
}
// Check when the next report is due
DateTime nextReport = lastReport.AddMonths(reportMonthInterval);
DateTime nextReportGenerationTime = nextReport.AddMonths(reportMonthInterval);
if (nowUtc > nextReportGenerationTime)
{
// Time for a new report
return ReportRequirement.Required;
}
// Otherwise, it looks like this is a month we don't need to make a VAT report
// (the reporting interval may be set to quarterly or annually)
return ReportRequirement.NotRequired;
}
// Not yet time for the first report
return ReportRequirement.NotRequired;
}
public static VatReport Create(Organization organization, int year, int startMonth, int monthCount)
{
VatReport newReport = CreateDbRecord(organization, year, startMonth, monthCount);
+1 -1
View File
@@ -491,7 +491,7 @@
<Compile Include="DashboardTasks\Tasks.cs" />
<Compile Include="DashboardTasks\TaskSalary.cs" />
<Compile Include="DashboardTasks\TaskVolunteer.cs" />
<Compile Include="UITests\Sockets.cs" />
<Compile Include="UITests\SocketTests.cs" />
<Compile Include="UITests\IUITest.cs" />
</ItemGroup>
<ItemGroup>
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Swarmops.Logic.UITests
{
public class Sockets: IUITestGroup
public class SocketTests: IUITestGroup
{
public string GroupId { get { return "Sockets"; } }
@@ -14,7 +14,20 @@ namespace Swarmops.Logic.UITests
public void InitializeServerSide() { }
public string JavaScriptClientCodeDocReady { get { return string.Empty; } }
public string JavaScriptClientCodeDocReady { get { return @"
function pageOnHeartbeat(source) { // called from Swarmops-v5.js script
onUITestPassed('Sockets-Browser');
if (source == 'Frontend') {
onUITestPassed('Sockets-Frontend');
}
else if (source == 'Backend') {
onUITestPassed('Sockets-Backend');
}
}
"; } }
public IUITest[] Tests
{
get
@@ -33,7 +46,7 @@ namespace Swarmops.Logic.UITests
{
public string Id { get { return @"Browser"; } }
public string Name { get { return @"Browser WebSocket connection"; } }
public string Name { get { return @"Browser WebSocket connection to server"; } }
public void ExecuteServerSide()
{
+1 -1
View File
@@ -2267,7 +2267,7 @@ namespace Resources.Pages {
}
/// <summary>
/// Looks up a localized string similar to You&apos;re viewing a filed VAT report. The inbound and outbound VAT, as well as total turnover, has been recorded for the report period. This report is ready to be transmitted to tax authorities..
/// Looks up a localized string similar to You&apos;re viewing a filed VAT report. The inbound and outbound VAT, as well as total turnover, have been recorded for the report period. This report is ready to be transmitted to tax authorities..
/// </summary>
internal static string ViewVatReports_Info {
get {
+1 -1
View File
@@ -883,7 +883,7 @@
<value>Turnover</value>
</data>
<data name="ViewVatReports_Info" xml:space="preserve">
<value>You're viewing a filed VAT report. The inbound and outbound VAT, as well as total turnover, has been recorded for the report period. This report is ready to be transmitted to tax authorities.</value>
<value>You're viewing a filed VAT report. The inbound and outbound VAT, as well as total turnover, have been recorded for the report period. This report is ready to be transmitted to tax authorities.</value>
</data>
<data name="ViewVatReports_PageTitle" xml:space="preserve">
<value>VAT Reports</value>
@@ -1,4 +1,4 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.Admin.Troubleshooting.DebugSockets" Codebehind="Sockets.aspx.cs" %>
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.Admin.Diagnostics" Codebehind="Diagnostics.aspx.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
@@ -14,6 +14,8 @@
$(document).ready(function () {
<%=this.JavascriptDocReady%>
$('#TableTestResults').datagrid('appendRow', {
testGroupName: '<span class="testGroupHeader">Socket tests</span>',
testId: 'Group'
@@ -53,30 +55,21 @@
<%=this.ProgressTests.ClientID%>_show();
});
function pageOnHeartbeat(source) { // called from Swarmops-v5.js script
testPassed('Sockets-Browser');
if (source == 'Frontend') {
testPassed('Sockets-Frontend');
}
else if (source == 'Backend') {
testPassed('Sockets-Backend');
}
}
function testPassed(testId)
function onUITestPassed(testId)
{
$('img.test-running[data-test-id="' + testId + '"').fadeOut();
$('img.test-passed[data-test-id="' + testId + '"').show();
}
function testFailed(testId)
function onUITestFailed(guid, testId)
{
$('img.test-passed[data-test-id="' + testId + '"').fadeOut();
$('img.test-running[data-test-id="' + testId + '"').fadeOut();
$('img.test-failed[data-test-id="' + testId + '"').show();
}
var uiTestPageGuid = '<%=this.PageGuid%>';
</script>
<style type="text/css">
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Security;
using System.Web;
using System.Web.Services;
@@ -8,13 +9,16 @@ using Swarmops.Common.Enums;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Support;
using Swarmops.Logic.UITests;
namespace Swarmops.Frontend.Pages.Admin.Troubleshooting
namespace Swarmops.Frontend.Pages.Admin
{
public partial class DebugSockets : PageV5Base
public partial class Diagnostics : PageV5Base
{
protected void Page_Load (object sender, EventArgs e)
{
this.PageGuid = Guid.NewGuid().ToString();
PageIcon = "iconshock-group-search";
this.PageAccessRequired = new Access (CurrentOrganization, AccessAspect.PersonalData, AccessType.Read);
@@ -24,12 +28,28 @@ namespace Swarmops.Frontend.Pages.Admin.Troubleshooting
}
RegisterControl (EasyUIControl.Tree | EasyUIControl.DataGrid);
// Add all test groups
List<IUITestGroup> testGroups = new List<IUITestGroup>();
testGroups.Add(new SocketTests());
// Create the document.ready() function body
string javascriptDocReady = string.Empty;
foreach (IUITestGroup testGroup in testGroups)
{
javascriptDocReady += testGroup.JavaScriptClientCodeDocReady;
}
}
private void Localize()
{
PageTitle = @"Debug Sockets";
InfoBoxLiteral = @"This troubleshoots socket connections by showing which connections are live.";
PageTitle = @"Troubleshooting";
InfoBoxLiteral = @"This runs a series of self-tests to check that the installation is working correctly. If one or more tests fail, or just don't pass, this helps you diagnose precisely what is needed to correct the problem.";
/* no localization for debug pages */
}
@@ -93,6 +113,10 @@ namespace Swarmops.Frontend.Pages.Admin.Troubleshooting
return result;
}
public string JavascriptDocReady { get; set; }
public string PageGuid { get; set; }
public struct ConfirmPayoutResult
{
public int AssignedId;
@@ -7,10 +7,10 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace Swarmops.Frontend.Pages.Admin.Troubleshooting {
namespace Swarmops.Frontend.Pages.Admin {
public partial class DebugSockets {
public partial class Diagnostics {
/// <summary>
/// ProgressTests control.
+164
View File
@@ -0,0 +1,164 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeBehind="EndOfMonth.aspx.cs" Inherits="Swarmops.Frontend.Pages.Ledgers.EndOfMonth" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" runat="server">
<script type="text/javascript">
$(document).ready(function () {
<%=this.JavascriptDocReady%>
var rowCount = 0;
$('#TableEomItems').datagrid('appendRow', {
testGroupName: '<span class="itemGroupHeader">Taxes and Payroll</span>',
testId: 'Group'
});
rowCount = $('#TableTestResults').datagrid('getRows').length;
$('#TableEomItems').datagrid('mergeCells', {
index: rowCount-1,
colspan: 4,
type: 'body',
field: 'itemGroupName'
});
$('#TableEomItems').datagrid('appendRow', {
itemName: 'VAT Report for [lastmonth]',
docs: "<img src='/Images/Icons/iconshock-red-cross-sphere-128x96px.png' data-test-id='Sockets-Browser' class='test-failed' style='display:none' height='20px' />",
actions: "<img src='/Images/Icons/iconshock-yellow-sphere-30pct-128x96px.png' data-test-id='Sockets-Browser' class='test-running' style='display:inline' height='20px' />"
});
$('#TableEomItems').datagrid('appendRow', {
itemName: 'Upload bank statement for [lastmonth]',
docs: "<img src='/Images/Icons/iconshock-red-cross-sphere-128x96px.png' data-test-id='Sockets-Browser' class='test-failed' style='display:none' height='20px' />",
actions: "<img src='/Images/Icons/iconshock-yellow-sphere-30pct-128x96px.png' data-test-id='Sockets-Browser' class='test-running' style='display:inline' height='20px' />"
});
/*
$('#TableEomItems').datagrid('appendRow', {
itemName: 'Payroll processing for [thismonth]',
docs: "<img src='/Images/Icons/iconshock-red-cross-sphere-128x96px.png' data-test-id='Sockets-Browser' class='test-failed' style='display:none' height='20px' />",
actions: "<img src='/Images/Icons/iconshock-yellow-sphere-30pct-128x96px.png' data-test-id='Sockets-Browser' class='test-running' style='display:inline' height='20px' />"
});
$('#TableEomItems').datagrid('appendRow', {
itemName: 'Submit to tax authorities',
docs: "<img src='/Images/Icons/iconshock-red-cross-sphere-128x96px.png' data-test-id='Sockets-Browser' class='test-failed' style='display:none' height='20px' />",
actions: "<img src='/Images/Icons/iconshock-yellow-sphere-30pct-128x96px.png' data-test-id='Sockets-Browser' class='test-running' style='display:inline' height='20px' />"
});
*/
$('#TableEomItems').datagrid('appendRow', {
testGroupName: '<span class="itemGroupHeader">Annual Reports</span>',
testId: 'Group'
});
rowCount = $('#TableTestResults').datagrid('getRows').length;
$('#TableEomItems').datagrid('mergeCells', {
index: rowCount - 1,
colspan: 4,
type: 'body',
field: 'itemGroupName'
});
$('#TableEomItems').datagrid('appendRow', {
itemName: 'Close ledgers for [year]',
docs: "<img src='/Images/Icons/iconshock-red-cross-sphere-128x96px.png' data-test-id='Sockets-Browser' class='test-failed' style='display:none' height='20px' />",
actions: "<img src='/Images/Icons/iconshock-yellow-sphere-30pct-128x96px.png' data-test-id='Sockets-Browser' class='test-running' style='display:inline' height='20px' />"
});
$('#TableEomItems').datagrid('appendRow', {
testGroupName: '<span class="itemGroupHeader">Send to Accountants, Shareholders, etc.</span>',
testId: 'Group'
});
rowCount = $('#TableTestResults').datagrid('getRows').length;
$('#TableEomItems').datagrid('mergeCells', {
index: rowCount - 1,
colspan: 4,
type: 'body',
field: 'itemGroupName'
});
$('#TableEomItems').datagrid('appendRow', {
itemName: 'Send all reports as required',
docs: "<img src='/Images/Icons/iconshock-red-cross-sphere-128x96px.png' data-test-id='Sockets-Browser' class='test-failed' style='display:none' height='20px' />",
actions: "<img src='/Images/Icons/iconshock-yellow-sphere-30pct-128x96px.png' data-test-id='Sockets-Browser' class='test-running' style='display:inline' height='20px' />"
});
});
document.ready(function() {
var lineIndex = 0; // declare here to not redeclare in autogen code below
}); // end of document.ready
// Function: Generate VAT report
// Function: Match all mismatched transactions
// Function: Upload bank statement PDF for accountId x
// Function: Close YEAR if a new year
// Function: Send EOM papers to accountants etc
</script>
<style type="text/css">
.itemGroupHeader {
font-size: 125%;
font-weight: 500;
}
.datagrid-row-selected,.datagrid-row-over{
background:transparent;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<h2>End-of-Month routine</h2>
<table id="TableEomItems" class="easyui-datagrid" style="width:680px;height:500px"
data-options="rownumbers:false,singleSelect:false,nowrap:false,fit:false,loading:false,selectOnCheck:true,checkOnSelect:true"
idField="testId">
<thead>
<tr>
<th data-options="field:'itemGroupName',width:54">Group</th>
<th data-options="field:'itemName',width:500">Todo</th>
<th data-options="field:'docs',width:42,align:'center'">Docs</th>
<th data-options="field:'actions',width:63,align:'center'">Actions</th>
</tr>
</thead>
</table>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
</asp:Content>
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Swarmops.Frontend.Pages.Ledgers
{
public partial class EndOfMonth : PageV5Base
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
+15
View File
@@ -0,0 +1,15 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Swarmops.Frontend.Pages.Ledgers {
public partial class EndOfMonth {
}
}
+21 -5
View File
@@ -609,6 +609,13 @@
<Compile Include="Automation\OrgFunctions.aspx.designer.cs">
<DependentUpon>OrgFunctions.aspx</DependentUpon>
</Compile>
<Compile Include="Automation\UITests.aspx.cs">
<DependentUpon>UITests.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Automation\UITests.aspx.designer.cs">
<DependentUpon>UITests.aspx</DependentUpon>
</Compile>
<Compile Include="Controls\v5\Base\AjaxToggleSlider.ascx.cs">
<DependentUpon>AjaxToggleSlider.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -672,12 +679,12 @@
<Compile Include="Pages\v5\Admin\CommenceImpersonation.aspx.designer.cs">
<DependentUpon>CommenceImpersonation.aspx</DependentUpon>
</Compile>
<Compile Include="Pages\v5\Admin\Troubleshooting\Sockets.aspx.cs">
<DependentUpon>Sockets.aspx</DependentUpon>
<Compile Include="Pages\v5\Admin\Diagnostics.aspx.cs">
<DependentUpon>Diagnostics.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\v5\Admin\Troubleshooting\Sockets.aspx.designer.cs">
<DependentUpon>Sockets.aspx</DependentUpon>
<Compile Include="Pages\v5\Admin\Diagnostics.aspx.designer.cs">
<DependentUpon>Diagnostics.aspx</DependentUpon>
</Compile>
<Compile Include="Pages\v5\Admin\Hacks\PopulateCountry1.aspx.cs">
<DependentUpon>PopulateCountry1.aspx</DependentUpon>
@@ -945,6 +952,13 @@
<Compile Include="Pages\v5\Ledgers\DebugLedgers.aspx.designer.cs">
<DependentUpon>DebugLedgers.aspx</DependentUpon>
</Compile>
<Compile Include="Pages\v5\Ledgers\EndOfMonth.aspx.cs">
<DependentUpon>EndOfMonth.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\v5\Ledgers\EndOfMonth.aspx.designer.cs">
<DependentUpon>EndOfMonth.aspx</DependentUpon>
</Compile>
<Compile Include="Pages\v5\Ledgers\InspectLedgers.aspx.cs">
<DependentUpon>InspectLedgers.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -1273,6 +1287,7 @@
<Content Include="Automation\Json-TransactionTagsTree.aspx" />
<Content Include="Automation\OrgFunctions.aspx" />
<Content Include="Automation\SwarmFunctions.aspx" />
<Content Include="Automation\UITests.aspx" />
<Content Include="Controls\v5\Base\AjaxTextBox.ascx" />
<Content Include="Controls\v5\Base\AjaxToggleSlider.ascx" />
<Content Include="Controls\v5\Base\ComboGeographies.ascx" />
@@ -1670,7 +1685,7 @@
<Content Include="Pages\v5\Admin\BitcoinEchoTest.aspx" />
<Content Include="Pages\v5\Admin\CreateOrganization.aspx" />
<Content Include="Pages\v5\Admin\CommenceImpersonation.aspx" />
<Content Include="Pages\v5\Admin\Troubleshooting\Sockets.aspx" />
<Content Include="Pages\v5\Admin\Diagnostics.aspx" />
<Content Include="Pages\v5\Admin\Hacks\PopulateCountry1.aspx" />
<Content Include="Pages\v5\Admin\Hacks\PopulateCountry2.aspx" />
<Content Include="Pages\v5\Admin\Hacks\PopulateFakePeople.aspx" />
@@ -1709,6 +1724,7 @@
<Content Include="Pages\v5\Ledgers\Csv-BalanceData.aspx" />
<Content Include="Pages\v5\Ledgers\Csv-ProfitLossData.aspx" />
<Content Include="Pages\v5\Ledgers\DebugLedgers.aspx" />
<Content Include="Pages\v5\Ledgers\EndOfMonth.aspx" />
<Content Include="Pages\v5\Ledgers\InspectLedgers.aspx" />
<Content Include="Pages\v5\Ledgers\Json-AccountPlanData.aspx" />
<Content Include="Pages\v5\Ledgers\Json-GeneralLedgerData.aspx" />