This commit is contained in:
mmrbnjd
2024-06-10 17:26:31 +03:30
parent 82bcfc1ffe
commit 2db5daa9b8
14 changed files with 953 additions and 469 deletions

View File

@@ -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> { "خطای ناشناخته" });
}
}
}
}

View File

@@ -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)));
}
}
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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 = "بهتر است اطلاعات شرکت بروزرسانی شود" });

View File

@@ -11,6 +11,7 @@ namespace Shared.DTOs
}
public class DashBoardDTO
{
public string Datenow { get { return DateTime.Now.ConvertMiladiToShamsiinFront(); } }
public string? LastLoginDate { get; set; }
public List<ServiceInDashBoardDTO> AlistofServices { get; set; }=new List<ServiceInDashBoardDTO>();
public List<AlertDTO> Warning { get; set; } = new List<AlertDTO>();

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared.DTOs
{
public class InquiryResultModelDto
{
public string ReferenceNumber { get; set; }
public string Uid { get; set; }
public string Status { get; set; }
public string Data { get; set; }
public string PacketType { get; set; }
public string FiscalId { get; set; }
}
public class MessageInSendTaxDto
{
public string code { get; set; }
public string message { get; set; }
// public string errorType { get; set; }
}
public class DataInSendTaxDto
{
// public int? confirmationReferenceId { get; set; }
public List<MessageInSendTaxDto> error { get; set; }
// public List<MessageInSendTaxDto> warning { get; set; }
public SentStatus SentStatus { get; set; }
public string msgSentStatus { get { return SentStatus.GetEnumDisplayName(); } } }
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared.DTOs
{
public class GetResultSentTaxDto
{
public SentStatus status { get; set; }
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
@@ -9,12 +10,18 @@ namespace Shared.DTOs
{
public class SentTaxDto
{
[Display(Name ="شناسه")]
public int ID { get; set; }
[Display(Name = "شناسه صورتحساب")]
public int InvoiceID { get; set; }
[Display(Name = "تاریخ")]
public string Date { get; set; }
[Display(Name = "زمان")]
public string Time { get; set; }
public SentStatus SentStatus { get; set; }
[Display(Name = "وضعیت صورتحساب")]
public string msgInvoiceType { get; set; }
[Display(Name = "وضعیت ارسال")]
public string msgSentStatus { get; set; }
}
}

View File

@@ -3,19 +3,21 @@ namespace Shared.DTOs
{
public enum SentStatus
{
[Display(Name = "ارسال شده")]
Send,
[Display(Name = "موفق")]
Successful,
Successful,
[Display(Name = "ناموفق")]
Unsuccessful,
[Display(Name = "در حال پردازش")]
pending,
pending,
[Display(Name = "نامشخص")]
Unknown,
[Display(Name = "یافت نشده")]
NOT_FOUND
}
NOT_FOUND,
[Display(Name = "در حال انجام")]
IN_PROGRESS
}
}

View File

@@ -0,0 +1,43 @@
@using Front.Services
@using Shared.DTOs
@inject HttpClientController hc;
<form>
<div class="row g-3">
<label class="col-sm-5 col-form-label">وضعیت ارسال</label>
<InputText @Value="inData.msgSentStatus" type="text" class="form-control" id="msgSentStatus" placeholder="وضعیت ارسال" />
</div>
@if (inData.SentStatus == SentStatus.Unsuccessful)
{
<div class="row g-3">
<table class="table">
<caption>لیست خطاهای صورتحساب</caption>
<thead>
<tr>
<th scope="col">کد</th>
<th scope="col">متن</th>
</tr>
</thead>
<tbody>
@foreach (var item in inData.error)
{
<tr>
<td>@item.code</td>
<td>@item.message</td>
</tr>
}
</tbody>
</table>
</div>
}
</form>
@code {
[Parameter] public DataInSendTaxDto inData { get; set; }
}

View File

@@ -50,7 +50,7 @@
@decimal.Parse(property.GetValue(item, null).ToString()).ToString("N0") ريال
</td>
}
else if (property.Name.ToLower() == "id")
else if (property.Name.ToLower() == "id" && item.ToString() != "Shared.DTOs.SentTaxDto")
{
if (id > 0)
{
@@ -62,6 +62,44 @@
}
}
else if (property.Name.ToLower() == "msgsentstatus" && item.ToString() == "Shared.DTOs.SentTaxDto")
{
var convertmodel = (SentTaxDto)Convert.ChangeType(item, typeof(SentTaxDto));
switch (convertmodel.SentStatus)
{
case SentStatus.Send:
<td style="background-color:#6495ED">@property.GetValue(item, null)</td>
break;
case SentStatus.Successful:
<td style="background-color:#2AD51B">@property.GetValue(item, null)</td>
break;
case SentStatus.Unsuccessful:
<td style="background-color:#C70000">@property.GetValue(item, null)</td>
break;
case SentStatus.pending :
<td style="background-color:#FCFF2A">@property.GetValue(item, null)</td>
break;
case SentStatus.IN_PROGRESS :
<td style="background-color:#FCFF2A">@property.GetValue(item, null)</td>
break;
case SentStatus.NOT_FOUND:
<td style="background-color:#F19109">@property.GetValue(item, null)</td>
break;
case SentStatus.Unknown:
<td style="background-color:#932D2D">@property.GetValue(item, null)</td>
break;
default:
<td>@property.GetValue(item, null)</td>
break;
}
}
else
{
<td>@property.GetValue(item, null)</td>
@@ -70,14 +108,36 @@
}
}
if (id > 0)
if (item.ToString() == "Shared.DTOs.SentTaxDto")
{
<td><button @onclick="()=>OnMultipleOfThree.InvokeAsync(Convert.ToInt32(id))" type="button" class="btn btn-link">ویرایش</button></td>
var convertmodel = (SentTaxDto)Convert.ChangeType(item, typeof(SentTaxDto));
if (convertmodel.SentStatus == SentStatus.Send
|| convertmodel.SentStatus == SentStatus.pending
|| convertmodel.SentStatus == SentStatus.IN_PROGRESS)
{
<td><button @onclick="()=>OnMultipleOfThree.InvokeAsync(Convert.ToInt32(id))" type="button" class="btn btn-link">تعیین وضعیت</button></td>
}
else if (convertmodel.SentStatus == SentStatus.Unsuccessful)
{
<td><button @onclick="()=>OnMultipleOfThree.InvokeAsync(Convert.ToInt32(id))" type="button" class="btn btn-link">نمایش خطا</button></td>
}
else
{
<td><button type="button" class="btn btn-link disabled">...</button></td>
}
}
else
{
<td><button type="button" class="btn btn-link disabled">ویرایش</button></td>
if (id > 0)
{
<td><button @onclick="()=>OnMultipleOfThree.InvokeAsync(Convert.ToInt32(id))" type="button" class="btn btn-link">ویرایش</button></td>
}
else
{
<td><button type="button" class="btn btn-link disabled">ویرایش</button></td>
}
}
}
</tr>

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@
@using Shared
@using Shared.DTOs
@using Shared.DTOs.Serch
<Modal @ref="modal" />
<Preload LoadingText="در حال بارگذاری..." />
@* search *@
<div class="row">
@@ -33,7 +33,7 @@
@foreach (InvoiceType i in Enum.GetValues(typeof(InvoiceType)))
{
<option value="@Convert.ToInt32(i)">@i.GetEnumDisplayName()</option>
<option value="@i">@i.GetEnumDisplayName()</option>
}
@@ -46,13 +46,16 @@
@foreach (SentStatus i in Enum.GetValues(typeof(SentStatus)))
{
<option value="@Convert.ToInt32(i)">@i.GetEnumDisplayName()</option>
<option value="@i">@i.GetEnumDisplayName()</option>
}
</select>
</div>
<div class="col-auto">
<button @onclick="() => Load(1)" type="submit" class="btn btn-primary">جستجو</button>
</div>
</div>
</li>
</ul>
@@ -99,8 +102,10 @@
}
@code {
private Modal modal = default!;
[Inject] protected PreloadService PreloadService { get; set; } = default!;
ItemSerchGetSentTax itemsearch = new ItemSerchGetSentTax();
[Parameter]
public int? routed { get; set; } = 0;
// alert
AlertColor alertColor = AlertColor.Primary;
@@ -128,7 +133,23 @@
@functions{
public async Task SentTaxItem(int ID)
{
var rsp = await hc.Get($"TaxPayer/GetResult/{ID}");
if (rsp.IsSuccessStatusCode)
{
var requestsendTax = await rsp.Content.ReadFromJsonAsync<DataInSendTaxDto>();
//عویض کردن اطلاعات در گرید
var ingriddata= request.list.Where(w => w.ID == ID).First();
ingriddata.SentStatus = requestsendTax.SentStatus;
ingriddata.msgSentStatus = requestsendTax.msgSentStatus;
//-----------------
var parameters = new Dictionary<string, object>();
parameters.Add("inData", requestsendTax);
await modal.ShowAsync<CUSComponent.SendTaxItem>(title: "وضعیت صورتحساب ارسالی", parameters: parameters);
}
else{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
public async Task Load(int pi)
{