This commit is contained in:
mmrbnjd
2024-11-29 18:52:58 +03:30
parent fc2d774506
commit 384bcbc20f
6 changed files with 43 additions and 25 deletions

View File

@@ -37,8 +37,8 @@ namespace Back.Controllers
{ {
if (logo == null) if (logo == null)
return BadRequest(); 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 UserID = claim.Value;
var result = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); var result = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
var company = result?.RolUsers.First().Company; var company = result?.RolUsers.First().Company;
@@ -50,25 +50,25 @@ namespace Back.Controllers
//کاهش سایز تصویر //کاهش سایز تصویر
image.Mutate(x => x.Resize(200, 200)); image.Mutate(x => x.Resize(200, 200));
var img = new MemoryStream(); var img = new MemoryStream();
image.Save(img, image.Metadata.DecodedImageFormat ); image.Save(img, image.Metadata.DecodedImageFormat);
company.Logo = img.ToArray(); company.Logo = img.ToArray();
//------------- //-------------
return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company)); return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company));
} }
[HttpGet("ChangeName/{name}")] [HttpGet("ChangeName/{name}")]
public async Task<ActionResult<bool>> ChangeName(string name) public async Task<ActionResult<bool>> ChangeName(string name)
{ {
if (string.IsNullOrEmpty(name) || name.Length<=3) if (string.IsNullOrEmpty(name) || name.Length <= 3)
return BadRequest(new List<string> { "نام صحیح نمی باشد"}); return BadRequest(new List<string> { "نام صحیح نمی باشد" });
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 UserID = claim.Value;
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
var company = user?.RolUsers.First().Company; var company = user?.RolUsers.First().Company;
company.Name = name; company.Name = name;
user.Fullname=name; user.Fullname = name;
await _servUser.UpdateUser(user); await _servUser.UpdateUser(user);
return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company)); return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company));
} }
@@ -82,9 +82,9 @@ namespace Back.Controllers
return Ok(new TaxPayerInfoDto return Ok(new TaxPayerInfoDto
{ {
EconomicCode = company.EconomicCode, EconomicCode = company.EconomicCode,
PrivateKey = company.PrivateKey , PrivateKey = company.PrivateKey,
UniqeMemory = company.UniqeMemory , UniqeMemory = company.UniqeMemory,
BranchID=company.BranchID, BranchID = company.BranchID,
}); });
} }
[HttpPut("ChangeTaxPayerInfo")] [HttpPut("ChangeTaxPayerInfo")]
@@ -94,10 +94,16 @@ namespace Back.Controllers
var UserID = claim.Value; var UserID = claim.Value;
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
if (!string.IsNullOrEmpty(model.BranchID) && (model.BranchID.Length > 10 || !int.TryParse(model.BranchID, out int a))) if (!string.IsNullOrEmpty(model.BranchID))
return BadRequest(new List<string> {"مقدار کد شعبه صحیح نمی باشد" }); {
if (!int.TryParse(model.BranchID, out int a))
return BadRequest(new List<string> { "مقدار کد شعبه صحیح نمی باشد" });
if(model.BranchID.Length!=4)
return BadRequest(new List<string> { "مقدار کد شعبه یاید 4عددی باشد" });
if (!string.IsNullOrEmpty(model.UniqeMemory) && (model.UniqeMemory.Length !=6 )) }
if (!string.IsNullOrEmpty(model.UniqeMemory) && (model.UniqeMemory.Length != 6))
return BadRequest(new List<string> { "مقدار حافظه مالیاتی صحیح نمی باشد" }); return BadRequest(new List<string> { "مقدار حافظه مالیاتی صحیح نمی باشد" });
var company = user?.RolUsers.First().Company; 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)) if (await _servTaxPayer.CheckingTheCompanyKeyInformation(company.ID, model.UniqeMemory, model.PrivateKey, model.EconomicCode))
return BadRequest(new List<string> { "فیلدهای کلیدی شامل (کداقتصادی،شناسه حافظه مالیاتی،کلید خصوصی)" + " برای شرکت دیگری ثبت شده است" }); return BadRequest(new List<string> { "فیلدهای کلیدی شامل (کداقتصادی،شناسه حافظه مالیاتی،کلید خصوصی)" + " برای شرکت دیگری ثبت شده است" });
company.EconomicCode = model.EconomicCode; company.EconomicCode = model.EconomicCode;
company.PrivateKey = model.PrivateKey; company.PrivateKey = model.PrivateKey;
company.UniqeMemory = model.UniqeMemory; company.UniqeMemory = model.UniqeMemory;
company.BranchID = model.BranchID; company.BranchID = model.BranchID;
return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company)); return Ok(await _servCompany.AddORUpdateCompanyBoolResult(company));

