Skip to content

Commit

Permalink
Shared - Fix OFX Parsing With Missing Sections
Browse files Browse the repository at this point in the history
Fixes #762
  • Loading branch information
nlogozzo committed Jan 5, 2024
1 parent a857ace commit 2fd1ccd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion NickvisionMoney.GNOME/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public Program(string[] args)
* Fixed an issue that caused sort to behave inconsistently
* Fixed an issue where dragging and dropping an account file was not working
* Fixed an issue where help documentation was not showing in-app
* Fixed calendar not showing marks for transactions after pressing the ""Today"" button
* Fixed an issue where some ofx files could not be imported
* Fixed an issue where the calendar was not showing marked days after pressing the ""Today"" button
* Added more logging to help debug issues
* Updated and added translations (Thanks to everyone on Weblate)!";
_application.OnActivate += OnActivate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@
<p>- Fixed an issue where the generated ids of new transactions were incorrect</p>
<p>- Fixed an issue that caused sort to behave inconsistently</p>
<p>- Fixed an issue where dragging and dropping an account file was not working</p>
<p>- Fixed calendar not showing marks for transactions after pressing the "Today" button</p>
<p>- Fixed an issue where help documentation was not showing in-app</p>
<p>- Fixed an issue where some ofx files could not be imported</p>
<p>- Fixed an issue where the calendar was not showing marked days after pressing the "Today" button</p>
<p>- Added more logging to help debug issues</p>
<p>- Updated translations (Thanks to everyone on Weblate)!</p>
</description>
Expand Down
23 changes: 23 additions & 0 deletions NickvisionMoney.Shared/Models/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,29 @@ private async Task<ImportResult> ImportFromOFXAsync(string path, string defaultT
OFXDocument? ofx = null;
//Check For Security
var ofxString = File.ReadAllText(path);
if (!ofxString.Contains("SIGNONMSGSRQV1") && !ofxString.Contains("SIGNONMSGSRSV1"))
{
ofxString = ofxString.Insert(ofxString.IndexOf("<OFX>") + 5, @"
<SIGNONMSGSRSV1>
<SONRS>
<STATUS>
<CODE>0</CODE>
<SEVERITY>INFO</SEVERITY>
<MESSAGE>OK</MESSAGE>
</STATUS>
<DTSERVER>20230302112111[-8:PST]</DTSERVER>
<LANGUAGE>ENG</LANGUAGE>
</SONRS>
</SIGNONMSGSRSV1>");
}
if(!ofxString.Contains("LEDGERBAL"))
{
ofxString = ofxString.Insert(ofxString.IndexOf("</BANKTRANLIST>") + 15, @"
<LEDGERBAL>
<BALAMT>0.00</BALAMT>
<DTASOF>20230302112111[-8:PST]</DTASOF>
</LEDGERBAL>");
}
if (ofxString.Contains("SECURITY:TYPE1"))
{
ofxString = ofxString.Replace("SECURITY:TYPE1", "SECURITY:NONE");
Expand Down

0 comments on commit 2fd1ccd

Please sign in to comment.