Skip to content

Commit

Permalink
Add Raiffeisen PDF support (#18)
Browse files Browse the repository at this point in the history
* Add Raiffeisen PDF support
* Minor recepies parser fixes
  • Loading branch information
vov4uk authored Feb 21, 2023
1 parent fb14773 commit dcefda0
Show file tree
Hide file tree
Showing 45 changed files with 747 additions and 281 deletions.
25 changes: 15 additions & 10 deletions src/Financier.Adapter/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Reflection;
using System.Text;
using Financier.DataAccess.Utils;

namespace Financier.Adapter
{
Expand All @@ -28,19 +29,23 @@ public static string ToBackupLines(this Entity entity, Dictionary<string, List<s
List<string> columnsOrder = entityColumnsOrder[classArttr.Name];
foreach (var propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
ColumnAttribute pattr = (ColumnAttribute)propertyInfo.GetCustomAttribute(typeof(ColumnAttribute));
if (pattr != null)
IgnoreAttribute ignoreAttr = propertyInfo.GetCustomAttribute(typeof(IgnoreAttribute)) as IgnoreAttribute;
if (ignoreAttr == null)
{
EntityPropertyInfo pInfo = new EntityPropertyInfo(propertyInfo)
ColumnAttribute pattr = propertyInfo.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute;
if (pattr != null)
{
Converter = (IPropertyConverter)Activator.CreateInstance(typeof(DefaultConverter))
};
pInfo.Converter.PropertyType = propertyInfo.PropertyType;
EntityPropertyInfo pInfo = new EntityPropertyInfo(propertyInfo)
{
Converter = (IPropertyConverter)Activator.CreateInstance(typeof(DefaultConverter))
};
pInfo.Converter.PropertyType = propertyInfo.PropertyType;

object val = propertyInfo.GetValue(entity);
if (val != null)
{
dict.Add(new KeyValuePair<int, string>(columnsOrder.IndexOf(pattr.Name), $"{pattr.Name}:{pInfo.Converter.ConvertBack(val)}"));
object val = propertyInfo.GetValue(entity);
if (val != null)
{
dict.Add(new KeyValuePair<int, string>(columnsOrder.IndexOf(pattr.Name), $"{pattr.Name}:{pInfo.Converter.ConvertBack(val)}"));
}
}
}
}
Expand Down
19 changes: 12 additions & 7 deletions src/Financier.Adapter/EntityReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection;
using Financier.DataAccess.Utils;

namespace Financier.Adapter
{
Expand Down Expand Up @@ -83,15 +84,19 @@ private IReadOnlyDictionary<string, EntityInfo> GetEntityTypes()
entities[attr.Name] = info;
foreach (PropertyInfo p in t.GetProperties())
{
ColumnAttribute pattr = (ColumnAttribute)p.GetCustomAttribute(typeof(ColumnAttribute));
if (pattr != null)
IgnoreAttribute ignoreAttr = p.GetCustomAttribute(typeof(IgnoreAttribute)) as IgnoreAttribute;
if (ignoreAttr == null)
{
EntityPropertyInfo pInfo = new EntityPropertyInfo(p)
ColumnAttribute pattr = p.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute;
if (pattr != null)
{
Converter = (IPropertyConverter)Activator.CreateInstance(typeof(DefaultConverter))
};
pInfo.Converter.PropertyType = p.PropertyType;
info.Properties[pattr.Name] = pInfo;
EntityPropertyInfo pInfo = new EntityPropertyInfo(p)
{
Converter = (IPropertyConverter)Activator.CreateInstance(typeof(DefaultConverter))
};
pInfo.Converter.PropertyType = p.PropertyType;
info.Properties[pattr.Name] = pInfo;
}
}
}
}
Expand Down
18 changes: 0 additions & 18 deletions src/Financier.Adapter/packages.config

This file was deleted.

22 changes: 12 additions & 10 deletions src/Financier.Common/Entities/DbManual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static async Task SetupAsync(IFinancierDatabase financierDatabase)
a.currency_id,
a.total_amount,
a.type,
a.last_transaction_id,
a.number,
c.Name as currency_name
FROM account a
INNER JOIN currency c ON a.currency_id = c._id
Expand Down Expand Up @@ -139,25 +141,25 @@ FROM v_report_transactions
}
}

public static List<AccountFilterModel> Account => _accounts;
public static List<AccountFilterModel> Account => _accounts ?? new();

public static List<CategoryModel> Category => _category;
public static List<CategoryModel> Category => _category ?? new();

public static List<CategoryModel> SubCategory => _category?.Where(x => x.Id > 0).ToList();
public static List<CategoryModel> SubCategory => _category?.Where(x => x.Id > 0).ToList() ?? new();

public static List<CategoryModel> TopCategories => _topCategory;
public static List<CategoryModel> TopCategories => _topCategory ?? new();

