Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Check Number #11

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions QFXparser.TestApp/QFXparser.TestApp.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 8 additions & 5 deletions QFXparser.Testing/QFXparser.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions QFXparser.Testing/test.qfx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,24 @@ NEWFILEUID:NONE
<CORRECTACTION>REPLACE
<NAME>PMT FROM BILL PAYER SERVICE
</STMTTRN>
<STMTTRN>
<TRNTYPE>CHECK
<DTPOSTED>20210930000000
<TRNAMT>-225.00
<FITID>7/30/2021 12:00:00 AM|3311628
<CHECKNUM>2022
<NAME>WITHDRAWAL, DRAFT NUMBER 2022
<MEMO>, Withdrawal, Processed
</STMTTRN>
</BANKTRANLIST>
<LEDGERBAL>
<BALAMT>-768.33
<DTASOF>20180525000000[0:UTC]
</LEDGERBAL>
<AVAILBAL>
<BALAMT>-267.24
<DTASOF>20180525000000[0:UTC]
</AVAILBAL>
</CCSTMTRS>
</CCSTMTTRNRS>
</CREDITCARDMSGSRSV1>
Expand Down
Binary file added QFXparser.snk
Binary file not shown.
11 changes: 11 additions & 0 deletions QFXparser/AvailableBalance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace QFXparser
{
//public class AvailableBalance
//{
// public decimal Amount { get; set; }

// public DateTime AsOf { get; set; }
//}
}
1 change: 0 additions & 1 deletion QFXparser/LedgerBalance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace QFXparser
public class LedgerBalance
{
public decimal Amount { get; set; }

public DateTime AsOf { get; set; }
}
}
5 changes: 4 additions & 1 deletion QFXparser/NodeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ internal enum NodeType
TransactionProp,
LedgerBalanceOpen,
LedgerBalanceClose,
LedgerBalanceProp
LedgerBalanceProp,
AvailableBalanceOpen,
AvailableBalanceClose,
AvailableBalanceProp
}
}
60 changes: 57 additions & 3 deletions QFXparser/QFXparser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class FileParser
{
private string _fileText;
private RawLedgerBalance _ledgerBalance;
//private RawAvailableBalance _availableBalance;

private readonly CultureInfo _cultureInfo = CultureInfo.CurrentCulture;

/// <summary>
Expand Down Expand Up @@ -76,6 +78,7 @@ public Statement BuildStatement()
Name = rawTrans.Name,
PostedOn = rawTrans.PostedOn,
RefNumber = rawTrans.RefNumber,
CheckNumber = rawTrans.CheckNumber,
TransactionId = rawTrans.TransactionId,
Type = rawTrans.Type
};
Expand All @@ -88,6 +91,12 @@ public Statement BuildStatement()
AsOf = rawStatement.LedgerBalance.AsOf
};

//statement.AvailableBalance = new AvailableBalance
//{
// Amount = rawStatement.AvailableBalance.Amount,
// AsOf = rawStatement.AvailableBalance.AsOf
//};

return statement;
}

Expand Down Expand Up @@ -129,6 +138,7 @@ private RawStatement BuildRaw()
case NodeType.TransactionProp:
currentMember = result.Member;
break;

case NodeType.LedgerBalanceOpen:
_ledgerBalance = new RawLedgerBalance();
break;
Expand All @@ -143,6 +153,22 @@ private RawStatement BuildRaw()
}
currentMember = result.Member;
break;

//case NodeType.AvailableBalanceOpen:
// _availableBalance = new RawAvailableBalance();
// break;
//case NodeType.AvailableBalanceClose:
// _statement.AvailableBalance.Amount = _availableBalance.Amount;
// _statement.AvailableBalance.AsOf = _availableBalance.AsOf;
// break;
//case NodeType.AvailableBalanceProp:
// if (_availableBalance == null)
// {
// _availableBalance = new RawAvailableBalance();
// }
// currentMember = result.Member;
// break;

default:
break;
}
Expand All @@ -168,6 +194,10 @@ private RawStatement BuildRaw()
case "RawLedgerBalance":
property.SetValue(_ledgerBalance, ConvertQfxType(token.Content, property.PropertyType));
break;
//case "RawAvailableBalance":
// property.SetValue(_availableBalance, ConvertQfxType(token.Content, property.PropertyType));
// break;

default:
break;
}
Expand Down Expand Up @@ -245,6 +275,20 @@ private PropertyResult GetPropertyInfo(string token)
return propertyResult;
}

