Files
moadiran/Back/Data/Models/Invoice.cs

195 lines
8.3 KiB
C#
Raw Normal View History

2024-03-30 15:10:36 +03:30
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
2024-07-08 22:51:59 +03:30
using System.Text.Json.Serialization;
2024-03-30 15:10:36 +03:30
using Back.Common;
2024-05-01 15:42:21 +03:30
using Shared.DTOs;
2024-03-30 15:10:36 +03:30
namespace Back.Data.Models
{
2024-07-09 23:04:19 +03:30
public class Invoice : ICloneable
2024-03-30 15:10:36 +03:30
{
#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)]
2024-05-27 18:01:50 +03:30
public int? inty { get { return pattern?.BillType.inty; } }
2024-03-30 15:10:36 +03:30
//الگوی صورتحساب
[MaxLength(2)]
2024-05-12 22:02:49 +03:30
public int? inp { get { return pattern?.inp; } }
2024-03-30 15:10:36 +03:30
//شماره اقتصادی فروشنده
[MaxLength(14)]
2024-05-12 22:02:49 +03:30
public string? tins { get { return company?.EconomicCode; } }
2024-03-30 15:10:36 +03:30
//شماره اقتصادی خریدار
[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)]
2024-05-12 22:02:49 +03:30
public decimal? tbill { get {return pattern?.inp==10? torv+ tvam+ todam : invoiceDetails.Sum(i => i.tsstam);}}
2024-03-30 15:10:36 +03:30
//مجموع وزن خالص
[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)]
2024-07-08 22:51:59 +03:30
public long? cdcd { get { return string.IsNullOrEmpty(CottageDateOfCustomsDeclaration) ? null : new DateTimeOffset(CottageDateOfCustomsDeclaration.Trim().ToMiladi()).ToUnixTimeMilliseconds(); } }
2024-03-30 15:10:36 +03:30
//کد پستی خریدار
[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)]
2024-05-12 22:02:49 +03:30
public string? sbc { get { return company?.BranchID; } }
2024-03-30 15:10:36 +03:30
//مبلغ پرداختی نقدی
[MaxLength(18)]
2024-06-08 21:48:26 +03:30
public decimal? cap { get { return tbill- insp- tvam- todam; } }
2024-03-30 15:10:36 +03:30
//موضوع صورتحساب
[MaxLength(1)]
public int? ins { get { return (int)invoiceType; } }
#endregion
#region fild
public string Title { get; set; }
2024-05-13 13:02:09 +03:30
public string? Des { get; set; }
2024-03-30 15:10:36 +03:30
public InvoiceType invoiceType { get; set; }
//شماره منحصر به فرد مالیاتی
2024-05-27 18:57:25 +03:30
// [MaxLength(22)]
public string taxid { get; set; } = "";
2024-03-30 15:10:36 +03:30
//شماره منحصر به فرد مالیاتی صورتحساب مرجع
[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)]
2024-06-08 21:48:26 +03:30
public int? setm
{
get
{
return pattern.BillTypeID == 3 || pattern.BillTypeID == 4 || pattern.inp == 8
2024-03-30 15:10:36 +03:30
? 1
2024-06-08 21:48:26 +03:30
: _setm;
}
2024-03-30 15:10:36 +03:30
set { _setm = value; }
2024-06-08 21:48:26 +03:30
}
2024-03-30 15:10:36 +03:30
//مبلغ نسیه
[MaxLength(18)]
2024-05-28 15:03:08 +03:30
public decimal? insp { get; set; } = 0;
2024-03-30 15:10:36 +03:30
//مالیات موضوع ماده 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; }
2024-07-22 16:56:16 +03:30
//عیار
[MaxLength(26)]
public decimal? cui { get; set; }
//شماره اقتصادی آژانس
[MaxLength(14)]
public string? tinc { get; set; }
2024-03-30 15:10:36 +03:30
#endregion
#region Navigation
[ForeignKey("CustomerID")]
public virtual Customer Customer { get; set; }
[ForeignKey("LastChangeUserID")]
public virtual User user { get; set; }
2024-05-27 18:57:25 +03:30
public virtual ICollection<InvoiceItem> invoiceDetails { get; set; }
2024-03-30 15:10:36 +03:30
[ForeignKey("BillReference")]
public virtual Invoice? invoice { get; set; }
2024-05-27 18:57:25 +03:30
public virtual ICollection<InvoicePayment> payments { get; set; }
public virtual ICollection<InvoiceStatusChang> invoiceStatusChangs { get; set; }
public virtual ICollection<SentTax> sentTax { get; set; }
2024-05-27 18:01:50 +03:30
[ForeignKey("PatternID")]
2024-03-30 15:10:36 +03:30
public virtual Pattern? pattern { get; set; }
[ForeignKey("CompanyID")]
public virtual Company? company { get; set; }
2024-07-09 23:04:19 +03:30
public object Clone()
{
return this.MemberwiseClone();
}
2024-03-30 15:10:36 +03:30
#endregion
}
}