625 lines
32 KiB
C#
625 lines
32 KiB
C#
using Back.Common;
|
|
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 Shared.DTOs;
|
|
using Shared.DTOs.Serch;
|
|
using static Shared.DTOs._TaxPayer;
|
|
|
|
namespace Back.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[Authorize]
|
|
[ApiController]
|
|
public class TaxPayerController : ControllerBase
|
|
{
|
|
private readonly servTaxPayer _servTaxPayer;
|
|
private readonly servUser _servUser;
|
|
private readonly ActionTaxPayer _actionTaxPayer;
|
|
public TaxPayerController(servTaxPayer servTaxPayer, servUser servUser, ActionTaxPayer actionTaxPayer)
|
|
{
|
|
_servTaxPayer = servTaxPayer;
|
|
_servUser = servUser;
|
|
_actionTaxPayer = actionTaxPayer;
|
|
}
|
|
[HttpGet("GetInvoice/{ID}")]
|
|
public async Task<ActionResult<_TaxPayer.Atemplatefield?>> Get(int ID)
|
|
{
|
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
var UserID = claim.Value;
|
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
var result = await _servTaxPayer.GetInvoice(user.RolUsers.First().CompanyID, ID);
|
|
if (result == null)
|
|
return BadRequest(new List<string> { "صورتحساب یافت نشد" });
|
|
|
|
else
|
|
{
|
|
if (!result.PatternID.HasValue || result.PatternID == 0)
|
|
return BadRequest(new List<string> { "ابتدا برای این صورتحساب الگو در نظر بگیرید" });
|
|
|
|
//if (result.invoiceType == InvoiceType.Bidding)
|
|
// return BadRequest(new List<string> { "صورتحساب در وضعیت پیش نویس نمیتواند ارسال شود" });
|
|
|
|
//if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result))
|
|
// return BadRequest(new List<string> { "این صورتحساب قبلا به سازمان ارسال شده" });
|
|
|
|
//if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair)
|
|
// && !result.BillReference.HasValue)
|
|
// return BadRequest(new List<string> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع وجود داشته باشد" });
|
|
|
|
|
|
//if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair)
|
|
// && !await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result.invoice))
|
|
// return BadRequest(new List<string> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع به سامانه مودیان ارسال شده باشد" });
|
|
|
|
|
|
|
|
return Ok(await _servTaxPayer.GetFildInvoiceForPreparation(result));
|
|
}
|
|
|
|
}
|
|
[HttpPost("PreparationInvoiceBeforeSending")]
|
|
public async Task<ActionResult<Shared.DTOs._TaxPayer.Atemplatefield?>> PreparationInvoiceBeforeSending([FromBody] Atemplatefield item)
|
|
{
|
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
var UserID = claim.Value;
|
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
var result = await _servTaxPayer.GetInvoice(user.RolUsers.First().CompanyID, item.header.ID);
|
|
if (result == null)
|
|
return BadRequest(new List<string> { "صورتحساب یافت نشد" });
|
|
|
|
else
|
|
{
|
|
if (result.invoiceType == InvoiceType.Bidding)
|
|
return BadRequest(new List<string> { "صورتحساب در وضعیت پیش نویس نمیتواند آماده ارسال شود" });
|
|
|
|
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result))
|
|
return BadRequest(new List<string> { "این صورتحساب قبلا به سازمان ارسال شده" });
|
|
|
|
if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair)
|
|
&& !result.BillReference.HasValue)
|
|
return BadRequest(new List<string> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع وجود داشته باشد" });
|
|
|
|
|
|
if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair)
|
|
&& !await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result.invoice))
|
|
return BadRequest(new List<string> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع به سامانه مودیان ارسال شده باشد" });
|
|
|
|
}
|
|
|
|
|
|
return Ok(await _servTaxPayer.PreparationInvoiceBeforeSending(item, result));
|
|
}
|
|
[HttpPost("UpdateInvoice")]
|
|
public async Task<ActionResult<bool>> UpdateInvoice([FromBody] Atemplatefield item)
|
|
{
|
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
var UserID = claim.Value;
|
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
var result = await _servTaxPayer.GetInvoice(user.RolUsers.First().CompanyID, item.header.ID);
|
|
if (result == null)
|
|
return BadRequest(new List<string> { "صورتحساب یافت نشد" });
|
|
|
|
//else
|
|
//{
|
|
// if (result.invoiceType == InvoiceType.Bidding)
|
|
// return BadRequest(new List<string> { "صورتحساب در وضعیت پیش نویس نمیتواند آماده ارسال شود" });
|
|
|
|
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result))
|
|
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
|
"برای تغییر ،صورتحساب را ابطال/اصلاح یا برگشت بزنید" });
|
|
|
|
// if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair)
|
|
// && !result.BillReference.HasValue)
|
|
// return BadRequest(new List<string> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع وجود داشته باشد" });
|
|
|
|
|
|
// if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair)
|
|
// && !await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result.invoice))
|
|
// return BadRequest(new List<string> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع به سامانه مودیان ارسال شده باشد" });
|
|
|
|
//}
|
|
|
|
|
|
return Ok(await _servTaxPayer.PreparationInvoiceBeforeSending(item, result));
|
|
}
|
|
[HttpGet("CheckAuth")]
|
|
public async Task<ActionResult<bool>> CheckAuth()
|
|
{
|
|
|
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
var UserID = claim.Value;
|
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
return Ok(await _actionTaxPayer.login(user.RolUsers.First().CompanyID));
|
|
// return Ok(true);
|
|
|
|
return BadRequest();
|
|
|
|
}
|
|
[HttpGet("SendInvoice/{InvoiceID}")]
|
|
public async Task<ActionResult<bool>> SendInvoice(int InvoiceID)
|
|
{
|
|
return BadRequest(new List<string> { "در حال حاضر سامانه مودیان در دسترس نمی باشد" });
|
|
|
|
//var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
//var UserID = claim.Value;
|
|
//var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
//if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID))
|
|
// return BadRequest(new List<string> { "خطا در احراز هویت سازمان مالیاتی" });
|
|
|
|
//var result = await _servTaxPayer.GetInvoice(user.RolUsers.First().CompanyID, InvoiceID);
|
|
//if (result == null)
|
|
// return BadRequest(new List<string> { "صورتحساب یافت نشد" });
|
|
|
|
//else
|
|
//{
|
|
// if (!result.PatternID.HasValue)
|
|
// return BadRequest(new List<string> { "ابتدا برای این صورتحساب الگو در نظر بگیرید" });
|
|
|
|
// if (result.invoiceType == InvoiceType.Bidding)
|
|
// return BadRequest(new List<string> { "صورتحساب در وضعیت پیش نویس نمیتواند ارسال شود" });
|
|
|
|
// if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result))
|
|
// return BadRequest(new List<string> { "این صورتحساب قبلا به سازمان ارسال شده" });
|
|
|
|
// if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair)
|
|
// && !result.BillReference.HasValue)
|
|
// return BadRequest(new List<string> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع وجود داشته باشد" });
|
|
|
|
|
|
// if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair)
|
|
// && !await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result.invoice))
|
|
// return BadRequest(new List<string> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع به سامانه مودیان ارسال شده باشد" });
|
|
|
|
// if (result.invoiceType == InvoiceType.Cancellation && string.IsNullOrEmpty(result.taxid))
|
|
// {
|
|
// return BadRequest(new List<string> { "صورتحساب در وضعیت ابطالی باید صورتحساب مرجع آن به سامانه مودیان ارسال شده باشد" });
|
|
|
|
// }
|
|
// #region Inital Send
|
|
// InvoiceHeaderDto header = new InvoiceHeaderDto();
|
|
// PreparationHeaderTaxInvoice preparation = new PreparationHeaderTaxInvoice(result, _actionTaxPayer);
|
|
|
|
|
|
// int level = result.pattern.ID;
|
|
|
|
// //header
|
|
// #region header
|
|
// header = new InvoiceHeaderDto
|
|
// {
|
|
// //شماره منحصر به فرد مالیاتی
|
|
// Taxid = preparation.Taxid,
|
|
// //زمان صدور
|
|
// Indatim = preparation.Indatim,
|
|
// //زمان ایجاد
|
|
// Indati2m = preparation.Indati2m,
|
|
// // صورتحساب نوع *
|
|
// Inty = preparation.Inty,
|
|
// //سریال صورت حساب
|
|
// Inno = preparation.Inno,
|
|
// //شماره منحصر به فرد مالیاتی صورتحساب مرجع
|
|
// Irtaxid = preparation.Irtaxid,
|
|
// //الگوی صورتحساب *
|
|
// Inp = preparation.Inp,
|
|
// //موضوع صورتحساب *
|
|
// Ins = preparation.Ins,
|
|
// //شماره اقتصادی فروشنده به جاش شناسه ملی داده شد
|
|
// Tins = preparation.Tins,
|
|
// //نوع شخص خریدار
|
|
// Tob = preparation.Tob,
|
|
// //شماره/شناسه ملی/شناسه مشارکت مدنی / کد فراگیر
|
|
// Bid = preparation.Bid,
|
|
// //شماره اقتصادی خریدار
|
|
// Tinb = preparation.Tinb,
|
|
// //کد شعبه فروشنده
|
|
// Sbc = preparation.Sbc,
|
|
// //کد پستی خریدار
|
|
// Bpc = preparation.Bpc,
|
|
// //کد شعبه خریدار
|
|
// Bbc = preparation.Bbc,
|
|
// //نوع پرواز
|
|
// Ft = preparation.Ft,
|
|
// //شماره گذرنامه خریدار
|
|
// Bpn = preparation.Bpn,
|
|
// //شماره پروانه گمرکی
|
|
// Scln = preparation.Scln,
|
|
// //کد گمرک محل اظهار فروشنده
|
|
// Scc = preparation.Scc,
|
|
// //شماره کدتاژ اظهارنامه گمرکی
|
|
// Cdcn = preparation.Cdcn,
|
|
// //تاریخ کوتاژ اظهارنامه گمرکی
|
|
// Cdcd = preparation.Cdcd,
|
|
// //شناسه یکتای ثبت قزارداد فروشنده
|
|
// Crn = preparation.Crn,
|
|
// //شماره اشتراک/شناسه قبض بهره بردار
|
|
// Billid = preparation.Billid,
|
|
// //مجموع مبلغ قبل از کسر تخفیف
|
|
// Tprdis = preparation.Tprdis,
|
|
// //مجموع تخفیفات
|
|
// Tdis = preparation.Tdis,
|
|
// // مجموع مبلغ پس از کسر تخفیف
|
|
// Tadis = preparation.Tadis,
|
|
// //مجموع مالیات بر ارزش افزوده
|
|
// Tvam = preparation.Tvam,
|
|
// // مجموع سایر مالیات، عوارض و وجوه قانونی
|
|
// Todam = preparation.Todam,
|
|
// //صورتحساب مجموع
|
|
// Tbill = preparation.Tbill,
|
|
// //مجموع وزن خالض
|
|
// Tonw = preparation.Tonw,
|
|
// //مجموع ارزش ریالی
|
|
// Torv = preparation.Torv,
|
|
// //مجموع ارزش ارزی
|
|
// Tocv = preparation.Tocv,
|
|
// // تسویه روش
|
|
// Setm = preparation.Setm,
|
|
// //نقدی پرداختی مبلغ
|
|
// Cap = preparation.Cap,
|
|
// //پرداختی نسیه
|
|
// Insp = preparation.Insp,
|
|
// //مجموع سهم مالیات بر ارزش افزوده از پرداخت
|
|
// Tvop = preparation.Tvop,
|
|
// //مالیات موضوع 17
|
|
// Tax17 = preparation.Tax17,
|
|
// //شماره اقتصادی آژانس
|
|
// Tinc = preparation.Tinc,
|
|
// //تاریخ اعلامیه فروش
|
|
// Asd=null,
|
|
// //شماره اعلامیه فروش
|
|
// Asn = null,
|
|
// //شماره ناوگان
|
|
// Cno=null,
|
|
// //شهر مقصد
|
|
// Dci = null,
|
|
// //کشور مقصد
|
|
// Dco = null,
|
|
// //کد ملی/ کد فراگیر اتباع غیر ایرانی راننده) در حمل و نقل جاده ای(
|
|
// Did = null,
|
|
// //شماره بارنامه
|
|
// Lno = null,
|
|
// //شماره بارنامه مرجع
|
|
// Lrno = null,
|
|
// //نوع بارنامه/ نوع حمل
|
|
// Lt = null,
|
|
// //شهر مبدا
|
|
// Oci = null,
|
|
// //کشور مبدا
|
|
// Ocu = null,
|
|
// //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیر ایرانی گیرنده
|
|
// Rid = null,
|
|
// //کالاهای حمل شده
|
|
// Sg = new List<ShippingGoodDto>(),
|
|
// //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی / کد فراگیر اتباع غیر ایرانی فرستنده
|
|
// Tid =null
|
|
|
|
// };
|
|
// #endregion header
|
|
|
|
|
|
|
|
|
|
// //body
|
|
// List<InvoiceBodyDto> InvoiceBody = new List<InvoiceBodyDto>();
|
|
// foreach (var bitem in result.invoiceDetails)
|
|
// {
|
|
// InvoiceBodyDto item = new InvoiceBodyDto();
|
|
// PreparationBodyTaxInvoice preparationBody = new PreparationBodyTaxInvoice(bitem, level);
|
|
// #region body
|
|
|
|
// item = new InvoiceBodyDto
|
|
// {
|
|
// //شناسه کالا / خدمت
|
|
// Sstid = preparationBody.Sstid,
|
|
// //شرح کاال/خدمت
|
|
// Sstt = preparationBody.Sstt,
|
|
// // تعداد
|
|
// Am = preparationBody.Am,
|
|
// //واحد اندازه گیری
|
|
// Mu = preparationBody.Mu,
|
|
// //وزن خالص
|
|
// Nw= preparationBody.Nw,
|
|
// // مبلغ واحد
|
|
// Fee = preparationBody.Fee,
|
|
// //میزان ارز
|
|
// Cfee = preparationBody.Cfee ,
|
|
// //نوع ارز
|
|
// Cut = preparationBody.Cut,
|
|
// //نرخ برابری ارز با ریال
|
|
// Exr = preparationBody.Exr,
|
|
// // ارزش ریالی کاا
|
|
// Ssrv= preparationBody.Ssrv,
|
|
// // ارزش ارزی کاا
|
|
// Sscv= preparationBody.Sscv,
|
|
// //مبلغ قبل از تخفیف
|
|
// Prdis = preparationBody.Prdis,
|
|
// //مبلغ تخفیف
|
|
// Dis = preparationBody.Dis,
|
|
// //مبلغ بعد از تخفیف
|
|
// Adis = preparationBody.Adis,
|
|
// //نرخ مالیات بر ارزش افزوده
|
|
// Vra = preparationBody.Vra,
|
|
// //مبلغ مالیات بر ارزش افزوده
|
|
// Vam = preparationBody.Vam,
|
|
// //موضوع سایر مالیات و عوارض
|
|
// Odt = preparationBody.Odt,
|
|
// //نرخ سایر مالیات و عوارض
|
|
// Odr = preparationBody.Odr,
|
|
// //مبلغ سایر مالیات و عوارض
|
|
// Odam = preparationBody.Odam,
|
|
// //موضوع سایر وجوه قانونی
|
|
// Olt = preparationBody.Olt,
|
|
// //نرخ سایر وجوه قانونی
|
|
// Olr = preparationBody.Olr,
|
|
// //مبلغ سایر وجوه قانونی
|
|
// Olam = preparationBody.Olam,
|
|
// //اجرت ساخت
|
|
// Consfee = preparationBody.Consfee,
|
|
// // سود فروشنده
|
|
// Spro= preparationBody.Spro,
|
|
// //حقالعمل
|
|
// Bros= preparationBody.Bros,
|
|
// //جمع کل اجرت، حقالعمل و سود
|
|
// Tcpbs= preparationBody.Tcpbs,
|
|
// //سهم نقدی از پرداخت
|
|
// Cop = preparationBody.Cop,
|
|
// //سهم مالیات بر لرزش افزوده از پرداخت
|
|
// Vop = preparationBody.Vop,
|
|
// //شناسه یکتای ثبت قرارداد حق العمل کاری
|
|
// Bsrn = preparationBody.Bsrn,
|
|
// // مبلغ کل کالا / خدمت
|
|
// Tsstam = preparationBody.Tsstam,
|
|
// //عیار
|
|
// Cui = preparationBody.Cui,
|
|
// // نرخ خرید ارز
|
|
// Cpr = preparationBody.Cpr,
|
|
// //ماخذ مالیات بر ارزش افزوده در الگوی فروش ارز
|
|
// Sovat = preparationBody.Sovat
|
|
// };
|
|
// #endregion
|
|
// InvoiceBody.Add(item);
|
|
// }
|
|
|
|
|
|
// //Pay
|
|
// List<PaymentDto> InvoicePay = new List<PaymentDto>();
|
|
// if (result.setm==1 || result.setm == 3)
|
|
// {
|
|
// if (level != 10)
|
|
// foreach (var pitem in result.payments)
|
|
// {
|
|
|
|
// PaymentDto payment = new PaymentDto();
|
|
// payment = new PaymentDto
|
|
// {
|
|
// Iinn = pitem.iinn,
|
|
// Acn = pitem.acn,
|
|
// Trmn = pitem.trmn,
|
|
// Pmt = pitem.pmt,
|
|
// Trn = pitem.trn,
|
|
// Pcn = pitem.pcn,
|
|
// Pid = pitem.pid,
|
|
// Pdt = pitem.pdt,
|
|
// Pv = pitem.pv,
|
|
|
|
// };
|
|
|
|
// InvoicePay.Add(payment);
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var responseModel = await _actionTaxPayer.SendInvoice(user.RolUsers.First().CompanyID, header, InvoiceBody, InvoicePay);
|
|
// if (responseModel == null)
|
|
// {
|
|
// return BadRequest(new List<string> { "خطا در ورود به سامانه مودیان" });
|
|
// }
|
|
// else if (responseModel.Status == 200 && (responseModel.Body.Errors == null || responseModel.Body.Errors.Count == 0))
|
|
// {
|
|
// foreach (var item in responseModel.Body.Result)
|
|
// {
|
|
|
|
|
|
// var ressenttax = new SentTax
|
|
// {
|
|
// InvoiceID = result.ID,
|
|
// Date = DateTime.Now.ConvertMiladiToShamsi(),
|
|
// Time = $"{DateTime.Now.Hour}:{DateTime.Now.Minute}:{DateTime.Now.Second}",
|
|
// InvoiceType = result.invoiceType,
|
|
// ReferenceNumber = item.ReferenceNumber,
|
|
// uId = item.Uid,
|
|
// SentStatus = SentStatus.Send,
|
|
// InvoiceModel = JsonConvert.SerializeObject(result, Formatting.Indented, new JsonSerializerSettings
|
|
// {
|
|
// PreserveReferencesHandling = PreserveReferencesHandling.Objects
|
|
// }),
|
|
// ResponseModel = JsonConvert.SerializeObject(responseModel)
|
|
|
|
// };
|
|
// await _servTaxPayer.AddSentTax(ressenttax);
|
|
// }
|
|
// result.taxid = header.Taxid;
|
|
// result.irtaxid = header.Irtaxid;
|
|
// return Ok(await _servTaxPayer.UpdateInvoice(result));
|
|
// }
|
|
// else
|
|
// {
|
|
// string errors = "";
|
|
// foreach (var item in responseModel.Body.Errors)
|
|
// errors += '\n' + $"{item.ErrorCode}:{item.Detail}";
|
|
|
|
// return BadRequest(new List<string> { errors });
|
|
// }
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
//}
|
|
}
|
|
[HttpPost("GetAllSentTax")]
|
|
public async Task<ActionResult<PagingDto<SentTaxDto>>> GetSentTax([FromBody] ItemSerchGetSentTax item)
|
|
{
|
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
var UserID = claim.Value;
|
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
return Ok(await _servTaxPayer.GetSentTax(user.RolUsers.First().CompanyID, item));
|
|
}
|
|
[HttpGet("GetResult/{ID}")]
|
|
public async Task<ActionResult<DataInSendTaxDto>> GetResultByUid(int ID)
|
|
{
|
|
return BadRequest(new List<string> { "در حال حاضر سامانه مودیان در دسترس نمی باشد" });
|
|
|
|
//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.Unsuccessful && !string.IsNullOrEmpty(item.ErrorsModel))
|
|
// {
|
|
// List<MessageInSendTaxDto> inquiryerrorResult = JsonConvert.DeserializeObject<List<MessageInSendTaxDto>>(item.ErrorsModel);
|
|
|
|
// InquiryResultModel inquiryResult = JsonConvert.DeserializeObject<InquiryResultModel>(item.InquiryResultModel);
|
|
// if (inquiryResult.Data != null)
|
|
// {
|
|
|
|
// desData = new DataInSendTaxDto();
|
|
// desData.SentStatus = SentStatus.Unsuccessful;
|
|
// desData.error = inquiryerrorResult;
|
|
|
|
|
|
|
|
// }
|
|
// return Ok(desData);
|
|
// }
|
|
// else if (item.SentStatus == SentStatus.Send
|
|
// || item.SentStatus == SentStatus.pending
|
|
// || item.SentStatus == SentStatus.IN_PROGRESS
|
|
// || item.SentStatus == SentStatus.Unsuccessful)
|
|
// {
|
|
|
|
// //ta imja
|
|
// 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 (item.SentStatus == SentStatus.Unsuccessful)
|
|
// item.ErrorsModel = JsonConvert.SerializeObject(desData.error);
|
|
// }
|
|
|
|
|
|
// if (await _servTaxPayer.UpdateSentTax(item)) return Ok(desData);
|
|
|
|
// else return BadRequest(new List<string> { "خطای در ذخیره سازی" });
|
|
// }
|
|
// return BadRequest(new List<string> { "در این وضعیت امکان پذیر نمی باشد" });
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// return BadRequest(new List<string> { "خطای ناشناخته" });
|
|
//}
|
|
}
|
|
[HttpGet("GetBillTypes")]
|
|
public async Task<ActionResult<List<IdName<int>>>> GetBillTypes()
|
|
{
|
|
return Ok(await _servTaxPayer.GetBillTypes());
|
|
}
|
|
[HttpGet("GetPatterns")]
|
|
public async Task<ActionResult<List<IdName<int>>>> GetPatterns()
|
|
{
|
|
return Ok(await _servTaxPayer.GetPatterns(true));
|
|
}
|
|
[HttpGet("GetUnits")]
|
|
public async Task<ActionResult<List<IdName<int>>>> GetUnits()
|
|
{
|
|
return Ok(await _servTaxPayer.GetUnits());
|
|
}
|
|
[HttpGet("EconomicCodeInformation")]
|
|
public async Task<ActionResult<EconomicCodeModelDto>> GetEconomicCodeInformation(string item)
|
|
{
|
|
return BadRequest(new List<string> { "در حال حاضر سامانه مودیان در دسترس نمی باشد" });
|
|
|
|
//var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
//var UserID = claim.Value;
|
|
//var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
//if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID))
|
|
// return BadRequest(new List<string> { "خطا در احراز هویت سازمان مالیاتی" });
|
|
//var result=await _actionTaxPayer.GetEconomicCodeInformation(item);
|
|
//if (result == null) return NotFound();
|
|
//return Ok(result);
|
|
}
|
|
[HttpGet("FiscalInformation")]
|
|
public async Task<ActionResult<FiscalInformationModelDto>> GetFiscalInformation(string item)
|
|
{
|
|
return BadRequest(new List<string> { "در حال حاضر سامانه مودیان در دسترس نمی باشد" });
|
|
|
|
//var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
//var UserID = claim.Value;
|
|
//var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
//if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID))
|
|
// return BadRequest(new List<string> { "خطا در احراز هویت سازمان مالیاتی" });
|
|
//var result=await _actionTaxPayer.GetFiscalInformation(item);
|
|
//if (result == null) return NotFound();
|
|
//return Ok(result);
|
|
}
|
|
[HttpGet("CodInTaxPayerHaveBeenSentSuccessfully/{CODID}")]
|
|
public async Task<ActionResult<bool>> CodInTaxPayerHaveBeenSentSuccessfully(int CODID)
|
|
{
|
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
var UserID = claim.Value;
|
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
return Ok(await _servTaxPayer.AnyCodInTaxPayerHaveBeenSentSuccessfully(CODID, user.RolUsers.First().CompanyID));
|
|
}
|
|
[HttpGet("CustomerInTaxPayerHaveBeenSentSuccessfully/{CUSID}")]
|
|
public async Task<ActionResult<bool>> CustomerInTaxPayerHaveBeenSentSuccessfully(int CUSID)
|
|
{
|
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
|
var UserID = claim.Value;
|
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
|
return Ok(await _servTaxPayer.AnyCusInTaxPayerHaveBeenSentSuccessfully(CUSID, user.RolUsers.First().CompanyID));
|
|
}
|
|
}
|
|
}
|