FruitBankHybridApp/FruitBank.Common/Entities/CargoTruck.cs

35 lines
1.9 KiB
C#

using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Core.Serializers.Attributes;
using AyCode.Core.Serializers.Toons;
using FruitBank.Common.Interfaces;
using LinqToDB.Mapping;
using Mango.Nop.Core.Entities;
using Newtonsoft.Json;
namespace FruitBank.Common.Entities;
[AcBinarySerializable(false, true, false, true, false, false)]
[ToonDescription("Cargo vehicle — truck or trailer — owned by a transport partner", Purpose = "A single vehicle in a transport company's fleet. One table holds both tractor units and trailers, distinguished by IsTrailer. Truck and trailer are tracked as separate vehicles because Hungarian EKÁER road-freight reporting (NAV) declares the towing vehicle and the trailer as distinct entries (vehicle / vehicle2), each with its own licence plate and country code — i.e. these shipments carry an EKÁER declaration obligation.")]
[LinqToDB.Mapping.Table(Name = FruitBankConstClient.CargoTruckDbTableName)]
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.CargoTruckDbTableName)]
public sealed class CargoTruck: MgEntityBase, ICargoTruck
{
[ToonDescription(Purpose = "FK to the owning transport company (CargoPartner) — the carrier, not the goods supplier.")]
public int CargoPartnerId { get; set; }
[Association(ThisKey = nameof(CargoPartnerId), OtherKey = nameof(CargoPartner.Id), CanBeNull = true)]
public CargoPartner CargoPartner { get; set; }
public string CountryCode { get; set; }
public string LicencePlate { get; set; }
[ToonDescription(Purpose = "Discriminates the shared table: false = tractor/truck unit, true = trailer.")]
public bool IsTrailer { get; set; }
[NotColumn, NotMapped, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
public string? CargoPartnerName => CargoPartner?.Name;
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
}