dolibarr  19.0.0-dev
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
StockMovements Class Reference
Inheritance diagram for StockMovements:
Inheritance graph
[legend]
Collaboration diagram for StockMovements:
Collaboration graph
[legend]

Public Member Functions

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

Protected Member Functions

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

Private Member Functions

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

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. More...
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria from a Generic filter string. More...
 

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
int 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 288 of file api_stockmovements.class.php.

◆ _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 346 of file api_stockmovements.class.php.

◆ index()

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

Get properties of a stock movement object.

Return an array with stock movement informations

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')"
Returns
array Array of warehouse objects
Exceptions
RestException

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

◆ 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', ...)
string$origin_idOrigin id (Id of source object)
Returns
int ID of stock movement
Exceptions
RestException

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


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