From a1db9175a3e409a2aaca2dc2d51204b198850ab9 Mon Sep 17 00:00:00 2001 From: ameerulrasyid Date: Mon, 10 Mar 2025 15:59:40 +0800 Subject: [PATCH] fix item movement qr master --- .../Views/InventoryMaster/QrMaster.cshtml | 58 ++++++++++++++----- Controllers/API/Inventory/InvMainAPI.cs | 4 +- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml b/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml index 1b0258f..9ce62fd 100644 --- a/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/QrMaster.cshtml @@ -144,8 +144,8 @@
- -
+ +

Item is on Delivery

@@ -169,6 +169,23 @@
+
+

Receive Item

+
+
+
+
+ +
+ +
+
+
+
+
+

Receive Repair / Calibration

@@ -226,7 +243,7 @@ @*
*@ @*
*@ -
+

Add Item Movement

@@ -240,7 +257,7 @@
-
+

Add Item Movement

@@ -730,8 +747,9 @@ }) .then(() => { console.log("📷 Applied Constraintsss:", track.getSettings()); - }).catch(err => - // console.error("❌ Failed to apply constraints:", err) + }) + .catch(err => + console.error("❌ Failed to apply constraints:", err) ); } else { @@ -812,9 +830,9 @@ ...(this.selectedAction === 'user' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), ...(this.selectedAction === 'station' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastStation: this.selectedStation, lastUser: this.selectedStationPIC, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), - ...(this.selectedAction === 'store' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), - ...(this.selectedAction === 'supplier' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, lastUser: this.currentUser.id, MovementComplete: false, } : {}), - ...(this.selectedAction === 'faulty' ? { toStore: this.currentUser.store, toUser: this.currentUser.id,toOther: 'Faulty', Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}), + ...(this.selectedAction === 'store' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastStore: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), + ...(this.selectedAction === 'supplier' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, lastUser: this.currentUser.id, lastStore: this.currentUser.store, MovementComplete: false, } : {}), + ...(this.selectedAction === 'faulty' ? { toStore: this.currentUser.store, toUser: this.currentUser.id,toOther: 'Faulty', SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}), ItemId: this.thisItem.itemID, Action: 'Stock Out', @@ -863,19 +881,23 @@ this.serialNumber = ""; } - if(this.thisItem.toOther === "On Delivery"){ + if(this.thisItem.toOther === "On Delivery" && this.thisItem.toUser == this.currentUser.id){ if(!window.confirm("Are you sure you want to cancel item delivery?")){ return; } } const now = new Date(); + console.log('currentuser'+this.currentUser.id); + console.log('lastuser'+this.thisItem.lastuser); + const formData = { Id: this.thisItem.movementId, ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), - Remark: this.thisItem.toOther === "On Delivery" ? this.thisItem.remark + ". Inventory Master cancelled delivery with remark: " + this.remark : this.thisItem.remark, - LatestStatus: this.thisItem.toOther === "Return" ? "Faulty" : (this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Repair" || this.thisItem.toOther === "On Delivery" ) ? "Ready To Deploy" : "" + Remark: this.thisItem.toOther === "On Delivery" && this.thisItem.toUser == this.currentUser.id ? this.thisItem.remark + ". Inventory Master cancelled delivery with remark: " + this.remark : this.thisItem.remark, + LastUser: this.thisItem.lastuser == null ? this.currentUser.id : this.thisItem.lastuser, + LatestStatus: this.thisItem.toOther === "Return" ? "Faulty" : (this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Repair" || this.thisItem.toOther === "On Delivery" ) ? "Ready To Deploy" : (this.itemlateststatus == 'On Delivery' && this.thisItem.lastStore == this.currentUser.store ? "Delivered" : "") }; @@ -923,9 +945,19 @@ // this.thisItem = await response.json(); this.thisItem = await response.json(); + console.log('last store'+this.thisItem.lastStore); + this.itemlateststatus = this.thisItem.latestStatus ? this.thisItem.latestStatus : this.thisItem.toOther; - this.itemassignedtouser = this.thisItem.toUser == this.currentUser.id || this.thisItem.lastUser == this.currentUser.id ? true : false; + this.itemassignedtouser = (this.thisItem.toUser === this.currentUser.id || this.thisItem.lastUser === this.currentUser.id ) && this.thisItem.lastStore === this.currentUser.store ? true : false; // console.log(this.thisItem); + // console.log(this.itemassignedtouser); + console.log(this.thisItem.lastStore); + console.log( this.thisItem.lastStore == this.currentUser.store? true : false); + console.log(this.thisItem.toUser == this.currentUser.id? true : false); + console.log( this.thisItem.lastUser == this.currentUser.id ? true : false); + console.log(((this.thisItem.toUser == this.currentUser.id) || ( this.thisItem.lastUser == this.currentUser.id)) ? true : false); + console.log('currentuser store'+this.currentUser.store); + } else { console.error('Failed to fetch item information'); diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs index 4afb06a..b78f641 100644 --- a/Controllers/API/Inventory/InvMainAPI.cs +++ b/Controllers/API/Inventory/InvMainAPI.cs @@ -538,6 +538,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory item.Movement?.ToOther, item.Movement?.LatestStatus, item.Movement?.LastUser, + item.Movement?.LastStore, item.Movement?.MovementComplete, remark = item.Movement?.Remark, QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String @@ -736,6 +737,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory return NotFound("Item movement record not found."); } + updatedList.LastUser = receiveMovement.LastUser; updatedList.LatestStatus = receiveMovement.LatestStatus; updatedList.receiveDate = receiveMovement.receiveDate; updatedList.Remark = receiveMovement.Remark; @@ -1216,7 +1218,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory { return NotFound("Item movement record not found."); } - + updatedList.MovementComplete = receiveMovement.MovementComplete; updatedList.LatestStatus = receiveMovement.LatestStatus; updatedList.receiveDate = receiveMovement.receiveDate; updatedList.MovementComplete = receiveMovement.MovementComplete;