Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

tax.component.js 78KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Forms;
  4. (function (Forms) {
  5. let Controls;
  6. (function (Controls) {
  7. class Tax extends Unibase.Platform.Core.BaseComponent {
  8. constructor() {
  9. super(...arguments);
  10. this.BranchIds = [];
  11. this.Branchlist = [];
  12. this.taxcode = new Array();
  13. this.editbranches = "";
  14. this.selectedids = "";
  15. this.CodeIds = [0];
  16. this.branchidsarray = [];
  17. this.selectData = [];
  18. this.txt_EditLedgerName = "";
  19. this.txt_EditLedgerId = 0;
  20. }
  21. init(formpropertyid, prop, callback) {
  22. var instance = this;
  23. if (callback != null) {
  24. callback();
  25. }
  26. }
  27. loadControl(container, prop) {
  28. var html = '<div class="panel panel-default"><input type="hidden" id="taxcodes" value="" data-isdynamic="true" data-propdoctypename="" />' +
  29. '<input type="hidden" id="hdn_customcontrol" class="value-control" value="Bizgaze.Forms.Controls.Tax.Instance().getTaxes();">' +
  30. '<div id="divtaxdetails"><div class="item-row" ></div></div></div>' +
  31. '<div class="" style="padding-bottom:33px"> <div class="col-sm-12 ">' +
  32. '<div class="row lineheight wrapper-sm" style="border-bottom: 2px solid grey;"><div class="col-sm-4 min-padding">' +
  33. '<strong class="">Tax Code</strong></div>' +
  34. '<div class="col-sm-3 min-padding"><strong>Rate</strong></div>' +
  35. '<div class="col-sm-2 min-padding"><strong>Display Text</strong></div>' +
  36. '<div class="col-sm-3 min-padding"><strong>Display Percent</strong></div></div ></div></div>' +
  37. '<div class="panel-body "><div class="item-row added-row "></div></div></div>' +
  38. '<a href="javascript:;" class="default pull-left" title="Add Item" data-original-title="Add New Tax"><span class="pull-right btn" style="text-decoration:underline;color:deepskyblue"' +
  39. 'id = "btnTax" onclick="Bizgaze.Forms.Controls.Tax.Instance().AddTaxCodes();">Add Tax Codes</span></a><input type="hidden" id="hidden_selectedTaxCode"><input type="hidden" id="hidden_selectedAccountName"><input type="hidden" id="hidden_selected_AccountName">';
  40. $("#" + container).html(html);
  41. }
  42. loadControlSettings(controlsettingjson, formpropertyid) {
  43. }
  44. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) {
  45. }
  46. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  47. var instance = this;
  48. var taxid = Number(propval);
  49. instance.getTaxesDetails(taxid);
  50. }
  51. getTaxesDetails(id) {
  52. var instance = this;
  53. instance.fileCacheHelper.loadJsFile("apps/transact/managers/taxmanager/taxmanager.js", function () {
  54. Unibase.Apps.Transact.Managers.TaxManager.Instance().getTaxes(id).then(function (response) {
  55. instance.taxcode = [];
  56. var result = response.result;
  57. if (result.length != 0) {
  58. var parenttaxcodes = new Array();
  59. for (var i = 0; i < result.length; i++) {
  60. parenttaxcodes.push({ TaxCodeName: result[i].TaxCodeName, TaxId: result[i].TaxId, TaxCodeId: result[i].TaxCodeId });
  61. }
  62. for (var i = 0; i < result.length; i++) {
  63. var rowid = moment().valueOf();
  64. var data = result[i];
  65. instance.taxcode.push({
  66. taxid: data.TaxId,
  67. rate: data.Rate,
  68. displaytext: data.DisplayText,
  69. displaypercent: data.DisplayPercent,
  70. taxcodeid: data.TaxCodeId,
  71. taxcodename: data.TaxCodeName,
  72. applion: data.AmountPercent,
  73. parentid: data.ParentId,
  74. parentname: data.Parentname,
  75. ratetypeid: data.TaxRateTypeId,
  76. branchlist: instance.branchs,
  77. Accledgerid: data.LedgerId,
  78. Accledgername: data.LedgerName,
  79. isbranchwiseledger: data.IsBranchWiseLedger,
  80. TCSPANNoAvail: data.TCSPANNoAvail,
  81. FromDate: data.FromDate,
  82. ToDate: data.ToDate
  83. });
  84. instance.addtaxcode = instance.taxcode[i];
  85. instance.AddRow(instance.addtaxcode, rowid);
  86. instance.getTax(data.TaxId, i, rowid);
  87. if (parenttaxcodes != null) {
  88. var cmbparent = $('#ddl_Parent' + rowid);
  89. for (var j = 0; j < parenttaxcodes.length; j++) {
  90. if (parenttaxcodes[j].TaxId != result[i].TaxId)
  91. $('<option>').val(parenttaxcodes[j].TaxId).text(parenttaxcodes[j].TaxCodeName).appendTo(cmbparent);
  92. }
  93. $("#ddl_Parent" + rowid + " option[value='" + data.ParentId + "']").attr("selected", "selected");
  94. }
  95. }
  96. }
  97. });
  98. });
  99. }
  100. getTax(TaxId, index, rowid) {
  101. var instance = this;
  102. var branchledger = new Array();
  103. var branchdata;
  104. var items = [];
  105. instance.fileCacheHelper.loadJsFile("apps/transact/managers/taxmanager/taxmanager.js", function () {
  106. Unibase.Apps.Transact.Managers.TaxManager.Instance().getBranch(TaxId).then(function (response) {
  107. var res = response.result;
  108. for (var i = 0; i < res.length; i++) {
  109. var data = res[i];
  110. branchledger.push({
  111. branchwiseledgerid: data.BranchWiseLedgerId,
  112. branchid: data.BranchId,
  113. ledgerid: data.LedgerId,
  114. taxid: data.TaxId,
  115. branchname: data.BranchName,
  116. ledgername: data.LedgerName,
  117. updateguid: data.UpdateGuid
  118. });
  119. branchdata = branchledger[i];
  120. if (items.length != 0 && items.find(x => x.ledgerid == branchdata.ledgerid) != undefined) {
  121. var multipleExist = items.find(x => x.ledgerid == branchdata.ledgerid);
  122. multipleExist.branchname += '|' + branchdata.branchname;
  123. multipleExist.branchid += '|' + branchdata.branchid;
  124. multipleExist.branchwiseledgerid += '|' + branchdata.branchwiseledgerid;
  125. }
  126. else {
  127. items.push(branchdata);
  128. }
  129. }
  130. if (data != null)
  131. if (data.BranchId == 0) {
  132. instance.taxcode[index].Accledgersid = data.LedgerId;
  133. instance.taxcode[index].Accledgersname = data.LedgerName;
  134. $(".AccountName").val(data.LedgerId);
  135. $("#hf_branchwiseledger" + rowid).val(data.BranchWiseLedgerId);
  136. $("#hf_updateguid" + rowid).val(data.UpdateGuid);
  137. var AutocompleteaAC = new Option(data.LedgerName, data.LedgerId.toString(), true);
  138. $("#txt_AccountName" + rowid).append(AutocompleteaAC);
  139. $('#chK_PortalWiseLedger' + rowid).prop('checked', false);
  140. $(".PortalAccountName" + rowid).addClass('hidden');
  141. $('.portalacc' + rowid).addClass('hidden');
  142. $(".li_branches" + rowid).addClass('hidden');
  143. $("#txt_AccountName" + rowid).prop('disabled', false);
  144. $('#txt_AccountName' + rowid).addClass('required');
  145. }
  146. else {
  147. instance.AddPortalAccName(null, items, rowid);
  148. $('#chK_PortalWiseLedger' + rowid).prop('checked', true);
  149. $('#txt_AccountName' + rowid).removeClass('required');
  150. $(".PortalAccountName" + rowid).removeClass('hidden');
  151. $('.portalacc' + rowid).removeClass('hidden');
  152. $("#txt_AccountName" + rowid).prop('disabled', true);
  153. $(".li_branches" + rowid).removeClass('hidden');
  154. }
  155. });
  156. });
  157. }
  158. AddTaxCodes() {
  159. var instance = this;
  160. var rowid = moment().valueOf();
  161. var emptyRow = {
  162. taxid: 0,
  163. rate: "",
  164. displaytext: "",
  165. taxcodename: "",
  166. displaypercent: "",
  167. taxcodeid: 0,
  168. applion: "",
  169. parentid: 0,
  170. parentname: "",
  171. ratetypeid: 0,
  172. Accledgerid: 0,
  173. Accledgername: "",
  174. };
  175. $(".moreoptions").addClass("hidden");
  176. instance.AddRow(emptyRow, rowid);
  177. }
  178. AddRow(row, rowid) {
  179. var instance = this;
  180. var len = $('.item-row').length;
  181. var html = "";
  182. var lilen = $("#ul_brancheslist" + rowid).children().length;
  183. var fromdate = moment(row.FromDate).format('DD/MM/YYYY');
  184. var todate = moment(row.toDate).format('DD/MM/YYYY');
  185. html = '<div class="item-row divtax_' + rowid + ' added-row"id="div_' + rowid + '" style = "padding-bottom:10px">' +
  186. '<div class="row">' +
  187. '<input type="hidden" id="hf_taxid" class"taxesid' + rowid + '" value="' + row.taxid + '"/>' +
  188. '<div class="col-sm-4 min-padding input-group">' +
  189. '<span id="hf_taxgroupid' + rowid + '"></span>' +
  190. '<div class="no-border row bg-white">' +
  191. '<a class="closeTax h6 delete text-danger" id="CloseTax ' + rowid + '" href="javascript:;">' +
  192. '<i class="fa fa-trash-o delete" style="color:red" aria-hidden="true" id="CloseTax ' + rowid + '"></i></a>' +
  193. '</div>' +
  194. '<div class="col-sm-12 ml-10 mb-mt-4 taxess" style="border-bottom:0;" id="div_TaxCode">' +
  195. '<select style="width:100%" id="txt_TaxCode' + rowid + '" class="form-control selectedTaxCode floating-label-control required" data-isdynamic="false" placeholder="Tax Code" data-placeholder="Output CGST" data-label="Tax Code"></select>' +
  196. '<input type="hidden" id="hf_TaxCode' + rowid + '" class="taxgrouptaxcode" value="' + row.taxcodeid + '"/>' +
  197. '<label for="Validation" id="lblValidation_TaxCode"></label><input class="selectedTaxId" value="0" type="hidden"><input type="hidden" id="hfFormPropertyId"/>' +
  198. '<input type="hidden" id="hf_len" value="' + rowid + '">' +
  199. '<input type="hidden" id="hf_codelen" value="' + rowid + '">' +
  200. '<input type="hidden" id="OldCodeId' + rowid + '" value="' + row.taxcodeid + '">' +
  201. '</div>' +
  202. '</div>' +
  203. '<div class="col-sm-3 min-padding">' +
  204. '<div class="floating-label-form-group taxrate" id="div_Rate' + rowid + '">' +
  205. '<div class="input-group">' +
  206. '<input type="text" id="txt_Rate' + rowid + '" value="' + row.rate + '"class="form-control required taxRate floating-label-control" data-isdynamic="false" placeholder="Rate *" data-placeholder="Enter Rate" data-label="Rate *" />' +
  207. '<input type="hidden" id="hf_Rate" value=""><label for="Validation" id="lblValidation_Rate"></label><input type="hidden" id="hfFormPropertyId" />' +
  208. '<input type="hidden" id="hf_taxid" class"taxesid' + rowid + '" value = "' + row.taxid + '"/> ' +
  209. '</div></div></div>' +
  210. '<div class="col-sm-2 min-padding">' +
  211. '<div class="floating-label-form-group diplaytext" id="div_DisplayTextTwo">' +
  212. '<div class="input-group">' +
  213. '<input type="text" id="txt_DisplayTextTwo' + rowid + '" value= "' + row.displaytext + '" class="form-control txtDisplayTextTwo floating-label-control" data-isdynamic="false" placeholder="Display Text" data-placeholder="Enter Display Text" data-label="Display Text" /><input type="hidden" id="hfFormPropertyId" />' +
  214. '</div></div></div>' +
  215. '<div class="col-sm-3 text-right min-padding">' +
  216. '<div class="floating-label-form-group displaypercent" id="div_DisplayPercentTwo">' +
  217. '<div class="input-group">' +
  218. '<input type="text" id="txt_DisplayPercentTwo' + rowid + ' "value="' + row.displaypercent + '" class="form-control txtDisplayPercentTwo floating-label-control" data-isdynamic="false" placeholder="Display Percent" data-placeholder="Enter Display Percent" data-label="Display Percent" />' +
  219. '<input type="hidden" id="hf_DisplayPercentTwo" value=""><label for="Validation" id="lblValidation_DisplayPercentTwo"></label><input type="hidden" id="hfFormPropertyId" />' +
  220. '</div></div></div></div>' +
  221. '<div class="hidden moreoptions bg-light" id="div_moreoptions' + rowid + '">' +
  222. '<div class="row">' +
  223. '<div class="col-sm-4 ">' +
  224. '<div class="floating-label-form-group floating-label-form-group-with-value" id="div_AppliedOnPercent">' +
  225. '<label for="txt_AppliedOnPercent" id="lbl_AppliedOnPercent">Applied On %</label><div class="input-group">' +
  226. '<input type="text" id="txt_AppliedOnPercent' + rowid + '"value="' + 100 + '" class="form-control txtAppliedOnPercent floating-label-control" data-isdynamic="false" placeholder="Applied On %" data-placeholder="Applied On" data-label="Applied On %" /><input type="hidden" id="hf_AppliedOnPercent" value="">' +
  227. '<label for="Validation" id="lblValidation_AppliedOnPercent"></label>' +
  228. '<input type="hidden" id="hfFormPropertyId" />' +
  229. '</div></div></div>' +
  230. '<div class="col-sm-4 ">' +
  231. '<div class="floating-label-form-group floating-label-form-group-with-value focus" id="div_Parent">' +
  232. '<label for="ddl_Parent" id="lbl_Parent">Parent</label>' +
  233. '<select class="form-control ddlParent no-border" id="ddl_Parent' + rowid + '"">' +
  234. '<option value="">Select Parent Tax Code</option>' +
  235. '<option value="0">None</option>' +
  236. '</select > ' +
  237. '</div></div>' +
  238. '<div class="col-sm-4">' +
  239. '<div class="floating-label-form-group floating-label-form-group-with-value focus" id="div_RateType">' +
  240. '<label for="ddl_RateType" id="lbl_RateType">Rate Type</label>' +
  241. '<select class="form-control ddlRateType no-border" id="ddl_RateType' + rowid + '" value="' + row.ratetypeid + '">' +
  242. '<option value="1">Percent</option>' +
  243. '<option value="2">Flat</option></select>' +
  244. '</div></div></div>' +
  245. '<div class="" style="padding-bottom:10px"></div>' +
  246. '<div class="row">' +
  247. '<div class="control-group col-sm-4 "><div id="div_FromDate" class="CancelBtnFloating floating-label-form-group"><label for="eTax_txt_FromDate" id="lbl_FromDate">From Date</label>' +
  248. '<div class="input-group"><input type="text" id = "eTax_txt_FromDate' + rowid + '" class="dateselect_1 form-control value-control datepicker-input hasDatepicker floating-label-control" placeholder="From Date " data-placeholder="dd/mm/yyyy" data-label="From Date ">' +
  249. '<span class="input-group-addon mt-10"><i class="fa fa-calendar"></i></span><input type="hidden" id="hfId" value="">' +
  250. '<label for="Validation" id="lblValidation_FromDate"></label>' +
  251. '</div></div></div>' +
  252. '<div class="control-group col-sm-4 "><div id="div_ToDate" class="CancelBtnFloating floating-label-form-group"><label for="eTax_txt_ToDate" id="lbl_ToDate">To Date</label>' +
  253. '<div class="input-group"><input type="text" id = "eTax_txt_ToDate' + rowid + '" class="dateselect_1 form-control value-control datepicker-input hasDatepicker floating-label-control" placeholder="To Date " data-placeholder="dd/mm/yyyy" data-label="To Date ">' +
  254. '<span class="input-group-addon mt-10"><i class="fa fa-calendar"></i></span><input type="hidden" id="hfId" value="">' +
  255. '<label for="Validation" id="lblValidation_ToDate"></label>' +
  256. '</div></div></div>' +
  257. '<div class="col-sm-4" >' +
  258. '<label>PAN No.Available ? <span class="control-label" > </span></label >' +
  259. '<div class="input-group" >' +
  260. '<label class="switch" >' +
  261. '<input class="negativestock" id = "rbtntcspancust' + rowid + '" type = "checkbox" >' +
  262. '<span></span></label></div></div>' +
  263. '</div>' +
  264. '<div class="row">' +
  265. '<div class="col-sm-4">' +
  266. '<div class="floating-label" style="border-bottom:0;" id="div_AccountName">' +
  267. '<label for="txt_AccountName" id="lbl_AccountName">Account Name<span class="text-danger"> *</span></label>' +
  268. '<select style="width:100%" id="txt_AccountName' + rowid + '" value="' + row.Accledgername + '" class="form-control selectedAccountName floating-label-control" data-isdynamic="false" placeholder="Account Name *" data-placeholder="Select Account Name" data-label="Select Account Name" />' +
  269. '<input type="hidden" id="hf_AccountName' + rowid + '" class="AccountName" value="' + row.Accledgersid + '"/>' +
  270. '<label for="Validation" id="lblValidation_AccountName"></label>' +
  271. '<input type="hidden" id="hfFormPropertyId" />' +
  272. '</div>' +
  273. '</div>' +
  274. '<div class="col-sm-4">' +
  275. '<div class="div_PortalWiseLedger' + rowid + ' checkbox-primary" style="padding-top:40px;">' +
  276. '<input type="checkbox" class="css-checkbox" id="chK_PortalWiseLedger' + rowid + '">' +
  277. '<span class="" for="PortalwiseLedger"> Branch Wise Ledgers</span>' +
  278. '</div>' +
  279. '</div>' +
  280. '</div >' +
  281. '<input type="hidden" id="hf_branchlen' + rowid + '" value = "' + lilen + '"/> ' +
  282. '<div class="row PortalAccountName' + rowid + '" id="div_PortalAccountName' + rowid + '">' +
  283. '<div class=" col-sm-6 floating-label-form-group-with-value tax-manager-branch" id="PortalAccountName' + rowid + '">' +
  284. '<label for="txt_PortalNames">Branch Names</label>' +
  285. '<select style="width:100%" id="txt_PortalNames' + rowid + '"value="" class="no-border form-control txtPortalNames' + rowid + ' " IsTagSelect="false" multiple="multiple" placeholder="Branch Name" data-placeholder="Select Branch Name" data-label="Select Branch Name"></select>' +
  286. '<input type="hidden" id="hfPortalNames' + rowid + '" value = "0" class="form-control hf_BranchNames" />' +
  287. '</div>' +
  288. '<div class="col-sm-4">' +
  289. '<div class="floating-label" style="border-bottom:0;" id="divAccountName">' +
  290. '<label for="txtAccountName" id="lblAccountName">Account Name</label>' +
  291. '<select style="width:100%" id="txtAccountName' + rowid + '"value="" class="form-control selected_AccountName floating-label-control" data-isdynamic="false" placeholder="Account Name" data-placeholder="Select Account Name" data-label="Select Account Name" />' +
  292. '<input type="hidden" id="hfAccountName' + rowid + '" class="Account_Name"/>' +
  293. '<label for="Validation" id="lblValidation_AccountName"></label>' +
  294. '<input type="hidden" id="hfFormPropertyId' + rowid + '" />' +
  295. '<input type="hidden" id="hf_taxid" class="taxesid' + rowid + '" value = "' + row.taxid + '"/> ' +
  296. '<input type="hidden" id="hf_branchwiseledger' + rowid + '" class="branchwiseledgerid' + rowid + '" value = "' + row.branchwiseledgerid + '"/> ' +
  297. '<input type="hidden" id="hf_updateguid' + rowid + '" class="updateguid' + rowid + '" value = "' + row.updateguid + '"/> ' +
  298. '</div>' +
  299. '</div>' +
  300. '<div>' +
  301. '<div class="btn-group text-center text-white btn-group-justified mt-20">' +
  302. '<a class="btn btn-primary btn-block mt-15 ml-15" id="btnAddPortalWiseLedger' + rowid + '" onclick="Bizgaze.Forms.Controls.Tax.Instance().AddEmptyBranchrow(' + rowid + ',' + lilen + ')">+</a>' +
  303. '</div>' +
  304. '</div>' +
  305. '</div>' +
  306. '<div class="" style="padding-bottom:10px"></div>' +
  307. '<div class=div_branchlist' + rowid + '>' +
  308. '<ul id="ul_brancheslist' + rowid + '"class="list-group list-group no-radius BranchesList' + rowid + '">' +
  309. '<li id="li_portalacc' + rowid + '"class="list-group-item list-group-item-row taxportalacc portalacc' + rowid + ' col-sm-12 clear">' +
  310. '<span class="col-sm-5 pull-left pl-5">Branch Name</span>' +
  311. '<span class="col-sm-5 text-center pl-5">Account Name</span>' +
  312. '<span class="col-sm-1 pull-right" ></span>' +
  313. '</li>' +
  314. '</ul>' +
  315. '</div>' +
  316. '</div>' +
  317. '</div ></div > ';
  318. $(".item-row:last").after(html);
  319. $('.taxRate').keypress(function (event) {
  320. if ((event.which > 47 && event.which < 58) || (event.which == 37 || event.which == 124) || (event.which == 46)) {
  321. }
  322. else {
  323. event.preventDefault();
  324. }
  325. }).on('paste', function (event) {
  326. event.preventDefault();
  327. });
  328. $(".dateselect_1").daterangepicker({
  329. locale: {
  330. format: 'DD/MM/YYYY',
  331. },
  332. singleDatePicker: true,
  333. showDropdowns: true,
  334. minYear: 1901,
  335. maxDate: new Date(2050, 11, 31)
  336. });
  337. $(".dateselect_1").parents(".floating-label-form-group").addClass("floating-label-form-group-with-value");
  338. var _fromdt = row.FromDate;
  339. if (row.FromDate == undefined) {
  340. _fromdt = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  341. }
  342. var _todt = row.ToDate;
  343. if (row.ToDate == undefined) {
  344. _todt = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  345. }
  346. var reffromdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(_fromdt, "DD/MM/YYYY");
  347. var reftodate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(_todt, "DD/MM/YYYY");
  348. $('#eTax_txt_FromDate' + rowid).val(reffromdate);
  349. $('#eTax_txt_ToDate' + rowid).val(reftodate);
  350. $('.txtAppliedOnPercent').keypress(function (event) {
  351. if ((event.which > 47 && event.which < 58) || (event.which == 37 || event.which == 124)) {
  352. }
  353. else {
  354. event.preventDefault();
  355. }
  356. }).on('paste', function (event) {
  357. event.preventDefault();
  358. });
  359. var element = $(".item-row:last");
  360. if (row.taxid > 0) {
  361. $("#txt_AppliedOnPercent" + rowid).text(100);
  362. $("#txt_AppliedOnPercent" + rowid).prop('disabled', true);
  363. $(".closeTax").addClass('hidden');
  364. var Autocompletetaxcode = new Option(row.taxcodename, row.taxcodeid.toString(), true);
  365. element.find("#txt_TaxCode" + rowid).append(Autocompletetaxcode);
  366. var AutocompleteledgrName = new Option(row.Accledgername, row.Accledgerid.toString(), true);
  367. $("#txt_AccountName" + rowid).append(AutocompleteledgrName);
  368. if (row.isbranchwiseledger == false) {
  369. $('#chK_PortalWiseLedger' + rowid).prop('checked', false);
  370. $("#div_PortalAccountName" + rowid).addClass('hidden');
  371. $(".div_branchlist" + rowid).addClass('hidden');
  372. }
  373. if (row.TCSPANNoAvail == true) {
  374. $('#rbtntcspancust' + rowid).prop('checked', true);
  375. }
  376. $("#ddl_RateType" + rowid + " option[value='" + row.ratetypeid + "']").attr("selected", "selected");
  377. $("#chK_PortalWiseLedger" + rowid).change(function () {
  378. if ($("#chK_PortalWiseLedger" + rowid).prop('checked') == true) {
  379. $("#div_PortalAccountName" + rowid).removeClass('hidden');
  380. $('.portalacc' + rowid).removeClass('hidden');
  381. $('#txt_AccountName' + rowid).removeClass('required');
  382. $("#txt_AccountName" + rowid).prop('disabled', true);
  383. $("#txt_AccountName" + rowid).text("");
  384. $(".li_branches" + rowid).removeClass('hidden');
  385. $("#txt_PortalNames" + rowid).addClass('required');
  386. }
  387. else {
  388. $("#div_PortalAccountName" + rowid).addClass('hidden');
  389. $('.portalacc' + rowid).addClass('hidden');
  390. $("#txt_AccountName" + rowid).prop('disabled', false);
  391. $(".li_branches" + rowid).addClass('hidden');
  392. $("#txt_AccountName" + rowid).text("");
  393. $("#txt_PortalNames" + rowid).removeClass('required');
  394. $('#txt_AccountName' + rowid).addClass('required');
  395. $(".li_branches" + rowid).text('');
  396. $(".li_branches" + rowid).val(0);
  397. $(".li_branches" + rowid).remove();
  398. }
  399. });
  400. }
  401. element.find(".taxRate").on('click', function () {
  402. if ($("#div_moreoptions" + rowid).hasClass("hidden")) {
  403. $("#div_moreoptions" + rowid).removeClass('hidden');
  404. }
  405. else {
  406. $("#div_moreoptions" + rowid).addClass('hidden');
  407. }
  408. });
  409. if (row.taxid == 0) {
  410. $("#txt_AppliedOnPercent" + rowid).text(100);
  411. $("#txt_AppliedOnPercent" + rowid).prop('disabled', true);
  412. $('#div_PortalAccountName' + rowid).addClass('hidden');
  413. $('.portalacc' + rowid).addClass('hidden');
  414. $('#txt_AccountName' + rowid).addClass('required');
  415. $("#chK_PortalWiseLedger" + rowid).change(function () {
  416. if ($("#chK_PortalWiseLedger" + rowid).prop('checked') == true) {
  417. $("#div_PortalAccountName" + rowid).removeClass('hidden');
  418. $('.portalacc' + rowid).removeClass('hidden');
  419. $('#txt_AccountName' + rowid).removeClass('required');
  420. $("#txt_AccountName" + rowid).prop('disabled', true);
  421. $("#txt_AccountName" + rowid).text("");
  422. $(".li_branches" + rowid).removeClass('hidden');
  423. $('#txtAccountName' + rowid).addClass('required');
  424. $("#txt_PortalNames" + rowid).addClass('required');
  425. }
  426. else {
  427. $("#div_PortalAccountName" + rowid).addClass('hidden');
  428. $('.portalacc' + rowid).addClass('hidden');
  429. $("#txt_AccountName" + rowid).prop('disabled', false);
  430. $('#txt_AccountName' + rowid).addClass('required');
  431. $(".li_branches" + rowid).addClass('hidden');
  432. $('#txtAccountName' + rowid).removeClass('required');
  433. $("#txt_PortalNames" + rowid).removeClass('required');
  434. $(".li_branches" + rowid).text('');
  435. $(".li_branches" + rowid).val(0);
  436. $(".li_branches" + rowid).remove();
  437. }
  438. });
  439. }
  440. instance.taxcodeautocomplete(element, rowid);
  441. instance.ledgerautocomplete(element, rowid);
  442. instance.ledgersautocomplete(element, rowid);
  443. instance.bind(element);
  444. instance.getbranches("", rowid);
  445. }
  446. getbranches(branchids, rowid) {
  447. var instance = this;
  448. var PostData = null;
  449. PostData = {
  450. bindedData: branchids,
  451. };
  452. if ($("#txt_Rate" + rowid).val() == 0 || $("#txt_Rate" + rowid).val() == "") {
  453. $("#hf_branchlen" + rowid).val("");
  454. var selectedids = "";
  455. }
  456. var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
  457. var session = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().sessionId;
  458. instance.fileCacheHelper.loadJsFile("apps/transact/managers/taxmanager/taxmanager.js", function () {
  459. Unibase.Apps.Transact.Managers.TaxManager.Instance().getAssignedBranches(PostData).then(function (response) {
  460. var Branches = [];
  461. var Ids = [];
  462. if (response.result[0].DisplayText != "No item found") {
  463. for (var i = 0; i < response.result.length; i++) {
  464. var lob = response.result[i];
  465. Branches.push({ id: lob.Value, text: lob.DisplayText });
  466. Ids.push(lob.Value);
  467. }
  468. }
  469. $("#txt_PortalNames" + rowid).select2({
  470. allowClear: true,
  471. placeholder: "Select Branch",
  472. data: Branches,
  473. ajax: {
  474. url: function (request) {
  475. var reqUrl = _appsettings.server_url() + "/apis/v4/bizgaze/crm/companies/branchautocomplete/";
  476. var term = request.term;
  477. reqUrl = reqUrl.replace('#', '');
  478. return reqUrl;
  479. },
  480. type: "POST",
  481. contentType: 'application/json',
  482. dataType: 'json',
  483. data: function (params) {
  484. var Participants = "";
  485. var ParticipantsCount = new Array();
  486. var Participant = $("#txt_PortalNames" + rowid).val().toString();
  487. if (Participant != "") {
  488. ParticipantsCount = Participant.split(',');
  489. for (var i = 0; i < ParticipantsCount.length; i++) {
  490. Participants += "|" + ParticipantsCount[i];
  491. }
  492. if (Participants != "")
  493. Participants += "|";
  494. }
  495. var branchesLength = $(".li_branches" + rowid).length;
  496. if (branchesLength > 0) {
  497. for (i = 1; i <= branchesLength; i++) {
  498. Participant = $(".li_branches" + rowid).find("#BrachId" + i).val().toString();
  499. if (Participant != "") {
  500. ParticipantsCount = Participant.split(',');
  501. for (var j = 0; j < ParticipantsCount.length; j++) {
  502. Participants += "|" + ParticipantsCount[j];
  503. }
  504. if (Participants != "")
  505. Participants += "|";
  506. }
  507. }
  508. }
  509. var Term = params.term != undefined ? params.term : "";
  510. var sessionid = session.replace('#', '');
  511. if ($("#txt_Rate" + rowid).val() != 0 || $("#txt_Rate" + rowid).val() != "") {
  512. if (instance.selectedids == "") {
  513. instance.selectedids = $("#hf_branchlen" + rowid).val().toString();
  514. }
  515. else {
  516. instance.selectedids = selectedids + ',' + $("#hf_branchlen" + rowid).val();
  517. }
  518. }
  519. var TaxId = $(".taxesid" + rowid).val();
  520. if (TaxId > 0) {
  521. Unibase.Apps.Transact.Managers.TaxManager.Instance().getBranch(TaxId).then(function (response) {
  522. var res = response[i].result;
  523. var editbranche = '';
  524. for (var i = 0; i < res.length; i++) {
  525. editbranche += res[i].BranchId + ',';
  526. }
  527. instance.editbranches = editbranche.slice(0, -1);
  528. });
  529. if (selectedids != "" && selectedids != undefined) {
  530. selectedids = selectedids.replace(/\|/g, ",");
  531. instance.editbranches += ',' + selectedids;
  532. }
  533. else {
  534. instance.editbranches;
  535. }
  536. }
  537. var ColumnNames = '';
  538. if ($(".taxesid" + rowid).val() == 0) {
  539. ColumnNames = selectedids;
  540. }
  541. else {
  542. ColumnNames = instance.editbranches;
  543. }
  544. var postDataObj = {
  545. DocPropertyId: 0,
  546. ColumnName: ColumnNames,
  547. FormPropertyId: 0,
  548. Value: "",
  549. bindedData: Participants,
  550. authToken: sessionid,
  551. term: Term,
  552. };
  553. return JSON.stringify(postDataObj);
  554. },
  555. beforeSend: function (xhr) {
  556. if (userinfo !== undefined && userinfo !== null) {
  557. xhr.setRequestHeader("Authorization", "Basic " + userinfo.sessionId);
  558. xhr.setRequestHeader('geoposition', userinfo.latd + ':' + userinfo.lgId);
  559. }
  560. },
  561. processResults: function (data) {
  562. if (data.result != null)
  563. data.result = JSON.parse(data.result);
  564. if (document.getElementsByClassName('li_branches' + rowid).length > 0) {
  565. $(".txtPortalNames" + rowid).removeClass('Active');
  566. }
  567. return {
  568. results: jQuery.map(data.result, function (item) {
  569. return {
  570. id: item.Value,
  571. text: item.DisplayText,
  572. addlInfo: item.addlData
  573. };
  574. })
  575. };
  576. },
  577. },
  578. escapeMarkup: function (m) {
  579. return m;
  580. },
  581. templateResult: function (item) { return item.text; },
  582. templateSelection: function (item) { return item.text; },
  583. });
  584. $("#txt_PortalNames" + rowid).on("select2:unselect", function (e) {
  585. var result = e.params.data;
  586. if (document.getElementsByClassName("Active").length <= 0) {
  587. if (Number(result.id) != 0) {
  588. instance.selectData.push({
  589. text: result.text,
  590. id: result.id
  591. });
  592. var Participants = "";
  593. var Participant = "";
  594. var ParticipantsCount = new Array();
  595. $(".txtPortalNames" + rowid).addClass('Active');
  596. var branchesLength = $(".li_branches" + rowid).length;
  597. if (branchesLength > 0) {
  598. for (i = 1; i <= branchesLength; i++) {
  599. Participant = $(".li_branches" + rowid).find("#BrachId" + i).val().toString();
  600. if (Participant != "") {
  601. ParticipantsCount = Participant.split(',');
  602. for (var j = 0; j < ParticipantsCount.length; j++) {
  603. if (result.id != ParticipantsCount[j])
  604. Participants += "," + ParticipantsCount[j];
  605. }
  606. if (Participants != "")
  607. Participants += ",";
  608. $(".li_branches" + rowid).find("#BrachId" + i).val(Participants);
  609. }
  610. }
  611. }
  612. }
  613. }
  614. });
  615. jQuery("#txt_PortalNames" + rowid).val(Ids).trigger('change');
  616. });
  617. });
  618. }
  619. AddEmptyBranchrow(rowid, lilen) {
  620. var instance = this;
  621. var updateguid;
  622. $(".div_branchlist" + rowid).removeClass('hidden');
  623. $(".txtPortalNames" + rowid).removeClass('Active');
  624. var branchid = $("#txt_PortalNames" + rowid).val().toString();
  625. var ledgerid = $("#hfAccountName" + rowid).val();
  626. if ((branchid == "" || branchid == "0" || branchid == "undefined" || branchid == null) && (ledgerid == "" || ledgerid == "0" || ledgerid == "undefined" || ledgerid == null)) {
  627. var errormsg = $(".bizgaze_FormErrorMessages").attr('id');
  628. $("#txt_PortalNames" + rowid).addClass('required');
  629. $('#txtAccountName' + rowid).addClass('required');
  630. MessageHelper.Instance().showError("Branch Name and Account Name cannot be empty", errormsg);
  631. return false;
  632. }
  633. if (branchid == "" || branchid == "0" || branchid == "undefined" || branchid == null) {
  634. var errormsg = $(".bizgaze_FormErrorMessages").attr('id');
  635. $("#txt_PortalNames" + rowid).addClass('required');
  636. MessageHelper.Instance().showError("Branch Name cannot be empty", errormsg);
  637. return false;
  638. }
  639. if (ledgerid == "" || ledgerid == "0" || ledgerid == "undefined" || ledgerid == null) {
  640. var errormsg = $(".bizgaze_FormErrorMessages").attr('id');
  641. $('#txtAccountName' + rowid).addClass('required');
  642. MessageHelper.Instance().showError("Account Name cannot be empty", errormsg);
  643. return false;
  644. }
  645. if (document.getElementsByClassName('li_branches' + rowid + ' Last_Checked ').length > 0) {
  646. if ($('.li_branches' + rowid).hasClass('Last_Checked')) {
  647. updateguid = $('#hf_updateguid' + rowid).val();
  648. }
  649. else {
  650. updateguid;
  651. }
  652. var branchid = $('#txt_PortalNames' + rowid).val().toString();
  653. var portalname = $.map($('#txt_PortalNames' + rowid + ' option:selected'), function (el, i) {
  654. return $(el).text();
  655. });
  656. var portals = $('.txtPortalNames' + rowid).text(portalname.join("|"));
  657. var Branchnames = portals[0].innerHTML;
  658. $("#hfAccountName" + rowid).val();
  659. var accountno = $("#txtAccountName" + rowid).val();
  660. var accountname = $('#txtAccountName' + rowid + ' option:selected').text();
  661. var a = document.getElementsByClassName('Last_Checked')[0].id;
  662. if ($(".taxesid" + rowid).val() == 0) {
  663. this.selectedids += ',' + branchid;
  664. }
  665. else {
  666. this.editbranches += ',' + branchid;
  667. }
  668. if (branchid != "" && accountno != 0) {
  669. $('#' + a).find(".Brachid").val(branchid);
  670. $('#' + a).find(".LedgerId").val(accountno);
  671. $('#' + a).find(".div_branchnames").text(Branchnames);
  672. $('#' + a).find(".div_ledgernames").text(accountname);
  673. }
  674. else {
  675. var errormsg = $(".bizgaze_FormErrorMessages").attr('id');
  676. MessageHelper.Instance().showError("Mandatory Fields are Missing", errormsg);
  677. return false;
  678. }
  679. $("#txt_PortalNames" + rowid).text('');
  680. $("#txtAccountName" + rowid).text('');
  681. $("#txt_PortalNames" + rowid).val(0);
  682. $("#txtAccountName" + rowid).val(0);
  683. $('#hf_updateguid' + rowid).val(updateguid);
  684. $('#' + a).removeClass('Last_Checked');
  685. }
  686. else {
  687. let lilen = $("#ul_brancheslist" + rowid).children().length;
  688. var emptyBranchRow = {
  689. taxid: 0,
  690. ledgerid: 0,
  691. ledgername: "",
  692. branchid: 0,
  693. branchname: "",
  694. branchwiseledgerid: 0,
  695. updateguid: ""
  696. };
  697. instance.AddPortalAccName(lilen, emptyBranchRow, rowid);
  698. }
  699. }
  700. AddPortalAccName(lilen, row, rowid) {
  701. $(".txtPortalNames" + rowid).removeClass('Active');
  702. var Html = "";
  703. if (row.taxid == 0) {
  704. row.branchid = $("#txt_PortalNames" + rowid).val().toString();
  705. row.ledgerid = $("#hfAccountName" + rowid).val();
  706. var portalname = $.map($('#txt_PortalNames' + rowid + ' option:selected'), function (el, i) {
  707. return $(el).text();
  708. });
  709. var portals = $('.txtPortalNames' + rowid).text(portalname.join("|"));
  710. if (row.branchid != "") {
  711. var Branchnames = portals[0].innerHTML;
  712. }
  713. var branchid = row.branchid;
  714. row.branchname = Branchnames;
  715. row.ledgername = $('#txtAccountName' + rowid + ' option:selected').text();
  716. row.branchwiseledgerid = $('#hf_branchwiseledger' + lilen).val();
  717. row.taxid = $('#hf_taxid').val();
  718. row.updateguid = $('#hf_updateguid' + rowid).val();
  719. Html = '<li class="list-group-item list-group-item-row li_branches' + rowid + '" id="li_branchledger_' + lilen + '_' + rowid + '">' +
  720. '<input type="hidden" id="hf_branchlen' + rowid + '" value = "' + branchid + '"/> ' +
  721. '<div class="row" id="div_Branchledger' + rowid + '" >' +
  722. '<input type="hidden" id="hf_row" value="' + rowid + '">' +
  723. '<input type="hidden" id="hf_taxid" class="taxesid' + rowid + '" value = "' + row.taxid + '"/> ' +
  724. '<input type="hidden" id="hf_updateguid ' + rowid + '" class="updateguid' + rowid + '" value = "' + row.updateguid + '"/> ' +
  725. '<input type="hidden" id="hf_branchwiseledger' + lilen + '" class="branchwiseledgerid' + lilen + '" value = "' + row.branchwiseledgerid + '"/> ' +
  726. '<input type="hidden" id="BrachId' + lilen + '" class="Brachid" value="' + row.branchid + '">' +
  727. '<input type="hidden" id="LedgerId' + lilen + '" class="LedgerId" value="' + row.ledgerid + '">' +
  728. '<div id="div_branchnames' + lilen + '"class="col-sm-5 pull-left div_branchnames branchnames' + rowid + 'div_branch' + lilen + '">' + row.branchname + '</div>' +
  729. '<div id="div_ledgernames' + lilen + '"class="col-sm-5 pull-right div_ledgernames ledgernames' + rowid + ' div_ledgernames' + lilen + '">' + row.ledgername + '</div>' +
  730. '<a id="liEdit" class="pl-10" style="text-decoration: underline;list-style: none; cursor: pointer; float: right; color: Blue;" onclick="Bizgaze.Forms.Controls.Tax.Instance().BranchWiseLedgerEdit(' + lilen + ',' + rowid + ',' + '\'' + row.updateguid + '\'' + ');">Edit</a>' +
  731. '</div></li>';
  732. $("#hf_branchlen" + rowid).val(branchid);
  733. if (row.ledgerid == "" || row.branchid == "") {
  734. var errormsg = $(".bizgaze_FormErrorMessages").attr('id');
  735. $('#txtAccountName' + rowid).addClass('required');
  736. $("#txt_PortalNames" + rowid).addClass('required');
  737. MessageHelper.Instance().showError("Mandatory Fields are Missing", errormsg);
  738. return false;
  739. }
  740. else {
  741. $(".txtPortalNames" + rowid).text("");
  742. $(".selected_AccountName").text("");
  743. $('.BranchesList' + rowid).append(Html);
  744. $('#txtAccountName' + rowid).removeClass('required');
  745. $("#txt_PortalNames" + rowid).removeClass('required');
  746. }
  747. }
  748. else {
  749. for (var i = 0; i < row.length; i++) {
  750. let lilen = $("#ul_brancheslist" + rowid).children().length;
  751. Html = '<li class="list-group-item list-group-item-row li_branches' + rowid + '" id="li_branchledger_' + lilen + '_' + rowid + '">' +
  752. '<input type="hidden" id="hf_branchlen' + rowid + '" value = "' + row[i].branchid + '"/> ' +
  753. '<div class="row" id="div_Branchledger' + rowid + '">' +
  754. '<input type="hidden" id="hf_row" value="' + rowid + '">' +
  755. '<input type="hidden" id="hf_taxid" class="taxesid' + rowid + '" value = "' + row[i].taxid + '"/> ' +
  756. '<input type="hidden" id="hf_updateguid' + rowid + '" class="updateguid' + rowid + '" value = "' + row[i].updateguid + '"/> ' +
  757. '<input type="hidden" id="hf_branchwiseledger' + lilen + '" class"branchwiseledgerid' + lilen + '" value = "' + row[i].branchwiseledgerid + '"/> ' +
  758. '<input type="hidden" id="BrachId' + lilen + '" class="Brachid" value="' + row[i].branchid + '">' +
  759. '<input type="hidden" id="LedgerId' + lilen + '" class="LedgerId" value="' + row[i].ledgerid + '">' +
  760. '<div id="div_branchnames' + lilen + '"class="col-sm-5 pull-left div_branchnames branchnames' + rowid + 'div_branch' + lilen + '">' + row[i].branchname + '</div>' +
  761. '<div id="div_ledgernames' + lilen + '"class="col-sm-5 pull-right div_ledgernames ledgernames' + rowid + ' div_ledgernames' + lilen + '">' + row[i].ledgername + '</div>' +
  762. '<a id="liEdit" class="pl-10" style="text-decoration: underline;list-style: none; cursor: pointer; float: right; color: Blue;" onclick="Bizgaze.Forms.Controls.Tax.Instance().BranchWiseLedgerEdit(' + lilen + ',' + rowid + ',' + '\'' + row[i].updateguid + '\'' + ');">Edit</a>' +
  763. '</div></li>';
  764. $("#hf_branchlen" + rowid).val(row[i].branchid);
  765. $("#hf_branchwiseledger" + lilen).val(row[i].branchwiseledgerid);
  766. if (row[i].branchid == "" || row[i].ledgerid == "") {
  767. var errormsg = $(".bizgaze_FormErrorMessages").attr('id');
  768. $(".txtPortalNames" + rowid).text();
  769. $(".selected_AccountName").text();
  770. $('.BranchesList' + rowid).append('');
  771. $('#txtAccountName' + rowid).addClass('required');
  772. $("#txt_PortalNames" + rowid).addClass('required');
  773. MessageHelper.Instance().showError("Mandatory Fields are Missing", errormsg);
  774. return false;
  775. }
  776. else {
  777. $(".txtPortalNames" + rowid).text("");
  778. $(".selected_AccountName").text("");
  779. $('.BranchesList' + rowid).append(Html);
  780. $('#txtAccountName' + rowid).removeClass('required');
  781. $("#txt_PortalNames" + rowid).removeClass('required');
  782. }
  783. }
  784. }
  785. this.BranchIds.push(row.branchid);
  786. }
  787. BranchWiseLedgerEdit(lilen, rowid, row) {
  788. var instance = this;
  789. var branchwiseledgerid = $('.branchwiseledgerid' + rowid).val();
  790. var updateguid = row;
  791. var ledgername;
  792. var ledgerid;
  793. var branchids;
  794. var branchnames;
  795. var editbranchwiseledgers;
  796. $('.Last_Checked').removeClass('Last_Checked');
  797. $('#li_branchledger_' + lilen + '_' + rowid).addClass("Last_Checked");
  798. if (updateguid != "undefined" || updateguid != 0) {
  799. ledgername = document.getElementsByClassName("ledgernames" + rowid + " div_ledgernames" + lilen + "")[0].textContent;
  800. }
  801. else {
  802. ledgername = $('#div_ledgernames' + lilen).text();
  803. }
  804. branchnames = document.getElementsByClassName("branchnames" + rowid + "div_branch" + lilen + "")[0].textContent;
  805. ledgerid = $('#LedgerId' + lilen).val();
  806. branchids = $('#li_branchledger_' + lilen + '_' + rowid).find("#BrachId" + lilen).val();
  807. editbranchwiseledgers = $('#li_branchledger_' + lilen + '_' + rowid).find("#hf_branchwiseledgerid" + lilen).val();
  808. var branchid = branchids.toString().replace(/,/g, '|');
  809. var Autocompleteledger = new Option(ledgername, ledgerid.toString(), true);
  810. if ($("#txtAccountName" + rowid + " option[value = '" + ledgerid.toString() + "']").length > 0) {
  811. }
  812. else
  813. $('#txtAccountName' + rowid).append(Autocompleteledger);
  814. $('#txtAccountName' + rowid).val(ledgerid).change();
  815. instance.branchids1 = branchid;
  816. instance.getbranches(branchid, rowid);
  817. }
  818. getTaxes() {
  819. var instance = this;
  820. var taxList = new Array();
  821. var lilen = 0;
  822. var isbranchchecked = 0;
  823. $(".item-row").each(function () {
  824. if ($(this).find(".taxgrouptaxcode").val() != undefined) {
  825. var errormsg = $(".bizgaze_FormErrorMessages").attr('id');
  826. var length = $(this).find("#hf_len").val();
  827. lilen = $("#ul_brancheslist" + length).children().length;
  828. if (($("#chK_PortalWiseLedger" + length).prop('checked') == true) && lilen < 2) {
  829. isbranchchecked = 1;
  830. MessageHelper.Instance().showError("Branch Name and Account Name is not added", errormsg);
  831. return false;
  832. }
  833. var brach = new Array();
  834. brach.push({
  835. BranchId: 0,
  836. LedgerId: 0,
  837. UpdateGuid: "",
  838. });
  839. var isbranchwiseledger = false;
  840. var tcspannoavail = false;
  841. var _datetimehelper = Unibase.Platform.Helpers.DateTimeHelper.Instance();
  842. var _fromdate = _datetimehelper.formatServerDate($("#eTax_txt_FromDate" + length).val());
  843. var _todate = _datetimehelper.formatServerDate($("#eTax_txt_ToDate" + length).val());
  844. if ($("#rbtntcspancust" + length).prop('checked') == true) {
  845. tcspannoavail = true;
  846. }
  847. if ($("#chK_PortalWiseLedger" + length).prop('checked') == true) {
  848. var ledgerid = $("#hfAccountName" + length).val();
  849. var ledgernames = $(".selected_AccountName" + length).text();
  850. brach = instance.BranchArraySave($(this), length);
  851. isbranchwiseledger = true;
  852. }
  853. else {
  854. var id1 = $(this).find('.AccountName').val();
  855. var ledgernames = $(this).find('.selectedAccountName').text();
  856. branchwiseledgerid = Number($(this).find('#hf_branchwiseledger' + length).val());
  857. updateguid = $(this).find('#hf_updateguid' + length).val();
  858. }
  859. var taxId = Number($(this).find("#hf_taxid").val());
  860. var Rate = Number($(this).find(".taxRate").val());
  861. var TaxCodeId = Number($(this).find(".taxgrouptaxcode").val());
  862. var taxCodeName = $(this).find(".selectedTaxCode").text();
  863. var DisplayText = $(this).find(".txtDisplayTextTwo").val();
  864. var DisplayPercent = $(this).find(".txtDisplayPercentTwo").val();
  865. var AmountPercent = Number($(this).find(".txtAppliedOnPercent").val());
  866. var Amountpercent = 100;
  867. var parentId = Number($(this).find(".ddlParent").val());
  868. var TaxRateType = Number($(this).find('.ddlRateType').val());
  869. var LedgerId = Number($(this).find('.AccountName').val());
  870. var branchwiseledgerid = $(this).find('#hf_branchwiseledger' + length).val();
  871. if (branchwiseledgerid == "undefined" || branchwiseledgerid == NaN) {
  872. branchwiseledgerid = 0;
  873. }
  874. else {
  875. branchwiseledgerid = Number(branchwiseledgerid);
  876. }
  877. var updateguid = $(this).find('#hf_updateguid' + length).val();
  878. if (taxCodeName != null) {
  879. taxList.push({
  880. TaxId: taxId, ParentId: parentId, TaxCodeId: TaxCodeId, TaxRateTypeId: TaxRateType,
  881. Rate: Rate, DisplayText: DisplayText, DisplayPercent: DisplayPercent, AmountPercent: Amountpercent,
  882. BranchList: brach,
  883. LedgerId: LedgerId,
  884. LedgerName: ledgernames,
  885. BranchWiseLedgerId: branchwiseledgerid,
  886. UpdateGuid: updateguid,
  887. IsBranchWiseLedger: isbranchwiseledger,
  888. TCSPANNoAvail: tcspannoavail,
  889. _FromDate: _fromdate,
  890. _ToDate: _todate,
  891. });
  892. }
  893. }
  894. });
  895. if (isbranchchecked == 1 && lilen < 2) {
  896. return false;
  897. }
  898. else
  899. return taxList;
  900. }
  901. BranchArraySave(element, len) {
  902. var BranchList = new Array();
  903. $('.div_branchlist' + len).each(function () {
  904. var line = 1;
  905. $(this).find('li').each(function () {
  906. var row = $("#hf_row").val();
  907. var Branches = $(this).find('.Brachid').val();
  908. if (Branches != undefined) {
  909. Branches = Branches.toString().replace(/\|/g, ",");
  910. Branches = Branches.toString().split(",");
  911. var branchwiseledgerid = $(this).find('#hf_branchwiseledger' + line).val();
  912. var Branchewiseledgers = branchwiseledgerid.toString().split("|");
  913. if (branchwiseledgerid == "undefined" || branchwiseledgerid == NaN || branchwiseledgerid == undefined) {
  914. branchwiseledgerid = 0;
  915. }
  916. for (var i = 0; i < Branches.length; i++) {
  917. if (Branchewiseledgers[i] == "undefined" || Number(Branchewiseledgers[i]) == NaN || Branchewiseledgers[i] == undefined) {
  918. Branchewiseledgers[i] = "0";
  919. }
  920. var BranchItem = {
  921. BranchId: Number(Branches[i]),
  922. LedgerId: Number($(this).find('.LedgerId').val()),
  923. UpdateGuid: $(this).find('#hf_updateguid' + len).val(),
  924. BranchWiseLedgerId: Number(Branchewiseledgers[i])
  925. };
  926. BranchList.push(BranchItem);
  927. }
  928. ;
  929. line += 1;
  930. }
  931. });
  932. });
  933. return BranchList;
  934. }
  935. bind(element) {
  936. var instance = this;
  937. element.find(".delete").on('click', function () {
  938. $(this).parents('.item-row:last').remove();
  939. instance.refreshtax();
  940. });
  941. }
  942. refreshtax() {
  943. var instance = this;
  944. var rowid = $('.item-row').length;
  945. var count = 0;
  946. $(".item-row").each(function () {
  947. if (count <= rowid) {
  948. $(instance).find('.taxs-row').text('Tax -' + count);
  949. $(instance).find("#div_moreoptions").attr('id', 'div_moreoptions' + count);
  950. $(instance).find(".a_ShowMore").attr('id', 'moreOptions' + count);
  951. $(instance).find(".ShowMore").attr('id', 'ShowMore_' + count);
  952. $(instance).find(".taxRate").attr('id', 'hf_Rate' + count);
  953. $(instance).find(".selectedTaxCode").attr('id', 'txt_TaxCode' + count);
  954. $(instance).find(".taxgrouptaxcode").attr('id', 'hf_TaxCode' + count);
  955. $(instance).find('.selectedAccountName').attr('id', 'txtAccountName' + count);
  956. $(instance).find('.AccountName').attr('id', 'hfAccountName' + count);
  957. $(instance).find('.selected_AccountName').attr('id', 'txt_AccountName' + count);
  958. $(instance).find('.Account_Name').attr('id', 'hf_AccountName' + count);
  959. $(instance).find('#txt_PortalNames').attr('id', 'txtPortalNames' + count);
  960. count += 1;
  961. }
  962. var element = $(instance);
  963. instance.taxcodeautocomplete(element, '');
  964. instance.ledgerautocomplete(element, '');
  965. instance.ledgersautocomplete(element, '');
  966. });
  967. }
  968. taxcodeautocomplete(element, len) {
  969. var instance = this;
  970. var txtTaxCode = element.find(".selectedTaxCode").attr('id');
  971. var hfTaxCode = element.find(".taxgrouptaxcode").attr('id');
  972. var id = 0;
  973. var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/tax/gettaxcodesbystatusid';
  974. AutoCompleteHelper.getHelper().Create("#" + txtTaxCode, "#" + hfTaxCode, url, function (response) {
  975. var data = response;
  976. if (data.id == "0")
  977. data.text = "Select Tax Code";
  978. if (data.id == "-1" || data.id == -1)
  979. data.text = "Create New";
  980. if (data.text == "Create New") {
  981. $('#hidden_selectedTaxCode').val(txtTaxCode);
  982. var FormUniqueId = 'Bizgaze_Extension_Transact_Tax Code_App_Tax Code_CreateForm';
  983. var AppConfigurationUniqueId = 'Bizgaze_Extension_Transact_TaxCode_AppConfiguration_CreateTaxCode';
  984. var taxCodeId = 0;
  985. var taxCodeName = '';
  986. instance.length = len;
  987. $("#" + txtTaxCode).text('');
  988. $("#" + hfTaxCode).val(0);
  989. var successobj = {
  990. CallBack: function (id) {
  991. Unibase.Apps.Transact.Managers.TaxManager.Instance().getTaxCodeById(id).then(function (response) {
  992. var rowid = Bizgaze.Forms.Controls.Tax.Instance().length;
  993. Bizgaze.Forms.Controls.Tax.Instance().bindTaxCode(rowid, response.result.TaxCodeId, response.result.TaxCodeName);
  994. });
  995. },
  996. Parameters: null,
  997. };
  998. Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(FormUniqueId).then(function (response) {
  999. var FormId = response.result.FormId;
  1000. var formviewerObj = {
  1001. FormId: FormId,
  1002. AppConfigurationId: 0,
  1003. Pk_Value: 0,
  1004. PortletWidgetId: 0,
  1005. OnSuccess: successobj,
  1006. OnFail: null,
  1007. OnLoad: null,
  1008. };
  1009. Unibase.Platform.Forms.Components.FormViewer.instance.init(formviewerObj);
  1010. });
  1011. }
  1012. });
  1013. }
  1014. bindTaxCode(rowid, taxcodeid, taxcodename) {
  1015. var selectedOptions = new Option(taxcodename, taxcodeid, true);
  1016. $("#txt_TaxCode" + rowid).append(selectedOptions).trigger('change');
  1017. $("#txt_TaxCode" + rowid).val(taxcodeid);
  1018. }
  1019. bindLedger(rowid, ledgerid, ledgername) {
  1020. var selectedOptions = new Option(ledgername, ledgerid, true);
  1021. $("#txt_AccountName" + rowid).append(selectedOptions).trigger('change');
  1022. $("#txt_AccountName" + rowid).val(ledgerid);
  1023. }
  1024. bindLedgers(rowid, ledgerid, ledgername) {
  1025. var selectedOptions = new Option(ledgername, ledgerid, true);
  1026. $("#txtAccountName" + rowid).append(selectedOptions).trigger('change');
  1027. $("#txtAccountName" + rowid).val(ledgerid);
  1028. }
  1029. ledgerautocomplete(element, len) {
  1030. var instance = this;
  1031. var txtAccountName = element.find(".selectedAccountName").attr('id');
  1032. var hfAccountName = element.find(".AccountName").attr('id');
  1033. var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgerautocomplete';
  1034. AutoCompleteHelper.getHelper().Create("#" + txtAccountName, "#" + hfAccountName, url, function (response) {
  1035. if (response.id == "-1" || response.id == -1)
  1036. response.text = "Create New";
  1037. if (response.text == "Create New") {
  1038. $('#hidden_selectedAccountName').val(txtAccountName);
  1039. var FormUniqueId = "Bizgaze_Extension_Transact_Ledgers_App_Ledgers_CreateForm";
  1040. var AppConfigurationUnique = "Bizgaze_Extension_Transact_Ledgers_AppConfiguration_CreateLedgers";
  1041. instance.length = len;
  1042. $("#" + txtAccountName).text('');
  1043. $("#" + hfAccountName).val(0);
  1044. Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(FormUniqueId).then(function (response) {
  1045. var FormId = response.result.FormId;
  1046. var successobj = {
  1047. CallBack: function (id) {
  1048. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLedgerById(id).then(function (response) {
  1049. var rowid = Bizgaze.Forms.Controls.Tax.Instance().length;
  1050. Bizgaze.Forms.Controls.Tax.Instance().bindLedger(rowid, response.result.LedgerId, response.result.LedgerName);
  1051. });
  1052. },
  1053. Parameters: null,
  1054. };
  1055. instance.fileCacheHelper.loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  1056. var formviewerObj = {
  1057. FormId: response.result.FormId,
  1058. AppConfigurationId: 0,
  1059. Pk_Value: 0,
  1060. PortletWidgetId: 0,
  1061. OnSuccess: successobj,
  1062. OnFail: null,
  1063. OnLoad: null,
  1064. };
  1065. Unibase.Platform.Forms.Components.FormViewer.instance.init(formviewerObj);
  1066. });
  1067. });
  1068. }
  1069. });
  1070. }
  1071. ledgersautocomplete(element, len) {
  1072. var instance = this;
  1073. var id = 0;
  1074. var txt_AccountName = element.find(".selected_AccountName").attr('id');
  1075. var hf_AccountName = element.find(".Account_Name").attr('id');
  1076. var txtTaxCode = element.find(".selectedTaxCode").attr('id');
  1077. var hfTaxCode = element.find(".taxgrouptaxcode").attr('id');
  1078. var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgerautocomplete';
  1079. AutoCompleteHelper.getHelper().Create("#" + txt_AccountName, "#" + hf_AccountName, url, function (response) {
  1080. var data = response;
  1081. if (data.id == "0")
  1082. data.text = "Select Account Name";
  1083. if (data.id == "-1" || data.id == -1)
  1084. data.text = "Create New";
  1085. if (data.text == "Create New") {
  1086. $('#hidden_selectedTaxCode').val(txt_AccountName);
  1087. var FormUniqueId = "Bizgaze_Extension_Transact_Ledgers_App_Ledgers_CreateForm";
  1088. var AppConfigurationUnique = "Bizgaze_Extension_Transact_Ledgers_AppConfiguration_CreateLedgers";
  1089. instance.length = len;
  1090. $("#" + txt_AccountName).text('');
  1091. $("#" + hf_AccountName).val(0);
  1092. Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(FormUniqueId).then(function (response) {
  1093. var FormId = response.result.FormId;
  1094. var successobj = {
  1095. CallBack: function (id) {
  1096. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLedgerById(id).then(function (response) {
  1097. var rowid = Bizgaze.Forms.Controls.Tax.Instance().length;
  1098. Bizgaze.Forms.Controls.Tax.Instance().bindLedgers(rowid, response.result.LedgerId, response.result.LedgerName);
  1099. });
  1100. },
  1101. Parameters: null,
  1102. };
  1103. instance.fileCacheHelper.loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  1104. var formviewerObj = {
  1105. FormId: response.result.FormId,
  1106. AppConfigurationId: 0,
  1107. Pk_Value: 0,
  1108. PortletWidgetId: 0,
  1109. OnSuccess: successobj,
  1110. OnFail: null,
  1111. OnLoad: null,
  1112. };
  1113. Unibase.Platform.Forms.Components.FormViewer.instance.init(formviewerObj);
  1114. });
  1115. });
  1116. }
  1117. });
  1118. }
  1119. static Instance() {
  1120. if (this._instance === undefined)
  1121. this._instance = new Tax();
  1122. return this._instance;
  1123. }
  1124. }
  1125. Controls.Tax = Tax;
  1126. })(Controls = Forms.Controls || (Forms.Controls = {}));
  1127. })(Forms = Bizgaze.Forms || (Bizgaze.Forms = {}));
  1128. })(Bizgaze || (Bizgaze = {}));