# Javascript overrides and extensions

Some commonly used Javascript functions can be replaced or extended to change their behavior. To do this, simply create a function that has the same name as the function to be modified with the addition of "\_override" or "\_extension" and the same parameters. The behavior of the two extensions is as follows:

<table border="1" id="bkmrk-funzione_override%28%29-" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 50%;">FUNCTION\_override()</td><td style="width: 50%;">If present, this function is called instead of the original one. The return value of this function is the return value.</td></tr><tr><td style="width: 50%;">FUNCTION\_extension()</td><td style="width: 50%;">If present, this function is called and if it returns **false** or a value equivalent to false, the original function ends by returning false, while if it returns **true** or an equivalent value, the execution continues in the original function.</td></tr></tbody></table>

The difference is that, in the first case the original function is completely ignored, while in the second, it is possible to decide whether to continue the standard execution or not. This is very convenient in the case of validation functions, usually very long, in which you simply want to add a control, without copying the entire function for small changes.  
The functions that support these extensions are as follows:

<table border="1" id="bkmrk-file-funzioni-includ" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 50%;">**File**</td><td style="width: 50%;">**Functions**</td></tr><tr><td style="width: 50%;">include/js/general.js</td><td style="width: 50%;">doformValidation  
startCall  
getFormValidate</td></tr><tr><td style="width: 50%;">include/js/Inventory.js</td><td style="width: 50%;"><span style="font-family: DejaVu Sans, Arial, sans-serif;">settotalnoofrows</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">deleteRow</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">calcTotal</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">calcProductTotal</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">calcGrandTotal</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">validateInventory</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">FindDuplicate</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">validateNewTaxType</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">validateTaxes</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">setDiscount</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">callTaxCalc  
</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">calcCurrentTax</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">calcGroupTax</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">calcSHTax</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">validateProductDiscounts</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">updatePrices</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">updatePriceValues</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">resetSHandAdjValues</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">moveUpDown</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">InventorySelectAll</span>

<span style="font-family: DejaVu Sans, Arial, sans-serif;">fnAddProductOrServiceRowNew</span>

</td></tr></tbody></table>