242 lines
11 KiB
C#
242 lines
11 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Text.Json.Serialization;
|
|
using Back.Common;
|
|
using Shared.DTOs;
|
|
using TaxCollectData.Library.Dto.Content;
|
|
namespace Back.Data.Models
|
|
{
|
|
public class Invoice : ICloneable
|
|
{
|
|
#region Key
|
|
public int ID { get; set; }
|
|
public int? PatternID { get; set; }
|
|
public int? CompanyID { get; set; }
|
|
public int CustomerID { get; set; }
|
|
public int? BillReference { get; set; }
|
|
#endregion
|
|
|
|
|
|
#region autofild
|
|
|
|
//تاریخ و زمان صدور صورتحساب )میالدی(
|
|
[MaxLength(13)]
|
|
public long? indatim { get { return new DateTimeOffset(InvoicIssueDate.Trim().ToMiladi()).ToUnixTimeMilliseconds(); } }
|
|
//تاریخ و زمان ایجاد صورتحساب )میالدی(
|
|
[MaxLength(15)]
|
|
public long? Indati2m { get { return new DateTimeOffset(InvoiceDate.Trim().ToMiladi()).ToUnixTimeMilliseconds(); } }
|
|
//نوع صورتحساب
|
|
[MaxLength(1)]
|
|
public int? inty { get { return pattern?.BillType.inty; } }
|
|
//الگوی صورتحساب
|
|
[MaxLength(2)]
|
|
public int? inp { get { return pattern?.inp; } }
|
|
//شماره اقتصادی فروشنده
|
|
[MaxLength(14)]
|
|
public string? tins { get { return company?.EconomicCode; } }
|
|
//شماره اقتصادی خریدار
|
|
[MaxLength(14)]
|
|
public string? tinb { get { return Customer.CustomerType==CustomerType.WithoutIdentity ?null : Customer.EconomicCode; } }
|
|
//مجموع مبلغ قبل از کسر تخفیف
|
|
[MaxLength(18)]
|
|
public decimal? tprdis { get { return invoiceDetails.Sum(i => i.prdis); } }
|
|
//مجموع تخفیفات
|
|
[MaxLength(18)]
|
|
public decimal? tdis { get { return invoiceDetails.Sum(i => i.dis); } }
|
|
//مجموع مبلغ پس از کسر تخفیف
|
|
[MaxLength(18)]
|
|
public decimal? tadis { get { return invoiceDetails.Sum(i => i.adis); } }
|
|
//مجموع مالیات بر ارزش افزوده
|
|
[MaxLength(18)]
|
|
public decimal? tvam { get { return invoiceDetails.Sum(i => i.vam); } }
|
|
//مجموع سایر مالیات، عوارض و وجوه قانونی
|
|
[MaxLength(18)]
|
|
public decimal? todam { get { return invoiceDetails.Sum(i => i.odam) + invoiceDetails.Sum(i => i.olam); } }
|
|
//مجموع صورتحساب
|
|
[MaxLength(18)]
|
|
public decimal? tbill { get {return pattern?.inp==10? torv+ tvam+ todam : invoiceDetails.Sum(i => i.tsstam);}}
|
|
//مجموع وزن خالص
|
|
[MaxLength(18)]
|
|
public decimal? tonw { get { return invoiceDetails.Sum(i => i.nw); } }
|
|
//مجموع ارزش ریالی
|
|
[MaxLength(18)]
|
|
public decimal? torv { get { return invoiceDetails.Sum(i => i.ssrv); } }
|
|
//مجموع ارزش ارزی
|
|
[MaxLength(18)]
|
|
public decimal? tocv { get { return invoiceDetails.Sum(i => i.sscv); } }
|
|
//مجموع سهم مالیات بر ارزش افزوده از پرداخت
|
|
[MaxLength(18)]
|
|
public decimal? tvop { get { return invoiceDetails.Sum(i => i.vop); } }
|
|
//نوع شخص خریدار
|
|
[MaxLength(1)]
|
|
public int tob { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? 0 : (int)Customer.CustomerType; } }
|
|
//اریخ کوتاژ اظهارنامه گمرکی
|
|
// Unix Time => from fild CottageDateOfCustomsDeclaration
|
|
[MaxLength(5)]
|
|
public int? cdcd { get {
|
|
return string.IsNullOrEmpty(CottageDateOfCustomsDeclaration) ? null : (int)DateTime.UtcNow.Subtract(CottageDateOfCustomsDeclaration.Trim().ToMiladi()).TotalSeconds;
|
|
// return string.IsNullOrEmpty(CottageDateOfCustomsDeclaration) ? null : new DateTimeOffset(CottageDateOfCustomsDeclaration.Trim().ToMiladi()).ToUnixTimeMilliseconds();
|
|
} }
|
|
//کد پستی خریدار
|
|
[MaxLength(10)]
|
|
public string? bpc { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.ZipCode; } }
|
|
//کد شعبه خریدار
|
|
[MaxLength(10)]
|
|
public string? bbc { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.BranchID; } }
|
|
//شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیرایرانی خریدار
|
|
[MaxLength(14)]
|
|
public string? bid { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.MeliCode; } }
|
|
//شماره گذرنامه خریدار
|
|
[MaxLength(9)]
|
|
public string? bpn { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.PassportNumber; } }
|
|
//کد شعبه فروشنده
|
|
[MaxLength(9)]
|
|
public string? sbc { get { return company?.BranchID; } }
|
|
//مبلغ پرداختی نقدی
|
|
[MaxLength(18)]
|
|
public decimal? cap { get {
|
|
return
|
|
setm == 1 ? tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault()
|
|
: setm == 2 ? 0
|
|
: tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault() - insp.GetValueOrDefault();
|
|
} }
|
|
//موضوع صورتحساب
|
|
[MaxLength(1)]
|
|
public int? ins { get { return (int)invoiceType; } }
|
|
public decimal Calcinsp { get { return tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault(); } }
|
|
#endregion
|
|
|
|
#region fild
|
|
//سریال صورتحساب داخلی حافظه مالیاتی
|
|
[MaxLength(10)]
|
|
public string? inno { get; set; }
|
|
public string Title { get; set; }
|
|
public string? Des { get; set; }
|
|
public InvoiceType invoiceType { get; set; }
|
|
//شماره منحصر به فرد مالیاتی
|
|
// [MaxLength(22)]
|
|
public string taxid { get; set; } = "";
|
|
//شماره منحصر به فرد مالیاتی صورتحساب مرجع
|
|
[MaxLength(22)]
|
|
public string? irtaxid { get; set; }
|
|
//نوع پرواز
|
|
[MaxLength(9)]
|
|
public int? ft { get; set; }
|
|
//شماره پروانه گمرکی
|
|
[MaxLength(14)]
|
|
public string? scln { get; set; }
|
|
//کد گمرک محل اظهار فروشنده
|
|
[MaxLength(5)]
|
|
public string? scc { get; set; }
|
|
//شناسه یکتای ثبت قرارداد فروشنده
|
|
[MaxLength(12)]
|
|
public string? crn { get; set; }
|
|
//شماره کوتاژ اظهارنامه گمرکی
|
|
[MaxLength(14)]
|
|
public string? cdcn { get; set; }
|
|
//اریخ کوتاژ اظهارنامه گمرکی
|
|
// Unix Time
|
|
[MaxLength(5)]
|
|
public string? CottageDateOfCustomsDeclaration { get; set; }
|
|
//شماره اشتراک/ شناسه قبض بهرهبردار
|
|
[MaxLength(19)]
|
|
public string? billid { get; set; }
|
|
//روش تسویه
|
|
private int? _setm;
|
|
[MaxLength(1)]
|
|
public int? setm
|
|
{
|
|
get
|
|
{
|
|
return pattern.BillTypeID == 3 || (pattern.BillTypeID == 2 && pattern.ID == 10)
|
|
? 1
|
|
: _setm;
|
|
}
|
|
set { _setm = value; }
|
|
}
|
|
//مبلغ نسیه
|
|
[MaxLength(18)]
|
|
public decimal? insp { get; set; } = 0;
|
|
//مالیات موضوع ماده 17
|
|
[MaxLength(18)]
|
|
public string? seventeentax { get; set; }
|
|
//نکته باید به شمسی تبدیل شود
|
|
public string? Cdate { get; set; }
|
|
public string? Udate { get; set; }
|
|
public string InvoicIssueDate { get; set; }
|
|
public string InvoiceDate { get; set; }
|
|
public bool PreparedtoSendtoTax { get; set; } = false;
|
|
public int LastChangeUserID { get; set; }
|
|
public bool IsDeleted { get; set; }
|
|
//شماره اقتصادی آژانس
|
|
[MaxLength(14)]
|
|
public string? tinc { get; set; }
|
|
//شماره بارنامه
|
|
[MaxLength(18)]
|
|
public string? ino { get; set; }
|
|
//شماره بارنامه مرجع
|
|
[MaxLength(18)]
|
|
public string? irno { get; set; }
|
|
//کشور مبدا
|
|
[MaxLength(3)]
|
|
public string? ocu { get; set; }
|
|
//شهر مبدا
|
|
[MaxLength(5)]
|
|
public string? oci { get; set; }
|
|
//کشور مقصد
|
|
[MaxLength(3)]
|
|
public string? dco { get; set; }
|
|
//شهر مقصد
|
|
[MaxLength(5)]
|
|
public string? dci { get; set; }
|
|
//شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیر ایرانی فرستنده
|
|
[MaxLength(12)]
|
|
public string? tid { get; set; }
|
|
//شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیر ایرانی گیرنده
|
|
[MaxLength(12)]
|
|
public string? rid { get; set; }
|
|
//نوع بارنامه/ نوع حمل
|
|
public int? lt { get; set; }
|
|
//شماره ناوگان
|
|
[MaxLength(20)]
|
|
public string? cno { get; set; }
|
|
//کد ملی/ کد فراگیر اتباع غیر ایرانی راننده) در حمل و نقل جاده ای(
|
|
[MaxLength(12)]
|
|
public string? did { get; set; }
|
|
//کالاهای حمل شده
|
|
//public List<ShippingGoodDto> sg { get { return new List<ShippingGoodDto>(); } }
|
|
//شماره اعلامیه فروش
|
|
[MaxLength(20)]
|
|
public string? asn { get; set; }
|
|
//تاریخ اعلامیه فروش
|
|
public string? DateSaleAnnouncement { get; set; }
|
|
public int? asd { get { return 0; } }
|
|
#endregion
|
|
|
|
#region Navigation
|
|
[ForeignKey("CustomerID")]
|
|
public virtual Customer Customer { get; set; }
|
|
[ForeignKey("LastChangeUserID")]
|
|
public virtual User user { get; set; }
|
|
public virtual ICollection<InvoiceItem> invoiceDetails { get; set; }
|
|
[ForeignKey("BillReference")]
|
|
public virtual Invoice? invoice { get; set; }
|
|
public virtual ICollection<Invoice> Childinvoice { get; set; }
|
|
public virtual ICollection<InvoicePayment> payments { get; set; }
|
|
public virtual ICollection<InvoiceStatusChang> invoiceStatusChangs { get; set; }
|
|
public virtual ICollection<SentTax> sentTax { get; set; }
|
|
[ForeignKey("PatternID")]
|
|
public virtual Pattern? pattern { get; set; }
|
|
[ForeignKey("CompanyID")]
|
|
public virtual Company? company { get; set; }
|
|
|
|
public object Clone()
|
|
{
|
|
return this.MemberwiseClone();
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
//asd نوعش باید long باشه نفهمیدم تو db چی بذارم |