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

822 lines
32 KiB
Plaintext
Raw Normal View History

2024-05-14 15:57:34 +03:30
@using Front.Services
@using Shared.DTOs
2024-05-16 23:40:32 +03:30
@using Shared
2024-07-01 15:39:40 +03:30
@inject IJSRuntime JS
2024-05-30 15:08:36 +03:30
2024-05-14 15:57:34 +03:30
@inject HttpClientController hc;
2024-05-17 23:05:46 +03:30
@layout PanelLayout
@inject Fixedvalues fv;
@page "/InvoiceDetails/{InvoiceID:int}"
@page "/InvoiceDetails"
2024-05-23 19:59:19 +03:30
<Modal @ref="modal" />
2024-05-17 23:05:46 +03:30
<Preload LoadingText="در حال بارگذاری..." />
2024-05-26 18:16:36 +03:30
<ConfirmDialog @ref="dialog" />
2024-05-28 17:29:20 +03:30
<Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
2024-05-31 00:24:45 +03:30
<PageTitle>جزئیات صورتحساب</PageTitle>
2024-05-30 15:08:36 +03:30
2024-07-03 16:05:28 +03:30
<Modal @ref="Codemodal" title="لینک برای دانلود" IsVerticallyCentered="true">
<BodyTemplate>
2024-07-04 17:18:59 +03:30
<h5>با لینک زیر دیگران میتوانند به این صورتحساب دسترسی داشته باشند</h5>
<NavLink href="@ExUrl">@ExUrl</NavLink>
2024-07-03 16:05:28 +03:30
</BodyTemplate>
<FooterTemplate>
<Button Color="ButtonColor.Secondary" @onclick="OnHideModalClick">Close</Button>
</FooterTemplate>
</Modal>
2024-05-30 15:08:36 +03:30
@if (invoice.IsDeleted)
{
<h1 style="color:red">این صورتحساب حذف شده و در دسترس نمی باشد</h1>
<br />
<hr class="hr" />
}
2024-05-14 15:57:34 +03:30
<form>
2024-07-01 15:39:40 +03:30
@if (InvoiceID.HasValue)
{
2024-05-31 00:24:45 +03:30
<h4 class="fw-bold py-3 mb-4">
<span class="text-muted fw-light">سرویس ها / صورتحساب /</span> @invoice?.Title
2024-07-01 15:39:40 +03:30
</h4>
}
else
{
2024-05-31 00:24:45 +03:30
<h4 class="fw-bold py-3 mb-4">
<span class="text-muted fw-light">سرویس ها / صورتحساب /</span> جدید
</h4>
2024-07-01 15:39:40 +03:30
}
2024-05-31 00:24:45 +03:30
2024-05-14 15:57:34 +03:30
@* alert *@
<div class="row">
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
<Icon Name="@alertIconName" class="me-2"></Icon>
@alertMessage
</Alert>
</div>
2024-05-30 15:08:36 +03:30
@if (InvoiceID == 0 || InvoiceID == null ? false : true && !invoice.IsDeleted)
2024-05-28 17:29:20 +03:30
{
<div class="row g-3">
2024-07-23 22:30:52 +03:30
<div class="form-group col-md-9">
2024-07-24 22:56:46 +03:30
@if (invoice.invoiceType!=InvoiceType.Cancellation)
2024-05-29 11:17:30 +03:30
{
2024-07-24 22:56:46 +03:30
<div class="multi-button">
@switch (invoice.invoiceType)
{
case (InvoiceType.Bidding):
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Sale)" id="cut"><span>فاکتور</span></Button>
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred1"><span>ابطال</span></Button>
break;
case (InvoiceType.Sale):
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.BackFrmSale)" id="copy"><span>برگشت فروش</span></Button>
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Repair)" id="paste"><span>اصلاح</span></Button>
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred"><span>ابطال</span></Button>
@* <Button class="button" style="color:white;" id="sred1" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)"><span>لغو</span></Button> *@
break;
case (InvoiceType.BackFrmSale):
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred"><span>ابطال</span></Button>
@* <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)" id="sred1"><span>لغو</span></Button> *@
break;
case (InvoiceType.Repair):
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred"><span>ابطال</span></Button>
@* <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)" id="sred1"><span>لغو</span></Button> *@
<Button class="button" style="color:white;" id="copy" @onclick="() => ChangeStatus((int)InvoiceType.BackFrmSale)"><span>برگشت فروش</span></Button>
break;
@* case (InvoiceType.Cancellation):
<Button class="button" style="color:white;" id="sred1" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)"><span>لغو</span></Button>
break; *@
}
2024-07-01 15:39:40 +03:30
2024-07-24 22:56:46 +03:30
</div>
}
2024-07-01 15:39:40 +03:30
2024-07-23 22:30:52 +03:30
</div>
<div class="form-group col-md-3">
<div class="multi-button">
2024-07-24 22:56:46 +03:30
<Tooltip Title="کپی از صورتحساب">
<Button style="color:white;" @onclick="CopyInvoice">
<img height="20" width="20" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVR4nO3YMQrCMBTG8dzuDeqqS72A4j0CdSx01QO49goloGQo3YSMrl27JNJdTZr3oqW+P2Sz8PNrBlGIuQaydtizPKprUqDpbPQZnt8U2q5ypSYLvLS9WxfaLnJ1mySwutt0SCpgFYKkuPD7UxMN9CKHD2MCWbttqd3h3EYDPyIpgM2jd1mp3S5wyVfAt0gKoOnsKGTItSEHmpFI3xdIAjREyKRAQ4BMDjRIJDkQPOenQF8MxAb8ipEBL4gMeEFkwAsiA14QGfCCyIAXRAa8IDKI/Dvlqz/5BSYGyn9YEBIfMdeel7WFVd/aZ3IAAAAASUVORK5CYII=">
</Button>
</Tooltip>
2024-07-01 15:39:40 +03:30
2024-07-23 22:30:52 +03:30
</div>
2024-05-28 17:29:20 +03:30
</div>
</div>
2024-07-23 22:30:52 +03:30
2024-05-28 17:29:20 +03:30
<br />
2024-07-01 15:39:40 +03:30
@if (invoice.InvoiceSendTaxs.Count > 0)
2024-06-12 07:54:43 +03:30
{
2024-07-01 15:39:40 +03:30
if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType == invoice.invoiceType
&& a.SentStatus == SentStatus.Send))
2024-06-12 07:54:43 +03:30
{
2024-06-14 22:37:22 +03:30
SendInvoice = false;
2024-07-01 15:39:40 +03:30
<h6>این صورتحساب با این وضعیت به سامانه مودیان ارسال شده ،برای اطلاع از وضعیت لطفا تعیین وضعیت کنید</h6>
2024-06-12 07:54:43 +03:30
}
else if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType == invoice.invoiceType
&& a.SentStatus == SentStatus.Successful))
{
2024-06-14 22:37:22 +03:30
SendInvoice = false;
2024-06-12 07:54:43 +03:30
<h6>
این صورتحساب با این وضعیت به سامانه مودیان ارسال و تائید شده
</h6>
}
else if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType == invoice.invoiceType
&& a.SentStatus == SentStatus.Unsuccessful))
{
SendInvoice = true;
<h6 style="color:red;">این صورتحساب با این وضعیت به سامانه مودیان ارسال ولی تائید نشده</h6>
}
else if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType == invoice.invoiceType
&& (a.SentStatus == SentStatus.pending || a.SentStatus == SentStatus.IN_PROGRESS)))
{
2024-06-14 22:37:22 +03:30
SendInvoice = false;
2024-07-01 15:39:40 +03:30
<h6>
2024-06-12 07:54:43 +03:30
این صورتحساب با این وضعیت به سامانه مودیان ارسال و در حال بررسی می باشد
</h6>
}
else if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType == invoice.invoiceType
&& (a.SentStatus == SentStatus.NOT_FOUND || a.SentStatus == SentStatus.Unknown)))
{
2024-06-14 22:37:22 +03:30
SendInvoice = false;
2024-07-01 15:39:40 +03:30
<h6>
2024-06-12 07:54:43 +03:30
این صورتحساب با این وضعیت به سامانه مودیان ارسال شده ولی وضعیت آن مشخص نیست
</h6>
}
else if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType != invoice.invoiceType))
{
SendInvoice = true;
<h6>این صورتحساب با این وضعیت به سامانه مودیان ارسال نشده</h6>
}
}
else SendInvoice = true;
2024-07-01 15:39:40 +03:30
2024-05-28 17:29:20 +03:30
<hr class="hr" />
}
2024-05-14 15:57:34 +03:30
<div class="row g-3">
2024-05-16 23:40:32 +03:30
<div class="form-group col-md-2">
<label class="col-sm-4 col-form-label" style="color:red" for="inputTitle">عنوان</label>
<InputText @bind-Value="invoice.Title" type="text" class="form-control" id="inputTitle" placeholder="عنوان" />
2024-05-14 15:57:34 +03:30
</div>
2024-05-16 23:40:32 +03:30
<div class="form-group col-md-2">
<label class="col-sm-4 col-form-label" for="inputinvoiceTypeTitle">نوع</label>
2024-05-28 17:29:20 +03:30
<select @bind="invoice.invoiceType" class="form-control" aria-label="Default select example" disabled id="inputinvoiceTypeTitle">
2024-05-16 23:40:32 +03:30
@if (!invoice.invoiceType.HasValue)
2024-05-14 15:57:34 +03:30
{
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
}
else
{
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
}
2024-05-17 23:05:46 +03:30
@foreach (InvoiceType i in Enum.GetValues(typeof(InvoiceType)))
{
2024-05-16 23:40:32 +03:30
if (invoice.invoiceType == i)
{
<option value="@i" selected>@i.GetEnumDisplayName()</option>
}
else
{
<option value="@i">@i.GetEnumDisplayName()</option>
}
2024-05-17 23:05:46 +03:30
}
2024-05-27 22:01:14 +03:30
</select>
2024-05-16 23:40:32 +03:30
</div>
<div class="form-group col-md-2">
<label class="col-sm-8 col-form-label" for="inputPatternID">الگو صورتحساب</label>
<select @bind="invoice.PatternID" class="form-control" aria-label="Default select example" id="inputPatternID">
2024-05-17 23:05:46 +03:30
@if (invoice.PatternID == null || invoice.PatternID == 0)
2024-05-16 23:40:32 +03:30
{
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
}
else
2024-05-14 15:57:34 +03:30
{
2024-05-16 23:40:32 +03:30
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
}
@if (Patterns != null)
{
foreach (var item in Patterns)
2024-05-14 15:57:34 +03:30
{
2024-05-16 23:40:32 +03:30
if (invoice.PatternID == item.ID)
2024-05-14 15:57:34 +03:30
{
<option value="@item.ID" selected>@item.Title</option>
}
else
{
<option value="@item.ID">@item.Title</option>
}
}
}
</select>
</div>
2024-05-16 23:40:32 +03:30
<div class="form-group col-md-2">
<label class="col-sm-5 col-form-label" style="color:red" for="inputCustomerID">مشتری</label>
<select @bind="invoice.CustomerID" class="form-control" aria-label="Default select example" id="inputCustomerID">
@if (invoice.CustomerID == null || invoice.CustomerID == 0)
{
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
}
else
{
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
}
@if (Cus != null)
{
foreach (var item in Cus)
{
if (invoice.CustomerID == item.ID)
{
<option value="@item.ID" selected>@item.CustomerName</option>
}
else
{
<option value="@item.ID">@item.CustomerName</option>
}
}
}
</select>
</div>
<div class="form-group col-md-2">
<label class="col-sm-5 col-form-label" for="inputInvoicIssueDate">تاریخ صدور</label>
<InputText style=" text-align: center;" @bind-Value="invoice.InvoicIssueDate" type="text" class="form-control" id="inputInvoicIssueDate" placeholder="تاریخ صدور" />
</div>
<div class="form-group col-md-2">
<label class="col-sm-4 col-form-label" for="inputInvoiceDate">تاریخ</label>
<InputText style=" text-align: center;" @bind-Value="invoice.InvoiceDate" type="text" class="form-control" id="inputInvoiceDate" placeholder="تاریخ" />
</div>
</div>
2024-07-01 15:39:40 +03:30
@if (InvoiceID == 0 || InvoiceID == null ? false : true)
2024-05-28 17:29:20 +03:30
{
<br /> <hr class="hr" />
<div class="row g-3">
@* <Tabs NavStyle="NavStyle.VerticalUnderline">
<Tab Title="آیتم ها" IsActive="true">
<Content> *@
2024-05-26 17:25:34 +03:30
<div class="row g-3">
2024-05-28 17:29:20 +03:30
<div class="form-group col-md-11">
@if (InvoiceID.HasValue && invoice.items.Count > 0)
{
2024-05-30 15:08:36 +03:30
<LGridInvoiceItem IsDeleted="invoice.IsDeleted" InvoiceID="InvoiceID.Value" OnMultipleOfThree="EventCallback.Factory.Create<string>(this, CallBack)" InvoiceItems="invoice.items" />
2024-05-26 17:25:34 +03:30
2024-05-28 17:29:20 +03:30
}
</div>
<div class="form-group col-md-1">
2024-05-30 15:08:36 +03:30
@if (!invoice.IsDeleted)
{
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
+
</Button>
}
2024-07-01 15:39:40 +03:30
2024-05-28 17:29:20 +03:30
</div>
2024-05-26 17:25:34 +03:30
</div>
2024-05-28 17:29:20 +03:30
@* </Content>
</Tab> *@
@* <Tab Title="پرداختی ها">
<Content>
<div class="row g-3">
<div class="form-group col-md-11">
<LGridInvoicePayment InvoicePays="invoice.payments" />
</div>
<div class="form-group col-md-1">
2024-05-26 17:25:34 +03:30
2024-05-28 17:29:20 +03:30
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="OnClickDelete" Outline="true" Type="ButtonType.Button">
+
</Button>
</div>
</div>
2024-05-17 23:05:46 +03:30
2024-05-28 17:29:20 +03:30
</Content>
</Tab> *@
@* </Tabs> *@
</div>
2024-05-27 18:01:50 +03:30
}
2024-07-01 15:39:40 +03:30
<br />
2024-05-16 23:40:32 +03:30
<hr class="hr" />
2024-05-28 17:29:20 +03:30
<div class="row g-3">
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مجموع تخفیف</label>
<CurrencyInput TValue="decimal?" @bind-Value="invoice.tdis" Locale="fa-Ir" Placeholder="مجموع تخفیف" readonly />
</div>
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مجموع مالیات</label>
<CurrencyInput TValue="decimal?" @bind-Value="invoice.tvam" Locale="fa-Ir" Placeholder="مجموع مالیات" readonly />
</div> <div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مجموع صورتحساب</label>
<CurrencyInput TValue="decimal?" @bind-Value="invoice.tbill" Locale="fa-Ir" Placeholder="مجموع صورتحساب" readonly />
</div>
</div>
2024-05-16 23:40:32 +03:30
<br />
2024-05-14 15:57:34 +03:30
<div class="row g-3">
2024-05-31 00:24:45 +03:30
<div class="form-group col-md-4">
2024-05-27 18:01:50 +03:30
<label class="col-form-label" for="inputdes">توضیحات</label>
2024-05-16 23:40:32 +03:30
<InputText @bind-Value="invoice.Des" type="text" class="form-control" id="inputdes" placeholder="توضیحات" />
2024-05-14 15:57:34 +03:30
</div>
2024-05-23 01:16:59 +03:30
<div class="form-group col-md-2">
2024-05-27 18:01:50 +03:30
<label class="col-form-label" for="inputUdate">آخرین ویرایش</label>
2024-05-16 23:40:32 +03:30
<InputText style=" text-align: center;" @bind-Value="invoice.Udate" class="form-control" id="inputUdate" readonly />
2024-05-17 23:05:46 +03:30
2024-05-14 15:57:34 +03:30
</div>
2024-07-01 15:39:40 +03:30
2024-05-27 18:01:50 +03:30
<div class="form-group col-md-4">
2024-05-23 01:16:59 +03:30
<br />
2024-05-30 15:08:36 +03:30
@if (!invoice.IsDeleted)
2024-05-23 01:16:59 +03:30
{
2024-05-30 15:08:36 +03:30
@if (InvoiceID == 0 || InvoiceID == null)
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
جدید
</Button>
}
else
{
2024-07-20 17:34:28 +03:30
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
ثبت تغییرات
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
حذف
</Button>
<Button class="mt-3" Color="ButtonColor.Primary" @onclick="showFullInvoiceItem" Type="ButtonType.Button">
اطلاعات تکمیلی
</Button>
2024-07-08 22:51:59 +03:30
@* <Button class="mt-3" Color="ButtonColor.Primary" @onclick="ShowReport" Type="ButtonType.Button">
2024-07-01 22:59:01 +03:30
pdf
2024-07-01 15:39:40 +03:30
</Button>
2024-07-06 16:18:23 +03:30
<Button class="mt-3" Color="ButtonColor.Info" @onclick="onClickLink" Type="ButtonType.Button">
2024-07-03 16:05:28 +03:30
لینک
2024-07-08 22:51:59 +03:30
</Button> *@
2024-05-30 15:08:36 +03:30
}
2024-05-23 01:16:59 +03:30
}
2024-07-01 15:39:40 +03:30
2024-05-30 15:08:36 +03:30
</div>
2024-07-20 17:34:28 +03:30
@if (!invoice.IsDeleted && invoice.invoiceType != InvoiceType.Bidding && SendInvoice)
2024-05-31 00:24:45 +03:30
{
<div class="form-group col-md-2">
<br />
2024-06-01 12:58:04 +03:30
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="showTaxPayer" Type="ButtonType.Button">
2024-05-31 00:24:45 +03:30
ارسال به سامانه مودیان
</Button>
</div>
}
2024-07-01 15:39:40 +03:30
2024-05-30 15:08:36 +03:30
</div>
<br />
<div class="row g-3">
2024-07-01 15:39:40 +03:30
@if (invoice.BillReference.HasValue)
{
<div class="row g-3">
@{
string Prefence = "InvoiceDetails/" + invoice.BillReference.Value.ToString();
}
<Button Color="ButtonColor.Link"><NavLink href="@Prefence">صورتحساب مرجع</NavLink></Button>
</div>
}
2024-05-14 15:57:34 +03:30
</div>
</form>
2024-05-23 01:16:59 +03:30
2024-05-14 15:57:34 +03:30
@code {
2024-07-03 16:05:28 +03:30
private Modal Codemodal = default!;
2024-06-12 07:54:43 +03:30
public bool SendInvoice { get; set; } = false;
2024-05-28 17:29:20 +03:30
List<ToastMessage> messages = new List<ToastMessage>();
2024-05-26 18:16:36 +03:30
private ConfirmDialog dialog = default!;
2024-05-23 19:59:19 +03:30
private Modal modal = default!;
2024-05-17 23:05:46 +03:30
[Inject] protected PreloadService PreloadService { get; set; } = default!;
2024-05-14 15:57:34 +03:30
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
2024-05-17 23:05:46 +03:30
[Parameter] public int? InvoiceID { get; set; }
public List<ForCustomerSearch>? Cus { get; set; }
public List<IdName<int>>? Patterns { get; set; }
public InvoiceDTO? invoice { get; set; }
2024-07-03 16:05:28 +03:30
public string ExUrl { get; set; } = "";
2024-05-17 23:05:46 +03:30
protected override async Task OnInitializedAsync()
{
2024-06-14 22:37:22 +03:30
fv.invoice = null;
2024-05-17 23:05:46 +03:30
invoice = new InvoiceDTO();
await base.OnInitializedAsync();
}
2024-05-26 17:25:34 +03:30
2024-05-17 23:05:46 +03:30
protected override async Task OnParametersSetAsync()
2024-05-14 15:57:34 +03:30
{
2024-05-28 15:03:08 +03:30
2024-05-23 01:16:59 +03:30
Cus = await fv.GetCustomers();
2024-05-17 23:05:46 +03:30
Patterns = await fv.GetPatterns();
if (InvoiceID != null && InvoiceID > 0)
{
2024-05-26 17:25:34 +03:30
2024-05-23 19:59:19 +03:30
await LoadData();
2024-05-17 23:05:46 +03:30
}
else
{
invoice = new InvoiceDTO()
{
2024-05-28 17:29:20 +03:30
invoiceType = InvoiceType.Bidding,
2024-05-17 23:05:46 +03:30
ID = 0,
InvoiceDate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(),
InvoicIssueDate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(),
Udate = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront()
};
}
2024-05-23 01:16:59 +03:30
2024-05-17 23:05:46 +03:30
2024-05-14 15:57:34 +03:30
Hidealert = true;
alertMessage = "";
2024-05-28 17:29:20 +03:30
2024-05-17 23:05:46 +03:30
await base.OnParametersSetAsync();
2024-05-14 15:57:34 +03:30
}
}
@functions {
2024-07-03 16:05:28 +03:30
private async Task OnHideModalClick()
{
await Codemodal.HideAsync();
}
2024-05-28 17:29:20 +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-05-23 19:59:19 +03:30
private async Task NewItemClick()
{
2024-05-26 17:25:34 +03:30
if (InvoiceID.HasValue)
{
var parameters = new Dictionary<string, object>();
2024-05-23 19:59:19 +03:30
2024-05-26 17:25:34 +03:30
parameters.Add("InvoiceID", InvoiceID);
parameters.Add("itemDTO", new InvoiceItemDTO());
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "آیتم جدید", parameters: parameters);
}
2024-05-23 19:59:19 +03:30
2024-07-23 22:30:52 +03:30
}
private async Task CopyInvoice()
{
var rsp = await hc.Post($"Invoice/CopyInvoice/{InvoiceID}");
if (rsp.IsSuccessStatusCode)
{
var resinvoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
if (resinvoice != null)
{
invoice = resinvoice;
InvoiceID = resinvoice.ID;
ShowSuccessAlert("صورتحساب جدید با موفقیت ایجاد شد");
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
2024-07-24 22:56:46 +03:30
else if (rsp.StatusCode==System.Net.HttpStatusCode.NotFound)
{
ShowDangerAlert("صورتحساب یافت نشد");
}
2024-07-23 22:30:52 +03:30
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
2024-05-23 19:59:19 +03:30
}
2024-05-30 15:08:36 +03:30
private async Task ChangeStatus(int type)
2024-05-29 15:51:06 +03:30
{
2024-05-30 15:08:36 +03:30
var rsp = await hc.Post($"Invoice/ChangeInvoiceType/{InvoiceID}?invoiceType={type}");
2024-05-29 15:51:06 +03:30
if (rsp.IsSuccessStatusCode)
{
var resinvoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
2024-07-01 15:39:40 +03:30
if (resinvoice != null)
2024-05-29 15:51:06 +03:30
{
invoice = resinvoice;
2024-05-30 15:08:36 +03:30
InvoiceID = resinvoice.ID;
2024-05-29 15:51:06 +03:30
ShowSuccessAlert("تغییر وضعیت با موفقیت انجام شد");
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
2024-07-24 22:56:46 +03:30
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
{
ShowDangerAlert("صورتحساب یافت نشد");
}
2024-05-29 15:51:06 +03:30
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
2024-05-30 15:08:36 +03:30
2024-05-29 15:51:06 +03:30
}
2024-06-01 12:58:04 +03:30
private async Task showTaxPayer()
{
if (InvoiceID.HasValue)
{
hc._nav.NavigateTo($"TaxPayerInvoiceItem/{InvoiceID}");
}
}
2024-07-20 15:52:29 +03:30
private async Task showFullInvoiceItem()
{
if (InvoiceID.HasValue)
{
hc._nav.NavigateTo($"FullInvoiceItem/{InvoiceID}");
}
}
2024-07-03 16:05:28 +03:30
2024-07-21 16:07:53 +03:30
2024-05-23 19:59:19 +03:30
private async Task LoadData()
{
2024-05-28 15:03:08 +03:30
PreloadService.Show(SpinnerColor.Dark);
2024-05-30 15:08:36 +03:30
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}/{true}");
2024-05-23 19:59:19 +03:30
if (rsp.IsSuccessStatusCode)
{
2024-07-01 15:39:40 +03:30
invoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
2024-05-30 15:08:36 +03:30
}
2024-05-31 00:24:45 +03:30
2024-07-01 15:39:40 +03:30
else if (rsp.StatusCode == System.Net.HttpStatusCode.BadRequest)
2024-05-30 15:08:36 +03:30
{
2024-07-01 15:39:40 +03:30
ShowDangerAlert("صورتحساب مرجع یافت نشد");
2024-05-23 19:59:19 +03:30
}
else
2024-05-30 15:08:36 +03:30
{
ShowDangerAlert("خطایی در بارگذاری");
}
2024-05-28 15:03:08 +03:30
PreloadService.Hide();
2024-05-23 19:59:19 +03:30
}
public async Task CallBack(ActionInResultComponent result)
{
string msg = "";
if (result.Action == ComponentAction.add)
{
if (result.Status == ComponentStatus.success)
msg = "آیتم جدید با موفقیت اضافه شد";
}
2024-05-26 18:16:36 +03:30
else if (result.Action == ComponentAction.update)
{
if (result.Status == ComponentStatus.success)
msg = "اطلاعات آیتم با موفقیت ویرایش شد";
}
else if (result.Action == ComponentAction.delete)
{
if (result.Status == ComponentStatus.success)
msg = "آیتم با موفقیت حذف شد";
}
2024-05-26 17:25:34 +03:30
await CallBack(msg);
2024-05-23 19:59:19 +03:30
// if (result.Status == ComponentStatus.success)
2024-07-21 16:07:53 +03:30
//await LoadData();
2024-05-23 19:59:19 +03:30
await modal.HideAsync();
}
private async Task CallBack(string result)
{
if (!string.IsNullOrEmpty(result))
{
ShowSuccessAlert(result);
2024-05-26 17:25:34 +03:30
await LoadData();
2024-07-21 16:07:53 +03:30
2024-05-23 19:59:19 +03:30
}
}
2024-05-14 15:57:34 +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;
}
public async Task OnClickDelete()
{
2024-05-26 17:25:34 +03:30
if (InvoiceID.HasValue)
{
var rsp = await hc.Delete($"Invoice/Delete/{InvoiceID.Value}");
if (rsp.IsSuccessStatusCode)
{
var request = await rsp.Content.ReadFromJsonAsync<bool>();
if (request)
{
2024-05-27 22:01:14 +03:30
//ToastService.Notify(new ToastMessage(ToastType.Success, $"عملیات حذف با موفقیت انجام شد"));
2024-05-26 17:25:34 +03:30
hc._nav.NavigateTo("Invoice");
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
2024-05-14 15:57:34 +03:30
2024-05-26 17:25:34 +03:30
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
{
ShowDangerAlert("صورتحساب با این شناسه یافت نشد");
}
2024-07-25 19:15:05 +03:30
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
2024-05-26 17:25:34 +03:30
}
2024-05-26 18:16:36 +03:30
2024-05-14 15:57:34 +03:30
}
public async Task OnClickUpdate()
{
2024-05-26 17:25:34 +03:30
if (InvoiceID.HasValue)
{
if (await Validate())
{
var rsp = await hc.Put<NUInvoiceDTO>("Invoice/Update", new NUInvoiceDTO
{
ID = InvoiceID,
CustomerID = invoice.CustomerID,
Des = invoice.Des,
2024-05-27 22:01:14 +03:30
InvoiceDate = invoice.InvoiceDate.Replace("/", ""),
InvoicIssueDate = invoice.InvoicIssueDate.Replace("/", ""),
2024-05-26 17:25:34 +03:30
PatternID = invoice.PatternID,
Title = invoice.Title
});
if (rsp.IsSuccessStatusCode)
{
2024-05-27 22:01:14 +03:30
var request = await rsp.Content.ReadFromJsonAsync<bool>();
2024-05-26 17:25:34 +03:30
2024-05-27 22:01:14 +03:30
if (request)
2024-05-26 17:25:34 +03:30
{
2024-05-28 17:29:20 +03:30
ShowSuccessAlert("ویرایش با موفقیت انجام شد");
2024-05-27 22:01:14 +03:30
2024-05-26 17:25:34 +03:30
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
}
2024-05-16 23:40:32 +03:30
// if (Cod.UnitID > 0 && Cod.TaxRate > 0 && !string.IsNullOrEmpty(Cod.Title))
// {
// var rsp = await hc.Put<RCOD>("Cod/Update", Cod);
// 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("فیلدهای قرمز باید مقدار دهی شوند");
2024-05-14 15:57:34 +03:30
}
public async Task OnClickAdd()
{
2024-05-26 17:25:34 +03:30
if (await Validate())
{
var rsp = await hc.Post<NUInvoiceDTO>("Invoice/Add", new NUInvoiceDTO
{
CustomerID = invoice.CustomerID,
Des = invoice.Des,
2024-05-28 17:29:20 +03:30
InvoiceDate = invoice.InvoiceDate.Replace("/", ""),
2024-05-27 18:01:50 +03:30
InvoicIssueDate = invoice.InvoicIssueDate.Replace("/", ""),
2024-05-26 17:25:34 +03:30
PatternID = invoice.PatternID,
Title = invoice.Title
});
if (rsp.IsSuccessStatusCode)
{
var request = await rsp.Content.ReadFromJsonAsync<int>();
2024-05-14 15:57:34 +03:30
2024-05-26 17:25:34 +03:30
if (request > 0)
{
InvoiceID = request;
2024-07-24 22:56:46 +03:30
ShowSuccessAlert("صورتحساب با موفقیت ایجاد شد");
2024-05-26 17:25:34 +03:30
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
2024-05-14 15:57:34 +03:30
2024-05-26 17:25:34 +03:30
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
2024-05-14 15:57:34 +03:30
2024-05-16 23:40:32 +03:30
}
public async Task<bool> Validate()
{
2024-05-26 17:25:34 +03:30
if (string.IsNullOrEmpty(invoice.Title))
{
ShowDangerAlert("عنوان نمی تواند خالی باشد");
return false;
}
if (string.IsNullOrEmpty(invoice.InvoiceDate))
{
ShowDangerAlert("تاریخ صورتحساب نمی تواند خالی باشد");
return false;
}
else
{
int InvoiceDate = 0;
if (invoice.InvoiceDate.Replace("/", "").Length != 8 || !int.TryParse(invoice.InvoiceDate.Replace("/", ""), out InvoiceDate))
{
ShowDangerAlert("تاریخ صورتحساب صحیح نمی باشد");
return false;
}
else if (InvoiceDate.ToString().Trim().ToMiladiinFront() > DateTime.Now)
{
ShowDangerAlert("تاریخ صورتحساب نمی تواند از امروز جلوتر باشد");
return false;
}
}
if (string.IsNullOrEmpty(invoice.InvoicIssueDate))
{ ShowDangerAlert("تاریخ صدور نمی تواند خالی باشد"); return false; }
else
{
int InvoicIssueDate = 0;
if (invoice.InvoicIssueDate.Replace("/", "").Length != 8 || !int.TryParse(invoice.InvoicIssueDate.Replace("/", ""), out InvoicIssueDate))
{ ShowDangerAlert("تاریخ صدور صحیح نمی باشد"); return false; }
else if (InvoicIssueDate.ToString().Trim().ToMiladiinFront() > DateTime.Now)
{ ShowDangerAlert("تاریخ صدور نمی تواند از امروز جلوتر باشد"); return false; }
}
2024-05-28 17:29:20 +03:30
if (invoice.PatternID.HasValue && invoice.PatternID > 0)
if (!Patterns.Any(w => w.ID == invoice.PatternID.Value))
2024-05-26 17:25:34 +03:30
{ ShowDangerAlert("شناسه الگو صحیح نمی باشد"); return false; }
if (invoice.CustomerID == null || invoice.CustomerID <= 0 || !Cus.Any(w => w.ID == invoice.CustomerID))
{ ShowDangerAlert("مشتری صحیح نمی باشد"); return false; }
return true;
2024-05-14 15:57:34 +03:30
}
2024-05-26 18:16:36 +03:30
private async Task ShowConfirmationDeleteAsync()
{
if (InvoiceID.HasValue)
{
var confirmation = await dialog.ShowAsync(
title: "عملیات حذف صورتحساب",
message1: $"از حذف صورتحساب {InvoiceID}",
message2: "اطمینان دارید?");
if (confirmation)
{
await OnClickDelete();
}
else
{
2024-05-28 17:29:20 +03:30
ShowMessage(ToastType.Secondary, "عملیات حذف متوقف شد");
2024-05-26 18:16:36 +03:30
}
}
}
2024-07-21 16:07:53 +03:30
2024-07-01 15:39:40 +03:30
}