using AyCode.Core.Interfaces;
using AyCode.Core.Serializers.Attributes;
using AyCode.Interfaces.TimeStampInfo;
using LinqToDB.Mapping;
using Mango.Nop.Core.Entities;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace FruitBank.Common.Entities;

[AcBinarySerializable(false, true, false, true, false, false)]
//[ToonDescription("Business partner with address and tax information", Purpose = "Represents an external legal entity, specifically a Supplier who provides goods or a business partner involved in the procurement chain")]
[LinqToDB.Mapping.Table(Name = FruitBankConstClient.PartnerDepotDbTableName)]
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.PartnerDepotDbTableName)]
public sealed class PartnerDepot : MgEntityBase, ITimeStampInfo, ICompanyInfoBase
{
    public int PartnerId { get; set; }

    public string Name { get; set;}

    [NotColumn, NotMapped, Newtonsoft.Json.JsonIgnore, JsonIgnore]
    public string? TaxId => Partner?.TaxId;

    public string CountryCode { get; set; }
    public string PostalCode { get; set;}
    public string City { get; set;}
    public string Street { get; set;}

    [NotColumn, NotMapped, Newtonsoft.Json.JsonIgnore, JsonIgnore]
    public string FullAddress => this.ComposeFullAddress() ?? string.Empty;

    [Association(ThisKey = nameof(PartnerId), OtherKey = nameof(Partner.Id), CanBeNull = true)]
    public Partner? Partner { get; set; }

    [SkipValuesOnUpdate]
    public DateTime Created { get; set; }
    public DateTime Modified { get; set; }
}