Skip to content

Commit

Permalink
Good for now
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanpranav committed Aug 20, 2024
1 parent 22002b9 commit ccebb5f
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 84 deletions.
1 change: 1 addition & 0 deletions src/Liber.Forms/Import/ImportForm.Designer.cs

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

136 changes: 68 additions & 68 deletions src/Liber.Forms/Import/ImportForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,38 +118,26 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="cancelButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
<value>439, 265</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="cancelButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 2</value>
</data>
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 22</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="cancelButton.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="cancelButton.Text" xml:space="preserve">
<value>&amp;Cancel</value>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>7, 15</value>
</data>
<data name="&gt;&gt;cancelButton.Name" xml:space="preserve">
<value>cancelButton</value>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>533, 298</value>
</data>
<data name="&gt;&gt;cancelButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 2</value>
</data>
<data name="&gt;&gt;cancelButton.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>ImportForm</value>
</data>
<data name="&gt;&gt;cancelButton.ZOrder" xml:space="preserve">
<value>3</value>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="acceptButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
Expand All @@ -160,6 +148,12 @@
<data name="acceptButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 2</value>
</data>
<data name="&gt;&gt;acceptButton.Name" xml:space="preserve">
<value>acceptButton</value>
</data>
<data name="&gt;&gt;acceptButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="acceptButton.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 22</value>
</data>
Expand All @@ -169,47 +163,41 @@
<data name="acceptButton.Text" xml:space="preserve">
<value>I&amp;mport</value>
</data>
<data name="&gt;&gt;acceptButton.Name" xml:space="preserve">
<value>acceptButton</value>
</data>
<data name="&gt;&gt;acceptButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;acceptButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;acceptButton.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="_dataGridView.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
<data name="cancelButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="_dataGridView.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 9</value>
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
<value>439, 265</value>
</data>
<data name="_dataGridView.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<data name="cancelButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 2</value>
</data>
<data name="_dataGridView.RowHeadersWidth" type="System.Int32, mscorlib">
<value>51</value>
<data name="&gt;&gt;cancelButton.Name" xml:space="preserve">
<value>cancelButton</value>
</data>
<data name="_dataGridView.Size" type="System.Drawing.Size, System.Drawing">
<value>509, 243</value>
<data name="&gt;&gt;cancelButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="_dataGridView.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 22</value>
</data>
<data name="&gt;&gt;_dataGridView.Name" xml:space="preserve">
<value>_dataGridView</value>
<data name="cancelButton.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;_dataGridView.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridView, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="cancelButton.Text" xml:space="preserve">
<value>&amp;Cancel</value>
</data>
<data name="&gt;&gt;_dataGridView.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;cancelButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;_dataGridView.ZOrder" xml:space="preserve">
<value>1</value>
<data name="&gt;&gt;cancelButton.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="label1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
Expand All @@ -220,6 +208,12 @@
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 259</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>333, 35</value>
</data>
Expand All @@ -229,34 +223,40 @@
<data name="label1.Text" xml:space="preserve">
<value>Use the Preferences window to adjust how transactions and accounts are automatically classified.</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
</data>
<data name="&gt;&gt;label1.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>7, 15</value>
<data name="_dataGridView.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>533, 298</value>
<data name="_dataGridView.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 9</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<data name="_dataGridView.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 2, 3, 2</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>ImportForm</value>
<data name="&gt;&gt;_dataGridView.Name" xml:space="preserve">
<value>_dataGridView</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="&gt;&gt;_dataGridView.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="_dataGridView.RowHeadersWidth" type="System.Int32, mscorlib">
<value>51</value>
</data>
<data name="_dataGridView.Size" type="System.Drawing.Size, System.Drawing">
<value>509, 243</value>
</data>
<data name="_dataGridView.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;_dataGridView.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridView, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;_dataGridView.ZOrder" xml:space="preserve">
<value>1</value>
</data>
</root>
26 changes: 19 additions & 7 deletions src/Liber.Forms/Import/ImportRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.ComponentModel;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;

namespace Liber.Forms.Import;

Expand All @@ -20,30 +21,41 @@ internal sealed class ImportRule
[TypeConverter(typeof(LocalizedEnumConverter))]
public AccountType Type { get; set; }

