Debugging works again; upload of DE-Postbank files work

This commit is contained in:
Rick Falkvinge
2017-10-03 11:24:13 +02:00
parent 9566877a13
commit 96b54365fa
10 changed files with 94 additions and 22 deletions
+43 -3
View File
@@ -1,7 +1,47 @@
ALTER TABLE `FinancialTransactions`
CHANGE COLUMN `Comment` `Comment` TEXT NOT NULL
#
DROP PROCEDURE `CreateFinancialTransactionStub`
#
CREATE PROCEDURE `CreateFinancialTransactionStub`(
IN organizationId INTEGER,
IN financialAccountId INTEGER,
IN amountCents BIGINT,
IN dateTime DATETIME,
IN comment TEXT,
IN importHash VARCHAR(32),
IN personId INTEGER
)
BEGIN
DECLARE financialTransactionId INTEGER;
SELECT 0 INTO financialTransactionId;
IF ((SELECT COUNT(*) FROM FinancialTransactions WHERE FinancialTransactions.ImportHash=importHash) = 0)
THEN
INSERT INTO FinancialTransactions (OrganizationId, DateTime, Comment, ImportHash)
VALUES (organizationId, dateTime, comment, importHash);
SELECT LAST_INSERT_ID() INTO financialTransactionId;
INSERT INTO FinancialTransactionRows (FinancialAccountId, FinancialTransactionId, Amount, AmountCents, CreatedDateTime, CreatedByPersonId)
VALUES (financialAccountId, financialTransactionId, amountCents/100.0, amountCents, DateTime, personId);
END IF;
SELECT financialTransactionId AS Identity;
END
#
ALTER TABLE `InboundInvoices`
ADD COLUMN `PayToBitcoinAddress` VARCHAR(128) NOT NULL DEFAULT '' AFTER `SupplierId`,
ADD COLUMN `PayToBitcoinCashAddress` VARCHAR(128) NOT NULL DEFAULT '' AFTER `PayToBitcoinAddress`
ADD COLUMN `PayToEthereumAddress` VARCHAR(128) NOT NULL DEFAULT '' AFTER `PayToBitcoinCashAddress`
ADD COLUMN `PayoutSpecId` INT NOT NULL DEFAULT 0 AFTER `SupplierId`,
#
+1
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography;
using Swarmops.Common;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
+4 -4
View File
@@ -121,13 +121,13 @@ namespace Swarmops.Logic.Financial
result.Name = "DE Postbank";
result.Country = Country.FromCode("DE");
result.Culture = "de-DE";
result.IgnoreInitialLines = 8;
result.InitialReplacements = ";|\t| €| (€)|";
result.IgnoreInitialLines = 7;
result.InitialReplacements = ";|\t| €|";
result.FieldNames[ExternalBankDataFieldName.Date] = "Buchungstag";
result.FieldNames[ExternalBankDataFieldName.Description] = "Buchungsdetails";
result.FieldNames[ExternalBankDataFieldName.TransactionNet] = "Betrag";
result.FieldNames[ExternalBankDataFieldName.AccountBalance] = "Saldo";
result.FieldNames[ExternalBankDataFieldName.TransactionNet] = "Betrag (€)";
result.FieldNames[ExternalBankDataFieldName.AccountBalance] = "Saldo (€)";
result.LatestTransactionLocation = LatestTransactionLocation.Top;
result.FeeSignage = FeeSignage.Unknown; // no inline fees
+15 -1
View File
@@ -40,10 +40,12 @@ namespace Swarmops.Logic.Financial
{
importKey = this.UniqueId;
}
else if (!string.IsNullOrEmpty (this.NotUniqueId))
else if (!string.IsNullOrEmpty (this.NotUniqueId)) // no unique ID, but maybe something else
{
string commentKey = this.Description.ToLowerInvariant();
// " / 100.0" below serves no purpose but must stay now that the hash scheme is in effect
string hashKey = this.NotUniqueId + commentKey +
(this.TransactionNetCents/100.0).ToString (CultureInfo.InvariantCulture) +
(this.AccountBalanceCents/100.0).ToString (CultureInfo.InvariantCulture) +
@@ -51,6 +53,18 @@ namespace Swarmops.Logic.Financial
importKey = SHA1.Hash (hashKey).Replace (" ", "");
}
else // neither unique nor nonunique ID, like DE Postbank
{
string commentKey = this.Description.ToLowerInvariant();
string hashKey = commentKey +
this.TransactionNetCents.ToString(CultureInfo.InvariantCulture) +
this.AccountBalanceCents.ToString(CultureInfo.InvariantCulture) +
this.DateTime.ToString("yyyy-MM-dd-HH-mm-ss");
importKey = SHA1.Hash(hashKey).Replace(" ", "");
}
if (importKey.Length > 30)
{
+2 -2
View File
@@ -1,5 +1,5 @@
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="FileUpload.ascx.cs" CodeFile="FileUpload.ascx.cs" Inherits="Swarmops.Controls.Base.FileUpload" %>
<%@ Import Namespace="System.Net" %>
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="FileUpload.ascx.cs" Inherits="Swarmops.Controls.Base.FileUpload" %>
<asp:HiddenField runat="server" ID="HiddenGuid"/>
+1 -2
View File
@@ -1,5 +1,4 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Site.Pages.Ledgers.UploadBankFiles" Codebehind="UploadBankFiles.aspx.cs" %>
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Site.Pages.Ledgers.UploadBankFiles" CodeFile="UploadBankFiles.aspx.cs" Codebehind="UploadBankFiles.aspx.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
@@ -376,7 +376,7 @@ namespace Swarmops.Site.Pages.Ledgers
GuidCache.Set (guid + "-Result", ImportResultsCategory.Questionable);
}
}
catch (Exception)
catch (Exception e)
{
reader.BaseStream.Position = 0; // rewind stream to retry parse with different file type
@@ -437,7 +437,7 @@ namespace Swarmops.Site.Pages.Ledgers
{
bool fileWasUploaded = false;
foreach (string fileInputID in Request.Files)
foreach (string fileInputID in Request.Files)F
{
UploadedFile file = UploadedFile.FromHttpPostedFile(Request.Files[fileInputID]);
if (file.ContentLength > 0)
@@ -579,7 +579,7 @@ namespace Swarmops.Site.Pages.Ledgers
{
FinancialAccount assetAccount = args.Account;
FinancialAccount autoDepositAccount = args.Organization.FinancialAccounts.IncomeDonations;
int autoDepositLimit = 1000; // TODO: this.CurrentOrganization.Parameters.AutoDonationLimit;
int autoDepositLimit = 0; // Disabled; TODO: this.CurrentOrganization.Parameters.AutoDonationLimit;
ImportResults result = new ImportResults();
int count = 0;
+10 -1
View File
@@ -191,7 +191,16 @@ namespace Swarmops.Pages.v5.Support
if (!File.Exists (StorageRoot + legacyMarker + serverFileName))
{
throw new FileNotFoundException (StorageRoot + legacyMarker + serverFileName);
if (!Debugger.IsAttached) // if running live; ignore FNF errors when debugging
{
throw new FileNotFoundException(StorageRoot + legacyMarker + serverFileName);
}
else
{
Response.StatusCode = 404;
Response.End();
return;
}
}
Response.ContentType = contentType + "; filename=" + document.ClientFileName;
+8
View File
@@ -110,6 +110,13 @@
<Compile Include="Controls\v5\Base\AjaxToggleSlider.ascx.designer.cs">
<DependentUpon>AjaxToggleSlider.ascx</DependentUpon>
</Compile>
<Compile Include="Controls\v5\Base\FileUploader.ascx.cs">
<DependentUpon>FileUploader.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Controls\v5\Base\FileUploader.ascx.designer.cs">
<DependentUpon>FileUploader.ascx</DependentUpon>
</Compile>
<Compile Include="Controls\v5\Swarm\ImpersonationWarningBox.ascx.cs">
<DependentUpon>ImpersonationWarningBox.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -683,6 +690,7 @@
<Content Include="Controls\v5\Base\ComboGeographies.ascx" />
<Content Include="Controls\v5\Base\DropDown.ascx" />
<Content Include="Controls\v5\Base\FileUpload.ascx" />
<Content Include="Controls\v5\Base\FileUploader.ascx" />
<Content Include="Controls\v5\Base\MainMenu.ascx" />
<Content Include="Controls\v5\Base\ModalDialog.ascx" />
<Compile Include="Controls\v5\Base\AjaxTextBox.ascx.designer.cs">
+7 -6
View File
@@ -30,18 +30,19 @@
</authorization>
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID">
<controls>
<add tagPrefix="Swarmops5" tagName="DropDown" src="~/Controls/v5/Base/DropDown.ascx" />
<add tagPrefix="Swarmops5" tagName="ComboBudgets" src="~/Controls/v5/Financial/ComboBudgets.ascx" />
<add tagPrefix="Swarmops5" tagName="ComboPeople" src="~/Controls/v5/Swarm/ComboPeople.ascx" />
<add tagPrefix="Swarmops5" tagName="AjaxComboPeople" src="~/Controls/v5/Swarm/ComboPeople.ascx" />
<add tagPrefix="Swarmops5" tagName="AjaxTextBox" src="~/Controls/v5/Base/AjaxTextBox.ascx" />
<add tagPrefix="Swarmops5" tagName="AjaxToggleSlider" src="~/Controls/v5/Base/AjaxToggleSlider.ascx" />
<add tagPrefix="Swarmops5" tagName="AjaxComboPeople" src="~/Controls/v5/Swarm/ComboPeople.ascx" />
<add tagPrefix="Swarmops5" tagName="ModalDialog" src="~/Controls/v5/Base/ModalDialog.ascx" />
<add tagPrefix="Swarmops5" tagName="ComboBudgets" src="~/Controls/v5/Financial/ComboBudgets.ascx" />
<add tagPrefix="Swarmops5" tagName="ComboPeople" src="~/Controls/v5/Swarm/ComboPeople.ascx" />
<add tagPrefix="Swarmops5" tagName="DropDown" src="~/Controls/v5/Base/DropDown.ascx" />
<add tagPrefix="Swarmops5" tagName="ExternalScripts" src="~/Controls/v5/UI/ExternalScripts.ascx" />
<add tagPrefix="Swarmops5" tagName="FileUpload" src="~/Controls/v5/Base/FileUpload.ascx"/>
<add tagPrefix="Swarmops5" tagName="ImpersonationWarningBox" src="~/Controls/v5/Swarm/ImpersonationWarningBox.ascx" />
<add tagPrefix="Swarmops5" tagName="IncludedScripts" src="~/Controls/v5/UI/IncludedScripts.ascx" />
<add tagPrefix="Swarmops5" tagName="ModalDialog" src="~/Controls/v5/Base/ModalDialog.ascx" />
<add tagPrefix="Swarmops5" tagName="MainMenu" src="~/Controls/v5/Base/MainMenu.ascx" />
<add tagPrefix="Swarmops5" tagName="TreePositions" src="~/Controls/v5/Swarm/TreePositions.ascx" />
<add tagPrefix="Swarmops5" tagName="ImpersonationWarningBox" src="~/Controls/v5/Swarm/ImpersonationWarningBox.ascx" />
</controls>
</pages>
</system.web>