Built files from Bizgaze WebServer
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

gstsubmission.js 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Integrations;
  6. (function (Integrations) {
  7. let GST;
  8. (function (GST) {
  9. let Components;
  10. (function (Components) {
  11. class GSTSubmission extends Unibase.Platform.Core.BaseComponent {
  12. jsFiles() {
  13. return ['apps/integrations/gst/managers/gstmanager.js'];
  14. }
  15. cssFiles() {
  16. return [];
  17. }
  18. html() {
  19. const html = `<div id="gst_Otp" class="modal fade hide"><div class="modal-dialog"><div class="modal-content"><div class="modal-header mt-2 mb-2"><h5 class="modal-title pull-left">OTP</h5><button type="button" class="close pull-right" data-dismiss="modal" aria-hidden="true">&times;</button></div><div class="modal-body" id="div_modalbody"><div class="mb-10"><p class="lbl_Otp">Please Enter The OTP</p></div><div class="floating-label-form-group mb-2"><input class="form-control" id="txt_Otp" placeholder="Enter OTP" type="text"></div></div><div class="modal-footer mb-2" style="display:block"><button type="button" onclick="" class="btn btn-primary pull-right" id="btn_VerifyOtp">Ok</button></div></div></div></div>`;
  20. $("#_bizgaze_modal").append(html);
  21. $(".bootbox-input").keypress(function (e) {
  22. if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
  23. MessageHelper.Instance().showSuccess("Numbers only allowed", 'div_validationsummary');
  24. return false;
  25. }
  26. });
  27. return html;
  28. }
  29. load() {
  30. }
  31. saveHSNGSTRtoGSTPortal(taxclassificationId, gstNo, InvoiceTypeId) {
  32. var instance = this;
  33. let containerId = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  34. let b2bCheckboxes = $(containerId).find('input.b2binvoices');
  35. var invoiceids = $(containerId).find('.b2binvoices:checkbox:checked').map(function () {
  36. return $(this).val();
  37. }).get();
  38. console.log(invoiceids);
  39. $(containerId).find("#selectedinvoices_check").click(function () {
  40. var checkBoxes = b2bCheckboxes.find('input.b2binvoices');
  41. checkBoxes.prop("checked", !checkBoxes.prop("checked"));
  42. });
  43. b2bCheckboxes.click(function () {
  44. if (!$(this).is(':checked')) {
  45. $("#selectedinvoices_check").prop('checked', false);
  46. }
  47. else if (b2bCheckboxes.is(":checked")) {
  48. $("#selectedinvoices_check").prop('checked', true);
  49. }
  50. });
  51. bootbox.prompt("Please Enter OTP", function (result) {
  52. if (result) {
  53. instance._saveHSNGSTRtoGSTPortal(taxclassificationId, result, gstNo, InvoiceTypeId);
  54. $(".bootbox-input").keypress(function (e) {
  55. if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
  56. MessageHelper.Instance().showSuccess("Numbers Only Allowed", 'div_validationsummary');
  57. return false;
  58. }
  59. });
  60. }
  61. });
  62. }
  63. _saveHSNGSTRtoGSTPortal(taxclassificationId, otp, gstNo, InvoiceTypeId) {
  64. var gstIntegratorId = 0;
  65. var instance = this;
  66. var integratorId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstintegratorid").Value;
  67. var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value;
  68. var fromDate = moment(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_fromdate").Value).format("YYYY-MM-DD");
  69. var toDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_todate").Value;
  70. var formattedfromDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate(toDate);
  71. toDate = moment(formattedfromDate).format("YYYY-MM-DD");
  72. var gstNo = [];
  73. $('.invoiceschk_selected:checked').each(function () {
  74. var isChecked = $(this).prop("checked");
  75. if (isChecked) {
  76. gstNo.push($(this).parents('.body-tr').find(".fromgstno").text());
  77. }
  78. });
  79. gstNo = gstNo.filter((value, index) => gstNo.indexOf(value) == index).toString();
  80. var rdmNo = moment.utc(new Date()).local().format("YYYYMMDDHHmmss");
  81. const rates = $('.invoiceschk_selected:checkbox:checked').map(function () {
  82. return $(this).closest('.body-tr').find('.gst-rate').text();
  83. }).get();
  84. const supplytype = $('.invoiceschk_selected:checkbox:checked').map(function () {
  85. return $(this).closest('.body-tr').find('.gst-supplytype').text();
  86. }).get();
  87. const pos = $('.invoiceschk_selected:checkbox:checked').map(function () {
  88. return $(this).closest('.body-tr').find('.gst-pos').text();
  89. }).get();
  90. const hsnCodes = $('.invoiceschk_selected:checkbox:checked').map(function () {
  91. return $(this).closest('.body-tr').find('.gst-hsncodes').text();
  92. }).get();
  93. const Uom = $('.invoiceschk_selected:checkbox:checked').map(function () {
  94. return $(this).closest('.body-tr').find('.gst-uom').text();
  95. }).get();
  96. var dynamicfilters = [{}];
  97. var OTP = otp.replace(' ', '');
  98. var taxClassificationData = [{
  99. TaxclassificationId: taxclassificationId,
  100. InvoiceId: [0],
  101. Rates: rates,
  102. SupplyType: supplytype,
  103. Pos: pos,
  104. HSNCodes: hsnCodes,
  105. InvoiceTypeId: InvoiceTypeId,
  106. UoM: Uom
  107. }];
  108. var postData = {
  109. TaxClassificationData: taxClassificationData,
  110. RtPeriod: returnPeriod,
  111. GSTIntegratorId: integratorId,
  112. ToDate: toDate,
  113. FromDate: fromDate,
  114. InvoiceTypeId: 1,
  115. GstNo: gstNo,
  116. Otp: OTP
  117. };
  118. instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstmanager.js", function () {
  119. Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().saveGSTRToPortal(postData).then(function (response) {
  120. if (response.errors != null) {
  121. MessageHelper.Instance().showError(response.message, "Unibase_ValidationSummary");
  122. return false;
  123. }
  124. else {
  125. alert(response.message);
  126. var obj = Unibase.Themes.Compact.Components.Details.Instance();
  127. obj._recordId = Unibase.Themes.Compact.Components.Details.Instance()._recordId;
  128. obj._installedAppId = Unibase.Themes.Compact.Components.Details.Instance()._installedAppId;
  129. obj.loadPortlets(obj);
  130. Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true;
  131. }
  132. });
  133. });
  134. }
  135. saveGSTRtoGSTPortal(taxclassificationId, gstNo, InvoiceTypeId) {
  136. var instance = this;
  137. let containerId = $("#" + instance.navigationHelper.getLastContainerId());
  138. if (!$('input.invoiceschk_selected').is(':checked')) {
  139. const errId = $('.gst-error-msg').last().attr('id');
  140. MessageHelper.Instance().showError("Please Select One or More Records", errId);
  141. return null;
  142. }
  143. let b2bCheckboxes = containerId.find('input.invoiceschk_selected');
  144. var invoiceids = containerId.find('.invoiceschk_selected:checkbox:checked').map(function () {
  145. return $(this).val();
  146. }).get();
  147. gstNo = $(containerId).find('.fromgstno').first().text() || $(containerId).find('.fromgstno').first().val();
  148. console.log(invoiceids);
  149. containerId.find("#selectedinvoices_check").click(function () {
  150. var checkBoxes = b2bCheckboxes.find('input.invoiceschk_selected');
  151. checkBoxes.prop("checked", !checkBoxes.prop("checked"));
  152. });
  153. b2bCheckboxes.click(function () {
  154. if (!$(this).is(':checked')) {
  155. $("#selectedinvoices_check").prop('checked', false);
  156. }
  157. else if (b2bCheckboxes.is(":checked")) {
  158. $("#selectedinvoices_check").prop('checked', true);
  159. }
  160. });
  161. bootbox.prompt("Please Enter OTP", function (result) {
  162. if (result) {
  163. instance._saveGSTRtoGSTPortal(taxclassificationId, result, gstNo, InvoiceTypeId);
  164. $(".bootbox-input").keypress(function (e) {
  165. if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
  166. MessageHelper.Instance().showSuccess("Numbers only allowed", 'div_validationsummary');
  167. return false;
  168. }
  169. });
  170. }
  171. });
  172. }
  173. DeleteGstrToGSTPortal(taxclassificationId, InvoiceTypeId) {
  174. var instance = this;
  175. let containerId = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  176. let b2bCheckboxes = $(containerId).find('input.invoiceschk_selected');
  177. var invoiceids = $(containerId).find('.invoiceschk_selected:checkbox:checked').map(function () {
  178. return $(this).val();
  179. }).get();
  180. $(containerId).find("#selectedinvoices_check").click(function () {
  181. var checkBoxes = b2bCheckboxes.find('input.invoiceschk_selected');
  182. checkBoxes.prop("checked", !checkBoxes.prop("checked"));
  183. });
  184. b2bCheckboxes.click(function () {
  185. if (!$(this).is(':checked')) {
  186. $("#selectedinvoices_check").prop('checked', false);
  187. }
  188. else if (b2bCheckboxes.is(":checked")) {
  189. $("#selectedinvoices_check").prop('checked', true);
  190. }
  191. });
  192. bootbox.confirm("Are you sure you want to delete", function (result) {
  193. if (result) {
  194. instance._deleteGSTRtoGSTPortal(taxclassificationId, result, InvoiceTypeId);
  195. }
  196. });
  197. }
  198. getSelectedInvoices() {
  199. $(".invoices_check");
  200. }
  201. generateOtp(gstNo) {
  202. var gstIntegratorId = 0;
  203. var instance = this;
  204. instance.fileCacheHelper.loadJsFile("apps/integrations/gst/components/gstsubmission.js", null);
  205. instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstmanager.js", null);
  206. bootbox.confirm("Are you sure, you want to continue", function (result) {
  207. if (result == true) {
  208. if (gstNo == undefined || gstNo == "") {
  209. alert("Please select Gst No");
  210. return false;
  211. }
  212. Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().getGstDetails(gstNo).then(function (response) {
  213. if (response.status == Unibase.Data.Status.Success) {
  214. var result = response.result[0];
  215. var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value;
  216. var rdmNo = moment.utc(new Date()).local().format("YYYYMMDDHHmmss");
  217. var postData = {
  218. username: result.gstusername,
  219. requestid: "Biz-" + rdmNo,
  220. gstin: gstNo,
  221. retperiod: returnPeriod
  222. };
  223. Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().generateOtp(postData).then(function (response) {
  224. if (response.errors != null) {
  225. instance.showGSTErrorMsg(response.message);
  226. return false;
  227. }
  228. else {
  229. alert(response.message);
  230. }
  231. });
  232. }
  233. else
  234. MessageHelper.Instance().showSuccess(response.message, '');
  235. });
  236. }
  237. });
  238. }
  239. _gstShowLog(taxclassificationId) {
  240. var instance = this;
  241. var gstNo;
  242. var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value;
  243. var gstr1type = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstr1type").Value;
  244. var gstintegratorId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstintegratorid").Value;
  245. var invoiceid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_invoiceid").Value;
  246. var invoiceno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_invoiceno").Value;
  247. gstNo = Unibase.Platform.Analytics.Viewers.TableViewer.Instance().Filter.find(x => x.ParameterName == "fromgstno");
  248. if (gstNo == undefined || gstNo == "")
  249. gstNo = Unibase.Platform.Analytics.Viewers.TemplateViewer.Instance().Filter.find(x => x.ParameterName == "fromgstno");
  250. if (gstNo == undefined || gstNo == "") {
  251. alert("Please select Gst No");
  252. return false;
  253. }
  254. gstNo = gstNo.ParameterValue;
  255. var Selectedinvoiceno = [];
  256. Selectedinvoiceno.push("Invoiceno", Selectedinvoiceno);
  257. var taxClassificationData = [];
  258. taxClassificationData.push("TaxclassificationId", taxclassificationId);
  259. taxClassificationData.push("InvoiceId", Selectedinvoiceno);
  260. var postData = {
  261. TaxClassificationData: taxClassificationData,
  262. Invoiceid: invoiceid,
  263. Invoiceno: invoiceno,
  264. RtPeriod: returnPeriod,
  265. GSTIntegratorid: gstintegratorId,
  266. GSTR1type: gstr1type,
  267. FromGSTNo: gstNo,
  268. InvoiceTypeId: 1,
  269. Selectedinvoiceno: invoiceno
  270. };
  271. instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstShowLog.js", function () {
  272. });
  273. }
  274. _saveGSTRtoGSTPortal(taxclassificationId, otp, gstNo, InvoiceTypeId) {
  275. var gstIntegratorId = 0;
  276. var instance = this;
  277. var integratorId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstintegratorid").Value;
  278. var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value;
  279. var fromDate = moment(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_fromdate").Value).format("YYYY-MM-DD");
  280. var toDate = moment(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_todate").Value).format("YYYY-MM-DD");
  281. var formattedfromDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate(toDate);
  282. var rdmNo = moment.utc(new Date()).local().format("YYYYMMDDHHmmss");
  283. var invoiceids = $('.invoiceschk_selected:checkbox:checked').map(function () {
  284. var instance = this;
  285. return Number(instance.value);
  286. }).get();
  287. if (isNaN(invoiceids.length))
  288. invoiceids;
  289. if (isNaN(invoiceids.length))
  290. invoiceids.length = 0;
  291. if (invoiceids.length == null) {
  292. invoiceids.length = 0;
  293. }
  294. const rates = $('.invoiceschk_selected:checkbox:checked').map(function () {
  295. return $(this).closest('.body-tr').find('.gst-rate').text();
  296. }).get();
  297. const supplytype = $('.invoiceschk_selected:checkbox:checked').map(function () {
  298. return $(this).closest('.body-tr').find('.gst-supplytype').text();
  299. }).get();
  300. const pos = $('.invoiceschk_selected:checkbox:checked').map(function () {
  301. return $(this).closest('.body-tr').find('.gst-pos').text();
  302. }).get();
  303. const hsnCodes = $('.invoiceschk_selected:checkbox:checked').map(function () {
  304. return $(this).closest('.body-tr').find('.gst-hsncodes').text();
  305. }).get();
  306. var dynamicfilters = [{}];
  307. var OTP = otp.replace(' ', '');
  308. var taxClassificationData = [{
  309. TaxclassificationId: taxclassificationId,
  310. InvoiceId: invoiceids,
  311. Rates: rates,
  312. SupplyType: supplytype,
  313. Pos: pos,
  314. HSNCodes: hsnCodes,
  315. InvoiceTypeId: 1
  316. }];
  317. var postData = {
  318. TaxClassificationData: taxClassificationData,
  319. RtPeriod: returnPeriod,
  320. GSTIntegratorId: integratorId,
  321. ToDate: toDate,
  322. FromDate: fromDate,
  323. InvoiceTypeId: 1,
  324. GstNo: gstNo,
  325. Otp: OTP
  326. };
  327. instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstmanager.js", function () {
  328. Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().saveGSTRToPortal(postData).then(function (response) {
  329. if (response.errors != null) {
  330. instance.showGSTErrorMsg(response.message);
  331. return false;
  332. }
  333. else {
  334. MessageHelper.Instance().showSuccess(response.message, "");
  335. var obj = Unibase.Themes.Compact.Components.Details.Instance();
  336. obj._recordId = Unibase.Themes.Compact.Components.Details.Instance()._recordId;
  337. obj._installedAppId = Unibase.Themes.Compact.Components.Details.Instance()._installedAppId;
  338. obj.loadPortlets(obj);
  339. Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true;
  340. }
  341. });
  342. });
  343. }
  344. _deleteGSTRtoGSTPortal(taxclassificationId, otp, InvoiceTypeId) {
  345. var gstIntegratorId = 0;
  346. var instance = this;
  347. var integratorId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstintegratorid").Value;
  348. var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value;
  349. var fromDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_fromdate").Value;
  350. var toDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_todate").Value;
  351. var gstNo = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstinno").Value;
  352. var rdmNo = moment.utc(new Date()).local().format("YYYYMMDDHHmmss");
  353. var invoiceids = $('.invoiceschk_selected:checkbox:checked').map(function () {
  354. var instance = this;
  355. return Number(instance.value);
  356. }).get();
  357. var DeletedInvoicesData = {
  358. DeletedInvoiceIds: invoiceids
  359. };
  360. var taxClassificationData = [{
  361. TaxclassificationId: taxclassificationId,
  362. InvoiceTypeId: InvoiceTypeId,
  363. DeleteInvoices: DeletedInvoicesData
  364. }];
  365. var postData = {
  366. TaxClassificationData: taxClassificationData,
  367. RtPeriod: returnPeriod,
  368. GSTIntegratorId: integratorId,
  369. ToDate: "'2022/08/01'",
  370. FromDate: "'2022/08/01'",
  371. InvoiceTypeId: 1,
  372. GstNo: gstNo,
  373. Otp: "575757"
  374. };
  375. instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstmanager.js", function () {
  376. Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().saveGSTRToPortal(postData).then(function (response) {
  377. if (response.errors != null) {
  378. instance.showGSTErrorMsg(response.message);
  379. return false;
  380. }
  381. else {
  382. MessageHelper.Instance().showSuccess(response.message, "");
  383. var obj = Unibase.Themes.Compact.Components.Details.Instance();
  384. obj._recordId = Unibase.Themes.Compact.Components.Details.Instance()._recordId;
  385. obj._installedAppId = Unibase.Themes.Compact.Components.Details.Instance()._installedAppId;
  386. obj.loadPortlets(obj);
  387. Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true;
  388. }
  389. });
  390. });
  391. }
  392. showGSTErrorMsg(message) {
  393. const errId = $('.gst-error-msg').last().attr('id');
  394. MessageHelper.Instance().showError(message, errId);
  395. }
  396. static Instance() {
  397. if (this.instance === undefined) {
  398. this.instance = new GSTSubmission();
  399. }
  400. return this.instance;
  401. }
  402. }
  403. Components.GSTSubmission = GSTSubmission;
  404. })(Components = GST.Components || (GST.Components = {}));
  405. })(GST = Integrations.GST || (Integrations.GST = {}));
  406. })(Integrations = Apps.Integrations || (Apps.Integrations = {}));
  407. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  408. })(Bizgaze || (Bizgaze = {}));