diff --git a/Back/Back.csproj b/Back/Back.csproj index 52705f9..a6bcdd4 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -35,7 +35,7 @@ - ..\..\Dlls\Service.dll + ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs index f59bfc6..4cdd999 100644 --- a/Back/Controllers/TaxPayerController.cs +++ b/Back/Controllers/TaxPayerController.cs @@ -1,4 +1,5 @@ -using Back.Services; +using Back.Data.Models; +using Back.Services; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Shared.DTOs; @@ -17,7 +18,7 @@ namespace Back.Controllers _servUser = servUser; } [HttpGet("GetInvoice/{ID}")] - public async Task> Get(int ID) + public async Task> Get(int ID) { var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); var UserID = claim.Value; @@ -28,6 +29,12 @@ namespace Back.Controllers else { + if (!result.PatternID.HasValue) + return BadRequest(new List { "ابتدا برای این صورتحساب الگو در نظر بگیرید" }); + + if (result.invoiceType == InvoiceType.Bidding) + return BadRequest(new List { "صورتحساب در وضعیت پیش نویس نمیتواند ارسال شود" }); + if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result)) return BadRequest(new List { "این صورتحساب قبلا به سازمان ارسال شده"}); @@ -40,17 +47,9 @@ namespace Back.Controllers && !await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result.invoice)) return BadRequest(new List { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع به سامانه مودیان ارسال شده باشد" }); + - - if (!result.PatternID.HasValue) - return BadRequest(new List { "ابتدا برای این صورتحساب الگو در نظر بگیرید" }); - - if (result.invoiceType==InvoiceType.Bidding) - return BadRequest(new List { "صورتحساب در وضعیت پیش نویس نمیتواند ارسال شود" }); - - - - return Ok(result); + return Ok(await _servTaxPayer.GetFildInvoiceForPreparation(result)); } } diff --git a/Back/Services/servTaxPayer.cs b/Back/Services/servTaxPayer.cs index 03357e9..c77f106 100644 --- a/Back/Services/servTaxPayer.cs +++ b/Back/Services/servTaxPayer.cs @@ -11,12 +11,19 @@ namespace Back.Services private readonly IAsyncRepository _repoSentTax; private readonly IAsyncRepository _repoPattern; private readonly IAsyncRepository _invoiceRepo; + private readonly IAsyncRepository _fildModeInPatternRepo; + private readonly IAsyncRepository _codingRepo; + private readonly IAsyncRepository _specialConditionRepo; public servTaxPayer(IAsyncRepository repoSentTax, IAsyncRepository repoPattern - , IAsyncRepository invoiceRepo) + , IAsyncRepository invoiceRepo, IAsyncRepository fildModeInPatternRepo + , IAsyncRepository codingRepo, IAsyncRepository specialConditionRepo) { _repoSentTax = repoSentTax; _repoPattern = repoPattern; _invoiceRepo = invoiceRepo; + _fildModeInPatternRepo = fildModeInPatternRepo; + _codingRepo = codingRepo; + _specialConditionRepo = specialConditionRepo; } public async Task ExistSuccessfulorSendorpendingInvoiceinCompanyID(int CompanyID) { @@ -49,11 +56,94 @@ namespace Back.Services #endregion //----------------------- return await invok - .Include(inc => inc.invoice) + .Include(inc => inc.Customer) + .Include(inc => inc.company) + .Include(inc => inc.company) + .Include(inc => inc.pattern) + .Include(inc => inc.payments) + .Include(inc => inc.invoice) .Include(inc => inc.invoiceDetails) .ThenInclude(inc => inc.cODItem) .ThenInclude(inc => inc.CODUnit) .FirstOrDefaultAsync(); } + + public async Task<_TaxPayer.Atemplatefield> GetFildInvoiceForPreparation(Invoice InvoiceItem) + { + _TaxPayer.Atemplatefield ret = new _TaxPayer.Atemplatefield(); + + + var invok = _fildModeInPatternRepo.Get + (w => w.PatternID == InvoiceItem.PatternID && w.FildModeID != 4 && (w.Fild.InputBox == "fild" || w.Fild.InputBox == "fromdb" || w.Fild.InputBox == "autofild") && w.pattern.Status); + + //-----------------------head + var head = await invok.Where(w => w.Fild.Title == "H").Select(s => new _TaxPayer.Fild() + { + FildID = s.FildID, + eName = s.Fild.Name == "indatim" ? "InvoicIssueDate" : s.Fild.Name == "Indati2m" ? "InvoiceDate" : s.Fild.Name == "cdcd" ? "CottageDateOfCustomsDeclaration" : s.Fild.Name, + fName = s.Fild.Type, + ModeID = s.FildModeID, + ModeTitle = s.FildMode.Title, + Title = s.Fild.Title, + InputBox = s.Fild.Name == "indatim" || s.Fild.Name == "Indati2m" || s.Fild.Name == "cdcd" ? "fild" : s.Fild.InputBox + + }).ToListAsync(); + foreach (_TaxPayer.Fild item in head) + { + var resval = InvoiceItem.GetType().GetProperties().Where(w => w.Name == item.eName).Select(s => s.GetValue(InvoiceItem)).FirstOrDefault(); + item.Value = resval == null ? "" : (item.eName == "InvoicIssueDate" || item.eName == "InvoiceDate" || item.eName == "CottageDateOfCustomsDeclaration" ? resval.ToString().ShamciToFormatShamci() : resval.ToString()); + item.DefVals = item.InputBox == "fromdb" ? _codingRepo.Get(w => w.FildID == item.FildID).Select(ss => new _TaxPayer.Coding() { ID = ss.Code, Name = ss.Title }).ToList() : new List<_TaxPayer.Coding>(); + item.Des = item.ModeID == 3 ? _specialConditionRepo.Get(w => w.FildID == item.FildID).Select(ss => ss.condition).ToArray() : null; + } + ret.header = new _TaxPayer.Filds() { ID = InvoiceItem.ID, filds = head }; + //-------------------body + var body = await invok.Where(w => w.Fild.Title == "B").Select(s => new _TaxPayer.Fild() + { + FildID = s.FildID, + eName = s.Fild.Name, + fName = s.Fild.Type, + ModeID = s.FildModeID, + ModeTitle = s.FildMode.Title, + Title = s.Fild.Title, + InputBox = s.Fild.InputBox + + }).ToListAsync(); + foreach (var invoicedetail in InvoiceItem.invoiceDetails) + { + foreach (_TaxPayer.Fild item in body) + { + var resval = InvoiceItem.GetType().GetProperties().Where(w => w.Name == item.eName).Select(s => s.GetValue(InvoiceItem)).FirstOrDefault(); + item.Value = resval == null ? "" : resval.ToString(); + item.DefVals = item.InputBox == "fromdb" ? _codingRepo.Get(w => w.FildID == item.FildID).Select(ss => new _TaxPayer.Coding() { ID = ss.Code, Name = ss.Title }).ToList() : new List<_TaxPayer.Coding>(); + item.Des = item.ModeID == 3 ? _specialConditionRepo.Get(w => w.FildID == item.FildID).Select(ss => ss.condition).ToArray() : null; + } + ret.Bodys.Add(new _TaxPayer.Filds() { ID = invoicedetail.ID, filds = body }); + } + //-----------------payment + var pay = await invok.Where(w => w.Fild.Title == "P").Select(s => new _TaxPayer.Fild() + { + FildID = s.FildID, + eName = s.Fild.Name == "pdt" ? "PaymentDateTime" : s.Fild.Name, + fName = s.Fild.Type, + ModeID = s.FildModeID, + ModeTitle = s.FildMode.Title, + Title = s.Fild.Title, + InputBox = s.Fild.Name == "pdt" ? "fild" : s.Fild.InputBox + + }).ToListAsync(); + foreach (var invoicepay in InvoiceItem.payments) + { + foreach (_TaxPayer.Fild item in pay) + { + var resval = InvoiceItem.GetType().GetProperties().Where(w => w.Name == item.eName).Select(s => s.GetValue(InvoiceItem)).FirstOrDefault(); + item.Value = resval == null ? "" : resval.ToString(); + item.DefVals = item.InputBox == "fromdb" ? _codingRepo.Get(w => w.FildID == item.FildID).Select(ss => new _TaxPayer.Coding() { ID = ss.Code, Name = ss.Title }).ToList() : new List<_TaxPayer.Coding>(); + item.Des = item.ModeID == 3 ? _specialConditionRepo.Get(w => w.FildID == item.FildID).Select(ss => ss.condition).ToArray() : null; + } + ret.Payments.Add(new _TaxPayer.Filds() { ID = invoicepay.ID, filds = pay }); + } + + return ret; + } } } diff --git a/Shared/DTOs/_TaxPayer.cs b/Shared/DTOs/_TaxPayer.cs new file mode 100644 index 0000000..11ddef6 --- /dev/null +++ b/Shared/DTOs/_TaxPayer.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DTOs +{ + public class _TaxPayer + { + public class Atemplatefield + { + public Filds header { get; set; } + public List Bodys { get; set; } + public List Payments { get; set; } + + } + public class Filds + { + public int ID { get; set; } + public List filds { get; set; } + } + public class Fild + { + public int FildID { get; set; } + public string fName { get; set; } + public string eName { get; set; } + public int ModeID { get; set; } + public string ModeTitle { get; set; } + public string Title { get; set; } + public string InputBox { get; set; } + public List DefVals { get; set; } + public string? Value { get; set; } + public string[] Des { get; set; } + } + public class Coding + { + public string ID { get; set; } + public string Name { get; set; } + } + } +} diff --git a/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor b/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor index bd0b76c..f5901b6 100644 --- a/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor +++ b/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor @@ -296,7 +296,7 @@ {

-
@@ -419,7 +419,13 @@ } - + private async Task showTaxPayer() + { + if (InvoiceID.HasValue) + { + hc._nav.NavigateTo($"TaxPayerInvoiceItem/{InvoiceID}"); + } + } private async Task ShowReport() { if (InvoiceID.HasValue) diff --git a/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor b/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor index 5a9bbaa..d545174 100644 --- a/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor +++ b/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor @@ -13,19 +13,19 @@ [Parameter] public int? InvoiceID { get; set; } List messages = new List(); [Inject] protected PreloadService PreloadService { get; set; } = default!; - public InvoiceDTO? invoice { get; set; } + public _TaxPayer.Atemplatefield? invoice { get; set; } // alert AlertColor alertColor = AlertColor.Primary; IconName alertIconName = IconName.CheckCircleFill; bool Hidealert = true; string alertMessage = ""; - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { await LoadData(); - - await base.OnInitializedAsync(); + await base.OnParametersSetAsync(); } + } @functions{ private void ShowSuccessAlert(string msg) @@ -48,7 +48,7 @@ var rsp = await hc.Get($"TaxPayer/GetInvoice/{InvoiceID}"); if (rsp.IsSuccessStatusCode) { - invoice = await rsp.Content.ReadFromJsonAsync(); + invoice = await rsp.Content.ReadFromJsonAsync<_TaxPayer.Atemplatefield?>(); } else { diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index 628e6c3..f8805c2 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -34,9 +34,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO() }) ; -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); -//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");