diff --git a/Areas/Report/Views/Reporting/InventoryReport.cshtml b/Areas/Report/Views/Reporting/InventoryReport.cshtml
index 040efdd..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
-
-
-
-
@@ -78,6 +62,58 @@
+
+
+
+
+
+
+
+
Department
+
+
+
+
+
+
+
+
Date filter
+
+
+
+
+
+
+
Position Filter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
User List
+
+
+ {{ selectedUser }}
+
+
+
+
+
+
@section Scripts {
@{
@@ -108,17 +144,27 @@
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: []
+ selectedCategory: [],
+ selectedPosition: [],
+ usersInfo: [],
+ submitBody: null,
+ formResponse: null,
+ selectedUser: [],
}
},
mounted() {
this.fetchUser();
this.fetchProductList();
- this.fetchCurrentReport();
this.fetchDepartmentsCompaniesList();
},
watch: {
@@ -131,14 +177,49 @@
}
},
methods: {
+ async generateReport(){
+ 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();
+ }
+ },
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 bcfa336..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 })
@@ -209,8 +214,8 @@ namespace PSTW_CentralSystem.Controllers.API
.ToListAsync();
var latestItemMovements = await _centralDbContext.ItemMovements
- //.Include(m => m.Item)
- //.Include(m => m.Item!.Product)
+ .Include(m => m.Item)
+ .Include(m => m.Item!.Product)
.Include(m => m.NextUser)
.Where(m => m.ItemId != null && (ToUser > 0 ? m.ToUser != null : m.ToUser > 0) && (ToStation > 0 ? m.ToStation != null : m.ToStation > 0) && (ToStore > 0 ? m.ToStore != null : m.ToStore > 0))
.GroupBy(m => m.ItemId)
@@ -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();