BPS C++ API  2.24.4
BpsOrderUtils Class Reference

BPS order utilities. More...

#include <bpsorderutils.h>

+ Inheritance diagram for BpsOrderUtils:

Public Types

enum  OrderGenMode { OM_BPS , OM_ERP }
 Order generation modes. More...
 
enum  OuIndex { O_unknown , O_PU , O_CU , O_TU , O_LU }
 Order unit enumeration. More...
 
enum  PuIndex { P_unknown , P_Piece , P_Kilo , P_Liter , P_Meter , P_SquareMeter , P_CubicMeter }
 Price unit enumeration. More...
 
enum  StockModeIndex { SM_unknown , SM_Regular , SM_FIFO , SM_Quick }
 Stock handling modes. More...
 
enum  StockReasonIndex {
  SR_Unknown , SR_Manual , SR_ManualPlus , SR_ManualMinus , SR_Storage , SR_Withdraw , SR_SupplyIntake , SR_SupplyReturn , SR_PickReturn , SR_PickDraw ,
  SR_StockOK , SR_StockPlus , SR_StockMinus , SR_Autosync
}
 Stock change reason index. More...
 

Public Member Functions

void addToStock (const QVariantMap &aParams)
 Adds (or subtracts) stock quantities and updates other stock fields. More...
 
Bps::Status adoptLu (const QVariantMap &aParams)
 Adopt an orphaned new logistic unit. More...
 
bool anyPicksOnLu (const QVariant &aKey)
 Check if there are any picks on the logistic unit. More...
 
bool anyRobots () const
 Check if there are any active robots. More...
 
 BpsOrderUtils (BpsDatastore *aDatastore, QObject *aParent=nullptr)
 Constructor for the BpsOrderUtils objects. More...
 
void cancelOrderPick (const QVariant &aPickKey)
 Cancel an existing pick by deleting the record in t_orderpicks. More...
 
QVariant clearPackStock (const QVariant &aPackRecKey)
 Clear stock registration of a packing record. More...
 
QVariant clearPurchaseDeliveryStock (const QVariant &aDeliveryKey)
 Clear stock registration of purchase delivery record. More...
 
QVariant cloneArticle (const QVariant &aKey)
 Make an exact copy of the original article, with exception of the key. More...
 
QVariant clonePartner (const QVariant &aKey)
 Make an exact copy of the original partner, with exception of the key. More...
 
QVariant cloneRecord (const QVariant &aKey, const QString &aName)
 Make an exact copy of an arbitrary BPS record, with exception of the key. More...
 
QString cprToString (const QVariant &aCpr)
 Convert a consumer price to string. More...
 
BpsDatastoredatastore () const
 
QString dprToString (const QVariant &aDpr)
 Convert a dealer price to string. More...
 
BpsEpcisepcis ()
 
QVariantMap finalizeLu (const QVariantMap &aParams)
 Finalize a logistic unit. More...
 
QVariantMap findLockLu (const QVariantMap &aParams)
 Find and lock an orphaned new logistic unit. More...
 
QVariant findLu (const QVariantMap &aParams)
 Find a new logistic unit. More...
 
QVariantMap findOrMakeSharedLu (const QVariantMap &aParams)
 Find and lock an orphaned new logistic unit, or create a new one. More...
 
QVariantMap finishOrderRow (const QVariantMap &aParams)
 Finish a order row. More...
 
bool finishPurchaseOrder (const QVariant &aOrderKey, bool aLock=false, int aTimeout=0)
 Finishes a purchase order having the status ready, active or completed, and not having any blocked deliveries. More...
 
QVariantMap getArticle (const QVariant &aArticleKey)
 Get article record. More...
 
QList< QPair< QString, QString > > getDefaultStockReasons ()
 Get the default stock reason types and names as a list. More...
 
QVariantMap getPackjob (const QVariant &aPackjobKey)
 Get packing job record. More...
 
QVariantMap getPartner (const QVariant &aPartnerKey)
 Get partner record. More...
 
QVariantMap getProd (const QVariant &aProdKey)
 Get production record. More...
 
bool getSellPrices (const QVariant &aArticleKey, const QDateTime &aStart, QVariant &aDpr, QVariant &aCpr, QVariant &aCode)
 Find the prices for a certain article and starting date/time. More...
 
QVariant getStockReason (const QString &aType)
 Get the stock reason for a certain type from table t_stockreasons. More...
 
QVariant getStockReason (StockReasonIndex aIndex)
 Get the stock reason for a certain stock reason index from table t_stockreasons. More...
 
QVariantMap getTrip (const QVariant &aTripKey)
 Get trip record. More...
 
QVariantMap getZone (const QVariant &aZoneKey)
 Get zone record. More...
 
bool getZoneMergeclass (const QVariant &aTripclassKey, const QVariant &aArticleclassKey, const QVariant &aPartnerclassKey, QVariant &aZoneKey, QVariant &aMergeclassKey)
 Get the zone and merge class for a combination of trip, article and partner class. More...
 
bool isOrdercolLocked (const QVariant &aKey)
 Checks if the order column, the order trip, or any of the details belonging to the column are locked. More...
 
bool isOrderitemLocked (const QVariant &aKey)
 Checks if the order detail or any parent record is locked. More...
 
bool isOrderrowLocked (const QVariant &aKey)
 Checks if the order row, the order trip, the related columns or any of the details belonging to the row are locked. More...
 
bool isOrdertripLocked (const QVariant &aKey)
 Checks if the order trip or any of the order rows, columns or details belonging to it are locked. More...
 
bool isPackjobLocked (const QVariant &aKey, bool aExclusive=true)
 Checks if the packing job or the production it belongs to are locked. More...
 
bool isPackprodLocked (const QVariant &aKey)
 Checks if the packing production or any of the jobs belonging to it are locked. More...
 
bool isPurchaseItemLocked (const QVariant &aKey)
 Checks if the purchase order item or the parent purchase order record is locked. More...
 
bool isPurchaseOrderLocked (const QVariant &aKey)
 Checks if the purchase order or any of the items belonging to the order are locked. More...
 
Bps::Status lockLu (const QVariant &aKey, int aTimeout=0)
 Lock an logistic unit in table t_newlogisticunits. More...
 
Bps::Status lockOrdercol (const QVariant &aKey, int aTimeout=0, bool aFullcheck=true)
 Lock an order column. More...
 
Bps::Status lockOrderitem (const QVariant &aKey, int aTimeout=0, bool aFullcheck=true)
 Lock an order item. More...
 
Bps::Status lockOrderrow (const QVariant &aKey, int aTimeout=0, bool aFullcheck=true)
 Lock an order row. More...
 
Bps::Status lockOrdertrip (const QVariant &aKey, int aTimeout=0, bool aFullcheck=true)
 Lock an order trip. More...
 
Bps::Status lockPackjob (const QVariant &aKey, bool aExclusive=true, int aTimeout=0, bool aFullcheck=true)
 Lock a packing job. More...
 
Bps::Status lockPackprod (const QVariant &aKey, int aTimeout=0, bool aFullcheck=true)
 Lock an packing production. More...
 
Bps::Status lockPurchaseItem (const QVariant &aKey, int aTimeout=0)
 Lock a purchase order item. More...
 
Bps::Status lockPurchaseOrder (const QVariant &aKey, int aTimeout=0)
 Lock a purchase order. More...
 
QVariantList makeErpOrders (const QList< QVariantMap > &aParams)
 Create ERP orders in table t_erporders and t_erporderitems. More...
 
QVariant makeLu (const QVariantMap &aParams)
 Create a new logistic unit. More...
 
QVariantMap makeOrderItem (const QVariantMap &aParams)
 Creates a new order item. More...
 
QVariant makeOrderPick (const QVariantMap &aParams)
 Make an order pick. More...
 
QVariantMap makePackJob (const QVariantMap &aParams)
 Creates or updates a packing job. More...
 
QVariant makePackRec (const QVariantMap &aParams)
 Make a packing record. More...
 
QVariantMap makePurchaseDelivery (const QVariantMap &aParams)
 Creates a new purchase order delivery. More...
 
QVariantMap makePurchaseEntry (const QVariantMap &aParams)
 Registration of an entry on an existing purchase delivery. More...
 
QVariantMap makePurchaseItem (const QVariantMap &aParams)
 Creates a new purchase order item. More...
 
QVariant makeStock (const QVariantMap &aParams)
 Create a new stock. More...
 
OrderGenMode orderGenMode (const QString &aTripid)
 Get the order generation mode for a given trip ID. More...
 
void refreshLu (const QVariant &aKey)
 Refresh the timestamp of the logistic unit, in case it is locked by the current actor. More...
 
BpsRobotrobot (const QVariant &aZone) const
 Get robot of a given zone. More...
 
QList< BpsRobot * > robots () const
 Get a list of all active robot. More...
 
QVariant saveZoneStock (const QVariantMap &aParams)
 Adds a quantity to an existing stock in the given zone, or creates a new stock in the zone when no existing stock was found. More...
 
void setPurchaseDeliveryStock (const QVariant &aDeliveryKey, const QVariant &aStockKey=QVariant())
 Register stock of purchase delivery record. More...
 
void setStock (const QVariantMap &aParams)
 Set the absolute stock quantities and updates other fields on an existing stock. More...
 
QString tripdateToString (const QVariant &aTripdate)
 Convert a order trip date to string. More...
 
void unlockLu (const QVariant &aKey)
 Unlock the logistic unit, in case it is locked by the current actor. More...
 
