More work on Upload Bank Files. Still works, shows more that it works.

This commit is contained in:
Rick Falkvinge
2014-08-18 21:37:25 +00:00
parent f70c59011e
commit 0c37aa2d08
4 changed files with 100 additions and 39 deletions
+37 -2
View File
@@ -243,6 +243,12 @@
<value>Set New Budgets</value>
<comment>Text on submit button</comment>
</data>
<data name="UploadBankFiles_AccountStatement" xml:space="preserve">
<value>Account Statement</value>
</data>
<data name="UploadBankFiles_BankAccount" xml:space="preserve">
<value>Bank Account</value>
</data>
<data name="UploadBankFiles_BankScreenshot" xml:space="preserve">
<value>Bank Screenshot</value>
<comment>Displayed as header above modally zoomed screenshot</comment>
@@ -287,6 +293,10 @@
<value>File Imported, But Data Out Of Sync</value>
<comment>Displayed as header after a good processing that ended in sync failure</comment>
</data>
<data name="UploadBankFiles_FileType" xml:space="preserve">
<value>File Type</value>
<comment>can be Account Statement or Payments File</comment>
</data>
<data name="UploadBankFiles_ImportError" xml:space="preserve">
<value>Error on importing file</value>
<comment>Displayed as header on import failure</comment>
@@ -299,6 +309,9 @@
<value>Here, you can upload files from your bank or payment provider into your organization's bookkeeping. Examples include account history and payments received.</value>
<comment>Displayed in sidebar on page.</comment>
</data>
<data name="UploadBankFiles_Instructions" xml:space="preserve">
<value>Instructions</value>
</data>
<data name="UploadBankFiles_PageTitle" xml:space="preserve">
<value>Upload Bank Files</value>
<comment>Displayed above main content.</comment>
@@ -317,6 +330,9 @@
<value>no payment groups|one payment group|{0} payment groups</value>
<comment>none|one|many</comment>
</data>
<data name="UploadBankFiles_PaymentsFile" xml:space="preserve">
<value>Payments File</value>
</data>
<data name="UploadBankFiles_PaymentSummary1" xml:space="preserve">
<value>The payment file contained {0}.</value>
</data>
@@ -327,6 +343,25 @@
<data name="UploadBankFiles_PaymentSummaryDuplicates" xml:space="preserve">
<value>There was also some duplicate information ({0} across {1}).</value>
</data>
<data name="UploadBankFiles_Processing" xml:space="preserve">
<value>Processing File...</value>
</data>
<data name="UploadBankFiles_ProcessingComplete" xml:space="preserve">
<value>Processing Complete</value>
</data>
<data name="UploadBankFiles_ResultsBad" xml:space="preserve">
<value>&lt;p&gt;&lt;strong&gt;The file could not be read as an input file to this bank.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;There are several reasons this could happen: the file may be bad, the bank may have silently changed its format, or you uploaded the wrong file entirely. Please try again.&lt;/p&gt;</value>
<comment>Displayed when the input file can't be parsed, before import attempt.</comment>
</data>
<data name="UploadBankFiles_ResultsGood" xml:space="preserve">
<value>&lt;p&gt;The file has been &lt;strong&gt;successfully imported.&lt;/strong&gt; {0:N} new transactions imported; {1:N} discarded as duplicates of what was already in Swarmops. The account balance in Swarmops matches that of the bank.&lt;/p&gt;&lt;p&gt;The file contained transactions from {2:yyyy-MMM-dd} to {3:yyyy-MMM-dd}.&lt;/p&gt;</value>
<comment>Zero is new transaction count, one is duplicate transaction count, two and three are lowest and highest dates found in file. Pay attention to date format and adjust to culture.</comment>
</data>
<data name="UploadBankFiles_ResultsQuestionable" xml:space="preserve">
<value>&lt;p&gt;The file was imported, but the &lt;strong&gt;resulting account balance mismatches.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;After importing {0:N} transactions (and discarding {1:N} duplicates), the entire file has been processed. However, the resulting account balance in Swarmops is not the same as that of the bank statement.&lt;/p&gt;
&lt;p&gt;Please try uploading a fresh account statement. If that still produces a mismatch, you may need to try &lt;a href="/Pages/v5/Ledgers/ResyncExternalAccount.aspx"&gt;resynchronizing&lt;/a&gt;the bank account with a comprehensive account statement file.&lt;/p&gt;</value>
<comment>Displayed on successful import, but the resulting balance is off compared to the account statement file that was just uploaded.</comment>
</data>
<data name="UploadBankFiles_SelectAccount" xml:space="preserve">
<value>Select Bookkeeping Account</value>
<comment>Select prompt for the financial account in the organization's bookkeeping.</comment>
@@ -340,10 +375,10 @@
</data>
<data name="UploadBankFiles_UploadAnother" xml:space="preserve">
<value>Upload another bank file?</value>
<comment>Displayed as link</comment>
<comment>Displayed as header after uploading one file</comment>
</data>
<data name="UploadBankFiles_UploadBankFile" xml:space="preserve">
<value>Upload Bank File</value>
<value>Upload bank file</value>
<comment>Displayed as header above download instructions / upload form</comment>
</data>
<data name="ViewOutstandingAccounts_FooterDifference" xml:space="preserve">
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Swarmops.Frontend.Automation
}
[WebMethod]
int GetProgress(string guid)
static public int GetProgress(string guid)
{
return (int) GuidCache.Get(guid + "-Progress"); // suffix because guid may refer to other data too
}
+22 -17
View File
@@ -3,13 +3,13 @@
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<Swarmops5:ExternalScripts ID="ExternalScripts1" Package="easyui" Control="tree" runat="server" />
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="/Scripts/jquery.fileupload/jquery.iframe-transport.js" type="text/javascript" language="javascript"></script>
<!-- The basic File Upload plugin -->
<script src="/Scripts/jquery.fileupload/jquery.fileupload.js" type="text/javascript" language="javascript"></script>
<link rel="stylesheet" type="text/css" href="/Style/v5-easyui-elements.css">
<style type="text/css">
/* custom styles were used in Telerik version of page */
@@ -50,7 +50,6 @@
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert('quux');
setTimeout('updateProgressProcessing();', 1000);
}
});
@@ -70,10 +69,11 @@
{
width: "100%"
}, { queue: false });
$('#DivStepPreview').fadeIn();
$('#DivStepProcessing').slideUp();
// Add processing results here
} else {
$('#DivProcessing').hide();
$('#DivProcessingFake').show();
// Add processing results here
} else {
if (msg.d > 50 && !halfway) {
halfway = true;
@@ -124,19 +124,24 @@
</script>
<div id="DivProcessingFake" style="display:none">
<h2><asp:Label ID="LabelProcessingComplete" runat="server" /></h2>
<div id="DivProgressFake" style="width:100%"></div>
</div>
<div id="DivUploadResultsGood">
<div id="DivUploadResultsGood">
</div>
</div>
<div id="DivUploadResultsBad">
<div id="DivUploadResultsBad">
<div float="left"><img src="/Images/Icons/iconshock-cross-96px.png" /></div><div id="DivUploadResultsBadText"></div>
</div>
<div id="DivUploadResultsQuestionable">
</div>
</div>
<div id="DivUploadBankFile">
<h2>Upload Bank File</h2>
<h2><asp:Label runat="server" ID="LabelUploadBankFileHeader" /></h2>
<div id="DivPrepData">
<div class="entryFields">
@@ -146,10 +151,10 @@
<Swarmops5:FileUpload runat="server" ID="UploadFile" Filter="NoFilter" DisplayCount="8" HideTrigger="true" ClientUploadCompleteCallback="uploadCompletedCallback" /></div>
<div class="entryLabels">
Bank account<br/>
File type<br/>
Instructions<br/>
Upload bank file
<asp:Label runat="server" ID="LabelBankAccount" /><br/>
<asp:Label runat="server" ID="LabelFileType" /><br/>
<asp:Label runat="server" ID="LabelInstructions" /><br/>
<asp:Label runat="server" ID="LabelUploadBankFile" />
</div>
</div>
@@ -157,7 +162,7 @@
</div>
<div id="DivProcessing" style="display:none">
<h2>Processing File...</h2>
<h2><asp:Label runat="server" ID="LabelProcessing" /></h2>
<div id="DivProgressProcessing" style="width:100%"></div>
</div>
+40 -19
View File
@@ -9,6 +9,7 @@ using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Swarm;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
@@ -35,11 +36,17 @@ namespace Swarmops.Site.Pages.Ledgers
// Localize
this.InfoBoxLiteral = Resources.Pages.Ledgers.UploadBankFiles_Info;
this.LabelBankAccount.Text = Resources.Pages.Ledgers.UploadBankFiles_BankAccount;
this.LabelFileType.Text = Resources.Pages.Ledgers.UploadBankFiles_FileType;
this.LabelInstructions.Text = Resources.Pages.Ledgers.UploadBankFiles_Instructions;
this.LabelProcessing.Text = Resources.Pages.Ledgers.UploadBankFiles_Processing;
this.LabelProcessingComplete.Text = Resources.Pages.Ledgers.UploadBankFiles_ProcessingComplete;
this.LabelUploadBankFile.Text = Resources.Pages.Ledgers.UploadBankFiles_UploadBankFile;
this.LabelUploadBankFileHeader.Text = Resources.Pages.Ledgers.UploadBankFiles_UploadBankFile;
// Populate the asset account dropdown, if needed for file type
PopulateAccountDropDown();
}
if (!IsPostBack)
@@ -234,27 +241,34 @@ namespace Swarmops.Site.Pages.Ledgers
Document uploadedDoc = documents[0];
FinancialAccount account = ((ProcessThreadArguments) args).Account;
ExternalBankData externalData = new ExternalBankData();
externalData.Profile = account.ExternalBankDataProfile;
if (fileType == BankFileType.AccountStatement)
try
{
using (StreamReader reader = uploadedDoc.GetReader(1252))
FinancialAccount account = ((ProcessThreadArguments) args).Account;
ExternalBankData externalData = new ExternalBankData();
externalData.Profile = account.ExternalBankDataProfile;
if (fileType == BankFileType.AccountStatement)
{
externalData.LoadData(reader, ((ProcessThreadArguments) args).Organization);
ImportResults results = ProcessImportedData(externalData, (ProcessThreadArguments) args);
using (StreamReader reader = uploadedDoc.GetReader(1252))
{
externalData.LoadData(reader, ((ProcessThreadArguments) args).Organization);
ImportResults results = ProcessImportedData(externalData, (ProcessThreadArguments) args);
}
}
else if (fileType == BankFileType.PaymentDetails)
{
// Get reader factory from ExternalBankData
throw new NotImplementedException("Need to implement new flexible payment reader structure");
// IBankDataPaymentsReader paymentsReader = externalData.GetPaymentsReader();
// then read
}
}
else if (fileType == BankFileType.PaymentDetails)
finally
{
// Get reader factory from ExternalBankData
throw new NotImplementedException("Need to implement new flexible payment reader structure");
// IBankDataPaymentsReader paymentsReader = externalData.GetPaymentsReader();
// then read
uploadedDoc.Delete(); // document no longer needed after processing, no matter the result
}
}
@@ -413,6 +427,12 @@ namespace Swarmops.Site.Pages.Ledgers
}
[WebMethod]
static public string GetImportResults(string guid)
{
return string.Empty;
}
static private ImportResults ProcessImportedData(ExternalBankData import, ProcessThreadArguments args)
{
FinancialAccount assetAccount = args.Account;
@@ -437,8 +457,7 @@ namespace Swarmops.Site.Pages.Ledgers
{
int percent = (count*99)/import.Records.Length;
// TODO: UPDATE PROGRESS BAR VIA NEW MECHANISM
// UpdateImportProgressBar(percent);
GuidCache.Set(args.Guid + "-Progress", percent);
}
// Update high- and low-water marks.
@@ -557,6 +576,8 @@ namespace Swarmops.Site.Pages.Ledgers
}
}
GuidCache.Set(args.Guid + "-Progress", 100); // Mark complete
// Import complete. Return true if the bookkeeping account matches the bank data.
Int64 databaseAccountBalanceCents = assetAccount.BalanceTotalCents;