Skip to content
Merged
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
10 changes: 9 additions & 1 deletion docs/AccountingData.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Location" type="xs:string" />
<xs:element name="Currency" type="xs:string" />
<xs:element name="Currency">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Show" default="false" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="BookingTemplates" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
Expand Down
10 changes: 5 additions & 5 deletions samples/sample.acml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Setup>
<Name>Demo</Name>
<Location>World</Location>
<Currency>€</Currency>
<Currency Show="true">€</Currency>
<Reports />
<Behavior />
</Setup>
Expand All @@ -26,17 +26,17 @@
<Account ID="990" Name="Carryforward" Type="Carryforward" />
</AccountGroup>
</Accounts>
<Journal Year="2024" DateStart="20240101" DateEnd="20241231">
<Booking Date="20240101" ID="1" Followup="true" Opening="true">
<Journal Year="2026" DateStart="20260101" DateEnd="20261231">
<Booking Date="20260101" ID="1" Followup="true" Opening="true">
<Debit Value="10000" Account="100" Text="Opening value 1" />
<Credit Value="10000" Account="990" Text="Opening value 1" />
</Booking>
<Booking Date="20240115" ID="2">
<Booking Date="20260115" ID="2">
<Debit Value="1000" Account="600" Text="Apples" />
<Debit Value="2500" Account="610" Text="Shoes" />
<Credit Value="3500" Account="100" Text="My Supermarket - Shopping Reference 4711" />
</Booking>
<Booking Date="20240128" ID="3">
<Booking Date="20260128" ID="3">
<Debit Value="55000" Account="100" Text="My Company - Salary" />
<Credit Value="40000" Account="400" Text="Monthly salary" />
<Credit Value="15000" Account="400" Text="Annual extra salary" />
Expand Down
11 changes: 11 additions & 0 deletions src/SimpleAccounting/Extensions/NumberExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ public static string FormatCurrency(this long value)
return (value / ConversionFactor).FormatCurrency();
}

/// <summary>
/// Formats the specified value as currency including the specified currency symbol.
/// The position of the symbol is defined by the specified culture.
/// </summary>
public static string FormatCurrency(this double value, string currencySymbol, CultureInfo culture)
{
var format = (NumberFormatInfo)culture.NumberFormat.Clone();
format.CurrencySymbol = currencySymbol;
return value.ToString("C2", format);
}

public static long ToModelValue(this double value)
{
return (long)Math.Round(value * ConversionFactor);
Expand Down
19 changes: 15 additions & 4 deletions src/SimpleAccounting/Model/AccountingData.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
}

[XmlAttribute("schemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
[SuppressMessage(

Check warning on line 38 in src/SimpleAccounting/Model/AccountingData.Extensions.cs

View workflow job for this annotation

GitHub Actions / build

Do not suppress issues.
"Minor Code Smell",
"S100:Methods and properties should be named in PascalCase",
Justification = "fixed name")]
[SuppressMessage("ReSharper", "RedundantCheckBeforeAssignment", Justification = "FP")]

Check warning on line 42 in src/SimpleAccounting/Model/AccountingData.Extensions.cs

View workflow job for this annotation

GitHub Actions / build

Do not suppress issues.
public string xsiSchemaLocation
{
get => this.schema;
Expand Down Expand Up @@ -78,7 +78,7 @@
};
return new AccountingData
{
Setup = new AccountingDataSetup { Currency = "€" },
Setup = new AccountingDataSetup(),
Accounts = [new AccountingDataAccountGroup { Name = "Default", Account = defaultAccounts }],
Journal = [accountJournal]
};
Expand Down Expand Up @@ -216,9 +216,10 @@

private bool IntroduceCurrency()
{
if (string.IsNullOrWhiteSpace(this.Setup.Currency))
if (string.IsNullOrWhiteSpace(this.Setup.Currency?.Value))
{
this.Setup.Currency = "€";
this.Setup.Currency ??= new AccountingDataSetupCurrency();
this.Setup.Currency.Value = AccountingDataSetupCurrency.DefaultValue;
return true;
}

Expand Down Expand Up @@ -263,10 +264,20 @@
{
this.behaviorField = new AccountingDataSetupBehavior();
this.reportsField = new AccountingDataSetupReports();
this.Currency = "€";
this.currencyField = new AccountingDataSetupCurrency { Value = AccountingDataSetupCurrency.DefaultValue };
}
}

public partial class AccountingDataSetupCurrency
{
internal const string DefaultValue = "€";

/// <summary>
/// Gets the currency symbol to be shown at the values, or <c>null</c> if the currency should not be shown.
/// </summary>
internal string? DisplaySymbol => this.Show ? this.Value : null;
}

public partial class AccountingDataSetupBehavior
{
/// <summary>
Expand Down
195 changes: 193 additions & 2 deletions src/SimpleAccounting/Model/AccountingData.designer.cs

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

10 changes: 9 additions & 1 deletion src/SimpleAccounting/Model/AccountingData.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Location" type="xs:string" />
<xs:element name="Currency" type="xs:string" />
<xs:element name="Currency">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Show" default="false" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="BookingTemplates" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
Expand Down
7 changes: 7 additions & 0 deletions src/SimpleAccounting/Presentation/AccountJournalViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public AccountJournalItemViewModel? SelectedItem
}
}

public string? DisplayCurrency => this.projectData.Storage.Setup.Currency.DisplaySymbol;

public void RefreshCurrency()
{
this.NotifyOfPropertyChange(nameof(this.DisplayCurrency));
}

public void Rebuild(ulong accountNumber)
{
this.Items.Clear();
Expand Down
Loading
Loading