91 lines
4.3 KiB
C#
91 lines
4.3 KiB
C#
using AyCode.Core.Serializers.Attributes;
|
|
using AyCode.Core.Serializers.Toons;
|
|
using AyCode.Interfaces.TimeStampInfo;
|
|
using LinqToDB.Mapping;
|
|
using Mango.Nop.Core.Entities;
|
|
|
|
namespace FruitBank.Common.Entities;
|
|
|
|
[AcBinarySerializable(false, true, false, true, false, false)]
|
|
[ToonDescription("NAV EKÁER declaration lifecycle record", Purpose = "Work-queue and audit row for one EKÁER road-freight declaration — one row per tradeCard: an incoming ShippingDocument (delivery note) or a completed outgoing Order. Tracks the declaration through generation, validation and submission to the Hungarian tax authority (NAV).")]
|
|
[Table(Name = FruitBankConstClient.EkaerHistoryDbTableName)]
|
|
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.EkaerHistoryDbTableName)]
|
|
|
|
public sealed class EkaerHistory: MgEntityBase, ITimeStampInfo
|
|
{
|
|
[ToonDescription(Purpose = "Id of the source entity the declaration belongs to: ShippingDocument.Id when IsOutgoing is false (one declaration per delivery note, matching NAV's one-TCN-per-tradeCard granularity), Order id when IsOutgoing is true.")]
|
|
public int ForeignKey { get; set; }
|
|
|
|
[ToonDescription(Purpose = "Direction of the goods movement: false = incoming shipment (Shipping), true = outgoing delivery (Order).")]
|
|
public bool IsOutgoing { get; set; }
|
|
|
|
[ToonDescription(Purpose = "Lifecycle state of the declaration: Pending (auto-created, not yet generated), Generated (tradeCard XML produced and valid), ValidationError (generation produced errors, see ErrorText), Sent (accepted by NAV, EkaerNumber filled), SendError (NAV call failed, see ErrorText).")]
|
|
public EkaerStatus Status { get; set; }
|
|
|
|
[ToonDescription(Purpose = "The generated NAV EKÁER tradeCard request XML exactly as it was (or will be) submitted — audit copy and source of the read-only detail view. Null until the first Generate.")]
|
|
public string? XmlDoc { get; set; }
|
|
|
|
[ToonDescription(Purpose = "The EKÁER number (TCN) assigned by NAV after a successful submission. Null until the declaration is accepted.")]
|
|
public string? EkaerNumber { get; set; }
|
|
|
|
[ToonDescription(Purpose = "When the declaration was successfully submitted to NAV. Null until sent.")]
|
|
public DateTime? SentDate { get; set; }
|
|
|
|
[ToonDescription(Purpose = "Validation or NAV submission error details for the ValidationError / SendError states. Null when the last operation succeeded.")]
|
|
public string? ErrorText { get; set; }
|
|
|
|
public DateTime Created { get; set; }
|
|
public DateTime Modified { get; set; }
|
|
}
|
|
|
|
/// <summary>Az EKÁER-bejelentés életciklus-állapota. Append-only: új érték a végére, meglévő értéke nem változhat (DB-ben int-ként tárolt).</summary>
|
|
public enum EkaerStatus
|
|
{
|
|
/// <summary>Automatikusan létrejött, még nem volt Generate.</summary>
|
|
Pending = 0,
|
|
/// <summary>A tradeCard XML legenerálva és valid — küldhető.</summary>
|
|
Generated = 1,
|
|
/// <summary>A Generate validációs hibákkal zárult (ErrorText) — a forrásadat javítandó.</summary>
|
|
ValidationError = 2,
|
|
/// <summary>NAV által befogadva (EkaerNumber + SentDate töltve).</summary>
|
|
Sent = 3,
|
|
/// <summary>A NAV-hívás hibával zárult (ErrorText) — újraküldhető.</summary>
|
|
SendError = 4,
|
|
}
|
|
|
|
//public sealed class EkaerHistoryShipping : EkaerHistoryBase
|
|
//{
|
|
// public int ShippingId
|
|
// {
|
|
// get => ForeignItemId;
|
|
// set => ForeignItemId = value;
|
|
// }
|
|
|
|
// [Association(ThisKey = nameof(ShippingId), OtherKey = nameof(Shipping.Id), CanBeNull = true)]
|
|
// public Shipping? Shipping { get; set; }
|
|
//}
|
|
|
|
//public sealed class EkaerHistoryOrder : EkaerHistoryBase
|
|
//{
|
|
// public int ShippingId
|
|
// {
|
|
// get => ForeignItemId;
|
|
// set => ForeignItemId = value;
|
|
// }
|
|
|
|
// [Association(ThisKey = nameof(ShippingId), OtherKey = nameof(Shipping.Id), CanBeNull = true)]
|
|
// public Shipping? Shipping { get; set; }
|
|
//}
|
|
|
|
//public abstract class EkaerHistoryBase : MgEntityBase, ITimeStampInfo
|
|
//{
|
|
// [NotColumn]
|
|
// protected int ForeignItemId;
|
|
|
|
// [NotColumn]
|
|
// [ToonDescription(BusinessRule = "get => ForeignItemId", Constraints = "[#SmartTypeConstraints]")]
|
|
// public int ForeignKey => ForeignItemId;
|
|
|
|
// public DateTime Created { get; set; }
|
|
// public DateTime Modified { get; set; }
|
|
//} |