...
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[HttpPost("GetAll")]
|
||||
public async Task<ActionResult<PagingDto<InvoiceDTO>?>> GetAll([FromBody] ItemSerchGetInvoices itemSerch)
|
||||
public async Task<ActionResult<PagingDto<InvoiceGridDTO>?>> GetAll([FromBody] ItemSerchGetInvoices itemSerch)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
@@ -34,6 +34,16 @@ namespace Back.Controllers
|
||||
|
||||
return Ok(await _servInvoice.GetInvoices(user.RolUsers.First().CompanyID, itemSerch));
|
||||
|
||||
}
|
||||
[HttpGet("Get/{ID}")]
|
||||
public async Task<ActionResult<PagingDto<InvoiceGridDTO>?>> GetAll(int ID)
|
||||
{
|
||||
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 _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, ID));
|
||||
|
||||
}
|
||||
[HttpPost("Add")]
|
||||
public async Task<ActionResult<int>> Add([FromBody] NUInvoiceDTO item)
|
||||
|
@@ -20,25 +20,12 @@ namespace Back.Services
|
||||
_checkPermission = checkPermission;
|
||||
|
||||
}
|
||||
public async Task<PagingDto<InvoiceDTO>?> GetInvoices(int CompanyID, ItemSerchGetInvoices itemSerch)
|
||||
public async Task<InvoiceDTO> GetInvoice(int CompanyID, int ID)
|
||||
{
|
||||
#region AdvancedSearch
|
||||
var invok = _invoiceRepo
|
||||
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted);
|
||||
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted && w.ID==ID);
|
||||
|
||||
if (itemSerch.InvoiceID != null)
|
||||
invok = invok.Where(w => w.ID == itemSerch.InvoiceID);
|
||||
|
||||
if (itemSerch.CustomerID != null)
|
||||
invok = invok.Where(w => w.CustomerID == itemSerch.CustomerID);
|
||||
|
||||
if (itemSerch.invoiceType != null)
|
||||
invok = invok.Where(w => w.invoiceType == itemSerch.invoiceType);
|
||||
|
||||
if (itemSerch.Title != null)
|
||||
invok = invok.Where(w => w.Title.Contains(itemSerch.Title));
|
||||
//foreach (InputObj item in inputObjs)
|
||||
// invok = invok.Where(ExMethod.GetFunc<Customer>(item.Param, item.Value));
|
||||
|
||||
#endregion
|
||||
//-----------------------
|
||||
@@ -93,6 +80,47 @@ namespace Back.Services
|
||||
trn = x.acn
|
||||
}).ToList(),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<PagingDto<InvoiceGridDTO>?> GetInvoices(int CompanyID, ItemSerchGetInvoices itemSerch)
|
||||
{
|
||||
#region AdvancedSearch
|
||||
var invok = _invoiceRepo
|
||||
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted);
|
||||
|
||||
if (itemSerch.InvoiceID != null)
|
||||
invok = invok.Where(w => w.ID == itemSerch.InvoiceID);
|
||||
|
||||
if (itemSerch.CustomerID != null)
|
||||
invok = invok.Where(w => w.CustomerID == itemSerch.CustomerID);
|
||||
|
||||
if (itemSerch.invoiceType != null)
|
||||
invok = invok.Where(w => w.invoiceType == itemSerch.invoiceType);
|
||||
|
||||
if (itemSerch.Title != null)
|
||||
invok = invok.Where(w => w.Title.Contains(itemSerch.Title));
|
||||
//foreach (InputObj item in inputObjs)
|
||||
// invok = invok.Where(ExMethod.GetFunc<Customer>(item.Param, item.Value));
|
||||
|
||||
#endregion
|
||||
//-----------------------
|
||||
return await invok
|
||||
.Include(inc => inc.invoiceDetails)
|
||||
.Include(inc => inc.payments)
|
||||
.Include(inc => inc.pattern)
|
||||
.Select(s => new InvoiceGridDTO()
|
||||
{
|
||||
CustomerID = s.CustomerID,
|
||||
CustomerName = s.Customer.FullName,
|
||||
ID = s.ID,
|
||||
invoiceTypeTitle = s.invoiceType.GetEnumDisplayName(),
|
||||
Title = s.Title,
|
||||
InvoicIssueDate = s.InvoicIssueDate.ShamciToFormatShamci(),
|
||||
tbill = s.tbill,
|
||||
tdis = s.tdis,
|
||||
tvam = s.tvam,
|
||||
Udate = s.Udate.ShamciToFormatShamci(),
|
||||
})
|
||||
.Paging(itemSerch.PageIndex, itemSerch.PageSize);
|
||||
}
|
||||
public async Task<bool> ExistInvoiceByInvoiceID(int CompanyID, int InvoiceID)
|
||||
|
@@ -17,6 +17,33 @@ namespace Shared.DTOs
|
||||
public string InvoiceDate { get; set; }
|
||||
public string? Des { get; set; }
|
||||
}
|
||||
public class InvoiceGridDTO
|
||||
{
|
||||
[Display(Name = "شناسه")]
|
||||
public int ID { get; set; }
|
||||
[Display(Name = "عنوان")]
|
||||
public string Title { get; set; }//
|
||||
[Display(Name = "نوع صورتحساب")]
|
||||
public string? invoiceTypeTitle { get; set; }//
|
||||
public int CustomerID { get; set; }//
|
||||
[Display(Name = "مشتری")]
|
||||
public string CustomerName { get; set; }//
|
||||
public string? Udate { get; set; }
|
||||
[Display(Name = "تاریخ صدور")]
|
||||
public string InvoicIssueDate { get; set; }//
|
||||
//مجموع تخفیفات
|
||||
[Display(Name = "مجموع تخفیف")]
|
||||
public decimal? tdis { get; set; }
|
||||
//مجموع مالیات بر ارزش افزوده
|
||||
[MaxLength(18)]
|
||||
[Display(Name = "مجموع مالیات")]
|
||||
public decimal? tvam { get; set; }
|
||||
//مجموع صورتحساب
|
||||
[MaxLength(18)]
|
||||
[Display(Name = "مجموع صورتحساب")]
|
||||
public decimal? tbill { get; set; }
|
||||
|
||||
}
|
||||
public class InvoiceDTO
|
||||
{
|
||||
[Display(Name = "شناسه")]
|
||||
|
@@ -2,6 +2,11 @@
|
||||
@using Shared.DTOs
|
||||
@using Shared
|
||||
@inject HttpClientController hc;
|
||||
@layout PanelLayout
|
||||
@inject Fixedvalues fv;
|
||||
@page "/InvoiceDetails/{InvoiceID:int}"
|
||||
@page "/InvoiceDetails"
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
<form>
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
@@ -166,29 +171,55 @@ else
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||
// alert
|
||||
AlertColor alertColor = AlertColor.Primary;
|
||||
IconName alertIconName = IconName.CheckCircleFill;
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
[Parameter] public List<ForCustomerSearch> Cus { get; set; }
|
||||
[Parameter] public List<IdName<int>> Patterns { get; set; }
|
||||
[Parameter] public InvoiceDTO invoice { get; set; }
|
||||
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
|
||||
// [Parameter] public List<IdName<int>>? Unitrequest { get; set; }
|
||||
public ActionInResultComponent result { get; set; }
|
||||
[Parameter] public int? InvoiceID { get; set; }
|
||||
public List<ForCustomerSearch>? Cus { get; set; }
|
||||
public List<IdName<int>>? Patterns { get; set; }
|
||||
public InvoiceDTO? invoice { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
invoice = new InvoiceDTO();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override Task OnParametersSetAsync()
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
result = new ActionInResultComponent()
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
Cus =await fv.GetCustomers();
|
||||
Patterns = await fv.GetPatterns();
|
||||
if (InvoiceID != null && InvoiceID > 0)
|
||||
{
|
||||
Status = ComponentStatus.fild
|
||||
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
invoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
|
||||
}
|
||||
else
|
||||
hc._nav.NavigateTo("/Pael");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
invoice = new InvoiceDTO()
|
||||
{
|
||||
ID = 0,
|
||||
InvoiceDate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(),
|
||||
InvoicIssueDate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(),
|
||||
Udate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Hidealert = true;
|
||||
alertMessage = "";
|
||||
return base.OnParametersSetAsync();
|
||||
PreloadService.Hide();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions {
|
||||
@@ -209,24 +240,25 @@ else
|
||||
public async Task OnClickDelete()
|
||||
{
|
||||
|
||||
var rsp = await hc.Delete($"Cod/Delete/{invoice.ID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (request)
|
||||
{
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.delete;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
// var rsp = await hc.Delete($"Cod/Delete/{invoice.ID}");
|
||||
// if (rsp.IsSuccessStatusCode)
|
||||
// {
|
||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
// if (request)
|
||||
// {
|
||||
// result.Status = ComponentStatus.success;
|
||||
// result.Action = ComponentAction.delete;
|
||||
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
{
|
||||
ShowDangerAlert("کالا با این شناسه یافت نشد");
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
// //await OnMultipleOfThree.InvokeAsync(result);
|
||||
// }
|
||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
// }
|
||||
|
||||
// else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
// {
|
||||
// ShowDangerAlert("کالا با این شناسه یافت نشد");
|
||||
// }
|
||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
|
||||
|
||||
|
||||
|
@@ -1,9 +1,46 @@
|
||||
using Shared.DTOs;
|
||||
using Front.Services;
|
||||
using Shared.DTOs;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace Front
|
||||
{
|
||||
public static class Fixedvalues
|
||||
public class Fixedvalues
|
||||
{
|
||||
public static UserAuthenticationDTO Userinfo=new UserAuthenticationDTO();
|
||||
public readonly HttpClientController _hc;
|
||||
private List<ForCustomerSearch>? Cus=null;
|
||||
private List<IdName<int>>? Patterns = null;
|
||||
public Fixedvalues(HttpClientController hc)
|
||||
{
|
||||
_hc = hc;
|
||||
}
|
||||
public async Task<List<ForCustomerSearch>?> GetCustomers()
|
||||
{
|
||||
if (Cus == null)
|
||||
{
|
||||
var request = await _hc.Get($"Customer/GetAllForidName");
|
||||
if (request.IsSuccessStatusCode)
|
||||
{
|
||||
Cus= await request.Content.ReadFromJsonAsync<List<ForCustomerSearch>>();
|
||||
}
|
||||
}
|
||||
|
||||
return Cus;
|
||||
|
||||
|
||||
}
|
||||
public async Task<List<IdName<int>>?> GetPatterns()
|
||||
{
|
||||
if (Patterns==null)
|
||||
{
|
||||
var request = await _hc.Get($"Invoice/GetPatterns");
|
||||
if (request.IsSuccessStatusCode)
|
||||
{
|
||||
Patterns =await request.Content.ReadFromJsonAsync<List<IdName<int>>>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Patterns;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
@using Front.CUSComponent
|
||||
@using Shared.DTOs.Serch
|
||||
@inject HttpClientController hc;
|
||||
@inject Fixedvalues fv;
|
||||
<PageTitle>صورتحساب</PageTitle>
|
||||
<Modal Size="ModalSize.ExtraLarge" @ref="modal" />
|
||||
|
||||
@@ -128,7 +129,7 @@
|
||||
ItemSerchGetInvoices itemsearch = new ItemSerchGetInvoices();
|
||||
[Parameter, SupplyParameterFromQuery]
|
||||
public int? PageIndex { get; set; }
|
||||
public Shared.DTOs.PagingDto<InvoiceDTO>? request { get; set; }
|
||||
public Shared.DTOs.PagingDto<InvoiceGridDTO>? request { get; set; }
|
||||
private Modal modal = default!;
|
||||
// alert
|
||||
AlertColor alertColor = AlertColor.Primary;
|
||||
@@ -171,7 +172,7 @@
|
||||
var rsp = await hc.Post<ItemSerchGetInvoices>("Invoice/GetAll", itemsearch);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
request = await rsp.Content.ReadFromJsonAsync<PagingDto<InvoiceDTO>>();
|
||||
request = await rsp.Content.ReadFromJsonAsync<PagingDto<InvoiceGridDTO>>();
|
||||
}
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.Forbidden)
|
||||
{
|
||||
@@ -183,7 +184,7 @@
|
||||
}
|
||||
PreloadService.Hide();
|
||||
}
|
||||
public async Task CallBackCustomerItem(ActionInResultComponent result)
|
||||
public async Task CallBackInvoiceItem(ActionInResultComponent result)
|
||||
{
|
||||
|
||||
if (result.Action == ComponentAction.add)
|
||||
@@ -210,42 +211,45 @@
|
||||
}
|
||||
public async Task InvoiceItem(int ID)
|
||||
{
|
||||
if (customers is null)
|
||||
customers = await GetCustomers();
|
||||
if (Patterns == null || Patterns.Count < 0)
|
||||
{
|
||||
var rsp = await hc.Get("Invoice/GetPatterns");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
Patterns = await rsp.Content.ReadFromJsonAsync<List<IdName<int>>>();
|
||||
}
|
||||
}
|
||||
var parameters = new Dictionary<string, object>();
|
||||
// if (customers is null)
|
||||
// customers = await GetCustomers();
|
||||
// if (Patterns == null || Patterns.Count < 0)
|
||||
// {
|
||||
// Patterns =await fv.GetPatterns();
|
||||
// }
|
||||
// var parameters = new Dictionary<string, object>();
|
||||
|
||||
if (ID == 0) parameters.Add("Invoice", new InvoiceDTO()
|
||||
{
|
||||
ID = 0,
|
||||
InvoiceDate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(),
|
||||
InvoicIssueDate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(),
|
||||
Udate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront()
|
||||
});
|
||||
else parameters.Add("invoice", request.list.Where(w => w.ID == ID).First().Clone());
|
||||
parameters.Add("Patterns", Patterns);
|
||||
parameters.Add("Cus", customers);
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
|
||||
await modal.ShowAsync<InvoiceItem>(title: ID == 0 ? "صورتحساب جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||
// if (ID == 0) parameters.Add("Invoice", new InvoiceDTO()
|
||||
// {
|
||||
// ID = 0,
|
||||
// InvoiceDate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(),
|
||||
// InvoicIssueDate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(),
|
||||
// Udate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront()
|
||||
// });
|
||||
// else parameters.Add("invoice", request.list.Where(w => w.ID == ID).First().Clone());
|
||||
// parameters.Add("Patterns", Patterns);
|
||||
// parameters.Add("Cus", customers);
|
||||
// parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackInvoiceItem));
|
||||
|
||||
//await modal.ShowAsync<InvoiceItem>(title: ID == 0 ? "صورتحساب جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||
if (ID==0)
|
||||
{
|
||||
hc._nav.NavigateTo($"InvoiceDetails");
|
||||
}
|
||||
else
|
||||
hc._nav.NavigateTo($"InvoiceDetails/{ID}");
|
||||
|
||||
}
|
||||
//------------------------
|
||||
private async Task<List<ForCustomerSearch>> GetCustomers()
|
||||
{
|
||||
var rsp = await hc.Get("Customer/GetAllForidName");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
return await rsp.Content.ReadFromJsonAsync<List<ForCustomerSearch>>();
|
||||
}
|
||||
return new List<ForCustomerSearch>();
|
||||
return await fv.GetCustomers();
|
||||
// var rsp = await hc.Get("Customer/GetAllForidName");
|
||||
// if (rsp.IsSuccessStatusCode)
|
||||
// {
|
||||
// return await rsp.Content.ReadFromJsonAsync<List<ForCustomerSearch>>();
|
||||
// }
|
||||
// return new List<ForCustomerSearch>();
|
||||
|
||||
}
|
||||
private void OnAutoCompleteChanged(ForCustomerSearch customer)
|
||||
|
@@ -14,6 +14,7 @@ builder.Services.AddBlazorBootstrap();
|
||||
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
|
||||
builder.Services.AddScoped<localService>();
|
||||
builder.Services.AddScoped<HttpClientController>();
|
||||
builder.Services.AddScoped<Fixedvalues>();
|
||||
builder.Services.AddScoped(sp => new UserAuthenticationDTO()
|
||||
{
|
||||
Company = new CompanyAuthenticationDTO()
|
||||
|
Reference in New Issue
Block a user