From cfdaeaad50aae02f10c7ea7b98889981f9d68598 Mon Sep 17 00:00:00 2001 From: Thilina Hasantha Date: Sun, 27 Dec 2015 05:03:40 +0530 Subject: [PATCH] Add salary module --- ext/admin/payroll/LICENSE.txt | 44 +++ ext/admin/payroll/api/PayrollAdminManager.php | 69 +++++ ext/admin/payroll/index.php | 17 ++ ext/admin/payroll/lib.js | 274 ++++++++++++++++++ ext/admin/payroll/meta.json | 11 + ext/modules/salary/meta.json | 2 +- 6 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 ext/admin/payroll/LICENSE.txt create mode 100644 ext/admin/payroll/api/PayrollAdminManager.php create mode 100644 ext/admin/payroll/index.php create mode 100644 ext/admin/payroll/lib.js create mode 100644 ext/admin/payroll/meta.json diff --git a/ext/admin/payroll/LICENSE.txt b/ext/admin/payroll/LICENSE.txt new file mode 100644 index 00000000..5fb38ea8 --- /dev/null +++ b/ext/admin/payroll/LICENSE.txt @@ -0,0 +1,44 @@ +ICEHRM END USER LICENSE AGREEMENT +NOTICE TO ALL USERS: BY PURCHASING THE MODULE, YOU (EITHER AN INDIVIDUAL OR A SINGLE ENTITY) CONSENT TO BE BOUND BY AND BECOME A PARTY TO THIS AGREEMENT. + +All references to "Software" herein shall be deemed to include the software license with which you will be provided by Gamonoid Media Pvt Ltd, as part of the Software. + +1. LICENSE GRANT. Subject to the payment of the applicable licence fees, and subject to the terms and conditions of this Agreement, ICEHRM hereby grants to you a non-exclusive, non-transferable right to use one copy of the specified version of the Software and the accompanying documentation (the "Documentation") for the term of this Agreement solely for your own internal business purposes. You may install one copy of the Software for production use. +. +2. USE. The Software is licensed as a single product; it may not be used on more than one ICEHRM Server at a time. The Software is "in use" on a Server when its installed on a Server. You shall not, nor permit any third party to copy (other than as expressly permitted herein). You shall not rent, lease or lend the Software to any other person, nor transfer or sub-licence your licence rights to any other person. + +3. TERM. This Agreement is effective until terminated as set forth herein. This Agreement will terminate automatically if you fail to comply with any of the conditions, limitations or other requirements described herein. Upon any termination of this Agreement, you must immediately destroy all copies of the Software and the Documentation. You may terminate this Agreement at any point by destroying all copies of the Software and the Documentation. + +4. SUPPORT. Gamonoid Media Pvt Ltd will provide you support according to the support agreement subscribed by the company. + +5. OWNERSHIP RIGHTS. The Software is protected by copyright laws. ICEHRM and Gamonoid Media Pvt Ltd own and retain all right, title and interest in and to the Software, including all copyrights, patents, trademarks and other intellectual property rights therein. Your possession, installation, or use of the Software does not transfer to you any title to the intellectual property in the Software, and you will not acquire any rights to the Software except as expressly set forth in this Agreement. + +6. LIMITED WARRANTY. You may not rent, lease, loan or resell the Software. You may not permit third parties to benefit from the use or functionality of the Software via a timesharing, service bureau or other arrangement, except to the extent such use is specified in the applicable list price or product packaging for the Software. You may not transfer any of the rights granted to you under this Agreement. You may not modify, or create derivative works based upon, the Software in whole or in part. You may not copy the Software or Documentation except as expressly permitted in Section 1 above. You may not remove any proprietary notices or labels on the Software. All rights not expressly set forth hereunder are reserved by ICEHRM. ICEHRM reserves the right to periodically conduct audits upon advance written notice to verify compliance with the terms of this Agreement. + +7. WARRANTY and DISCLAIMER. + +(i) Gamonoid Media Pvt Ltd. warrants that for 30 days from first download or installation the Software will perform substantially in accordance with the functionality described in the Documentation (http://blog.icehrm.com) when operated properly and in the manner specified in the Documentation. + +(ii) You accept all responsibility for the selection of this Software to meet your requirements. + +(iii) Gamonoid Media Pvt Ltd. does not warrant that the Software and/or the Documentation will be suitable for such requirements nor that any use will be uninterrupted and error free. + +(iv) The warranty in (i) shall not apply if you (a) make or cause to be made any modifications to this Software, (b) use the Software in a manner for which it was not intended or (c) use the Software other than as permitted under this Agreement. + +(vii) The warranties and conditions stated in this Agreement are in lieu of all other conditions, warranties or other terms concerning the supply or purported supply of, failure to supply or delay in supplying the Software or the Documentation which might but for this paragraph (vii) have effect between the ICEHRM and you or would otherwise be implied into or incorporated into this Agreement or any collateral contract, whether by statute, common law or otherwise, all of which are hereby excluded (including, without limitation, the implied conditions, warranties or other terms as to satisfactory quality, fitness for purpose or as to the use of reasonable skill and care). + +8. LIMITATION of LIABILITY. Gamonoid Media Pvt Ltd. shall have no liability (whether in contract, tort, restitution or otherwise) for any of the following losses or damage (whether such losses or damage were foreseen, foreseeable, known or otherwise): +- Loss of revenue; +- Loss of actual or anticipated profits (including for loss of profits on contracts); +- Loss of the use of money; +- Loss of anticipated savings; +- Loss of business; +- Loss of opportunity; +- Loss of goodwill; +- Loss of reputation; +- Loss of, damage to or corruption of data; +or +Any indirect or consequential loss or damage howsoever caused (including, for the avoidance of doubt, where such loss or damage is of the type specified in paragraph (ii), (a) to (ii), (i). +The ICEHRM liability (whether in contract, tort, restitution or otherwise) arising out of or in connection with the supply of the Software shall in no circumstances exceed a sum equal to the amount equally paid by you for the Software. +The construction and interpretation of this Agreement shall be governed in accordance with the laws of Sri Lanka. The parties hereby submit to the jurisdiction of the courts of Sri Lanka save that ICEHRM as claimant shall be entitled to initiate proceedings in any court of competent jurisdiction. +This Agreement contains the entire understanding of the parties with respect to the subject matter hereof and supersedes all and any prior understandings, undertakings and promises between you and ICEHRM, whether oral or in writing, which have been given or may be implied from anything written or said in negotiations between us or our representatives prior to this Agreement and all prior agreements between the parties relating to the matters aforesaid shall cease to have effect as from the Effective Date. \ No newline at end of file diff --git a/ext/admin/payroll/api/PayrollAdminManager.php b/ext/admin/payroll/api/PayrollAdminManager.php new file mode 100644 index 00000000..17e6b951 --- /dev/null +++ b/ext/admin/payroll/api/PayrollAdminManager.php @@ -0,0 +1,69 @@ +addModelClass('SalaryComponentType'); + $this->addModelClass('SalaryComponent'); + $this->addModelClass('Deduction'); + + } + + } +} + +if (!class_exists('SalaryComponentType')) { + class SalaryComponentType extends ICEHRM_Record { + var $_table = 'SalaryComponentType'; + + public function getAdminAccess(){ + return array("get","element","save","delete"); + } + + public function getUserAccess(){ + return array("get","element"); + } + } +} + +if (!class_exists('SalaryComponent')) { + class SalaryComponent extends ICEHRM_Record { + var $_table = 'SalaryComponent'; + + public function getAdminAccess(){ + return array("get","element","save","delete"); + } + + public function getUserAccess(){ + return array("get","element"); + } + } +} + +if (!class_exists('Deduction')) { + class Deduction extends ICEHRM_Record { + var $_table = 'Deductions'; + + public function getAdminAccess(){ + return array("get","element","save","delete"); + } + + public function getUserAccess(){ + return array("get","element"); + } + } +} + + diff --git a/ext/admin/payroll/index.php b/ext/admin/payroll/index.php new file mode 100644 index 00000000..f342a7af --- /dev/null +++ b/ext/admin/payroll/index.php @@ -0,0 +1,17 @@ +addModuleOrGroup(new ModuleTab('SalaryComponentType','SalaryComponentType','Salary Component Types','SalaryComponentTypeAdapter','','',true)); +$moduleBuilder->addModuleOrGroup(new ModuleTab('SalaryComponent','SalaryComponent','Salary Components','SalaryComponentAdapter','','')); +$moduleBuilder->addModuleOrGroup(new ModuleTab('EmployeeSalary','EmployeeSalary','Employee Salary','EmployeeSalaryAdapter','','',false,array("setRemoteTable"=>"true"))); + + +echo UIManager::getInstance()->renderModule($moduleBuilder); + +include APP_BASE_PATH.'footer.php'; \ No newline at end of file diff --git a/ext/admin/payroll/lib.js b/ext/admin/payroll/lib.js new file mode 100644 index 00000000..97a5eb85 --- /dev/null +++ b/ext/admin/payroll/lib.js @@ -0,0 +1,274 @@ +/** + * Author: Thilina Hasantha + */ + + +/** + * SalaryComponentTypeAdapter + */ + +function SalaryComponentTypeAdapter(endPoint,tab,filter,orderBy) { + this.initAdapter(endPoint,tab,filter,orderBy); +} + +SalaryComponentTypeAdapter.inherits(AdapterBase); + + + +SalaryComponentTypeAdapter.method('getDataMapping', function() { + return [ + "id", + "code", + "name" + ]; +}); + +SalaryComponentTypeAdapter.method('getHeaders', function() { + return [ + { "sTitle": "ID" ,"bVisible":false}, + { "sTitle": "Code" }, + { "sTitle": "Name"} + ]; +}); + +SalaryComponentTypeAdapter.method('getFormFields', function() { + return [ + [ "id", {"label":"ID","type":"hidden"}], + [ "code", {"label":"Code","type":"text","validation":""}], + [ "name", {"label":"Name","type":"text","validation":""}] + ]; +}); + + +/** + * SalaryComponentAdapter + */ + +function SalaryComponentAdapter(endPoint,tab,filter,orderBy) { + this.initAdapter(endPoint,tab,filter,orderBy); +} + +SalaryComponentAdapter.inherits(AdapterBase); + + + +SalaryComponentAdapter.method('getDataMapping', function() { + return [ + "id", + "name", + "componentType", + "details" + ]; +}); + +SalaryComponentAdapter.method('getHeaders', function() { + return [ + { "sTitle": "ID" ,"bVisible":false}, + { "sTitle": "Name" }, + { "sTitle": "Salary Component Type" }, + { "sTitle": "Details"} + ]; +}); + +SalaryComponentAdapter.method('getFormFields', function() { + return [ + [ "id", {"label":"ID","type":"hidden"}], + [ "name", {"label":"Name","type":"text","validation":""}], + [ "componentType", {"label":"Salary Component Type","type":"select2","remote-source":["SalaryComponentType","id","name"]}], + [ "details", {"label":"Details","type":"textarea","validation":"none"}] + ]; +}); + + +/** + * DeductionAdapter + */ + +function DeductionAdapter(endPoint,tab,filter,orderBy) { + this.initAdapter(endPoint,tab,filter,orderBy); +} + +DeductionAdapter.inherits(AdapterBase); + + + +DeductionAdapter.method('getDataMapping', function() { + return [ + "id", + "name", + "contributor", + "type", + ]; +}); + +DeductionAdapter.method('getHeaders', function() { + return [ + { "sTitle": "ID" ,"bVisible":false}, + { "sTitle": "Name" }, + { "sTitle": "Contributor"}, + { "sTitle": "Deduction Type"} + ]; +}); + +DeductionAdapter.method('getFormFields', function() { + + var rangeAmounts = [ "rangeAmounts", {"label":"Deduction Amounts","type":"datagroup", + "form":[ + [ "lowerCondition", {"label":"Lower Limit Condition","type":"select","source":[["No Lower Limit","No Lower Limit"],[">","Greater than"],[">=","Greater than or Equal"]]}], + [ "lowerLimit", {"label":"Lower Limit","type":"text","validation":"none"}], + [ "upperCondition", {"label":"Upper Limit Condition","type":"select","source":[["No Upper Limit","No Upper Limit"],["<","Less than"],["<=","Less than or Equal"]]}], + [ "upperLimit", {"label":"Upper Limit","type":"text","validation":"none"}], + [ "amount", {"label":"Value","type":"text","validation":"float"}] + ], + "html":'
#_delete_##_edit_#
#_renderFunction_#
', + "validation":"none", + "render":function(item){ + var output = ""; + if(item.lowerCondition != "No Lower Limit"){ + output += item.lowerLimit + " " + item.lowerCondition + " "; + output += " and "; + } + + if(item.upperCondition != "No Upper Limit"){ + output += item.upperCondition + " " + item.upperLimit + " "; + } + if(output == ""){ + return "Deduction is "+item.amount + " for all ranges"; + }else{ + return "If salary component "+output+ " deduction is "+item.amount; + } + + + return output; + + } + + }]; + + return [ + [ "id", {"label":"ID","type":"hidden"}], + [ "name", {"label":"Name","type":"text","validation":""}], + [ "contributor", {"label":"Contributor","type":"select","source":[["Employee","Employee"],["Employer","Employer"]]}], + [ "type", {"label":"Deduction Type","type":"select","source":[["Fixed","Fixed"],["Percentage","Percentage"]]}], + [ "percentage_type", {"label":"Percentage Type","type":"select","source":[["On Component","On Component"],["On Component Type","On Component Type"]]}], + [ "componentType", {"label":"Salary Component Type","type":"select2","allow-null":true,"null-label":"N/A","remote-source":["SalaryComponentType","id","name"]}], + [ "component", {"label":"Salary Component","type":"select2","allow-null":true,"null-label":"N/A","remote-source":["SalaryComponent","id","name"]}], + rangeAmounts, + [ "country", {"label":"Country","type":"select2","remote-source":["Country","id","name"]}] + + ]; +}); + +DeductionAdapter.method('doCustomValidation', function(params) { + if(params.type == "Fixed"){ + return null; + } + if(params.percentage_type == "On Component Type"){ + params.component = "NULL"; + if(params.componentType == "NULL"){ + return "Salary component type should be selected"; + } + }else if(params.percentage_type == "On Component"){ + params.componentType = "NULL"; + if(params.component == "NULL"){ + return "Salary component should be selected"; + } + } + + return null; +}); + +DeductionAdapter.method('postRenderForm', function(object, $tempDomObj) { + + $tempDomObj.find("#field_componentType").hide(); + $tempDomObj.find("#field_percentage_type").hide(); + $tempDomObj.find("#field_component").hide(); + + + $tempDomObj.find("#percentage_type").off().on('change',function(e){ + if(e.val == "On Component"){ + $("#componentType").hide(); + $("#component").show(); + }else{ + $("#componentType").show(); + $("#component").hide(); + } + }); + + $tempDomObj.find("#type").off().on('change',function(e){ + if(e.val == "Fixed"){ + $("#componentType").hide(); + $("#percentage_type").hide(); + $("#component").hide(); + }else{ + $("#percentage_type").show(); + if($("#percentage_type").select2('data').id == 'On Component'){ + $("#field_componentType").hide(); + $("#field_component").show(); + }else{ + $("#field_componentType").show(); + $("#field_component").hide(); + } + + } + }); +}); + + +/* + * EmployeeSalaryAdapter + */ + +function EmployeeSalaryAdapter(endPoint,tab,filter,orderBy) { + this.initAdapter(endPoint,tab,filter,orderBy); +} + +EmployeeSalaryAdapter.inherits(AdapterBase); + + + +EmployeeSalaryAdapter.method('getDataMapping', function() { + return [ + "id", + "employee", + "component", + "pay_frequency", + "currency", + "amount", + "details" + ]; +}); + +EmployeeSalaryAdapter.method('getHeaders', function() { + return [ + { "sTitle": "ID" ,"bVisible":false}, + { "sTitle": "Employee" }, + { "sTitle": "Salary Component" }, + { "sTitle": "Pay Frequency"}, + { "sTitle": "Currency"}, + { "sTitle": "Amount"}, + { "sTitle": "Details"} + ]; +}); + +EmployeeSalaryAdapter.method('getFormFields', function() { + return [ + [ "id", {"label":"ID","type":"hidden"}], + [ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}], + [ "component", {"label":"Salary Component","type":"select2","remote-source":["SalaryComponent","id","name"]}], + [ "pay_frequency", {"label":"Pay Frequency","type":"select","source":[["Hourly","Hourly"],["Daily","Daily"],["Bi Weekly","Bi Weekly"],["Weekly","Weekly"],["Semi Monthly","Semi Monthly"],["Monthly","Monthly"]]}], + [ "currency", {"label":"Currency","type":"select2","remote-source":["CurrencyType","id","name"]}], + [ "amount", {"label":"Amount","type":"text","validation":"float"}], + [ "details", {"label":"Details","type":"textarea","validation":"none"}] + ]; +}); + +EmployeeSalaryAdapter.method('getFilters', function() { + return [ + [ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}] + + ]; +}); + + + diff --git a/ext/admin/payroll/meta.json b/ext/admin/payroll/meta.json new file mode 100644 index 00000000..e3babd0f --- /dev/null +++ b/ext/admin/payroll/meta.json @@ -0,0 +1,11 @@ +{ +"label":"Setup", +"menu":"Salary Details", +"order":"6", +"icon":"fa-cogs", +"user_levels":["Admin"], + +"permissions": + { + } +} \ No newline at end of file diff --git a/ext/modules/salary/meta.json b/ext/modules/salary/meta.json index 1439ac84..9543b4a1 100644 --- a/ext/modules/salary/meta.json +++ b/ext/modules/salary/meta.json @@ -19,4 +19,4 @@ "Delete Salary":"No" } } -} +} \ No newline at end of file