Files
moadiran/Back/Data/Models/Invoice.cs
2024-05-12 22:02:49 +03:30

177 lines
7.8 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Back.Common;
using Shared.DTOs;
namespace Back.Data.Models
{
public class Invoice
{
#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(10)]
public string? inno { get { return ID.ToString("0000000000"); } }
//تاریخ و زمان صدور صورتحساب )میالدی(
[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.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 (int)Customer.CustomerType; } }
//اریخ کوتاژ اظهارنامه گمرکی
// Unix Time => from fild CottageDateOfCustomsDeclaration
[MaxLength(5)]
public long? cdcd { get { return new DateTimeOffset(CottageDateOfCustomsDeclaration.Trim().ToMiladi()).ToUnixTimeMilliseconds(); } }
//کد پستی خریدار
[MaxLength(10)]
public string? bpc { get { return Customer.ZipCode; } }
//کد شعبه خریدار
[MaxLength(10)]
public string? bbc { get { return Customer.BranchID; } }
//شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیرایرانی خریدار
[MaxLength(14)]
public string? bid { get { return Customer.MeliCode; } }
//شماره گذرنامه خریدار
[MaxLength(9)]
public string? bpn { get { return Customer.PassportNumber; } }
//کد شعبه فروشنده
[MaxLength(9)]
public string? sbc { get { return company?.BranchID; } }
//مبلغ پرداختی نقدی
[MaxLength(18)]
public decimal? cap { get { return insp - tvam - todam - tbill; } }
//موضوع صورتحساب
[MaxLength(1)]
public int? ins { get { return (int)invoiceType; } }
#endregion
#region fild
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 == 4 || pattern.inp==8
? 1
:_setm; }
set { _setm = value; }
}
//مبلغ نسیه
[MaxLength(18)]
public decimal? insp { get; set; }
//مالیات موضوع ماده 17
[MaxLength(18)]
public string? seventeentax { get; set; }
//نکته باید به شمسی تبدیل شود
public string? Cdate { get; set; }
//تفاوت نرخ خرید و فروش ارز/ کارمزد فروش ارز
[MaxLength(26)]
public decimal? pspd { 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; }
#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<InvoicePayment> payments { get; set; }
public virtual ICollection<InvoiceStatusChang> invoiceStatusChangs { get; set; }
public virtual ICollection<SentTax> sentTax { get; set; }
[ForeignKey("PatternsID")]
public virtual Pattern? pattern { get; set; }
[ForeignKey("CompanyID")]
public virtual Company? company { get; set; }
#endregion
}
}