Files
moadiran/TaxPayerFull/Pages/UserPanel/TaxPayerInvoiceItem.razor

488 lines
22 KiB
Plaintext
Raw Normal View History

2024-05-31 00:24:45 +03:30
@page "/TaxPayerInvoiceItem/{InvoiceID:int}"
2024-07-20 15:52:29 +03:30
@page "/FullInvoiceItem/{InvoiceID:int}"
2024-05-31 00:24:45 +03:30
@using Front.Services
2024-08-09 19:35:50 +03:30
@using Shared
2024-05-31 00:24:45 +03:30
@using Shared.DTOs
@layout PanelLayout
@inject HttpClientController hc;
2024-08-08 18:20:21 +03:30
@inject Fixedvalues fv;
2024-05-31 00:24:45 +03:30
<Preload LoadingText="در حال بارگذاری..." />
<ConfirmDialog @ref="dialog" />
2024-07-22 14:23:29 +03:30
<Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
<Modal @ref="modal" />
2024-07-20 17:35:53 +03:30
@if (FullInvoice)
{
<PageTitle>اطلاعات تکمیلی صورتحساب</PageTitle>
}
else
{
<PageTitle>آماده سازی صورتحساب</PageTitle>
}
2024-06-09 17:23:57 +03:30
2024-06-08 21:48:26 +03:30
@* alert *@
<div class="row">
2024-10-15 14:19:54 +03:30
<div class="col-md-2">
2024-06-08 21:48:26 +03:30
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
<Icon Name="@alertIconName" class="me-2"></Icon>
@alertMessage
</Alert>
2024-10-15 14:19:54 +03:30
</div>
<div class="col-md-2">
<Spinner Visible="SpinnerVisible" Color="SpinnerColor.Primary" />
</div>
2024-06-08 21:48:26 +03:30
</div>
2024-07-20 17:34:28 +03:30
@if (FullInvoice)
{
<h4 class="fw-bold py-3 mb-4">
<span class="text-muted fw-light">سرویس ها / صورتحساب /</span> اطلاعات تکمیلی صورتحساب
</h4>
}
else
{
<h4 class="fw-bold py-3 mb-4">
<span class="text-muted fw-light">سرویس ها / صورتحساب /</span> آماده سازی قبل از ارسال به سامانه مودیان
</h4>
}
2024-07-22 14:23:29 +03:30
@if (!FullInvoice)
2024-07-20 17:34:28 +03:30
{
<div class="row">
<div class="col-md-12">
<div class="card mb-4">
<h4 style="color:red;" class="card-header">توجه</h4>
<div class="card-body">
<p>1) این یک پیش نمایش کامل از صورتحساب شماست با دقت آنرا بررسی کنید</p>
<p>2) یسری از فیلدها قابل دسترس هستند میتوانید در این مرحله اطلاعات تکمیلی بیشتری برای صورتحساب وارد کنید</p>
<p>3) فیلد هایی که قابل دسترسی نیستند به صورت خودکار از صورتحساب پر شده اند</p>
<p>4) فیلد های قرمز را حتما مشخص کنید</p>
</div>
2024-06-08 21:48:26 +03:30
</div>
</div>
</div>
2024-07-20 17:34:28 +03:30
}
2024-06-08 17:13:12 +03:30
<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)
{
2024-07-22 14:23:29 +03:30
<div class="mb-1 col-md-3">
2024-06-08 17:13:12 +03:30
@if (item.ModeID == 1 && item.InputBox != "autofild")
{
2024-07-22 16:19:42 +03:30
if (item.Des != null && item.Des.Count() > 0 && !FullInvoice)
2024-07-22 14:23:29 +03:30
{
2024-08-08 18:20:21 +03:30
<Badge style="cursor: pointer;" @onclick="()=>ShowConditions(item.Des,item.fName)" Color="BadgeColor.Primary" IndicatorType="BadgeIndicatorType.RoundedPill">شرایط خاص</Badge>
<label style="color:red;" class="form-label">@item.fName</label>
2024-07-22 14:23:29 +03:30
}
else
{
<label style="color:red;" class="form-label">@item.fName</label>
}
2024-06-08 17:13:12 +03:30
}
else
{
2024-07-22 16:19:42 +03:30
if (item.Des != null && item.Des.Count() > 0 && !FullInvoice)
2024-07-22 14:23:29 +03:30
{
2024-08-11 20:29:57 +03:30
<Badge style="cursor: pointer;" @onclick="()=>ShowConditions(item.Des,item.fName)" Color="BadgeColor.Primary" IndicatorType="BadgeIndicatorType.RoundedPill">...</Badge>
2024-08-08 18:20:21 +03:30
<label class="form-label">@item.fName</label>
2024-07-22 14:23:29 +03:30
}
else
{
<label class="form-label">@item.fName</label>
}
2024-06-08 17:13:12 +03:30
}
@if (item.InputBox == "fromdb")
{
<select @bind="item.Value" class="form-control" aria-label="Default select example">
2024-07-22 14:23:29 +03:30
<option style="color: #b5b5b5; " selected>@item.fName...</option>
2024-06-08 17:13:12 +03:30
@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")
{
2024-08-08 18:20:21 +03:30
if (item.eName.ToLower() == "inty")
{
var bill = BillTypes.Where(w => w.ID == Convert.ToInt32(item.Value)).Select(s => s.Title).FirstOrDefault();
2024-08-09 23:20:25 +03:30
<input value="@bill" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" disabled />
2024-08-08 18:20:21 +03:30
}
else if (item.eName.ToLower() == "inp")
{
2024-08-11 18:59:36 +03:30
patt = item.Value;
2024-08-09 23:20:25 +03:30
var _patt = Patterns.Where(w => w.ID == Convert.ToInt32(item.Value)).Select(s => s.Title).FirstOrDefault();
<input value="@_patt" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" disabled />
2024-08-08 18:20:21 +03:30
}
else if (item.eName.ToLower() == "ins")
{
2024-08-09 19:35:50 +03:30
InvoiceType foo = (InvoiceType)Enum.Parse(typeof(InvoiceType), item.Value);
2024-08-09 23:20:25 +03:30
<input value="@foo.GetEnumDisplayName()" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" disabled />
2024-08-08 18:20:21 +03:30
}
2024-08-11 18:59:36 +03:30
else if (item.eName.ToLower() == "tob")
2024-08-08 18:20:21 +03:30
{
2024-08-09 19:35:50 +03:30
CustomerType foo = (CustomerType)Enum.Parse(typeof(CustomerType), item.Value);
2024-08-09 23:20:25 +03:30
<input value="@foo.GetEnumDisplayName()" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" disabled />
2024-08-09 19:35:50 +03:30
2024-08-09 23:20:25 +03:30
}
else
{
2024-08-08 18:20:21 +03:30
<input @bind-value="item.Value" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" disabled />
2024-08-09 23:20:25 +03:30
}
2024-08-08 18:20:21 +03:30
2024-08-11 18:59:36 +03:30
2024-06-08 17:13:12 +03:30
}
2024-06-08 21:48:26 +03:30
else
2024-06-08 17:13:12 +03:30
{
<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">
2024-06-08 21:48:26 +03:30
<div class="col-md-12">
2024-06-08 17:13:12 +03:30
<div class="card mb-4">
2024-06-08 21:48:26 +03:30
<h5 class="card-header">اطلاعات تکمیلی بدنه صورتحساب (کالاها)</h5>
2024-06-08 17:13:12 +03:30
<div class="card-body">
2024-06-08 21:48:26 +03:30
@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)
2024-06-08 17:13:12 +03:30
{
2024-07-22 14:23:29 +03:30
<div class="mb-1 col-md-3">
2024-06-08 21:48:26 +03:30
@if (itemB.ModeID == 1 && itemB.InputBox != "autofild")
2024-06-08 17:13:12 +03:30
{
2024-07-22 16:19:42 +03:30
if (itemB.Des != null && itemB.Des.Count() > 0 && !FullInvoice)
2024-07-22 14:23:29 +03:30
{
2024-08-11 20:29:57 +03:30
<Badge style="cursor: pointer;" @onclick="()=>ShowConditions(itemB.Des,itemB.fName)" Color="BadgeColor.Primary" IndicatorType="BadgeIndicatorType.RoundedPill">...</Badge>
2024-08-08 18:20:21 +03:30
<label style="color:red;" class="form-label">@itemB.fName</label>
2024-07-22 14:23:29 +03:30
}
else
{
<label style="color:red;" class="form-label">@itemB.fName</label>
}
2024-06-08 17:13:12 +03:30
}
2024-06-08 21:48:26 +03:30
else
{
2024-07-22 16:19:42 +03:30
if (itemB.Des != null && itemB.Des.Count() > 0 && !FullInvoice)
2024-07-22 14:23:29 +03:30
{
2024-08-11 20:29:57 +03:30
<Badge style="cursor: pointer;" @onclick="()=>ShowConditions(itemB.Des,itemB.fName)" Color="BadgeColor.Primary" IndicatorType="BadgeIndicatorType.RoundedPill">...</Badge>
2024-08-08 18:20:21 +03:30
<label class="form-label">@itemB.fName</label>
2024-07-22 14:23:29 +03:30
}
else
{
<label class="form-label">@itemB.fName</label>
}
2024-06-08 21:48:26 +03:30
}
@if (itemB.InputBox == "fromdb")
{
2024-06-08 17:13:12 +03:30
2024-06-08 21:48:26 +03:30
<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>
2024-06-08 17:13:12 +03:30
2024-06-08 21:48:26 +03:30
}
2024-08-09 23:20:25 +03:30
else if (itemB.InputBox == "autofild" || (itemB.eName.ToLower() == "_cfee" && patt != "2"))
2024-06-08 21:48:26 +03:30
{
2024-08-11 18:59:36 +03:30
@if (itemB.eName.ToLower() == "mu")
{
var mu = units.Where(w => w.ID == Convert.ToInt32(itemB.Value)).Select(s => s.Title).FirstOrDefault();
<input value="@mu" 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" disabled />
}
2024-06-08 21:48:26 +03:30
}
else
{
<input @bind-value="itemB.Value" style="text-align:center;" class="form-control" type="text" placeholder="@itemB.fName" />
}
2024-06-08 17:13:12 +03:30
2024-08-11 18:59:36 +03:30
2024-06-08 21:48:26 +03:30
</div>
}
2024-06-08 17:13:12 +03:30
</div>
2024-06-08 21:48:26 +03:30
</Content>
</AccordionItem>
2024-06-08 17:13:12 +03:30
</div>
</div>
2024-06-08 21:48:26 +03:30
}
2024-06-08 17:13:12 +03:30
2024-06-08 21:48:26 +03:30
</Accordion>
2024-06-08 17:13:12 +03:30
2024-06-08 21:48:26 +03:30
}
2024-06-08 17:13:12 +03:30
</div>
</div>
</div>
2024-06-08 21:48:26 +03:30
</div>
2024-06-08 17:13:12 +03:30
2024-06-08 21:48:26 +03:30
2024-07-22 14:23:29 +03:30
@if (invoice != null)
2024-06-08 21:48:26 +03:30
{
@* action *@
<div class="row">
<div class="col-md-12">
<div class="mb-2">
<div class="row">
2024-10-16 16:35:38 +03:30
<div class="col-md-6">
2024-07-20 17:34:28 +03:30
@if (FullInvoice)
{
2024-10-15 14:19:54 +03:30
<Button Disabled="SpinnerVisible" Color="ButtonColor.Primary" @onclick="Send">ثبت تغییرات</Button>
2024-07-20 17:34:28 +03:30
}
else
{
2024-10-15 14:19:54 +03:30
<Button Disabled="SpinnerVisible" Color="ButtonColor.Primary" @onclick="Send">آماده سازی و ارسال</Button>
2024-07-20 17:34:28 +03:30
}
2024-07-22 14:23:29 +03:30
2024-10-16 16:35:38 +03:30
</div>
<div class="col-md-1">
<Spinner Visible="SpinnerVisible" Color="SpinnerColor.Primary" />
2024-06-08 17:13:12 +03:30
</div>
</div>
</div>
</div>
</div>
2024-06-08 21:48:26 +03:30
}
2024-06-08 17:13:12 +03:30
2024-05-31 00:24:45 +03:30
@code {
2024-10-15 14:19:54 +03:30
public bool SpinnerVisible { get; set; } = false;
2024-08-09 23:20:25 +03:30
string patt = "";
2024-08-08 18:20:21 +03:30
private List<IdName<int>>? Patterns = new List<IdName<int>>();
private List<IdName<int>>? BillTypes = new List<IdName<int>>();
2024-08-11 18:59:36 +03:30
private List<IdName<int>>? units = new List<IdName<int>>();
2024-07-22 14:23:29 +03:30
private Modal modal = default!;
2024-05-31 00:24:45 +03:30
private ConfirmDialog dialog = default!;
[Parameter] public int? InvoiceID { get; set; }
List<ToastMessage> messages = new List<ToastMessage>();
[Inject] protected PreloadService PreloadService { get; set; } = default!;
2024-06-01 12:58:04 +03:30
public _TaxPayer.Atemplatefield? invoice { get; set; }
2024-07-20 17:34:28 +03:30
public bool FullInvoice { get; set; } = true;
2024-05-31 00:24:45 +03:30
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
2024-06-01 12:58:04 +03:30
protected override async Task OnParametersSetAsync()
2024-05-31 00:24:45 +03:30
{
2024-10-15 14:19:54 +03:30
SpinnerVisible = true;
2024-06-08 21:48:26 +03:30
PreloadService.Show(SpinnerColor.Dark);
2024-08-08 18:20:21 +03:30
Patterns = await fv.GetPatternsbyinp();
BillTypes = await fv.GetBillTypes();
2024-08-11 18:59:36 +03:30
units = await fv.GetUnitsbyUnitTaxID();
2024-10-15 14:19:54 +03:30
SpinnerVisible = false;
2024-05-31 00:24:45 +03:30
await LoadData();
2024-06-08 21:48:26 +03:30
PreloadService.Hide();
2024-07-20 15:52:29 +03:30
2024-07-20 17:34:28 +03:30
if (hc._nav.Uri.ToString().Contains("FullInvoiceItem"))
FullInvoice = true;
else FullInvoice = false;
2024-06-01 12:58:04 +03:30
await base.OnParametersSetAsync();
2024-06-08 17:13:12 +03:30
2024-05-31 00:24:45 +03:30
}
2024-06-01 12:58:04 +03:30
2024-05-31 00:24:45 +03:30
}
2024-06-08 17:13:12 +03:30
@functions {
2024-06-08 21:48:26 +03:30
private void ShowMessage(ToastType toastType, string msg) => messages.Add(CreateToastMessage(toastType, msg));
private ToastMessage CreateToastMessage(ToastType toastType, string msg)
=> new ToastMessage
{
Type = toastType,
Message = msg,
};
2024-06-08 17:13:12 +03:30
public async Task Send()
{
2024-10-15 14:19:54 +03:30
SpinnerVisible = true;
2024-10-16 16:35:38 +03:30
2024-07-22 22:29:28 +03:30
string route = "PreparationInvoiceBeforeSending";
if (FullInvoice)
route = "UpdateInvoice";
var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/{route}", invoice);
2024-06-09 17:23:57 +03:30
if (rsp.IsSuccessStatusCode)
2024-06-08 17:13:12 +03:30
{
2024-06-09 17:23:57 +03:30
var response = await rsp.Content.ReadFromJsonAsync<bool>();
if (response)
{
2024-07-22 14:23:29 +03:30
if (FullInvoice)
ShowMessage(ToastType.Success, "تغییرات با موفقیت انجام شد");
2024-07-20 17:34:28 +03:30
2024-07-22 22:29:28 +03:30
else
2024-06-09 17:23:57 +03:30
{
2024-07-20 17:34:28 +03:30
ShowMessage(ToastType.Light, "در حال ارسال صورتحساب");
rsp = await hc.Get($"TaxPayer/SendInvoice/{InvoiceID}");
if (rsp.IsSuccessStatusCode)
2024-06-09 17:23:57 +03:30
{
2024-07-20 17:34:28 +03:30
response = await rsp.Content.ReadFromJsonAsync<bool>();
if (response)
{
hc._nav.NavigateTo($"TaxPayer/{InvoiceID}");
// ShowMessage(ToastType.Success, "ارسال با موفقیت انجام شد");
}
else
{
ShowMessage(ToastType.Danger, "خطای در ارسال رخ داده");
}
2024-06-09 17:23:57 +03:30
}
else
{
2024-07-20 17:34:28 +03:30
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowMessage(ToastType.Danger, request[0]);
2024-06-09 17:23:57 +03:30
}
}
2024-07-22 14:23:29 +03:30
2024-06-09 17:23:57 +03:30
}
else
{
2024-08-08 18:20:21 +03:30
ShowMessage(ToastType.Danger, "خطای در آماده سازی اطلاعات رخ داده");
2024-06-09 17:23:57 +03:30
}
2024-06-08 17:13:12 +03:30
}
else
{
2024-06-09 17:23:57 +03:30
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowMessage(ToastType.Danger, request[0]);
2024-06-08 17:13:12 +03:30
}
2024-10-16 16:35:38 +03:30
2024-10-15 14:19:54 +03:30
SpinnerVisible = false;
2024-06-09 17:23:57 +03:30
}
public async Task<bool> CheckAuth()
{
2024-10-15 14:19:54 +03:30
SpinnerVisible = true;
2024-06-09 17:23:57 +03:30
var rsp = await hc.Get($"TaxPayer/CheckAuth");
if (rsp.IsSuccessStatusCode)
2024-06-08 17:13:12 +03:30
{
2024-06-09 17:23:57 +03:30
var response = await rsp.Content.ReadFromJsonAsync<bool>();
if (response)
{
2024-10-15 14:19:54 +03:30
SpinnerVisible = false;
2024-06-09 17:23:57 +03:30
return true;
}
2024-06-08 17:13:12 +03:30
}
2024-10-15 14:19:54 +03:30
SpinnerVisible = false;
2024-06-09 17:23:57 +03:30
return false;
2024-06-08 17:13:12 +03:30
}
2024-05-31 00:24:45 +03:30
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;
}
private async Task LoadData()
{
2024-10-15 14:19:54 +03:30
SpinnerVisible = true;
2024-05-31 22:08:09 +03:30
var rsp = await hc.Get($"TaxPayer/GetInvoice/{InvoiceID}");
2024-05-31 00:24:45 +03:30
if (rsp.IsSuccessStatusCode)
{
2024-06-01 12:58:04 +03:30
invoice = await rsp.Content.ReadFromJsonAsync<_TaxPayer.Atemplatefield?>();
2024-05-31 00:24:45 +03:30
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
2024-10-15 14:19:54 +03:30
SpinnerVisible = false;
2024-05-31 00:24:45 +03:30
}
2024-07-22 14:23:29 +03:30
private async Task ShowConditions(string[]? Conditions, string fild)
{
if (Conditions != null)
{
var parameters = new Dictionary<string, object>();
parameters.Add("Conditions", Conditions);
2024-08-11 20:29:57 +03:30
await modal.ShowAsync<CUSComponent.SpecialConditions>(title: $"فیلد {fild}", parameters: parameters);
2024-07-22 14:23:29 +03:30
}
}
2024-05-31 00:24:45 +03:30
}