AccountingNext/Schaad.Accounting.Common/Models/Account.cs
Claudio Schaad 3ffe4578c2 PR L: drop Copy(target) methods in favour of index-based replace
Replace the hand-rolled model.Copy(target) pattern in every SaveXxx
with FindIndex -> in-place replace (or Add on new). Move the two
hidden defaults out of the deleted Copy bodies: Currency = "CHF"
default now lives in AccountRepository.SaveAccount; BookingDate =
ValueDate default now lives in TransactionRepository.SaveTransaction.

Delete Copy from Account, BookingRule, BookingText, SubClass, and
SplitPredefinition. Keep Transaction.Clone() (renamed from Copy, and
now includes RelatedParty) for the defensive copy in GetTransaction
and ViewService.WithDisplaySign.

Fixes a pre-existing bug where Transaction.Copy silently dropped
RelatedParty on every update save.

42 tests total, all passing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-02 21:57:17 +02:00

63 lines
No EOL
1.5 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.Xml.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; }
[XmlIgnore]
[Display(Name = "Klasse")]
public int Class
{
get { return Number / 1000; }
}
[XmlIgnore]
[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; }
[XmlIgnore]
public bool IsFxAccount
{
get { return string.IsNullOrEmpty(Currency) == false && Currency != "CHF"; }
}
}
}