//if (typeof(RawAvailableBalance).GetCustomAttribute<NodeNameAttribute>().OpenTag == token)
//{
// propertyResult.Member = typeof(RawAvailableBalance);
// propertyResult.Type = NodeType.AvailableBalanceOpen;
// return propertyResult;
//}

//if (typeof(RawAvailableBalance).GetCustomAttribute<NodeNameAttribute>().CloseTag == token)
//{
// propertyResult.Member = typeof(RawAvailableBalance);
// propertyResult.Type = NodeType.AvailableBalanceClose;
// return propertyResult;
//}

var statementMember = typeof(RawStatement).GetProperties().FirstOrDefault(m => m.GetCustomAttribute<NodeNameAttribute>().OpenTag == token);

if (statementMember != null)
Expand All @@ -264,16 +308,26 @@ private PropertyResult GetPropertyInfo(string token)
return propertyResult;
}

var balanceMember = typeof(RawLedgerBalance).GetProperties().Where(m => m.GetCustomAttribute<NodeNameAttribute>() != null)
var ledgerBalanceMember = typeof(RawLedgerBalance).GetProperties().Where(m => m.GetCustomAttribute<NodeNameAttribute>() != null)
.FirstOrDefault(m => m.GetCustomAttribute<NodeNameAttribute>().OpenTag == token);

if (balanceMember != null)
if (ledgerBalanceMember != null)
{
propertyResult.Member = balanceMember;
propertyResult.Member = ledgerBalanceMember;
propertyResult.Type = NodeType.LedgerBalanceProp;
return propertyResult;
}

//var availableBalanceMember = typeof(RawAvailableBalance).GetProperties().Where(m => m.GetCustomAttribute<NodeNameAttribute>() != null)
// .FirstOrDefault(m => m.GetCustomAttribute<NodeNameAttribute>().OpenTag == token);

//if (availableBalanceMember != null)
//{
// propertyResult.Member = availableBalanceMember;
// propertyResult.Type = NodeType.AvailableBalanceProp;
// return propertyResult;
//}

return null;
}
}
Expand Down
6 changes: 4 additions & 2 deletions QFXparser/QFXparser.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<Company>emaquest.net</Company>
<Product>QFXparser</Product>
<PackageId>QFXparser</PackageId>
Expand All @@ -17,6 +17,8 @@
<PackageReleaseNotes>See Changelog:
https://github.com/eramella/QFXparser/blob/master/CHANGELOG.md</PackageReleaseNotes>
<NeutralLanguage>en-US</NeutralLanguage>
<SignAssembly>False</SignAssembly>
<AssemblyOriginatorKeyFile>D:\Visual Studio\Repos\QFXparser\QFXparser.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

</Project>
14 changes: 14 additions & 0 deletions QFXparser/RawAvailableBalance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace QFXparser
{
//[NodeName("AVAILBAL", "/AVAILBAL")]
//public class RawAvailableBalance
//{
// [NodeName("BALAMT")]
// public decimal Amount { get; set; }

// [NodeName("DTASOF")]
// public DateTime AsOf { get; set; }
//}
}
3 changes: 3 additions & 0 deletions QFXparser/RawStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ internal class RawStatement

[NodeName("LEDGERBAL")]
public RawLedgerBalance LedgerBalance { get; set; } = new RawLedgerBalance();

//[NodeName("AVAILBAL")]
//public RawAvailableBalance AvailableBalance { get; set; } = new RawAvailableBalance();
}
}
5 changes: 4 additions & 1 deletion QFXparser/RawTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ internal class RawTransaction

[NodeName("REFNUM")]
public string RefNumber { get; set; }


[NodeName("CHECKNUM")]
public string CheckNumber { get; set; }

[NodeName("NAME")]
public string Name { get; set; }

Expand Down
1 change: 1 addition & 0 deletions QFXparser/Statement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class Statement
public string AccountNum { get; set; }
public ICollection<Transaction> Transactions { get; set; } = new List<Transaction>();
public LedgerBalance LedgerBalance { get; set; } = new LedgerBalance();
// public AvailableBalance AvailableBalance { get; set; } = new AvailableBalance();
}
}
1 change: 1 addition & 0 deletions QFXparser/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Transaction
public Decimal Amount { get; set; }
public string TransactionId { get; set; }
public string RefNumber { get; set; }
public string CheckNumber { get; set; }
public string Name { get; set; }
public string Memo { get; set; }
}
Expand Down