This commit is contained in:
mmrbnjd
2024-05-29 15:51:06 +03:30
parent 8efa1d6f81
commit 85a72bc1ad
6 changed files with 96 additions and 48 deletions

View File

@@ -35,7 +35,7 @@
<ItemGroup>
<Reference Include="Service">
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
<HintPath>..\..\Dlls\Service.dll</HintPath>
</Reference>
</ItemGroup>

View File

@@ -4,6 +4,7 @@ using Back.Services;
using Back.Validations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Shared.DTOs;
using Shared.DTOs.Serch;
@@ -38,7 +39,7 @@ namespace Back.Controllers
}
[HttpGet("Get/{ID}")]
public async Task<ActionResult<InvoiceGridDTO>?> GetAll(int ID)
public async Task<ActionResult<InvoiceDTO>?> GetAll(int ID)
{
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
var UserID = claim.Value;
@@ -191,7 +192,7 @@ namespace Back.Controllers
return Ok(await _servInvoice.DeleteInvoice(invoice));
}
[HttpPost("ChangeInvoiceType/{InvoiceID}")]// ok
public async Task<ActionResult<int>> ChangeInvoiceType(int InvoiceID, InvoiceType invoiceType)
public async Task<ActionResult<InvoiceDTO>> ChangeInvoiceType(int InvoiceID, InvoiceType invoiceType)
{
//-----GetUserAndCompany
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
@@ -229,7 +230,7 @@ namespace Back.Controllers
case InvoiceType.Repair:
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
return Ok(await _servInvoice.AddInvoice(new Invoice()
var result = await _servInvoice.AddInvoice(new Invoice()
{
Title = Invoice.Title,
@@ -243,11 +244,13 @@ namespace Back.Controllers
BillReference = Invoice.ID,
IsDeleted = false,
PatternID = Invoice.PatternID
}, false));
}, false);
if (result > 0)
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID,result));
break;
case InvoiceType.BackFrmSale:
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
return Ok(await _servInvoice.AddInvoice(new Invoice()
var result1 = await _servInvoice.AddInvoice(new Invoice()
{
Title = Invoice.Title,
@@ -261,7 +264,10 @@ namespace Back.Controllers
BillReference = Invoice.ID,
IsDeleted = false,
PatternID = Invoice.PatternID
}, false));
}, false);
if (result1 > 0)
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result1));
break;
default:
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
@@ -286,8 +292,8 @@ namespace Back.Controllers
{
switch (invoiceType)
{
case InvoiceType.Sale:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
//case InvoiceType.Sale:
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
case InvoiceType.CANCEL:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
@@ -320,7 +326,7 @@ namespace Back.Controllers
case InvoiceType.BackFrmSale:
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
return Ok(await _servInvoice.AddInvoice(new Invoice()
var result2 = await _servInvoice.AddInvoice(new Invoice()
{
Title = Invoice.Title,
@@ -334,7 +340,10 @@ namespace Back.Controllers
BillReference = Invoice.ID,
IsDeleted = false,
PatternID = Invoice.PatternID
}, false));
}, false);
if (result2 > 0)
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result2));
break;
default:
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
@@ -362,23 +371,23 @@ namespace Back.Controllers
case InvoiceType.Cancellation:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
case InvoiceType.Repair:
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
return Ok(await _servInvoice.AddInvoice(new Invoice()
{
//case InvoiceType.Repair:
// await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
// return Ok(await _servInvoice.AddInvoice(new Invoice()
// {
Title = Invoice.Title,
Des = Invoice.Des,
invoiceType = invoiceType,
CustomerID = Invoice.CustomerID,
CompanyID = Invoice.CompanyID,
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""),
LastChangeUserID = Convert.ToInt32(UserID),
BillReference = Invoice.ID,
IsDeleted = false,
PatternID = Invoice.PatternID
}, false));
// Title = Invoice.Title,
// Des = Invoice.Des,
// invoiceType = invoiceType,
// CustomerID = Invoice.CustomerID,
// CompanyID = Invoice.CompanyID,
// InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
// InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""),
// LastChangeUserID = Convert.ToInt32(UserID),
// BillReference = Invoice.ID,
// IsDeleted = false,
// PatternID = Invoice.PatternID
// }, false));
default:
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });

View File

