A little work on resync

This commit is contained in:
Rick Falkvinge
2014-04-20 17:13:38 +00:00
parent 365daaf3b2
commit 8981f6adc7
3 changed files with 64 additions and 2 deletions
@@ -13,6 +13,27 @@ namespace Swarmops.Logic.Financial
this.FieldNames = new Dictionary<ExternalBankDataFieldName, string>();
}
public string DateTimeFormatString
{
get
{
switch (Precision)
{
case ExternalBankDateTimePrecision.Day:
return "yyyy-MM-dd";
case ExternalBankDateTimePrecision.Minute:
return "yyyy-MM-dd HH:mm";
case ExternalBankDateTimePrecision.Second:
return "yyyy-MM-dd HH:mm:ss";
case ExternalBankDateTimePrecision.Microsecond:
return "yyyy-MM-dd HH:mm:ss.ffffff";
default:
throw new NotImplementedException("Unknown ExternalDateTimePrecision: " + Precision.ToString());
}
}
}
static public ExternalBankDataProfile FromIdentity (int externalBankDataProfileId)
{
ExternalBankDataProfile result = new ExternalBankDataProfile();
@@ -32,6 +53,7 @@ namespace Swarmops.Logic.Financial
result.FieldNames[ExternalBankDataFieldName.NotUniqueId] = "Verifikationsnummer";
result.LatestTransactionLocation = LatestTransactionLocation.Top;
result.Precision = ExternalBankDateTimePrecision.Day;
return result;
}
@@ -54,6 +76,7 @@ namespace Swarmops.Logic.Financial
result.FieldNames[ExternalBankDataFieldName.UniqueId] = "Transaction ID";
result.LatestTransactionLocation = LatestTransactionLocation.Top;
result.Precision = ExternalBankDateTimePrecision.Second;
return result;
}
@@ -69,6 +92,7 @@ namespace Swarmops.Logic.Financial
public string Culture { get; set; }
public string Currency { get; set; }
public LatestTransactionLocation LatestTransactionLocation;
public ExternalBankDateTimePrecision Precision;
public Dictionary<ExternalBankDataFieldName, string> FieldNames { get; private set; }
}
@@ -102,4 +126,33 @@ namespace Swarmops.Logic.Financial
/// </summary>
Bottom
}
public enum ExternalBankDateTimePrecision
{
Unknown = 0,
/// <summary>
/// The external bank has day precision only. Typical for oldbanks.
/// </summary>
Day,
/// <summary>
/// The external bank has minute (hour:minute) precision on top of day.
/// </summary>
Minute,
/// <summary>
/// The external bank tags transactions with hour, minute, and second.
/// </summary>
Second,
/// <summary>
/// The external bank has millisecond-level timestamps for transactions. Not implemented.
/// </summary>
Millisecond,
/// <summary>
/// The external bank has microsecond-resolution timestamp for transactions
/// </summary>
Microsecond,
/// <summary>
/// The external bank has nanosecond-resolution timestamp for transactions
/// </summary>
Nanosecond
}
}
@@ -21,7 +21,10 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
string guid = Request.QueryString["Guid"];
ExternalBankMismatchingDateTime[] mismatchArray =
(ExternalBankMismatchingDateTime[]) Session["LedgersResync" + guid + "MismatchArray"];
(ExternalBankMismatchingDateTime[])Session["LedgersResync" + guid + "MismatchArray"];
ExternalBankDataProfile profile =
(ExternalBankDataProfile)Session["LedgersResync" + guid + "Profile"];
if (!_authenticationData.CurrentUser.HasAccess(new Access(_authenticationData.CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
{
@@ -42,7 +45,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
string childrenString = string.Empty; // Room for next step here
string rowId = mismatch.DateTime.ToString("yyyyMMddHHmmss");
string rowName = mismatch.DateTime.ToString("yyyy-MMM-dd HH:mm:ss");
string rowName = mismatch.DateTime.ToString(profile.DateTimeFormatString);
string swarmopsData = ((double) mismatch.SwarmopsDeltaCents/100.0).ToString("N2") + " " +
currentOrganizationCurrency;
@@ -102,7 +102,11 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
HttpContext.Current.Session["LedgersResync" + guid + "MismatchArray"] =
_staticDataLookup[guid + "MismatchArray"];
HttpContext.Current.Session["LedgersResync" + guid + "Profile"] =
_staticDataLookup[guid + "Profile"];
_staticDataLookup[guid + "MismatchArray"] = null; // clear the static object, which will otherwise live on
_staticDataLookup[guid + "Profile"] = null;
}
return percentReady;
@@ -191,6 +195,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
externalData.Records[externalData.Records.Length - 1].DateTime.ToLongDateString();
_staticDataLookup[guid + "TxCount"] = externalData.Records.Length.ToString("N0");
_staticDataLookup[guid + "Profile"] = externalData.Profile;
_staticDataLookup[guid + "PercentRead"] = 1;
int accountId = 1; // TODO: HACK HACK HACK HACK