...
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> { "خطای ناشناخته" });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user