[LocalizedDisplayName(nameof(Adjustment))]
[TypeConverter(typeof(LocalizedEnumConverter))]
public TriState Adjustment { get; set; }

[LocalizedDisplayName(nameof(Strict))]
[TypeConverter(typeof(LocalizedEnumConverter))]
public bool Strict { get; set; }

public void Apply(IEnumerable<Account> accounts)
{
if (Type == AccountType.None)
if (Type == AccountType.None && Adjustment == TriState.UseDefault)
{
return;
}

foreach (Account account in accounts)
{
if (!Strict && !account.Type.IsUncategorized())
{
continue;
}

if (Filter.IsMatch(account.Name))
{
if (Type != AccountType.None)
if (Type != AccountType.None &&
(Strict || account.Type.IsUncategorized()))
{
account.Type = Type;
}

switch (Adjustment)
{
case TriState.True:
account.Adjustment = true;
break;

case TriState.False:
account.Adjustment = false;
break;
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/Liber.Forms/Reports/Xsl/XslReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ void IXmlSerializable.ReadXml(XmlReader reader)

private void WriteAccountXml(XmlWriter writer, Account value)
{
if (Metadata.CashBasis && value.Adjustment)
{
return;
}

writer.WriteStartElement("account");
writer.WriteElementString("name", value.Name);
writer.WriteElementString("type", value.Type.ToString());
Expand Down
2 changes: 1 addition & 1 deletion src/Liber.Forms/SettingsForm.Designer.cs

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

16 changes: 8 additions & 8 deletions src/Liber.Forms/SettingsForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="acceptButton.Location" type="System.Drawing.Point, System.Drawing">
<value>289, 329</value>
<value>360, 332</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="acceptButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
Expand Down Expand Up @@ -173,7 +173,7 @@
<value>NoControl</value>
</data>
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
<value>376, 329</value>
<value>447, 332</value>
</data>
<data name="cancelButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 4, 3, 4</value>
Expand Down Expand Up @@ -218,7 +218,7 @@
<value>True</value>
</data>
<data name="cultureComboBox.Size" type="System.Drawing.Size, System.Drawing">
<value>425, 28</value>
<value>496, 28</value>
</data>
<data name="cultureComboBox.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
Expand All @@ -242,7 +242,7 @@
<value>3, 64</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<value>437, 52</value>
<value>508, 52</value>
</data>
<data name="label2.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
Expand Down Expand Up @@ -275,7 +275,7 @@
<value>3, 4, 3, 4</value>
</data>
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>443, 120</value>
<value>514, 120</value>
</data>
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
Expand Down Expand Up @@ -308,7 +308,7 @@
<value>51</value>
</data>
<data name="importRulesDataGridView.Size" type="System.Drawing.Size, System.Drawing">
<value>437, 149</value>
<value>508, 152</value>
</data>
<data name="importRulesDataGridView.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
Expand Down Expand Up @@ -338,7 +338,7 @@
<value>3, 4, 3, 4</value>
</data>
<data name="groupBox2.Size" type="System.Drawing.Size, System.Drawing">
<value>443, 177</value>
<value>514, 180</value>
</data>
<data name="groupBox2.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
Expand All @@ -365,7 +365,7 @@
<value>8, 20</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>469, 375</value>
<value>540, 378</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 4, 3, 4</value>
Expand Down
5 changes: 5 additions & 0 deletions src/Liber/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,14 @@ public Account(Guid parentId)
[BooleanTrueValues("T")]
[Index(9)]
[Key(9)]
[LocalizedDisplayName(nameof(Inactive))]
[Name("Hidden")]
[Optional]
public bool Inactive { get; set; }

[Ignore]
[Key(10)]
[LocalizedDisplayName(nameof(Adjustment))]
public bool Adjustment { get; set; }

/// <summary>
Expand Down Expand Up @@ -230,6 +232,9 @@ public IOrderedEnumerable<Line> OrderedLines
}
}

[Browsable(false)]
[IgnoreMember]
[JsonIgnore]
public bool Hidden
{
get
Expand Down

0 comments on commit ccebb5f

Please sign in to comment.