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

@@ -38,6 +38,11 @@ namespace Back.Validations
{
if (model.Item4 == eActionValidation.update || model.Item4 == eActionValidation.add)
{
if (model.Item3.pv <= 0)
{
context.AddFailure("مبلغ پرداختی باید بیشتر از صفر باشد.");
}
var totalpay = invoice.payments.Sum(s => s.pv).GetValueOrDefault() + model.Item3.pv;
if (totalpay > invoice.tbill) context.AddFailure("مجموع مبلغ پرداختی نمی تواند از مجموع صورتحساب بیشتر باشد.");
else
@@ -50,13 +55,23 @@ namespace Back.Validations
}
else
{
var today = Convert.ToInt32(DateTime.Now.ConvertMiladiToShamsi());
string paydate = model.Item3.PaymentDateTime.Replace("/", "");
if (paydate.Length == 8 && int.TryParse(paydate, out int _paydate))
{
if (today >= _paydate)
{
if (Convert.ToInt32(invoice.InvoiceDate) > _paydate)
{
context.AddFailure("تاریخ پرداخت نمیتواند از تاریخ صورتحساب عقبتر باشد");
}
}
else
{
context.AddFailure("تاریخ پرداخت نمی تواند از امروز جلوتر باشد");
}
}
else context.AddFailure("تاریخ صحیح نمی باشد");

View File

@@ -120,31 +120,31 @@ namespace Shared.DTOs
public class InvoicePaymentDTO
{
public int? ID { get; set; }
[MaxLength(9)]
//[MaxLength(9)]
public string? iinn { get; set; }
//شماره پذیرنده فروشگاهی
[MaxLength(14)]
//[MaxLength(14)]
public string? acn { get; set; }
//شماره پایانه
[MaxLength(8)]
//[MaxLength(8)]
public string? trmn { get; set; }
//روش پرداخت
[MaxLength(2)]
//[MaxLength(2)]
public int? pmt { get; set; }
public string? paymentMethod { get; set; }
//شماره پیگیری/شماره مرجع
[MaxLength(14)]
//[MaxLength(14)]
public string? trn { get; set; }
//شماره کارت پرداخت کننده صورتحساب
[MaxLength(16)]
//[MaxLength(16)]
public string? pcn { get; set; }
//شماره/شناسه ملی/کد فراگیر اتباع غیر ایرانی پرداخت کننده صورتحساب
[MaxLength(12)]
public string? pid { get; set; }
//تاریخ و زمان پرداخت
public string? PaymentDateTime { get; set; }
public string? PaymentDateTime { get; set; } = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront();
//مبلغ پرداختی
[MaxLength(18)]
//[MaxLength(18)]
public long? pv { get; set; }
}

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("مجموع مبلغ پرداختی نمی تواند از مجموع صورتحساب بیشتر باشد.");
@@ -311,12 +329,21 @@
{
string paydate = item.PaymentDateTime.Replace("/", "");
if (paydate.Length == 8 && int.TryParse(paydate, out int _paydate))
{
var today = Convert.ToInt32(DateTime.Now.ConvertMiladiToShamsiinFront());
if (today >= _paydate)
{
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");