Class InventoryItem
- All Implemented Interfaces:
Displayable
,StringFiller
,HasId
,HasInventoryItem
- Direct Known Subclasses:
ServiceItem
,SubscriptionItem
- Author:
- Syam
-
Field Summary
Fields inherited from class com.storedobject.core.StoredObject
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
attachPO
(Transaction transaction, InventoryPO po) Attach the PO for this item.void
attachRO
(Transaction transaction, InventoryRO ro) Attach the RO for this item.static String[]
boolean
Check if this item came as a part of a bigger assembly when it was purchased.final boolean
canBin
(InventoryLocation location) Can this item be stored at the given location?protected boolean
canStore
(InventoryLocation location) Can this item be stored at the given location?void
changePartNumber
(Transaction transaction, InventoryItemType newPartNumber) void
Check whether the measurement unit of the given quantity compatible for this item or not.void
Check whether the measurement unit of the given quantity compatible for this item or not.static void
createGRN
(Transaction transaction, InventoryStore store, Date grnDate, int grnNumber, Date invoiceDate, String invoiceReference, Entity supplier) Create the GRN for this item.createGRN
(Transaction transaction, InventoryStore store, Date grnDate, int grnNumber, Date invoiceDate, String invoiceReference, Entity supplier, int grnType) Create the GRN for this item.static <T extends InventoryItem>
Tget
(Class<T> itemClass, String serialNumber, InventoryItemType partNumber) static <T extends InventoryItem>
Tget
(Class<T> itemClass, String serialNumber, InventoryItemType partNumber, boolean any) static <T extends InventoryItem>
InventoryItemget
(String serialNumber, InventoryItemType partNumber) static InventoryItem
final int
Get the assembly level of this item.static <T extends InventoryItem>
TgetByPartNumber
(Class<T> itemClass, String serialNumber, String partNumber) static <T extends InventoryItem>
TgetByPartNumber
(Class<T> itemClass, String serialNumber, String partNumber, boolean any) static <T extends InventoryItem>
TgetByPartNumberId
(Class<T> itemClass, String serialNumber, Id partNumber) static InventoryItem
getByPartNumberId
(String serialNumber, Id partNumber) getCost()
Get the grandparent item on which this item is fitted on.final InventoryGRN
getGRN()
final Id
getGRNId()
boolean
getItem()
Retrieves the inventory item associated with this entity.final Class
<? extends InventoryItemType> Get the name of the current location for display purposes.getOwner()
Get the parent item on which this item is fitted on.<I extends InventoryItem>
IgetParentItem
(Class<I> itemClass) Get the parent/grandparents item on which this item is fitted on.final String
final String
final Class
<? extends InventoryItemType> final InventoryPO
getPO()
Get the PO through which this item was procured.final InventoryLocation
final InventoryLocation
getPreviousLocation
(int stepsBackward) Retrieves the quantity of the inventory item associated with this entity.Get the real location of this item.final InventoryRO
getRO()
Get the RO through which this item was repaired.Get the serial number for display purposes.final String
final String
Get the shelf-life of this item.Get that description of the status of this item (serviceability, storage condition etc.)getStore()
getUnitCost
(boolean guessIfZero) getUnitCost
(MeasurementUnit unit) static void
boolean
Check for vacant fitment positions under this item.boolean
isAvailableAt
(InventoryLocation location) Is this item available at the given location?boolean
Is this a "blocked" serial?final boolean
Is this a consumable item?final boolean
Is this an expendable item?boolean
Is this an obsolete part number?boolean
Is this a repairable item?final boolean
Is this a repairable item?final boolean
Is this a serialized item?boolean
Whether this item is serviceable or not.final boolean
Is shelf-life applicable?final boolean
isTool()
Is this item a tool?static <T extends InventoryItem>
ObjectIterator<T> list
(Class<T> itemClass, String serialNumber, InventoryItemType partNumber) static <T extends InventoryItem>
ObjectIterator<T> list
(Class<T> itemClass, String serialNumber, InventoryItemType partNumber, boolean any) final ObjectIterator
<InventoryItem> List of assembly items under this item.final <O extends InventoryItem>
ObjectIterator<O> listAssemblies
(Class<O> itemClass) List of assembly items under this item.final <O extends InventoryItem>
ObjectIterator<O> listAssemblies
(Class<O> itemClass, Predicate<O> filter) List of assembly items under this item.final ObjectIterator
<InventoryItem> listAssemblies
(Predicate<InventoryItem> filter) List of assembly items under this item.List of all fitment positions (includes full tree) under this item.List the fitment positions under this item.static ObjectIterator
<InventoryItem> listItems
(InventoryItemType partNumber) List all the items for the given part number.static ObjectIterator
<InventoryItem> listItems
(InventoryItemType partNumber, boolean includeZeros) List all the items for the given part number.static ObjectIterator
<InventoryItem> listItems
(InventoryItemType partNumber, String condition) List all the items for the given part number.static ObjectIterator
<InventoryItem> listItems
(InventoryItemType partNumber, String condition, boolean includeZeros) List all the items for the given part number.List the assembly positions where items are missing.static ObjectIterator
<InventoryItem> listStock
(InventoryItemType partNumber, String serialNumber) List stock for a given part number.static ObjectIterator
<InventoryItem> listStock
(String partNumber, InventoryLocation location) List stock for a given part number and location.static ObjectIterator
<InventoryItem> listStock
(String partNumber, InventoryStore store) List stock for a given part number and store.static ObjectIterator
<InventoryItem> List stock for a given part number.static ObjectIterator
<InventoryItem> listStock
(String partNumber, String serialNumber, InventoryLocation location) List stock for a given part number and location.static ObjectIterator
<InventoryItem> listStock
(String partNumber, String serialNumber, InventoryStore store) List stock for a given part number and store.static <T extends InventoryItemType>
ObjectIterator<InventoryItem> listStock
(T partNumber) List stock for a given part number and store.static <T extends InventoryItemType>
ObjectIterator<InventoryItem> listStock
(T partNumber, InventoryLocation location) List stock for a given part number and location.static <T extends InventoryItemType>
ObjectIterator<InventoryItem> listStock
(T partNumber, InventoryStore store) List stock for a given part number and store.static <T extends InventoryItemType>
ObjectIterator<InventoryItem> listStock
(T partNumber, String serialNumber, InventoryLocation location) List stock for a given part number and location.static <T extends InventoryItemType>
ObjectIterator<InventoryItem> listStock
(T partNumber, String serialNumber, InventoryStore store) List stock for a given part number and store.void
migrate
(TransactionManager tm, InventoryItemType migratedType, Function<InventoryItem, InventoryItem> itemConvertor) Migrate this item to another type.void
migrate
(TransactionManager tm, StoredObject migratedInstance) Migrate this instance to another class instance.void
moved
(InventoryLocation from, InventoryLocation to) This will be invoked whenever this item is moved from one location to another.static String[]
void
reloaded()
This method is invoked whenever this instance is reloaded from the database.void
resurrect
(Money cost, InventoryLocation location) Resurrect an item so that the same P/N and S/N can be used again.static String[]
void
setBatchTag
(String batchTag) void
void
void
void
setGRN
(InventoryGRN grn) void
setGRN
(BigDecimal idValue) void
setInTransit
(boolean inTransit) void
setLocation
(Id locationId) void
setLocation
(InventoryLocation location) void
setLocation
(BigDecimal idValue) void
void
void
setOwner
(BigDecimal idValue) void
setPartNumber
(Id partNumberId) void
setPartNumber
(InventoryItemType partNumber) void
setPartNumber
(BigDecimal idValue) void
setPurchaseDate
(Date purchaseDate) void
setQuantity
(Quantity quantity) void
setQuantity
(Object value) void
setSerialNumber
(String serialNumber) void
void
setStore
(InventoryStore store) void
setStore
(BigDecimal idValue) Display representation of the instance used for human-friendly display.toString()
String representation of the instance.boolean
updateCost
(TransactionManager tm, Money newCost, boolean updateAll) Update the cost of this item.void
validate()
This method is invoked internally by the system whenever the object gets saved to the DB (that means, while doing transactions).void
This will be invoked by the system whenever the object is saved to the DB.void
This method will be invoked whenever an existing instance is deleted from the database.void
This method will be invoked whenever an existing instance is updated in the database.boolean
Whether this item was data-picked or not.boolean
wasDataPicked
(int stepsBackward) Whether this item was data-picked or not.Methods inherited from class com.storedobject.core.StoredObject
addLink, addLink, addLink, addLink, addLink, addLink, addLink, addLink, checkCurrency, checkCurrency, checkForDuplicate, checkForDuplicate, checkTimeZone, checkTransaction, clearObjectLinks, contemporary, copy, copy, count, count, count, count, count, count, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, create, created, delete, delete, delete, deleted, directUpdate, equals, exists, exists, exists, exists, exists, existsFileData, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsMaster, existsMaster, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, family, family, family, fill, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getAttachment, getAttachmentId, getChildren, getDeleted, getDeleted, getExistsCondition, getExistsCondition, getFileData, getFileData, getHistorical, getId, getKeyIndex, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getNotExistsCondition, getNotExistsCondition, getParent, getParent, getParent, getParentId, getParentId, getParentId, getRelated, getRelated, getTransaction, getTransactionId, getTransactionIP, getUnique, getUniqueCondition, hashCode, inserted, isModified, isVirtual, list, list, list, list, list, list, list, list, list, list, list, list, list, listFileData, listFileData, listHistory, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listTree, listTree, listTree, listTree, listViaQuery, listViaQuery, load, load, load, load, loaded, loading, makeNew, makeVirtual, moduleName, nextVersion, objectLink, objectLink, objectLink, objectLinks, objectLinks, old, person, previousVersion, previousVersion, query, query, query, query, query, query, query, query, query, query, query, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, reload, reload, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeReverseLinks, removeReverseLinks, save, save, save, save, save, save, save, save, save, save, save, save, save, save, saved, saving, setMaster, setRawValue, setTransaction, stringify, tableName, timestamp, toCode, transacting, undelete, undelete, undeleted, updated, user, userId, validateChildAttach, validateChildDetach, validateChildUpdate, validateInsert, validateParentAttach, validateParentDetach, validateParentUpdate, validateUndelete, valueEquals
-
Constructor Details
-
InventoryItem
public InventoryItem()
-
-
Method Details
-
columns
-
indices
-
protectedColumns
-
searchColumns
-
browseColumns
-
setPartNumber
-
setPartNumber
-
setPartNumber
-
getPartNumberId
-
getPartNumber
-
setSerialNumber
-
getSerialNumber
-
getSerialNumberDisplay
Get the serial number for display purposes.- Returns:
- By default, the
serialNumber
value is returned with appropriate name prefix. But, it can be overridden to display other details.
-
setBatchTag
-
getBatchTag
-
setStore
-
setStore
-
setStore
-
getStoreId
-
getStore
-
setLocation
-
setLocation
-
setLocation
-
getLocationId
-
getLocation
-
getLocationDisplay
Get the name of the current location for display purposes.- Returns:
- By default, this method returns the
toDisplay()
string of the location returned by thegetLocation()
method. But, this could be overridden to provide other information.
-
getRealLocation
Get the real location of this item. (If the item is on an assembly, then, its grandparent's location is returned).- Returns:
- Real location of this item.
-
isAvailableAt
Is this item available at the given location?- Parameters:
location
- Location to check.- Returns:
- True if the item is currently available at the same location or in the same store.
-
setQuantity
-
setQuantity
-
getItem
Description copied from interface:HasInventoryItem
Retrieves the inventory item associated with this entity.- Specified by:
getItem
in interfaceHasInventoryItem
- Returns:
- the associated InventoryItem instance
-
getQuantity
Description copied from interface:HasInventoryItem
Retrieves the quantity of the inventory item associated with this entity.- Specified by:
getQuantity
in interfaceHasInventoryItem
- Returns:
- the quantity of the associated inventory item
-
setCost
-
setCost
-
getCost
-
getUnitCost
-
getUnitCost
-
getUnitCost
-
getCost
-
updateCost
Update the cost of this item.- Parameters:
tm
- Transaction manager.newCost
- New cost.updateAll
- Update all items or not (applicable for serialized items only).- Throws:
Exception
- if error occurs while updating.
-
setInTransit
public void setInTransit(boolean inTransit) -
getInTransit
public boolean getInTransit() -
setOwner
-
setOwner
-
setOwner
-
getOwnerId
-
getOwner
-
setPurchaseDate
-
getPurchaseDate
-
setGRN
-
setGRN
-
setGRN
-
getGRNId
-
getGRN
-
reloaded
public void reloaded()Description copied from class:StoredObject
This method is invoked whenever this instance is reloaded from the database.- Overrides:
reloaded
in classStoredObject
-
moved
This will be invoked whenever this item is moved from one location to another. This is called from within the transaction. So,StoredObject.getTransaction()
can be used tp get the current transaction.- Parameters:
from
- Location from.to
- Location to.- Throws:
Exception
- An exception may be raised if the move is not legal.
-
validateData
Description copied from class:StoredObject
This will be invoked by the system whenever the object is saved to the DB. It will be invoked in all cases, while creating new objects and updating/deleting/un-deleting existing objects. If any exception is raised by this method, the process of saving to the DB will be abandoned.
Note: This method is mainly used to validate the data of all attributes of the object, and it may be used by others for validating the object. For example, front-end data-entry systems can use this method for validating the object.
- Overrides:
validateData
in classStoredObject
- Parameters:
tm
- Current transaction manager.- Throws:
Exception
- If data is invalid.
-
validate
Description copied from class:StoredObject
This method is invoked internally by the system whenever the object gets saved to the DB (that means, while doing transactions). It will be invoked in all cases (while creating new objects and updating/deleting/un-deleting existing objects). If this method raises any exceptions, the process of saving to the DB will be abandoned.
This method is not usually used for validating data (For that purpose,
StoredObject.validateData(TransactionManager)
is recommended). It is mainly used for validating state of the object. Methods such asStoredObject.created()
,StoredObject.updated()
,StoredObject.deleted()
,StoredObject.undeleted()
etc. are used to check the specific states but overridden methods may check for other "application-specific"/"business-specific" states.This method is invoked only after one of the other operation-specific validate method is invoked depending on the save operation -
StoredObject.validateInsert()
,StoredObject.validateUpdate()
,StoredObject.validateDelete()
,StoredObject.validateUndelete()
.Note: When overridden "super" should be called, otherwise, a "design error" will occur.
- Overrides:
validate
in classStoredObject
- Throws:
Exception
- By raising an exception from this method the current transaction can be abandoned.
-
validateUpdate
Description copied from class:StoredObject
This method will be invoked whenever an existing instance is updated in the database. So, it will be called within an active transaction. Child classes can override this method to do validation when an existing instance is updated in the database.Note: When overridden "super" should be called, otherwise, a "design error" will occur.
Also, see
StoredObject.validate()
.- Overrides:
validateUpdate
in classStoredObject
- Throws:
Exception
- By raising an exception from this method the current transaction can be abandoned.
-
validateDelete
Description copied from class:StoredObject
This method will be invoked whenever an existing instance is deleted from the database. So, it will be called within an active transaction. Child classes can override this method to do validation when an existing instance is deleted from the database.Note: When overridden "super" should be called, otherwise, a "design error" will occur.
Also, see
StoredObject.validate()
.- Overrides:
validateDelete
in classStoredObject
- Throws:
Exception
- By raising an exception from this method the current transaction can be abandoned.
-
get
-
get
public static <T extends InventoryItem> InventoryItem get(String serialNumber, InventoryItemType partNumber) -
getByPartNumberId
-
getByPartNumber
public static <T extends InventoryItem> T getByPartNumber(Class<T> itemClass, String serialNumber, String partNumber) -
get
public static <T extends InventoryItem> T get(Class<T> itemClass, String serialNumber, InventoryItemType partNumber) -
getByPartNumber
public static <T extends InventoryItem> T getByPartNumber(Class<T> itemClass, String serialNumber, String partNumber, boolean any) -
get
public static <T extends InventoryItem> T get(Class<T> itemClass, String serialNumber, InventoryItemType partNumber, boolean any) -
getByPartNumberId
public static <T extends InventoryItem> T getByPartNumberId(Class<T> itemClass, String serialNumber, Id partNumber) -
list
public static <T extends InventoryItem> ObjectIterator<T> list(Class<T> itemClass, String serialNumber, InventoryItemType partNumber) -
list
public static <T extends InventoryItem> ObjectIterator<T> list(Class<T> itemClass, String serialNumber, InventoryItemType partNumber, boolean any) -
canBin
Can this item be stored at the given location?Note: This is the method to be used to check if the item can be binned at a specific location or not. The other method
canStore(InventoryLocation)
may be overridden by inherited classes and may skip fundamental checks.- Parameters:
location
- Location.- Returns:
- True or false.
-
canStore
Can this item be stored at the given location?- Parameters:
location
- Location.- Returns:
- True or false.
-
isServiceable
public boolean isServiceable()Whether this item is serviceable or not. If the item is not serviceable, it will not be selected for issuing against any requests. It can still be transferred to other locations.- Returns:
- Default is true. However, a subclass may return false depending on other attribute values.
-
isBlocked
public boolean isBlocked()Is this a "blocked" serial? One or more serial numbers (or a sequence of serial numbers) may be blocked and should not be used any more due to safety reasons. The default implementation of this method checks whether the P/N is blocked or not. If this method is overridden, it must call the super so that the default implementation is still applied.- Returns:
- True or false.
-
isObsolete
public boolean isObsolete()Is this an obsolete part number? If marked as obsolete, it will not be ordered again via purchase orders. The default implementation of this method checks whether the P/N is obsolete or not. If this method is overridden, it must call the super so that the default implementation is still applied.- Returns:
- True or false.
-
isSerialized
public final boolean isSerialized()Is this a serialized item?
A serialized item has a unique serial number (mostly assigned by the manufacturer itself). The item is always tracked by the serial number in the system.
- Returns:
- True or false.
-
isExpendable
public final boolean isExpendable()Is this an expendable item?
Items (such as nut, bolt, rivet etc.) for which (1) no authorized repair procedure exists, and/or (2) the cost of repair would exceed cost of its replacement. Expendable items are usually considered to be consumed when issued and are not recorded as returnable inventory.
- Returns:
- True or false.
-
isConsumable
public final boolean isConsumable()Is this a consumable item?
A consumable item (or a consumable) is an item that is once used, can not be recovered. Once issued from stores, consumables gets incorporated into other items and loose their identity. An example of a consumable is paint.
- Returns:
- True or false.
-
isTool
public final boolean isTool()Is this item a tool?
A tool is always tracked when issued to a location other than another store.
- Returns:
- True or false.
-
isRepairable
public boolean isRepairable()Is this a repairable item?
Generally, serialized items are repairable but this method can return
false
if a serialized item is not repairable. If this method returnstrue
for non-serialized items, it will be ignored by theisRepairAllowed()
method.- Returns:
- True or false.
-
isRepairAllowed
public final boolean isRepairAllowed()Is this a repairable item?
This method is used to check whether an item is repairable or not. It makes sure that the item is a serialized items and its
isRepairable()
returnstrue
.- Returns:
- True or false.
-
getPartNumberType
-
getItemType
-
isShelfLifeApplicable
public final boolean isShelfLifeApplicable()Is shelf-life applicable?- Returns:
- True or false.
-
getShelfLife
Get the shelf-life of this item.- Returns:
- Date of expiry if shelf-life is applicable, otherwise
null
.
-
checkUnit
Check whether the measurement unit of the given quantity compatible for this item or not.- Parameters:
quantity
- Quantity to check.name
- Name of the quantity (used to generate message of the exception).- Throws:
Invalid_State
- Throws if the measurement unit is not compatible.
-
checkUnit
Check whether the measurement unit of the given quantity compatible for this item or not.- Parameters:
quantity
- Quantity to check.- Throws:
Invalid_State
- Throws if the measurement unit is not compatible.
-
toString
Description copied from class:StoredObject
String representation of the instance. Mostly used for logging purposes.- Overrides:
toString
in classStoredObject
- Returns:
- String representation of the instance.
-
toDisplay
Description copied from class:StoredObject
Display representation of the instance used for human-friendly display.- Specified by:
toDisplay
in interfaceDisplayable
- Overrides:
toDisplay
in classStoredObject
- Returns:
- Display representation of the instance.
-
listStock
List stock for a given part number and store.- Parameters:
partNumber
- Part number.- Returns:
- List of items that are in the stock.
-
listStock
List stock for a given part number and store.- Parameters:
partNumber
- Part number.store
- Store.- Returns:
- List of items that are in the stock.
-
listStock
public static ObjectIterator<InventoryItem> listStock(String partNumber, String serialNumber, InventoryStore store) List stock for a given part number and store.- Parameters:
partNumber
- Part number.serialNumber
- Serial number.store
- Store.- Returns:
- List of items that are in the stock.
-
listStock
public static <T extends InventoryItemType> ObjectIterator<InventoryItem> listStock(T partNumber, InventoryStore store) List stock for a given part number and store.- Parameters:
partNumber
- Part number.store
- Store.- Returns:
- List of items that are in the stock.
-
listStock
public static <T extends InventoryItemType> ObjectIterator<InventoryItem> listStock(T partNumber, String serialNumber, InventoryStore store) List stock for a given part number and store.- Parameters:
partNumber
- Part number.serialNumber
- Serial number.store
- Store.- Returns:
- List of items that are in the stock.
-
listStock
public static ObjectIterator<InventoryItem> listStock(String partNumber, InventoryLocation location) List stock for a given part number and location.- Parameters:
partNumber
- Part number.location
- Location.- Returns:
- List of items that are in the stock.
-
listStock
public static ObjectIterator<InventoryItem> listStock(String partNumber, String serialNumber, InventoryLocation location) List stock for a given part number and location.- Parameters:
partNumber
- Part number.serialNumber
- Serial number.location
- Location.- Returns:
- List of items that are in the stock.
-
listStock
public static <T extends InventoryItemType> ObjectIterator<InventoryItem> listStock(T partNumber, InventoryLocation location) List stock for a given part number and location.- Parameters:
partNumber
- Part number.location
- Location.- Returns:
- List of items that are in the stock.
-
listStock
public static <T extends InventoryItemType> ObjectIterator<InventoryItem> listStock(T partNumber, String serialNumber, InventoryLocation location) List stock for a given part number and location.- Parameters:
partNumber
- Part number.serialNumber
- Serial number.location
- Location.- Returns:
- List of items that are in the stock.
-
listStock
List stock for a given part number.- Parameters:
partNumber
- Part number.serialNumber
- Serial number.- Returns:
- List of items that are in the stock.
-
listStock
public static ObjectIterator<InventoryItem> listStock(InventoryItemType partNumber, String serialNumber) List stock for a given part number.- Parameters:
partNumber
- Part number.serialNumber
- Serial number.- Returns:
- List of items that are in the stock.
-
listItems
List all the items for the given part number. It will return even the items fitted on assemblies, items sent for repair etc. However, items that are already scrapped/consumed will not be included.- Parameters:
partNumber
- Part number for which the list needs to be obtained.- Returns:
- List of items.
-
listItems
public static ObjectIterator<InventoryItem> listItems(InventoryItemType partNumber, String condition) List all the items for the given part number. It will return even the items fitted on assemblies, items sent for repair etc. However, items that are already scrapped/consumed will not be included.- Parameters:
partNumber
- Part number for which the list needs to be obtained.condition
- Additional condition if any. Could be null.- Returns:
- List of items.
-
listItems
public static ObjectIterator<InventoryItem> listItems(InventoryItemType partNumber, boolean includeZeros) List all the items for the given part number. It will return even the items fitted on assemblies, items sent for repair etc. However, items that are already scrapped/consumed will not be included.- Parameters:
partNumber
- Part number for which the list needs to be obtained.includeZeros
- Whether to include zero quantity items (in the case of non-serialized items) or not.- Returns:
- List of items.
-
listItems
public static ObjectIterator<InventoryItem> listItems(InventoryItemType partNumber, String condition, boolean includeZeros) List all the items for the given part number. It will return even the items fitted on assemblies, items sent for repair etc. However, items that are already scrapped/consumed will not be included.- Parameters:
partNumber
- Part number for which the list needs to be obtained.condition
- Additional condition if any. Could be null.includeZeros
- Whether to include zero quantity items (in the case of non-serialized items) or not.- Returns:
- List of items.
-
getGrandParentItem
Get the grandparent item on which this item is fitted on.- Returns:
- Grandparent item if exists.
-
getParentItem
Get the parent item on which this item is fitted on.- Returns:
- Parent item if exists.
-
getParentItem
Get the parent/grandparents item on which this item is fitted on.- Type Parameters:
I
- Type of parent class.- Parameters:
itemClass
- Type of parent/grandparent to look for.- Returns:
- Parent item if exists.
-
getPreviousLocation
-
getPreviousLocation
-
getPartNumberName
-
getPartNumberShortName
-
getSerialNumberName
-
getSerialNumberShortName
-
listFitmentPositions
List of all fitment positions (includes full tree) under this item.- Returns:
- Iterator containing all fitment positions.
-
listImmediateFitmentPositions
List the fitment positions under this item.- Returns:
- Iterator containing all fitment positions (not the children).
-
listAssemblies
List of assembly items under this item.- Type Parameters:
O
- Type of the item class.- Parameters:
itemClass
- Type of assemblies to be retrieved.- Returns:
- Iterator containing assembly items under this item.
-
listAssemblies
public final <O extends InventoryItem> ObjectIterator<O> listAssemblies(Class<O> itemClass, Predicate<O> filter) List of assembly items under this item.- Type Parameters:
O
- Type of the item class.- Parameters:
itemClass
- Type of assemblies to be retrieved.filter
- Filter to be applied.- Returns:
- Iterator containing assembly items under this item.
-
listAssemblies
List of assembly items under this item.- Returns:
- Iterator containing assembly items under this item.
-
listAssemblies
List of assembly items under this item.- Parameters:
filter
- Filter to be applied.- Returns:
- Iterator containing assembly items under this item.
-
isAssemblyIncomplete
public boolean isAssemblyIncomplete()Check for vacant fitment positions under this item. (Only mandatory assemblies are counted and accessories are not considered).- Returns:
- True/false.
-
listMissingAssemblies
List the assembly positions where items are missing.- Returns:
- Assembly positions where items are missing.
-
wasDataPicked
public boolean wasDataPicked()Whether this item was data-picked or not.- Returns:
- True/false.
-
wasDataPicked
public boolean wasDataPicked(int stepsBackward) Whether this item was data-picked or not.- Parameters:
stepsBackward
- Number of steps backward to go for checking.- Returns:
- True/false.
-
cameAsAssemblyPart
public boolean cameAsAssemblyPart()Check if this item came as a part of a bigger assembly when it was purchased. This will return true only if the item is still part of the assembly and not moved to anywhere else, including other fitment locations.- Returns:
- True/false.
-
getAssemblyLevel
public final int getAssemblyLevel()Get the assembly level of this item. If this item is fitted as part of an assembly, this method returns the level at which that exists from the top level assembly. If it is not fitted on any assembly, this method returns 0.- Returns:
- Assembly level.
-
getStatusDescription
Get that description of the status of this item (serviceability, storage condition etc.)- Returns:
- Status description.
-
getPO
Get the PO through which this item was procured. If this item was repaired by a repair organization later, this information will not be available anymore, and you should seegetRO()
.- Returns:
- PO if available.
-
getRO
Get the RO through which this item was repaired. If this item was repaired more than once, the latest RO is returned.- Returns:
- RO if available.
-
createGRN
public InventoryGRN createGRN(Transaction transaction, InventoryStore store, Date grnDate, int grnNumber, Date invoiceDate, String invoiceReference, Entity supplier, int grnType) throws Exception Create the GRN for this item. This method is used only for creating GRNs for the items that are data-picked.- Parameters:
transaction
- Transaction.store
- Store.grnDate
- GRN date (Receipt date)grnNumber
- GRN number (if zero is passed, a new number is generated).invoiceDate
- Invoice date.invoiceReference
- Invoice reference (supplier's invoice number).supplier
- Supplier.grnType
- GRN Type - 0:Purchase, 1:External Owner, 2:Loaned from, 3:Items Repaired by, 4:Sales Return- Returns:
- GRN
- Throws:
Exception
- if transaction errors occur.
-
createGRN
public InventoryGRN createGRN(Transaction transaction, InventoryStore store, Date grnDate, int grnNumber, Date invoiceDate, String invoiceReference, Entity supplier) throws Exception Create the GRN for this item. This method is used only for creating GRNs for the items that are data-picked.- Parameters:
transaction
- Transaction.store
- Store.grnDate
- GRN date (Receipt date)grnNumber
- GRN number (if zero is passed, a new number is generated).invoiceDate
- Invoice date.invoiceReference
- Invoice reference (supplier's invoice number).supplier
- Supplier.- Returns:
- GRN
- Throws:
Exception
- if transaction errors occur.
-
attachPO
Attach the PO for this item. This method is used only for creating POs for the items that are data-picked.- Parameters:
transaction
- Transaction.po
- PO to attach.- Throws:
Exception
- if transaction errors occur.
-
attachRO
Attach the RO for this item. This method is used only for creating ROs for the items that are data-picked.- Parameters:
transaction
- Transaction.ro
- RO to attach.- Throws:
Exception
- if transaction errors occur.
-
changePartNumber
public void changePartNumber(Transaction transaction, InventoryItemType newPartNumber) throws Exception - Throws:
Exception
-
migrate
Description copied from class:StoredObject
Migrate this instance to another class instance. Please note that there is no error checking or validations when this is invoked. This is used very rarely, and it may be useful for building low-level utilities.- Overrides:
migrate
in classStoredObject
- Parameters:
tm
- Transaction Manager.migratedInstance
- Migrated instance. Make sure that all the attribute values are properly set.- Throws:
Exception
- thrown for errors.
-
migrate
public void migrate(TransactionManager tm, InventoryItemType migratedType, Function<InventoryItem, InventoryItem> itemConvertor) throws ExceptionMigrate this item to another type.- Parameters:
tm
- Transaction Manager.migratedType
- Migrated item type.itemConvertor
- Item convertor.- Throws:
Exception
- thrown for errors.
-
resurrect
Resurrect an item so that the same P/N and S/N can be used again.- Parameters:
cost
- Cost.location
- New location.
-