From 745412ee56aee00dae344db65f560ad27ddad715 Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Sat, 7 Sep 2024 16:50:34 +0330 Subject: [PATCH] invoicepays component --- Back/Controllers/InvoicePaymentController.cs | 30 ++++---- Back/Services/servInvoice.cs | 2 +- TaxPayerFull/CUSComponent/InvoicePays.razor | 81 ++++++++++++++++++++ 3 files changed, 97 insertions(+), 16 deletions(-) create mode 100644 TaxPayerFull/CUSComponent/InvoicePays.razor diff --git a/Back/Controllers/InvoicePaymentController.cs b/Back/Controllers/InvoicePaymentController.cs index c62cc22..ece360f 100644 --- a/Back/Controllers/InvoicePaymentController.cs +++ b/Back/Controllers/InvoicePaymentController.cs @@ -40,9 +40,9 @@ namespace Back.Controllers var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); //-----Validaton - //var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.add)); - //if (!resultValidationmodel.IsValid) - // return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); + var resultValidationmodel = await _validation.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.add)); + if (!resultValidationmodel.IsValid) + return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); //-----Get invoice Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, model.invoiceID); @@ -91,16 +91,16 @@ namespace Back.Controllers //-----Validaton - //var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.update)); - //if (!resultValidationmodel.IsValid) - //{ - // if (invoice.invoiceType != InvoiceType.BackFrmSale || (invoice.invoiceType != InvoiceType.BackFrmSale - // && resultValidationmodel.Errors.Count > 1)) - // { - // return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); - // } + var resultValidationmodel = await _validation.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.update)); + if (!resultValidationmodel.IsValid) + { + if (invoice.invoiceType != InvoiceType.BackFrmSale || (invoice.invoiceType != InvoiceType.BackFrmSale + && resultValidationmodel.Errors.Count > 1)) + { + return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); + } - //} + } @@ -146,9 +146,9 @@ namespace Back.Controllers return NotFound(new List { "invoice pay notFound..." }); ////-----Validaton - //var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, invoiceitem.InvoiceID, new InvoiceItemDTO(), eActionValidation.delete)); - //if (!resultValidationmodel.IsValid) - // return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); + var resultValidationmodel = await _validation.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, payitem.InvoiceID, new InvoicePaymentDTO(), eActionValidation.delete)); + if (!resultValidationmodel.IsValid) + return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); diff --git a/Back/Services/servInvoice.cs b/Back/Services/servInvoice.cs index 3628985..b3f8a49 100644 --- a/Back/Services/servInvoice.cs +++ b/Back/Services/servInvoice.cs @@ -99,7 +99,7 @@ namespace Back.Services acn = x.acn, iinn = x.acn, pcn = x.acn, - PaymentDateTime = x.PaymentDateTime, + PaymentDateTime = x.PaymentDateTime.ShamciToFormatShamci(), pid = x.pid, pmt = x.pmt, pv = x.pv, diff --git a/TaxPayerFull/CUSComponent/InvoicePays.razor b/TaxPayerFull/CUSComponent/InvoicePays.razor new file mode 100644 index 0000000..0d172f2 --- /dev/null +++ b/TaxPayerFull/CUSComponent/InvoicePays.razor @@ -0,0 +1,81 @@ +@using Shared.DTOs + + + + + + @context.ID + + + @context.iinn + + + @context.acn + + + @context.trmn + + + @context.pmt + + + @context.trn + + + @context.pcn + + + @context.pid + + + @context.PaymentDateTime + + + @context.pv??.ToString("N0") + + + + + +@code { + [Parameter] public ICollection payments { get; set; } + Grid grid = default!; + + + protected override void OnInitialized() + { + // payments = new List(); + } + + // private async Task AddEmployee() + // { + // // for the same employees collection, we are adding an object + // // explicit grid refresh required + // employees!.Add(CreateEmployee()); + // await grid.RefreshDataAsync(); + // } + + // private void AddEmployee2() + // { + // // creates a shallow copy + // var emps = employees!.GetRange(0, employees.Count); + // emps.Add(CreateEmployee()); + // // now employees variable has a new reference. So no need to refresh the grid explicitly + // // explicit grid refresh is not required + // employees = emps; + // } + + // private Employee1 CreateEmployee() + // { + // var emp = new Employee1(); + // emp.Id = employees!.Max(x => x.Id) + 1; + // emp.Name = $"Employee {emp.Id}"; + // emp.Designation = $"QA Engineer {emp.Id}"; + // emp.DOJ = new DateOnly(new Random().Next(1970, 2000), new Random().Next(1, 12), new Random().Next(1, 25)); + // emp.IsActive = true; + // return emp; + // } +} \ No newline at end of file