The OrderUtils class holds a number of utility methods for order processing. More...
Public Member Functions | |
| void | addToStock (Object aParams) |
| Adds or subtracts stock quantities and updates other stock fields. | |
| void | cancelOrderPick (Number aPickKey) |
| Cancel an existing pick by deleting the record in t_orderpicks. | |
| Number | cloneArticle (Number aKey) |
| Make an exact copy of the original article, with exception of the key. | |
| Number | clonePartner (Number aKey) |
| Make an exact copy of the original partner, with exception of the key. | |
| Number | cloneRecord (Number aKey, String aName) |
| Make an exact copy of an arbitrary BPS record, with exception of the key. | |
| String | cprToString (Number aCpr) |
| Convert a consumer price to string. | |
| String | dprToString (Number aDpr) |
| Convert a dealer price to string. | |
| Number | finishOrderRow (Object aParams) |
| Finish a order row (depreciated). | |
| Object | finishOrderRowEx (Object aParams) |
| Finish a order row. | |
| Boolean | finishPurchaseOrder (Number aOrderKey, Boolean aLock=false, Number aTimeout=0) |
| Finishes a purchase order having the status ready, active or completed, and not having any blocked deliveries. | |
| Boolean | getSellPrices (Object aParams) |
| Find the prices for a certain article and starting date/time. | |
| Boolean | getZoneMergeclass (Object aParams) |
| Get the zone and merge class for a combination of trip, article and partner class. | |
| Boolean | isOrdercolLocked (Number aKey) |
| Checks if the order column, the open trip, or any of the details belonging to the column are locked. | |
| Boolean | isOrderitemLocked (Number aKey) |
| Checks if the order detail or any parent record is locked. | |
| Boolean | isOrderrowLocked (Number aKey) |
| Checks if the order row, the open trip or any of the details belonging to the row are locked. | |
| Boolean | isOrdertripLocked (Number aKey) |
| Checks if the open trip or any of the order rows, columns or details belonging to it are locked. | |
| Boolean | isPurchaseItemLocked (Number aKey) |
| Checks if the purchase order item or the parent purchase order record is locked. | |
| Boolean | isPurchaseOrderLocked (Number aKey) |
| Checks if the purchase order or any of the items belonging to the order are locked. | |
| Boolean | isRobotLocked (Number aKey) |
| Checks if the zone is currently robot-locked. | |
| Boolean | lockOrdercol (Number aKey, Number aTimeout=0) |
| Lock an order column. | |
| Boolean | lockOrderitem (Number aKey, Number aTimeout=0) |
| Lock an order detail. | |
| Boolean | lockOrderrow (Number aKey, Number aTimeout=0) |
| Lock an order row. | |
| Boolean | lockOrdertrip (Number aKey, Number aTimeout=0) |
| Lock an open trip. | |
| Boolean | lockPurchaseItem (Number aKey, Number aTimeout=0) |
| Lock a purchase order item. | |
| Boolean | lockPurchaseOrder (Number aKey, Number aTimeout=0) |
| Lock a purchase order. | |
| Boolean | lockRobot (Number aKey, Number aTimeout=0) |
| Lock a zone for exclusive robot access. | |
| Number | makeOrderItem (Object aParams) |
| Creates a new order item (depreciated). | |
| Object | makeOrderItemEx (Object aParams) |
| Creates a new order item. | |
| Number | makeOrderPick (Object aParams) |
| Make an order pick. | |
| Object | makePurchaseItem (Object aParams) |
| Creates a new purchase order item. | |
| OrderUtils (Datastore aDatastore) | |
| void | setStock (Object aParams) |
| Set the absolute stock quantities and updates other fields. | |
| String | tripdateToString (Date aTripdate) |
| Convert a order trip date to string. | |
| void | unlockOrdercol (Number aKey) |
| Unlock the order column, in case it was locked by the current actor. | |
| void | unlockOrderitem (Number aKey) |
| Unlock the order detail, in case it was locked by the current actor. | |
| void | unlockOrderrow (Number aKey) |
| Unlock the order row, in case it was locked by the current actor. | |
| void | unlockOrdertrip (Number aKey) |
| Unlock the open trip, in case it was locked by the current actor. | |
| void | unlockPurchaseItem (Number aKey) |
| Unlock the purchase order item, in case it was locked by the current actor. | |
| void | unlockPurchaseOrder (Number aKey) |
| Unlock the purchase order, in case it was locked by the current actor. | |
| void | unlockRobot (Number aKey) |
| Unlock the zone, in case it was locked by the current actor. | |
Static Public Member Functions | |
| static String | orderUnitName (String aOu) |
| Get the human readable and translated order unit name (LU, TU, CU, PU) from a order unit code (L, T, C, P). | |
| static String | priceUnitAbbreviation (String aPu) |
| Get the abbreviated, maximum 3 character price unit name (PCS, KG, L, M, M2, M3) from a price unit code (p, k, l, m, s, c). | |
| static String | priceUnitName (String aPu) |
| Get the human readable and translated price unit name (Piece, Kilo, Liter, Meter, M2, M3) from a price unit code (p, k, l, m, s, c). | |
| static String | stockModeName (String aMode) |
| Get the human readable and translated stock mode name (Regular, FIFO, Quick) from a price unit code (r, f, q). | |
The OrderUtils class holds a number of utility methods for order processing.
Example:
importExtension('bps'); var ds = new bps.Datastore; with (ds) { connection = 'lu_buv'; username = 'lu_buv'; password = 'lu_buv1'; if (!loadConnection()) throw Error("Invalid connection.\nKnown connections are: "+bps.Datastore.connections); connect(); purgeActors(); checkin(0, "batch", "stocktest"); } var utl = new bps.OrderUtils(ds); utl.setStock({ stock_key: 605, stock_reason: 0, stock_lus: 3, stock_tus: 5, stock_cus: 2, stock_tu_lu: 24, stock_cu_tu: 10 }); ds.checkout(); ds.disconnect();
| bps::OrderUtils::OrderUtils | ( | Datastore | aDatastore | ) |
| aDatastore | The datastore connection to use. |
| void bps::OrderUtils::addToStock | ( | Object | aParams | ) |
Adds or subtracts stock quantities and updates other stock fields.
Lus, tus and cus are normalized in the stock, e.g. recalculated according to the factors tu/lu and cu/tu for better human readability.
| [in] | aParams | The parameters defining the stock action.
|
| void bps::OrderUtils::cancelOrderPick | ( | Number | aPickKey | ) |
Cancel an existing pick by deleting the record in t_orderpicks.
If the pick was taken from stock, this operation will also add the picked quantities back to the stock in the same transaction.
| [in] | aPickKey | Key of the record in t_orderpicks. |
| Number bps::OrderUtils::cloneArticle | ( | Number | aKey | ) |
Make an exact copy of the original article, with exception of the key.
Copies also all subtables of the article record like prices, bar codes, fields and whatever new subtables may come in future releases of BPS.
Stock records are excluded, although in the workplace they are found in the article master data for convenience, they do not really belong to master data but are more like transaction data.
| [in] | aKey | Key of the original article record. |
| BpsException | when original article does not exist. |
| Number bps::OrderUtils::clonePartner | ( | Number | aKey | ) |
Make an exact copy of the original partner, with exception of the key.
Copies also all subtables of the partner record like attributes, departments and whatever new subtables may come in future releases of BPS.
| [in] | aKey | Key of the original partner record. |
| BpsException | when original partner does not exist. |
| Number bps::OrderUtils::cloneRecord | ( | Number | aKey, |
| String | aName | ||
| ) |
Make an exact copy of an arbitrary BPS record, with exception of the key.
The record must have a primary column c_key, the table must be the given name with prefix t_, and there must exist a sequence with the given name and prefix s_.
// clone a resource in update safe manner QVariant key = utils->cloneRecord(oldKey, bStr("resources"));
| [in] | aKey | Key of the original record. |
| [in] | aName | Name of the table and sequence, without prefixes. |
| BpsException | when original record does not exist. |
| String bps::OrderUtils::cprToString | ( | Number | aCpr | ) |
Convert a consumer price to string.
The mask is taken from the validator for t_articleprices.c_cpr. Null values are converted to an empty string.
| [in] | aCpr | The consumer price to convert. |
| String bps::OrderUtils::dprToString | ( | Number | aDpr | ) |
Convert a dealer price to string.
The mask is taken from the validator for t_articleprices.c_dpr. Null values are converted to an empty string.
| [in] | aDpr | The dealer price to convert. |
| Number bps::OrderUtils::finishOrderRow | ( | Object | aParams | ) |
Finish a order row (depreciated).
Kept for backward compatibility to older scripts. Use finishOrderRowEx for new developments.
| [in] | aParams | The parameters defining the finish action. |
| Object bps::OrderUtils::finishOrderRowEx | ( | Object | aParams | ) |
Finish a order row.
| [in] | aParams | The parameters defining the finish action.
|
| Property | Description |
|---|---|
| orderpicks_delivery | The delivery ID used. |
| new_ordertrips | Keys of the new created order trips in table t_ordertrips. |
| new_orderrows | Keys of the new created partner orders in table t_orderrows. |
| new_ordercols | Keys of the new created article orders in table t_ordercols. |
| new_orderitems | Keys of the new created order items in table t_orderitems. |
| Boolean bps::OrderUtils::finishPurchaseOrder | ( | Number | aOrderKey, |
| Boolean | aLock = false, |
||
| Number | aTimeout = 0 |
||
| ) |
Finishes a purchase order having the status ready, active or completed, and not having any blocked deliveries.
The following tasks are performed:
| [in] | aOrderKey | Key of the purchase order (t_purchaseorders.c_key) |
| [in] | aLock | True = lock the order while processing. False = do not lock/unlock (because order was locked in advance). |
| [in] | aTimeout | Locking time out in seconds. Special values: 0 = no wait, -1 = wait endless. |
| Boolean bps::OrderUtils::getSellPrices | ( | Object | aParams | ) |
Find the prices for a certain article and starting date/time.
The properties article and start must be set before calling. The method will set or add the properties dpr, cpr and code at execution. If no price is found, dpr and cpr are set to null, and code is to 'n'.
| [in] | aParams | Object with the parameters.
|
| Boolean bps::OrderUtils::getZoneMergeclass | ( | Object | aParams | ) |
Get the zone and merge class for a combination of trip, article and partner class.
In case no record is found, the method retries possible combinations in the order below and just returns false if none succeeded:
| Order | Trip Class | Article Class | Partner Class |
|---|---|---|---|
| 1 | * | * | * |
| 2 | * | * | null |
| 3 | * | null | * |
| 4 | * | null | null |
| 5 | null | * | * |
| 6 | null | * | null |
| 7 | null | null | * |
| 8 | null | null | null |
The properties tripclass, articleclass and partnerclass must be set before calling. The method will set or add the properties zone and mergeclass at execution. If no matching entry is found in table t_pickmatrix, zone and mergeclass are set to null.
| aParams | Object with the parameters.
|
| Boolean bps::OrderUtils::isOrdercolLocked | ( | Number | aKey | ) |
Checks if the order column, the open trip, or any of the details belonging to the column are locked.
| [in] | aKey | The primary key value (c_key) of the record in table t_ordercols. |
| Boolean bps::OrderUtils::isOrderitemLocked | ( | Number | aKey | ) |
Checks if the order detail or any parent record is locked.
| [in] | aKey | The primary key value (c_key) of the record in table t_orderitems. |
| Boolean bps::OrderUtils::isOrderrowLocked | ( | Number | aKey | ) |
Checks if the order row, the open trip or any of the details belonging to the row are locked.
| [in] | aKey | The primary key value (c_key) of the record in table t_orderrows. |
| Boolean bps::OrderUtils::isOrdertripLocked | ( | Number | aKey | ) |
Checks if the open trip or any of the order rows, columns or details belonging to it are locked.
| [in] | aKey | The primary key value (c_key) of the record in table t_ordertrips. |
| Boolean bps::OrderUtils::isPurchaseItemLocked | ( | Number | aKey | ) |
Checks if the purchase order item or the parent purchase order record is locked.
| [in] | aKey | The primary key value (c_key) of the record in table t_purchaseitems. |
| Boolean bps::OrderUtils::isPurchaseOrderLocked | ( | Number | aKey | ) |
Checks if the purchase order or any of the items belonging to the order are locked.
| [in] | aKey | The primary key value (c_key) of the record in table t_purchaseorders. |
| Boolean bps::OrderUtils::isRobotLocked | ( | Number | aKey | ) |
Checks if the zone is currently robot-locked.
| [in] | aKey | The primary key value (c_key) in table t_zones. |
| Boolean bps::OrderUtils::lockOrdercol | ( | Number | aKey, |
| Number | aTimeout = 0 |
||
| ) |
Lock an order column.
This lock will only succeed when no other actor has locked the column or any of the details belonging to it.
| [in] | aKey | The primary key value (c_key) of the record in table t_ordercols. |
| [in] | aTimeout | Time out in seconds. Special values: 0 = no wait, -1 = wait endless |
| Boolean bps::OrderUtils::lockOrderitem | ( | Number | aKey, |
| Number | aTimeout = 0 |
||
| ) |
Lock an order detail.
This lock will only succeed when no other actor has locked the detail record.
| [in] | aKey | The primary key value (c_key) of the record in table t_orderitems. |
| [in] | aTimeout | Time out in seconds. Special values: 0 = no wait, -1 = wait endless |
| Boolean bps::OrderUtils::lockOrderrow | ( | Number | aKey, |
| Number | aTimeout = 0 |
||
| ) |
Lock an order row.
This lock will only succeed when no other actor has locked the row or any of the details belonging to it.
| [in] | aKey | The primary key value (c_key) of the record in table t_orderrows. |
| [in] | aTimeout | Time out in seconds. Special values: 0 = no wait, -1 = wait endless |
| Boolean bps::OrderUtils::lockOrdertrip | ( | Number | aKey, |
| Number | aTimeout = 0 |
||
| ) |
Lock an open trip.
This lock will only succeed when no other actor has locked the open trip or any of the order rows, columns and details belonging to the open trip.
| [in] | aKey | The primary key value (c_key) of the record in table t_ordertrips. |
| [in] | aTimeout | Time out in seconds. Special values: 0 = no wait, -1 = wait endless |
| Boolean bps::OrderUtils::lockPurchaseItem | ( | Number | aKey, |
| Number | aTimeout = 0 |
||
| ) |
Lock a purchase order item.
This lock will only succeed when no other actor has locked the item or the parent purchase order.
| [in] | aKey | The primary key value (c_key) of the record in table t_purchaseitems. |
| [in] | aTimeout | Time out in seconds. Special values: 0 = no wait, -1 = wait endless |
| Boolean bps::OrderUtils::lockPurchaseOrder | ( | Number | aKey, |
| Number | aTimeout = 0 |
||
| ) |
Lock a purchase order.
This lock will only succeed when no other actor has locked the order or any of the items belonging to it.
| [in] | aKey | The primary key value (c_key) of the record in table t_purchaseorders. |
| [in] | aTimeout | Time out in seconds. Special values: 0 = no wait, -1 = wait endless |
| Boolean bps::OrderUtils::lockRobot | ( | Number | aKey, |
| Number | aTimeout = 0 |
||
| ) |
Lock a zone for exclusive robot access.
This lock will only succeed when no other actor has locked the robot.
| [in] | aKey | The primary key value (c_key) in table t_zones. |
| [in] | aTimeout | Time out in seconds. Special values: 0 = no wait, -1 = wait endless |
| Number bps::OrderUtils::makeOrderItem | ( | Object | aParams | ) |
Creates a new order item (depreciated).
Kept for backward compatibility to older scripts. Use makeOrderItemEx for new developments.
| aParams | Object with the parameters defining the order item (see makeOrderItemEx). |
| Object bps::OrderUtils::makeOrderItemEx | ( | Object | aParams | ) |
Creates a new order item.
| aParams | Object with the parameters defining the order item.
|
| Property | Description |
|---|---|
| tripkey | Key of the order trip in table t_ordertrips. |
| rowkey | Key of the partner order in table t_orderrows. |
| colkey | Key of the article order in table t_ordercols. |
| itemkey | Key of the order item in table t_orderitems. |
| newtrip | True if the order trip was created, false if it already existed before. |
| newrow | True if the partner order was created, false if it already existed before. |
| newcol | True if the article order was created, false if it already existed before. |
| Number bps::OrderUtils::makeOrderPick | ( | Object | aParams | ) |
Make an order pick.
| aParams | The parameters defining the pick action.
|
| Object bps::OrderUtils::makePurchaseItem | ( | Object | aParams | ) |
Creates a new purchase order item.
| [in] | aParams | The parameters defining the purchase order item.
|
| Property | Description |
|---|---|
| orderkey | Key of the new created order in table t_purchaseorders. |
| itemkey | Key of the new created item in table t_purchaseitems. |
Get the human readable and translated order unit name (LU, TU, CU, PU) from a order unit code (L, T, C, P).
print( bps.OrderUtils.orderUnitName('T') ); // TU
| [in] | aOu | The order unit code. |
Get the abbreviated, maximum 3 character price unit name (PCS, KG, L, M, M2, M3) from a price unit code (p, k, l, m, s, c).
print( bps.OrderUtils.priceUnitAbbreviation('p') ); // PCS, STK, PEZ - depending on current language
| [in] | aPu | The price unit code. |
Get the human readable and translated price unit name (Piece, Kilo, Liter, Meter, M2, M3) from a price unit code (p, k, l, m, s, c).
print( bps.OrderUtils.priceUnitName('p') ); // Piece, Stück, Pièce, Pezzi - depending on current language
| [in] | aPu | The price unit code. |
| void bps::OrderUtils::setStock | ( | Object | aParams | ) |
Set the absolute stock quantities and updates other fields.
LU's, TU's and CU's are normalized in the stock, e.g. recalculated according to the factors TU/LU and CU/TU for better human readability.
| [in] | aParams | The parameters defining the stock action.
|
Get the human readable and translated stock mode name (Regular, FIFO, Quick) from a price unit code (r, f, q).
print( bps.OrderUtils.stockModeName('r') ); // Regular, Normal, Regolare - depending on current language
| [in] | aMode | The stock mode code. |
| String bps::OrderUtils::tripdateToString | ( | Date | aTripdate | ) |
Convert a order trip date to string.
The format is taken from the validator for t_ordertrips.c_date. Null values are converted to an empty string.
| [in] | aTripdate | The date to convert. |
| void bps::OrderUtils::unlockOrdercol | ( | Number | aKey | ) |
Unlock the order column, in case it was locked by the current actor.
| [in] | aKey | The primary key value (c_key) of the record in table t_ordercols. |
| void bps::OrderUtils::unlockOrderitem | ( | Number | aKey | ) |
Unlock the order detail, in case it was locked by the current actor.
| [in] | aKey | The primary key value (c_key) of the record in table t_orderitems. |
| void bps::OrderUtils::unlockOrderrow | ( | Number | aKey | ) |
Unlock the order row, in case it was locked by the current actor.
| [in] | aKey | The primary key value (c_key) of the record in table t_orderrows. |
| void bps::OrderUtils::unlockOrdertrip | ( | Number | aKey | ) |
Unlock the open trip, in case it was locked by the current actor.
| [in] | aKey | The primary key value (c_key) of the record in table t_ordertrips. |
| void bps::OrderUtils::unlockPurchaseItem | ( | Number | aKey | ) |
Unlock the purchase order item, in case it was locked by the current actor.
| [in] | aKey | The primary key value (c_key) of the record in table t_purchaseitems. |
| void bps::OrderUtils::unlockPurchaseOrder | ( | Number | aKey | ) |
Unlock the purchase order, in case it was locked by the current actor.
| [in] | aKey | The primary key value (c_key) of the record in table t_purchaseorders. |
| void bps::OrderUtils::unlockRobot | ( | Number | aKey | ) |
Unlock the zone, in case it was locked by the current actor.
| [in] | aKey | The primary key value (c_key) in table t_zones. |