AccountingNext/Schaad.Accounting.Common/Models/Account.cs
Claudio Schaad 24bdfe60bc Store data as JSON instead of XML, with startup migration
Repositories now read and write indented, human-readable JSON
(System.Text.Json, shared settings in JsonStorage). File names and folders
are unchanged apart from the extension.

XmlToJsonMigrator runs at startup before the app serves requests. It converts
the known Data/*.xml files under every year/mandator, verifies the JSON reads
back to the same data, and moves the XML to
{year}/backup/{mandator}/xml-{timestamp}/. Bank-statement XMLs in uploads/ are
never touched. Any failure stops startup and leaves that file's XML in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 13:34:23 +02:00

63 lines
No EOL
1.5 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Schaad.Accounting.Models
{
public class Account
{
public string Id { get; set; }
[Display(Name = "Nummer")]
[Required]
public int Number { get; set; }
[Display(Name = "Name")]
[Required]
[MinLength(3)]
public string Name { get; set; }
[Display(Name = "Währung")]
[Required]
[MinLength(3)]
[MaxLength(3)]
public string Currency { get; set; }
[JsonIgnore]
[Display(Name = "Klasse")]
public int Class
{
get { return Number / 1000; }
}
[JsonIgnore]
[Display(Name = "Subklasse")]
public int SubClass
{
get { return Number / 100; }
}
/// <summary>
/// If mapped to a bank account
/// </summary>
[Display(Name = "Bankkontonummer")]
public string BankAccountNumber { get; set; }
/// <summary>
/// Start balance for acitvas
/// </summary>
[Display(Name = "Start Saldo")]
public decimal StartBalance { get; set; }
/// <summary>
/// Last received balance from bank
/// </summary>
[Display(Name = "Letzter Banksaldo")]
public decimal LastBankBalance { get; set; }
[JsonIgnore]
public bool IsFxAccount
{
get { return string.IsNullOrEmpty(Currency) == false && Currency != "CHF"; }
}
}
}