@@ -92,7 +92,7 @@ namespace Back.Services
{
#region AdvancedSearch
var invok = _invoiceRepo
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted);
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted && !w.BillReference.HasValue);
if (itemSerch.InvoiceID != null)
invok = invok.Where(w => w.ID == itemSerch.InvoiceID);
@@ -209,7 +209,7 @@ namespace Back.Services
}
}
public async Task<bool> ChangeInvoiceType(Invoice invoiceitem, InvoiceType item, bool action = true)
public async Task<InvoiceDTO?> ChangeInvoiceType(Invoice invoiceitem, InvoiceType item, bool action = true)
{
string old = invoiceitem.invoiceType.GetEnumDisplayName();
invoiceitem.invoiceType = item;
@@ -226,8 +226,19 @@ namespace Back.Services
UserID = invoiceitem.LastChangeUserID
});
if (action)
return await _invoiceRepo.UpdateAsync(invoiceitem);
else return true;
{
var result = await _invoiceRepo.UpdateAsync(invoiceitem);
if (result)
{
return await GetInvoice(invoiceitem.CompanyID.Value, invoiceitem.ID);
}
else
{
return null;
}
}
else return await GetInvoice(invoiceitem.CompanyID.Value, invoiceitem.ID);
//_contextMongodb.InsertItem(new SysLog()
//{
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
@@ -249,7 +260,7 @@ namespace Back.Services
// Route = _httpContextAccessor.HttpContext.Request.Path,
// Type = "catch"
//});
return false;
return null;
}

View File

@@ -10,7 +10,7 @@
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<NavLink class="nav-link" href="/" Match="NavLinkMatch.All">
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>

View File

@@ -27,30 +27,30 @@
@switch (invoice.invoiceType)
{
case(InvoiceType.Bidding):
<button class="button" id="cut"><span>فاکتور</span></button>
<button class="button" id="sred1"><span>لغو</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Sale)" id="cut"><span>فاکتور</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.CANCEL)" id="sred1"><span>لغو</span></button>
break;
case (InvoiceType.Sale):
<button class="button" id="copy"><span>برگشت فروش</span></button>
<button class="button" id="paste"><span>اصلاح</span></button>
<button class="button" id="sred"><span>ابطال</span></button>
<button class="button" id="sred1"><span>لغو</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.BackFrmSale)" id="copy"><span>برگشت فروش</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Repair)" id="paste"><span>اصلاح</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Cancellation)" id="sred"><span>ابطال</span></button>
<button class="button" id="sred1" @onclick="() => ChangeStatus(InvoiceType.CANCEL)"><span>لغو</span></button>
break;
case (InvoiceType.BackFrmSale):
<button class="button" id="sred"><span>ابطال</span></button>
<button class="button" id="sred1"><span>لغو</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Cancellation)" id="sred"><span>ابطال</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.CANCEL)" id="sred1"><span>لغو</span></button>
break;
case (InvoiceType.Repair):
<button class="button" id="sred"><span>ابطال</span></button>
<button class="button" id="sred1"><span>لغو</span></button>
<button class="button" id="copy"><span>برگشت فروش</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Cancellation)" id="sred"><span>ابطال</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.CANCEL)" id="sred1"><span>لغو</span></button>
<button class="button" id="copy" @onclick="() => ChangeStatus(InvoiceType.BackFrmSale)"><span>برگشت فروش</span></button>
break;
case (InvoiceType.Cancellation):
<button class="button" id="sred1"><span>لغو</span></button>
<button class="button" id="sred1" @onclick="() => ChangeStatus(InvoiceType.CANCEL)"><span>لغو</span></button>
break;
}
@@ -236,6 +236,13 @@
<InputText style=" text-align: center;" @bind-Value="invoice.Udate" class="form-control" id="inputUdate" readonly />
</div>
@* @if (invoice.BillReference.HasValue)
{
<div class="row g-3">
<Button Color="ButtonColor.Link"><NavLink href="InvoiceDetails/@invoice.BillReference.Value">صورتحساب مرجع</NavLink></Button>
</div>
} *@
<div class="form-group col-md-4">
<br />
@if (InvoiceID == 0 || InvoiceID == null)
@@ -337,6 +344,27 @@
}
private async Task ChangeStatus(InvoiceType type)
{
var rsp = await hc.Post<InvoiceType>($"Invoice/ChangeInvoiceType/{InvoiceID}",type);
if (rsp.IsSuccessStatusCode)
{
var resinvoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
if (resinvoice!=null)
{
invoice = resinvoice;
ShowSuccessAlert("تغییر وضعیت با موفقیت انجام شد");
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
private async Task LoadData()
{
PreloadService.Show(SpinnerColor.Dark);

View File

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