public static List<CurrencyModel> Currencies => _currencies;
public static List<CurrencyModel> Currencies => _currencies ?? new();

public static List<PayeeModel> Payee => _payee;
public static List<PayeeModel> Payee => _payee ?? new ();

public static List<ProjectModel> Project => _project;
public static List<ProjectModel> Project => _project ?? new();

public static List<YearMonths> YearMonths => _yearMonths;
public static List<YearMonths> YearMonths => _yearMonths ?? new();

public static List<Years> Years => _years;
public static List<Years> Years => _years ?? new();

public static List<LocationModel> Location => _location;
public static List<LocationModel> Location => _location ?? new();

public static void ResetAllManuals()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Financier.Common/Financier.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetProjects.Extended.Wpf.Toolkit" Version="5.0.100" />
<PackageReference Include="Emoji.Wpf" Version="0.3.3" />
<PackageReference Include="DotNetProjects.Extended.Wpf.Toolkit" Version="5.0.103" />
<PackageReference Include="Emoji.Wpf" Version="0.3.4" />
<PackageReference Include="Prism.Core" Version="8.1.97" />
<PackageReference Include="WPFChromeTabsMVVM" Version="1.4.0" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions src/Financier.Common/Model/AccountFilterModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ public class AccountFilterModel : BaseModel, IActive

[Column("total_amount")]
public long TotalAmount { get; set; }

[Column("last_transaction_id")]
public int LastTransactionId { get; set; }

[Column("number")]
public string Number { get; set; }
}
}
4 changes: 4 additions & 0 deletions src/Financier.DataAccess/Data/Account.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using Financier.DataAccess.Utils;

namespace Financier.DataAccess.Data
{
Expand All @@ -22,6 +23,9 @@ public class Account : Entity, IIdentity
[Column("last_transaction_date")]
public long LastTransactionDate { get; set; }

[Column("last_transaction_id"), Ignore]
public int LastTransactionId { get; set; }

[ForeignKey("Currency")]
[Column("currency_id")]
public int CurrencyId { get; set; }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,7 @@
<data name="_20190209_alter_entities_add_is_active" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>alter\20190209_alter_entities_add_is_active.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="_20220901_1220_add_lastaccounttransactionid" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>alter\20220901_1220_add_lastaccounttransactionid.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE account ADD COLUMN last_transaction_id integer not null default 0;
6 changes: 3 additions & 3 deletions src/Financier.DataAccess/Financier.DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<EmbeddedResource Include="DataBase\Scripts\alter\20180301_0101_added_order_column_to_smstemplates.sql" />
<EmbeddedResource Include="DataBase\Scripts\alter\20180301_0202_add_sort_order_to_all_entities.sql" />
<EmbeddedResource Include="DataBase\Scripts\alter\20190209_alter_entities_add_is_active.sql" />
<EmbeddedResource Include="DataBase\Scripts\alter\20220901_1220_add_lastaccounttransactionid.sql" />
<EmbeddedResource Include="DataBase\Scripts\create\account.sql" />
<EmbeddedResource Include="DataBase\Scripts\create\attributes.sql" />
<EmbeddedResource Include="DataBase\Scripts\create\budget.sql" />
Expand Down Expand Up @@ -102,10 +103,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="27.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="5.0.0-rc2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NLog" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Financier.DataAccess/FinancierDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public async Task RebuildAccountBalanceAsync(int accountId)
acc.TotalAmount = balance;
var lastTransaction = transactions.LastOrDefault();
acc.LastTransactionDate = lastTransaction?.DateTime ?? 0;
acc.LastTransactionId = lastTransaction?.Id ?? 0;
context.Accounts.Update(acc);
await context.SaveChangesAsync();
}
Expand Down
11 changes: 11 additions & 0 deletions src/Financier.DataAccess/Utils/IgnoreAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Financier.DataAccess.Utils
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public class IgnoreAttribute : Attribute
{
}
}
10 changes: 6 additions & 4 deletions src/Financier.Desktop/Financier.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,21 @@
<Resource Include="Images\menu_entities_payees.png" />
<Resource Include="Images\menu_entities_projects.png" />
<Resource Include="Images\monobank.png" />
<Resource Include="Images\raifaisenbank.png" />
<Resource Include="Images\save_as_db.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="DataGridExtensions" Version="2.6.0-beta1" />
<PackageReference Include="Docnet.Core" Version="2.4.0-alpha.2" />
<PackageReference Include="DotNetProjects.Extended.Wpf.Toolkit" Version="5.0.103" />
<PackageReference Include="Emoji.Wpf" Version="0.3.3" />
<PackageReference Include="Emoji.Wpf" Version="0.3.4" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="5.0.0-rc2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NLog" Version="5.1.0" />
<PackageReference Include="Prism.Core" Version="8.1.97" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.38.0.46746">
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.49.0.57237">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit dcefda0

Please sign in to comment.