diff --git a/Areas/Report/Views/Reporting/InventoryReport.cshtml b/Areas/Report/Views/Reporting/InventoryReport.cshtml
index a687d47..1228191 100644
--- a/Areas/Report/Views/Reporting/InventoryReport.cshtml
+++ b/Areas/Report/Views/Reporting/InventoryReport.cshtml
@@ -102,6 +102,12 @@
Store
@@ -194,6 +216,8 @@
selectedUser: [],
userItemsTable: null,
stationItemsTable: null,
+ stockInItemsTable: null,
+ stockOutItemsTable: null,
storeItemsTable: null,
storeAllItemsTable: null,
activeTab: "userTab"
@@ -299,6 +323,14 @@
this.storeItemsTable.clear().destroy();
this.storeItemsTable = null;
}
+ if (this.stockInItemsTable) {
+ this.stockInItemsTable.clear().destroy();
+ this.stockInItemsTable = null;
+ }
+ if (this.stockOutItemsTable) {
+ this.stockOutItemsTable.clear().destroy();
+ this.stockOutItemsTable = null;
+ }
}
else {
console.error(`Failed to fetch user: ${response.statusText}`);
@@ -471,6 +503,65 @@
});
}
});
+ const stockInItemTableData = this.formResponse.exactMonthStockIn ? this.formResponse.exactMonthStockIn : [];
+ this.stockInItemsTable = $('#stockInItemsTable').DataTable({
+ data: stockInItemTableData.items,
+ columns: [
+ { data: 'itemName', title: 'Item Name' },
+ { data: 'uniqueID', title: 'Unique ID' },
+ { data: 'quantity', title: 'Quantity' },
+ { data: 'from', title: 'From' },
+ { data: 'to', title: 'To' },
+ { data: 'price', title: 'Item Price' },
+ ],
+ destroy: true,
+ drawCallback: function () {
+ const total = storeTableData.totalItemPrice;
+ // const total = stockInItemTableData.items.reduce((acc, item) => acc + item.price, 0) || 0;
+ $(this.api().table().node()).find('tbody tr.total-row').remove();
+ $(this.api().table().node()).find('tbody').append(
+ `
+ | Total |
+ ${total} |
+
`
+ );
+ },
+ "createdRow": function (row, data, dataIndex) {
+ $(row).on('click', function () {
+ app.fetchItemMovement(data.uniqueID);
+ });
+ }
+ });
+ const stockOutItemTableData = this.formResponse.exactMonthStockOut ? this.formResponse.exactMonthStockOut : [];
+ console.log(stockOutItemTableData);
+ this.stockOutItemsTable = $('#stockOutItemsTable').DataTable({
+ data: stockOutItemTableData.items,
+ columns: [
+ { data: 'itemName', title: 'Item Name' },
+ { data: 'uniqueID', title: 'Unique ID' },
+ { data: 'quantity', title: 'Quantity' },
+ { data: 'from', title: 'From' },
+ { data: 'to', title: 'To' },
+ { data: 'price', title: 'Item Price' },
+ ],
+ destroy: true,
+ drawCallback: function () {
+ const total = storeTableData.totalItemPrice;
+ // const total = stockOutItemTableData.items.reduce((acc, item) => acc + item.price, 0) || 0;
+ $(this.api().table().node()).find('tbody tr.total-row').remove();
+ $(this.api().table().node()).find('tbody').append(
+ `
+ | Total |
+ ${total} |
+
`
+ );
+ },
+ "createdRow": function (row, data, dataIndex) {
+ $(row).on('click', function () {
+ app.fetchItemMovement(data.uniqueID);
+ });
+ }
+ });
const storeAllTableData = this.formResponse.allProductInStore ? this.formResponse.allProductInStore : [];
this.storeAllItemsTable = $('#storeAllItemsTable').DataTable({
data: storeAllTableData ,
diff --git a/Controllers/API/ReportingAPI.cs b/Controllers/API/ReportingAPI.cs
index 6403493..bf2a20e 100644
--- a/Controllers/API/ReportingAPI.cs
+++ b/Controllers/API/ReportingAPI.cs
@@ -183,6 +183,34 @@ namespace PSTW_CentralSystem.Controllers.API
.FirstOrDefault())
.ToListAsync();
+ var exactMonthStockOut = latestItemMovements
+ .Where(m => m != null && (m.Action!.ToLower() == "stockout" || m.Action!.ToLower() == "stock out") && m.Date.Month == parsedDate.Month)
+ .Select(m => new
+ {
+ UniqueID = m!.Item!.UniqueID,
+ From = m!.LastUser != null ? m.FromUser!.UserName : m.LastStore != null ? m.FromStore!.StoreName : m.LastStation != null ? m.FromStation!.StationName : "Unknown",
+ To = m.NextUser != null ? m.NextUser!.UserName : m.NextStore != null ? m.NextStore!.StoreName : m.NextStation != null ? m.NextStation!.StationName : "Unknown",
+ Item = m.Item!.Product!.ProductName,
+ Quantity = m.Quantity,
+ Date = m.Date,
+ Price = m.Item!.ConvertPrice * m.Quantity,
+
+ })
+ .ToList();
+ var exactMonthStockIn = latestItemMovements
+ .Where(m => m != null && (m.Action!.ToLower() == "stockin" || m.Action!.ToLower() == "stock in") && m.Date.Month == parsedDate.Month)
+ .Select(m => new
+ {
+ UniqueID = m!.Item!.UniqueID,
+ From = m!.LastUser != null ? m.FromUser!.UserName : m.LastStore != null ? m.FromStore!.StoreName : m.LastStation != null ? m.FromStation!.StationName : "Unknown",
+ To = m.NextUser != null ? m.NextUser!.UserName : m.NextStore != null ? m.NextStore!.StoreName : m.NextStation != null ? m.NextStation!.StationName : "Unknown",
+ Item = m.Item!.Product!.ProductName,
+ Quantity = m.Quantity,
+ Date = m.Date,
+ Price = m.Item!.ConvertPrice * m.Quantity,
+ })
+ .ToList();
+
//select latestItemMovements with the Touser is not null
var latestUserItemMovements = latestItemMovements.Where(m => m != null && m.ItemId != null && m.ToUser > 0 ).ToList();
var latestStationItemMovements = latestItemMovements.Where(m => m != null && m.ItemId != null && m.ToStation > 0).ToList();
@@ -264,6 +292,8 @@ namespace PSTW_CentralSystem.Controllers.API
userItemBalance = usersItemMovements,
stationItemBalance = stationItemMovements,
storeItemBalance = storeItemMovements,
+ exactMonthStockIn = exactMonthStockIn,
+ exactMonthStockOut = exactMonthStockOut,
};
return Json(report);