diff --git a/Back/Controllers/CODController.cs b/Back/Controllers/CODController.cs index 52fd6aa..468375c 100644 --- a/Back/Controllers/CODController.cs +++ b/Back/Controllers/CODController.cs @@ -30,6 +30,19 @@ namespace Back.Controllers var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); // if (!await _checkPermission.AllowSYSGetCOD(Convert.ToInt32(UserID), user.RolUsers.First().CompanyID)) return Forbid("شما دسترسی به خواندن اطلاعات کالا را نداربد"); return Ok(await _servCOD.GetCODs(user.RolUsers.First().CompanyID, itemSerch)); + } + [HttpGet("GetAllForidName")] + public async Task>>> GetAllForidName() + { + var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); + var UserID = claim.Value; + var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); + + + + return Ok(await _servCOD.GetCODs(user.RolUsers.First().CompanyID)); + + } [HttpGet("GetUnits")] public async Task>>> GetUnits() diff --git a/Back/Services/ServCOD.cs b/Back/Services/ServCOD.cs index c79a94b..b98f887 100644 --- a/Back/Services/ServCOD.cs +++ b/Back/Services/ServCOD.cs @@ -54,6 +54,23 @@ namespace Back.Services }) .Paging(itemSerch.PageIndex, itemSerch.PageSize); } + public async Task>?> GetCODs(int CompanyID) + { + + #region AdvancedSearch + var invok = _CODRepo + .Get(w => w.CompanyID == CompanyID && !w.IsDeleted); + + #endregion + //----------------------- + return await invok.Select(s => new CODIdName() + { + ID = s.ID, + Title = s.Title, + Tax=s.TaxRate + }) + .ToListAsync(); + } public async Task>> GetUnits() { return await _UnitRepo.GetAll().Select(s => new IdName { ID = s.ID, Title = s.Title }).ToListAsync(); diff --git a/Back/Services/servInvoice.cs b/Back/Services/servInvoice.cs index b0e2ba2..86bf011 100644 --- a/Back/Services/servInvoice.cs +++ b/Back/Services/servInvoice.cs @@ -56,7 +56,7 @@ namespace Back.Services { ID = x.ID, CODID = x.CODID, - adis = x.adis, + //adis = x.adis, am = x.am.Value, dis = x.dis, fee = x.fee.Value, diff --git a/Shared/DTOs/IdName.cs b/Shared/DTOs/IdName.cs index d306faa..56f96c4 100644 --- a/Shared/DTOs/IdName.cs +++ b/Shared/DTOs/IdName.cs @@ -11,4 +11,8 @@ namespace Shared.DTOs public T ID { get; set; } public string Title { get; set; } } + public class CODIdName: IdName + { + public int Tax { get; set; } + } } diff --git a/Shared/DTOs/InvoiceDtos.cs b/Shared/DTOs/InvoiceDtos.cs index e2e3e42..8a2fd3d 100644 --- a/Shared/DTOs/InvoiceDtos.cs +++ b/Shared/DTOs/InvoiceDtos.cs @@ -99,12 +99,15 @@ namespace Shared.DTOs //مبلغ مالیات بر ارزش افزوده public decimal? vam { get; set; } //مبلغ تخفیف - public decimal? dis { get; set; } - //مبلغ بعد از تخفیف - public decimal? adis { get; set; } + public decimal? dis { get; set; } = 0; //مبلغ کل کالا/خدمت public decimal? tsstam { get; set; } - + //مبلغ قبل از تخفیف + public decimal? prdis { get; set; } + //مبلغ بعد از تخفیف + [MaxLength(18)] + public decimal? adis { get; set; } + } public class InvoicePaymentDTO { diff --git a/TaxPayerFull/CUSComponent/InvoiceItem.razor b/TaxPayerFull/CUSComponent/InvoiceItem.razor new file mode 100644 index 0000000..af5f86f --- /dev/null +++ b/TaxPayerFull/CUSComponent/InvoiceItem.razor @@ -0,0 +1,251 @@ +@using Front.Services +@using Shared.DTOs +@inject HttpClientController hc; +@inject Fixedvalues fv; +
+ @* alert *@ +
+ + +
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +@if (itemDTO.ID == null) +{ + +} +else +{ + + +} + + +@code { + // alert + AlertColor alertColor = AlertColor.Primary; + IconName alertIconName = IconName.CheckCircleFill; + bool Hidealert = true; + string alertMessage = ""; + public int Tax { get; set; } = 0; + [Parameter] public InvoiceItemDTO itemDTO { get; set; } + [Parameter] public EventCallback OnMultipleOfThree { get; set; } + public List> cods { get; set; } = new(); + public ActionInResultComponent result { get; set; } + protected override async Task OnInitializedAsync() + { + cods = await fv.GetCODs(); + await base.OnInitializedAsync(); + } + protected override async Task OnParametersSetAsync() + { + + result = new ActionInResultComponent() + { + Status = ComponentStatus.fild + }; + Hidealert = true; + alertMessage = ""; + await base.OnParametersSetAsync(); + } +} +@functions { + private async Task prdisAsync() + { + if (itemDTO.ID == null) + itemDTO.prdis = itemDTO.fee * itemDTO.am; + } + private async Task adisAsync() + { + if (itemDTO.ID == null) + itemDTO.adis= itemDTO.prdis - itemDTO.dis; + + // await AftervamAsync(); + } + private async Task vamAsync() + { + if (itemDTO.ID == null) + itemDTO.vam = itemDTO.vra * itemDTO.adis / 100; + } + private async Task tsstamAsync() + { + if (itemDTO.ID == null) + itemDTO.tsstam = itemDTO.vam + itemDTO.adis ; + } + private async Task AfterAsync() + { + await prdisAsync(); + await adisAsync(); + await vamAsync(); + await tsstamAsync(); + } + public async Task OnClickDelete() + { + + // var rsp = await hc.Delete($"Customer/Delete/{Cus.ID}"); + // if (rsp.IsSuccessStatusCode) + // { + // var request = await rsp.Content.ReadFromJsonAsync(); + // if (request) + // { + // result.Status = ComponentStatus.success; + // result.Action = ComponentAction.delete; + // await OnMultipleOfThree.InvokeAsync(result); + // } + // else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); + // } + + // else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound) + // { + // ShowDangerAlert("مشتری با این شناسه یافت نشد"); + // } + // else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); + + + + + } + public async Task OnClickUpdate() + { + // if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName)) + // { + // if (ItemSearchCustomertype > 0) + // Cus.CustomerType = (CustomerType)ItemSearchCustomertype; + + // var rsp = await hc.Put("Customer/Update", Cus); + // if (rsp.IsSuccessStatusCode) + // { + // var request = await rsp.Content.ReadFromJsonAsync(); + // if (request) + // { + // result.Status = ComponentStatus.success; + // result.Action = ComponentAction.update; + // await OnMultipleOfThree.InvokeAsync(result); + // } + // else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); + // } + // else + // { + // var request = await rsp.Content.ReadFromJsonAsync>(); + // ShowDangerAlert(request[0]); + // } + // } + // else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند"); + } + public async Task OnClickAdd() + { + // if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName)) + // { + // if (ItemSearchCustomertype > 0) + // Cus.CustomerType = (CustomerType)ItemSearchCustomertype; + // Cus.ID = null; + + + // var rsp = await hc.Post("Customer/Add", Cus); + // if (rsp.IsSuccessStatusCode) + // { + // var request = await rsp.Content.ReadFromJsonAsync(); + + // if (request) + // { + // result.Status = ComponentStatus.success; + // result.Action = ComponentAction.add; + // await OnMultipleOfThree.InvokeAsync(result); + // } + // else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); + // } + // else + // { + + // var request = await rsp.Content.ReadFromJsonAsync>(); + // ShowDangerAlert(request[0]); + // } + // } + // else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند"); + } +} \ No newline at end of file diff --git a/TaxPayerFull/FixedValues.cs b/TaxPayerFull/FixedValues.cs index 9fba843..af19a27 100644 --- a/TaxPayerFull/FixedValues.cs +++ b/TaxPayerFull/FixedValues.cs @@ -9,6 +9,7 @@ namespace Front public readonly HttpClientController _hc; private List? Cus=null; private List>? Patterns = null; + private List>? Cods = null; public Fixedvalues(HttpClientController hc) { _hc = hc; @@ -27,6 +28,21 @@ namespace Front return Cus; + } + public async Task>?> GetCODs() + { + if (Cods == null) + { + var request = await _hc.Get($"COD/GetAllForidName"); + if (request.IsSuccessStatusCode) + { + Cods = await request.Content.ReadFromJsonAsync>>(); + } + } + + return Cods; + + } public async Task>?> GetPatterns() { diff --git a/TaxPayerFull/Layout/LGridInvoiceItem.razor b/TaxPayerFull/Layout/LGridInvoiceItem.razor index 90c1dcc..c7b250b 100644 --- a/TaxPayerFull/Layout/LGridInvoiceItem.razor +++ b/TaxPayerFull/Layout/LGridInvoiceItem.razor @@ -1,4 +1,6 @@ @using Shared.DTOs + + OnMultipleOfThree { get; set; } [Parameter] public IEnumerable InvoiceItems { get; set; } + private Modal modal = default!; private async Task> DataProvider(GridDataProviderRequest request) { if (InvoiceItems is null) // pull employees only one time for client-side filtering, sorting, and paging @@ -55,7 +58,39 @@ } private async Task OnRowClick(GridRowEventArgs args) { - await ModalService.ShowAsync(new ModalOption { Type = ModalType.Primary, Title = "Event: Row Click", Message = $"Id: {args.Item.ID}, Name: {args.Item.sstt}" }); + var parameters = new Dictionary(); + + + parameters.Add("itemDTO", args.Item); + parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack)); + await modal.ShowAsync(title: "ویرایش اطلاعات", parameters: parameters); + + } + + public async Task CallBack(ActionInResultComponent result) + { + string msg = ""; + if (result.Action == ComponentAction.add) + { + if (result.Status == ComponentStatus.success) + msg="آیتم جدید با موفقیت اضافه شد"; + + } + else if (result.Action == ComponentAction.update) + { + if (result.Status == ComponentStatus.success) + msg="اطلاعات آیتم با موفقیت ویرایش شد"; + } + else if (result.Action == ComponentAction.delete) + { + if (result.Status == ComponentStatus.success) + msg="آیتم با موفقیت حذف شد"; + } + + // if (result.Status == ComponentStatus.success) + // await LoadCod(1); + + await modal.HideAsync(); } private IEnumerable GetInvoiceItems() { diff --git a/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor b/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor index f890683..1b9cbb1 100644 --- a/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor +++ b/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor @@ -6,6 +6,7 @@ @inject Fixedvalues fv; @page "/InvoiceDetails/{InvoiceID:int}" @page "/InvoiceDetails" +
@* alert *@ @@ -125,16 +126,19 @@
- +
- + +
- + @*
@@ -142,15 +146,15 @@
-
-
+
*@ @@ -195,6 +199,7 @@ @code { + private Modal modal = default!; [Inject] protected PreloadService PreloadService { get; set; } = default!; // alert AlertColor alertColor = AlertColor.Primary; @@ -211,7 +216,7 @@ invoice = new InvoiceDTO(); await base.OnInitializedAsync(); } - + protected override async Task OnParametersSetAsync() { PreloadService.Show(SpinnerColor.Dark); @@ -219,14 +224,8 @@ Patterns = await fv.GetPatterns(); if (InvoiceID != null && InvoiceID > 0) { - var rsp = await hc.Get($"Invoice/Get/{InvoiceID}"); - if (rsp.IsSuccessStatusCode) - { - invoice = await rsp.Content.ReadFromJsonAsync(); - } - else - hc._nav.NavigateTo("/Pael"); - + + await LoadData(); } else { @@ -247,6 +246,59 @@ } } @functions { + private async Task NewItemClick() + { + var parameters = new Dictionary(); + + + parameters.Add("itemDTO", new InvoiceItemDTO()); + parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack)); + await modal.ShowAsync(title: "آیتم جدید", parameters: parameters); + + } + private async Task LoadData() + { + var rsp = await hc.Get($"Invoice/Get/{InvoiceID}"); + if (rsp.IsSuccessStatusCode) + { + invoice = await rsp.Content.ReadFromJsonAsync(); + } + else + hc._nav.NavigateTo("/Panel"); + } + public async Task CallBack(ActionInResultComponent result) + { + string msg = ""; + if (result.Action == ComponentAction.add) + { + if (result.Status == ComponentStatus.success) + msg = "آیتم جدید با موفقیت اضافه شد"; + + } + // else if (result.Action == ComponentAction.update) + // { + // if (result.Status == ComponentStatus.success) + // msg = "اطلاعات آیتم با موفقیت ویرایش شد"; + // } + // else if (result.Action == ComponentAction.delete) + // { + // if (result.Status == ComponentStatus.success) + // msg = "آیتم با موفقیت حذف شد"; + // } + await CallBack(msg); + // if (result.Status == ComponentStatus.success) + // await LoadCod(1); + + await modal.HideAsync(); + } + private async Task CallBack(string result) + { + if (!string.IsNullOrEmpty(result)) + { + ShowSuccessAlert(result); + await LoadData(); + } + } private void ShowSuccessAlert(string msg) { Hidealert = false; diff --git a/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor.css b/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor.css deleted file mode 100644 index f831d04..0000000 --- a/TaxPayerFull/Pages/UserPanel/InvoiceItem.razor.css +++ /dev/null @@ -1,42 +0,0 @@ -/* CSS */ -.button-8 { - background-color: #e1ecf4; - border-radius: 3px; - border: 1px solid #7aa7c7; - box-shadow: rgba(255, 255, 255, .7) 0 1px 0 0 inset; - box-sizing: border-box; - color: #39739d; - cursor: pointer; - display: inline-block; - font-family: -apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif; - font-size: 13px; - font-weight: 400; - line-height: 1.15385; - margin: 0; - outline: none; - padding: 8px .8em; - position: relative; - text-align: center; - text-decoration: none; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; - vertical-align: baseline; - white-space: nowrap; -} - - .button-8:hover, - .button-8:focus { - background-color: #b3d3ea; - color: #2c5777; - } - - .button-8:focus { - box-shadow: 0 0 0 4px rgba(0, 149, 255, .15); - } - - .button-8:active { - background-color: #a0c7e4; - box-shadow: none; - color: #2c5777; - }