This commit is contained in:
mmrbnjd
2024-05-23 19:59:19 +03:30
parent 12b89ad630
commit 0fc2efd5ca
10 changed files with 413 additions and 64 deletions

View File

@@ -30,6 +30,19 @@ namespace Back.Controllers
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
// if (!await _checkPermission.AllowSYSGetCOD(Convert.ToInt32(UserID), user.RolUsers.First().CompanyID)) return Forbid("شما دسترسی به خواندن اطلاعات کالا را نداربد");
return Ok(await _servCOD.GetCODs(user.RolUsers.First().CompanyID, itemSerch));
}
[HttpGet("GetAllForidName")]
public async Task<ActionResult<List<CODIdName<int>>>> GetAllForidName()
{
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 _servCOD.GetCODs(user.RolUsers.First().CompanyID));
}
[HttpGet("GetUnits")]
public async Task<ActionResult<List<IdName<int>>>> GetUnits()

View File

@@ -54,6 +54,23 @@ namespace Back.Services
})
.Paging(itemSerch.PageIndex, itemSerch.PageSize);
}
public async Task<List<CODIdName<int>>?> GetCODs(int CompanyID)
{
#region AdvancedSearch
var invok = _CODRepo
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted);
#endregion
//-----------------------
return await invok.Select(s => new CODIdName<int>()
{
ID = s.ID,
Title = s.Title,
Tax=s.TaxRate
})
.ToListAsync();
}
public async Task<List<IdName<int>>> GetUnits()
{
return await _UnitRepo.GetAll().Select(s => new IdName<int> { ID = s.ID, Title = s.Title }).ToListAsync();

View File

@@ -56,7 +56,7 @@ namespace Back.Services
{
ID = x.ID,
CODID = x.CODID,
adis = x.adis,
//adis = x.adis,
am = x.am.Value,
dis = x.dis,
fee = x.fee.Value,

View File

@@ -11,4 +11,8 @@ namespace Shared.DTOs
public T ID { get; set; }
public string Title { get; set; }
}
public class CODIdName<T>: IdName<T>
{
public int Tax { get; set; }
}
}

View File

