diff --git a/Back/Controllers/CompanyController.cs b/Back/Controllers/CompanyController.cs index 0a7f265..965ffdb 100644 --- a/Back/Controllers/CompanyController.cs +++ b/Back/Controllers/CompanyController.cs @@ -37,8 +37,8 @@ namespace Back.Controllers { if (logo == null) return BadRequest(); - - var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); + + var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); var UserID = claim.Value; var result = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); var company = result?.RolUsers.First().Company; @@ -50,25 +50,25 @@ namespace Back.Controllers //کاهش سایز تصویر image.Mutate(x => x.Resize(200, 200)); var img = new MemoryStream(); - image.Save(img, image.Metadata.DecodedImageFormat ); + image.Save(img, image.Metadata.DecodedImageFormat); company.Logo = img.ToArray(); //------------- - + return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company)); } [HttpGet("ChangeName/{name}")] public async Task> ChangeName(string name) { - if (string.IsNullOrEmpty(name) || name.Length<=3) - return BadRequest(new List { "نام صحیح نمی باشد"}); + if (string.IsNullOrEmpty(name) || name.Length <= 3) + return BadRequest(new List { "نام صحیح نمی باشد" }); var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); var UserID = claim.Value; var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); var company = user?.RolUsers.First().Company; company.Name = name; - user.Fullname=name; + user.Fullname = name; await _servUser.UpdateUser(user); return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company)); } @@ -82,9 +82,9 @@ namespace Back.Controllers return Ok(new TaxPayerInfoDto { EconomicCode = company.EconomicCode, - PrivateKey = company.PrivateKey , - UniqeMemory = company.UniqeMemory , - BranchID=company.BranchID, + PrivateKey = company.PrivateKey, + UniqeMemory = company.UniqeMemory, + BranchID = company.BranchID, }); } [HttpPut("ChangeTaxPayerInfo")] @@ -94,10 +94,16 @@ namespace Back.Controllers var UserID = claim.Value; var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); - if (!string.IsNullOrEmpty(model.BranchID) && (model.BranchID.Length > 10 || !int.TryParse(model.BranchID, out int a))) - return BadRequest(new List {"مقدار کد شعبه صحیح نمی باشد" }); + if (!string.IsNullOrEmpty(model.BranchID)) + { + if (!int.TryParse(model.BranchID, out int a)) + return BadRequest(new List { "مقدار کد شعبه صحیح نمی باشد" }); + if(model.BranchID.Length!=4) + return BadRequest(new List { "مقدار کد شعبه یاید 4عددی باشد" }); - if (!string.IsNullOrEmpty(model.UniqeMemory) && (model.UniqeMemory.Length !=6 )) + } + + if (!string.IsNullOrEmpty(model.UniqeMemory) && (model.UniqeMemory.Length != 6)) return BadRequest(new List { "مقدار حافظه مالیاتی صحیح نمی باشد" }); var company = user?.RolUsers.First().Company; @@ -109,9 +115,9 @@ namespace Back.Controllers if (await _servTaxPayer.CheckingTheCompanyKeyInformation(company.ID, model.UniqeMemory, model.PrivateKey, model.EconomicCode)) return BadRequest(new List { "فیلدهای کلیدی شامل (کداقتصادی،شناسه حافظه مالیاتی،کلید خصوصی)" + " برای شرکت دیگری ثبت شده است" }); - + company.EconomicCode = model.EconomicCode; - company.PrivateKey = model.PrivateKey; + company.PrivateKey = model.PrivateKey; company.UniqeMemory = model.UniqeMemory; company.BranchID = model.BranchID; return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company)); diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs index 1b9dae9..6f63c62 100644 --- a/Back/Controllers/TaxPayerController.cs +++ b/Back/Controllers/TaxPayerController.cs @@ -152,7 +152,7 @@ namespace Back.Controllers [HttpGet("SendInvoice/{InvoiceID}")] public async Task> SendInvoice(int InvoiceID) { - return BadRequest(new List { "در حال حاضر سامانه مودیان در دسترس نمی باشد" }); + //return BadRequest(new List { "در حال حاضر سامانه مودیان در دسترس نمی باشد" }); var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); var UserID = claim.Value; @@ -255,7 +255,7 @@ namespace Back.Controllers // مجموع سایر مالیات، عوارض و وجوه قانونی Todam = result.todam ?? null, //صورتحساب مجموع - Tbill =-10 /* result.tbill ?? null*/, + Tbill = result.tbill ?? null, //مجموع وزن خالض Tonw = level == 10 ? result.tonw : null, //مجموع ارزش ریالی @@ -302,7 +302,7 @@ namespace Back.Controllers // مبلغ واحد Fee = level == 4 ? null : bitem.fee, //میزان ارز - Cfee = level==8 || level==10 ?null: bitem.cfee, + Cfee = bitem.cfee == 0|| level ==8 || level==10 ?null: bitem.cfee , //نوع ارز Cut = level == 8 || string.IsNullOrEmpty(bitem.cut) ? null : bitem.cut, //نرخ برابری ارز با ریال diff --git a/Back/Data/Models/InvoicePayment.cs b/Back/Data/Models/InvoicePayment.cs index ef8d82b..fbac6a0 100644 --- a/Back/Data/Models/InvoicePayment.cs +++ b/Back/Data/Models/InvoicePayment.cs @@ -14,7 +14,12 @@ namespace Back.Data.Models #region autofild //تاریخ و زمان پرداخت [MaxLength(13)] - public long? pdt { get { return new DateTimeOffset(PaymentDateTime.Trim().ToMiladi()).ToUnixTimeSeconds(); } } + public long? pdt { get + { + return null; + return new DateTimeOffset(PaymentDateTime.Trim().ToMiladi().Date).ToUnixTimeSeconds(); + + } } #endregion #region fild diff --git a/Back/Services/ActionTaxPayer.cs b/Back/Services/ActionTaxPayer.cs index 5d132e7..f17a60a 100644 --- a/Back/Services/ActionTaxPayer.cs +++ b/Back/Services/ActionTaxPayer.cs @@ -16,10 +16,14 @@ namespace Back.Services private string _UniqueMemory; private string _PrivateKey; private readonly servCompany _servCompany; - public ActionTaxPayer(servCompany servCompany) + private readonly IConfiguration _configuration; + + public ActionTaxPayer(servCompany servCompany, IConfiguration configuration) { _servCompany = servCompany; + _configuration = configuration; } + public string GenerateTaxid(string FactorNo, string InvoiceDate) { //return "testTaxid"; @@ -70,12 +74,14 @@ namespace Back.Services if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey)) { - // "https://sandboxrc.tax.gov.ir/req/api/" + + //string taxapi = _configuration.GetSection("TaxPayerApi").Value; + string taxapi = "https://sandboxrc.tax.gov.ir/req/api/"; _UniqueMemory = resquth.UniqueMemory; _PrivateKey = resquth.PrivateKey; TaxApiService.Instance.Init(_UniqueMemory, new SignatoryConfig(_PrivateKey, null), - new NormalProperties(ClientType.SELF_TSP), "https://tp.tax.gov.ir/req/api/"); + new NormalProperties(ClientType.SELF_TSP), taxapi); await TaxApiService.Instance.TaxApis.GetServerInformationAsync(); } #endregion diff --git a/Back/Validations/AddOrCustomerValidation.cs b/Back/Validations/AddOrCustomerValidation.cs index 4581cf2..e79c258 100644 --- a/Back/Validations/AddOrCustomerValidation.cs +++ b/Back/Validations/AddOrCustomerValidation.cs @@ -65,8 +65,8 @@ namespace Back.Validations RuleFor(r => r.Item2.BranchID) .Custom((model, context) => { - if (!string.IsNullOrEmpty(model) && (model.Length > 10)) - context.AddFailure("تعداد کارکتر کد شعبه صحبح نمی باشد"); + if (!string.IsNullOrEmpty(model) && (model.Length !=4)) + context.AddFailure("مقدار کد شعبه یاید 4عددی باشد"); }); RuleFor(r => r.Item2.ZipCode) .Custom((model, context) => diff --git a/Back/appsettings.json b/Back/appsettings.json index 10f68b8..b8fd607 100644 --- a/Back/appsettings.json +++ b/Back/appsettings.json @@ -5,5 +5,6 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "TaxPayerApi": "https://tp.tax.gov.ir/req/api/" }