This commit is contained in:
mmrbnjd
2024-09-08 21:50:17 +03:30
parent b81c950c39
commit 7d7b352b51
4 changed files with 83 additions and 41 deletions

View File

@@ -1,4 +1,5 @@
@using Front.Services
@using Shared
@using Shared.DTOs
@inject Fixedvalues fv;
@inject HttpClientController hc;
@@ -7,7 +8,8 @@
TItem="InvoicePaymentDTO"
Class="table table-hover table-bordered table-striped mt-3"
Data="invoice.payments"
OnRowClick="OnRowClick">
OnRowClick="OnRowClick"
Responsive="true">
<GridColumns>
<GridColumn TItem="InvoicePaymentDTO" TextAlignment="Alignment.Center" HeaderTextAlignment="Alignment.Center" HeaderText="شماره سوییچ پرداخت" PropertyName="iinn">
@@ -34,8 +36,8 @@
<GridColumn TItem="InvoicePaymentDTO" TextAlignment="Alignment.Center" HeaderTextAlignment="Alignment.Center" HeaderText="تاریخ" PropertyName="PaymentDateTime">
@context.PaymentDateTime
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" TextAlignment="Alignment.Center" HeaderTextAlignment="Alignment.Center" HeaderText="مبلغ" PropertyName="pv">
@context.pv??.ToString("N0")
<GridColumn TItem="InvoicePaymentDTO" TextAlignment="Alignment.Center" HeaderTextAlignment="Alignment.Center" HeaderText="مبلغ(ریال)" PropertyName="pv">
@context.pv.Value.ToString("N0")
</GridColumn>
</GridColumns>
</Grid>
@@ -128,6 +130,14 @@
<CurrencyInput TValue="long?" @bind-Value="item.pv" Locale="fa-Ir" Placeholder="مبلغ" style="text-align: center" />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-4">
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
<Icon Name="@alertIconName" class="me-2"></Icon>
@alertMessage
</Alert>
</div>
</div>
<div class="row g-3">
@if (add)
{
@@ -151,22 +161,15 @@
</div>
<div class="form-group col-md-2">
<Button class="mt-3" Color="ButtonColor.Primary" @onclick="cancell" Type="ButtonType.Button">
انصزاف
انصراف
</Button>
</div>
}
}
</div>
@* alert *@
<div class="row">
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
<Icon Name="@alertIconName" class="me-2"></Icon>
@alertMessage
</Alert>
</div>
@code {
bool add = true;
[Parameter] public InvoiceDTO invoice { get; set; }
@@ -182,6 +185,7 @@
protected override async Task OnParametersSetAsync()
{
item = new InvoicePaymentDTO();
pmts = await fv.GetPaymentMethods();
await base.OnParametersSetAsync();
}
@@ -199,9 +203,15 @@
}
async Task AddPay()
{
if (await Validation())
{
var rsp = await hc.Post<InvoicePaymentDTO>("InvoicePayment/AddPay", item);
var sentItem = new InvoiceItemAction<InvoicePaymentDTO>()
{
invoiceID = invoice.ID,
item = item
};
var rsp = await hc.Post<InvoiceItemAction<InvoicePaymentDTO>>("InvoicePayment/AddPay", sentItem);
if (rsp.IsSuccessStatusCode)
{
var request = await rsp.Content.ReadFromJsonAsync<InvoicePaymentDTO>();
@@ -230,7 +240,11 @@
{
if (await Validation())
{
var rsp = await hc.Put<InvoicePaymentDTO>("InvoicePayment/UpdatePay", item);
var rsp = await hc.Put<InvoiceItemAction<InvoicePaymentDTO>>("InvoicePayment/UpdatePay", new InvoiceItemAction<InvoicePaymentDTO>()
{
invoiceID = invoice.ID,
item = item
});
if (rsp.IsSuccessStatusCode)
{
var request = await rsp.Content.ReadFromJsonAsync<InvoicePaymentDTO>();
@@ -294,6 +308,10 @@
}
async Task<bool> Validation()
{
if (item.pv<=0)
{
ShowDangerAlert("مبلغ پرداختی باید بیشتر از صفر باشد.");
}
if (invoice.tbill < invoice.payments.Sum(s => s.pv) + item.pv)
{
ShowDangerAlert("مجموع مبلغ پرداختی نمی تواند از مجموع صورتحساب بیشتر باشد.");
@@ -312,11 +330,20 @@
string paydate = item.PaymentDateTime.Replace("/", "");
if (paydate.Length == 8 && int.TryParse(paydate, out int _paydate))
{
if (Convert.ToInt32(invoice.InvoiceDate.Replace("/", "")) > _paydate)
var today = Convert.ToInt32(DateTime.Now.ConvertMiladiToShamsiinFront());
if (today >= _paydate)
{
ShowDangerAlert("تاریخ پرداخت نمیتواند از تاریخ صورتحساب عقبتر باشد");
return false;
if (Convert.ToInt32(invoice.InvoiceDate.Replace("/", "")) > _paydate)
{
ShowDangerAlert("تاریخ پرداخت نمیتواند از تاریخ صورتحساب عقبتر باشد");
return false;
}
}
else
{
ShowDangerAlert("تاریخ پرداخت نمی تواند از امروز جلوتر باشد");
}
}
else { ShowDangerAlert("تاریخ صحیح نمی باشد"); return false; }

View File

@@ -36,10 +36,10 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") });
//Home
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
//farzan
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");