diff --git a/Areas/Report/Views/Reporting/InventoryReport.cshtml b/Areas/Report/Views/Reporting/InventoryReport.cshtml index d22da9d..53b50ee 100644 --- a/Areas/Report/Views/Reporting/InventoryReport.cshtml +++ b/Areas/Report/Views/Reporting/InventoryReport.cshtml @@ -16,15 +16,6 @@
-
-
-

Department

- - -
-
-

Category

@@ -41,13 +32,6 @@
-
-
-

Date filter

- -
-
-
@@ -88,17 +72,24 @@

Department

- + -
+

Date filter

- -
+ +
+
+
+
+
+

Position Filter

+ +
@@ -111,20 +102,13 @@
-
-

Statistic

-

Total Number of Item Registered: {{ reportData.itemCountRegistered }}

-

Total Number of Item Still in Stock: {{ reportData.itemCountStillInStock }}

-
-
-

Item Registered

-

This Month: {{ reportData.itemCountRegisteredThisMonth }}

-

Last Month: {{ reportData.itemCountRegisteredLastMonth }}

-
-
-

Item Stock Out

-

This Month: {{ reportData.itemCountStockOutThisMonth }}

-

Last Month: {{ reportData.itemCountStockOutLastMonth }}

+
+
+

User List

+ +
+ {{ selectedUser }} +
@@ -160,13 +144,22 @@ productList: {}, categoryList:['Asset', 'Part', 'Disposable'], monthList: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], + positionList: [ + { positionId: 1, positionName: 'User' }, + { positionId: 2, positionName: 'Station' }, + { positionId: 3, positionName: 'Store' } + ], filteredProduct: [], - selectedMonth: [], + selectedMonth: null, selectedDepartment: [], + selectedSingleDepartment: null, selectedItem: [], selectedCategory: [], + selectedPosition: [], usersInfo: [], submitBody: null, + formResponse: null, + selectedUser: [], } }, mounted() { @@ -185,21 +178,48 @@ }, methods: { async generateReport(){ - this.submitBody = { - selectedMonth: this.selectedMonth, - selectedDepartment: this.selectedDepartment + if(this.selectedMonth == null || this.selectedSingleDepartment.length == 0 || this.selectedPosition.length == 0) + { + var msg = []; + if(this.selectedMonth == null) + { + msg.push("Date"); + } + if(this.selectedSingleDepartment.length == 0) + { + msg.push("Department"); + } + if(this.selectedPosition.length == 0) + { + msg.push("Position"); + } + alert(msg.length > 1 ? msg.join(" & ") + " cannot be empty" : msg[0] + " cannot be empty"); + } + else{ + this.submitBody = { + formDate: new Date(this.selectedMonth.year, this.selectedMonth.month + 1, 0, 23, 59, 59).toISOString().slice(0, 19), + // selectedCategory: this.selectedCategory, + deptId: this.selectedSingleDepartment.departmentCode, + toUser: this.selectedPosition.positionId == 1 ? 1 : 0, + toStation: this.selectedPosition.positionId == 2 ? 1 : 0, + toStore: this.selectedPosition.positionId == 3 ? 1 : 0, + } + this.fetchCurrentReport(); } - console.log(this.submitBody); - // this.fetchCurrentReport(); }, async fetchCurrentReport(){ try { const response = await fetch(`/ReportingAPI/GetMonthlyReport/`, { + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(this.submitBody), method: 'POST', }); if (response.ok) { const data = await response.json(); - console.log(data); + this.formResponse = data + console.log(this.formResponse); } else { console.error(`Failed to fetch user: ${response.statusText}`); diff --git a/Controllers/API/ReportingAPI.cs b/Controllers/API/ReportingAPI.cs index 96521c1..72a6b7f 100644 --- a/Controllers/API/ReportingAPI.cs +++ b/Controllers/API/ReportingAPI.cs @@ -35,11 +35,11 @@ namespace PSTW_CentralSystem.Controllers.API public class ReportQuery { - string? FormDate { get; set; } - string? DeptId { get; set; } - int ToUser { get; set; } - int ToStation { get; set; } - int ToStore { get; set; } + public string? FormDate { get; set; } + public string? DeptId { get; set; } + public int ToUser { get; set; } + public int ToStation { get; set; } + public int ToStore { get; set; } } #region ItemReport @@ -135,10 +135,15 @@ namespace PSTW_CentralSystem.Controllers.API #region Monthly Report [HttpPost("GetMonthlyReport")] - public async Task GetMonthlyReport([FromBody] string FormDate = "2026/1/31", string DeptId = "PA", int ToUser = 1, int ToStation = 0, int ToStore = 0) + public async Task GetMonthlyReport([FromBody] ReportQuery reportQuery) { try { + string FormDate = reportQuery.FormDate!; + string DeptId = reportQuery.DeptId!; + int ToUser = reportQuery.ToUser; + int ToStation = reportQuery.ToStation; + int ToStore = reportQuery.ToStore; var currentProductBalance = new List(); var result = await _centralDbContext.Products .Select(p => new { p.ProductName, p.QuantityJSON }) @@ -233,8 +238,10 @@ namespace PSTW_CentralSystem.Controllers.API ItemId = m.ItemId, ItemName = m.Item!.Product!.ProductName, Quantity = m.Quantity, + ItemPrice = m.Item!.ConvertPrice, }) - .ToList() + .ToList(), + TotalItemPrice = latestItemMovements.Where(m => m.ToUser == u.Id).Sum(m => m!.Item!.ConvertPrice * m.Quantity), }) .Where(u => u.Items.Count > 0).ToList();