From d67a9ae4404369f7341f450391dfdc88f887f295 Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Tue, 9 Jul 2024 23:04:19 +0330 Subject: [PATCH] ... --- Back/Controllers/TaxPayerController.cs | 21 ++++++++++++------- Back/Data/Models/Invoice.cs | 8 +++++++- Back/Features/IgnorePropertiesResolver.cs | 25 +++++++++++++++++++++++ Back/Services/ActionTaxPayer.cs | 13 ++++++++++++ 4 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 Back/Features/IgnorePropertiesResolver.cs diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs index c5558d0..71edce1 100644 --- a/Back/Controllers/TaxPayerController.cs +++ b/Back/Controllers/TaxPayerController.cs @@ -435,7 +435,7 @@ namespace Back.Controllers { foreach (var item in responseModel.Body.Result) { - //ta imja + var ressenttax = new SentTax { @@ -447,8 +447,11 @@ namespace Back.Controllers uId = item.Uid, SentStatus = SentStatus.Send, InvoiceModel = JsonConvert.SerializeObject(result, Formatting.Indented,new JsonSerializerSettings - { PreserveReferencesHandling = PreserveReferencesHandling.Objects }), + { + PreserveReferencesHandling = PreserveReferencesHandling.Objects + }), ResponseModel = JsonConvert.SerializeObject(responseModel) + }; await _servTaxPayer.AddSentTax(ressenttax); } @@ -494,16 +497,17 @@ namespace Back.Controllers if (string.IsNullOrEmpty(item.uId)) return BadRequest(new List { "کد پیگیری یافت نشد" }); - if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) - return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); + //if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) + // return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); DataInSendTaxDto desData = new DataInSendTaxDto(); if (item.SentStatus == SentStatus.Send || item.SentStatus == SentStatus.pending - || item.SentStatus == SentStatus.IN_PROGRESS) + || item.SentStatus == SentStatus.IN_PROGRESS + || item.SentStatus == SentStatus.Unsuccessful) { - + //ta imja var result = await _actionTaxPayer.GetResultByUid(user.RolUsers.First().CompanyID, item.uId); if (result == null) return BadRequest(new List { "پاسخی از سازمان دریافت نشد" }); @@ -528,10 +532,13 @@ namespace Back.Controllers : result.Status == "IN_PROGRESS" ? SentStatus.IN_PROGRESS : SentStatus.Unknown; } - if (await _servTaxPayer.UpdateSentTax(item)) return Ok(desData); + + + if (await _servTaxPayer.UpdateSentTax(item)) return Ok(desData); else return BadRequest(new List { "خطای در ذخیره سازی" }); } + else if (item.SentStatus == SentStatus.Unsuccessful && !string.IsNullOrEmpty(item.InquiryResultModel)) { InquiryResultModel inquiryResult = JsonConvert.DeserializeObject(item.InquiryResultModel); diff --git a/Back/Data/Models/Invoice.cs b/Back/Data/Models/Invoice.cs index 95e44b1..07ac23b 100644 --- a/Back/Data/Models/Invoice.cs +++ b/Back/Data/Models/Invoice.cs @@ -5,7 +5,7 @@ using Back.Common; using Shared.DTOs; namespace Back.Data.Models { - public class Invoice + public class Invoice : ICloneable { #region Key public int ID { get; set; } @@ -178,6 +178,12 @@ namespace Back.Data.Models [ForeignKey("CompanyID")] [JsonIgnore] public virtual Company? company { get; set; } + + public object Clone() + { + return this.MemberwiseClone(); + + } #endregion } diff --git a/Back/Features/IgnorePropertiesResolver.cs b/Back/Features/IgnorePropertiesResolver.cs new file mode 100644 index 0000000..2334787 --- /dev/null +++ b/Back/Features/IgnorePropertiesResolver.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json.Serialization; +using Newtonsoft.Json; +using System.Reflection; + +namespace Back.Features +{ + public class IgnorePropertiesResolver : DefaultContractResolver + { + private readonly HashSet ignoreProps; + public IgnorePropertiesResolver(IEnumerable propNamesToIgnore) + { + this.ignoreProps = new HashSet(propNamesToIgnore); + } + + protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) + { + JsonProperty property = base.CreateProperty(member, memberSerialization); + if (this.ignoreProps.Contains(property.PropertyName)) + { + property.ShouldSerialize = _ => false; + } + return property; + } + } +} diff --git a/Back/Services/ActionTaxPayer.cs b/Back/Services/ActionTaxPayer.cs index 4d05c15..6cb0064 100644 --- a/Back/Services/ActionTaxPayer.cs +++ b/Back/Services/ActionTaxPayer.cs @@ -1,6 +1,7 @@ using Back.Common; using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; +using Shared.DTOs; using TaxCollectData.Library.Business; using TaxCollectData.Library.Dto.Config; using TaxCollectData.Library.Dto.Content; @@ -27,6 +28,18 @@ namespace Back.Services } public async Task GetResultByUid(int CompanyID, string uid) { + return new InquiryResultModel("18084a18-1eb4-41cd-8bd3-2cad73c45398", "0a4a4ab2-8047-4c31-b765-456ddf0e9c53", "SUCCESS", + new DataInSendTaxDto() + { + error=new List() + { + new MessageInSendTaxDto() + { + code="21001",message="یک خطای تست" + } + } + } + , "receive_invoice_confirm", "A2FFKZ"); if (!await login(CompanyID)) return null; var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory);