dolibarr 20.0.0
StockMovements Class Reference
Inheritance diagram for StockMovements:
Collaboration diagram for StockMovements:

Public Member Functions

 __construct ()
 Constructor.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $sqlfilters='', $properties='')
 Get properties of a stock movement object.
 
 post ($product_id, $warehouse_id, $qty, $type=2, $lot='', $movementcode='', $movementlabel='', $price='', $datem='', $dlc='', $dluo='', $origin_type='', $origin_id=0)
 Create stock movement object.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($object)
 Update stock movement.
 
- Protected Member Functions inherited from DolibarrApi
 _checkValForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _filterObjectProperties ($object, $properties)
 Filter properties that will be returned on object.
 
 _checkFilters ($sqlfilters, &$error='')
 Return if a $sqlfilters parameter is valid Function no more used.
 

Private Member Functions

 _validate ($data)
 Validate fields before create or update object.
 

Additional Inherited Members

- Static Protected Member Functions inherited from DolibarrApi
static _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
 Check access by user to a given resource.
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria from a Generic filter string.
 

Detailed Description

Definition at line 29 of file api_stockmovements.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

StockMovements::_cleanObjectDatas ( $object)
protected

Update stock movement.

Parameters
int$idId of warehouse to update
array$request_dataDatas
Returns
Object Updated object Delete stock movement
Parameters
int$idStock movement ID
Returns
array Clean sensible object datas
Parameters
MouvementStock$objectObject to clean
Returns
Object Object with cleaned properties

Reimplemented from DolibarrApi.

Definition at line 287 of file api_stockmovements.class.php.

References $object.

Referenced by index().

◆ _validate()

StockMovements::_validate ( $data)
private

Validate fields before create or update object.

Parameters
array | null$dataData to validate
Returns
array
Exceptions
RestException

Definition at line 345 of file api_stockmovements.class.php.

◆ index()

StockMovements::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$sqlfilters = '',
$properties = '' )

Get properties of a stock movement object.

Return an array with stock movement information

Parameters
int$idID of movement
Returns
Object Object with cleaned properties
Exceptions
RestExceptionGet a list of stock movement
Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.product_id:=:1) and (t.date_creation:<:'20160101')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
Returns
array Array of warehouse objects
Exceptions
RestException

Definition at line 97 of file api_stockmovements.class.php.

References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), and forgeSQLFromUniversalSearchCriteria().

◆ post()

StockMovements::post ( $product_id,
$warehouse_id,
$qty,
$type = 2,
$lot = '',
$movementcode = '',
$movementlabel = '',
$price = '',
$datem = '',
$dlc = '',
$dluo = '',
$origin_type = '',
$origin_id = 0 )

Create stock movement object.

You can use the following message to test this RES API: { "product_id": 1, "warehouse_id": 1, "qty": 1, "lot": "", "movementcode": "INV123", "movementlabel": "Inventory 123", "price": 0 } $price Can be set to update AWP (Average Weighted Price) when you make a stock increase $dlc Eat-by date. Will be used if lot does not exists yet and will be created. $dluo Sell-by date. Will be used if lot does not exists yet and will be created.

Parameters
int$product_idId product id {@min 1} {@from body} {@required true}
int$warehouse_idId warehouse {@min 1} {@from body} {@required true}
float$qtyQty to add (Use negative value for a stock decrease) {@from body} {@required true}
int$typeOptionally specify the type of movement. 0=input (stock increase by a stock transfer), 1=output (stock decrease by a stock transfer), 2=output (stock decrease), 3=input (stock increase). {@from body} {@type int}
string$lotLot {@from body}
string$movementcodeMovement code {@from body}
string$movementlabelMovement label {@from body}
string$priceTo update AWP (Average Weighted Price) when you make a stock increase (qty must be higher then 0). {@from body}
string$datemDate of movement {@from body} {@type date}
string$dlcEat-by date. {@from body} {@type date}
string$dluoSell-by date. {@from body} {@type date}
string$origin_typeOrigin type (Element of source object, like 'project', 'inventory', ...)
int$origin_idOrigin id (Id of source object)
Returns
int ID of stock movement
Exceptions
RestException

Definition at line 176 of file api_stockmovements.class.php.

References dol_stringtotime().


The documentation for this class was generated from the following file: