...
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Service">
|
||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
||||
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -1,22 +1,35 @@
|
||||
using Back.Data.Models;
|
||||
using Back.Common;
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Org.BouncyCastle.Asn1.Cmp;
|
||||
using Shared.DTOs;
|
||||
using Shared.DTOs.Serch;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using TaxCollectData.Library.Dto.Content;
|
||||
using static Shared.DTOs._TaxPayer;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
|
||||
namespace Back.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class TaxPayerController : ControllerBase
|
||||
{
|
||||
private readonly servTaxPayer _servTaxPayer;
|
||||
private readonly servUser _servUser;
|
||||
public TaxPayerController(servTaxPayer servTaxPayer, servUser servUser)
|
||||
private readonly ActionTaxPayer _actionTaxPayer;
|
||||
public TaxPayerController(servTaxPayer servTaxPayer, servUser servUser, ActionTaxPayer actionTaxPayer)
|
||||
{
|
||||
_servTaxPayer = servTaxPayer;
|
||||
_servTaxPayer = servTaxPayer;
|
||||
_servUser = servUser;
|
||||
_actionTaxPayer = actionTaxPayer;
|
||||
}
|
||||
[HttpGet("GetInvoice/{ID}")]
|
||||
public async Task<ActionResult<_TaxPayer.Atemplatefield?>> Get(int ID)
|
||||
@@ -25,9 +38,9 @@ namespace Back.Controllers
|
||||
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> { "صورتحساب یافت نشد"});
|
||||
|
||||
if (result == null)
|
||||
return BadRequest(new List<string> { "صورتحساب یافت نشد" });
|
||||
|
||||
else
|
||||
{
|
||||
if (!result.PatternID.HasValue)
|
||||
@@ -37,19 +50,19 @@ namespace Back.Controllers
|
||||
return BadRequest(new List<string> { "صورتحساب در وضعیت پیش نویس نمیتواند ارسال شود" });
|
||||
|
||||
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result))
|
||||
return BadRequest(new List<string> { "این صورتحساب قبلا به سازمان ارسال شده"});
|
||||
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)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -67,23 +80,395 @@ namespace Back.Controllers
|
||||
|
||||
return Ok(await _servTaxPayer.PreparationInvoiceBeforeSending(item, result));
|
||||
}
|
||||
[HttpPost("CheckAuth")]
|
||||
public async Task<ActionResult<string>> CheckAuth([FromBody] CheckAuthDTO item)
|
||||
[HttpGet("CheckAuth")]
|
||||
public async Task<ActionResult<bool>> CheckAuth()
|
||||
{
|
||||
|
||||
if (item == null)
|
||||
return BadRequest("مدل صحیح نمی باشد");
|
||||
|
||||
using (ActionTaxPayer action = new ActionTaxPayer(item.UniqueMemory, item.PrivateKey))
|
||||
{
|
||||
if (action.login())
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
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 Ok();
|
||||
|
||||
return BadRequest();
|
||||
|
||||
}
|
||||
[HttpGet("SendInvoice/{InvoiceID}")]
|
||||
public async Task<ActionResult<bool>> SendInvoice(int InvoiceID)
|
||||
{
|
||||
|
||||
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> { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع به سامانه مودیان ارسال شده باشد" });
|
||||
|
||||
#region Inital Send
|
||||
InvoiceHeaderDto header = new InvoiceHeaderDto();
|
||||
#region header
|
||||
if (header.Inty == 1 && header.Inp == 1)
|
||||
header = new InvoiceHeaderDto
|
||||
{
|
||||
//نوع شخص خریدار
|
||||
Tob = result.tob,
|
||||
// صورتحساب نوع *
|
||||
Inty = result.inty ?? 1,
|
||||
//الگوی صورتحساب *
|
||||
Inp = result.inp ?? 1,
|
||||
//موضوع صورتحساب *
|
||||
Ins = result.ins ?? 1,
|
||||
//شماره منحصر به فرد مالیاتی
|
||||
Taxid = _actionTaxPayer.GenerateTaxid(result.inno, result.InvoiceDate.Replace("/", "").Trim()),
|
||||
//سریال صورت حساب
|
||||
Inno = result.inno ?? null,
|
||||
//شماره اقتصادی فروشنده به جاش شناسه ملی داده شد
|
||||
Tins = result.tins ?? null,
|
||||
//مجموع مبلغ قبل از کسر تخفیف
|
||||
Tprdis = result.tprdis ?? null,
|
||||
// مجموع مبلغ پس از کسر تخفیف
|
||||
Tadis = result.tadis ?? null,
|
||||
//مجموع مالیات بر ارزش افزوده
|
||||
Tvam = result.tvam ?? null,
|
||||
// مجموع سایر مالیات، عوارض و وجوه قانونی
|
||||
Todam = result.todam ?? null,
|
||||
//صورتحساب مجموع
|
||||
Tbill = result.tbill ?? null,
|
||||
// تسویه روش
|
||||
Setm = result.setm ?? null,
|
||||
//نقدی پرداختی مبلغ
|
||||
Cap = result.cap ?? null,
|
||||
//پرداختی نسیه
|
||||
Insp = result.insp ?? null,
|
||||
//مجموع تخفیفات
|
||||
Tdis = result.tdis ?? null,
|
||||
//شماره منحصر به فرد مالیاتی صورتحساب مرجع
|
||||
Irtaxid = result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair ? result.invoice.taxid : null,
|
||||
//شماره اقتصادی خریدار
|
||||
Tinb = result.tinb ?? null,
|
||||
//زمان صدور
|
||||
Indatim = result.indatim ?? null,
|
||||
//زمان ایجاد
|
||||
Indati2m = result.Indati2m ?? null,
|
||||
//کد شعبه خریدار
|
||||
Bbc = result.bbc ?? null,
|
||||
Tvop = result.tvop ?? null,
|
||||
Crn = result.crn ?? null,
|
||||
Tax17 = string.IsNullOrEmpty(result.seventeentax) ? null : Convert.ToDecimal(result.seventeentax),
|
||||
Scc = result.scc ?? null,
|
||||
Scln = result.scln ?? null,
|
||||
Bid = result.bid ?? null,
|
||||
};
|
||||
if (header.Inty == 1 && header.Inp == 2)
|
||||
header = new InvoiceHeaderDto
|
||||
{
|
||||
//نوع شخص خریدار
|
||||
Tob = result.tob,
|
||||
// صورتحساب نوع *
|
||||
Inty = result.inty ?? 1,
|
||||
//الگوی صورتحساب *
|
||||
Inp = result.inp ?? 1,
|
||||
//موضوع صورتحساب *
|
||||
Ins = result.ins ?? 1,
|
||||
//شماره منحصر به فرد مالیاتی
|
||||
Taxid = _actionTaxPayer.GenerateTaxid(result.inno, result.InvoiceDate.Replace("/", "").Trim()),
|
||||
//سریال صورت حساب
|
||||
Inno = result.inno ?? null,
|
||||
//شماره اقتصادی فروشنده به جاش شناسه ملی داده شد
|
||||
Tins = result.tins ?? null,
|
||||
//مجموع مبلغ قبل از کسر تخفیف
|
||||
Tprdis = result.tprdis ?? null,
|
||||
// مجموع مبلغ پس از کسر تخفیف
|
||||
Tadis = result.tadis ?? null,
|
||||
//مجموع مالیات بر ارزش افزوده
|
||||
Tvam = result.tvam ?? null,
|
||||
// مجموع سایر مالیات، عوارض و وجوه قانونی
|
||||
Todam = result.todam ?? null,
|
||||
//صورتحساب مجموع
|
||||
Tbill = result.tbill ?? null,
|
||||
// تسویه روش
|
||||
Setm = result.setm ?? null,
|
||||
//نقدی پرداختی مبلغ
|
||||
Cap = result.cap ?? null,
|
||||
//پرداختی نسیه
|
||||
Insp = result.insp ?? null,
|
||||
//مجموع تخفیفات
|
||||
Tdis = result.tdis ?? null,
|
||||
//شماره منحصر به فرد مالیاتی صورتحساب مرجع
|
||||
Irtaxid = result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair ? result.invoice.taxid : null,
|
||||
//شماره اقتصادی خریدار
|
||||
Tinb = result.tinb ?? null,
|
||||
//زمان صدور
|
||||
Indatim = result.indatim ?? null,
|
||||
//زمان ایجاد
|
||||
Indati2m = result.Indati2m ?? null,
|
||||
//کد شعبه خریدار
|
||||
Bbc = result.bbc ?? null,
|
||||
Tvop = result.tvop ?? null,
|
||||
Crn = result.crn ?? null,
|
||||
Tax17 = string.IsNullOrEmpty(result.seventeentax) ? null : Convert.ToDecimal(result.seventeentax),
|
||||
Scc = result.scc ?? null,
|
||||
Scln = result.scln ?? null,
|
||||
Bpn = result.bpn ?? null,
|
||||
Bid = result.bid ?? null,
|
||||
};
|
||||
if (header.Inty == 1 && header.Inp == 3)
|
||||
header = new InvoiceHeaderDto
|
||||
{
|
||||
//نوع شخص خریدار
|
||||
Tob = result.tob,
|
||||
// صورتحساب نوع *
|
||||
Inty = result.inty ?? 1,
|
||||
//الگوی صورتحساب *
|
||||
Inp = result.inp ?? 1,
|
||||
//موضوع صورتحساب *
|
||||
Ins = result.ins ?? 1,
|
||||
//شماره منحصر به فرد مالیاتی
|
||||
Taxid = _actionTaxPayer.GenerateTaxid(result.inno, result.InvoiceDate.Replace("/", "").Trim()),
|
||||
//سریال صورت حساب
|
||||
Inno = result.inno ?? null,
|
||||
//شماره اقتصادی فروشنده به جاش شناسه ملی داده شد
|
||||
Tins = result.tins ?? null,
|
||||
//مجموع مبلغ قبل از کسر تخفیف
|
||||
Tprdis = result.tprdis ?? null,
|
||||
// مجموع مبلغ پس از کسر تخفیف
|
||||
Tadis = result.tadis ?? null,
|
||||
//مجموع مالیات بر ارزش افزوده
|
||||
Tvam = result.tvam ?? null,
|
||||
// مجموع سایر مالیات، عوارض و وجوه قانونی
|
||||
Todam = result.todam ?? null,
|
||||
//صورتحساب مجموع
|
||||
Tbill = result.tbill ?? null,
|
||||
// تسویه روش
|
||||
Setm = result.setm ?? null,
|
||||
//نقدی پرداختی مبلغ
|
||||
Cap = result.cap ?? null,
|
||||
//پرداختی نسیه
|
||||
Insp = result.insp ?? null,
|
||||
//مجموع تخفیفات
|
||||
Tdis = result.tdis ?? null,
|
||||
//شماره منحصر به فرد مالیاتی صورتحساب مرجع
|
||||
Irtaxid = result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair ? result.invoice.taxid : null,
|
||||
//شماره اقتصادی خریدار
|
||||
Tinb = result.tinb ?? null,
|
||||
//زمان صدور
|
||||
Indatim = result.indatim ?? null,
|
||||
//زمان ایجاد
|
||||
Indati2m = result.Indati2m ?? null,
|
||||
//کد شعبه خریدار
|
||||
Bbc = result.bbc ?? null,
|
||||
Tvop = result.tvop ?? null,
|
||||
Crn = result.crn ?? null,
|
||||
Tax17 = string.IsNullOrEmpty(result.seventeentax) ? null : Convert.ToDecimal(result.seventeentax),
|
||||
Bid = result.bid ?? null,
|
||||
};
|
||||
#endregion header
|
||||
List<InvoiceBodyDto> InvoiceBody = new List<InvoiceBodyDto>();
|
||||
foreach (var bitem in result.invoiceDetails)
|
||||
{
|
||||
InvoiceBodyDto item=new InvoiceBodyDto();
|
||||
#region body
|
||||
if (header.Inty==1 && header.Inp==1)
|
||||
item = new InvoiceBodyDto
|
||||
{
|
||||
//شناسه کالا / خدمت
|
||||
Sstid = bitem.sstid,
|
||||
//شرح کاال/خدمت
|
||||
Sstt = bitem.sstt,
|
||||
//واحد اندازه گیری
|
||||
Mu = bitem.mu,
|
||||
// تعداد
|
||||
Am = bitem.am,
|
||||
// مبلغ واحد
|
||||
Fee = bitem.fee,
|
||||
//مبلغ قبل از تخفیف
|
||||
Prdis = bitem.prdis,
|
||||
//مبلغ تخفیف
|
||||
Dis = bitem.dis,
|
||||
//مبلغ بعد از تخفیف
|
||||
Adis = bitem.adis,
|
||||
//نرخ مالیات بر ارزش افزوده
|
||||
Vra = bitem.vra,
|
||||
//مبلغ مالیات بر ارزش افزوده
|
||||
Vam = bitem.vam,
|
||||
// مبلغ کل کالا / خدمت
|
||||
Tsstam = bitem.tsstam,
|
||||
Cfee = bitem.cfee,
|
||||
Cut = bitem.cut,
|
||||
Exr = bitem.exr,
|
||||
Odt = bitem.odt,
|
||||
Odr = bitem.odr,
|
||||
Odam = bitem.odam,
|
||||
Olt = bitem.olt,
|
||||
Olr = bitem.olr,
|
||||
Olam = bitem.olam,
|
||||
Cop = bitem.cop,
|
||||
Vop = bitem.vop,
|
||||
Bsrn = bitem.bsrn,
|
||||
|
||||
|
||||
};
|
||||
|
||||
else if (header.Inty == 1 && header.Inp == 2)
|
||||
item = new InvoiceBodyDto
|
||||
{
|
||||
//شناسه کالا / خدمت
|
||||
Sstid = bitem.sstid,
|
||||
//شرح کاال/خدمت
|
||||
Sstt = bitem.sstt,
|
||||
//واحد اندازه گیری
|
||||
Mu = bitem.mu,
|
||||
// تعداد
|
||||
Am = bitem.am,
|
||||
// مبلغ واحد
|
||||
Fee = bitem.fee,
|
||||
//مبلغ قبل از تخفیف
|
||||
Prdis = bitem.prdis,
|
||||
//مبلغ تخفیف
|
||||
Dis = bitem.dis,
|
||||
//مبلغ بعد از تخفیف
|
||||
Adis = bitem.adis,
|
||||
//نرخ مالیات بر ارزش افزوده
|
||||
Vra = bitem.vra,
|
||||
//مبلغ مالیات بر ارزش افزوده
|
||||
Vam = bitem.vam,
|
||||
// مبلغ کل کالا / خدمت
|
||||
Tsstam = bitem.tsstam,
|
||||
Cfee = bitem.cfee,
|
||||
Cut = bitem.cut,
|
||||
Exr = bitem.exr,
|
||||
Odt = bitem.odt,
|
||||
Odr = bitem.odr,
|
||||
Odam = bitem.odam,
|
||||
Olt = bitem.olt,
|
||||
Olr = bitem.olr,
|
||||
Olam = bitem.olam,
|
||||
Cop = bitem.cop,
|
||||
Vop = bitem.vop,
|
||||
Bsrn = bitem.bsrn,
|
||||
|
||||
|
||||
};
|
||||
|
||||
else if(header.Inty == 1 && header.Inp == 3)
|
||||
item = new InvoiceBodyDto
|
||||
{
|
||||
//شناسه کالا / خدمت
|
||||
Sstid = bitem.sstid,
|
||||
//شرح کاال/خدمت
|
||||
Sstt = bitem.sstt,
|
||||
//واحد اندازه گیری
|
||||
Mu = bitem.mu,
|
||||
// تعداد
|
||||
Am = bitem.am,
|
||||
// مبلغ واحد
|
||||
Fee = bitem.fee,
|
||||
//مبلغ قبل از تخفیف
|
||||
Prdis = bitem.prdis,
|
||||
//مبلغ تخفیف
|
||||
Dis = bitem.dis,
|
||||
//مبلغ بعد از تخفیف
|
||||
Adis = bitem.adis,
|
||||
//نرخ مالیات بر ارزش افزوده
|
||||
Vra = bitem.vra,
|
||||
//مبلغ مالیات بر ارزش افزوده
|
||||
Vam = bitem.vam,
|
||||
// مبلغ کل کالا / خدمت
|
||||
Tsstam = bitem.tsstam,
|
||||
Cfee = bitem.cfee,
|
||||
Cut = bitem.cut,
|
||||
Exr = bitem.exr,
|
||||
Odt = bitem.odt,
|
||||
Odr = bitem.odr,
|
||||
Odam = bitem.odam,
|
||||
Olt = bitem.olt,
|
||||
Olr = bitem.olr,
|
||||
Olam = bitem.olam,
|
||||
Cop = bitem.cop,
|
||||
Vop = bitem.vop,
|
||||
Bsrn = bitem.bsrn,
|
||||
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 { });
|
||||
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),
|
||||
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(_servTaxPayer.GetSentTax(user.RolUsers.First().CompanyID,item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -74,6 +74,7 @@ builder.Services.AddScoped<servInvoice>();
|
||||
builder.Services.AddScoped<AddOrUpdateInvoiceValidation>();
|
||||
builder.Services.AddScoped<AUInvoiceItemValidation>();
|
||||
builder.Services.AddScoped<servInvoiceItem>();
|
||||
builder.Services.AddScoped<ActionTaxPayer>();
|
||||
builder.Services.AddScoped(c => new mpNuget.RestClient("09119660045", "C54S2"));
|
||||
|
||||
string origins = "OriginTaxPayer";
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Back.Common;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using TaxCollectData.Library.Business;
|
||||
using TaxCollectData.Library.Dto.Config;
|
||||
using TaxCollectData.Library.Dto.Content;
|
||||
@@ -8,32 +9,23 @@ using TaxCollectData.Library.Enums;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
public class ActionTaxPayer : IDisposable
|
||||
public class ActionTaxPayer
|
||||
{
|
||||
private string _UniqueMemory;
|
||||
public ActionTaxPayer(string UniqueMemory, string PrivateKey)
|
||||
private string _PrivateKey;
|
||||
private readonly servCompany _servCompany;
|
||||
public ActionTaxPayer(servCompany servCompany)
|
||||
{
|
||||
#region TokenTax
|
||||
if (!string.IsNullOrEmpty(UniqueMemory) && !string.IsNullOrEmpty(PrivateKey))
|
||||
{
|
||||
_UniqueMemory = UniqueMemory;
|
||||
|
||||
TaxApiService.Instance.Init(UniqueMemory,
|
||||
new SignatoryConfig(PrivateKey, null),
|
||||
new NormalProperties(ClientType.SELF_TSP), "https://tp.tax.gov.ir/req/api/");
|
||||
TaxApiService.Instance.TaxApis.GetServerInformation();
|
||||
}
|
||||
#endregion
|
||||
_servCompany = servCompany;
|
||||
}
|
||||
public string GenerateTaxid(string FactorNo, string InvoiceDate)
|
||||
{
|
||||
return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory,
|
||||
Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi());
|
||||
}
|
||||
|
||||
public InquiryResultModel GetResultByUid(string uid)
|
||||
public async Task<InquiryResultModel> GetResultByUid(int CompanyID, string uid)
|
||||
{
|
||||
if (!login())
|
||||
if (!await login(CompanyID))
|
||||
return null;
|
||||
var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory);
|
||||
var inquiryResultModels = TaxApiService.Instance.TaxApis.InquiryByUidAndFiscalId(new() { uidAndFiscalId });
|
||||
@@ -41,45 +33,58 @@ namespace Back.Services
|
||||
return inquiryResultModels[0];
|
||||
return null;
|
||||
}
|
||||
public TaxCollectData.Library.Dto.HttpResponse<AsyncResponseModel> SendInvoice(InvoiceHeaderDto header, List<InvoiceBodyDto> InvoiceBody, PaymentDto payment)
|
||||
public async Task<TaxCollectData.Library.Dto.HttpResponse<AsyncResponseModel>> SendInvoice(int CompanyID,InvoiceHeaderDto header, List<InvoiceBodyDto> InvoiceBody, PaymentDto payment)
|
||||
{
|
||||
if (!login())
|
||||
if (!await login(CompanyID))
|
||||
return null;
|
||||
return TaxApiService.Instance.TaxApis.SendInvoices(new List<InvoiceDto>()
|
||||
return await TaxApiService.Instance.TaxApis.SendInvoicesAsync(new List<InvoiceDto>()
|
||||
{
|
||||
new InvoiceDto()
|
||||
new()
|
||||
{
|
||||
Header =header,Body =InvoiceBody,Payments = new() {payment}
|
||||
}
|
||||
}
|
||||
, null);
|
||||
}
|
||||
public EconomicCodeModel? GetEconomicCodeInformation(string Item)
|
||||
public async Task<EconomicCodeModel?> GetEconomicCodeInformation(string Item)
|
||||
{
|
||||
return TaxApiService.Instance.TaxApis.GetEconomicCodeInformation(Item);
|
||||
return await TaxApiService.Instance.TaxApis.GetEconomicCodeInformationAsync(Item);
|
||||
}
|
||||
//-------------------internal
|
||||
public bool login()
|
||||
public async Task<bool> login(int CompanyID)
|
||||
{
|
||||
try
|
||||
{
|
||||
#region TokenTax
|
||||
var resquth = await _servCompany.GetTaxAuth(CompanyID);
|
||||
if (string.IsNullOrEmpty(resquth.UniqueMemory) || string.IsNullOrEmpty(resquth.PrivateKey))
|
||||
return false;
|
||||
|
||||
if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey))
|
||||
{
|
||||
_UniqueMemory = resquth.UniqueMemory;
|
||||
_PrivateKey = resquth.PrivateKey;
|
||||
TaxApiService.Instance.Init(_UniqueMemory,
|
||||
new SignatoryConfig(_PrivateKey, null),
|
||||
new NormalProperties(ClientType.SELF_TSP), "https://tp.tax.gov.ir/req/api/");
|
||||
await TaxApiService.Instance.TaxApis.GetServerInformationAsync();
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (TaxApiService.Instance.TaxApis.GetToken() is null)
|
||||
{
|
||||
if(TaxApiService.Instance.TaxApis.RequestToken()==null)
|
||||
return false;
|
||||
if (await TaxApiService.Instance.TaxApis.RequestTokenAsync() == null)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -18,38 +18,38 @@ namespace Back.Services
|
||||
_repoCompany = repoCompany;
|
||||
_repoRolUser = repoRolUser;
|
||||
}
|
||||
public async Task<bool> ExsistCompanyByComoanyIDandUserID(int ComoanyID, int UserID,bool InAdmin=false)
|
||||
public async Task<bool> ExsistCompanyByComoanyIDandUserID(int ComoanyID, int UserID, bool InAdmin = false)
|
||||
{
|
||||
var res= _repoRolUser.Get(w => w.CompanyID == ComoanyID && w.UserID == UserID && w.Company.IsActive);
|
||||
var res = _repoRolUser.Get(w => w.CompanyID == ComoanyID && w.UserID == UserID && w.Company.IsActive);
|
||||
if (InAdmin)
|
||||
res = res.Where( w=> w.IsAdmin);
|
||||
res = res.Where(w => w.IsAdmin);
|
||||
|
||||
return await res.AnyAsync();
|
||||
return await res.AnyAsync();
|
||||
}
|
||||
public async Task<CompanyDTO?> GetCompany(int ComoanyID)
|
||||
{
|
||||
return await _repoCompany.Get(w => w.ID == ComoanyID && w.IsActive)
|
||||
.Select(s=>new CompanyDTO()
|
||||
{
|
||||
BranchID = s.BranchID,
|
||||
EconomicCode = s.EconomicCode,
|
||||
ID = s.ID,
|
||||
Email = s.Email,
|
||||
Logo= s.Logo==null ?null: System.Text.Encoding.UTF8.GetString(s.Logo) ,
|
||||
Mobile = s.Mobile,
|
||||
Name = s.Name,
|
||||
Phone = s.Phone,
|
||||
PrivateKey= s.PrivateKey,
|
||||
UniqeMemory = s.UniqeMemory
|
||||
}).FirstOrDefaultAsync();
|
||||
return await _repoCompany.Get(w => w.ID == ComoanyID && w.IsActive)
|
||||
.Select(s => new CompanyDTO()
|
||||
{
|
||||
BranchID = s.BranchID,
|
||||
EconomicCode = s.EconomicCode,
|
||||
ID = s.ID,
|
||||
Email = s.Email,
|
||||
Logo = s.Logo == null ? null : System.Text.Encoding.UTF8.GetString(s.Logo),
|
||||
Mobile = s.Mobile,
|
||||
Name = s.Name,
|
||||
Phone = s.Phone,
|
||||
PrivateKey = s.PrivateKey,
|
||||
UniqeMemory = s.UniqeMemory
|
||||
}).FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<Company?> GetCompanyOrg(int ComoanyID,bool IsActive=true)
|
||||
public async Task<Company?> GetCompanyOrg(int ComoanyID, bool IsActive = true)
|
||||
{
|
||||
var inv = _repoCompany.Get(w => w.ID == ComoanyID);
|
||||
if (IsActive)
|
||||
inv= inv.Where(w=>w.IsActive);
|
||||
|
||||
return await inv.FirstOrDefaultAsync();
|
||||
inv = inv.Where(w => w.IsActive);
|
||||
|
||||
return await inv.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<Company?> GetCompanyOrgByMobileAndCompanynotActive(string Mobile)
|
||||
{
|
||||
@@ -72,16 +72,16 @@ namespace Back.Services
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
|
||||
if (item.ID == null || item.ID ==0)
|
||||
if (item.ID == null || item.ID == 0)
|
||||
{
|
||||
return await _repoCompany.AddAsync(item);
|
||||
return await _repoCompany.AddAsync(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _repoCompany.UpdateByObjAsync(item);
|
||||
return await _repoCompany.UpdateByObjAsync(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -144,15 +144,23 @@ namespace Back.Services
|
||||
|
||||
}
|
||||
}
|
||||
public async Task<bool> ExistMobileInCompany(string mobile,bool IsActive=true)
|
||||
public async Task<bool> ExistMobileInCompany(string mobile, bool IsActive = true)
|
||||
{
|
||||
var resquest= _repoCompany.GetAll().Where(w => w.Mobile == mobile );
|
||||
var resquest = _repoCompany.GetAll().Where(w => w.Mobile == mobile);
|
||||
if (IsActive)
|
||||
resquest = resquest.Where(w => w.IsActive);
|
||||
|
||||
|
||||
return await resquest.AnyAsync();
|
||||
}
|
||||
|
||||
public async Task<CheckAuthDTO> GetTaxAuth(int ComoanyID)
|
||||
{
|
||||
return await _repoCompany.Get(w => w.ID == ComoanyID && w.IsActive)
|
||||
.Select(s => new CheckAuthDTO()
|
||||
{
|
||||
PrivateKey = s.PrivateKey,
|
||||
UniqueMemory = s.UniqeMemory
|
||||
}).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -3,6 +3,9 @@ using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Back.Common;
|
||||
using Shared;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
using Shared.DTOs.Serch;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
@@ -48,7 +51,10 @@ namespace Back.Services
|
||||
return await _repoPattern.Get(w=>w.Status).Select(s => new IdName<int> { ID = s.ID, Title = s.Title }).ToListAsync();
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateInvoice(Invoice invoice)
|
||||
{
|
||||
return await _invoiceRepo.UpdateAsync(invoice);
|
||||
}
|
||||
public async Task<Invoice?> GetInvoice(int CompanyID, int ID)
|
||||
{
|
||||
#region AdvancedSearch
|
||||
@@ -71,7 +77,10 @@ namespace Back.Services
|
||||
.ThenInclude(inc => inc.CODUnit)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> AddSentTax(SentTax sentTax)
|
||||
{
|
||||
return await _repoSentTax.AddBoolResultAsync(sentTax);
|
||||
}
|
||||
public async Task<_TaxPayer.Atemplatefield> GetFildInvoiceForPreparation(Invoice InvoiceItem)
|
||||
{
|
||||
_TaxPayer.Atemplatefield ret = new _TaxPayer.Atemplatefield();
|
||||
@@ -192,6 +201,35 @@ namespace Back.Services
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async Task<PagingDto<SentTaxDto>> GetSentTax(int CompanyID, ItemSerchGetSentTax itemSerchGetSentTax)
|
||||
{
|
||||
var request = _repoSentTax.Get(w => w.invoice.CompanyID == CompanyID);
|
||||
|
||||
if (itemSerchGetSentTax.ID.HasValue)
|
||||
request = request.Where(w => w.ID == itemSerchGetSentTax.ID.Value);
|
||||
|
||||
if (itemSerchGetSentTax.invoiceType.HasValue)
|
||||
request = request.Where(w => w.invoice.invoiceType == itemSerchGetSentTax.invoiceType.Value);
|
||||
|
||||
if (itemSerchGetSentTax.SentStatus.HasValue)
|
||||
request = request.Where(w => w.SentStatus == itemSerchGetSentTax.SentStatus.Value);
|
||||
|
||||
if (itemSerchGetSentTax.InvoiceID.HasValue)
|
||||
request = request.Where(w => w.InvoiceID == itemSerchGetSentTax.InvoiceID.Value);
|
||||
|
||||
return await request.OrderByDescending(o=>o.ID)
|
||||
.Select(s => new SentTaxDto
|
||||
{
|
||||
Date = s.Date.ShamciToFormatShamciinFront(),
|
||||
Time = s.Time,
|
||||
ID = s.ID,
|
||||
InvoiceID = s.InvoiceID,
|
||||
SentStatus=s.SentStatus,
|
||||
msgInvoiceType = s.InvoiceType.GetDisplayName(),
|
||||
msgSentStatus = s.SentStatus.GetDisplayName()
|
||||
|
||||
}).Paging(itemSerchGetSentTax.PageIndex, itemSerchGetSentTax.PageSize);
|
||||
}
|
||||
private void SetValue<T>(_TaxPayer.Fild fild, ref T obj)
|
||||
{
|
||||
|
20
Shared/DTOs/SentTaxDto.cs
Normal file
20
Shared/DTOs/SentTaxDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class SentTaxDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int InvoiceID { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Time { get; set; }
|
||||
public SentStatus SentStatus { get; set; }
|
||||
public string msgInvoiceType { get; set; }
|
||||
public string msgSentStatus { get; set; }
|
||||
}
|
||||
}
|
20
Shared/DTOs/Serch/ItemSerchGetSentTax.cs
Normal file
20
Shared/DTOs/Serch/ItemSerchGetSentTax.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.DTOs.Serch
|
||||
{
|
||||
public class ItemSerchGetSentTax : IFildGlobalItemSerch
|
||||
{
|
||||
[Display(Name = "شناسه")]
|
||||
public int? ID { get; set; }
|
||||
public int? InvoiceID { get; set; }
|
||||
public InvoiceType? invoiceType { get; set; }
|
||||
public SentStatus? SentStatus { get; set; }
|
||||
public int PageIndex { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 5;
|
||||
}
|
||||
}
|
@@ -2,7 +2,166 @@
|
||||
@inject HttpClientController hc;
|
||||
@layout PanelLayout
|
||||
@page "/TaxPayer"
|
||||
@page "/TaxPayer/{routed:int}"
|
||||
@using Front.Services
|
||||
@code {
|
||||
@using Shared
|
||||
@using Shared.DTOs
|
||||
@using Shared.DTOs.Serch
|
||||
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
@* search *@
|
||||
<div class="row">
|
||||
<h4 class="fw-bold py-3 mb-4">
|
||||
<span class="text-muted fw-light">سرویس ها /</span> سامانه مودیان
|
||||
</h4>
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-2">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ul class="list-group fa-padding" style="border: 2px solid #0d6efd">
|
||||
<li class="list-group-item" data-toggle="modal" data-target="#issue">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-1">
|
||||
<input @bind-value="itemsearch.ID" placeholder="شناسه" style="text-align:center;" class="form-control" type="text">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<input @bind-value="itemsearch.InvoiceID" placeholder="شناسه صورتحساب" style="text-align:center;" class="form-control" type="text">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select @bind="itemsearch.invoiceType" class="form-control" aria-label="Default select example">
|
||||
<option value="100" style="color: #b5b5b5" selected>نوع صورتحساب...</option>
|
||||
@foreach (InvoiceType i in Enum.GetValues(typeof(InvoiceType)))
|
||||
{
|
||||
|
||||
<option value="@Convert.ToInt32(i)">@i.GetEnumDisplayName()</option>
|
||||
|
||||
|
||||
}
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select @bind="itemsearch.SentStatus" class="form-control" aria-label="Default select example">
|
||||
<option value="100" style="color: #b5b5b5" selected>وضعیت...</option>
|
||||
@foreach (SentStatus i in Enum.GetValues(typeof(SentStatus)))
|
||||
{
|
||||
|
||||
<option value="@Convert.ToInt32(i)">@i.GetEnumDisplayName()</option>
|
||||
|
||||
|
||||
}
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
||||
<Icon Name="@alertIconName" class="me-2"></Icon>
|
||||
@alertMessage
|
||||
</Alert>
|
||||
|
||||
</div>
|
||||
@* data *@
|
||||
@if (request != null)
|
||||
{
|
||||
<LTable ModelinComponent="request?.list" OnMultipleOfThree="EventCallback.Factory.Create<int>(this,SentTaxItem)" />
|
||||
@* pagination *@
|
||||
<p style="color:red">@request?.RowCount آیتم یافت شد</p>
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination justify-content-center">
|
||||
@for (int page = 1; page <= request?.PageCount; page++)
|
||||
{
|
||||
if (page == PageIndex)
|
||||
{
|
||||
<li class="page-item active">
|
||||
<a class="page-link" href="@hc._nav.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="@hc._nav.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||
ItemSerchGetSentTax itemsearch = new ItemSerchGetSentTax();
|
||||
public int? routed { get; set; } = 0;
|
||||
// alert
|
||||
AlertColor alertColor = AlertColor.Primary;
|
||||
IconName alertIconName = IconName.CheckCircleFill;
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
[Parameter, SupplyParameterFromQuery]
|
||||
public int? PageIndex { get; set; }
|
||||
public Shared.DTOs.PagingDto<SentTaxDto>? request { get; set; }
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (routed.HasValue && routed > 0)
|
||||
{
|
||||
ShowSuccessAlert($"صورتحساب شماره {routed} با موفقیت ارسال شد " +'\n'+
|
||||
"برای برای 'نمایش وضعیت' آن را تعیین وضعیت کنید");
|
||||
itemsearch.InvoiceID = routed.Value;
|
||||
}
|
||||
|
||||
if (PageIndex == null) PageIndex = 1;
|
||||
await Load(PageIndex.Value);
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions{
|
||||
public async Task SentTaxItem(int ID)
|
||||
{
|
||||
|
||||
}
|
||||
public async Task Load(int pi)
|
||||
{
|
||||
itemsearch.PageSize = 10;
|
||||
itemsearch.PageIndex = pi;
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Post<ItemSerchGetSentTax>("TaxPayer/GetAllSentTax", itemsearch);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
request = await rsp.Content.ReadFromJsonAsync<PagingDto<SentTaxDto>>();
|
||||
}
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.Forbidden)
|
||||
{
|
||||
ShowDangerAlert("شما دسترسی به خواندن اطلاعات صورتحساب را نداربد");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
PreloadService.Hide();
|
||||
}
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
alertColor = AlertColor.Success;
|
||||
alertIconName = IconName.CheckCircleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
private void ShowDangerAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
alertColor = AlertColor.Danger;
|
||||
alertIconName = IconName.ExclamationTriangleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
}
|
@@ -5,8 +5,9 @@
|
||||
@inject HttpClientController hc;
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
<Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
|
||||
<Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
|
||||
<PageTitle>آماده سازی صورتحساب</PageTitle>
|
||||
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
||||
@@ -228,27 +229,66 @@
|
||||
};
|
||||
public async Task Send()
|
||||
{
|
||||
var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/PreparationInvoiceBeforeSending", invoice);
|
||||
if (!await CheckAuth())
|
||||
{
|
||||
ShowMessage(ToastType.Danger, "خطا در احراز هویت سازمان مالیاتی");
|
||||
}
|
||||
else
|
||||
{
|
||||
var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/PreparationInvoiceBeforeSending", invoice);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var response = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (response)
|
||||
{
|
||||
ShowMessage(ToastType.Success, "آماده سازی با موفقیت انجام شد");
|
||||
ShowMessage(ToastType.Light, "در حال ارسال صورتحساب");
|
||||
rsp = await hc.Get($"TaxPayer/SendInvoice/{InvoiceID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
response = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (response)
|
||||
{
|
||||
hc._nav.NavigateTo($"TaxPayer/{InvoiceID}");
|
||||
// ShowMessage(ToastType.Success, "ارسال با موفقیت انجام شد");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(ToastType.Danger, "خطای در ارسال رخ داده");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowMessage(ToastType.Danger, request[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(ToastType.Danger, "خطای در آماده سازی اطلاعات رخ داده");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowMessage(ToastType.Danger, request[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<bool> CheckAuth()
|
||||
{
|
||||
var rsp = await hc.Get($"TaxPayer/CheckAuth");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var response = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (response)
|
||||
{
|
||||
ShowMessage(ToastType.Success, "آماده سازی با موفقیت انجام شد");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(ToastType.Danger, "خطای در آماده سازی اطلاعات رخ داده");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
|
@@ -34,9 +34,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
|
||||
}) ;
|
||||
|
||||
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||
|
||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
||||
|
||||
|
Reference in New Issue
Block a user