Skip to content

Commit

Permalink
Breaking change to Other Income/Expense accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanpranav committed Aug 19, 2024
1 parent 59f3ec7 commit 291cca6
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Liber.Forms/Accounts/AccountDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AccountDialog(EditableAccountView value)

_listView.BeginUpdate();

foreach (AccountType type in Enum.GetValues<AccountType>())
foreach (AccountType type in AccountTypeExtensions.GetSortedValues())
{
_listView.Groups.Add(type.ToString(), type.Humanize());
}
Expand Down
132 changes: 132 additions & 0 deletions src/Liber.Forms/Accounts/AccountDialog.es.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="$this.Text" xml:space="preserve">
<value>Cuenta</value>
</data>
<data name="cancelButton.Text" xml:space="preserve">
<value>&amp;Cancelar</value>
</data>
<data name="nameColumn.Text" xml:space="preserve">
<value>Nombre</value>
</data>
<data name="numberColumn.Text" xml:space="preserve">
<value>Número</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/Liber.Forms/Accounts/AccountDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
</data>
<data name="acceptButton.Text" xml:space="preserve">
<value>O&amp;K</value>
<comment>@Invariant</comment>
</data>
<data name="&gt;&gt;acceptButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
Expand Down
6 changes: 1 addition & 5 deletions src/Liber.Forms/Accounts/AccountForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ protected AccountForm(Company company)

new ComponentResourceManager(GetType()).ApplyResources(this, "$this");

AccountType[] types = Enum.GetValues<AccountType>();

Array.Sort(types, (x, y) => Math.Abs((short)x) - Math.Abs((short)y));

Company = company;
DialogResult = DialogResult.Cancel;
typeComboBox.DataSource = types;
typeComboBox.DataSource = AccountTypeExtensions.GetSortedValues();
taxTypeComboBox.DataSource = Enum.GetValues<TaxType>();
numberNumericUpDown.Maximum = decimal.MaxValue;
}
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 @@ -309,6 +309,11 @@ private void WriteTransactionXml(XmlWriter writer, Transaction value)

private void WriteLineXml(XmlWriter writer, Line value)
{
if (value.AccountId != Account.Id)
{
return;
}

writer.WriteStartElement("line");
writer.WriteElementString("account", Company.Accounts[value.AccountId].Name);
writer.WriteElementString("debit", XmlConvert.ToString(value.Debit));
Expand Down
25 changes: 17 additions & 8 deletions src/Liber/AccountType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,32 @@ public enum AccountType : short
[Name("EXP")]
Expense = 6000,

/// <summary>
/// Specifies an income tax expense. This account type records taxes.
/// </summary>
[LocalizedDescription(nameof(IncomeTaxExpense))]
[Name("INC")]
IncomeTaxExpense = 7000,

/// <summary>
/// Specifies an other income or expense account. This account is used for realized capital gains and losses and extraordinary income and expenses.
/// </summary>
[LocalizedDescription(nameof(OtherIncomeExpense))]
[Name("EXEXP", "EXINC")]
OtherIncomeExpense = -9000
OtherIncomeExpense = -6900,

/// <summary>
/// Specifies an income tax expense. This account type records taxes.
/// </summary>
[LocalizedDescription(nameof(IncomeTaxExpense))]
[Name("INC")]
IncomeTaxExpense = 7000
}

public static class AccountTypeExtensions
{
public static AccountType[] GetSortedValues()
{
AccountType[] types = Enum.GetValues<AccountType>();

Array.Sort(types, (x, y) => Math.Abs((short)x) - Math.Abs((short)y));

return types;
}

public static bool IsAsset(this AccountType value)
{
switch (value)
Expand Down
6 changes: 6 additions & 0 deletions src/Liber/LocalizedResources.es-ES.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="_d_Account" xml:space="preserve">
<value>Determina la cuenta incluida en el informe. Los elementos de datos 'Cuenta' y 'Cuentas' son mutuamente excluyentes.</value>
</data>
<data name="_d_Accounts" xml:space="preserve">
<value>Determina las cuentas incluidas en el informe. Los elementos de datos 'Cuenta' y 'Cuentas' son mutuamente excluyentes.</value>
</data>
<data name="_d_Title" xml:space="preserve">
<value>Especifica el título del informe.</value>
</data>
Expand Down
11 changes: 10 additions & 1 deletion src/Liber/LocalizedResources.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Account" xml:space="preserve">
<value>Cuenta</value>
</data>
<data name="Accounts" xml:space="preserve">
<value>Cuentas</value>
</data>
Expand Down Expand Up @@ -171,6 +174,9 @@
<data name="Type" xml:space="preserve">
<value>Tipo</value>
</data>
<data name="_c_Account" xml:space="preserve">
<value>Fuente de datos</value>
</data>
<data name="_c_Accounts" xml:space="preserve">
<value>Fuente de datos</value>
</data>
Expand Down Expand Up @@ -201,14 +207,17 @@
<data name="_c_Title" xml:space="preserve">
<value>Diseño</value>
</data>
<data name="_d_Account" xml:space="preserve">
<value>Determina la cuenta incluida en el reporte. Los elementos de datos 'Cuenta' y 'Cuentas' son mutuamente excluyentes.</value>
</data>
<data name="_d_AccountPayable" xml:space="preserve">
<value>Cuenta por pagar</value>
</data>
<data name="_d_AccountReceivable" xml:space="preserve">
<value>Cuenta por cobrar</value>
</data>
<data name="_d_Accounts" xml:space="preserve">
<value>Determina las cuentas incluidas en el documento.</value>
<value>Determina las cuentas incluidas en el reporte. Los elementos de datos 'Cuenta' y 'Cuentas' son mutuamente excluyentes.</value>
</data>
<data name="_d_Annually" xml:space="preserve">
<value>Anualmente</value>
Expand Down
11 changes: 10 additions & 1 deletion src/Liber/LocalizedResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Account" xml:space="preserve">
<value>Account</value>
</data>
<data name="Accounts" xml:space="preserve">
<value>Accounts</value>
</data>
Expand Down Expand Up @@ -174,6 +177,9 @@
<data name="Type" xml:space="preserve">
<value>Type</value>
</data>
<data name="_c_Account" xml:space="preserve">
<value>Data Source</value>
</data>
<data name="_c_Accounts" xml:space="preserve">
<value>Data Source</value>
</data>
Expand Down Expand Up @@ -204,14 +210,17 @@
<data name="_c_Title" xml:space="preserve">
<value>Design</value>
</data>
<data name="_d_Account" xml:space="preserve">
<value>Determines the account used in the report. The 'Account' and 'Accounts' fields are mutually exclusive.</value>
</data>
<data name="_d_AccountPayable" xml:space="preserve">
<value>Account Payable</value>
</data>
<data name="_d_AccountReceivable" xml:space="preserve">
<value>Account Receivable</value>
</data>
<data name="_d_Accounts" xml:space="preserve">
<value>Determines the accounts included in the report.</value>
<value>Determines the accounts included in the report. The 'Account' and 'Accounts' fields are mutually exclusive.</value>
</data>
<data name="_d_Annually" xml:space="preserve">
<value>Annually</value>
Expand Down

0 comments on commit 291cca6

Please sign in to comment.