get invoice view
This commit is contained in:
@@ -36,6 +36,19 @@ namespace Back.Controllers
|
||||
return Ok(await _servCus.GetCustomers(user.RolUsers.First().CompanyID, itemSerch));
|
||||
|
||||
|
||||
}
|
||||
[HttpGet("GetAllForidName")]
|
||||
public async Task<ActionResult<List<ForCustomerSearch>>> GetAllForSearch()
|
||||
{
|
||||
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 _servCus.GetCustomers(user.RolUsers.First().CompanyID));
|
||||
|
||||
|
||||
}
|
||||
[HttpPost("Add")]
|
||||
public async Task<ActionResult<bool>> Add(RCustomer item)
|
||||
|
@@ -61,6 +61,20 @@ namespace Back.Services
|
||||
}).OrderByDescending(o=>o.ID)
|
||||
.Paging(itemSerch.PageIndex, itemSerch.PageSize);
|
||||
}
|
||||
public async Task<List<ForCustomerSearch>?> GetCustomers(int CompanyID)
|
||||
{
|
||||
var invok = _repoCus
|
||||
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted);
|
||||
|
||||
//-----------------------
|
||||
return await invok.Select(s => new ForCustomerSearch()
|
||||
{
|
||||
CustomerName=s.FullName,
|
||||
ID = s.ID
|
||||
|
||||
}).OrderByDescending(o => o.ID)
|
||||
.ToListAsync();
|
||||
}
|
||||
public async Task<Customer?> GetCustomerByCustomerID(int CustomerID, int CompanyID)
|
||||
{
|
||||
return await _repoCus
|
||||
|
@@ -13,9 +13,9 @@ namespace Back.Services
|
||||
private readonly IAsyncRepository<InvoiceStatusChang> _invoiceStatusChangPaymentRepo;
|
||||
private readonly CheckPermission _checkPermission;
|
||||
public servInvoice(IAsyncRepository<Invoice> invoiceRepo, CheckPermission checkPermission
|
||||
,IAsyncRepository<InvoiceStatusChang> invoiceStatusChangPaymentRepo)
|
||||
, IAsyncRepository<InvoiceStatusChang> invoiceStatusChangPaymentRepo)
|
||||
{
|
||||
_invoiceStatusChangPaymentRepo= invoiceStatusChangPaymentRepo;
|
||||
_invoiceStatusChangPaymentRepo = invoiceStatusChangPaymentRepo;
|
||||
_invoiceRepo = invoiceRepo;
|
||||
_checkPermission = checkPermission;
|
||||
|
||||
@@ -45,9 +45,11 @@ namespace Back.Services
|
||||
return await invok
|
||||
.Include(inc => inc.invoiceDetails)
|
||||
.Include(inc => inc.payments)
|
||||
.Include(inc => inc.pattern)
|
||||
.Select(s => new InvoiceDTO()
|
||||
{
|
||||
PatternID= s.PatternID,
|
||||
PatternID = s.PatternID,
|
||||
PatternTitle = s.pattern.Title,
|
||||
CustomerID = s.CustomerID,
|
||||
CustomerName = s.Customer.FullName,
|
||||
ID = s.ID,
|
||||
@@ -93,9 +95,9 @@ namespace Back.Services
|
||||
})
|
||||
.Paging(itemSerch.PageIndex, itemSerch.PageSize);
|
||||
}
|
||||
public async Task<bool> ExistInvoiceByInvoiceID(int CompanyID,int InvoiceID)
|
||||
public async Task<bool> ExistInvoiceByInvoiceID(int CompanyID, int InvoiceID)
|
||||
{
|
||||
return await _invoiceRepo.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
|
||||
return await _invoiceRepo.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
|
||||
|
||||
}
|
||||
public async Task<bool> AddInvoice(Invoice invoice, bool calculate = true)
|
||||
@@ -113,7 +115,7 @@ namespace Back.Services
|
||||
{
|
||||
return await _invoiceRepo.AddBoolResultAsync(invoice);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public async Task<bool> UpdateInvoice(Invoice invoice)
|
||||
{
|
||||
@@ -121,7 +123,7 @@ namespace Back.Services
|
||||
invoice.PreparedtoSendtoTax = false;
|
||||
|
||||
|
||||
return await _invoiceRepo.UpdateAsync(invoice);
|
||||
return await _invoiceRepo.UpdateAsync(invoice);
|
||||
}
|
||||
public async Task<Invoice?> GetInvoiceByInvoiceID(int CompanyID, int InvoiceID)
|
||||
{
|
||||
@@ -180,8 +182,8 @@ namespace Back.Services
|
||||
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
UserID = invoiceitem.LastChangeUserID
|
||||
});
|
||||
if(action)
|
||||
return await _invoiceRepo.UpdateAsync(invoiceitem);
|
||||
if (action)
|
||||
return await _invoiceRepo.UpdateAsync(invoiceitem);
|
||||
else return true;
|
||||
//_contextMongodb.InsertItem(new SysLog()
|
||||
//{
|
||||
|
14
Shared/DTOs/ForCustomerSearch.cs
Normal file
14
Shared/DTOs/ForCustomerSearch.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.DTOs
|
||||
{
|
||||
public class ForCustomerSearch
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string CustomerName { get; set; }
|
||||
}
|
||||
}
|
@@ -19,25 +19,34 @@ namespace Shared.DTOs
|
||||
}
|
||||
public class InvoiceDTO
|
||||
{
|
||||
[Display(Name = "شناسه")]
|
||||
public int ID { get; set; }
|
||||
[Display(Name = "عنوان")]
|
||||
public string Title { get; set; }
|
||||
public InvoiceType? invoiceType { get; set; }
|
||||
public int? PatternID { get; set; }
|
||||
public string? PatternTitle { 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; }
|
||||
public string InvoiceDate { get; set; }
|
||||
public bool PreparedtoSendtoTax { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string? Des { 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 int? BillReference { get; set; }
|
||||
public ICollection<InvoiceItemDTO> items { get; set; }
|
||||
|
@@ -8,10 +8,10 @@ namespace Shared.DTOs.Serch
|
||||
{
|
||||
public class ItemSerchGetInvoices : IFildGlobalItemSerch
|
||||
{
|
||||
public string? Title { get; set; }
|
||||
public int? InvoiceID { get; set; }
|
||||
public string? Title { get; set; }//
|
||||
public int? InvoiceID { get; set; }//
|
||||
public int? CustomerID { get; set; }
|
||||
public InvoiceType? invoiceType { get; set; }
|
||||
public InvoiceType? invoiceType { get; set; }//
|
||||
public int PageIndex { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 5;
|
||||
}
|
||||
|
21
Shared/ExMethod.cs
Normal file
21
Shared/ExMethod.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
public static class ExMethod
|
||||
{
|
||||
public static string GetEnumDisplayName(this Enum enumType)
|
||||
{
|
||||
return enumType.GetType().GetMember(enumType.ToString())
|
||||
.First()
|
||||
.GetCustomAttribute<DisplayAttribute>()
|
||||
.Name;
|
||||
}
|
||||
}
|
||||
}
|
@@ -26,7 +26,7 @@
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="menu-item @cssActionItem[3]" @onclick="() => onClickcssActionItem(3)">
|
||||
<NavLink href="icons-boxicons.html" class="menu-link">
|
||||
<NavLink href="Invoice" class="menu-link">
|
||||
<i class="menu-icon tf-icons bx bx-detail"></i>
|
||||
<div>صورتحساب</div>
|
||||
</NavLink>
|
||||
|
243
TaxPayerFull/Pages/UserPanel/Invoice.razor
Normal file
243
TaxPayerFull/Pages/UserPanel/Invoice.razor
Normal file
@@ -0,0 +1,243 @@
|
||||
@page "/Invoice"
|
||||
@using Front.Services
|
||||
@using Shared
|
||||
@using Shared.DTOs
|
||||
@using Front.CUSComponent
|
||||
@using Shared.DTOs.Serch
|
||||
@inject HttpClientController hc;
|
||||
<PageTitle>صورتحساب</PageTitle>
|
||||
<Modal @ref="modal" />
|
||||
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
@* search *@
|
||||
<div class="row">
|
||||
<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.InvoiceID" placeholder="شناسه" style="text-align:center;" class="form-control" type="text">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select @bind="ItemSearchInvoicetype" 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">
|
||||
<input @bind-value="itemsearch.Title" placeholder="عنوان" style="text-align:center;" class="form-control" type="text">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<AutoComplete @bind-Value="customerName"
|
||||
TItem="ForCustomerSearch"
|
||||
DataProvider="CustomersDataProvider"
|
||||
PropertyName="CustomerName"
|
||||
Placeholder="مشتری"
|
||||
OnChanged="(ForCustomerSearch customer) => OnAutoCompleteChanged(customer)" />
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button @onclick="() => LoadInvoice(1)" type="submit" class="btn btn-primary">جستجو</button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</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="()=>InvoiceItem(0)" class="btn btn-primary">جدید</button>
|
||||
</div>
|
||||
</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,InvoiceItem)" />
|
||||
@* 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>
|
||||
}
|
||||
|
||||
@layout PanelLayout
|
||||
@code {
|
||||
private string? customerName;
|
||||
public IEnumerable<ForCustomerSearch>? customers;
|
||||
|
||||
private async Task<AutoCompleteDataProviderResult<ForCustomerSearch>> CustomersDataProvider(AutoCompleteDataProviderRequest<ForCustomerSearch> request)
|
||||
{
|
||||
if (customers is null) // pull customers only one time for client-side autocomplete
|
||||
customers =await GetCustomers(); // call a service or an API to pull the customers
|
||||
|
||||
return await Task.FromResult(request.ApplyTo(customers.OrderBy(customer => customer.CustomerName)));
|
||||
}
|
||||
//-----------
|
||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||
public int? ItemSearchInvoicetype { get; set; }
|
||||
ItemSerchGetInvoices itemsearch = new ItemSerchGetInvoices();
|
||||
[Parameter, SupplyParameterFromQuery]
|
||||
public int? PageIndex { get; set; }
|
||||
public Shared.DTOs.PagingDto<InvoiceDTO>? request { get; set; }
|
||||
private Modal modal = default!;
|
||||
// alert
|
||||
AlertColor alertColor = AlertColor.Primary;
|
||||
IconName alertIconName = IconName.CheckCircleFill;
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (PageIndex == null) PageIndex = 1;
|
||||
await LoadInvoice(PageIndex.Value);
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions {
|
||||
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;
|
||||
}
|
||||
public async Task LoadInvoice(int pi)
|
||||
{
|
||||
if (ItemSearchInvoicetype == 100 || ItemSearchInvoicetype==null)
|
||||
itemsearch.invoiceType = null;
|
||||
else
|
||||
itemsearch.invoiceType = (InvoiceType)ItemSearchInvoicetype;
|
||||
|
||||
itemsearch.PageSize = 10;
|
||||
itemsearch.PageIndex = pi;
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Post<ItemSerchGetInvoices>("Invoice/GetAll", itemsearch);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
request = await rsp.Content.ReadFromJsonAsync<PagingDto<InvoiceDTO>>();
|
||||
}
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.Forbidden)
|
||||
{
|
||||
ShowDangerAlert("شما دسترسی به خواندن اطلاعات صورتحساب را نداربد");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
PreloadService.Hide();
|
||||
}
|
||||
public async Task CallBackCustomerItem(ActionInResultComponent result)
|
||||
{
|
||||
|
||||
if (result.Action == ComponentAction.add)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("صورتحساب جدید با موفقیت اضافه شد");
|
||||
|
||||
}
|
||||
else if (result.Action == ComponentAction.update)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("اطلاعات صورتحساب با موفقیت ویرایش شد");
|
||||
}
|
||||
else if (result.Action == ComponentAction.delete)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("صورتحساب با موفقیت حذف شد");
|
||||
}
|
||||
|
||||
if (result.Status == ComponentStatus.success)
|
||||
await LoadInvoice(1);
|
||||
|
||||
await modal.HideAsync();
|
||||
}
|
||||
public async Task InvoiceItem(int ID)
|
||||
{
|
||||
|
||||
var parameters = new Dictionary<string, object>();
|
||||
|
||||
if (ID == 0) parameters.Add("Invoice", new InvoiceDTO() { ID = 0 });
|
||||
else parameters.Add("Invoice", request.list.Where(w => w.ID == ID).First().Clone());
|
||||
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
|
||||
await modal.ShowAsync<CustomerItem>(title: ID == 0 ? "صورتحساب جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||
|
||||
|
||||
}
|
||||
//------------------------
|
||||
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>();
|
||||
|
||||
}
|
||||
private void OnAutoCompleteChanged(ForCustomerSearch customer)
|
||||
{
|
||||
itemsearch.CustomerID = customer?.ID;
|
||||
// // TODO: handle your own logic
|
||||
|
||||
// // NOTE: do null check
|
||||
// Console.WriteLine($"'{customer?.Name}' selected.");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user