...
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Service">
|
<Reference Include="Service">
|
||||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ using Back.Services;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Shared.DTOs;
|
using Shared.DTOs;
|
||||||
|
using static Shared.DTOs._TaxPayer;
|
||||||
|
|
||||||
namespace Back.Controllers
|
namespace Back.Controllers
|
||||||
{
|
{
|
||||||
@@ -53,5 +54,18 @@ namespace Back.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[HttpPost("PreparationInvoiceBeforeSending")]
|
||||||
|
public async Task<ActionResult<bool>> 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> { "صورتحساب یافت نشد" });
|
||||||
|
|
||||||
|
|
||||||
|
return Ok(await _servTaxPayer.PreparationInvoiceBeforeSending(item, result));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,12 +11,14 @@ namespace Back.Services
|
|||||||
private readonly IAsyncRepository<SentTax> _repoSentTax;
|
private readonly IAsyncRepository<SentTax> _repoSentTax;
|
||||||
private readonly IAsyncRepository<Pattern> _repoPattern;
|
private readonly IAsyncRepository<Pattern> _repoPattern;
|
||||||
private readonly IAsyncRepository<Invoice> _invoiceRepo;
|
private readonly IAsyncRepository<Invoice> _invoiceRepo;
|
||||||
|
private readonly IAsyncRepository<InvoiceItem> _invoiceitemRepo;
|
||||||
private readonly IAsyncRepository<FildModeInPattern> _fildModeInPatternRepo;
|
private readonly IAsyncRepository<FildModeInPattern> _fildModeInPatternRepo;
|
||||||
private readonly IAsyncRepository<Coding> _codingRepo;
|
private readonly IAsyncRepository<Coding> _codingRepo;
|
||||||
private readonly IAsyncRepository<SpecialCondition> _specialConditionRepo;
|
private readonly IAsyncRepository<SpecialCondition> _specialConditionRepo;
|
||||||
public servTaxPayer(IAsyncRepository<SentTax> repoSentTax, IAsyncRepository<Pattern> repoPattern
|
public servTaxPayer(IAsyncRepository<SentTax> repoSentTax, IAsyncRepository<Pattern> repoPattern
|
||||||
, IAsyncRepository<Invoice> invoiceRepo, IAsyncRepository<FildModeInPattern> fildModeInPatternRepo
|
, IAsyncRepository<Invoice> invoiceRepo, IAsyncRepository<FildModeInPattern> fildModeInPatternRepo
|
||||||
, IAsyncRepository<Coding> codingRepo, IAsyncRepository<SpecialCondition> specialConditionRepo)
|
, IAsyncRepository<Coding> codingRepo, IAsyncRepository<SpecialCondition> specialConditionRepo
|
||||||
|
, IAsyncRepository<InvoiceItem> invoiceitemRepo)
|
||||||
{
|
{
|
||||||
_repoSentTax = repoSentTax;
|
_repoSentTax = repoSentTax;
|
||||||
_repoPattern = repoPattern;
|
_repoPattern = repoPattern;
|
||||||
@@ -24,6 +26,7 @@ namespace Back.Services
|
|||||||
_fildModeInPatternRepo = fildModeInPatternRepo;
|
_fildModeInPatternRepo = fildModeInPatternRepo;
|
||||||
_codingRepo = codingRepo;
|
_codingRepo = codingRepo;
|
||||||
_specialConditionRepo = specialConditionRepo;
|
_specialConditionRepo = specialConditionRepo;
|
||||||
|
_invoiceitemRepo = invoiceitemRepo;
|
||||||
}
|
}
|
||||||
public async Task<bool> ExistSuccessfulorSendorpendingInvoiceinCompanyID(int CompanyID)
|
public async Task<bool> ExistSuccessfulorSendorpendingInvoiceinCompanyID(int CompanyID)
|
||||||
{
|
{
|
||||||
@@ -86,7 +89,7 @@ namespace Back.Services
|
|||||||
ModeID = s.FildModeID,
|
ModeID = s.FildModeID,
|
||||||
ModeTitle = s.FildMode.Title,
|
ModeTitle = s.FildMode.Title,
|
||||||
Title = s.Fild.Title,
|
Title = s.Fild.Title,
|
||||||
InputBox = s.Fild.Name == "indatim" || s.Fild.Name == "Indati2m" || s.Fild.Name == "cdcd" ? "fild" : s.Fild.InputBox
|
InputBox = s.Fild.Name == "indatim" || s.Fild.Name == "Indati2m" || s.Fild.Name == "cdcd" ? "autofild" : s.Fild.InputBox
|
||||||
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
foreach (_TaxPayer.Fild item in head)
|
foreach (_TaxPayer.Fild item in head)
|
||||||
@@ -106,7 +109,7 @@ namespace Back.Services
|
|||||||
ModeID = s.FildModeID,
|
ModeID = s.FildModeID,
|
||||||
ModeTitle = s.FildMode.Title,
|
ModeTitle = s.FildMode.Title,
|
||||||
Title = s.Fild.Title,
|
Title = s.Fild.Title,
|
||||||
InputBox = s.Fild.InputBox
|
InputBox = s.Fild.Name == "dis" || s.Fild.Name == "fee" || s.Fild.Name == "am" ? "autofild" : s.Fild.InputBox
|
||||||
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
foreach (var invoicedetail in InvoiceItem.invoiceDetails)
|
foreach (var invoicedetail in InvoiceItem.invoiceDetails)
|
||||||
@@ -146,5 +149,107 @@ namespace Back.Services
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
public async Task<bool> PreparationInvoiceBeforeSending(Shared.DTOs._TaxPayer.Atemplatefield FildItems, Invoice InvoiceItem)
|
||||||
|
{
|
||||||
|
foreach (var item in FildItems.header.filds.Where(w=>w.InputBox== "fild" || w.InputBox == "fromdb"))
|
||||||
|
{
|
||||||
|
if (item.eName == "indatim" || item.eName == "Indati2m" || item.eName == "cdcd")
|
||||||
|
item.Value = item.Value.Replace("/", "");
|
||||||
|
SetValue(item, ref InvoiceItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (await _invoiceRepo.UpdateAsync(InvoiceItem))
|
||||||
|
{
|
||||||
|
foreach (var Bitem in FildItems.Bodys)
|
||||||
|
{
|
||||||
|
var invoiceDetItem = InvoiceItem.invoiceDetails.Where(w => w.ID == Bitem.ID).FirstOrDefault();
|
||||||
|
foreach (var item in Bitem.filds.Where(w => w.InputBox == "fild" || w.InputBox == "fromdb"))
|
||||||
|
{
|
||||||
|
if (invoiceDetItem != null)
|
||||||
|
SetValue(item, ref invoiceDetItem);
|
||||||
|
}
|
||||||
|
if (!await _invoiceitemRepo.UpdateAsync(invoiceDetItem))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//foreach (var Pitem in FildItems.Payments)
|
||||||
|
//{
|
||||||
|
// var invoicepayItem = InvoiceItem.payments.Where(w => w.ID == Pitem.ID).FirstOrDefault();
|
||||||
|
// foreach (var item in Pitem.filds)
|
||||||
|
// {
|
||||||
|
// if (invoicepayItem != null)
|
||||||
|
// {
|
||||||
|
// SetValue(item, ref invoicepayItem);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// // _repositores.UPDATE(invoicepayItem);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
private void SetValue<T>(_TaxPayer.Fild fild, ref T obj)
|
||||||
|
{
|
||||||
|
var resvaltype = obj.GetType().GetProperties().Where(w => w.Name == (fild.eName=="tax17" ? "seventeentax" : fild.eName)).FirstOrDefault();
|
||||||
|
//if (resvaltype != null)
|
||||||
|
//{
|
||||||
|
if ((resvaltype.GetValue(obj) == null && !string.IsNullOrEmpty(fild.Value))
|
||||||
|
||
|
||||||
|
resvaltype.GetValue(obj) != null && resvaltype.GetValue(obj).ToString() != fild.Value)
|
||||||
|
{
|
||||||
|
if (resvaltype != null && resvaltype.CanWrite)
|
||||||
|
{
|
||||||
|
string _type = ""; object _val = "";
|
||||||
|
|
||||||
|
if (resvaltype.PropertyType.FullName.Contains("Nullable"))
|
||||||
|
_type = resvaltype.PropertyType.GenericTypeArguments[0].FullName;
|
||||||
|
else
|
||||||
|
_type = resvaltype.PropertyType.FullName;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_val = Convert.ChangeType(fild.Value, Type.GetType(_type));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//_contextMongodb.InsertItem(new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/SetValue",
|
||||||
|
// Value = ex.Message + '\n' + "_____________" + '\n' + JsonConvert.SerializeObject(fild),
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "catch"
|
||||||
|
//});
|
||||||
|
|
||||||
|
switch (_type)
|
||||||
|
{
|
||||||
|
case "string":
|
||||||
|
_val = Convert.ChangeType("", Type.GetType(_type));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "bool":
|
||||||
|
if (fild.Value == "1" || fild.Value == "true") _val = Convert.ChangeType(true, Type.GetType(_type));
|
||||||
|
else _val = Convert.ChangeType(false, Type.GetType(_type));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
_val = Convert.ChangeType("0", Type.GetType(_type));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resvaltype.SetValue(obj, _val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ namespace Shared.DTOs
|
|||||||
public string InputBox { get; set; }
|
public string InputBox { get; set; }
|
||||||
public List<Coding> DefVals { get; set; }
|
public List<Coding> DefVals { get; set; }
|
||||||
public string? Value { get; set; }
|
public string? Value { get; set; }
|
||||||
public string[] Des { get; set; }
|
public string[]? Des { get; set; }
|
||||||
}
|
}
|
||||||
public class Coding
|
public class Coding
|
||||||
{
|
{
|
||||||
|
@@ -8,6 +8,165 @@
|
|||||||
<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>
|
<PageTitle>آماده سازی صورتحساب</PageTitle>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card mb-4">
|
||||||
|
<h5 class="card-header">اطلاعات تکمیلی سرآمد صورتحساب</h5>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<form>
|
||||||
|
@if (invoice?.header != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
@foreach (var item in invoice?.header.filds)
|
||||||
|
{
|
||||||
|
<div class="mb-3 col-md-6">
|
||||||
|
@if (item.ModeID == 1 && item.InputBox != "autofild")
|
||||||
|
{
|
||||||
|
<label style="color:red;" class="form-label">@item.fName</label>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<label class="form-label">@item.fName</label>
|
||||||
|
}
|
||||||
|
@if (item.InputBox == "fromdb")
|
||||||
|
{
|
||||||
|
|
||||||
|
<select @bind="item.Value" class="form-control" aria-label="Default select example">
|
||||||
|
<option value="100" style="color: #b5b5b5; " selected>@item.fName...</option>
|
||||||
|
@foreach (var itema in item.DefVals)
|
||||||
|
{
|
||||||
|
if (itema.ID == item.Value)
|
||||||
|
{
|
||||||
|
<option value="@itema.ID" selected>@itema.Name</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="@itema.ID">@itema.Name</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (item.InputBox == "autofild")
|
||||||
|
{
|
||||||
|
<input @bind-value="item.Value" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" disabled />
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input @bind-value="item.Value" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" />
|
||||||
|
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card mb-4">
|
||||||
|
<h5 class="card-header">اطلاعات تکمیلی بدنه صورتحساب</h5>
|
||||||
|
<div class="card-body">
|
||||||
|
@if (invoice?.Bodys != null)
|
||||||
|
{
|
||||||
|
<Accordion>
|
||||||
|
@foreach (var item in invoice?.Bodys)
|
||||||
|
{<div class="col-md-12">
|
||||||
|
<div class="card mb-4">
|
||||||
|
<AccordionItem Title="@item.filds.Where(w=>w.eName=="sstt").Select(s=>s.Value).First()">
|
||||||
|
<Content>
|
||||||
|
<div class="row">
|
||||||
|
@foreach (var itemB in item.filds)
|
||||||
|
{
|
||||||
|
<div class="mb-3 col-md-6">
|
||||||
|
@if (itemB.ModeID == 1 && itemB.InputBox != "autofild")
|
||||||
|
{
|
||||||
|
<label style="color:red;" class="form-label">@itemB.fName</label>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<label class="form-label">@itemB.fName</label>
|
||||||
|
}
|
||||||
|
@if (itemB.InputBox == "fromdb")
|
||||||
|
{
|
||||||
|
|
||||||
|
<select @bind="itemB.Value" class="form-control" aria-label="Default select example">
|
||||||
|
<option value="100" style="color: #b5b5b5; " selected>@itemB.fName...</option>
|
||||||
|
@foreach (var itema in itemB.DefVals)
|
||||||
|
{
|
||||||
|
if (itema.ID == itemB.Value)
|
||||||
|
{
|
||||||
|
<option value="@itema.ID" selected>@itema.Name</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="@itema.ID">@itema.Name</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (itemB.InputBox == "autofild")
|
||||||
|
{
|
||||||
|
<input @bind-value="itemB.Value" style="text-align:center;" class="form-control" type="text" placeholder="@itemB.fName" disabled />
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input @bind-value="itemB.Value" style="text-align:center;" class="form-control" type="text" placeholder="@itemB.fName" />
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</Content>
|
||||||
|
</AccordionItem>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
</Accordion>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@* action *@
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="mb-2">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="col-auto">
|
||||||
|
<button type="submit" @onclick="Send" class="btn btn-primary">ارسال</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ConfirmDialog dialog = default!;
|
private ConfirmDialog dialog = default!;
|
||||||
[Parameter] public int? InvoiceID { get; set; }
|
[Parameter] public int? InvoiceID { get; set; }
|
||||||
@@ -24,10 +183,33 @@
|
|||||||
{
|
{
|
||||||
await LoadData();
|
await LoadData();
|
||||||
await base.OnParametersSetAsync();
|
await base.OnParametersSetAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@functions{
|
@functions {
|
||||||
|
public async Task Send()
|
||||||
|
{
|
||||||
|
var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/PreparationInvoiceBeforeSending", invoice);
|
||||||
|
if (rsp.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var response = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||||
|
if (response)
|
||||||
|
{
|
||||||
|
ShowSuccessAlert("آماده سازی با موفقیت انجام شد");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowDangerAlert("خطای در آماده سازی اطلاعات رخ داده");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||||
|
ShowDangerAlert(request[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowSuccessAlert(string msg)
|
private void ShowSuccessAlert(string msg)
|
||||||
{
|
{
|
||||||
Hidealert = false;
|
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");
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user