From 488f2257f77d5b5c9a1b7c0d36a019d808415d39 Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Mon, 8 Jul 2024 16:10:06 +0330 Subject: [PATCH] ... --- Back/Controllers/InvoiceController.cs | 91 +------------------------- Back/Controllers/TaxPayerController.cs | 18 ++--- Back/Services/ActionTaxPayer.cs | 3 + Shared/DTOs/Authentication.cs | 2 +- 4 files changed, 15 insertions(+), 99 deletions(-) diff --git a/Back/Controllers/InvoiceController.cs b/Back/Controllers/InvoiceController.cs index 1af97ce..8fa99af 100644 --- a/Back/Controllers/InvoiceController.cs +++ b/Back/Controllers/InvoiceController.cs @@ -221,25 +221,17 @@ namespace Back.Controllers { case 1: return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Sale)); - case 3: return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation)); - //case 0: - // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL)); - default: return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" }); } } if (Invoice.invoiceType == InvoiceType.Sale) { - //if (sent) - //{ + switch (invoiceType) { - //case 0: - // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL)); - case 3: return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation)); @@ -305,53 +297,9 @@ namespace Back.Controllers default: return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); } - //} - //else - //{ - // switch (invoiceType) - // { - // case 0: - // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL)); - - // default: - // return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" }); - // } - - //} } - //if (Invoice.invoiceType == InvoiceType.Cancellation) - //{ - // if (!sent) - // { - // switch (invoiceType) - // { - // //case InvoiceType.Sale: - // // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); - - // case 0: - // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL)); - - // default: - // return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" }); - // } - // } - // else return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); - //} if (Invoice.invoiceType == InvoiceType.Repair) { - //if (!sent) - //{ - // switch (invoiceType) - // { - // case 0: - // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL)); - - // default: - // return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" }); - // } - //} - //else - //{ switch (invoiceType) { case 3: @@ -391,53 +339,16 @@ namespace Back.Controllers return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); } - //} } if (Invoice.invoiceType == InvoiceType.BackFrmSale) { - // if (!sent) - // { switch (invoiceType) { - //case 0: - // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL)); - case 3: return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation)); default: return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" }); } - // } - //else - //{ - // switch (invoiceType) - // { - // case 3: - // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation)); - - // //case InvoiceType.Repair: - // // await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); - // // return Ok(await _servInvoice.AddInvoice(new Invoice() - // // { - - // // Title = Invoice.Title, - // // Des = Invoice.Des, - // // invoiceType = invoiceType, - // // CustomerID = Invoice.CustomerID, - // // CompanyID = Invoice.CompanyID, - // // InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""), - // // InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""), - // // LastChangeUserID = Convert.ToInt32(UserID), - // // BillReference = Invoice.ID, - // // IsDeleted = false, - // // PatternID = Invoice.PatternID - // // }, false)); - - // default: - // return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); - - // } - //} } diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs index 457b131..98d8c2e 100644 --- a/Back/Controllers/TaxPayerController.cs +++ b/Back/Controllers/TaxPayerController.cs @@ -14,6 +14,7 @@ using Shared.DTOs.Serch; using System; using System.Security.Cryptography; using TaxCollectData.Library.Dto.Content; +using TaxCollectData.Library.Dto.Transfer; using static Shared.DTOs._TaxPayer; using static System.Collections.Specialized.BitVector32; @@ -86,11 +87,11 @@ namespace Back.Controllers public async Task> CheckAuth() { - var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); - var UserID = claim.Value; - var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); - if (await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) - return Ok(); + //var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); + //var UserID = claim.Value; + //var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); + // return Ok(await _actionTaxPayer.login(user.RolUsers.First().CompanyID)); + return Ok(true); return BadRequest(); @@ -102,8 +103,8 @@ namespace Back.Controllers var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); var UserID = claim.Value; var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); - if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) - return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); + //if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) + // return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); var result = await _servTaxPayer.GetInvoice(user.RolUsers.First().CompanyID, InvoiceID); if (result == null) @@ -132,7 +133,7 @@ namespace Back.Controllers #region Inital Send InvoiceHeaderDto header = new InvoiceHeaderDto(); #region header - if (header.Inty == 1 && header.Inp == 1) + if (result.inty == 1 && result.inp == 1) header = new InvoiceHeaderDto { //نوع شخص خریدار @@ -424,6 +425,7 @@ namespace Back.Controllers InvoiceBody.Add(item); } + var responseModel = await _actionTaxPayer.SendInvoice(user.RolUsers.First().CompanyID, header, InvoiceBody, new PaymentDto { }); if (responseModel == null) { diff --git a/Back/Services/ActionTaxPayer.cs b/Back/Services/ActionTaxPayer.cs index c4ce83a..f3093fb 100644 --- a/Back/Services/ActionTaxPayer.cs +++ b/Back/Services/ActionTaxPayer.cs @@ -1,5 +1,6 @@ using Back.Common; using Microsoft.IdentityModel.Tokens; +using Newtonsoft.Json; using TaxCollectData.Library.Business; using TaxCollectData.Library.Dto.Config; using TaxCollectData.Library.Dto.Content; @@ -35,6 +36,8 @@ namespace Back.Services } public async Task> SendInvoice(int CompanyID,InvoiceHeaderDto header, List InvoiceBody, PaymentDto payment) { + var stringtest = "{\"ReferenceNumber\":\"18084a18-1eb4-41cd-8bd3-2cad73c45398\",\"Uid\":\"0a4a4ab2-8047-4c31-b765-456ddf0e9c53\",\"Status\":\"SUCCESS\",\"Data\":{\"ValueKind\":1},\"PacketType\":\"receive_invoice_confirm\",\"FiscalId\":\"A2FFKZ\"}"; + return JsonConvert.DeserializeObject>(stringtest); if (!await login(CompanyID)) return null; return await TaxApiService.Instance.TaxApis.SendInvoicesAsync(new List() diff --git a/Shared/DTOs/Authentication.cs b/Shared/DTOs/Authentication.cs index d7a9afb..d88eb8a 100644 --- a/Shared/DTOs/Authentication.cs +++ b/Shared/DTOs/Authentication.cs @@ -8,6 +8,6 @@ namespace Shared.DTOs public string Username { get; set; } [MinLength(3, ErrorMessage = ("کلمه عبور باید حداقل 3 کاراکتر باشد"))] public string Password { get; set; } - public bool Remember { get; set; }=false; + public bool Remember { get; set; }=true; } }