void unlockOrdercol (const QVariant &aKey)
 Unlock the order column, in case it was locked by the current actor. More...
 
void unlockOrderitem (const QVariant &aKey)
 Unlock the order item. More...
 
void unlockOrderitems (const QVariant &aKID)
 Unlock a list of order items held in table t_keyids. More...
 
void unlockOrderitems (const QVariantList &aKeys)
 Unlock a list of order items. More...
 
void unlockOrderrow (const QVariant &aKey)
 Unlock the order row, in case it was locked by the current actor. More...
 
void unlockOrdertrip (const QVariant &aKey)
 Unlock the order trip, in case it was locked by the current actor. More...
 
void unlockPackjob (const QVariant &aKey)
 Unlock the packing job, in case it was locked by the current actor. More...
 
void unlockPackprod (const QVariant &aKey)
 Unlock the packing production, in case it was locked by the current actor. More...
 
void unlockPurchaseItem (const QVariant &aKey)
 Unlock the purchase order item, in case it was locked by the current actor. More...
 
void unlockPurchaseOrder (const QVariant &aKey)
 Unlock the purchase order, in case it was locked by the current actor. More...
 
- Public Member Functions inherited from QObject
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
 QObject (QObject *parent)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static OuIndex orderUnitIndex (const QVariant &aOu)
 Get the enumeration for a order unit code. More...
 
static QString orderUnitName (const QVariant &aOu)
 Get the human readable and translated order unit name (LU, TU, CU, PU) from a order unit code ("L", "T", "C", "P"). More...
 
static QString orderUnitName (const QVariant &aOu, const QVariant &aPu)
 Get the human readable and translated order unit name (LU, TU, CU, Piece, Kilo, Liter, Meter, M2, M3) from a order unit index and price unit index. More...
 
static QString orderUnitName (OuIndex aOu)
 Get the human readable and translated order unit name (LU, TU, CU, PU) from a order unit index (O_LU, O_TU, O_CU, O_PU). More...
 
static QString orderUnitName (OuIndex aOu, PuIndex aPu)
 Get the human readable and translated order unit name (LU, TU, CU, Piece, Kilo, Liter, Meter, M2, M3) from a order unit index and price unit index. More...
 
static QString priceUnitAbbreviation (const QVariant &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). More...
 
static QString priceUnitAbbreviation (PuIndex aPu)
 Get the abbreviated, maximum 3 character price unit name (PCS, KG, L, M, M2, M3) from a price unit index (P_Piece, P_Kilo, P_Liter, P_Meter, P_SquareMeter, P_CubicMeter). More...
 
static PuIndex priceUnitIndex (const QVariant &aPu)
 Get the enumeration for a price unit code. More...
 
static QString priceUnitName (const QVariant &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). More...
 
static QString priceUnitName (PuIndex aPu)
 Get the human readable and translated price unit name (Piece, Kilo, Liter, Meter, M2, M3) from a price unit index (P_Piece, P_Kilo, P_Liter, P_Meter, P_SquareMeter, P_CubicMeter). More...
 
static StockModeIndex stockModeIndex (const QVariant &aMode)
 Get the enumeration for a stock mode code. More...
 
static QString stockModeName (const QVariant &aMode)
 Get the human readable and translated stock mode name (Regular, FIFO, Quick) from a price unit code (r, f, q). More...
 
static QString stockModeName (StockModeIndex aMode)
 Get the human readable and translated stock mode name (Regular, FIFO, Quick) from a stock mode index (SM_Regular, SM_FIFO, SM_Quick). More...
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

BPS order utilities.

This class assembles a collection of utilities used for order processing.

Member Enumeration Documentation

◆ OrderGenMode

Order generation modes.

Enumerator
OM_BPS 

Create BPS orders.

OM_ERP 

Submit ERP orders.

◆ OuIndex

Order unit enumeration.

Enumerator
O_unknown 

Unknown unit.

O_PU 

Price unit.

O_CU 

Consumer unit.

O_TU 

Traded unit.

O_LU 

Logistic unit.

◆ PuIndex

Price unit enumeration.

Enumerator
P_unknown 

Unknown unit.

P_Piece 

Pieces.

P_Kilo 

Kilos.

P_Liter 

Liters.

P_Meter 

Meters.

P_SquareMeter 

Square meters.

P_CubicMeter 

Cubic meters.

◆ StockModeIndex

Stock handling modes.

Enumerator
SM_unknown 

Unknown stock mode.

SM_Regular 

Regular stock mode.

SM_FIFO 

Regular stock mode.

SM_Quick 

Regular stock mode.

◆ StockReasonIndex

Stock change reason index.

Enumerator
SR_Unknown 

Unknown stock reason.

SR_Manual 

Manual change (m)

SR_ManualPlus 

Manual + change (m+)

SR_ManualMinus 

Manual - change (m-)

SR_Storage 

General storage (g+)

SR_Withdraw 

General withdraw (g-)

SR_SupplyIntake 

Supply intake (i+)

SR_SupplyReturn 

Supply return (i-)

SR_PickReturn 

Picking return (p+)

SR_PickDraw 

Picking draw (p-)

SR_StockOK 

Stocktaking confirmation (s0)

SR_StockPlus 

Stocktaking + change (s+)

SR_StockMinus 

Stocktaking - change (s-)

SR_Autosync 

Automatic sync (a)

Constructor & Destructor Documentation

◆ BpsOrderUtils()

BpsOrderUtils::BpsOrderUtils ( BpsDatastore aDatastore,
QObject aParent = nullptr 
)

Constructor for the BpsOrderUtils objects.

Parameters
aDatastoreDatastore to work on.
aParentPointer to an optional parent object.

Member Function Documentation

◆ addToStock()

void BpsOrderUtils::addToStock ( const QVariantMap &  aParams)

Adds (or subtracts) stock quantities and updates other stock fields.

Parameters
aParamsThe parameters defining the stock action.
Key Description Mandatory Default
stock_key The stock key in t_stock yes n.a.
stock_reason The change reason. A key from t_stockreasons yes n.a.
stock_lus Logical units delta (+/-) to the existing stock no 0
stock_tus Traded units delta (+/-) to the existing stock no 0
stock_cus Consumer units delta (+/-) to the existing stock no 0

◆ adoptLu()

Bps::Status BpsOrderUtils::adoptLu ( const QVariantMap &  aParams)

Adopt an orphaned new logistic unit.

The method tries to lock and the record with key c_luid in t_newlogisticunits. On success, it sets either c_orderrow or c_ordertrip, where c_orderrow has precedence if both are given and not NULL. It also sets c_zone and c_mergeclass if they are given and not NULL.

Parameters
aParamsParameters for the new LU.
Key Description Mandatory Default
c_luid The ID of the LU. yes n.a.
c_timeout Seconds to wait for the lock. 0 = dont wait, -1 = wait endless. no 0
c_orderrow Key of the new order row no Leave old order row alone.
c_ordertrip Key of the new order trip no Leave old order trip alone
c_zone Key of the new picking zone no Leave old zone alone.
c_mergeclass Key of the new merge class no leave old merge class alone

If c_orderrow is given and not NULL, parameter c_ordertrip is ignored and set to NULL in the record. The the partner of the new order row must match the current record value, otherwise a BpsException is thrown.

If c_ordertrip is given and not NULL, but c_orderrow is not given or is NULL, c_orderrow is set NULL in the record.

Returns
Bps::Status as:
  • Bps::OK if the adopting was successful and record is locked.
  • Bps::Notfound If record not found in t_newlogisticunits, or maybe it was deleted while waiting.
  • Bps::Locked Record exists but it was already locked and stayed locked until timeout.

◆ anyPicksOnLu()

bool BpsOrderUtils::anyPicksOnLu ( const QVariant aKey)

Check if there are any picks on the logistic unit.

Parameters
aKeyThe primary key value (c_key) of the record in table t_newlogisticunits.
Returns
True if there are any picks, false if not.

◆ anyRobots()

bool BpsOrderUtils::anyRobots ( ) const

Check if there are any active robots.

Equivalent to !robots().isEmpty().

Returns
True if there are any active robots.

◆ cancelOrderPick()

