Package com.storedobject.core
Class TaxMethod
java.lang.Object
com.storedobject.core.StoredObject
com.storedobject.core.Name
com.storedobject.core.TaxMethod
- All Implemented Interfaces:
Displayable,HasName,StringFiller,HasId
Represents a taxation method for financial calculations.
Provides functionality to calculate taxes based on specific
logic, manage active state, and implement data validation.
Caching is implemented to optimize retrieval by maintaining a static
map of cached
TaxMethod objects.- Author:
- Syam
-
Field Summary
Fields inherited from class com.storedobject.core.StoredObject
logger -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a TaxMethod object with a default tax calculation method name. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidConfigures columns for a data model by adding a column named "Active" with a type of "boolean".booleanRetrieves the active status of the tax method.static TaxMethodRetrieves a TaxMethod instance for the provided Id.getTax(InventoryItemType itemType, Quantity quantity, Money unitCost, Percentage taxRate, Currency localCurrency) Calculates the tax amount for a given inventory item based on its type, quantity, unit cost, tax rate, and local currency.static inthints()Provides hints for this object, indicating specific characteristics or optimizations associated with the object or its usage.static voidModifies the given indices object by adding a specific index with a specified condition.Rounds the given monetary amount to the nearest valid value based on the specific rounding rules defined.voidsaved()Removes the cached entry associated with this instance's Id after the object is saved.voidsetActive(boolean active) Sets the active status of the object.voidValidates the data associated with a TaxMethod instance.Methods inherited from class com.storedobject.core.Name
getName, getUniqueCondition, setName, toStringMethods 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, family, fill, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getActor, getAttachment, getAttachmentId, getChildren, getContemporaryOf, 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, hashCode, inserted, isModified, isVirtual, list, list, list, list, list, list, list, list, list, list, list, list, list, listDeletedIds, 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, loadAttributesFrom, loaded, loading, makeNew, makeVirtual, migrate, migrateLink, migrateLink, 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, reloaded, 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, save, saving, setMaster, setRawValue, setTransaction, stringify, tableName, timestamp, toCode, toDisplay, transacting, undelete, undelete, undeleted, updated, user, userId, validate, validateChildAttach, validateChildDetach, validateChildUpdate, validateDelete, validateInsert, validateParentAttach, validateParentDetach, validateParentUpdate, validateUndelete, validateUpdate, valueEquals
-
Constructor Details
-
TaxMethod
public TaxMethod()Constructs a TaxMethod object with a default tax calculation method name. The default name is set to "Percentage".
-
-
Method Details
-
columns
Configures columns for a data model by adding a column named "Active" with a type of "boolean".- Parameters:
columns- The columns object to which the "Active" column is added. Represents a set of definable columns in a database or data structure.
-
indices
Modifies the given indices object by adding a specific index with a specified condition.- Parameters:
indices- The object representing the collection of indices to be modified.
-
hints
public static int hints()Provides hints for this object, indicating specific characteristics or optimizations associated with the object or its usage.- Returns:
- A bitwise combination of constants from the
ObjectHintclass, such asObjectHint.SMALLandObjectHint.SMALL_LIST, representing the applicable hints.
-
setActive
public void setActive(boolean active) Sets the active status of the object.- Parameters:
active- a boolean value indicating whether the object should be active (true) or inactive (false)
-
getActive
-
saved
Removes the cached entry associated with this instance's Id after the object is saved. This method is invoked when the object state is persisted, ensuring the cache remains consistent with the underlying state.- Overrides:
savedin classStoredObject- Throws:
Exception- if an error occurs during the cache removal process.
-
validateData
Validates the data associated with a TaxMethod instance. This method ensures that the correct TaxMethod types exist and checks for possible duplicate entries, throwing exceptions in case of invalid or inconsistent states.- Overrides:
validateDatain className- Parameters:
tm- The transaction manager used to handle database transactions during validation.- Throws:
Exception- Thrown if validation encounters an invalid state, such as duplicate entries or missing required TaxMethod types.
-
getFor
Retrieves a TaxMethod instance for the provided Id. If the instance is not found in the cache, it fetches the instance, caches it, and then returns it.- Parameters:
id- the unique identifier of the TaxMethod to retrieve- Returns:
- the TaxMethod instance associated with the provided Id, or null if not found
-
getTax
public Money getTax(InventoryItemType itemType, Quantity quantity, Money unitCost, Percentage taxRate, Currency localCurrency) Calculates the tax amount for a given inventory item based on its type, quantity, unit cost, tax rate, and local currency.- Parameters:
itemType- the type of the inventory item for which the tax is being calculatedquantity- the quantity of the inventory itemunitCost- the cost per unit of the inventory itemtaxRate- the percentage tax rate to be appliedlocalCurrency- the currency in which the tax amount should be calculated- Returns:
- the calculated tax amount in the specified local currency
-
round
-