Built files from Bizgaze WebServer
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

findandmatchreconciliation.js 53KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. var _pagesize = 20;
  2. var pageIndex = 0;
  3. var subtotal = 0;
  4. var outbyvalue = 0;
  5. var reconciledata = [];
  6. var Bizgaze;
  7. (function (Bizgaze) {
  8. let Apps;
  9. (function (Apps) {
  10. let Transact;
  11. (function (Transact) {
  12. let Components;
  13. (function (Components) {
  14. class FindandMatch extends Unibase.Platform.Core.BaseComponent {
  15. constructor() {
  16. super(...arguments);
  17. this._idscount = 0;
  18. this._oldId = "";
  19. this._Unchkidscount = 0;
  20. this._checkidscount = 0;
  21. this._ContainerId = "";
  22. }
  23. cssFiles() {
  24. return ['tenants/themes/compact/css/coupons.css'];
  25. }
  26. jsFiles() {
  27. return ["platform/tag/managers/tagmanager.js",
  28. "platform/apps/managers/appmanager.js",
  29. "apps/transact/components/bankreconciliation/findandmatchreconciliation.js",
  30. "platform/analytics/components/reportviewer/reportviewer.js",
  31. "platform/analytics/components/templateviewer/templateviewer.js",
  32. "platform/analytics/components/reportviewer/linkreport.js"];
  33. }
  34. html(recdetailsid, containerid) {
  35. const instance = this;
  36. const ledgerCard = $(`#bankLedgerCard_${recdetailsid}`);
  37. const id = +ledgerCard.find('#hf_brsjournalid').val();
  38. instance.journalId = id;
  39. instance.ledgerid = +ledgerCard.find('#hf_brsledgerid').val();
  40. instance.bankamount = +ledgerCard.find('#hf_brsbankbalid').val();
  41. instance.ledgeramount = +ledgerCard.find('#hf_brsledgerbalid').val();
  42. instance.journalno = ledgerCard.find('#hf_brsjournalnumberid').val();
  43. instance.bankReconcileId = +ledgerCard.find('#hf_brsbankrecid').val();
  44. instance.reconciliationDetailsId = +ledgerCard.find('#hf_brsrecdetailsid').val();
  45. instance.accountname = ledgerCard.find('#hf_brsaccountname').val();
  46. instance.journaldate = ledgerCard.find('#hf_brsjournaldate').val();
  47. instance.action = ledgerCard.find('#hf_brsledgeractions').val();
  48. instance.recdetailsid = recdetailsid;
  49. subtotal = 0;
  50. outbyvalue = 0;
  51. reconciledata = [];
  52. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._ContainerId = containerid;
  53. if (instance.action == "spent") {
  54. instance.bankamount = -1 * Number(instance.bankamount);
  55. }
  56. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Bankamount = instance.bankamount;
  57. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/widgets/managers/interfaces/iwidgetmanager.js", null);
  58. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/widgets/managers/widgetmanager.js", null);
  59. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/core/helpers/propertyhelper/propertyhelper.js", null);
  60. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/core/helpers/token/tokenhelper.js", null);
  61. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/analytics/components/reportviewer/reportviewer.js", null);
  62. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/analytics/components/reportviewer/_reportviewer.js", null);
  63. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/compact/js/navigation/navigationhelper.js", null);
  64. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadCssFile("tenants/themes/compact/css/coupons.css", null);
  65. let html = `<div class="bg-white modal-header find-match-header pa-10 model_find_and_match_div"><strong class="text-dark">Find & Match</strong>
  66. </div>
  67. <div data-simplebar class="simple-scroll-bar modal-body find-match-body" id="CardViewer_modal_` + id + `">
  68. <span class="findandmatch_errormsg text-danger text-center" id="findandmatch_errormsg" ></span>
  69. <div class="row">
  70. <div class="cardbody rounded-4 col-6">
  71. <div class="div_TransactionReconciliation_` + id + `" id="div_TransactionReconciliation_` + id + `">
  72. <div id="div_TransactionReconciliation_details_` + id + `" class="card shadow-hover mb-0">
  73. <div class="card-header card-header-action border-bottom-0 px-20">
  74. <strong>
  75. <span class="biz-highlight-bg-color" id="hf-div_TransactionReconciliation_details_` + id + `">Transaction To Reconcile</span>
  76. </strong>
  77. </div>
  78. <div class="card-body py-0">
  79. <div class="row">
  80. <div class="col-md-12">
  81. <ul class="list-group list-group-flush px-0" id="div_TransactionReconciliation_details_` + id + `_col1">
  82. <li class="Twocolumn-listgroup-1-item Twocolumn-listgroup-1-addeditem li-0 px-0 py-2 detailProperty_` + id + ` widget_details_item` + id + `_col1" style="border-top: 1px solid rgb(243, 243, 243); font-size: 14px;">
  83. <div class="d-flex justify-content-between align-items-center">
  84. <span class="col-5 pl-0">` + instance.journalno + `</span>
  85. <span class="text-overflow text-right d-none d-md-block" title="ledgeramount">` + instance.ledgeramount + `</span>
  86. </div>
  87. </li>
  88. <li class="Twocolumn-listgroup-1-item Twocolumn-listgroup-1-addeditem li-1 px-0 py-2 detailProperty_` + id + ` widget_details_item` + id + `_col1" style="border-top: 1px solid rgb(243, 243, 243); font-size: 14px;">
  89. <div class="d-flex justify-content-between align-items-center">
  90. <span class="col-5 pl-0">` + instance.accountname + `</span>
  91. <span class="text-overflow text-right text-danger d-none d-md-block" title="Spent">` + instance.action + `</span>
  92. </div>
  93. </li>
  94. <li class="Twocolumn-listgroup-1-item Twocolumn-listgroup-1-addeditem li-1 px-0 py-2 detailProperty_` + id + ` widget_details_item` + id + `_col1" style="border-top: 1px solid rgb(243, 243, 243); font-size: 14px;">
  95. <div class="d-flex justify-content-between align-items-center">
  96. <span class="col-5 pl-0">` + instance.journaldate + `</span>
  97. <span class="text-overflow text-right text-danger d-none d-md-block" title="journaldate"></span>
  98. </div>
  99. </li>
  100. </ul>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. <div class="cardbody rounded-4 col-6">
  108. <div class="div_SelectedTransaction_` + id + `" id="div_SelectedTransaction_` + id + `">
  109. <div id="div_details_SelectedTransaction_` + id + `" class="card shadow-hover mb-0">
  110. <div class="card-header card-header-action border-bottom-0 px-20">
  111. <strong>
  112. <span class="biz-highlight-bg-color" id="hf-SelectedTransaction_` + id + `">Selected Transaction</span>
  113. </strong>
  114. </div>
  115. <div class="card-body py-0">
  116. <div class="row">
  117. <div class="col-md-12">
  118. <ul class="list-group list-group-flush px-0" id="div_details_` + id + `_col1">
  119. <li class="Twocolumn-listgroup-1-item Twocolumn-listgroup-1-addeditem li-0 px-0 py-2 detailProperty_` + id + ` widget_details_item` + id + `_col1" style="border-top: 1px solid rgb(243, 243, 243); font-size: 14px;">
  120. <div class="d-flex justify-content-between align-items-center">
  121. <span class="col-5 pl-0">SubTotal</span>
  122. <span class="text-overflow text-right d-none d-md-block subtotal-Value" title="subtotal-Value" id="subtotal_` + id + `">` + 0 + `</span>
  123. </div>
  124. </li>
  125. <li class="Twocolumn-listgroup-1-item Twocolumn-listgroup-1-addeditem li-1 px-0 py-2 detailProperty_` + id + ` widget_details_item` + id + `_col1" style="border-top: 1px solid rgb(243, 243, 243); font-size: 14px;">
  126. <div class="d-flex justify-content-between align-items-center">
  127. <span class="col-5 pl-0">As Per Bank Statement</span>
  128. <span class="text-overflow text-right d-none d-md-block" title="Personnel Costs">` + instance.bankamount + `</span>
  129. </div>
  130. </li>
  131. <li class="Twocolumn-listgroup-1-item Twocolumn-listgroup-1-addeditem li-1 px-0 py-2 detailProperty_` + id + ` widget_details_item` + id + `_col1" style="border-top: 1px solid rgb(243, 243, 243); font-size: 14px;">
  132. <div class="d-flex justify-content-between align-items-center">
  133. <span class="col-5 pl-0">Total Is Out By</span>
  134. <span class="text-overflow text-right text-danger d-none d-md-block outbyvalue_amount" title="Personnel Costs" id="outbyvalue_` + id + `"></span>
  135. </div>
  136. </li>
  137. </ul>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </br>
  146. <span class="spn_bankrecon_errormsg text-danger text-center" id="spn_cpnaprl_errormsg" ></span>
  147. <div class="card">
  148. <input type="text" id="txt_accountname_refno_Org_search" class="form-control text-control required" style="width:100%;" placeholder = "Search" data-placeholder="Search"/>
  149. <input type="hidden" id="hf_Coupon_Org_search" class="hf_txt_CouponSubmission_Org_search' form-control value-control" data-isdynamic="true"/>
  150. </div>
  151. <div class="card">
  152. <div class="table-wrap card simple-scroll-bar bg-white-s bg-white-removed templateviewer-body" style="height:100% !important">
  153. <div class="table-responsive tableFixHead dropdown-menu-scrollbar">
  154. <table class="table table-hover table-bordered mb-0 tblreconciledata" id="tblreconciledata">
  155. <thead>
  156. <tr>
  157. <th>Date</th>
  158. <th>Name</th>
  159. <th>Reference</th>
  160. <th>ChequeNo</th>
  161. <th>Spent</th>
  162. <th>Received</th>
  163. </tr>
  164. </thead>
  165. <tbody id="tblReconcile">
  166. <tr class="ReconciliationDetails-list-items"> </tr>
  167. </tbody>
  168. </table>
  169. </div>
  170. <div class="d-flex justify-content-center">
  171. <button class="btn btn-sm btn-outline-primary mt-15 mb-15 text-center btn_reconciliationlist_load_more__modal_bizgaze_BRS" id="btn_reconciliationlist_load_more__modal_bizgaze_BRS"><u>View All</u></button>
  172. </div>
  173. </div>
  174. </div></div>
  175. <div class="bg-white modal-footer find-match-footer pa-10">
  176. <a class="btn btn-light btn-sm btn-center mr-auto" id="btnClose">Close</a>
  177. <a class="btn btn-primary btn-center btn-sm text-white" id="btnSave">Save</a>
  178. <input type="hidden"id="bankreconciliationfromdate" />
  179. <input type="hidden"id="bankreconciliationtodate" />
  180. </div>`;
  181. return html;
  182. }
  183. load(recdetailsid, containerid, callback) {
  184. const instance = this;
  185. pageIndex = 0;
  186. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._oldId = "";
  187. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._idscount = 0;
  188. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Unchkidscount = 0;
  189. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._checkidscount = 0;
  190. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  191. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getBankReconcileById(instance.bankReconcileId).then(function (response) {
  192. if (response.result != null) {
  193. $("#bankreconciliationfromdate").val(response.result.FromDate);
  194. $("#bankreconciliationtodate").val(response.result.ToDate);
  195. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().BankRecFromDate = response.result.FromDate;
  196. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().BankRecToDate = response.result.ToDate;
  197. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().getLedgerJournalEntryDetails(instance.ledgerid, 0, Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Bankamount, instance.ledgeramount, null, containerid, instance.bankReconcileId, recdetailsid);
  198. }
  199. });
  200. });
  201. $('#btn_reconciliationlist_load_more__modal_bizgaze_BRS').click(function () {
  202. pageIndex++;
  203. var term = $("#txt_accountname_refno_Org_search").val();
  204. if (term == "" || term == null || term == undefined) {
  205. term = "null";
  206. }
  207. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().getLedgerJournalEntryDetails(instance.ledgerid, pageIndex, Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Bankamount, instance.ledgeramount, term, containerid, instance.bankReconcileId, recdetailsid, true);
  208. });
  209. $("#btnClose").click(function () {
  210. instance.navigationHelper.closePopUp();
  211. });
  212. $("#txt_accountname_refno_Org_search").on("input", function () {
  213. var term = $(this).val();
  214. if (term == "" || term == null || term == undefined) {
  215. term = "null";
  216. }
  217. pageIndex = 0;
  218. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._oldId = "";
  219. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._idscount = 0;
  220. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Unchkidscount = 0;
  221. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._checkidscount = 0;
  222. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().getLedgerJournalEntryDetails(instance.ledgerid, pageIndex, instance.bankamount, instance.ledgeramount, term, containerid, instance.bankReconcileId, recdetailsid);
  223. });
  224. $("#btnSave").click(function () {
  225. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().saveAllselectedReconcilition(containerid, instance.journalId, Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Bankamount, reconciledata, instance.ledgerid);
  226. });
  227. }
  228. init() {
  229. }
  230. getFindAndMatchDetails(id) {
  231. var html = '';
  232. }
  233. getLedgerJournalEntryDetails(ledgerid, page, BankAmount, journalAmount, term, containerid, BankReconcileId, ReconciliationDetailsId, isViewAll) {
  234. if (ledgerid != 0) {
  235. var fromDate = "";
  236. var toDate = "";
  237. var cf_fromDate = Unibase.Platform.Helpers.NavigationHelper.commonFilter_FromDate;
  238. var cf_toDate = Unibase.Platform.Helpers.NavigationHelper.commonFilter_ToDate;
  239. let row = 0;
  240. if (cf_fromDate != null && cf_toDate != null) {
  241. fromDate = cf_fromDate.toString();
  242. toDate = cf_toDate.toString();
  243. }
  244. else {
  245. fromDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(new Date(Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate()), "YYYY/MM/DD");
  246. toDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(new Date(Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate()), "YYYY/MM/DD");
  247. }
  248. $(".ReconciliationDetails-list-items").remove();
  249. if (term !== "" && term !== "null") {
  250. $(".ReconciliationDetails-item-active").remove();
  251. }
  252. var Fdate = moment(fromDate).format("YYYY-MM-DD");
  253. var Tdate = moment(toDate).format("YYYY-MM-DD");
  254. var BRCFromDate = moment(Bizgaze.Apps.Transact.Components.FindandMatch.Instance().BankRecFromDate).format("YYYY-MM-DD");
  255. var BRCToDate = moment(Bizgaze.Apps.Transact.Components.FindandMatch.Instance().BankRecToDate).format("YYYY-MM-DD");
  256. BankAmount = BankAmount;
  257. journalAmount = journalAmount;
  258. var UpdateAmount = Number(journalAmount);
  259. var showPortalGroupWise = true;
  260. if (page == 0) {
  261. row = 5;
  262. }
  263. else {
  264. row = 0;
  265. }
  266. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  267. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getReconciliationData(ledgerid, BRCFromDate, BRCToDate, showPortalGroupWise, page, term, row).then(function (response) {
  268. if (page == 0) {
  269. $("#checkAll").prop('checked', false);
  270. }
  271. $("#btn_reconciliationlist_load_more__modal_bizgaze_BRS").addClass("hidden");
  272. var totalRecords = 0;
  273. $('._btnreconciliation_div').addClass('hidden');
  274. if (response.result._rows.length != 0) {
  275. $("#btn_reconciliationlist_load_more__modal_bizgaze_BRS").removeClass("hidden");
  276. var _datetimehelper = Unibase.Platform.Helpers.DateTimeHelper.Instance();
  277. var Stagestatusname = '';
  278. var finalhtml = '';
  279. totalRecords = response.result._totalRecords;
  280. if (row <= 5 && Number(totalRecords) <= 5) {
  281. $("#btn_reconciliationlist_load_more__modal_bizgaze_BRS").addClass("hidden");
  282. }
  283. if (row == 0 && Number(totalRecords) == 0) {
  284. $("#btn_reconciliationlist_load_more__modal_bizgaze_BRS").addClass("hidden");
  285. }
  286. for (var i = 0; i < response.result._rows.length; i++) {
  287. var data = response.result._rows[i];
  288. var JournalId = Number(data.Cells[0]);
  289. var JournalNo = data.Cells[1];
  290. var JournalDate = moment(data.Cells[2], "DD-MM-YYYY").format("DD/MM/YYYY");
  291. if (JournalDate == "Invalid date") {
  292. JournalDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().serverDateformat(data.Cells[2]);
  293. }
  294. var ChequeNo = data.Cells[3];
  295. var Credit = data.Cells[4];
  296. var Debit = data.Cells[5];
  297. var AccountName = "";
  298. var JournalStatusId = data.Cells[7];
  299. var LedgerID = Number(data.Cells[13]);
  300. var FirstLedgerID = Number(data.Cells[20]);
  301. var SecLedgerID = Number(data.Cells[21]);
  302. if (LedgerID == FirstLedgerID) {
  303. AccountName = data.Cells[14];
  304. }
  305. else if (LedgerID == SecLedgerID) {
  306. AccountName = data.Cells[9];
  307. }
  308. var JournalEntryID = data.Cells[19];
  309. var html = '';
  310. var index = Number(i);
  311. var j = Number(JournalId);
  312. html += '<tr class="ReconciliationDetails-list-items ReconciliationDetails-item-active value-row li-' + j + '">' +
  313. '<input type="hidden"id="recledgerid" value="' + JournalId + '" />' +
  314. '<input type="hidden"id="bankreconcileid" value="' + BankReconcileId + '" />' +
  315. '<input type="hidden"id="bankreconciliationdetailsid" value="' + ReconciliationDetailsId + '" />' +
  316. '<input type="hidden"id="JournalEntryId" value="' + JournalEntryID + '" />' +
  317. '<input type="hidden"id="bankbalanceamount" value="' + BankAmount + '" />' +
  318. '<input type="hidden"id="ledgerid" value="' + LedgerID + '" />';
  319. if (j == 0) {
  320. html += '<td id="JournalDate_"><div class="" > <input type="checkbox" id = "transactionDate_checkbox_" name = "transactionRadio" class="chkReconciliaionStatus " checked="checked" > <label class="custom-control-label" for= "transactionDate_checkbox_">' + JournalDate + '</label></div></td>';
  321. }
  322. else {
  323. html += '<td id="JournalDate_' + JournalId + '"><div class="" > <input type="checkbox" id = "transactionDate_checkbox_' + JournalId + '" name = "transactionRadio" class="chkReconciliaionStatus " > <label class="custom-control-label" for= "transactionDate_checkbox_' + JournalId + '" value=>' + JournalDate + '</label></div></td>';
  324. }
  325. html += '<td id="AccountName_' + JournalId + '">' + AccountName + '</td>' +
  326. '<td id="JournalNo_' + JournalId + '">' + JournalNo + '</td>' +
  327. '<td id="ChequeNo_' + JournalId + '">' + ChequeNo + '</td>' +
  328. '<td id="Credit_' + JournalId + '">' + Credit + '</td>' +
  329. '<input type="hidden"id="spentamount" value="' + Credit + '" />' +
  330. '<input type="hidden"id="receivedamount" value="' + Debit + '" />' +
  331. '<td id="Debit_' + JournalId + '">' + Debit + '</td>';
  332. html += '</tr>';
  333. $("#tblreconciledata tbody").append(html);
  334. }
  335. }
  336. if (isViewAll) {
  337. $("#btn_reconciliationlist_load_more__modal_bizgaze_BRS").addClass("hidden");
  338. }
  339. $('input:checkbox').click(function () {
  340. var id = $(this).attr('id');
  341. var element = $(this).closest("tr");
  342. var jid = $(element).find("#recledgerid").val();
  343. var isselected = $(element).find('.chkReconciliaionStatus').is(':checked');
  344. if (isselected == false) {
  345. $("#subtotal_" + Number(jid)).text("0");
  346. subtotal = 0;
  347. }
  348. var jId = $(element).find("#recledgerid").val();
  349. var LId = $(element).find("#ledgerid").val();
  350. var amount = 0;
  351. var Sp_amount = 0;
  352. var Rd_amount = 0;
  353. var spentamount = $(element).find("#spentamount").val();
  354. if (Number(spentamount) != 0) {
  355. var Credit = $("#Credit_" + jId).text();
  356. amount = -1 * Number(Credit);
  357. Sp_amount = amount;
  358. }
  359. var receivedamount = $(element).find("#receivedamount").val();
  360. if (Number(receivedamount) != 0) {
  361. var Debit = $("#Debit_" + jId).text();
  362. amount = Number(Debit);
  363. Rd_amount = Number(Debit);
  364. }
  365. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().savereconcile($(this).closest("tr"), amount, containerid, Number(Sp_amount), Number(Rd_amount));
  366. });
  367. });
  368. });
  369. }
  370. }
  371. savereconcile(element, selectedamount, containerid, SP_Amt, Rd_amt) {
  372. var Reconcile = new Array();
  373. var isSelected = $(element).find('.chkReconciliaionStatus').is(':checked');
  374. var reconcileno = 0;
  375. var journalId = $(element).find("#recledgerid").val();
  376. var LedgerId = $(element).find("#ledgerid").val();
  377. var bankreconcileid = $(element).find("#bankreconcileid").val();
  378. var bankreconciliationdetailsid = $(element).find("#bankreconciliationdetailsid").val();
  379. var bankamount = Number($(element).find("#bankbalanceamount").val());
  380. var JournalEntryId = $(element).find("#JournalEntryId").val();
  381. var todayDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  382. var serverdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDate(todayDate, "DD/MM/YYYY");
  383. subtotal = Number(subtotal);
  384. if (isSelected) {
  385. reconcileno = 1;
  386. if (Number(SP_Amt) != 0) {
  387. subtotal = Number(subtotal) - (Number(selectedamount));
  388. bankamount = -1 * bankamount;
  389. }
  390. else if (Number(Rd_amt) != 0) {
  391. subtotal = Number(subtotal) + Number(selectedamount);
  392. bankamount = 1 * bankamount;
  393. }
  394. if (Number(bankamount) == Number(subtotal)) {
  395. $(".subtotal-Value").text(subtotal);
  396. outbyvalue = bankamount - subtotal;
  397. if (Number(outbyvalue == 0) && Number(SP_Amt) != 0) {
  398. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Bankamount = -1 * Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Bankamount;
  399. }
  400. $(".outbyvalue_amount").text(outbyvalue);
  401. reconciledata.push({
  402. JournalId: journalId,
  403. ReconcileNo: reconcileno,
  404. ReconcileDate: serverdate,
  405. LedgerId: LedgerId,
  406. ReconciliationDetailsId: bankreconciliationdetailsid,
  407. BankReconcileId: bankreconcileid,
  408. JournalEntryId: JournalEntryId
  409. });
  410. }
  411. else {
  412. subtotal = 0;
  413. outbyvalue = 0;
  414. $(".subtotal-Value").text(subtotal);
  415. $(".outbyvalue_amount").text(outbyvalue);
  416. $("#subtotal_" + journalId).text(subtotal);
  417. $("#outbyvalue_" + journalId).text(outbyvalue);
  418. MessageHelper.Instance().showError('Please selected valid amount', 'findandmatch_errormsg');
  419. $(".chkReconciliaionStatus").prop('checked', false);
  420. $("#transactionDate_checkbox_" + journalId).prop('checked', false);
  421. if (Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._oldId != "") {
  422. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._idscount = 1;
  423. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._checkidscount = 0;
  424. Bizgaze.Apps.Transact.Components.FindandMatch.Instance()._Unchkidscount = 0;
  425. }
  426. }
  427. }
  428. var postData = reconciledata;
  429. }
  430. confirmreconcile(id, containerid, ledgerid, bankamount, ledgeramount, journalno, accountname, journaldate, BankReconcileId, JournalentryId, ReconcileDetailsId) {
  431. if (Number(id) != 0 && Number(bankamount) == Number(ledgeramount)) {
  432. var journalId = Number(id);
  433. var LedgerId = Number(ledgerid);
  434. var bankreconciliationdetailsid = Number(ReconcileDetailsId);
  435. var bankreconcileid = Number(BankReconcileId);
  436. var JEntryId = Number(JournalentryId);
  437. var todayDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  438. var serverdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDate(todayDate, "DD/MM/YYYY");
  439. var Reconcile = new Array();
  440. var reconcileno = 1;
  441. Reconcile.push({
  442. JournalId: journalId,
  443. ReconcileNo: reconcileno,
  444. ReconcileDate: serverdate,
  445. LedgerId: LedgerId,
  446. ReconciliationDetailsId: bankreconciliationdetailsid,
  447. BankReconcileId: bankreconcileid,
  448. JournalEntryId: JEntryId
  449. });
  450. var postData = Reconcile;
  451. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  452. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().saveReconcile(postData).then(function (response) {
  453. if (response.result != null) {
  454. MessageHelper.Instance().showSuccess(response.message, '');
  455. $(`#reportRefreshBtn_${containerid}`).trigger('click');
  456. }
  457. else {
  458. MessageHelper.Instance().showError(response.message, 'findandmatch_errormsg');
  459. }
  460. });
  461. });
  462. }
  463. else {
  464. MessageHelper.Instance().showError("selected amount is (Bank Amount:" + Number(bankamount) + " Ledger Amount :" + Number(ledgeramount) + ") not matched go through the find and match or create new record", 'reconcile_errormsg');
  465. }
  466. }
  467. RefreshReportsAndWidgets(Portletwidgetid, cid, ledgerid) {
  468. Unibase.Platform.Widgets.Managers.WidgetManager.Instance().getPortletWidget(Portletwidgetid).then(function (widresponse) {
  469. if (widresponse.result != null) {
  470. var WidgetID = Number(widresponse.result.WidgetId);
  471. var portletwidgetid = Number(widresponse.result.PortletWidgetId);
  472. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().linkReport(WidgetID, portletwidgetid, cid, ledgerid);
  473. }
  474. });
  475. }
  476. confirm_And_Action_Hide_and_Show(id, containerid, ledgerid, bankamount, ledgeramount, journalno, accountname, journaldate, BankFormatId, action, Value) {
  477. if (Value.trim() == 'actions') {
  478. $(".div_subdata_" + id).removeClass("hidden");
  479. }
  480. else {
  481. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().confirmreconcile(id, containerid, ledgerid, bankamount, ledgeramount, journalno, accountname, journaldate, BankFormatId, 0, 0);
  482. }
  483. }
  484. linkReport(widgetid, portletwidgetid, cid, ledgerid) {
  485. var instance = this;
  486. Unibase.Platform.Widgets.Managers.WidgetManager.Instance().getKPIWidget(widgetid).then(function (response) {
  487. var res = response.result;
  488. if (res != null) {
  489. let containerid = cid;
  490. var rv_obj = Unibase.Platform.Analytics.Components.ReportViewer.Instance();
  491. let ReplaceText = [];
  492. ReplaceText.push({
  493. Key: "ledgerid",
  494. Value: String(ledgerid),
  495. ExpOp: Unibase.Platform.Core.Enums.ExpressionOperator.Equals,
  496. });
  497. instance.inputParameters = ReplaceText;
  498. var rv_obj = Unibase.Platform.Analytics.Components.ReportViewer.Instance();
  499. rv_obj.inputParameters = instance.inputParameters;
  500. Unibase.Platform.Analytics.Components.ReportViewer.Instance().getReportData(res.LinkReportId, containerid, null, null);
  501. }
  502. });
  503. }
  504. saveAllselectedReconcilition(containerid, journalId, bankamount, postData, LedgerId) {
  505. const instance = this;
  506. if (Number(bankamount) >= Number(subtotal)) {
  507. if (Number(bankamount) == Number(subtotal)) {
  508. $("#div_brs_" + journalId).addClass("hidden");
  509. MessageHelper.Instance().showSuccess("amount matched sucessfully", 'findandmatch_errormsg');
  510. subtotal = 0;
  511. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  512. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().saveReconcile(postData).then(function (response) {
  513. if (response.result != null) {
  514. instance.navigationHelper.closePopUp();
  515. MessageHelper.Instance().showSuccess(response.message, '');
  516. const reconcileContainerId = instance.navigationHelper.getLastContainerId();
  517. $(`#reportRefreshBtn_${reconcileContainerId}`).trigger('click');
  518. }
  519. else {
  520. MessageHelper.Instance().showError(response.message, 'findandmatch_errormsg');
  521. }
  522. });
  523. });
  524. }
  525. else {
  526. alert("Amount Not Matched");
  527. }
  528. }
  529. else {
  530. MessageHelper.Instance().showError("Amount is greater than the bank amount", 'findandmatch_errormsg');
  531. }
  532. }
  533. _dynaminReportClose() {
  534. var detail_instance = Unibase.Themes.Compact.Components.Details.Instance();
  535. var containerid = $("._bizgaze_detail_container:visible").attr("id");
  536. var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  537. var portletid = detail_instance.unibase_core_activeportletid;
  538. detail_instance.loadWidgets(_installedAppId, portletid, "#" + containerid + "");
  539. }
  540. ledgerreconcile(id, containerid, ledgerid, ledgeramount, journalno) {
  541. if (Number(id) != 0) {
  542. var journalId = Number(id);
  543. var LedgerId = Number(ledgerid);
  544. var ReconcileDate = $("#txt_RecconileDate_" + journalId).val();
  545. var JDate = $("#txt_JournalDate_" + journalId).val();
  546. var JournalDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate(JDate);
  547. var todayDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  548. var serverdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate(ReconcileDate);
  549. var Reconcile = new Array();
  550. var reconcileno = 1;
  551. Reconcile.push({
  552. JournalId: journalId,
  553. ReconcileNo: reconcileno,
  554. ReconcileDate: serverdate,
  555. LedgerId: LedgerId,
  556. JournalEntryId: 0,
  557. JournalNo: journalno,
  558. JournalDate: JournalDate
  559. });
  560. var postData = Reconcile;
  561. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  562. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().saveLedgerReconcile(postData).then(function (response) {
  563. if (response.result != null) {
  564. MessageHelper.Instance().showSuccess(response.message, 'findandmatch_errormsg');
  565. var cid = $('.' + containerid).attr("id");
  566. var _ReportUniqueid = "Reportid_" + cid;
  567. var _Reportid = $("#" + _ReportUniqueid).text();
  568. Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportById(Number(_Reportid)).then(function (refresponse) {
  569. if (refresponse.result != null) {
  570. Unibase.Platform.Analytics.Components.ReportViewer.Instance().getReportData(refresponse.result.ReportId, containerid, null, null);
  571. }
  572. });
  573. }
  574. else {
  575. MessageHelper.Instance().showError(response.message, 'findandmatch_errormsg');
  576. }
  577. });
  578. });
  579. }
  580. }
  581. getDateDetails(e, id) {
  582. e.stopPropagation();
  583. $("#txt_RecconileDate_" + id).daterangepicker({
  584. locale: {
  585. format: 'DD/MM/YYYY',
  586. },
  587. singleDatePicker: true,
  588. showDropdowns: true,
  589. minYear: 1901,
  590. maxDate: new Date(2050, 11, 31)
  591. });
  592. }
  593. AutoReconcileByAllMatchedData() {
  594. var MatchedDate = [];
  595. $(".btn_BrsRecActions:not(#btn_Bankconfirm_0):visible").each(function (i, e) {
  596. MatchedDate.push($(e));
  597. });
  598. if (MatchedDate.length >= 1) {
  599. bootbox.confirm("Are you sure ! You want to reconcile all matched data ? ", function (result) {
  600. if (result) {
  601. var Reconcile = new Array();
  602. for (var i = 0; i < MatchedDate.length; i++) {
  603. var confirmdata = MatchedDate[i];
  604. var journalId = Number($(confirmdata).find('#hf_brsjournalid').val());
  605. var cId = $(confirmdata).find('#hf_brscid').val();
  606. var LedgerId = Number($(confirmdata).find('#hf_brsledgerid').val());
  607. var bankreconciliationdetailsid = Number($(confirmdata).find('#hf_brsrecdetailsid').val());
  608. var bankreconcileid = Number($(confirmdata).find('#hf_brsbankrecid').val());
  609. var bankamount = Number($(confirmdata).find('#hf_brsbankbalid').val());
  610. var ledgeramount = Number($(confirmdata).find('#hf_brsledgerbalid').val());
  611. var JEntryId = Number(0);
  612. var todayDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  613. var serverdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDate(todayDate, "DD/MM/YYYY");
  614. var reconcileno = 1;
  615. if (Number(journalId) != 0 && Number(bankamount) == Number(ledgeramount)) {
  616. Reconcile.push({
  617. JournalId: journalId,
  618. ReconcileNo: reconcileno,
  619. ReconcileDate: serverdate,
  620. LedgerId: LedgerId,
  621. ReconciliationDetailsId: bankreconciliationdetailsid,
  622. BankReconcileId: bankreconcileid,
  623. JournalEntryId: JEntryId
  624. });
  625. }
  626. }
  627. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  628. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().saveReconcile(Reconcile).then(function (response) {
  629. if (response.result != null) {
  630. MessageHelper.Instance().showSuccess(response.message, 'findandmatch_errormsg');
  631. var cid = $('.' + cId).attr("id");
  632. var number = cid.match(/\d+/);
  633. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().RefreshReportsAndWidgets(Number(number[0]), cid, LedgerId);
  634. }
  635. else {
  636. const containerId = $('._bizgaze_popup_container:visible').attr('id');
  637. $(`#div_errors_reportviewer_${containerId}`).addClass('form-error-message');
  638. MessageHelper.Instance().showError(response.message, `div_errors_reportviewer_${containerId}`);
  639. }
  640. });
  641. });
  642. }
  643. });
  644. }
  645. else {
  646. const containerId = $('._bizgaze_popup_container:visible').attr('id');
  647. $(`#div_errors_reportviewer_${containerId}`).addClass('form-error-message');
  648. MessageHelper.Instance().showError('matched records not found', `div_errors_reportviewer_${containerId}`);
  649. }
  650. }
  651. unReconcile(id, containerid, ledgerid, bankamount, ledgeramount, journalno, accountname, journaldate, BankReconcileId, JournalentryId, ReconcileDetailsId) {
  652. if (Number(JournalentryId) != 0) {
  653. var journalId = Number(id);
  654. var LedgerId = Number(ledgerid);
  655. var bankreconciliationdetailsid = Number(ReconcileDetailsId);
  656. var bankreconcileid = Number(BankReconcileId);
  657. var JEntryId = Number(JournalentryId);
  658. var todayDate = "0001-01-01 00:00:00";
  659. var serverdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDate(todayDate, "DD/MM/YYYY");
  660. var Reconcile = new Array();
  661. var reconcileno = 0;
  662. Reconcile.push({
  663. JournalId: journalId,
  664. ReconcileNo: reconcileno,
  665. ReconcileDate: serverdate,
  666. LedgerId: LedgerId,
  667. ReconciliationDetailsId: bankreconciliationdetailsid,
  668. BankReconcileId: bankreconcileid,
  669. JournalEntryId: JEntryId
  670. });
  671. var postData = Reconcile;
  672. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  673. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().saveReconcile(postData).then(function (response) {
  674. if (response.result != null) {
  675. MessageHelper.Instance().showSuccess(response.message, 'findandmatch_errormsg');
  676. var cid = $('.' + containerid).attr("id");
  677. var number = cid.match(/\d+/);
  678. Bizgaze.Apps.Transact.Components.FindandMatch.Instance().RefreshReportsAndWidgets(Number(number[0]), cid, LedgerId);
  679. }
  680. else {
  681. MessageHelper.Instance().showError(response.message, 'findandmatch_errormsg');
  682. }
  683. });
  684. });
  685. }
  686. else {
  687. MessageHelper.Instance().showError("selected amount is (Bank Amount:" + Number(bankamount) + " Ledger Amount :" + Number(ledgeramount) + ") not matched go through the find and match or create new record", 'reconcile_errormsg');
  688. }
  689. }
  690. static Instance() {
  691. if (this._instance === undefined)
  692. this._instance = new FindandMatch();
  693. return this._instance;
  694. }
  695. }
  696. Components.FindandMatch = FindandMatch;
  697. })(Components = Transact.Components || (Transact.Components = {}));
  698. })(Transact = Apps.Transact || (Apps.Transact = {}));
  699. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  700. })(Bizgaze || (Bizgaze = {}));