Stock
| 📊 Overview: 1 Constructor | 17 Functions |
🕐 Last updated: 2026-01-13T16:04:13.480Z
📑 Table of Contents
- 🏗️ Constructor (2 params)
- ⚙️ Functions
- Regular Functions
- adjust (5 params) →
$lockObject : Object - move (5 params) →
$lockObject : Object - SetNewStockQuarantineStatus (1 param) →
$lockObject : Object - Quarantine_Stock (2 params) →
$lockObject : Object - Quarantine_Release (2 params) →
$lockObject : Object - Quarantine_Scrap (2 params) →
$lockObject : Object - startTransaction
- validateTransaction
- cancelTransaction
- InTransaction →
$InTransaction : Boolean - _RecordStockMovement (7 params) →
$Stock_MovementEntity : cs.Stock_MovementEntity - SetQuarantineReason (1 param) →
$lockObject : Object - GetAvailableQuantity (1 param) →
$AvailableQuantity : Integer - GetQuarantinedQuantity →
$QuarantinedQuantity : Integer - GetStockEntitySelection →
$EntitySelection : 4D.EntitySelection - GetNewStockQuarantineStatus →
$QuarantineNewStock : Boolean - GetQuarantineReason →
$QuarantineReason : Text
- adjust (5 params) →
- Regular Functions
Constructor
constructor
[🏗️ constructor]
Class constructor($DataStore : 4D.DataStoreImplementation; $WorksOrder : Integer)
Initializes stock management for a works order, setting up locations and default stock status
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$DataStore | 4D.DataStoreImplementation | - | - |
$WorksOrder | Integer | - | - |
Functions
Regular Functions
adjust
Function adjust($LocationID : Integer; $AdjustmentQuantity : Integer; $CreateStockMovement : Boolean; $AdjustmentReason : Text; $AdviceNote : Integer) -> $lockObject : Object
Adjusts stock quantity at a specific location and optionally records the movement
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$LocationID | Integer | - | - |
$AdjustmentQuantity | Integer | - | - |
$CreateStockMovement | Boolean | - | - |
$AdjustmentReason | Text | - | - |
$AdviceNote | Integer | - | - |
Returns: Object
move
Function move($FromLocation : Integer; $ToLocation : Integer; $AdjustmentQuantity : Integer; $AdjustmentReason : Text; $AdviceNote : Integer) -> $lockObject : Object
Moves stock from one location to another in a single transaction, recording the movement
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$FromLocation | Integer | - | - |
$ToLocation | Integer | - | - |
$AdjustmentQuantity | Integer | - | - |
$AdjustmentReason | Text | - | - |
$AdviceNote | Integer | - | - |
Returns: Object
SetNewStockQuarantineStatus
Function SetNewStockQuarantineStatus($QuarantineNewStock : Boolean) -> $lockObject : Object
Sets whether new stock for this works order should be quarantined by default
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$QuarantineNewStock | Boolean | - | - |
Returns: Object
Quarantine_Stock
Function Quarantine_Stock($QuantityToQuarantine : Integer; $QuarantineReason : Text) -> $lockObject : Object
Moves the specified quantity of finished stock to quarantine status with a reason
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$QuantityToQuarantine | Integer | - | - |
$QuarantineReason | Text | - | - |
Returns: Object
Quarantine_Release
Function Quarantine_Release($QuantityToRelease : Integer; $ReleaseReason : Text) -> $lockObject : Object
Releases quarantined stock back to finished goods with a release reason
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$QuantityToRelease | Integer | - | - |
$ReleaseReason | Text | - | - |
Returns: Object
Quarantine_Scrap
Function Quarantine_Scrap($QuantityToScrap : Integer; $ScrapReason : Text) -> $lockObject : Object
Scraps quarantined stock with a scrap reason and records the movement
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$QuantityToScrap | Integer | - | - |
$ScrapReason | Text | - | - |
Returns: Object
startTransaction
Function startTransaction
Begins a database transaction and increments the transaction level counter
validateTransaction
Function validateTransaction
Commits the current transaction and decrements the transaction level counter
cancelTransaction
Function cancelTransaction
Rolls back the current transaction and decrements the transaction level counter
InTransaction
Function InTransaction -> $InTransaction : Boolean
Returns whether a transaction is currently active based on the transaction level counter
Returns: Boolean
_RecordStockMovement
Function _RecordStockMovement($Quantity : Integer; $From_LocationID : Integer; $To_LocationID : Integer; $From_Type : Text; $To_Type : Text; $Reason : Text; $AdviceNote : Integer) -> $Stock_MovementEntity : cs.Stock_MovementEntity
Records a stock movement entry with source/destination locations, types, and reason
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$Quantity | Integer | - | - |
$From_LocationID | Integer | - | - |
$To_LocationID | Integer | - | - |
$From_Type | Text | - | - |
$To_Type | Text | - | - |
$Reason | Text | - | - |
$AdviceNote | Integer | - | - |
Returns: cs.Stock_MovementEntity
SetQuarantineReason
Function SetQuarantineReason($QuarantineReason : Text) -> $lockObject : Object
Sets the reason for quarantining stock on this works order
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$QuarantineReason | Text | - | - |
Returns: Object
GetAvailableQuantity
Function GetAvailableQuantity($StockLocation : Integer) -> $AvailableQuantity : Integer
Returns the total available stock quantity at the specified location (or default location if 0)
Parameters:
| Name | Type | Optional | Description |
|---|---|---|---|
$StockLocation | Integer | - | - |
Returns: Integer
GetQuarantinedQuantity
Function GetQuarantinedQuantity -> $QuarantinedQuantity : Integer
Returns the total quantity of stock currently in quarantine for this works order
Returns: Integer
GetStockEntitySelection
Function GetStockEntitySelection -> $EntitySelection : 4D.EntitySelection
Returns an entity selection of all non-zero stock records for this works order
Returns: 4D.EntitySelection
GetNewStockQuarantineStatus
Function GetNewStockQuarantineStatus -> $QuarantineNewStock : Boolean
Returns whether new stock for this works order is set to be quarantined
Returns: Boolean
GetQuarantineReason
Function GetQuarantineReason -> $QuarantineReason : Text
Returns the reason stored for quarantining stock on this works order
Returns: Text
Generated from Stock.4dm