var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Integrations; (function (Integrations) { let GST; (function (GST) { let Components; (function (Components) { class GSTSubmission extends Unibase.Platform.Core.BaseComponent { jsFiles() { return ['apps/integrations/gst/managers/gstmanager.js']; } cssFiles() { return []; } html() { const html = ``; $("#_bizgaze_modal").append(html); $(".bootbox-input").keypress(function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { MessageHelper.Instance().showSuccess("Numbers only allowed", 'div_validationsummary'); return false; } }); return html; } load() { } saveHSNGSTRtoGSTPortal(taxclassificationId, gstNo, InvoiceTypeId) { var instance = this; let containerId = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; let b2bCheckboxes = $(containerId).find('input.b2binvoices'); var invoiceids = $(containerId).find('.b2binvoices:checkbox:checked').map(function () { return $(this).val(); }).get(); console.log(invoiceids); $(containerId).find("#selectedinvoices_check").click(function () { var checkBoxes = b2bCheckboxes.find('input.b2binvoices'); checkBoxes.prop("checked", !checkBoxes.prop("checked")); }); b2bCheckboxes.click(function () { if (!$(this).is(':checked')) { $("#selectedinvoices_check").prop('checked', false); } else if (b2bCheckboxes.is(":checked")) { $("#selectedinvoices_check").prop('checked', true); } }); bootbox.prompt("Please Enter OTP", function (result) { if (result) { instance._saveHSNGSTRtoGSTPortal(taxclassificationId, result, gstNo, InvoiceTypeId); $(".bootbox-input").keypress(function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { MessageHelper.Instance().showSuccess("Numbers Only Allowed", 'div_validationsummary'); return false; } }); } }); } _saveHSNGSTRtoGSTPortal(taxclassificationId, otp, gstNo, InvoiceTypeId) { var gstIntegratorId = 0; var instance = this; var integratorId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstintegratorid").Value; var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value; 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"); var toDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_todate").Value; var formattedfromDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate(toDate); toDate = moment(formattedfromDate).format("YYYY-MM-DD"); var gstNo = []; $('.invoiceschk_selected:checked').each(function () { var isChecked = $(this).prop("checked"); if (isChecked) { gstNo.push($(this).parents('.body-tr').find(".fromgstno").text()); } }); gstNo = gstNo.filter((value, index) => gstNo.indexOf(value) == index).toString(); var rdmNo = moment.utc(new Date()).local().format("YYYYMMDDHHmmss"); const rates = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-rate').text(); }).get(); const supplytype = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-supplytype').text(); }).get(); const pos = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-pos').text(); }).get(); const hsnCodes = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-hsncodes').text(); }).get(); const Uom = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-uom').text(); }).get(); var dynamicfilters = [{}]; var OTP = otp.replace(' ', ''); var taxClassificationData = [{ TaxclassificationId: taxclassificationId, InvoiceId: [0], Rates: rates, SupplyType: supplytype, Pos: pos, HSNCodes: hsnCodes, InvoiceTypeId: InvoiceTypeId, UoM: Uom }]; var postData = { TaxClassificationData: taxClassificationData, RtPeriod: returnPeriod, GSTIntegratorId: integratorId, ToDate: toDate, FromDate: fromDate, InvoiceTypeId: 1, GstNo: gstNo, Otp: OTP }; instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstmanager.js", function () { Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().saveGSTRToPortal(postData).then(function (response) { if (response.errors != null) { MessageHelper.Instance().showError(response.message, "Unibase_ValidationSummary"); return false; } else { alert(response.message); var obj = Unibase.Themes.Compact.Components.Details.Instance(); obj._recordId = Unibase.Themes.Compact.Components.Details.Instance()._recordId; obj._installedAppId = Unibase.Themes.Compact.Components.Details.Instance()._installedAppId; obj.loadPortlets(obj); Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true; } }); }); } saveGSTRtoGSTPortal(taxclassificationId, gstNo, InvoiceTypeId) { var instance = this; let containerId = $("#" + instance.navigationHelper.getLastContainerId()); if (!$('input.invoiceschk_selected').is(':checked')) { const errId = $('.gst-error-msg').last().attr('id'); MessageHelper.Instance().showError("Please Select One or More Records", errId); return null; } let b2bCheckboxes = containerId.find('input.invoiceschk_selected'); var invoiceids = containerId.find('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).val(); }).get(); gstNo = $(containerId).find('.fromgstno').first().text() || $(containerId).find('.fromgstno').first().val(); console.log(invoiceids); containerId.find("#selectedinvoices_check").click(function () { var checkBoxes = b2bCheckboxes.find('input.invoiceschk_selected'); checkBoxes.prop("checked", !checkBoxes.prop("checked")); }); b2bCheckboxes.click(function () { if (!$(this).is(':checked')) { $("#selectedinvoices_check").prop('checked', false); } else if (b2bCheckboxes.is(":checked")) { $("#selectedinvoices_check").prop('checked', true); } }); bootbox.prompt("Please Enter OTP", function (result) { if (result) { instance._saveGSTRtoGSTPortal(taxclassificationId, result, gstNo, InvoiceTypeId); $(".bootbox-input").keypress(function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { MessageHelper.Instance().showSuccess("Numbers only allowed", 'div_validationsummary'); return false; } }); } }); } DeleteGstrToGSTPortal(taxclassificationId, InvoiceTypeId) { var instance = this; let containerId = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; let b2bCheckboxes = $(containerId).find('input.invoiceschk_selected'); var invoiceids = $(containerId).find('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).val(); }).get(); $(containerId).find("#selectedinvoices_check").click(function () { var checkBoxes = b2bCheckboxes.find('input.invoiceschk_selected'); checkBoxes.prop("checked", !checkBoxes.prop("checked")); }); b2bCheckboxes.click(function () { if (!$(this).is(':checked')) { $("#selectedinvoices_check").prop('checked', false); } else if (b2bCheckboxes.is(":checked")) { $("#selectedinvoices_check").prop('checked', true); } }); bootbox.confirm("Are you sure you want to delete", function (result) { if (result) { instance._deleteGSTRtoGSTPortal(taxclassificationId, result, InvoiceTypeId); } }); } getSelectedInvoices() { $(".invoices_check"); } generateOtp(gstNo) { var gstIntegratorId = 0; var instance = this; instance.fileCacheHelper.loadJsFile("apps/integrations/gst/components/gstsubmission.js", null); instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstmanager.js", null); bootbox.confirm("Are you sure, you want to continue", function (result) { if (result == true) { if (gstNo == undefined || gstNo == "") { alert("Please select Gst No"); return false; } Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().getGstDetails(gstNo).then(function (response) { if (response.status == Unibase.Data.Status.Success) { var result = response.result[0]; var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value; var rdmNo = moment.utc(new Date()).local().format("YYYYMMDDHHmmss"); var postData = { username: result.gstusername, requestid: "Biz-" + rdmNo, gstin: gstNo, retperiod: returnPeriod }; Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().generateOtp(postData).then(function (response) { if (response.errors != null) { instance.showGSTErrorMsg(response.message); return false; } else { alert(response.message); } }); } else MessageHelper.Instance().showSuccess(response.message, ''); }); } }); } _gstShowLog(taxclassificationId) { var instance = this; var gstNo; var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value; var gstr1type = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstr1type").Value; var gstintegratorId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstintegratorid").Value; var invoiceid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_invoiceid").Value; var invoiceno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_invoiceno").Value; gstNo = Unibase.Platform.Analytics.Viewers.TableViewer.Instance().Filter.find(x => x.ParameterName == "fromgstno"); if (gstNo == undefined || gstNo == "") gstNo = Unibase.Platform.Analytics.Viewers.TemplateViewer.Instance().Filter.find(x => x.ParameterName == "fromgstno"); if (gstNo == undefined || gstNo == "") { alert("Please select Gst No"); return false; } gstNo = gstNo.ParameterValue; var Selectedinvoiceno = []; Selectedinvoiceno.push("Invoiceno", Selectedinvoiceno); var taxClassificationData = []; taxClassificationData.push("TaxclassificationId", taxclassificationId); taxClassificationData.push("InvoiceId", Selectedinvoiceno); var postData = { TaxClassificationData: taxClassificationData, Invoiceid: invoiceid, Invoiceno: invoiceno, RtPeriod: returnPeriod, GSTIntegratorid: gstintegratorId, GSTR1type: gstr1type, FromGSTNo: gstNo, InvoiceTypeId: 1, Selectedinvoiceno: invoiceno }; instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstShowLog.js", function () { }); } _saveGSTRtoGSTPortal(taxclassificationId, otp, gstNo, InvoiceTypeId) { var gstIntegratorId = 0; var instance = this; var integratorId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstintegratorid").Value; var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value; 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"); 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"); var formattedfromDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate(toDate); var rdmNo = moment.utc(new Date()).local().format("YYYYMMDDHHmmss"); var invoiceids = $('.invoiceschk_selected:checkbox:checked').map(function () { var instance = this; return Number(instance.value); }).get(); if (isNaN(invoiceids.length)) invoiceids; if (isNaN(invoiceids.length)) invoiceids.length = 0; if (invoiceids.length == null) { invoiceids.length = 0; } const rates = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-rate').text(); }).get(); const supplytype = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-supplytype').text(); }).get(); const pos = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-pos').text(); }).get(); const hsnCodes = $('.invoiceschk_selected:checkbox:checked').map(function () { return $(this).closest('.body-tr').find('.gst-hsncodes').text(); }).get(); var dynamicfilters = [{}]; var OTP = otp.replace(' ', ''); var taxClassificationData = [{ TaxclassificationId: taxclassificationId, InvoiceId: invoiceids, Rates: rates, SupplyType: supplytype, Pos: pos, HSNCodes: hsnCodes, InvoiceTypeId: 1 }]; var postData = { TaxClassificationData: taxClassificationData, RtPeriod: returnPeriod, GSTIntegratorId: integratorId, ToDate: toDate, FromDate: fromDate, InvoiceTypeId: 1, GstNo: gstNo, Otp: OTP }; instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstmanager.js", function () { Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().saveGSTRToPortal(postData).then(function (response) { if (response.errors != null) { instance.showGSTErrorMsg(response.message); return false; } else { MessageHelper.Instance().showSuccess(response.message, ""); var obj = Unibase.Themes.Compact.Components.Details.Instance(); obj._recordId = Unibase.Themes.Compact.Components.Details.Instance()._recordId; obj._installedAppId = Unibase.Themes.Compact.Components.Details.Instance()._installedAppId; obj.loadPortlets(obj); Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true; } }); }); } _deleteGSTRtoGSTPortal(taxclassificationId, otp, InvoiceTypeId) { var gstIntegratorId = 0; var instance = this; var integratorId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstintegratorid").Value; var returnPeriod = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_returnperiod").Value; var fromDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_fromdate").Value; var toDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_todate").Value; var gstNo = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_gstinno").Value; var rdmNo = moment.utc(new Date()).local().format("YYYYMMDDHHmmss"); var invoiceids = $('.invoiceschk_selected:checkbox:checked').map(function () { var instance = this; return Number(instance.value); }).get(); var DeletedInvoicesData = { DeletedInvoiceIds: invoiceids }; var taxClassificationData = [{ TaxclassificationId: taxclassificationId, InvoiceTypeId: InvoiceTypeId, DeleteInvoices: DeletedInvoicesData }]; var postData = { TaxClassificationData: taxClassificationData, RtPeriod: returnPeriod, GSTIntegratorId: integratorId, ToDate: "'2022/08/01'", FromDate: "'2022/08/01'", InvoiceTypeId: 1, GstNo: gstNo, Otp: "575757" }; instance.fileCacheHelper.loadJsFile("apps/integrations/gst/managers/gstmanager.js", function () { Bizgaze.Apps.Integrations.GST.Managers.GSTManager.Instance().saveGSTRToPortal(postData).then(function (response) { if (response.errors != null) { instance.showGSTErrorMsg(response.message); return false; } else { MessageHelper.Instance().showSuccess(response.message, ""); var obj = Unibase.Themes.Compact.Components.Details.Instance(); obj._recordId = Unibase.Themes.Compact.Components.Details.Instance()._recordId; obj._installedAppId = Unibase.Themes.Compact.Components.Details.Instance()._installedAppId; obj.loadPortlets(obj); Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true; } }); }); } showGSTErrorMsg(message) { const errId = $('.gst-error-msg').last().attr('id'); MessageHelper.Instance().showError(message, errId); } static Instance() { if (this.instance === undefined) { this.instance = new GSTSubmission(); } return this.instance; } } Components.GSTSubmission = GSTSubmission; })(Components = GST.Components || (GST.Components = {})); })(GST = Integrations.GST || (Integrations.GST = {})); })(Integrations = Apps.Integrations || (Apps.Integrations = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));