Built files from Bizgaze WebServer
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

salarytemplate.component.js 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Hrms;
  6. (function (Hrms) {
  7. let Payroll;
  8. (function (Payroll) {
  9. let Controls;
  10. (function (Controls) {
  11. class SalaryTemplate extends Unibase.Platform.Core.BaseComponent {
  12. constructor() {
  13. super(...arguments);
  14. this.TotalAnnualAmount = 0;
  15. this.TotalMonthlyAmount = 0;
  16. this.strtxt = "";
  17. this.ctc_Array = [];
  18. this.g_VisibleContainerId = "";
  19. this.salarycomponenttypeid = 1;
  20. }
  21. init(formpropertyid, prop, callback) {
  22. var container = "control-container-" + formpropertyid;
  23. var instance = this;
  24. instance.local_container = container;
  25. instance.editEarning = false;
  26. instance.findtxtcrRdr = 2;
  27. instance.rowindexid = parseInt('00001', 8);
  28. instance.flag = 0;
  29. if (Unibase.Platform.Helpers.NavigationHelper.installedAppId == 0) {
  30. instance.fileCacheHelper.loadJsFiles(['platform/forms/infos/formbuilder/formbuilderinfo.js'], function () {
  31. var properties = new Properties();
  32. properties.FormPropertyId = parseInt('00001', 8);
  33. instance.local_container = formpropertyid.toString();
  34. instance.loadControl(formpropertyid.toString(), properties);
  35. });
  36. }
  37. instance.fileCacheHelper.loadJsFiles(['platform/core/helpers/numberhelper/numberhelper.js', 'apps/hrms/payroll/managers/payrollmanager.js'], function () {
  38. instance.changeannualctc();
  39. instance.getsalarycomponentdetails();
  40. });
  41. }
  42. loadControlSettings(controlsettingjson, formpropertyid) { }
  43. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) { }
  44. bindEditFormDetails(formpropertyid, propval, DocPropertyName) { }
  45. loadControl(container, prop) {
  46. var instance = this;
  47. instance.rowindexid = prop.FormPropertyId;
  48. instance.g_VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  49. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array = [];
  50. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = "";
  51. 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 () {
  52. $('#hdn_salarycomponentcontrol').val("Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().salarycomponentObj();");
  53. var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
  54. $("#" + container).html(ctcInstance.getcomponentHtml());
  55. if (Unibase.Platform.Helpers.NavigationHelper.installedAppId == 0) {
  56. 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>';
  57. $(".salarytemplate_hdr").before(str);
  58. $(".txt_annualctc").on("keypress", function (event) {
  59. var charCode = (event.which) ? event.which : event.keyCode;
  60. if (charCode != 46 && charCode > 31
  61. && (charCode < 48 || charCode > 57))
  62. return false;
  63. return true;
  64. });
  65. }
  66. var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  67. if (installedAppId == 0) {
  68. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().SalaryEarningdetails(Bizgaze.Apps.Hrms.Enums.EarningTypes.Basic);
  69. }
  70. });
  71. }
  72. refreshsystemcalculations() {
  73. var instance = this;
  74. let AnnualCTC = $(".txt_annualctc").val();
  75. let basic = 0;
  76. 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);
  77. if (obj != undefined) {
  78. basic = obj.monthlyamount;
  79. }
  80. instance.fileCacheHelper.loadJsFile("apps/hrms/payroll/managers/payrollmanager.js", function () {
  81. Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().calculateSalaryTemplatePreTaxDeductions(AnnualCTC, basic).then(function (response) {
  82. for (var i = 0; i < response.result.length; i++) {
  83. let data = response.result[i];
  84. let salarycomponentid = data.SalaryComponentId;
  85. let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.salarycomponentid == salarycomponentid);
  86. if (obj != undefined) {
  87. obj.amount = data.Amount;
  88. obj.monthlyamount = data.Amount;
  89. }
  90. }
  91. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
  92. });
  93. });
  94. }
  95. getsalarycomponentdetails() {
  96. var instance = this;
  97. var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  98. if (installedAppId != 0) {
  99. var templateid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_recordid").Value);
  100. if (templateid != 0) {
  101. instance.fileCacheHelper.loadJsFile("apps/hrms/payroll/managers/payrollmanager.js", function () {
  102. Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().getSalaryTemplateById(templateid).then(function (response) {
  103. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array = [];
  104. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = "";
  105. if (response.result != null) {
  106. $(".txt_annualctc").val(response.result[0].AnnualCTC);
  107. $(".txt_templatename").val(response.result[0].TemplateName);
  108. $(".txt_description").val(response.result[0].TemplateName);
  109. $(".date_templateeffectivefrom").val(response.result[0].FromDate);
  110. $(".date_templateeffectiveto").val(response.result[0].ToDate);
  111. for (var i = 0; i < response.result.length; i++) {
  112. var data = response.result[i];
  113. var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
  114. let item = ctcInstance.itemobj(data);
  115. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.push(item);
  116. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt + "|" + item.rowindexid;
  117. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().bindcomponenthtml(item);
  118. }
  119. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
  120. }
  121. });
  122. });
  123. }
  124. }
  125. }
  126. SalaryEarningdetails(earningtypeid) {
  127. var instance = this;
  128. instance.fileCacheHelper.loadJsFiles(["apps/hrms/payroll/managers/payrollmanager.js", "apps/hrms/payroll/controls/ctccalculation.js"], function () {
  129. Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().getSalaryComponentsByEarningtypeId(earningtypeid).then(function (response) {
  130. var data = response.result;
  131. if (data != null) {
  132. var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
  133. let item = ctcInstance.itemobj(data);
  134. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.push(item);
  135. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt + "|" + item.rowindexid;
  136. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().bindcomponenthtml(item);
  137. if (Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.length > 1)
  138. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
  139. }
  140. });
  141. });
  142. }
  143. getsalarycomponentbyid(salarycomponentid) {
  144. var instance = this;
  145. if (salarycomponentid != 0) {
  146. instance.fileCacheHelper.loadJsFile("apps/hrms/payroll/managers/payrollmanager.js", function () {
  147. Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().getsalarycomponentbyid(salarycomponentid).then(function (response) {
  148. if (response.result != null) {
  149. var data = response.result;
  150. var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
  151. let item = ctcInstance.itemobj(data);
  152. let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.rowindexid == item.rowindexid);
  153. if (obj != undefined) {
  154. obj.payslipname = data.PaySlipName;
  155. obj.calculationtypeid = data.CalculationTypeId;
  156. obj.calculationtypename = data.CalculationTypeName;
  157. obj.salarycomponentid = data.SalaryComponentId;
  158. obj.earningtypeid = data.EarningTypeId;
  159. obj.amount = data.Amount;
  160. obj.monthlyamount = data.Amount;
  161. }
  162. else {
  163. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.push(item);
  164. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt + "|" + item.rowindexid;
  165. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().bindcomponenthtml(item);
  166. }
  167. if (data.ComponentTypeId == Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions || data.ComponentTypeId == Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes) {
  168. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().refreshsystemcalculations();
  169. }
  170. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
  171. }
  172. });
  173. });
  174. }
  175. }
  176. validation() {
  177. if (Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.rowindexid == Bizgaze.Apps.Hrms.Enums.EarningTypes.FixedAllowance)) {
  178. var obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.find(x => x.rowindexid == Bizgaze.Apps.Hrms.Enums.EarningTypes.FixedAllowance);
  179. if (obj.monthlyamount < 0 && obj.annualamount < 0) {
  180. $("#txt_AmountMonthly_" + obj.rowindexid).addClass('text-danger');
  181. $("#txt_AmountAnnually_" + obj.rowindexid).addClass('text-danger');
  182. MessageHelper.Instance().showError("Fixed Allowance amount should Not Be Negative", 'div_ErrorMessage_' + Unibase.Platform.Forms.Components.FormViewer.instance.FormId);
  183. return false;
  184. }
  185. else {
  186. $("#txt_AmountMonthly_" + obj.rowindexid).removeClass('text-danger');
  187. $("#txt_AmountAnnually_" + obj.rowindexid).removeClass('text-danger');
  188. }
  189. }
  190. }
  191. removeComponent(id) {
  192. if (id == Bizgaze.Apps.Hrms.Enums.EarningTypes.Basic || id == Bizgaze.Apps.Hrms.Enums.EarningTypes.FixedAllowance) {
  193. return false;
  194. }
  195. let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
  196. for (var i = 0; i < obj.length; i++) {
  197. if (id == obj[i].rowindexid) {
  198. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt.replace('|' + obj[i].rowindexid, '');
  199. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array = $.grep(obj, function (value) {
  200. return value != obj[i];
  201. });
  202. break;
  203. }
  204. }
  205. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
  206. var element = $('.salaryearningdetails_item_row_' + id);
  207. element.remove();
  208. }
  209. salarycomponentObj() {
  210. 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];
  211. let _rowid = 1;
  212. for (var i = 0; i < item.length; i++) {
  213. let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array.filter(x => x.componenttypeid == item[i]);
  214. for (var j = 0; j < obj.length; j++) {
  215. if (obj[j].rowid == 0) {
  216. obj[j].rowid = _rowid;
  217. _rowid++;
  218. }
  219. }
  220. }
  221. return Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
  222. }
  223. changeannualctc() {
  224. $(".txt_annualctc").blur(function () {
  225. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_calculation();
  226. });
  227. }
  228. addnew() {
  229. $('#earningModal').modal("hide");
  230. let salarycomponentid = $("#hdnAutoComplete_Component").val();
  231. let salarycomponenttypeid = Number($('#txtAutoComplete_SalaryComponenttype').val());
  232. if (salarycomponenttypeid == Bizgaze.Apps.Hrms.Enums.ComponentTypes.Earnings) {
  233. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().SalaryEarningdetails(salarycomponentid);
  234. }
  235. else {
  236. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().getsalarycomponentbyid(salarycomponentid);
  237. }
  238. }
  239. popup() {
  240. $("#_bizgaze_modal").empty();
  241. var instance = this;
  242. $(".settings-panel-close").trigger('click');
  243. 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">
  244. <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.Earnings}>Earnings</option>
  245. <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.Reimbursements}>Reimbursements</option>
  246. <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.FBPComponents}>FBPComponents</option>
  247. <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions}>Deductions</option>
  248. <option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.OneTimeEarnings}>OneTimeEarnings</option>
  249. /*<option value=${Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes}>Taxes</option>*/
  250. </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>`;
  251. $("#_bizgaze_modal").html(ModalHtml);
  252. $('#earningModal').modal();
  253. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().salarycomponenttypeautocomplete(Bizgaze.Apps.Hrms.Enums.ComponentTypes.Earnings);
  254. $('#txtAutoComplete_SalaryComponenttype').change(function () {
  255. Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().salarycomponenttypeautocomplete(Number($('#txtAutoComplete_SalaryComponenttype').val()));
  256. });
  257. }
  258. salarycomponenttypeautocomplete(salarycomponenttype) {
  259. var url = "";
  260. const instance = this;
  261. $("#hdnAutoComplete_Component").val(0);
  262. $('#txtAutoComplete_Component').empty();
  263. if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.Reimbursements == salarycomponenttype) {
  264. var url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/getsalarycomponentautocomplete/componenttypeid/' + Bizgaze.Apps.Hrms.Enums.ComponentTypes.Reimbursements + '/salarycomponentids/' + instance.strtxt + '/earningtypeid/' + 0;
  265. }
  266. else if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions == salarycomponenttype) {
  267. var url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/getsalarycomponentautocomplete/componenttypeid/' + Bizgaze.Apps.Hrms.Enums.ComponentTypes.PreTaxDeductions + '/salarycomponentids/' + instance.strtxt + '/earningtypeid/' + 0;
  268. }
  269. else if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.OneTimeEarnings == salarycomponenttype) {
  270. var url = "";
  271. }
  272. else if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.FBPComponents == salarycomponenttype) {
  273. var url = "";
  274. }
  275. else if (Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes == salarycomponenttype) {
  276. var url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/getsalarycomponentautocomplete/componenttypeid/' + Bizgaze.Apps.Hrms.Enums.ComponentTypes.Taxes + '/salarycomponentids/' + instance.strtxt + '/earningtypeid/' + 0;
  277. }
  278. else {
  279. url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/earningtypeautocomplete/previoustext/' + Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().strtxt;
  280. }
  281. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_Component", $("#hdnAutoComplete_Component"), url, function (response) {
  282. if (response.id != 0) {
  283. $('.btn_addnew').removeClass('hidden');
  284. }
  285. });
  286. }
  287. ctc_calculation() {
  288. let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
  289. var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
  290. ctcInstance.ctc_calculation(obj);
  291. }
  292. salaryitem_Calculation(rowindexid) {
  293. let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
  294. var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
  295. ctcInstance.salaryitem_Calculation(rowindexid, obj);
  296. }
  297. bindcomponenthtml(data) {
  298. let obj = Bizgaze.Apps.Hrms.Payroll.Controls.SalaryTemplate.Instance().ctc_Array;
  299. var ctcInstance = new Bizgaze.Apps.Hrms.Payroll.CtcCalculation();
  300. ctcInstance.bindcomponenthtml(data, obj, data.templateid == 0 || data.templateid == undefined ? true : false);
  301. }
  302. static Instance() {
  303. if (this.instance === undefined) {
  304. this.instance = new SalaryTemplate();
  305. }
  306. return this.instance;
  307. }
  308. }
  309. Controls.SalaryTemplate = SalaryTemplate;
  310. })(Controls = Payroll.Controls || (Payroll.Controls = {}));
  311. })(Payroll = Hrms.Payroll || (Hrms.Payroll = {}));
  312. })(Hrms = Apps.Hrms || (Apps.Hrms = {}));
  313. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  314. })(Bizgaze || (Bizgaze = {}));