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

241 lines
11 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
2024-10-19 18:30:02 +03:30
2024-03-30 15:10:36 +03:30
#region autofild
2024-08-06 17:24:25 +03:30
2024-03-30 15:10:36 +03:30
//تاریخ و زمان صدور صورتحساب )میالدی(
[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-12-11 15:33:33 +03:30
public string? tins { get { return company?.EconomicCode; } }
2024-03-30 15:10:36 +03:30
//شماره اقتصادی خریدار
[MaxLength(14)]
2024-12-13 16:04:57 +03:30
public string? tinb { get { return Customer.CustomerType==CustomerType.WithoutIdentity ? null : Customer.EconomicCode; } }
2024-03-30 15:10:36 +03:30
//مجموع مبلغ قبل از کسر تخفیف
[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)]
2024-12-14 14:20:36 +03:30
public decimal? tvop { get { return Math.Floor(invoiceDetails.Sum(i => i.vop).GetValueOrDefault()); } }
2024-03-30 15:10:36 +03:30
//نوع شخص خریدار
[MaxLength(1)]
2024-12-11 15:33:33 +03:30
public int tob { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? 0 : (int)Customer.CustomerType; } }
2024-03-30 15:10:36 +03:30
//اریخ کوتاژ اظهارنامه گمرکی
// Unix Time => from fild CottageDateOfCustomsDeclaration
[MaxLength(5)]
2024-08-28 00:29:35 +03:30
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();
} }
2024-03-30 15:10:36 +03:30
//کد پستی خریدار
[MaxLength(10)]
2024-12-11 15:33:33 +03:30
public string? bpc { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.ZipCode; } }
2024-03-30 15:10:36 +03:30
//کد شعبه خریدار
[MaxLength(10)]
2024-12-11 15:33:33 +03:30
public string? bbc { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.BranchID; } }
2024-03-30 15:10:36 +03:30
//شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیرایرانی خریدار
[MaxLength(14)]
2024-12-11 15:33:33 +03:30
public string? bid { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.MeliCode; } }
2024-03-30 15:10:36 +03:30
//شماره گذرنامه خریدار
[MaxLength(9)]
2024-12-11 15:33:33 +03:30
public string? bpn { get { return Customer.CustomerType == CustomerType.WithoutIdentity ? null : Customer.PassportNumber; } }
2024-03-30 15:10:36 +03:30
//کد شعبه فروشنده
[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-08-28 00:29:35 +03:30
public decimal? cap { get {
return
2024-10-19 18:30:02 +03:30
setm == 1 ? tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault()
: setm == 2 ? 0
: tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault() - insp.GetValueOrDefault();
2024-08-28 00:29:35 +03:30
} }
2024-03-30 15:10:36 +03:30
//موضوع صورتحساب
[MaxLength(1)]
public int? ins { get { return (int)invoiceType; } }
2024-10-19 18:30:02 +03:30
public decimal Calcinsp { get { return tbill.GetValueOrDefault() - todam.GetValueOrDefault() - tvam.GetValueOrDefault(); } }
2024-03-30 15:10:36 +03:30
#endregion
#region fild
2024-08-06 17:24:25 +03:30
//سریال صورتحساب داخلی حافظه مالیاتی
[MaxLength(10)]
public string? inno { get; set; }
2024-03-30 15:10:36 +03:30
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
{
2025-01-24 19:18:17 +03:30
return pattern!=null && (pattern.BillTypeID == 3 || (pattern.BillTypeID == 2 && pattern.ID == 10))
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; }
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(14)]
public string? tinc { get; set; }
2024-12-10 17:17:17 +03:30
//شماره بارنامه
[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)]
2024-12-12 21:08:17 +03:30
public string? cno { get; set; }
2024-12-10 17:17:17 +03:30
//کد ملی/ کد فراگیر اتباع غیر ایرانی راننده) در حمل و نقل جاده ای(
[MaxLength(12)]
public string? did { get; set; }
//کالاهای حمل شده
2024-12-12 21:08:17 +03:30
//public List<ShippingGoodDto> sg { get { return new List<ShippingGoodDto>(); } }
2024-12-10 17:17:17 +03:30
//شماره اعلامیه فروش
[MaxLength(20)]
public string? asn { get; set; }
//تاریخ اعلامیه فروش
public string? DateSaleAnnouncement { get; set; }
public int? asd { get { return 0; } }
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-08-08 00:28:17 +03:30
public virtual ICollection<Invoice> Childinvoice { 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
}
}
2024-12-12 21:08:17 +03:30
//asd نوعش باید long باشه نفهمیدم تو db چی بذارم