...
This commit is contained in:
@@ -3,10 +3,12 @@ using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Org.BouncyCastle.Asn1.Cmp;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using Shared.DTOs;
|
||||
using Shared.DTOs.Serch;
|
||||
using System;
|
||||
@@ -289,9 +291,9 @@ namespace Back.Controllers
|
||||
List<InvoiceBodyDto> InvoiceBody = new List<InvoiceBodyDto>();
|
||||
foreach (var bitem in result.invoiceDetails)
|
||||
{
|
||||
InvoiceBodyDto item=new InvoiceBodyDto();
|
||||
InvoiceBodyDto item = new InvoiceBodyDto();
|
||||
#region body
|
||||
if (header.Inty==1 && header.Inp==1)
|
||||
if (header.Inty == 1 && header.Inp == 1)
|
||||
item = new InvoiceBodyDto
|
||||
{
|
||||
//شناسه کالا / خدمت
|
||||
@@ -331,7 +333,7 @@ namespace Back.Controllers
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
else if (header.Inty == 1 && header.Inp == 2)
|
||||
item = new InvoiceBodyDto
|
||||
{
|
||||
@@ -372,8 +374,8 @@ namespace Back.Controllers
|
||||
|
||||
|
||||
};
|
||||
|
||||
else if(header.Inty == 1 && header.Inp == 3)
|
||||
|
||||
else if (header.Inty == 1 && header.Inp == 3)
|
||||
item = new InvoiceBodyDto
|
||||
{
|
||||
//شناسه کالا / خدمت
|
||||
@@ -410,17 +412,17 @@ namespace Back.Controllers
|
||||
Cop = bitem.cop,
|
||||
Vop = bitem.vop,
|
||||
Bsrn = bitem.bsrn,
|
||||
Consfee=bitem.consfee,
|
||||
Spro=bitem.spro,
|
||||
Bros=bitem.bros,
|
||||
Tcpbs=bitem.tcpbs,
|
||||
Consfee = bitem.consfee,
|
||||
Spro = bitem.spro,
|
||||
Bros = bitem.bros,
|
||||
Tcpbs = bitem.tcpbs,
|
||||
};
|
||||
|
||||
#endregion
|
||||
InvoiceBody.Add(item);
|
||||
}
|
||||
|
||||
var responseModel =await _actionTaxPayer.SendInvoice(user.RolUsers.First().CompanyID,header, InvoiceBody, new PaymentDto { });
|
||||
var responseModel = await _actionTaxPayer.SendInvoice(user.RolUsers.First().CompanyID, header, InvoiceBody, new PaymentDto { });
|
||||
if (responseModel == null)
|
||||
{
|
||||
return BadRequest(new List<string> { "خطا در ورود به سامانه مودیان" });
|
||||
@@ -441,25 +443,25 @@ namespace Back.Controllers
|
||||
InvoiceModel = JsonConvert.SerializeObject(result),
|
||||
ResponseModel = JsonConvert.SerializeObject(responseModel)
|
||||
};
|
||||
await _servTaxPayer.AddSentTax(ressenttax);
|
||||
await _servTaxPayer.AddSentTax(ressenttax);
|
||||
}
|
||||
result.taxid = header.Taxid;
|
||||
result.irtaxid = header.Irtaxid;
|
||||
return Ok(await _servTaxPayer.UpdateInvoice(result));
|
||||
return Ok(await _servTaxPayer.UpdateInvoice(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
string errors = "";
|
||||
foreach (var item in responseModel.Body.Errors)
|
||||
errors +='\n'+ $"{item.ErrorCode}:{item.Detail}";
|
||||
|
||||
errors += '\n' + $"{item.ErrorCode}:{item.Detail}";
|
||||
|
||||
return BadRequest(new List<string> { errors });
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
[HttpPost("GetAllSentTax")]
|
||||
@@ -468,7 +470,90 @@ 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));
|
||||
return Ok(_servTaxPayer.GetSentTax(user.RolUsers.First().CompanyID,item));
|
||||
return Ok(await _servTaxPayer.GetSentTax(user.RolUsers.First().CompanyID, item));
|
||||
}
|
||||
[HttpGet("GetResult/{ID}")]
|
||||
public async Task<ActionResult<DataInSendTaxDto>> GetResultByUid(int ID)
|
||||
{
|
||||
try
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var item = await _servTaxPayer.GetSentTax(user.RolUsers.First().CompanyID, ID);
|
||||
if (item == null)
|
||||
return BadRequest(new List<string> { "یافت نشد" });
|
||||
|
||||
if (string.IsNullOrEmpty(item.uId))
|
||||
return BadRequest(new List<string> { "کد پیگیری یافت نشد" });
|
||||
|
||||
if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID))
|
||||
return BadRequest(new List<string> { "خطا در احراز هویت سازمان مالیاتی" });
|
||||
|
||||
DataInSendTaxDto desData = new DataInSendTaxDto();
|
||||
if (item.SentStatus==SentStatus.Send
|
||||
|| item.SentStatus == SentStatus.pending
|
||||
|| item.SentStatus == SentStatus.IN_PROGRESS)
|
||||
{
|
||||
|
||||
|
||||
var result = await _actionTaxPayer.GetResultByUid(user.RolUsers.First().CompanyID, item.uId);
|
||||
if (result == null)
|
||||
return BadRequest(new List<string> { "پاسخی از سازمان دریافت نشد" });
|
||||
|
||||
else
|
||||
{
|
||||
item.InquiryResultModel = JsonConvert.SerializeObject(result);
|
||||
if (result.Data != null)
|
||||
{
|
||||
desData = JsonConvert.DeserializeObject<DataInSendTaxDto>(result.Data.ToString());
|
||||
if (desData == null)
|
||||
{
|
||||
desData = new DataInSendTaxDto();
|
||||
desData.error = JsonConvert.DeserializeObject<List<MessageInSendTaxDto>>(result.Data.ToString());
|
||||
}
|
||||
}
|
||||
desData.SentStatus = item.SentStatus =
|
||||
result.Status == "FAILED" ? SentStatus.Unsuccessful
|
||||
: result.Status == "PENDING" ? SentStatus.pending
|
||||
: result.Status == "SUCCESS" ? SentStatus.Successful
|
||||
: result.Status == "NOT_FOUND" ? SentStatus.NOT_FOUND
|
||||
: result.Status == "IN_PROGRESS" ? SentStatus.IN_PROGRESS
|
||||
: SentStatus.Unknown;
|
||||
}
|
||||
if (await _servTaxPayer.UpdateSentTax(item)) return Ok(desData);
|
||||
|
||||
else return BadRequest(new List<string> { "خطای در ذخیره سازی" });
|
||||
}
|
||||
else if (item.SentStatus == SentStatus.Unsuccessful && !string.IsNullOrEmpty(item.InquiryResultModel))
|
||||
{
|
||||
InquiryResultModel inquiryResult = JsonConvert.DeserializeObject<InquiryResultModel>(item.InquiryResultModel);
|
||||
if (inquiryResult.Data != null)
|
||||
{
|
||||
desData.SentStatus = item.SentStatus =
|
||||
inquiryResult.Status == "FAILED" ? SentStatus.Unsuccessful
|
||||
: inquiryResult.Status == "PENDING" ? SentStatus.pending
|
||||
: inquiryResult.Status == "SUCCESS" ? SentStatus.Successful
|
||||
: inquiryResult.Status == "NOT_FOUND" ? SentStatus.NOT_FOUND
|
||||
: inquiryResult.Status == "IN_PROGRESS" ? SentStatus.IN_PROGRESS
|
||||
: SentStatus.Unknown;
|
||||
|
||||
desData = JsonConvert.DeserializeObject<DataInSendTaxDto>(inquiryResult.Data.ToString());
|
||||
if (desData == null)
|
||||
{
|
||||
desData = new DataInSendTaxDto();
|
||||
desData.error = JsonConvert.DeserializeObject<List<MessageInSendTaxDto>>(inquiryResult.Data.ToString());
|
||||
}
|
||||
}
|
||||
return Ok(desData);
|
||||
}
|
||||
|
||||
return BadRequest(new List<string> { "در این وضعیت امکان پذیر نمی باشد" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(new List<string> { "خطای ناشناخته" });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -82,7 +82,16 @@ namespace Back.Controllers
|
||||
// return Ok(await _servUser.ChangeUserName(newUsername, Convert.ToInt32(UserID)));
|
||||
}
|
||||
|
||||
[HttpGet("GetDashBoard")]
|
||||
public async Task<ActionResult<DashBoardDTO>> GetDashBoard()
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
|
||||
|
||||
return Ok(await _servUser.GetDashBoard(Convert.ToInt32(UserID)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,8 @@ namespace Back.Data.Models
|
||||
public string InvoiceModel { get; set; }
|
||||
[Column(TypeName = "nvarchar(MAX)")]
|
||||
public string? ResponseModel { get; set; }
|
||||
[Column(TypeName = "nvarchar(MAX)")]
|
||||
public string? InquiryResultModel { get; set; }
|
||||
public SentStatus SentStatus { get; set; }
|
||||
|
||||
#region Navigation
|
||||
|
@@ -3,7 +3,6 @@ using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Back.Common;
|
||||
using Shared;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
using Shared.DTOs.Serch;
|
||||
|
||||
@@ -77,6 +76,14 @@ namespace Back.Services
|
||||
.ThenInclude(inc => inc.CODUnit)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<SentTax> GetSentTax(int CompanyID, int ID)
|
||||
{
|
||||
return await _repoSentTax.Get(w=>w.ID== ID && w.invoice.CompanyID==CompanyID).FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<bool> UpdateSentTax(SentTax sent)
|
||||
{
|
||||
return await _repoSentTax.UpdateAsync(sent);
|
||||
}
|
||||
public async Task<bool> AddSentTax(SentTax sentTax)
|
||||
{
|
||||
return await _repoSentTax.AddBoolResultAsync(sentTax);
|
||||
@@ -221,13 +228,13 @@ namespace Back.Services
|
||||
return await request.OrderByDescending(o=>o.ID)
|
||||
.Select(s => new SentTaxDto
|
||||
{
|
||||
Date = s.Date.ShamciToFormatShamciinFront(),
|
||||
Date = s.Date.ShamciToFormatShamci(),
|
||||
Time = s.Time,
|
||||
ID = s.ID,
|
||||
InvoiceID = s.InvoiceID,
|
||||
SentStatus=s.SentStatus,
|
||||
msgInvoiceType = s.InvoiceType.GetDisplayName(),
|
||||
msgSentStatus = s.SentStatus.GetDisplayName()
|
||||
msgInvoiceType = s.InvoiceType.GetEnumDisplayName(),
|
||||
msgSentStatus = s.SentStatus.GetEnumDisplayName()
|
||||
|
||||
}).Paging(itemSerchGetSentTax.PageIndex, itemSerchGetSentTax.PageSize);
|
||||
}
|
||||
|
@@ -188,11 +188,15 @@ namespace Back.Services
|
||||
user.Password = newpassword.encrypted();
|
||||
return await _RepoUser.UpdateAsync(user);
|
||||
}
|
||||
public async Task<DashBoardDTO> GetDashBoard(int CompanyID, int UserID)
|
||||
public async Task<DashBoardDTO> GetDashBoard(int UserID)
|
||||
{
|
||||
var user = await GetUserByUserID(UserID);
|
||||
DashBoardDTO request = new DashBoardDTO();
|
||||
var period = await _RepoPermissionPeriod
|
||||
.Get(w => w.CompanyID == CompanyID && (!w.IsLocked.HasValue || !w.IsLocked.Value)).ToListAsync();
|
||||
.Get(w => w.CompanyID == user.RolUsers.First().CompanyID && (!w.IsLocked.HasValue || !w.IsLocked.Value))
|
||||
.Include(inc=>inc.CalculationType)
|
||||
.Include(inc => inc.Permission)
|
||||
.ToListAsync();
|
||||
foreach (var item in period)
|
||||
{
|
||||
request.AlistofServices.Add(new ServiceInDashBoardDTO
|
||||
@@ -210,16 +214,16 @@ namespace Back.Services
|
||||
if (!string.IsNullOrEmpty(request.LastLoginDate))
|
||||
request.LastLoginDate.ShamciToFormatShamci();
|
||||
|
||||
var user = await GetUserByUserID(UserID);
|
||||
if (user.Mobile == user.Username)
|
||||
request.Warning.Add(new AlertDTO { Status = 0, Message = "موبایل و نام کاربری بهتر است شبیه هم نباشند" });
|
||||
|
||||
//if (user.Mobile == user.Username)
|
||||
// request.Warning.Add(new AlertDTO { Status = 0, Message = "موبایل و نام کاربری بهتر است شبیه هم نباشند" });
|
||||
if (user.Mobile.encrypted() == user.Password)
|
||||
request.Warning.Add(new AlertDTO { Status = 0, Message = "موبایل و کلمه عبور بهتر است شبیه هم نباشند" });
|
||||
var Company = user.RolUsers.Where(w => w.CompanyID == CompanyID).Select(s => s.Company).FirstOrDefault();
|
||||
var Company = user.RolUsers.Where(w => w.CompanyID == user.RolUsers.First().CompanyID).Select(s => s.Company).FirstOrDefault();
|
||||
if (Company != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Company.Email) || string.IsNullOrEmpty(Company.Phone)
|
||||
|| string.IsNullOrEmpty(Company.EconomicCode) || string.IsNullOrEmpty(Company.UniqeMemory)
|
||||
if (/*string.IsNullOrEmpty(Company.Email) || string.IsNullOrEmpty(Company.Phone) || */
|
||||
string.IsNullOrEmpty(Company.EconomicCode) || string.IsNullOrEmpty(Company.UniqeMemory)
|
||||
|| string.IsNullOrEmpty(Company.PrivateKey))
|
||||
{
|
||||
request.Warning.Add(new AlertDTO { Status = 0, Message = "بهتر است اطلاعات شرکت بروزرسانی شود" });
|
||||
|
Reference in New Issue
Block a user