void BpsOrderUtils::cancelOrderPick ( const QVariant 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.

Parameters
aPickKeyKey of the record in t_orderpicks.

◆ clearPackStock()

QVariant BpsOrderUtils::clearPackStock ( const QVariant aPackRecKey)

Clear stock registration of a packing record.

If c_stock is already NULL or the packing production is archived (c_status = h) nothing happens. If c_stock is not NULL, the LU, TU and CU quantities are subtracted from the stock and c_stock is set to NULL.

Parameters
aPackRecKeyKey of the record in table t_packrecs.
Returns
Value of c_stock before clearing.

◆ clearPurchaseDeliveryStock()

QVariant BpsOrderUtils::clearPurchaseDeliveryStock ( const QVariant aDeliveryKey)

Clear stock registration of purchase delivery record.

If c_stock is already NULL or the purchase order is archived (c_status = h) nothing happens. If c_stock is not NULL, the LU, TU and CU quantities are subtracted from the stock and c_stock is set to NULL.

Parameters
aDeliveryKeyKey of the delivery in table t_purchasedeliveries.
Returns
Value of c_stock before clearing.

◆ cloneArticle()

QVariant BpsOrderUtils::cloneArticle ( const QVariant 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.

Parameters
aKeyKey of the original article record.
Returns
Key of the new article record.
Exceptions
BpsExceptionwhen original article does not exist.

◆ clonePartner()

QVariant BpsOrderUtils::clonePartner ( const QVariant 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.

Parameters
aKeyKey of the original partner record.
Returns
Key of the new partner record.
Exceptions
BpsExceptionwhen original partner does not exist.

◆ cloneRecord()

QVariant BpsOrderUtils::cloneRecord ( const QVariant aKey,
const QString 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"));
#define bStr(aStr)
Encapsulation for string literals.
Definition: bpsglobals.h:125
Parameters
aKeyKey of the original record.
aNameName of the table and sequence, without prefixes.
Returns
Key of the new article record.
Exceptions
BpsExceptionwhen original record does not exist.

◆ cprToString()

QString BpsOrderUtils::cprToString ( const QVariant 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.

Parameters
aCprThe consumer price to convert.
Returns
The string representation.

◆ datastore()

BpsDatastore* BpsOrderUtils::datastore ( ) const
Returns
The datastore worked on.

◆ dprToString()

QString BpsOrderUtils::dprToString ( const QVariant 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.

Parameters
aDprThe dealer price to convert.
Returns
The string representation.

◆ epcis()

BpsEpcis* BpsOrderUtils::epcis ( )
Returns
The epcis used by this object.

◆ finalizeLu()

QVariantMap BpsOrderUtils::finalizeLu ( const QVariantMap &  aParams)

Finalize a logistic unit.

Completes a logistic unit making it ready for shipping. The LU must have a record in t_newlogisticunits and be locked for the current actor.

  • Sets t_orderpicks.c_finishby and c_finishdate
  • Sets t_orderpicks.c_delivery, c_delivby and c_delivdate where c_delivery is null and any of
    • t_partner.c_billmode = 'l' (billing mode = LU)
    • Central System Settings/GuiConfig/Finalize LU:ForceDelivery = "yes"
  • Optionally add SSCC to the order picks.
  • Optionally create EPCIS events for the LU. Basic condition is BpsEpcis::isEnabled() returns true.
  • Send finalized LU back to robot when items belong to a robot subjob.
  • Delete record from t_newlogisticunits.
Parameters
aParamsThe parameters defining the finish action.
Key Description Mandatory Default
c_luid ID of the LU (logistic unit) to finalize in t_ordertrips.c_luid yes n.a.
c_finishdate Finish timestamp (QDateTime) to set as t_ordertrips.c_finishdate no Current timestamp
c_finishby User key to set as t_ordertrips.c_finishby no Key of current user
c_delivery Delivery ID to set as t_ordertrips.c_delivery no Created from sequence s_deliveries
c_delivdate Delivery timestamp (QDateTime) to set as t_ordertrips.c_delivdate no Current timestamp
c_delivby User key to set as t_ordertrips.c_delivby no Key of current user
c_sscc The SSCC in EPCIS format to set no Generate from CSS/Labeling/LU:SSCC Prefix and sequence s_ssccval
c_sscccond Conditions for setting SSCC, depending on current values of c_sscc and c_grai in t_orderpicks:
0=Never set.
1=If current values of both c_sscc and c_grai are NULL.
2=If current value in c_sscc is NULL. Dont care about c_grai.
3=If c_grai is NULL. Dont care about current value of c_sscc.
4=Always set. Dont care about current values of c_sscc or c_grai.
no 1
c_epciscond Additional conditions for creating EPCIS events:
0=Never create.
1=Create a SSCC-event for each SSCC in the orderpicks of the LU.
2=Create a GRAI-event for each GRAI in the orderpicks of the LU.
3=Create a GRAI-event for each GRAI, and a SSCC-event for each SSCC in the orderpicks of the LU.
no 1
Returns
Map with informations about the operation:
Key Description
c_status Bps::OK if successful.
Bps::Notfound Record was not found in t_newlogisticunits, or it contains no valid orderrow or ordertrip.
Bps::Notlocked The LU was not locked for the current actor. Lock it before calling this method.
c_ordertrip Key of the order trip.
c_sscc The SSCC in EPCIS format, for example "7617007.3000999991".
c_sscc18 The SSCC in scanning format, for example "376170070009999913".

◆ findLockLu()

QVariantMap BpsOrderUtils::findLockLu ( const QVariantMap &  aParams)

Find and lock an orphaned new logistic unit.

Either c_orderrow or c_ordertrip+c_partner are used as conditions to find a matching record in t_newlogisticunits.

If c_orderrow is present and not NULL it has precedence, and parameters c_ordertrip+c_partner are ignored.

If c_zone and/or c_mergeclass are present, they are used as additional conditions (even when NULL).

Parameters
aParamsParameters for the new LU.
Key Description Mandatory Default
c_orderrow Key of the order row yes(*) n.a.
c_ordertrip Key of the order trip yes(*) null
c_partner Key of the partner yes if c_orderrow missing Take from order row
c_zone Key of the picking zone no null
c_mergeclass Key of the merge class no null
c_timeout Seconds to wait for the lock. 0 = dont wait, -1 = wait endless. no 0
Returns
Map with informations about the operation:
Key Description
c_status Bps::OK Record found and lock was successful.
Bps::Notfound If record not found in t_newlogisticunits, or maybe deleted while waiting.
Bps::Locked Record exists but it was already locked and stayed locked until timeout.
c_luid Key of the found record.

◆ findLu()

QVariant BpsOrderUtils::findLu ( const QVariantMap &  aParams)

Find a new logistic unit.

Either c_orderrow or c_ordertrip+c_partner are used as conditions to find a matching record in t_newlogisticunits.

If c_orderrow is present and not NULL it has precedence, and parameters c_ordertrip+c_partner are ignored.

If c_zone and/or c_mergeclass are present, they are used as additional conditions (even when NULL).

Parameters
aParamsParameters for the LU.
Key Description Mandatory Default
c_orderrow Key of the order row yes(*) n.a.
c_ordertrip Key of the order trip yes(*) null
c_partner Key of the partner yes if c_orderrow missing Take from order row
c_zone Key of the picking zone no not used
c_mergeclass Key of the merge class no not used
Returns
Key of the found record (luid). NULL if not found.

◆ findOrMakeSharedLu()

QVariantMap BpsOrderUtils::findOrMakeSharedLu ( const QVariantMap &  aParams)

Find and lock an orphaned new logistic unit, or create a new one.

This is basically a combination of BpsOrderUtils::findLockLu(), and if no record exists create a new one with BpsOrderUtils::makeLu().

During the find/make process the table t_newlogistics is locked to avoid that two clients create each a new record at same time (hence "shared").

Use case is for example break bulk picking, where multiple clients pick onto a single LU - you don't want that two create a LU at same time.

This method may not be called within a database transaction.

Parameters
aParamsParameters for the LU to find or make.
Key Description Mandatory Default
c_orderrow Key of the order row yes(*) n.a.
c_ordertrip Key of the order trip yes(*) NULL
c_partner Key of the partner yes if c_orderrow missing Take from order row
c_zone Key of the picking zone no Not used when searching, NULL when creating
c_mergeclass Key of the merge class no Not used when searching, NULL when creating
c_timeout Seconds to wait for the locks. 0 = dont wait, -1 = wait endless. no -1
Returns
Map with informations about the operation:
Key Description
c_status Bps::OK Record found or created, and lock was successful.
Bps::Locked Record exists but it was already locked and stayed locked until timeout.
c_luid Key of the found or created record.

◆ finishOrderRow()

QVariantMap BpsOrderUtils::finishOrderRow ( const QVariantMap &  aParams)

Finish a order row.

There are 2 modes of operation:

  • Final delivery mode
    • All items are processed.
    • Not yet picked items are moved completely to the new trip when reordering. When not reordering they are shortened to 0 and a zero picking record is added.
    • Underdelivered items get shortened to the picked quantity. The missing quantity is reordered in the new trip in case.
  • Partial delivery mode
    • Only picked items are processed.
    • Not yet picked items are left untouched.
    • Underdelivered items get shortened to the picked quantity. The missing quantity is reordered in the same trip in case.
Parameters
aParamsThe parameters defining the finish action.
Key Description Mandatory Default
orderrows_key Key of the order row to process yes n.a.
orderpicks_delivery Delivery ID no Created from sequence s_deliveries
orderpicks_delivdate Delivery date no Current timestamp
mode 0=partial delivery, 1=final delivery no 0
underdelivery_tolerance Tolerance in percent (0...100) that the picked PU may be below the ordered quantity (which is 100%) without the being considered as underdelivered. no 0
new_trip Final delivery mode: Key of t_trips used for reordering. Partial delivery mode: Any non-null value will enable subsequent deliveries to the same trip. If not present no reordering happens. no n.a.
new_tripdate Date for new t_ordertrips in final delivery mode. If not present in final delivery mode, no reordering happens. no n.a.
new_articles List of article keys to be reordered. If not present, all articles are reordered. no n.a.
short_remarks Remarks for shortened items not getting reordered. no Leave remarks unchanged
orig_remarks Remarks for shortened items getting reordered. no Leave remarks unchanged
new_remarks Remarks for new article orders created for the reorders. no Remarks of original article order
Returns
Map with informations about the operation:
Key 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.

◆ finishPurchaseOrder()

bool BpsOrderUtils::finishPurchaseOrder ( const QVariant aOrderKey,
bool  aLock = false,
int  aTimeout = 0 
)

Finishes a purchase order having the status ready, active or completed, and not having any blocked deliveries.

The following tasks are performed:

  • Set order status to completed
  • Set all item status to completed
  • Deliveries not yet entered get arrival and entry by and date set, and quantities set to zero.
  • Items not having any deliveries get a zero delivery appended.
Parameters
aOrderKeyKey of the purchase order (t_purchaseorders.c_key)
aLockTrue = lock the order while processing. False = do not lock/unlock (because order was locked in advance).
aTimeoutLocking time out in seconds. Special values: 0 = no wait, -1 = wait endless.
Returns
True when operation successfully completed. False when not executable because aLock is true and order already locked, or order status not as required, or any blocked deliveries.
Exceptions
BpsExceptionon sql errors.

◆ getArticle()

QVariantMap BpsOrderUtils::getArticle ( const QVariant aArticleKey)

Get article record.

Subsequent queries of the same article are cached to minimize database access.

Parameters
aArticleKeyKey of the article.
Returns
The record.
Exceptions
BpsExceptionOn database errors or when record not found.

◆ getDefaultStockReasons()

QList<QPair<QString,QString> > BpsOrderUtils::getDefaultStockReasons ( )

Get the default stock reason types and names as a list.

The names are not the names of the actual stock reason in table t_stockreasons, but the default names used when automatically creating records missing in t_stockreasons.

Returns
Default name of the reason, empty string for SR_Unknown.

◆ getPackjob()

QVariantMap BpsOrderUtils::getPackjob ( const QVariant aPackjobKey)

Get packing job record.

Subsequent queries of the same packing job are cached to minimize database access.

Parameters
aPackjobKeyKey of the packing job.
Returns
The record.
Exceptions
BpsExceptionOn database errors or when record not found.

◆ getPartner()

QVariantMap BpsOrderUtils::getPartner ( const QVariant aPartnerKey)

Get partner record.

Subsequent queries of the same partner are cached to minimize database access.

Parameters
aPartnerKeyKey of the partner.
Returns
The record.
Exceptions
BpsExceptionOn database errors or when record not found.

◆ getProd()

QVariantMap BpsOrderUtils::getProd ( const QVariant aProdKey)

Get production record.

Subsequent queries of the same production are cached to minimize database access.

Parameters
aProdKeyKey of the production.
Returns
The record.
Exceptions
BpsExceptionOn database errors or when record not found.

◆ getSellPrices()

bool BpsOrderUtils::getSellPrices ( const QVariant aArticleKey,
const QDateTime aStart,
QVariant aDpr,
QVariant aCpr,
QVariant aCode 
)

Find the prices for a certain article and starting date/time.

Parameters
aArticleKeyThe key of the article.
aStartThe minimum starting date of the price to find.
aDprThe found dealer price as BpsDecimal. Invalid if not found.
aCprThe found consumer price as BpsDecimal. Invalid if not found.
aCodeThe found price code. 'n' if not found.
Returns
True if prices found, false if not found.

◆ getStockReason() [1/2]

QVariant BpsOrderUtils::getStockReason ( const QString aType)

Get the stock reason for a certain type from table t_stockreasons.

Returns the first reason if multiple exist, where the ordering is by id, name and key. Creates the stock reason with default values if it does not yet exist and aType is a known type. Typically this method is used to look up non-manual reasons.

Parameters
aTypeThe reason type (i+, p- etc) .
Returns
Key of the first found reason record.
Exceptions
BpsExceptionthrown if no such reason exists.

◆ getStockReason() [2/2]

QVariant BpsOrderUtils::getStockReason ( StockReasonIndex  aIndex)

Get the stock reason for a certain stock reason index from table t_stockreasons.

Returns the first reason if multiple exist, where the ordering is by id, name and key. Creates the stock reason with default values if it does not yet exist and aIndex is not SR_Unknown. Typically this method is used to look up non-manual reasons.

Parameters
aIndexThe reason index (for example SR_StockOK).
Returns
Key of the first found reason record.
Exceptions
BpsExceptionthrown if no such reason exists.

◆ getTrip()

QVariantMap BpsOrderUtils::getTrip ( const QVariant aTripKey)

Get trip record.

Subsequent queries of the same trip are cached to minimize database access.

Parameters
aTripKeyKey of the trip.
Returns
The record.
Exceptions
BpsExceptionOn database errors or when record not found.

◆ getZone()

QVariantMap BpsOrderUtils::getZone ( const QVariant aZoneKey)

Get zone record.

Subsequent queries of the same zone are cached to minimize database access.

Parameters
aZoneKeyKey of the zone.
Returns
The record.
Exceptions
BpsExceptionOn database errors or when record not found.

◆ getZoneMergeclass()

bool BpsOrderUtils::getZoneMergeclass ( const QVariant aTripclassKey,
const QVariant aArticleclassKey,
const QVariant aPartnerclassKey,
QVariant aZoneKey,
QVariant aMergeclassKey 
)

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:

OrderTrip ClassArticle ClassPartner Class
1***
2**null
3*null*
4*nullnull
5null**
6null*null
7nullnull*
8nullnullnull
Parameters
aTripclassKeyThe key of the trip class.
aArticleclassKeyThe key of the article class.
aPartnerclassKeyThe key of the partner class.
aZoneKeyKey of the zone found.
aMergeclassKeyKey of the mergeclass found.
Returns
True if zone and mergeclass found, false if not found.

◆ isOrdercolLocked()

bool BpsOrderUtils::isOrdercolLocked ( const QVariant aKey)

Checks if the order column, the order trip, or any of the details belonging to the column are locked.

Parameters
aKeyThe primary key value (c_key) of the record in table t_ordercols.
Returns
True if any locks are present, false if not.

◆ isOrderitemLocked()

bool BpsOrderUtils::isOrderitemLocked ( const QVariant aKey)

Checks if the order detail or any parent record is locked.

Parameters
aKeyThe primary key value (c_key) of the record in table t_orderitems.
Returns
True if any locks are present, false if not.

◆ isOrderrowLocked()

bool BpsOrderUtils::isOrderrowLocked ( const QVariant aKey)

Checks if the order row, the order trip, the related columns or any of the details belonging to the row are locked.

Parameters
aKeyThe primary key value (c_key) of the record in table t_orderrows.
Returns
True if any locks are present, false if not.

◆ isOrdertripLocked()

bool BpsOrderUtils::isOrdertripLocked ( const QVariant aKey)

Checks if the order trip or any of the order rows, columns or details belonging to it are locked.

Parameters
aKeyThe primary key value (c_key) of the record in table t_ordertrips.
Returns
True if any locks are present, false if not.

◆ isPackjobLocked()

bool BpsOrderUtils::isPackjobLocked ( const QVariant aKey,
bool  aExclusive = true 
)

Checks if the packing job or the production it belongs to are locked.

Parameters
aKeyThe primary key value (c_key) of the record in table t_packjobs.
aExclusiveAllow other workers on the same job (check production only).
Returns
True if locked, false if not.

◆ isPackprodLocked()

bool BpsOrderUtils::isPackprodLocked ( const QVariant aKey)

Checks if the packing production or any of the jobs belonging to it are locked.

Parameters
aKeyThe primary key value (c_key) of the record in table t_packprods.
Returns
True if any locks are present, false if not.

◆ isPurchaseItemLocked()

bool BpsOrderUtils::isPurchaseItemLocked ( const QVariant aKey)

Checks if the purchase order item or the parent purchase order record is locked.

Parameters
aKeyThe primary key value (c_key) of the record in table t_purchaseitems.
Returns
True if any locks are present, false if not.

◆ isPurchaseOrderLocked()

bool BpsOrderUtils::isPurchaseOrderLocked ( const QVariant aKey)

Checks if the purchase order or any of the items belonging to the order are locked.

Parameters
aKeyThe primary key value (c_key) of the record in table t_purchaseorders.
Returns
True if any locks are present, false if not.

◆ lockLu()

Bps::Status BpsOrderUtils::lockLu ( const QVariant aKey,
int  aTimeout = 0 
)

Lock an logistic unit in table t_newlogisticunits.

Parameters
aKeyThe ID of the LU, which is the primary key value (c_key) in table t_newlogisticunits.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_newlogisticunits, or maybe deleted while waiting.
  • Bps::Locked If the LU is still locked after timeout.

◆ lockOrdercol()

Bps::Status BpsOrderUtils::lockOrdercol ( const QVariant aKey,
int  aTimeout = 0,
bool  aFullcheck = true 
)

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.

Parameters
aKeyThe primary key value (c_key) of the record in table t_ordercols.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
aFullcheckCheck for locks in related objects (ordertrip, orderrows, orderitems)
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_ordercols, or maybe deleted while waiting.
  • Bps::Locked If the order column is still locked after timeout.

◆ lockOrderitem()

Bps::Status BpsOrderUtils::lockOrderitem ( const QVariant aKey,
int  aTimeout = 0,
bool  aFullcheck = true 
)

Lock an order item.

This lock will only succeed when no other actor has locked the detail record.

Parameters
aKeyThe primary key value (c_key) of the record in table t_orderitems.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
aFullcheckCheck for locks in related objects (ordertrip, orderrows, ordercols)
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_orderitems, or maybe deleted while waiting.
  • Bps::Locked If the order item is still locked after timeout.

◆ lockOrderrow()

Bps::Status BpsOrderUtils::lockOrderrow ( const QVariant aKey,
int  aTimeout = 0,
bool  aFullcheck = true 
)

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.

Parameters
aKeyThe primary key value (c_key) of the record in table t_orderrows.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
aFullcheckCheck for locks in related objects (ordertrip, ordercols, orderitems)
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_orderrows, or maybe deleted while waiting.
  • Bps::Locked If the order row is still locked after timeout.

◆ lockOrdertrip()

Bps::Status BpsOrderUtils::lockOrdertrip ( const QVariant aKey,
int  aTimeout = 0,
bool  aFullcheck = true 
)

Lock an order trip.

This lock will only succeed when no other actor has locked the order trip or any of the order rows, columns and details belonging to the order trip.

Parameters
aKeyThe primary key value (c_key) of the record in table t_ordertrips.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
aFullcheckCheck for locks in related objects (orderrows, ordercols, orderitems)
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_ordertrips, or maybe deleted while waiting.
  • Bps::Locked If the order trip is still locked after timeout.

◆ lockPackjob()

Bps::Status BpsOrderUtils::lockPackjob ( const QVariant aKey,
bool  aExclusive = true,
int  aTimeout = 0,
bool  aFullcheck = true 
)

Lock a packing job.

This lock will only succeed when no other actor has locked the packing job or the production it belongs to.

Parameters
aKeyThe primary key value (c_key) of the record in table t_packjobs.
aExclusiveAllow other workers on the same job.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
aFullcheckCheck for lock in related packprod
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_packjobs, or maybe deleted while waiting.
  • Bps::Locked If the packing job is still locked after timeout.

◆ lockPackprod()

Bps::Status BpsOrderUtils::lockPackprod ( const QVariant aKey,
int  aTimeout = 0,
bool  aFullcheck = true 
)

Lock an packing production.

This lock will only succeed when no other actor has locked the packing production or any of the packing jobs belonging to it.

Parameters
aKeyThe primary key value (c_key) of the record in table t_packprods.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
aFullcheckCheck for locks in related packjobs
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_packprods, or maybe deleted while waiting.
  • Bps::Locked If the packing production is still locked after timeout.

◆ lockPurchaseItem()

Bps::Status BpsOrderUtils::lockPurchaseItem ( const QVariant aKey,
int  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.

Parameters
aKeyThe primary key value (c_key) of the record in table t_purchaseitems.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_purchaseitems, or maybe deleted while waiting.
  • Bps::Locked If the purchase item is still locked after timeout.

◆ lockPurchaseOrder()

Bps::Status BpsOrderUtils::lockPurchaseOrder ( const QVariant aKey,
int  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.

Parameters
aKeyThe primary key value (c_key) of the record in table t_purchaseorders.
aTimeoutTime out in seconds. Special values: 0 = no wait, -1 = wait endless
Returns
Bps::Status as:
  • Bps::OK if the lock was successful.
  • Bps::Notfound If record not found in t_purchaseorders, or maybe deleted while waiting.
  • Bps::Locked If the purchase order is still locked after timeout.

◆ makeErpOrders()

QVariantList BpsOrderUtils::makeErpOrders ( const QList< QVariantMap > &  aParams)

Create ERP orders in table t_erporders and t_erporderitems.

Parameters
aParamsA list of parameters defining the items.
Key Description Mandatory Default
c_date Delivery date yes n.a.
c_trip Key of trip in t_trips yes n.a.
c_partner Key of partner in t_partners yes n.a.
c_article Key of article in t_articles yes n.a.
c_quantity Number of units to order yes n.a.
c_prcd Price code no t_articleprices.c_code
c_ou Order unit no t_articles.c_ou
c_tu_lu Number of TU in one LU no t_articles.c_tu_lu
c_cu_tu Number of CU in one TU no t_articles.c_cu_tu
c_pu_cu PU quantity in one CU no t_articles.c_pu_cu
c_remarks Remarks to set (gets simplified and truncated to fit in t_erporderitems) no null
c_olditem Key of old order item in t_orderitems. Used for reordering (order type "r"). no Omit old order info
c_containers QStringList with GRAI codes in EPCIS format used when creating picks later after the ERP order is created. Used for customer order (order type "c") - provide an empty list to identify customer order without GRAI's. no No GRAI list = no customer order
Returns
Keys of the records created in t_erporders

◆ makeLu()

QVariant BpsOrderUtils::makeLu ( const QVariantMap &  aParams)

Create a new logistic unit.

The parameters of the new LU are saved in t_newlogisticunits, and the record is locked for the current actor.

Parameters
aParamsParameters for the new LU.
Key Description Mandatory Default
c_orderrow Key of the order row yes(*) n.a.
c_ordertrip Key of the order trip yes(*) null
c_partner Key of the partner yes if c_orderrow missing Take from order row
c_zone Key of the picking zone no NULL
c_mergeclass Key of the merge class no NULL

(*) Either t_orderrow, or c_ordertrip must be present and valid. If c_orderrow is present and valid, the inputs c_ordertrip and c_partner are ignored.

Returns
Key of the new LU.

◆ makeOrderItem()

QVariantMap BpsOrderUtils::makeOrderItem ( const QVariantMap &  aParams)

Creates a new order item.

Parameters
aParamsThe parameters defining the order item.
Key Description Mandatory Default
ordertrips_date Trip date yes n.a.
ordertrips_trip Trip key yes n.a.
orderrows_partner Partner key yes n.a.
orderrows_ordercd Order code no 'n'
orderrows_orderid Order row ID no null
orderrows_origin Origin system name no null
orderrows_originfo Origin system information data no null
orderrows_remarks Order row remarks no null
ordercols_article Article key yes n.a.
ordercols_dpr Dealer price (charged to partner) no t_articleprices.c_dpr
ordercols_cpr Consumer price (printed on goods) no t_articleprices.c_cpr
ordercols_prcd Price code no t_articleprices.c_code
ordercols_ou Ordered units no t_articles.c_stock_unit
ordercols_tu_lu Traded units per logistic unit no t_articles.c_tu_lu
ordercols_cu_tu Consumer units per traded unit no t_articles.c_cu_tu
ordercols_pu_cu Price units per ordered unit no t_articles.c_pu_cu
ordercols_selldays Number of selling days, counted from production/labeling date no t_articles.c_selldays
ordercols_expiredays Expires this number days after selling days no t_articles.c_expiredays
ordercols_remarks Order column remarks no null
orderitems_ordered Ordered quantity yes n.a.
orderitems_planned Planned quantity no Ordered quantity
orderitems_orderid Order item ID no null
orderitems_originfo Origin system information data no null
orderitems_zone Zone no t_pickmatrix.c_zone
orderitems_mergeclass Merge class no t_pickmatrix.c_mergeclass
orderitems_remarks Order item remarks no null
orderitems_readonly Order item is readonly in ordertrips app ('y', 'n') no 'n'
orderitems_robotsplit Perform robot splitting if applicable ('y', 'n') no 'y'
orderitems_existmode How to handle the case where a similar order item exists already:
'c'Create a new item anyway.
'u'Update the existing item with the new values. Leave existing picks alone.
'a'/'A'Add the new ordered and planned quantities. Leave the rest alone.
'd'/'D'If the the new ordered quantity is not equal, add/subtract the difference to/from both ordered and planned. Don't let c_planned go below 0. Leave the rest alone.
'p'/'P'If the delta of the new ordered quantity is positive, add it to both ordered and planned. Leave the rest alone.
'i'/'I'Ignore the new item data und leave the item completely alone.
'r'/'R'Reject the new item by throwing a BpsException.
Lower case (except 'c'): c_orderid and c_originfo must equal, and c_orderid must not be empty.
Upper case: c_orderid, c_originfo, c_zone, c_mergeclass, c_remarks, c_readonly must be equal.
no 'c'
Returns
Map with informations about the operation:
Key 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 last order item in table t_orderitems. Multiple items may have been created in case of robot splitting and newitem=true.
itemkeys Key of all order item in table t_orderitems. Multiple items may have been created in case of robot splitting and newitem=true.
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.
newitem True if new order item(s) was/were created, false if it already existed before.

◆ makeOrderPick()

QVariant BpsOrderUtils::makeOrderPick ( const QVariantMap &  aParams)

Make an order pick.

Parameters
aParamsThe parameters defining the pick action.
Key Description Mandatory Default
orderitems_key Order item key. yes n.a.
orderpicks_luid Logistic unit ID. no null
orderpicks_sscc SSCC of the shipped container. no null
orderpicks_grai GRAI of the picked container. no null
orderpicks_graicheck Check if GRAI has been recently used, and throw exception in case. Register as recently used if not used recently.
Only used when orderpicks_grai is given.
no "yes"
orderpicks_lotid Lot ID. no t_stock.c_lotid if stock_key given, NULL otherwise.
orderpicks_packline Packing line number. no null
orderpicks_lus # of logistic units picked. (integer) no null
orderpicks_tus # of traded units picked. (integer) no null
orderpicks_cus # of consumer units picked. (integer) no null
orderpicks_pus Quantity of price units picked. (floating point, precision 3) no calculated
orderpicks_tu_lu Traded units in one logistic unit picked. (integer)
May cause a stock splitting if it differs from t_stock.c_tu_lu.
no t_stock.c_tu_lu (t_ordercol.c_tu_lu when no stock)
orderpicks_cu_tu Consumer units in one traded unit picked. (integer).
May cause a stock splitting if it differs from t_stock.c_cu_tu.
no t_stock.c_cu_tu (t_ordercol.c_cu_tu when no stock)
orderpicks_pu_cu Nominal price units in one consumer unit picked. (integer).
May cause a stock splitting if it differs from t_stock.c_pu_cu.
no t_stock.c_pu_cu (t_ordercol.c_pu_cu when no stock)
stock_key The stock to take the picked amounts from.
If a value is given, the stock update will happen in the same transaction as the pick record gets created.
The parameter is taken as the key of the desired stock in table t_stock. The stock must have the status free and be for the same article as the order column.
If registration on the given stock is not possible because of factor mismatch (tu_lu, cu_tu), the function may search and use another free stock for the same article on the same stock location where the factors are matching. If finally no such stock is found, the function will create a new stock cloning the original stock, but with the factors of the pick (automatic stock splitting).
This parameter has precedence over stock_auto.
no null
stock_auto Automatically select a stock if this parameter is given as string "yes".
Only used when stock_key is not given.
An existing stock is searched as:
  • In the zone of the item
  • With status free
  • On a stock location with status open or drawing
Order the found stocks first by stock priority and second by stock location, then take the first stock.
If no such stock is found, the pick will be done without any stock operation.
no "no"
orderpicks_pickdate Pick timestamp (QDateTime) to set as t_orderpicks.c_pickdate no Current timestamp
orderpicks_pickby User key to set as t_orderpicks.c_pickby no Key of current user
Returns
The key of the new record as t_orderpicks.c_key

◆ makePackJob()

QVariantMap BpsOrderUtils::makePackJob ( const QVariantMap &  aParams)

Creates or updates a packing job.

Parameters
aParamsThe parameters defining the packing job.
Key Description Mandatory Default
packprods_date Date of the packing production yes n.a.
packprods_prod Production key yes n.a.
packjobs_article Article key yes n.a.
packjobs_quantity Quantity to pack yes n.a.
packjobs_packunit Packed units no t_articles.c_stock_unit
packjobs_tu_lu Traded units per logistic unit no t_articles.c_tu_lu
packjobs_cu_tu Consumer units per traded unit no t_articles.c_cu_tu
packjobs_pu_cu Price units per ordered unit no t_articles.c_pu_cu
packjobs_cpr Consumer price (printed on goods) no t_articleprices.c_cpr
packjobs_prcd Price code no t_articleprices.c_code
packjobs_selldays Number of selling days, counted from production/labeling date no t_articles.c_selldays
packjobs_expiredays Expires this number days after selling days no t_articles.c_expiredays
packjobs_remarks Order column remarks no null
packjobs_update "yes": If there already exists one or more matching jobs, but the sum quantity of the jobs is below packjobs_quantity, the quantity of the newest job is increased so the total quantity reaches packjobs_quantity. If no matching job exists, a new one is created with quantity = packjobs_quantity.
"no": A new job is created with quantity = packjobs_quantity, no matter if there already exists one or more matching jobs.
no "no"
lockmode 0: Do not lock existing packing production or job. 1: Lock existing packjob or packprod in not full mode (see lockPackjob/lockPackprod) 2: Lock existing packjob or packprod in full mode (see lockPackjob/lockPackprod) no 2
Returns
Map with informations about the operation:
Key Description
prodkey Key of the packing production in table t_packprods.
jobkey Key of the packing job in table t_packjobs.
newprod True if a new packing production was created, false if it already existed before.
newjob True if a new packing job was created, false if packjobs_update was "yes" and an existing packing job was found.
updatedjob True if the quantity of an existing packing job was updated.

◆ makePackRec()

QVariant BpsOrderUtils::makePackRec ( const QVariantMap &  aParams)

Make a packing record.

Stock registration happens according to the settings in Central System Settings/GuiConfig/Production/Putaway.

Parameters
aParamsThe parameters defining the pack action.
Key Description Mandatory Default
packjobs_key Packing job key. yes n.a.
packrecs_packline Packing line number. yes n.a.
packrecs_targetzone Key of the target zone where the packed quantities are stocked to. yes n.a.
packrecs_luid Logistic unit ID. no null
packrecs_grai GRAI of the packed container. no null
packrecs_lotid Lot ID. no null
packrecs_origin Origin key. no null
packrecs_producer Producer key. no null
packrecs_method Production method key. no null
packrecs_tu_lu Traded units in one logistic unit. (integer) no t_packjobs.c_tu_lu
packrecs_cu_tu Consumer units in one traded. (integer). no t_packjobs.c_cu_tu
packrecs_lus # of whole logistic units packed. (integer) no null
packrecs_tus # of whole traded units packed. (integer) no null
packrecs_cus # of whole consumer units packed. (integer) no null
packrecs_pus Total quantity of price units packed in all given LU's, TU's and CU's. (floating point, precision 3) no calculated
Returns
The key of the new record as t_packrecs.c_key

◆ makePurchaseDelivery()

QVariantMap BpsOrderUtils::makePurchaseDelivery ( const QVariantMap &  aParams)

Creates a new purchase order delivery.

  • In case the PU quantity is smaller/equal 0 or is NULL, or the purchase order is archived (c_status = h), no delivery is created.
Parameters
aParamsThe parameters defining the purchase order delivery:
Key Description Mandatory Default
purchaseitems_key Key of the purchase item. yes n.a.
purchasedeliveries_blocked Block state no false
purchasedeliveries_shipdate Shipping date/time no Arrival date/time
purchasedeliveries_deliverydate Estimated delivery date/time no t_purchaseorders.c_deliverydate
purchasedeliveries_deliveryid Delivery ID (to be found on the receipt) no NULL
purchasedeliveries_arrivaldate Arrival date/time no Entry date/time
purchasedeliveries_arrivalby Key of user processing the arrival no Current user if arrival date is not NULL, else NULL
purchasedeliveries_entrydate Entry date/time no NULL
purchasedeliveries_entryby Key of user processing the entry no >Current user if entry date is not null, else NULL
purchasedeliveries_targetzone The target zone to save stock changes to if entry date is not NULL. no Do not save stock changes
purchasedeliveries_carrier Name of final carrier or vehicle ID bringing the delivery no NULL
purchasedeliveries_sscc Comma separated list of SSCC's involved (usually one per hierarchical level) no NULL
purchasedeliveries_lotid Comma separated list of lot ID's no NULL
purchasedeliveries_tu_lu Factor TU/LU no t_purchaseitems.c_tu_lu
purchasedeliveries_cu_tu Factor CU/TU no t_purchaseitems.c_cu_tu
purchasedeliveries_lus # of whole logistic units no Open quantity or NULL (1)
purchasedeliveries_tus # of whole traded units not included in LU's above no Open quantity or NULL (1)
purchasedeliveries_cus # of whole consumer units not included in LU's or TU's above no Open quantity or NULL (1)
purchasedeliveries_pus Total quantity of price units in all LU's, TU's and CU's above no Calculated from LU's, TU's, CU's, TU/LU, CU/TU and t_purchaseitems.c_pu_cu
purchasedeliveries_deduction Deduction in price units (delivered, but not accepted PU's) no NULL
purchasedeliveries_retention Retention in percent no NULL
purchasedeliveries_remarks Delivery remarks no NULL
purchaseweighings List of weighing records to save (see table in makePurchaseEntry) no No weighings saved

(1) If none of LU's, TU's, CU's or PU's is given, then the open quantity of this item is used. The open quantity is calculated by subtracting all existing delivery quantities from the ordered or confirmed quantity respectively.

Returns
Map with informations about the operation:
Key Description
orderkey Key of the order in table t_purchaseorders.
itemkey Key of the item in table t_purchaseitems.
deliverykey Key of the new created delivery in table t_purchasedeliveries.
NULL if no delivery created because no quantities were given, and there is no more open quantity.
articlekey Key of the article as in table t_purchaseitems.
stockkey Key of the stock as in table t_purchasedeliveries.

◆ makePurchaseEntry()

QVariantMap BpsOrderUtils::makePurchaseEntry ( const QVariantMap &  aParams)

Registration of an entry on an existing purchase delivery.

  • Nothing is done when the purchase order is archived (c_status = h).
  • Existing old weighings and packages are deleted in advance.
  • Existing old stock registrations are subtracted in advance.
Parameters
aParamsThe parameters list:
Key Description Mandatory Default
purchasedeliveries_key Key of existing purchase delivery in t_purchasedeliveries. yes n.a.
purchasedeliveries_blocked Block state no false
purchasedeliveries_shipdate Shipping date/time no Unchanged if current value not NULL, arrival date/time otherwise
purchasedeliveries_deliverydate Estimated delivery date/time no Unchanged if current value not NULL, entry date/time otherwise
purchasedeliveries_deliveryid Delivery ID (to be found on the receipt) no Current value unchanged
purchasedeliveries_arrivaldate Arrival date/time no Unchanged if current value not NULL, entry date/time otherwise
purchasedeliveries_arrivalby Key of user processing the arrival no Unchanged if current value not NULL, entry user key otherwise
purchasedeliveries_entrydate Entry date/time no Current date/time
purchasedeliveries_entryby Key of user processing the entry no Current user
purchasedeliveries_targetzone The target zone to save stock changes to. no Do not save stock changes
purchasedeliveries_carrier Name of final carrier or vehicle ID bringing the delivery no Current value unchanged
purchasedeliveries_sscc Comma separated list of SSCC's involved (usually one per hierarchical level) no Current value unchanged
purchasedeliveries_lotid Comma separated list of lot ID's no Current value unchanged
purchaseitems_tu_lu Traded units per logistic unit no Current value unchanged
purchaseitems_cu_tu Consumer units per traded unit no Current value unchanged
purchasedeliveries_lus # of whole logistic units no 0 or leave unchanged (2)
purchasedeliveries_tus # of whole traded units not included in LU's no 0 or leave unchanged (2)
purchasedeliveries_cus # of whole consumer units not included in LU's or TU's no 0 or leave unchanged (2)
purchasedeliveries_pus Total quantity of price units in all LU's, TU's and CU's no 0 or leave unchanged (2)
purchasedeliveries_deduction Deduction in price units (delivered, but not accepted PU's) no Current value unchanged
purchasedeliveries_retention Retention in percent no Current value unchanged
purchasedeliveries_remarks Delivery remarks no Current value unchanged
purchaseweighings List of new weighing records to save (see next table) no No weighings saved

Weighing record:

Key Description Mandatory Default
purchaseweighings_timestamp Date/time of weighing yes n.a.
purchaseweighings_id ID info such as animal number, ear mark etc. no NULL
purchaseweighings_lus # of whole logistic units no NULL
purchaseweighings_tus # of whole traded units not included in LU's no NULL
purchaseweighings_cus # of whole consumer units not included in LU's or TU's no NULL
purchaseweighings_net Net weight in kg yes n.a.
purchaseweighings_tare Total tare in kg no NULL
purchaseweighings_deduction Deduction in percent of net weight no NULL
purchaseweighings_weighed False = Manual entry, True = Weight from scales no True
purchaseweighings_quality Quality codes and remarks no NULL
purchaseweighings_temp Comma separated list of temperatures measured no NULL
purchaseweighings_ph Comma separated list of pH values measured no NULL
purchasepackages List of packages in this weighing (see next table) no No packages

Package record:

Key Description Mandatory Default
purchasepackages_package Key of a package in table t_packages. yes n.a.
purchasepackages_quantity Integer number of packages. yes n.a.
  • (2) The current value is unchanged if no LU, TU, CU or PU quantity given, to confirm entry of the planned quantities. The value is set to NULL if any of the LU, TU, CU or PU quantities was given.
Returns
Map with informations about the operation:
Key Description
orderkey Key of the order in table t_purchaseorders.
itemkey Key of the item in table t_purchaseitems.
deliverykey Key of the delivery in table t_purchasedeliveries.
articlekey Key of the article as in table t_purchaseitems.
stockkey Key of the stock as in table t_purchasedeliveries.

◆ makePurchaseItem()

QVariantMap BpsOrderUtils::makePurchaseItem ( const QVariantMap &  aParams)

Creates a new purchase order item.

Parameters
aParamsThe parameters defining the purchase order item.
Key Description Mandatory Default
purchaseorders_zone Entry zone no t_articles.c_entryzone if not null, otherwise throw exception
purchaseorders_orderid Own order ID no null
purchaseorders_deliverydate Target delivery date/time yes n.a.
purchaseorders_seller Partner key of seller yes n.a.
purchaseorders_selleroid Order ID of seller no null
purchaseorders_sellerom Order mode for seller no 'n' (none)
purchaseorders_selleros Order status of seller no 'u' (unsent)
purchaseorders_sellerod Order date/time of seller no current timestamp when order status='s', null otherwise
purchaseorders_distributor Partner key of distributor no null
purchaseorders_distributoroid Order ID of distributor no null
purchaseorders_distributorom Order mode for distributor no 'n' (none)
purchaseorders_distributoros Order status of distributor no 'u' (unsent)
purchaseorders_distributorod Order date/time of distributor no current timestamp when order status='s', null otherwise
purchaseorders_remarks Order remarks no null
purchaseorders_origin Origin system name no null
purchaseorders_originfo Origin system order information data no null
purchaseitems_itemid Own item ID no null
purchaseitems_selleriid Item ID of seller no null
purchaseitems_distributoriid Item ID of distributor no null
purchaseitems_article Article key yes n.a.
purchaseitems_prcd Price code for consumer price labeling no t_articleprices.c_code
purchaseitems_cpr Consumer price for price labeling no t_articleprices.c_cpr
purchaseitems_bpr Buying price per price unit no null
purchaseitems_ordered Ordered quantity in OU yes n.a.
purchaseitems_confirmed Confirmed quantity in OU no null
purchaseitems_confirmdate Confirm date/time no current timestamp when confirmed not null, null otherwise
purchaseitems_ou Ordered units (L)U (T)U (C)U (P)U no t_articles.c_stock_unit
purchaseitems_pu Price unit (p)iece (k)g (l)iter (m)eter (s)quare meter (c)ubic meter no t_articles.c_pu
purchaseitems_tu_lu Traded units per logistic unit no t_articles.c_tu_lu
purchaseitems_cu_tu Consumer units per traded unit no t_articles.c_cu_tu
purchaseitems_pu_cu Price units per ordered unit no t_articles.c_pu_cu
purchaseitems_remarks Item remarks no null
purchaseitems_originfo Origin system item information data no null
Returns
Map with informations about the operation:
Key Description
orderkey Key of the new created order in table t_purchaseorders.
itemkey Key of the new created item in table t_purchaseitems.

◆ makeStock()

QVariant BpsOrderUtils::makeStock ( const QVariantMap &  aParams)

Create a new stock.

In case of virtual stocks, quantities are recalculated for best human readability: The stock is represented in the leading stock unit of the article as far as possible, e.g. higher units all set to 0, lower units will represent any rest smaller than one leading stock unit. Additionally, the quantities are normalized in respect of the sign, so there will either be only values>=0, or only values<=0.

In case of physical stock, the quantities will automatically break up higher units to eliminate any negative TU or CU value, unless the higher up units are of equal size (factor 1).

Parameters
aParamsThe parameters defining the stock action.
Key Description Mandatory Default
stock_reason The change reason, a key from t_stockreasons yes n.a.
stock_article The article key in t_articles yes n.a.
stock_location The stock location key in t_stocklocations yes n.a.
stock_prio Priority no t_stock validator value c_prio.default
stock_status Status no t_stock validator value c_status.default
stock_type Type no t_stock validator value c_type.default
stock_indate In date no NULL
stock_expdate Expire date no NULL
stock_cpr Consumer price no NULL
stock_lotid Lot ID no NULL
stock_lus Quantity for logical units no 0
stock_tus Quantity for traded units no 0
stock_cus Quantity for consumer units no 0
stock_tu_lu Factor tu/lu no Inherit from article
stock_cu_tu Factor cu/tu no Inherit from article
stock_pu_cu Factor pu/cu no Inherit from article
stock_remarks Remarks no None
Returns
Key of the new stock in table t_stock.

◆ orderGenMode()

OrderGenMode BpsOrderUtils::orderGenMode ( const QString aTripid)

Get the order generation mode for a given trip ID.

Parameters
aTripidThe id of the trip to check for erp exceptions. Empty string if not to be checked.
Returns
the order generation mode.

◆ orderUnitIndex()

static OuIndex BpsOrderUtils::orderUnitIndex ( const QVariant aOu)
static

Get the enumeration for a order unit code.

Parameters
aOuThe order unit code
Returns
The enumeration

◆ orderUnitName() [1/4]

static QString BpsOrderUtils::orderUnitName ( const QVariant aOu)
static

Get the human readable and translated order unit name (LU, TU, CU, PU) from a order unit code ("L", "T", "C", "P").

Note
It is common to use the English abbreviations LU, TU, CU and PU also in the other languages.
Parameters
aOuThe order unit code.
Returns
The human readable order unit name, or an empty string if none of "L", "T", "C", "P".

◆ orderUnitName() [2/4]

static QString BpsOrderUtils::orderUnitName ( const QVariant aOu,
const QVariant aPu 
)
static

Get the human readable and translated order unit name (LU, TU, CU, Piece, Kilo, Liter, Meter, M2, M3) from a order unit index and price unit index.

Parameters
aOuThe order unit code.
aPuThe price unit code, only used when aOu == "P".
Returns
The human readable order unit name, or an empty string if order unit is none of "L", "T", "C", "P".

◆ orderUnitName() [3/4]

static QString BpsOrderUtils::orderUnitName ( OuIndex  aOu)
static

Get the human readable and translated order unit name (LU, TU, CU, PU) from a order unit index (O_LU, O_TU, O_CU, O_PU).

Note
It is common to use the English abbreviations LU, TU, CU and PU also in the other languages.
Parameters
aOuThe order unit index.
Returns
The human readable order unit name, or an empty string for O_unknown.

◆ orderUnitName() [4/4]

static QString BpsOrderUtils::orderUnitName ( OuIndex  aOu,
PuIndex  aPu 
)
static

Get the human readable and translated order unit name (LU, TU, CU, Piece, Kilo, Liter, Meter, M2, M3) from a order unit index and price unit index.

Parameters
aOuThe order unit index.
aPuThe price unit index, only used if aOu == O_PU.
Returns
The human readable order unit name, or an empty string for O_unknown.

◆ priceUnitAbbreviation() [1/2]

static QString BpsOrderUtils::priceUnitAbbreviation ( const QVariant aPu)
static

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).

Parameters
aPuThe price unit code.
Returns
The price unit abbreviation.

◆ priceUnitAbbreviation() [2/2]

static QString BpsOrderUtils::priceUnitAbbreviation ( PuIndex  aPu)
static

Get the abbreviated, maximum 3 character price unit name (PCS, KG, L, M, M2, M3) from a price unit index (P_Piece, P_Kilo, P_Liter, P_Meter, P_SquareMeter, P_CubicMeter).

Parameters
aPuThe price unit index.
Returns
The price unit abbreviation.

◆ priceUnitIndex()

static PuIndex BpsOrderUtils::priceUnitIndex ( const QVariant aPu)
static

Get the enumeration for a price unit code.

Parameters
aPuThe price unit code
Returns
The enumeration

◆ priceUnitName() [1/2]

static QString BpsOrderUtils::priceUnitName ( const QVariant aPu)
static

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).

Parameters
aPuThe price unit code.
Returns
The human readable price unit name.

◆ priceUnitName() [2/2]

static QString BpsOrderUtils::priceUnitName ( PuIndex  aPu)
static

Get the human readable and translated price unit name (Piece, Kilo, Liter, Meter, M2, M3) from a price unit index (P_Piece, P_Kilo, P_Liter, P_Meter, P_SquareMeter, P_CubicMeter).

Parameters
aPuThe price unit index.
Returns
The human readable price unit name.

◆ refreshLu()

void BpsOrderUtils::refreshLu ( const QVariant aKey)

Refresh the timestamp of the logistic unit, in case it is locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_newlogisticunits.

◆ robot()

BpsRobot* BpsOrderUtils::robot ( const QVariant aZone) const

Get robot of a given zone.

Parameters
aZoneKey of the zone.
Returns
Pointer to the robot object, or 0 if no robot for the given zone.

◆ robots()

QList<BpsRobot*> BpsOrderUtils::robots ( ) const

Get a list of all active robot.

Returns
The list of active robots.

◆ saveZoneStock()

QVariant BpsOrderUtils::saveZoneStock ( const QVariantMap &  aParams)

Adds a quantity to an existing stock in the given zone, or creates a new stock in the zone when no existing stock was found.

VIRTUAL STOCKS

Virtual stocks are matched according to the leading stock unit of the article (t_articles.c_stock_unit). For example when the leading stock unit is TU, the factors CU/TU and PU/CU must match, but the factor TU/LU may differ.

Quantities are recalculated for best human readability: The stock is represented in the leading stock unit of the article as far as possible, e.g. higher units all set to 0, lower units will represent any rest smaller than one leading stock unit. Additionally, the quantities are normalized in respect of the sign, so there will either be only values>=0, or only values<=0.

PHYSICAL STOCKS

Physical stocks must match in all factors TU/LU, CU/TU and PU/CU.

Quantities will automatically break up higher units to eliminate any negative TU or CU value, unless the higher up units are of equal size (factor 1).

GENERAL MATCHING RULES (FOR BOTH, VIRTUAL AND PHYSICAL STOCKS)

  • The lot id must match when any of the following is true:
    • It is given in the parameters.
    • The existing stock has a lot id and the given quantity is positive.
    • The zone is a lot zone of the article.
  • The in date must match when any of the following is true:
    • It is given in the parameters.
    • The existing stock has an in date and the given quantity is positive.
    • The zone is a lot zone of the article.
    • The articles stock mode is FIFO (t_articles.c_stock_mode='f').
  • The expire date must match when any of the following is true:
    • It is given in the parameters.
    • The existing stock has an expire date and the given quantity is positive.
  • The consumer price must match when any of the following is true:
    • It is given in the parameters.
    • The existing stock has a consumer price and the given quantity is positive.

NEW STOCK CREATION

  • In case a new stock needs to be created, a stock location open for storage or withdraw respectively is searched in the given zone.
  • If there is another open stock location of the same article, the first such stock location is used.
  • If there in no open stock location of the same article, the first open stock location of the zone is used.
Parameters
aParamsThe parameters defining the stock operation.
Key Description Mandatory Default
stock_zone The zone key in t_zones yes n.a.
stock_article The article key in t_articles yes n.a.
stock_reason The (default) change reason. A key from t_stockreasons yes n.a.
stock_status Stock status to search and to use in case for new stock. no Search only free stocks. In case a new stock is created, use t_stock validator value c_status.default.
stock_prio Stock priority: used only when a new stock is created no t_stock validator value c_prio.default
stock_type Stock type: Used only when creating new stocks. no In case a new stock is created, t_stock validator value c_type.default
stock_indate In date no null
stock_expdate Expire date no null
stock_cpr Consumer price no null
stock_lotid Lot ID no null
stock_lus Quantity of logistic units no 0
stock_tus Quantity of traded units no 0
stock_cus Quantity of consumer units no 0
stock_tu_lu Factor TU/LU no Use factor of article
stock_cu_tu Factor CU/TU no Use factor of article
stock_pu_cu Factor PU/CU no Use factor of article
Returns
Key of the stock in table t_stock.

◆ setPurchaseDeliveryStock()

void BpsOrderUtils::setPurchaseDeliveryStock ( const QVariant aDeliveryKey,
const QVariant aStockKey = QVariant() 
)

Register stock of purchase delivery record.

If c_stock is not NULL or the purchase order is archived (c_status = h) nothing happens. If aStockKey and c_stock are NULL, a stock is searched and in case created as configures in Central System Settings/GuiConfig/Goods Entry/Putaway. The LU, TU and CU quantities are added to the stock and c_stock is set to the stock key.

Parameters
aDeliveryKeyKey of the delivery in table t_purchasedeliveries.
aStockKeyKey of the stock in table t_stock.

◆ setStock()

void BpsOrderUtils::setStock ( const QVariantMap &  aParams)

Set the absolute stock quantities and updates other fields on an existing stock.

In case of virtual stocks, quantities are recalculated for best human readability: The stock is represented in the leading stock unit of the article as far as possible, e.g. higher units all set to 0, lower units will represent any rest smaller than one leading stock unit. Additionally, the quantities are normalized in respect of the sign, so there will either be only values>=0, or only values<=0.

In case of physical stock, the quantities will automatically break up higher units to eliminate any negative TU or CU value, unless the higher up units are of equal size (factor 1).

Parameters
aParamsThe parameters defining the stock action.
Key Description Mandatory Default
stock_key The stock key in t_stock yes n.a.
stock_reason The (default) change reason. A key from t_stockreasons yes n.a.
stock_prio Stock priority no Keep old priority
stock_status New status no Keep old status
stock_type New type no Keep old type
stock_indate New in date no Keep old in date
stock_expdate New expire date no Keep old expire date
stock_cpr New consumer price no Keep old consumer price
stock_lotid New lot ID no Keep old lot ID
stock_lus New quantity for logical units no 0
stock_tus New quantity for traded units no 0
stock_cus New quantity for consumer units no 0
stock_tu_lu New factor tu/lu no Keep existing factor
stock_cu_tu New factor cu/tu no Keep existing factor
stock_pu_cu New factor pu/cu no Keep existing factor
stock_remarks New remarks no Keep existing remarks

◆ stockModeIndex()

static StockModeIndex BpsOrderUtils::stockModeIndex ( const QVariant aMode)
static

Get the enumeration for a stock mode code.

Parameters
aModeThe stock mode code (r, f, q)
Returns
The enumeration

◆ stockModeName() [1/2]

static QString BpsOrderUtils::stockModeName ( const QVariant aMode)
static

Get the human readable and translated stock mode name (Regular, FIFO, Quick) from a price unit code (r, f, q).

Parameters
aModeThe stock mode code.
Returns
The human readable stock mode name.

◆ stockModeName() [2/2]

static QString BpsOrderUtils::stockModeName ( StockModeIndex  aMode)
static

Get the human readable and translated stock mode name (Regular, FIFO, Quick) from a stock mode index (SM_Regular, SM_FIFO, SM_Quick).

Parameters
aModeThe stock mode index.
Returns
The human readable stock mode name.

◆ tripdateToString()

QString BpsOrderUtils::tripdateToString ( const QVariant 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.

Parameters
aTripdateThe date to convert.
Returns
The string representation.

◆ unlockLu()

void BpsOrderUtils::unlockLu ( const QVariant aKey)

Unlock the logistic unit, in case it is locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_newlogisticunits.

◆ unlockOrdercol()

void BpsOrderUtils::unlockOrdercol ( const QVariant aKey)

Unlock the order column, in case it was locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_ordercols.

◆ unlockOrderitem()

void BpsOrderUtils::unlockOrderitem ( const QVariant aKey)

Unlock the order item.

Parameters
aKeyThe primary key value (c_key) of the record in table t_orderitems.

◆ unlockOrderitems() [1/2]

void BpsOrderUtils::unlockOrderitems ( const QVariant aKID)

Unlock a list of order items held in table t_keyids.

See BpsDatastore::setKeys(const QVariantList& aKeys).

Parameters
aKIDID of the list of locked order item keys in table t_keys.

◆ unlockOrderitems() [2/2]

void BpsOrderUtils::unlockOrderitems ( const QVariantList &  aKeys)

Unlock a list of order items.

Parameters
aKeysThe list of primary key values (c_key) of the records in table t_orderitems.

◆ unlockOrderrow()

void BpsOrderUtils::unlockOrderrow ( const QVariant aKey)

Unlock the order row, in case it was locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_orderrows.

◆ unlockOrdertrip()

void BpsOrderUtils::unlockOrdertrip ( const QVariant aKey)

Unlock the order trip, in case it was locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_ordertrips.

◆ unlockPackjob()

void BpsOrderUtils::unlockPackjob ( const QVariant aKey)

Unlock the packing job, in case it was locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_packjobs.

◆ unlockPackprod()

void BpsOrderUtils::unlockPackprod ( const QVariant aKey)

Unlock the packing production, in case it was locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_packprods.

◆ unlockPurchaseItem()

void BpsOrderUtils::unlockPurchaseItem ( const QVariant aKey)

Unlock the purchase order item, in case it was locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_purchaseitems.

◆ unlockPurchaseOrder()

void BpsOrderUtils::unlockPurchaseOrder ( const QVariant aKey)

Unlock the purchase order, in case it was locked by the current actor.

Parameters
aKeyThe primary key value (c_key) of the record in table t_purchaseorders.

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