diff --git a/Back/Back.csproj b/Back/Back.csproj index 9daa180..18e672f 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -7,7 +7,29 @@ + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + diff --git a/Back/Back.http b/Back/Back.http deleted file mode 100644 index c39c7af..0000000 --- a/Back/Back.http +++ /dev/null @@ -1,6 +0,0 @@ -@Back_HostAddress = http://localhost:5271 - -GET {{Back_HostAddress}}/weatherforecast/ -Accept: application/json - -### diff --git a/Back/Common/DTOs/PagingDto.cs b/Back/Common/DTOs/PagingDto.cs new file mode 100644 index 0000000..b32df4d --- /dev/null +++ b/Back/Common/DTOs/PagingDto.cs @@ -0,0 +1,16 @@ +namespace Back.Common.ViewModels +{ + public class PagingDto + { + public PagingDto(int RowCount, int pageCount, List list) + { + this.RowCount = RowCount; + this.list = list; + PageCount = pageCount; + + } + public int RowCount { get; set; } + public int PageCount { get; set; } + public List list { get; set; } + } +} diff --git a/Back/Common/Enums/CustomerType.cs b/Back/Common/Enums/CustomerType.cs new file mode 100644 index 0000000..44ad4a8 --- /dev/null +++ b/Back/Common/Enums/CustomerType.cs @@ -0,0 +1,17 @@ +using System.ComponentModel.DataAnnotations; + +namespace Back.Common.Enums +{ + public enum CustomerType:int + { + [Display(Name = "حقیقی")] + genuine = 1, + [Display(Name = "حقوقی")] + legal = 2, + [Display(Name = "مشارکت مدنی")] + CivilPartnership = 3, + [Display(Name = "اتباع عیر ایرانی")] + NonIranianNationals = 4 + + } +} diff --git a/Back/Common/Enums/InvoiceType.cs b/Back/Common/Enums/InvoiceType.cs new file mode 100644 index 0000000..9f12752 --- /dev/null +++ b/Back/Common/Enums/InvoiceType.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations; + +namespace Back.Common.Enums +{ + public enum InvoiceType:int + { + [Display(Name = "پیشنهاد قیمت")] + Bidding=10, + //[Display(Name = "فاکتور")] + //Factor=11, + //[Display(Name = "قطعی")] + //Final=12, + [Display(Name = "لغو")] + CANCEL = 0, + [Display(Name = "فروش")] + Sale=1, + [Display(Name = "ابطالی")] + Cancellation=3, + [Display(Name = "اصلاحی")] + Repair=2, + [Display(Name = "برگشت از فروش")] + BackFrmSale = 4 + + } +} diff --git a/Back/Common/Enums/SentStatus.cs b/Back/Common/Enums/SentStatus.cs new file mode 100644 index 0000000..7245c92 --- /dev/null +++ b/Back/Common/Enums/SentStatus.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations; +namespace Back.Common.Enums +{ + public enum SentStatus + { + + [Display(Name = "ارسال شده")] + Send, + [Display(Name = "موفق")] + Successful, + [Display(Name = "ناموفق")] + Unsuccessful, + [Display(Name = "در حال پردازش")] + pending, + [Display(Name = "نامشخص")] + Unknown, + [Display(Name = "یافت نشده")] + NOT_FOUND + +} +} diff --git a/Back/Common/Enums/SideType.cs b/Back/Common/Enums/SideType.cs new file mode 100644 index 0000000..ba41583 --- /dev/null +++ b/Back/Common/Enums/SideType.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations; + +namespace Back.Common.Enums +{ + public enum SideType + { + [Display(Name = "مشتری")] + Customer, + [Display(Name = "کارشناس")] + Expert + } +} diff --git a/Back/Common/Enums/StatusOrder.cs b/Back/Common/Enums/StatusOrder.cs new file mode 100644 index 0000000..c3d6729 --- /dev/null +++ b/Back/Common/Enums/StatusOrder.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; + +namespace Back.Common.Enums +{ + public enum StatusOrder + { + [Display(Name = "ساخته شده")] + Create, + [Display(Name = "پرداخت شده")] + Paid, + [Display(Name = "انصراف داده شده")] + Cancel + } +} diff --git a/Back/Common/Enums/StatusTicket.cs b/Back/Common/Enums/StatusTicket.cs new file mode 100644 index 0000000..d47e8e9 --- /dev/null +++ b/Back/Common/Enums/StatusTicket.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations; +using static Back.Common.ExclusiveAttribute; + +namespace Back.Common.Enums +{ + public enum StatusTicket + { + + [Color("00FF23")] + [Display(Name = "فرد ناشناس")] + unknownPerson, + [Color("8844A3")] + [Display(Name = "در انتظار بررسی")] + Awaitingreview, + [Color("2CAFE8")] + [Display(Name = "خوانده شده/ در حال بررسی")] + Read_Checking, + [Color("4AB621")] + [Display(Name = "پاسخ داده شده")] + hasbeenanswered, + [Color("37363E")] + [Display(Name = "پاِیان")] + End, + [Color("D24249")] + [Display(Name = "انصراف")] + optout, + } +} diff --git a/Back/Common/ExclusiveAttribute.cs b/Back/Common/ExclusiveAttribute.cs new file mode 100644 index 0000000..7c1590e --- /dev/null +++ b/Back/Common/ExclusiveAttribute.cs @@ -0,0 +1,13 @@ +namespace Back.Common +{ + public class ExclusiveAttribute + { + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Class, + AllowMultiple = false)] + public class ColorAttribute : Attribute + { + public string _ColorHex; + public ColorAttribute(string ColorHex) => _ColorHex = ColorHex; + } + } +} diff --git a/Back/Common/ExtentionMethods.cs b/Back/Common/ExtentionMethods.cs new file mode 100644 index 0000000..8d0b57e --- /dev/null +++ b/Back/Common/ExtentionMethods.cs @@ -0,0 +1,93 @@ +using Microsoft.EntityFrameworkCore; +using static Back.Common.ExclusiveAttribute; +using System.ComponentModel.DataAnnotations; +using System.Data; +using System.Globalization; +using System.Reflection; +using System.Security.Cryptography; +using Back.Common.ViewModels; + +namespace Back.Common +{ + public static class ExtentionMethods + { + public static string GetEnumDisplayName(this Enum enumType) + { + return enumType.GetType().GetMember(enumType.ToString()) + .First() + .GetCustomAttribute() + .Name; + } + public static string GetEnumHexColor(this Enum enumType) + { + return enumType.GetType().GetMember(enumType.ToString()) + .First() + .GetCustomAttribute() + ._ColorHex; + } + public static string encrypted(this string txt) + { + HashAlgorithm hash = new MD5CryptoServiceProvider(); + var bytes = System.Text.Encoding.UTF8.GetBytes(txt); + var hashedBytes = hash.ComputeHash(bytes); + + string res = BitConverter.ToString(hashedBytes).Replace("-", string.Empty); + return res; + } + public static string ConvertMiladiToShamsi(this DateTime date) + { + PersianCalendar PersianCal = new PersianCalendar(); + return PersianCal.GetYear(date).ToString("0000") + + PersianCal.GetMonth(date).ToString("00") + + PersianCal.GetDayOfMonth(date).ToString("00"); + } + public static string ShamciToFormatShamci(this string str) + { + if (string.IsNullOrEmpty(str)) return ""; + return str.Substring(0, 4) + "/" + str.Substring(4, 2) + "/" + str.Substring(6, 2); + } + public static DateTime ToMiladi(this string value) + { + PersianCalendar p = new PersianCalendar(); + return p.ToDateTime(Convert.ToInt32(value.Substring(0, 4)), Convert.ToInt32(value.Substring(4, 2)), Convert.ToInt32(value.Substring(6, 2)), 0, 0, 0, 0); + } + public static async Task> Paging(this IQueryable values, int pageId, int take) + { + if (/*values.Count()<1000 && */pageId == 0 && take == 0) + { + return new PagingDto(values.Count(), 1, await values.ToListAsync()); + } + else + { + int skip = (pageId - 1) * take; + int rowCount = values.Count(); + int PageCount = rowCount % take == 0 ? rowCount / take : rowCount / take + 1; + return new PagingDto(rowCount, PageCount, await values.Skip(skip).Take(take).ToListAsync()); + } + + } + public static System.Linq.Expressions.Expression> GetFunc(string Fild, string Value) + { + Type type = typeof(TEntity); + // System.Linq.Expressions.Expression> convert = s => type.GetProperty(Fild) != null && s.GetType().GetProperty(Fild).GetValue(s) == Value; + return Entity => type.GetProperty(Fild) != null && Entity.GetType().GetProperty(Fild).GetValue(Entity) == Value; + } + public static DataTable ConvertStringBase64toDataTable(this string value, string SheetName = null) + { + //try + //{ + // MemoryStream stream1 = new MemoryStream(Convert.FromBase64String(value)); + // WorkBook workbook = WorkBook.Load(stream1); + + // WorkSheet sheet = SheetName == null ? workbook.DefaultWorkSheet : workbook.GetWorkSheet(SheetName); + + // return sheet.ToDataTable(true); + //} + //catch (Exception) + //{ + return new DataTable(); + // } + + } + } +} diff --git a/Back/Controllers/BaseController.cs b/Back/Controllers/BaseController.cs new file mode 100644 index 0000000..f96497c --- /dev/null +++ b/Back/Controllers/BaseController.cs @@ -0,0 +1,22 @@ +using Back.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Shared.DTOs; + +namespace Back.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class BaseController : ControllerBase + { + private readonly ServBase _sBase; + public BaseController(ServBase sBase) + { + _sBase = sBase; + } + [HttpGet("BasePrice")] + public async Task>> GetBasePrice() + => Ok(await _sBase.GetBasePrice()); + + } +} diff --git a/Back/Controllers/WeatherForecastController.cs b/Back/Controllers/WeatherForecastController.cs deleted file mode 100644 index 7975bcd..0000000 --- a/Back/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace Back.Controllers -{ - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} diff --git a/Back/Data/Contracts/IAsyncRepository.cs b/Back/Data/Contracts/IAsyncRepository.cs new file mode 100644 index 0000000..1d82436 --- /dev/null +++ b/Back/Data/Contracts/IAsyncRepository.cs @@ -0,0 +1,39 @@ +using Microsoft.Data.SqlClient; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace Back.Data.Contracts +{ + public interface IAsyncRepository + { + IQueryable GetAll(); + IQueryable Get(Expression> predicate); + IQueryable Get(Expression> predicate = null, + Func, IOrderedQueryable> orderBy = null, + string[] includeSrings = null, + bool disableTracking = true); + + IQueryable Get(Expression> predicate = null, + Func, IOrderedQueryable> orderBy = null, + List>> includes = null, + bool disableTracking = true); + Task AddRangeAsync(ICollection entites); + Task AddAsync(T entity); + T? Add(T entity); + Task AddBoolResultAsync(T entity); + bool AddBoolResult(T entity); + Task UpdateAsync(T entity); + bool Update(T entity); + Task UpdateRangeAsync(ICollection entites); + bool UpdateRange(ICollection entites); + bool Delete(T entity); + Task DeleteRangeAsync(ICollection entites); + Task DeleteAsync(T entity); + Task> RunSP(string query, List parameters); + Task ExecuteSql(string query); + } +} diff --git a/Back/Data/Infrastructure/Persistence/SqlDbContext.cs b/Back/Data/Infrastructure/Persistence/SqlDbContext.cs new file mode 100644 index 0000000..ad81e8b --- /dev/null +++ b/Back/Data/Infrastructure/Persistence/SqlDbContext.cs @@ -0,0 +1,67 @@ +using Microsoft.EntityFrameworkCore; +using Back.Data.Models; + +namespace TaxPayer.Infrastructure.Persistence +{ + public class SqlDbContext : DbContext + { + public SqlDbContext(DbContextOptions options) : base(options) + { + } + #region Table + public DbSet BillTypes { get; set; } + public DbSet Filds { get; set; } + public DbSet FildModes { get; set; } + public DbSet FildModeInPattern { get; set; } + public DbSet Patterns { get; set; } + public DbSet Codings { get; set; } + public DbSet SpecialConditions { get; set; } + public DbSet Companies { get; set; } + public DbSet Users { get; set; } + public DbSet CalculationTypes { get; set; } + public DbSet Permissions { get; set; } + public DbSet PermissionPeriods { get; set; } + public DbSet RolUsers { get; set; } + public DbSet Customers { get; set; } + public DbSet CODUnits { get; set; } + public DbSet CODItems { get; set; } + public DbSet Invoices { get; set; } + public DbSet InvoiceItems { get; set; } + public DbSet InvoicePayments { get; set; } + public DbSet PermissionUsers { get; set; } + public DbSet InvoiceStatusChangs { get; set; } + public DbSet VerificationCodes { get; set; } + public DbSet Pricing { get; set; } + public DbSet Orders { get; set; } + public DbSet OrderItems { get; set; } + public DbSet Notifications { get; set; } + public DbSet Questions { get; set; } + public DbSet QuestionCategories { get; set; } + public DbSet Blogs { get; set; } + public DbSet Tickets { get; set; } + public DbSet SubTickets { get; set; } + public DbSet OrderDiscountCodes { get; set; } + public DbSet TiceketUnknownPeoples { get; set; } + public DbSet SaleLeads { get; set; } + #endregion + //public override Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()) + //{ + // foreach (var entry in ChangeTracker.Entries()) + // { + // switch (entry.State) + // { + // case EntityState.Added: + // entry.Entity.CreateDate = ""; + // entry.Entity.CreatedBy = "mohammad"; + // break; + // case EntityState.Modified: + // entry.Entity.ModifiedDate = ""; + // entry.Entity.LastModifiedBy = "mohammad"; + // break; + // } + // } + + // return base.SaveChangesAsync(cancellationToken); + //} + } +} diff --git a/Back/Data/Infrastructure/Repository/RepositoryBase.cs b/Back/Data/Infrastructure/Repository/RepositoryBase.cs new file mode 100644 index 0000000..4776475 --- /dev/null +++ b/Back/Data/Infrastructure/Repository/RepositoryBase.cs @@ -0,0 +1,235 @@ +using Back.Data.Contracts; +using Back.Data.Contracts; +using Microsoft.Data.SqlClient; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using TaxPayer.Infrastructure.Persistence; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; + +namespace Back.Data.Infrastructure.Repository +{ + public class RepositoryBase : IAsyncRepository where T : class + { + protected readonly SqlDbContext _dbContext; + private DbSet _query; + public RepositoryBase(SqlDbContext dbContext) + { + _dbContext = dbContext; + _query = _dbContext.Set(); + } + public IQueryable GetAll() + { + return _query.AsQueryable(); + } + public IQueryable Get(Expression> predicate) + { + var query = _query.AsQueryable(); + query = query.AsNoTracking(); + return query.Where(predicate).AsQueryable(); + } + + public IQueryable Get( + Expression> predicate = null, + Func, IOrderedQueryable> orderBy = null, + string[] includeStrings = null, + bool disableTracking = true) + { + var query = _query.AsQueryable(); + + if (disableTracking) query = query.AsNoTracking(); + if (includeStrings != null) + { + foreach (var includeString in includeStrings) + if (!string.IsNullOrWhiteSpace(includeString)) query = query.Include(includeString); + } + + + if (predicate != null) query = query.Where(predicate); + + if (orderBy != null) + return orderBy(query).AsQueryable(); + + return query.AsQueryable(); + } + + public IQueryable Get( + Expression> predicate = null, + Func, IOrderedQueryable> orderBy = null, + List>> includes = null, + bool disableTracking = true) + { + var query = _query.AsQueryable(); + + if (disableTracking) query = query.AsNoTracking(); + + if (includes != null) query = includes.Aggregate(query, (current, include) => current.Include(include)); + + if (predicate != null) query = query.Where(predicate); + + if (orderBy != null) + return orderBy(query).AsQueryable(); + + return query.AsQueryable(); + } + + public async Task AddAsync(T entity) + { + await _query.AddAsync(entity); + await _dbContext.SaveChangesAsync(); + return entity; + } + public T? Add(T entity) + { + _query.Add(entity); + var res = _dbContext.SaveChanges(); + return res > 0 ? entity : null; + //await _dbContext.SaveChangesAsync(); + //return entity; + } + public async Task AddRangeAsync(ICollection entites) + { + try + { + await _query.AddRangeAsync(entites); + await _dbContext.SaveChangesAsync(); + return true; + } + catch (Exception) + { + return false; + } + } + public async Task UpdateAsync(T entity) + { + try + { + + _dbContext.Entry(entity).State = EntityState.Modified; + var result = await _dbContext.SaveChangesAsync(); + return result > 0; + } + catch (Exception) + { + return false; + throw; + } + + } + public bool Update(T entity) + { + try + { + _dbContext.Update(entity); + var result = _dbContext.SaveChanges(); + return result > 0; + } + catch (Exception) + { + return false; + } + + } + public async Task DeleteAsync(T entity) + { + try + { + _query.Remove(entity); + var res = await _dbContext.SaveChangesAsync(); + return res > 0; + } + catch (Exception) + { + return false; + } + + } + public async Task DeleteRangeAsync(ICollection entites) + { + try + { + _query.RemoveRange(entites); + var res = await _dbContext.SaveChangesAsync(); + return res > 0; + } + catch (Exception) + { + return false; + } + + } + public async Task> RunSP(string query, List parameters) + { + await _dbContext.Database.ExecuteSqlRawAsync(query, parameters); + return parameters; + } + public async Task ExecuteSql(string query) + { + await _dbContext.Database.ExecuteSqlRawAsync(query); + } + public bool Delete(T entity) + { + _query.Remove(entity); + var res = _dbContext.SaveChanges(); + return res > 0; + } + public async Task AddBoolResultAsync(T entity) + { + int a = 0; + await _query.AddAsync(entity); + try + { + a = await _dbContext.SaveChangesAsync(); + } + catch (Exception) + { + + throw; + } + + return a > 0; + } + public bool AddBoolResult(T entity) + { + _query.Add(entity); + var res = _dbContext.SaveChanges(); + return res > 0; + } + public async Task UpdateRangeAsync(ICollection entites) + { + try + { + //_dbContext.Entry(entites).State = EntityState.Modified; + _dbContext.UpdateRange(entites); + var result = await _dbContext.SaveChangesAsync(); + return result > 0; + } + catch (Exception) + { + return false; + throw; + } + } + public bool UpdateRange(ICollection entites) + { + try + { + _dbContext.UpdateRange(entites); + var result = _dbContext.SaveChanges(); + return result > 0; + } + catch (Exception) + { + return false; + } + } + } +} +//Sample Inclucde List +//new List>> +// { x => x.System } \ No newline at end of file diff --git a/Back/Data/Models/BillType.cs b/Back/Data/Models/BillType.cs new file mode 100644 index 0000000..e43fde7 --- /dev/null +++ b/Back/Data/Models/BillType.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class BillType + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ID { get; set; } + public int inty { get; set; } + public string Title { get; set; } + public string Dec { get; set; } + + + #region Navigation + public virtual ICollection Patterns { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Blog.cs b/Back/Data/Models/Blog.cs new file mode 100644 index 0000000..e0cd55c --- /dev/null +++ b/Back/Data/Models/Blog.cs @@ -0,0 +1,13 @@ +namespace Back.Data.Models +{ + public class Blog + { + public int ID { get; set; } + public string Title { get; set; } + public string Text { get; set; } + public byte[]? Photo { get; set; } + public string Date { get; set; } + public string Time { get; set; } + public bool Status { get; set; } + } +} diff --git a/Back/Data/Models/CODItem.cs b/Back/Data/Models/CODItem.cs new file mode 100644 index 0000000..4fcaa39 --- /dev/null +++ b/Back/Data/Models/CODItem.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class CODItem + { + public int ID { get; set; } + public int UnitID { get; set; } + [MaxLength(13)] + public string? ItemTaxID { get; set; } + public int CompanyID { get; set; } + public string Title { get; set; } + public int TaxRate { get; set; } + public bool IsDeleted { get; set; } + + + #region Navigation + [ForeignKey("UnitID")] + public virtual CODUnit CODUnit { get; set; } + [ForeignKey("CompanyID")] + public virtual Company Company { get; set; } + public virtual ICollection invoiceDetails { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/CODUnit.cs b/Back/Data/Models/CODUnit.cs new file mode 100644 index 0000000..c191eea --- /dev/null +++ b/Back/Data/Models/CODUnit.cs @@ -0,0 +1,17 @@ +using System.ComponentModel.DataAnnotations; + +namespace Back.Data.Models +{ + public class CODUnit + { + + public int ID { get; set; } + [MaxLength(8)] + public string? UnitTaxID { get; set; } + public string Title { get; set; } + + #region Navigation + public virtual ICollection CODItemS { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/CalculationType.cs b/Back/Data/Models/CalculationType.cs new file mode 100644 index 0000000..7274e57 --- /dev/null +++ b/Back/Data/Models/CalculationType.cs @@ -0,0 +1,15 @@ +namespace Back.Data.Models +{ + public class CalculationType + { + public int ID { get; set; } + public string Name { get; set; } + public string Title { get; set; } + #region Navigation + public virtual ICollection permissionPeriods { get; set; } + #endregion + + } + //a number + //unlimited +} diff --git a/Back/Data/Models/Coding.cs b/Back/Data/Models/Coding.cs new file mode 100644 index 0000000..f928109 --- /dev/null +++ b/Back/Data/Models/Coding.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + [PrimaryKey("FildID", "Code")] + public class Coding + { + public int FildID { get; set; } + [Column(TypeName = "varchar(10)")] + public string Code { get; set; } + public string Title { get; set; } + #region Navigation + + [ForeignKey("FildID")] + public virtual Fild Fild { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Company.cs b/Back/Data/Models/Company.cs new file mode 100644 index 0000000..02b98fd --- /dev/null +++ b/Back/Data/Models/Company.cs @@ -0,0 +1,26 @@ +namespace Back.Data.Models +{ + public class Company + { + public int ID { get; set; } + public string Name { get; set; } + public string? Email { get; set; } + public string? Phone { get; set; } + public string Mobile { get; set; } + public string? BranchID { get; set; } + public string? EconomicCode { get; set; } + public string? UniqeMemory { get; set; } + public string? PrivateKey { get; set; } + public byte[]? Logo { get; set; } + public string RegisterDate { get; set; } + public bool IsActive { get; set; } + + #region Navigation + public virtual ICollection CODItemS { get; set; } + public virtual ICollection RolUsers { get; set; } + public virtual ICollection PermissionPeriods { get; set; } + public virtual ICollection Customers { get; set; } + public virtual ICollection invoices { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Customer.cs b/Back/Data/Models/Customer.cs new file mode 100644 index 0000000..26991c2 --- /dev/null +++ b/Back/Data/Models/Customer.cs @@ -0,0 +1,35 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Back.Common.Enums; +namespace Back.Data.Models +{ + + public class Customer + { + public int ID { get; set; } + public CustomerType CustomerType { get; set; } + public string FullName { get; set; } + public string? EconomicCode { get; set; } + public string? Phone { get; set; } + public string? Email { get; set; } + public string? Address { get; set; } + public string? Info { get; set; } + public int CompanyID { get; set; } + [MaxLength(10)] + public string? ZipCode { get; set; } + [MaxLength(10)] + public string? BranchID { get; set; } + [MaxLength(14)] + public string? MeliCode { get; set; } + [MaxLength(9)] + public string? PassportNumber { get; set; } + public bool IsDeleted { get; set; } + + #region Navigation + + [ForeignKey("CompanyID")] + public virtual Company Company { get; set; } + + #endregion + } +} diff --git a/Back/Data/Models/Fild.cs b/Back/Data/Models/Fild.cs new file mode 100644 index 0000000..139d6c4 --- /dev/null +++ b/Back/Data/Models/Fild.cs @@ -0,0 +1,24 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class Fild + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ID { get; set; } + public string Name { get; set; } + public string Type { get; set; } + public string Title { get; set; } + public string InputBox { get; set; } + + #region Navigation + public virtual ICollection FildModeInPatterns { get; set; } + public virtual ICollection Codings { get; set; } + [NotMapped] + public ICollection specialConditions { get; set; } + #endregion + + } +} diff --git a/Back/Data/Models/FildMode.cs b/Back/Data/Models/FildMode.cs new file mode 100644 index 0000000..638c4d6 --- /dev/null +++ b/Back/Data/Models/FildMode.cs @@ -0,0 +1,18 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class FildMode + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ID { get; set; } + public string Name { get; set; } + public string Title { get; set; } + + #region Navigation + public virtual ICollection FildModeInPatterns { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/FildModeInPattern.cs b/Back/Data/Models/FildModeInPattern.cs new file mode 100644 index 0000000..dd5add9 --- /dev/null +++ b/Back/Data/Models/FildModeInPattern.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + [PrimaryKey("FildID", "PatternID", "FildModeID")] + public class FildModeInPattern + { + + public int FildID { get; set; } + public int PatternID { get; set; } + public int FildModeID { get; set; } + + #region Navigation + + [ForeignKey("FildID")] + public virtual Fild Fild { get; set; } + + [ForeignKey("PatternID")] + public virtual Pattern pattern { get; set; } + + [ForeignKey("FildModeID")] + public virtual FildMode FildMode { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Invoice.cs b/Back/Data/Models/Invoice.cs new file mode 100644 index 0000000..de0cae7 --- /dev/null +++ b/Back/Data/Models/Invoice.cs @@ -0,0 +1,176 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Back.Common; +using Back.Common.Enums; +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 invoiceDetails { get; set; } + [ForeignKey("BillReference")] + public virtual Invoice? invoice { get; set; } + public virtual ICollection payments { get; set; } + public virtual ICollection invoiceStatusChangs { get; set; } + public virtual ICollection sentTax { get; set; } + [ForeignKey("PatternsID")] + public virtual Pattern? pattern { get; set; } + [ForeignKey("CompanyID")] + public virtual Company? company { get; set; } + #endregion + } + +} diff --git a/Back/Data/Models/InvoiceItem.cs b/Back/Data/Models/InvoiceItem.cs new file mode 100644 index 0000000..37081e4 --- /dev/null +++ b/Back/Data/Models/InvoiceItem.cs @@ -0,0 +1,135 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class InvoiceItem + { + #region Key + public int ID { get; set; } + public int CODID { get; set; } + public int? InvoiceID { get; set; } + #endregion + + #region autofild + //شناسه کاال/خدمت + [MaxLength(13)] + // [DatabaseGenerated(DatabaseGeneratedOption.None)] + public string? sstid { get { return cODItem.ItemTaxID; } } + // شرح کاال/خدمت + [MaxLength(13)] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public string? sstt { get { return cODItem.Title; } } + //واحد اندازهگیری + [MaxLength(8)] + public string? mu { get { return cODItem.CODUnit.UnitTaxID; } } + //میزان ارز + [MaxLength(18)] + public decimal? cfee { get { return fee / exr; } } + //مبلغ مالیات بر ارزش افزوده + [MaxLength(18)] + public decimal? vam { get + { + return invoice.pattern.inp == 9 ? fee*vra/100 : + invoice.pattern.inp == 13 ? ((tcpbs+9)/100)+((prdis*vra)/100) + : vra * adis / 100; + } } + //جمع کل اجرت ،حق العمل و سود + [MaxLength(18)] + public decimal? tcpbs { get { return consfee + spro + bros; } } + //سهم نقدی از پرداخت + [MaxLength(18)] + public decimal? cop { get { return (tsstam * invoice.cap) / invoice.tadis; } } + //سهم مالیات بر ارزش افزوده از پرداخت + [MaxLength(18)] + public decimal? vop { get { return vra == 0 ? 0 : (vam * invoice.cap) / invoice.tadis; } } + //مبلغ کل کالا/خدمت + [MaxLength(18)] + public decimal? tsstam { get + { + return invoice.pattern.inp == 9 ? fee+vam : + invoice.pattern.inp == 10 ? sscv + vam + odam + olam : + invoice.pattern.inp == 4 ? prdis + vam + odam + olam : + vam + adis + odam + olam; + } } + //مبلغ بعد از تخفیف + [MaxLength(18)] + public decimal? adis { get + { + return invoice.pattern.inp == 13 ? prdis+ tcpbs - dis: prdis - dis; + } } + //مبلغ قبل از تخفیف + [MaxLength(18)] + public decimal? prdis { get { return am * fee; } } + //نرخ مالیات بر ازش افزوده + [MaxLength(5)] + public decimal? vra { get { return cODItem.TaxRate; } } + #endregion + + #region fild + //تعداد/مقدار + [MaxLength(36)] + public decimal? am { get; set; } + //وزن خالص + [MaxLength(23)] + public decimal? nw { get; set; } + //مبلغ واحد + [MaxLength(36)] + public decimal? fee { get; set; } + //نوع ارز + [MaxLength(4)] + public string? cut { get; set; } + //نرخ برابری ارز با ریال + [MaxLength(18)] + public decimal? exr { get; set; } + //ارزش ریالی کالا + [MaxLength(18)] + public decimal? ssrv { get; set; } + //ارزش ارزی کالا + [MaxLength(18)] + public decimal? sscv { get; set; } + //مبلغ تخفیف + [MaxLength(18)] + public decimal? dis { get; set; } + //موضوع سایر مالیات و عوارض + [MaxLength(255)] + public string? odt { get; set; } + //نرخ سایرمالیات و عوارض + [MaxLength(5)] + public decimal? odr { get; set; } + //مبلغ سایر مالیات و عواض + [MaxLength(18)] + public decimal? odam { get; set; } + //موضوع سایر وجوه قانونی + [MaxLength(255)] + public string? olt { get; set; } + //نرخ سایروجوه قانونی + [MaxLength(5)] + public decimal? olr { get; set; } + //مبلغ سایر وجوه قانونی + [MaxLength(18)] + public decimal? olam { get; set; } + //اجرت دساخت + [MaxLength(18)] + public decimal? consfee { get; set; } + //سود فروشنده + [MaxLength(18)] + public decimal? spro { get; set; } + //حق العمل + [MaxLength(18)] + public decimal? bros { get; set; } + //شناسه یکتای ثبت قرارداد حق العمل کاری + [MaxLength(12)] + public string? bsrn { get; set; } + #endregion + + #region Navigation + [ForeignKey("InvoiceID")] + public virtual Invoice? invoice { get; set; } + + [ForeignKey("CODID")] + public virtual CODItem cODItem { get; set; } + #endregion + + } +} diff --git a/Back/Data/Models/InvoicePayment.cs b/Back/Data/Models/InvoicePayment.cs new file mode 100644 index 0000000..2ba584c --- /dev/null +++ b/Back/Data/Models/InvoicePayment.cs @@ -0,0 +1,53 @@ +using Back.Common; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class InvoicePayment + { + #region Key + public int ID { get; set; } + public int InvoiceID { get; set; } + #endregion + + #region autofild + //تاریخ و زمان پرداخت + [MaxLength(13)] + public long? pdt { get { return new DateTimeOffset(PaymentDateTime.Trim().ToMiladi()).ToUnixTimeMilliseconds(); } } + #endregion + + #region fild + //شماره سوییچ پرداخت + [MaxLength(9)] + public string? iinn { get; set; } + //شماره پذیرنده فروشگاهی + [MaxLength(14)] + public string? acn { get; set; } + //شماره پایانه + [MaxLength(8)] + public string? trmn { get; set; } + //روش پرداخت + [MaxLength(2)] + public int? pmt { get; set; } + //شماره پیگیری/شماره مرجع + [MaxLength(14)] + public string? trn { get; set; } + //شماره کارت پرداخت کننده صورتحساب + [MaxLength(16)] + public string? pcn { get; set; } + //شماره/شناسه ملی/کد فراگیر اتباع غیر ایرانی پرداخت کننده صورتحساب + [MaxLength(12)] + public string? pid { get; set; } + public string PaymentDateTime { get; set; } + //مبلغ پرداختی + [MaxLength(18)] + public long? pv { get; set; } + #endregion + + #region Navigation + [ForeignKey("InvoiceID")] + public virtual Invoice invoice { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/InvoiceStatusChang.cs b/Back/Data/Models/InvoiceStatusChang.cs new file mode 100644 index 0000000..4c44f43 --- /dev/null +++ b/Back/Data/Models/InvoiceStatusChang.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class InvoiceStatusChang + { + public int ID { get; set; } + public int? InvoiceID { get; set; } + public string FromStatus { get; set; } + public string ToStatus { get; set; } + public string Date { get; set; } + public int? UserID { get; set; } + + #region Navigation + [ForeignKey("UserID")] + public virtual User? user { get; set; } + [ForeignKey("InvoiceID")] + public virtual Invoice? invoice { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Mongodb/SystemLog.cs b/Back/Data/Models/Mongodb/SystemLog.cs new file mode 100644 index 0000000..0876eeb --- /dev/null +++ b/Back/Data/Models/Mongodb/SystemLog.cs @@ -0,0 +1,12 @@ +namespace TaxPayer.Models.Mongodb +{ + public class SystemLog + { + public string TraceIdentifierID { get; set; } + public string Datetime { get; set; } + public string Route { get; set; } + public string Method { get; set; } + public string Type { get; set; } + public string Value { get; set; } + } +} diff --git a/Back/Data/Models/Notification.cs b/Back/Data/Models/Notification.cs new file mode 100644 index 0000000..07cffc5 --- /dev/null +++ b/Back/Data/Models/Notification.cs @@ -0,0 +1,13 @@ +namespace Back.Data.Models +{ + public class Notification + { + public int ID { get; set; } + public int Type { get; set; } + public string Message { get; set; } + public string? Path { get; set; } + public string? ViewSize { get; set; } + public string Date { get; set; } + public bool Status { get; set; } + } +} diff --git a/Back/Data/Models/Order.cs b/Back/Data/Models/Order.cs new file mode 100644 index 0000000..8093bb3 --- /dev/null +++ b/Back/Data/Models/Order.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations.Schema; +using Back.Common.Enums; +namespace Back.Data.Models +{ + + public class Order + { + public int ID { get; set; } + public int CompanyID { get; set; } + public int UserID { get; set; } + public StatusOrder Status { get; set; } + public string DateCreate { get; set; } + public string ApprovalDate { get; set; } + public decimal PreDiscount { get { return OrderItems.Sum(s => s.Total); } } + public decimal TDiscount { get; set; } = 0; + public decimal TPrice { get { return OrderItems.Sum(s => s.Total) - TDiscount; } } + + #region Navigation + [ForeignKey("CompanyID")] + public virtual Company Company { get; set; } + [ForeignKey("UserID")] + public virtual User User { get; set; } + public virtual ICollection OrderItems { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/OrderDiscountCode.cs b/Back/Data/Models/OrderDiscountCode.cs new file mode 100644 index 0000000..af89033 --- /dev/null +++ b/Back/Data/Models/OrderDiscountCode.cs @@ -0,0 +1,10 @@ +namespace Back.Data.Models +{ + public class OrderDiscountCode + { + public int ID { get; set; } + public int Code { get; set; } + public int Val { get; set; } + public bool Status { get; set; } + } +} diff --git a/Back/Data/Models/OrderItem.cs b/Back/Data/Models/OrderItem.cs new file mode 100644 index 0000000..43e7058 --- /dev/null +++ b/Back/Data/Models/OrderItem.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class OrderItem + { + public int ID { get; set; } + public int OrderID { get; set; } + public int PermissionID { get; set; } + public int CalculationTypeID { get; set; } + public int CreditAmount { get; set; } + public decimal APrice { get; set; } + public decimal Discount { get; set; } + public decimal Tax { get; set; } + public decimal Total { get { return (CreditAmount * APrice) - Discount + Tax; } } + + #region Navigation + [ForeignKey("OrderID")] + public virtual Order Order { get; set; } + [ForeignKey("PermissionID")] + public virtual Permission Permission { get; set; } + [ForeignKey("CalculationTypeID")] + public virtual CalculationType CalculationType { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Pattern.cs b/Back/Data/Models/Pattern.cs new file mode 100644 index 0000000..0c75e2d --- /dev/null +++ b/Back/Data/Models/Pattern.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class Pattern + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ID { get; set; } + public int inp { get; set; } + public int BillTypeID { get; set; } + public string Title { get; set; } + public string Dec { get; set; } + public bool Status { get; set; } + #region Navigation + public virtual BillType BillType { get; set; } + public virtual ICollection FildModeInPatterns { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Permission.cs b/Back/Data/Models/Permission.cs new file mode 100644 index 0000000..834e3fe --- /dev/null +++ b/Back/Data/Models/Permission.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class Permission + { + public int ID { get; set; } + public int ParentID { get; set; } + public string Title { get; set; } + + #region Navigation + public virtual ICollection RolUsers { get; set; } + + + #endregion + + + } +} diff --git a/Back/Data/Models/PermissionPeriod.cs b/Back/Data/Models/PermissionPeriod.cs new file mode 100644 index 0000000..6ed5cb6 --- /dev/null +++ b/Back/Data/Models/PermissionPeriod.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + [PrimaryKey("CompanyID", "PermissionID", "CalculationTypeID")] + public class PermissionPeriod + { + public int CompanyID { get; set; } + public int PermissionID { get; set; } + public int TotalAmount { get; set; } + public int RemainingAmount { get; set; } + public int CalculationTypeID { get; set; } + public bool? IsLocked { get; set; } + + #region Navigation + [ForeignKey("CompanyID")] + public virtual Company Company { get; set; } + [ForeignKey("PermissionID")] + public virtual Permission Permission { get; set; } + [ForeignKey("CalculationTypeID")] + public virtual CalculationType CalculationType { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/PermissionUser.cs b/Back/Data/Models/PermissionUser.cs new file mode 100644 index 0000000..71bfad3 --- /dev/null +++ b/Back/Data/Models/PermissionUser.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + [PrimaryKey("PermissionID", "RolUserID")] + public class PermissionUser + { + public int PermissionID { get; set; } + public int RolUserID { get; set; } + + #region Navigation + [ForeignKey("RolUserID")] + public virtual RolUser RolUser { get; set; } + [ForeignKey("PermissionID")] + public virtual Permission Permission { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Pricing.cs b/Back/Data/Models/Pricing.cs new file mode 100644 index 0000000..ab8c49f --- /dev/null +++ b/Back/Data/Models/Pricing.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + // قیمت گداری + public class Pricing + { + public int ID { get; set; } + public int PermissionID { get; set; } + public int CalculationTypeID { get; set; } + public decimal Price { get; set; } + + #region Navigation + + [ForeignKey("PermissionID")] + public virtual Permission Permission { get; set; } + [ForeignKey("CalculationTypeID")] + public virtual CalculationType CalculationType { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/Question.cs b/Back/Data/Models/Question.cs new file mode 100644 index 0000000..6787150 --- /dev/null +++ b/Back/Data/Models/Question.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class QuestionCategory + { + public int ID { get; set; } + public string Title { get; set; } + + #region Navigation + public virtual ICollection questions { get; set; } + #endregion + } + public class Question + { + public int ID { get; set; } + public int QuestionCategoryID { get; set; } + public string Title { get; set; } + public string Answer { get; set; } + public bool Status { get; set; } + + #region Navigation + [ForeignKey("QuestionCategoryID")] + public virtual QuestionCategory questionCategory { get; set; } + #endregion + + } +} diff --git a/Back/Data/Models/RolUser.cs b/Back/Data/Models/RolUser.cs new file mode 100644 index 0000000..eef4582 --- /dev/null +++ b/Back/Data/Models/RolUser.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + + public class RolUser + { + public int ID { get; set; } + public int UserID { get; set; } + public int CompanyID { get; set; } + public bool IsAdmin { get; set; } + + #region Navigation + [ForeignKey("UserID")] + public virtual User User { get; set; } + [ForeignKey("CompanyID")] + public virtual Company Company { get; set; } + public virtual ICollection rolePermissions { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/SaleLead.cs b/Back/Data/Models/SaleLead.cs new file mode 100644 index 0000000..15c05ef --- /dev/null +++ b/Back/Data/Models/SaleLead.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using System.ComponentModel.DataAnnotations; + +namespace Back.Data.Models +{ + public class SaleLead + { + public int ID { get; set; } + public string cn { get; set; } + public string sn { get; set; } + public string company { get; set; } + public string Mobile { get; set; } + public string Key { get; set; } + public string csr { get; set; } + } +} diff --git a/Back/Data/Models/SentTax.cs b/Back/Data/Models/SentTax.cs new file mode 100644 index 0000000..1a03626 --- /dev/null +++ b/Back/Data/Models/SentTax.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations.Schema; +using Back.Common.Enums; +namespace Back.Data.Models +{ + public class SentTax + { + public int ID { get; set; } + public int InvoiceID { get; set; } + public string Date { get; set; } + public string Time { get; set; } + public string uId { get; set; } + public string ReferenceNumber { get; set; } + public InvoiceType InvoiceType { get; set; } + [Column(TypeName = "nvarchar(MAX)")] + public string InvoiceModel { get; set; } + [Column(TypeName = "nvarchar(MAX)")] + public string? ResponseModel { get; set; } + public SentStatus SentStatus { get; set; } + + #region Navigation + [ForeignKey("InvoiceID")] + public virtual Invoice invoice { get; set; } + #endregion + + } +} diff --git a/Back/Data/Models/SpecialCondition.cs b/Back/Data/Models/SpecialCondition.cs new file mode 100644 index 0000000..5cfe403 --- /dev/null +++ b/Back/Data/Models/SpecialCondition.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + [Keyless] + public class SpecialCondition + { + public int FildID { get; set; } + public string condition { get; set; } + #region Navigation + + [ForeignKey("FildID")] + public virtual Fild Fild { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/SubTicket.cs b/Back/Data/Models/SubTicket.cs new file mode 100644 index 0000000..43f5bc2 --- /dev/null +++ b/Back/Data/Models/SubTicket.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations.Schema; +using Back.Common.Enums; + +namespace Back.Data.Models +{ + + public class SubTicket + { + public int ID { get; set; } + public int TicketID { get; set; } + public string Text { get; set; } + public string Date { get; set; } + public string Time { get; set; } + public SideType Type { get; set; } + + #region Navigation + [ForeignKey("TicketID")] + public virtual Ticket Ticket { get; set; } + #endregion + + + } +} diff --git a/Back/Data/Models/TiceketUnknownPeople.cs b/Back/Data/Models/TiceketUnknownPeople.cs new file mode 100644 index 0000000..40a6f3a --- /dev/null +++ b/Back/Data/Models/TiceketUnknownPeople.cs @@ -0,0 +1,9 @@ +namespace Back.Data.Models +{ + public class TiceketUnknownPeople + { + public int ID { get; set; } + public string Mobile { get; set; } + public string FullName { get; set; } + } +} diff --git a/Back/Data/Models/Ticket.cs b/Back/Data/Models/Ticket.cs new file mode 100644 index 0000000..1a7039a --- /dev/null +++ b/Back/Data/Models/Ticket.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations; +using Back.Common.Enums; + +namespace Back.Data.Models +{ + //حتما مدیر میخواد + + public class Ticket + { + public int ID { get; set; } + public string CompanyIDOrMobile { get; set; } + public string Title { get; set; } + public string CreateDate { get; set; } + public string CreateTime { get; set; } + public string? EndDate { get; set; } + public string? EndTime { get; set; } + public StatusTicket Status { get; set; } + + #region Navigation + public virtual ICollection SubTickets { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/User.cs b/Back/Data/Models/User.cs new file mode 100644 index 0000000..71e4839 --- /dev/null +++ b/Back/Data/Models/User.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Data.Models +{ + public class User + { + public int ID { get; set; } + public string Fullname { get; set; } + public string? Email { get; set; } + public string Mobile { get; set; } + public string Username { get; set; } + public string Password { get; set; } + public byte[]? Photo { get; set; } + public bool IsActive { get; set; } + [Column(TypeName = "varchar(max)")] + public string? Token { get; set; } + public string? DateLastLogin { get; set; } + #region Navigation + public virtual ICollection RolUsers { get; set; } + #endregion + } +} diff --git a/Back/Data/Models/ValidationCode.cs b/Back/Data/Models/ValidationCode.cs new file mode 100644 index 0000000..722378d --- /dev/null +++ b/Back/Data/Models/ValidationCode.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + + +namespace Back.Data.Models +{ + public class VerificationCode + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ID { get; set; } + public string prm { get; set; } + public string val { get; set; } + public string Type { get; set; } + } +} diff --git a/Back/Program.cs b/Back/Program.cs index 48863a6..9ce6563 100644 --- a/Back/Program.cs +++ b/Back/Program.cs @@ -1,3 +1,9 @@ +using Back.Data.Contracts; +using Back.Data.Infrastructure.Repository; +using Back.Services; +using Microsoft.EntityFrameworkCore; +using TaxPayer.Infrastructure.Persistence; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -6,6 +12,23 @@ builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); +builder.Services.AddDbContext(options => +{ + options.UseSqlServer(builder.Configuration.GetConnectionString("Base")); +}); +builder.Services.AddScoped(typeof(IAsyncRepository<>), typeof(RepositoryBase<>)); +builder.Services.AddScoped(); +string origins = "OriginTaxPayer"; +builder.Services.AddCors(options => +{ + options.AddPolicy(origins, + policy => + { + policy.WithOrigins("http://localhost:5107") + .AllowAnyHeader() + .AllowAnyMethod(); + }); +}); var app = builder.Build(); @@ -17,7 +40,7 @@ if (app.Environment.IsDevelopment()) } app.UseHttpsRedirection(); - +app.UseCors(origins); app.UseAuthorization(); app.MapControllers(); diff --git a/Back/Services/ServBase.cs b/Back/Services/ServBase.cs new file mode 100644 index 0000000..11eb442 --- /dev/null +++ b/Back/Services/ServBase.cs @@ -0,0 +1,27 @@ +using Back.Data.Contracts; +using Back.Data.Models; +using Microsoft.EntityFrameworkCore; +using Shared.DTOs; + +namespace Back.Services +{ + public class ServBase + { + private readonly IAsyncRepository _repoPricing; + public ServBase(IAsyncRepository repoPricing) + { + _repoPricing = repoPricing; + } + public async Task> GetBasePrice() + { + return await _repoPricing.GetAll().Select(x => new BasePriceDto + { + Price = x.Price, + CalculationType = x.CalculationTypeID==1 ? "واحدی" + : x.CalculationTypeID == 1 && x.PermissionID==16 ? "هر ارسال" + : x.CalculationTypeID == 2 ? "نامحدود" : "روزانه", + PermissionID=x.PermissionID, + }).ToListAsync(); + } + } +} diff --git a/Back/WeatherForecast.cs b/Back/WeatherForecast.cs deleted file mode 100644 index f2f3419..0000000 --- a/Back/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Back -{ - public class WeatherForecast - { - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } - } -} diff --git a/Back/appsettings.Development.json b/Back/appsettings.Development.json index 0c208ae..2ceab23 100644 --- a/Back/appsettings.Development.json +++ b/Back/appsettings.Development.json @@ -4,5 +4,12 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning" } + }, + "ConnectionStrings": { + "Base": "Data Source=195.88.208.142;Initial Catalog=TaxPayer020713;User ID=sa;Password=M439610m@;TrustServerCertificate=True" + + }, + "Fixedvalues": { + "Jwt_Lifetime_Minutes": "60" } } diff --git a/Shared/Class1.cs b/Shared/Class1.cs deleted file mode 100644 index 82f3dcf..0000000 --- a/Shared/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Shared -{ - public class Class1 - { - - } -} diff --git a/Shared/DTOs/BasePriceDto.cs b/Shared/DTOs/BasePriceDto.cs new file mode 100644 index 0000000..b9a06a4 --- /dev/null +++ b/Shared/DTOs/BasePriceDto.cs @@ -0,0 +1,9 @@ +namespace Shared.DTOs +{ + public class BasePriceDto + { + public int PermissionID { get; set; } + public string CalculationType { get; set; } + public decimal Price { get; set; } + } +} diff --git a/TaxPayerFull/Front.csproj b/TaxPayerFull/Front.csproj index 0edf64a..84c5a50 100644 --- a/TaxPayerFull/Front.csproj +++ b/TaxPayerFull/Front.csproj @@ -1,9 +1,11 @@ - + net8.0 enable enable + true + @@ -11,4 +13,11 @@ + + + + + + true + diff --git a/TaxPayerFull/Layout/Rank.razor b/TaxPayerFull/Layout/Rank.razor index 0a62d20..041e177 100644 --- a/TaxPayerFull/Layout/Rank.razor +++ b/TaxPayerFull/Layout/Rank.razor @@ -1,4 +1,6 @@ -
+@using Shared.DTOs +@inject HttpClient _hc +
@@ -45,7 +47,7 @@
صدور انواع فاکتور
- روزانه 10000 تومان + @GetTypeService(3) @GetPriceService(3).ToString("N0") تومان
@@ -54,8 +56,9 @@
مشتری جدید
- واحدی 8500 تومان + @GetTypeService(5) @GetPriceService(5).ToString("N0") تومان
+
@@ -63,7 +66,7 @@
کالای جدید
- واحدی 10000 تومان + @GetTypeService(4) @GetPriceService(4).ToString("N0") تومان
@@ -72,7 +75,7 @@
سامانه مودیان
- هر ارسال 8500 تومان + @GetTypeService(16) @GetPriceService(16).ToString("N0") تومان
@@ -81,7 +84,25 @@ +@functions{ + private string GetTypeService(int permissionID){ + var type = Models.Where(w => w.PermissionID == permissionID).Select(s => s.CalculationType).FirstOrDefault() ; + if (type==null) + type = ""; -@code { - + return type; + } + private decimal GetPriceService(int permissionID) + => Models.Where(w => w.PermissionID == permissionID).Select(s => s.Price).FirstOrDefault(); } +@code { + List Models = new List(); + protected override async Task OnParametersSetAsync() + { + Models = await _hc.GetFromJsonAsync>("Base/BasePrice"); + await base.OnParametersSetAsync(); + } + + +} + diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index e812c9d..6a5e860 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -1,11 +1,14 @@ using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Front; +using System.Globalization; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); + +CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir"); await builder.Build().RunAsync();