@@ -99,12 +99,15 @@ namespace Shared.DTOs
//مبلغ مالیات بر ارزش افزوده
public decimal? vam { get; set; }
//مبلغ تخفیف
public decimal? dis { get; set; }
//مبلغ بعد از تخفیف
public decimal? adis { get; set; }
public decimal? dis { get; set; } = 0;
//مبلغ کل کالا/خدمت
public decimal? tsstam { get; set; }
//مبلغ قبل از تخفیف
public decimal? prdis { get; set; }
//مبلغ بعد از تخفیف
[MaxLength(18)]
public decimal? adis { get; set; }
}
public class InvoicePaymentDTO
{

View File

@@ -0,0 +1,251 @@
@using Front.Services
@using Shared.DTOs
@inject HttpClientController hc;
@inject Fixedvalues fv;
<form>
@* alert *@
<div class="row">
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
<Icon Name="@alertIconName" class="me-2"></Icon>
@alertMessage
</Alert>
</div>
<div class="row g-3">
<div class="form-group col-md-6">
<label class="col-sm-4 col-form-label" style="color:red" for="inputcod">کالا</label>
<select @bind="itemDTO.CODID" @bind:after="() =>
{
if(itemDTO.ID==null)
itemDTO.vra=cods.Where(w=>w.ID==itemDTO.CODID).Select(s=>s.Tax).FirstOrDefault();
}" class="form-control" aria-label="Default select example" id="inputcod">
@if (itemDTO.CODID > 0)
{
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
}
else
{
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
}
@if (cods != null)
{
foreach (var item in cods)
{
if (itemDTO.CODID == item.ID)
{
<option value="@item.ID" selected>@item.Title</option>
}
else
{
<option value="@item.ID">@item.Title</option>
}
}
}
</select>
</div>
<div class="form-group col-md-3">
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">تعداد</label>
<InputNumber @bind-Value="itemDTO.am" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputam" placeholder="تعداد" />
</div>
<div class="form-group col-md-3">
<label style="color:red" class="col-sm-6 col-form-label">مبلغ واحد</label>
<InputNumber @bind-Value="itemDTO.fee" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputfee" placeholder="مبلغ واحد" />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مبلغ کل</label>
<InputNumber @bind-Value="itemDTO.prdis" type="text" class="form-control" id="inputfee" placeholder="مبلغ کل" readonly />
</div>
<div class="col-md-4">
<label class="col-sm-6 col-form-label">مبلغ تخفیف</label>
<InputNumber @bind-Value="itemDTO.dis" type="text" @bind-Value:after="AfterAsync" class="form-control" id="inputdis" placeholder="مبلغ تخفیف" />
</div>
<div class="col-md-4">
<label class="col-sm-8 col-form-label">مبلغ بعد تخفیف</label>
<InputNumber @bind-Value="itemDTO.adis" type="text" class="form-control" id="inputadis" placeholder="مبلغ تخفیف" readonly />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">نرخ مالیات</label>
<InputNumber @bind-Value="itemDTO.vra" type="text" class="form-control" id="inputvra" placeholder="نرخ مالیات" readonly />
</div>
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مبلغ مالیات</label>
<InputNumber @bind-Value="itemDTO.vam" type="text" class="form-control" id="inputvra" placeholder="مبلغ مالیات" readonly />
</div>
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مبلغ نهایی</label>
<InputNumber @bind-Value="itemDTO.tsstam" type="text" class="form-control" id="inputvra" placeholder="مبلغ مالیات" readonly />
</div>
</div>
</form>
@if (itemDTO.ID == null)
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
جدید
</Button>
}
else
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
ثبت تغییرات
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickDelete" Type="ButtonType.Button">
حذف
</Button>
}
@code {
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
public int Tax { get; set; } = 0;
[Parameter] public InvoiceItemDTO itemDTO { get; set; }
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
public List<CODIdName<int>> cods { get; set; } = new();
public ActionInResultComponent result { get; set; }
protected override async Task OnInitializedAsync()
{
cods = await fv.GetCODs();
await base.OnInitializedAsync();
}
protected override async Task OnParametersSetAsync()
{
result = new ActionInResultComponent()
{
Status = ComponentStatus.fild
};
Hidealert = true;
alertMessage = "";
await base.OnParametersSetAsync();
}
}
@functions {
private async Task prdisAsync()
{
if (itemDTO.ID == null)
itemDTO.prdis = itemDTO.fee * itemDTO.am;
}
private async Task adisAsync()
{
if (itemDTO.ID == null)
itemDTO.adis= itemDTO.prdis - itemDTO.dis;
// await AftervamAsync();
}
private async Task vamAsync()
{
if (itemDTO.ID == null)
itemDTO.vam = itemDTO.vra * itemDTO.adis / 100;
}
private async Task tsstamAsync()
{
if (itemDTO.ID == null)
itemDTO.tsstam = itemDTO.vam + itemDTO.adis ;
}
private async Task AfterAsync()
{
await prdisAsync();
await adisAsync();
await vamAsync();
await tsstamAsync();
}
public async Task OnClickDelete()
{
// var rsp = await hc.Delete($"Customer/Delete/{Cus.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("خطایی در اجرای عملیات رخ داده");
// }
// else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
// {
// ShowDangerAlert("مشتری با این شناسه یافت نشد");
// }
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
public async Task OnClickUpdate()
{
// if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
// {
// if (ItemSearchCustomertype > 0)
// Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
// var rsp = await hc.Put<RCustomer>("Customer/Update", Cus);
// if (rsp.IsSuccessStatusCode)
// {
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
// if (request)
// {
// result.Status = ComponentStatus.success;
// result.Action = ComponentAction.update;
// await OnMultipleOfThree.InvokeAsync(result);
// }
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
// }
// else
// {
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
// ShowDangerAlert(request[0]);
// }
// }
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
}
public async Task OnClickAdd()
{
// if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
// {
// if (ItemSearchCustomertype > 0)
// Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
// Cus.ID = null;
// var rsp = await hc.Post<RCustomer>("Customer/Add", Cus);
// if (rsp.IsSuccessStatusCode)
// {
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
// if (request)
// {
// result.Status = ComponentStatus.success;
// result.Action = ComponentAction.add;
// await OnMultipleOfThree.InvokeAsync(result);
// }
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
// }
// else
// {
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
// ShowDangerAlert(request[0]);
// }
// }
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
}
}

View File

@@ -9,6 +9,7 @@ namespace Front
public readonly HttpClientController _hc;
private List<ForCustomerSearch>? Cus=null;
private List<IdName<int>>? Patterns = null;
private List<CODIdName<int>>? Cods = null;
public Fixedvalues(HttpClientController hc)
{
_hc = hc;
@@ -27,6 +28,21 @@ namespace Front
return Cus;
}
public async Task<List<CODIdName<int>>?> GetCODs()
{
if (Cods == null)
{
var request = await _hc.Get($"COD/GetAllForidName");
if (request.IsSuccessStatusCode)
{
Cods = await request.Content.ReadFromJsonAsync<List<CODIdName<int>>>();
}
}
return Cods;
}
public async Task<List<IdName<int>>?> GetPatterns()
{

View File

@@ -1,4 +1,6 @@
@using Shared.DTOs
<Modal @ref="modal" />
<Grid TItem="InvoiceItemDTO"
Class="table table-hover table-bordered table-striped"
DataProvider="DataProvider"
@@ -44,8 +46,9 @@
@code {
[Inject] ModalService ModalService { get; set; } = default!;
[Parameter] public EventCallback<string> OnMultipleOfThree { get; set; }
[Parameter] public IEnumerable<InvoiceItemDTO> InvoiceItems { get; set; }
private Modal modal = default!;
private async Task<GridDataProviderResult<InvoiceItemDTO>> DataProvider(GridDataProviderRequest<InvoiceItemDTO> request)
{
if (InvoiceItems is null) // pull employees only one time for client-side filtering, sorting, and paging
@@ -55,7 +58,39 @@
}
private async Task OnRowClick(GridRowEventArgs<InvoiceItemDTO> args)
{
await ModalService.ShowAsync(new ModalOption { Type = ModalType.Primary, Title = "Event: Row Click", Message = $"Id: {args.Item.ID}, Name: {args.Item.sstt}" });
var parameters = new Dictionary<string, object>();
parameters.Add("itemDTO", args.Item);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "ویرایش اطلاعات", parameters: parameters);
}
public async Task CallBack(ActionInResultComponent result)
{
string msg = "";
if (result.Action == ComponentAction.add)
{
if (result.Status == ComponentStatus.success)
msg="آیتم جدید با موفقیت اضافه شد";
}
else if (result.Action == ComponentAction.update)
{
if (result.Status == ComponentStatus.success)
msg="اطلاعات آیتم با موفقیت ویرایش شد";
}
else if (result.Action == ComponentAction.delete)
{
if (result.Status == ComponentStatus.success)
msg="آیتم با موفقیت حذف شد";
}
// if (result.Status == ComponentStatus.success)
// await LoadCod(1);
await modal.HideAsync();
}
private IEnumerable<InvoiceItemDTO> GetInvoiceItems()
{

View File

@@ -6,6 +6,7 @@
@inject Fixedvalues fv;
@page "/InvoiceDetails/{InvoiceID:int}"
@page "/InvoiceDetails"
<Modal @ref="modal" />
<Preload LoadingText="در حال بارگذاری..." />
<form>
@* alert *@
@@ -125,16 +126,19 @@
<Content>
<div class="row g-3">
<div class="form-group col-md-11">
<LGridInvoiceItem InvoiceItems="invoice.items" />
<LGridInvoiceItem OnMultipleOfThree="EventCallback.Factory.Create<string>(this, CallBack)" InvoiceItems="invoice.items" />
</div>
<div class="form-group col-md-1">
<button class="button-8" role="button">+</button>
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
+
</Button>
</div>
</div>
</Content>
</Tab>
<Tab Title="پرداختی ها">
@* <Tab Title="پرداختی ها">
<Content>
<div class="row g-3">
<div class="form-group col-md-11">
@@ -142,15 +146,15 @@
</div>
<div class="form-group col-md-1">
<Button class="mt-3" Color="ButtonColor.Secondary" @onclick="OnClickDelete" Type="ButtonType.Button">
پرداخت جدید
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="OnClickDelete" Outline="true" Type="ButtonType.Button">
+
</Button>
</div>
</div>
</Content>
</Tab>
</Tab> *@
</Tabs>
</div>
@@ -195,6 +199,7 @@
@code {
private Modal modal = default!;
[Inject] protected PreloadService PreloadService { get; set; } = default!;
// alert
AlertColor alertColor = AlertColor.Primary;
@@ -211,7 +216,7 @@
invoice = new InvoiceDTO();
await base.OnInitializedAsync();
}
protected override async Task OnParametersSetAsync()
{
PreloadService.Show(SpinnerColor.Dark);
@@ -219,14 +224,8 @@
Patterns = await fv.GetPatterns();
if (InvoiceID != null && InvoiceID > 0)
{
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}");
if (rsp.IsSuccessStatusCode)
{
invoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
}
else
hc._nav.NavigateTo("/Pael");
await LoadData();
}
else
{
@@ -247,6 +246,59 @@
}
}
@functions {
private async Task NewItemClick()
{
var parameters = new Dictionary<string, object>();
parameters.Add("itemDTO", new InvoiceItemDTO());
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "آیتم جدید", parameters: parameters);
}
private async Task LoadData()
{
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}");
if (rsp.IsSuccessStatusCode)
{
invoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
}
else
hc._nav.NavigateTo("/Panel");
}
public async Task CallBack(ActionInResultComponent result)
{
string msg = "";
if (result.Action == ComponentAction.add)
{
if (result.Status == ComponentStatus.success)
msg = "آیتم جدید با موفقیت اضافه شد";
}
// else if (result.Action == ComponentAction.update)
// {
// if (result.Status == ComponentStatus.success)
// msg = "اطلاعات آیتم با موفقیت ویرایش شد";
// }
// else if (result.Action == ComponentAction.delete)
// {
// if (result.Status == ComponentStatus.success)
// msg = "آیتم با موفقیت حذف شد";
// }
await CallBack(msg);
// if (result.Status == ComponentStatus.success)
// await LoadCod(1);
await modal.HideAsync();
}
private async Task CallBack(string result)
{
if (!string.IsNullOrEmpty(result))
{
ShowSuccessAlert(result);
await LoadData();
}
}
private void ShowSuccessAlert(string msg)
{
Hidealert = false;

View File

@@ -1,42 +0,0 @@
/* CSS */
.button-8 {
background-color: #e1ecf4;
border-radius: 3px;
border: 1px solid #7aa7c7;
box-shadow: rgba(255, 255, 255, .7) 0 1px 0 0 inset;
box-sizing: border-box;
color: #39739d;
cursor: pointer;
display: inline-block;
font-family: -apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;
font-size: 13px;
font-weight: 400;
line-height: 1.15385;
margin: 0;
outline: none;
padding: 8px .8em;
position: relative;
text-align: center;
text-decoration: none;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
vertical-align: baseline;
white-space: nowrap;
}
.button-8:hover,
.button-8:focus {
background-color: #b3d3ea;
color: #2c5777;
}
.button-8:focus {
box-shadow: 0 0 0 4px rgba(0, 149, 255, .15);
}
.button-8:active {
background-color: #a0c7e4;
box-shadow: none;
color: #2c5777;
}