123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Hrms;
- (function (Hrms) {
- let Payroll;
- (function (Payroll) {
- let Controls;
- (function (Controls) {
- class SalaryTemplate extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.TotalAnnualAmount = 0;
- this.TotalMonthlyAmount = 0;
- this.strtxt = "";
- this.ctc_Array = [];
- this.g_VisibleContainerId = "";
- this.salarycomponenttypeid = 1;
- }
- init(formpropertyid, prop, callback) {
- var container = "control-container-" + formpropertyid;
- var instance = this;
- instance.local_container = container;
- instance.editEarning = false;
- instance.findtxtcrRdr = 2;
- instance.rowindexid = parseInt('00001', 8);
- instance.flag = 0;
- if (Unibase.Platform.Helpers.NavigationHelper.installedAppId == 0) {
- instance.fileCacheHelper.loadJsFiles(['platform/forms/infos/formbuilder/formbuilderinfo.js'], function () {
- var properties = new Properties();
- properties.FormPropertyId = parseInt('00001', 8);
- instance.local_container = formpropertyid.toString();
- instance.loadControl(formpropertyid.toString(), properties);
- });
- }
- instance.fileCacheHelper.loadJsFiles(['platform/core/helpers/numberhelper/numberhelper.js', 'apps/hrms/payroll/managers/payrollmanager.js'], function () {
- instance.changeannualctc();
- instance.getsalarycomponentdetails();
- });
- }
- loadControlSettings(controlsettingjson, formpropertyid) { }
- loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) { }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) { }
- loadControl(container, prop) {
- var instance = this;
- instance.rowindexid = prop.FormPropertyId;
- instance.g_VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array = [];
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = "";
- instance.fileCacheHelper.loadJsFiles(['apps/hrms/enums/earningtypes.js', 'apps/hrms/enums/componenttypes.js', 'apps/hrms/enums/calculationtype.js', 'apps/hrms/payroll/controls/ctccalculation.js', 'apps/hrms/payroll/managers/payrollmanager.js'], function () {
- $('#hdn_salarycomponentcontrol').val("Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().salarycomponentObj();");
- var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
- $("#" + container).html(ctcInstance.getcomponentHtml());
- if (Unibase.Platform.Helpers.NavigationHelper.installedAppId == 0) {
- var str = '<div class="input-group col-sm-6 mb-10"><input type="text" id="txt_100011620016131" class=" form-control txt_annualctc" placeholder="Annual CTC" data-placeholder="Enter Annual CTC" data-label="Annual CTC" data-regularexp="" onblur="Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation()"></div>';
- $(".salarytemplate_hdr").before(str);
- $(".txt_annualctc").on("keypress", function (event) {
- var charCode = (event.which) ? event.which : event.keyCode;
- if (charCode != 46 && charCode > 31
- && (charCode < 48 || charCode > 57))
- return false;
- return true;
- });
- }
- var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- if (installedAppId == 0) {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().SalaryEarningdetails(Bizgaze.Apps.Hrms.Enums.EarningTypes.Basic);
- }
- });
- }
- refreshsystemcalculations() {
- var instance = this;
- let AnnualCTC = $(".txt_annualctc").val();
- let basic = 0;
- let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.componenttypeid == Bizgaze.Apps.Hrms.Enums.ComponentTypes.Earnings && x.earningtypeid == Bizgaze.Apps.Hrms.Enums.EarningTypes.Basic);
- if (obj != undefined) {
- basic = obj.monthlyamount;
- }
- instance.fileCacheHelper.loadJsFile("apps/hrms/payroll/managers/payrollmanager.js", function () {
- Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().calculateSalaryTemplatePreTaxDeductions(AnnualCTC, basic).then(function (response) {
- for (var i = 0; i < response.result.length; i++) {
- let data = response.result[i];
- let salarycomponentid = data.SalaryComponentId;
- let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.salarycomponentid == salarycomponentid);
- if (obj != undefined) {
- obj.amount = data.Amount;
- obj.monthlyamount = data.Amount;
- }
- }
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
- });
- });
- }
- getsalarycomponentdetails() {
- var instance = this;
- var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- if (installedAppId != 0) {
- var templateid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_recordid").Value);
- if (templateid != 0) {
- instance.fileCacheHelper.loadJsFile("apps/hrms/payroll/managers/payrollmanager.js", function () {
- Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().getSalaryTemplateById(templateid).then(function (response) {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array = [];
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = "";
- if (response.result != null) {
- $(".txt_annualctc").val(response.result[0].AnnualCTC);
- $(".txt_templatename").val(response.result[0].TemplateName);
- $(".txt_description").val(response.result[0].TemplateName);
- $(".date_templateeffectivefrom").val(response.result[0].FromDate);
- $(".date_templateeffectiveto").val(response.result[0].ToDate);
- for (var i = 0; i < response.result.length; i++) {
- var data = response.result[i];
- var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
- let item = ctcInstance.itemobj(data);
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.push(item);
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt + "|" + item.rowindexid;
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().bindcomponenthtml(item);
- }
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
- }
- });
- });
- }
- }
- }
- SalaryEarningdetails(earningtypeid) {
- var instance = this;
- instance.fileCacheHelper.loadJsFiles(["apps/hrms/payroll/managers/payrollmanager.js", "apps/hrms/payroll/controls/ctccalculation.js"], function () {
- Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().getSalaryComponentsByEarningtypeId(earningtypeid).then(function (response) {
- var data = response.result;
- if (data != null) {
- var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
- let item = ctcInstance.itemobj(data);
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.push(item);
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt + "|" + item.rowindexid;
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().bindcomponenthtml(item);
- if (Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.length > 1)
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
- }
- });
- });
- }
- getsalarycomponentbyid(salarycomponentid) {
- var instance = this;
- if (salarycomponentid != 0) {
- instance.fileCacheHelper.loadJsFile("apps/hrms/payroll/managers/payrollmanager.js", function () {
- Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().getsalarycomponentbyid(salarycomponentid).then(function (response) {
- if (response.result != null) {
- var data = response.result;
- var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
- let item = ctcInstance.itemobj(data);
- let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.rowindexid == item.rowindexid);
- if (obj != undefined) {
- obj.payslipname = data.PaySlipName;
- obj.calculationtypeid = data.CalculationTypeId;
- obj.calculationtypename = data.CalculationTypeName;
- obj.salarycomponentid = data.SalaryComponentId;
- obj.earningtypeid = data.EarningTypeId;
- obj.amount = data.Amount;
- obj.monthlyamount = data.Amount;
- }
- else {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.push(item);
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt + "|" + item.rowindexid;
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().bindcomponenthtml(item);
- }
- if (data.ComponentTypeId == Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions || data.ComponentTypeId == Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes) {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().refreshsystemcalculations();
- }
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
- }
- });
- });
- }
- }
- validation() {
- if (Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.rowindexid == Bizgaze.Apps.Hrms.Enums.EarningTypes.FixedAllowance)) {
- var obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.rowindexid == Bizgaze.Apps.Hrms.Enums.EarningTypes.FixedAllowance);
- if (obj.monthlyamount < 0 && obj.annualamount < 0) {
- $("#txt_AmountMonthly_" + obj.rowindexid).addClass('text-danger');
- $("#txt_AmountAnnually_" + obj.rowindexid).addClass('text-danger');
- MessageHelper.Instance().showError("Fixed Allowance amount should Not Be Negative", 'div_ErrorMessage_' + Unibase.Platform.Forms.Components.FormViewer.instance.FormId);
- return false;
- }
- else {
- $("#txt_AmountMonthly_" + obj.rowindexid).removeClass('text-danger');
- $("#txt_AmountAnnually_" + obj.rowindexid).removeClass('text-danger');
- }
- }
- }
- removeComponent(id) {
- if (id == Bizgaze.Apps.Hrms.Enums.EarningTypes.Basic || id == Bizgaze.Apps.Hrms.Enums.EarningTypes.FixedAllowance) {
- return false;
- }
- let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
- for (var i = 0; i < obj.length; i++) {
- if (id == obj[i].rowindexid) {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt.replace('|' + obj[i].rowindexid, '');
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array = $.grep(obj, function (value) {
- return value != obj[i];
- });
- break;
- }
- }
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
- var element = $('.salaryearningdetails_item_row_' + id);
- element.remove();
- }
- salarycomponentObj() {
- var item = [Bizgaze.Apps.Hrms.Enums.ComponentTypes.Earnings, Bizgaze.Apps.Hrms.Enums.ComponentTypes.FBPComponents, Bizgaze.Apps.Hrms.Enums.ComponentTypes.OneTimeEarnings, Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions, Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes, Bizgaze.Apps.Hrms.Enums.ComponentTypes.Reimbursements];
- let _rowid = 1;
- for (var i = 0; i < item.length; i++) {
- let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.filter(x => x.componenttypeid == item[i]);
- for (var j = 0; j < obj.length; j++) {
- if (obj[j].rowid == 0) {
- obj[j].rowid = _rowid;
- _rowid++;
- }
- }
- }
- return Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
- }
- changeannualctc() {
- $(".txt_annualctc").blur(function () {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
- });
- }
- addnew() {
- $('#earningModal').modal("hide");
- let salarycomponentid = $("#hdnAutoComplete_Component").val();
- let salarycomponenttypeid = Number($('#txtAutoComplete_SalaryComponenttype').val());
- if (salarycomponenttypeid == Bizgaze.Apps.Hrms.Enums.ComponentTypes.Earnings) {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().SalaryEarningdetails(salarycomponentid);
- }
- else {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().getsalarycomponentbyid(salarycomponentid);
- }
- }
- popup() {
- $("#_bizgaze_modal").empty();
- var instance = this;
- $(".settings-panel-close").trigger('click');
- let ModalHtml = `<div class="settings-modal-container"><div class="modal fade" id="earningModal" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog modal-dialog-centered" role="document"><div class="modal-content rounded-10"><div class="modal-header" style="border-style:dashed"><h5 class="modal-title ml-auto">Select salary components</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="badge badge-soft-danger font-20 rounded-circle pb-2 px-2">×</span></button></div><div class="modal-body"><div class="form-group branch-Section"><label class="control-label text-primary font-weight-500 mb-5 biz-highlight-text-color" for="ComponentTypesSelect">Salary Component Types</label><select class="form-control border border-top-0 border-right-0 border-left-0" style="width:100%" id="txtAutoComplete_SalaryComponenttype">
- <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.Earnings}>Earnings</option>
- <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.Reimbursements}>Reimbursements</option>
- <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.FBPComponents}>FBPComponents</option>
- <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions}>Deductions</option>
- <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.OneTimeEarnings}>OneTimeEarnings</option>
- /*<option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes}>Taxes</option>*/
- </select><input type="hidden" id="hdnAutoComplete_SalaryComponenttype"></div><div class="form-group branch-Section"><label class="control-label text-primary font-weight-500 mb-5 biz-highlight-text-color" for="branchSelect">Salary Component</label><select class="form-control border border-top-0 border-right-0 border-left-0" style="width:100%" id="txtAutoComplete_Component"></select><input type="hidden" id="hdnAutoComplete_Component"></div><div class="text-center"><button class="hidden btn_addnew btn px-4 py-1 btn btn-sm btn-primary" onclick="Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().addnew()">Apply</button></div></div></div></div></div></div>`;
- $("#_bizgaze_modal").html(ModalHtml);
- $('#earningModal').modal();
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().salarycomponenttypeautocomplete(Bizgaze.Apps.Hrms.Enums.ComponentTypes.Earnings);
- $('#txtAutoComplete_SalaryComponenttype').change(function () {
- Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().salarycomponenttypeautocomplete(Number($('#txtAutoComplete_SalaryComponenttype').val()));
- });
- }
- salarycomponenttypeautocomplete(salarycomponenttype) {
- var url = "";
- const instance = this;
- $("#hdnAutoComplete_Component").val(0);
- $('#txtAutoComplete_Component').empty();
- if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.Reimbursements == salarycomponenttype) {
- var url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/getsalarycomponentautocomplete/componenttypeid/' + Bizgaze.Apps.Hrms.Enums.ComponentTypes.Reimbursements + '/salarycomponentids/' + instance.strtxt + '/earningtypeid/' + 0;
- }
- else if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions == salarycomponenttype) {
- var url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/getsalarycomponentautocomplete/componenttypeid/' + Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions + '/salarycomponentids/' + instance.strtxt + '/earningtypeid/' + 0;
- }
- else if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.OneTimeEarnings == salarycomponenttype) {
- var url = "";
- }
- else if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.FBPComponents == salarycomponenttype) {
- var url = "";
- }
- else if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes == salarycomponenttype) {
- var url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/getsalarycomponentautocomplete/componenttypeid/' + Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes + '/salarycomponentids/' + instance.strtxt + '/earningtypeid/' + 0;
- }
- else {
- url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/earningtypeautocomplete/previoustext/' + Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt;
- }
- AutoCompleteHelper.getHelper().Create("#txtAutoComplete_Component", $("#hdnAutoComplete_Component"), url, function (response) {
- if (response.id != 0) {
- $('.btn_addnew').removeClass('hidden');
- }
- });
- }
- ctc_calculation() {
- let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
- var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
- ctcInstance.ctc_calculation(obj);
- }
- salaryitem_Calculation(rowindexid) {
- let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
- var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
- ctcInstance.salaryitem_Calculation(rowindexid, obj);
- }
- bindcomponenthtml(data) {
- let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
- var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
- ctcInstance.bindcomponenthtml(data, obj, data.templateid == 0 || data.templateid == undefined ? true : false);
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new SalaryTemplate();
- }
- return this.instance;
- }
- }
- Controls.SalaryTemplate = SalaryTemplate;
- })(Controls = Payroll.Controls || (Payroll.Controls = {}));
- })(Payroll = Hrms.Payroll || (Hrms.Payroll = {}));
- })(Hrms = Apps.Hrms || (Apps.Hrms = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|