View File

@@ -152,7 +152,7 @@ namespace Back.Controllers
[HttpGet("SendInvoice/{InvoiceID}")] [HttpGet("SendInvoice/{InvoiceID}")]
public async Task<ActionResult<bool>> SendInvoice(int InvoiceID) public async Task<ActionResult<bool>> SendInvoice(int InvoiceID)
{ {
return BadRequest(new List<string> { "در حال حاضر سامانه مودیان در دسترس نمی باشد" }); //return BadRequest(new List<string> { "در حال حاضر سامانه مودیان در دسترس نمی باشد" });
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 UserID = claim.Value;
@@ -255,7 +255,7 @@ namespace Back.Controllers
// مجموع سایر مالیات، عوارض و وجوه قانونی // مجموع سایر مالیات، عوارض و وجوه قانونی
Todam = result.todam ?? null, Todam = result.todam ?? null,
//صورتحساب مجموع //صورتحساب مجموع
Tbill =-10 /* result.tbill ?? null*/, Tbill = result.tbill ?? null,
//مجموع وزن خالض //مجموع وزن خالض
Tonw = level == 10 ? result.tonw : null, Tonw = level == 10 ? result.tonw : null,
//مجموع ارزش ریالی //مجموع ارزش ریالی
@@ -302,7 +302,7 @@ namespace Back.Controllers
// مبلغ واحد // مبلغ واحد
Fee = level == 4 ? null : bitem.fee, 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, Cut = level == 8 || string.IsNullOrEmpty(bitem.cut) ? null : bitem.cut,
//نرخ برابری ارز با ریال //نرخ برابری ارز با ریال

View File

@@ -14,7 +14,12 @@ namespace Back.Data.Models
#region autofild #region autofild
//تاریخ و زمان پرداخت //تاریخ و زمان پرداخت
[MaxLength(13)] [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 #endregion
#region fild #region fild

View File

@@ -16,10 +16,14 @@ namespace Back.Services
private string _UniqueMemory; private string _UniqueMemory;
private string _PrivateKey; private string _PrivateKey;
private readonly servCompany _servCompany; private readonly servCompany _servCompany;
public ActionTaxPayer(servCompany servCompany) private readonly IConfiguration _configuration;
public ActionTaxPayer(servCompany servCompany, IConfiguration configuration)
{ {
_servCompany = servCompany; _servCompany = servCompany;
_configuration = configuration;
} }
public string GenerateTaxid(string FactorNo, string InvoiceDate) public string GenerateTaxid(string FactorNo, string InvoiceDate)
{ {
//return "testTaxid"; //return "testTaxid";
@@ -70,12 +74,14 @@ namespace Back.Services
if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey)) 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; _UniqueMemory = resquth.UniqueMemory;
_PrivateKey = resquth.PrivateKey; _PrivateKey = resquth.PrivateKey;
TaxApiService.Instance.Init(_UniqueMemory, TaxApiService.Instance.Init(_UniqueMemory,
new SignatoryConfig(_PrivateKey, null), 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(); await TaxApiService.Instance.TaxApis.GetServerInformationAsync();
} }
#endregion #endregion

View File

@@ -65,8 +65,8 @@ namespace Back.Validations
RuleFor(r => r.Item2.BranchID) RuleFor(r => r.Item2.BranchID)
.Custom((model, context) => .Custom((model, context) =>
{ {
if (!string.IsNullOrEmpty(model) && (model.Length > 10)) if (!string.IsNullOrEmpty(model) && (model.Length !=4))
context.AddFailure("تعداد کارکتر کد شعبه صحبح نمی باشد"); context.AddFailure("مقدار کد شعبه یاید 4عددی باشد");
}); });
RuleFor(r => r.Item2.ZipCode) RuleFor(r => r.Item2.ZipCode)
.Custom((model, context) => .Custom((model, context) =>

View File

@@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*",
"TaxPayerApi": "https://tp.tax.gov.ir/req/api/"
} }