var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Integrations; (function (Integrations) { let EInvoice; (function (EInvoice_1) { let Components; (function (Components) { class EInvoice extends Unibase.Platform.Core.BaseComponent { jsFiles() { return []; } cssFiles() { return []; } html() { return null; } init() { } loadControl(containerid, prop) { this.fileCacheHelper.loadJsFiles(["apps/transact/managers/einvoice/einvoicemanager.js", "apps/transact/enums/enum.js"], function () { var html = `
`; $("#" + containerid).html(html); }); } loadControlSettings(controlsettingjson, formpropertyid) { return null; } loadPropertySettings(propertysettings, formpropertyid) { return null; } bindEditFormDetails(formpropertyid, propval, DocPropertyName) { var ewaybillid = Number(propval); var instance = this; } load() { } getEinvoiceForm(Pk_Value) { let instance = Bizgaze.Apps.Integrations.EInvoice.Components.EInvoice.Instance(); instance.fileCacheHelper.loadJsFiles(['platform/forms/managers/formmanager.js', 'platform/apps/managers/appmanager.js'], function () { var FormUniqueId = 'Bizgaze_Extension_Transact_E-Invoice_App_E-Invoice_CreateForm'; Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(FormUniqueId).then(function (response) { var onLoadCallBack = { CallBack: function () { instance.bindeinvoicedata(Pk_Value); }, Parameters: null, }; var formviewerObj = { FormId: response.result.FormId, AppConfigurationId: 0, Pk_Value: 0, PortletWidgetId: 0, OnSuccess: null, OnFail: null, OnLoad: onLoadCallBack, }; Unibase.Platform.Forms.Components.FormViewer.Instance().init(formviewerObj); instance.navigationHelper.hideLoading(); }); }); } bindeinvoicedata(Pk_Value) { let instance = Bizgaze.Apps.Integrations.EInvoice.Components.EInvoice.Instance(); let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var invoiceId = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_invoiceid").Value); var invoiceNo = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_invoiceno").Value); var gstInvoiceType = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_gstinvoicetypeid").Value); var isEWayBill = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_isewaybill").Value); var einvoiceid = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_einvoiceid").Value); var ewaybillid = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_ewaybillid").Value); var invoice = new Option(invoiceNo, invoiceId, true); ; let _einvoiceid = Pk_Value; instance.fileCacheHelper.loadJsFiles(["apps/transact/managers/einvoice/einvoicemanager.js", "apps/transact/enums/enum.js"], function () { Bizgaze.Apps.Transact.Managers.EInvoiceManager.Instance().geteinvoicepayload(_einvoiceid).then(function (res) { if (res.result != null) { $('input[type=text]').parent().addClass("floating-label-form-group-with-value"); $(".txtAutoComplete_invoiceid").empty(); $(".txtAutoComplete_invoiceid").append(invoice); $(".hfAutoCompleteId_invoiceid").val(invoiceId); $('.txtAutoComplete_invoiceid').prop('disabled', true); $(".hdn_einvoiceid").val(einvoiceid); $(".hdn_ewaybillid").val(ewaybillid); $(".hdn_einvoicestatusid").val("1"); $(".txt_gstinvoicetypeid").val(gstInvoiceType).prop("disabled", true); $(".txt_buyeraddr1").val(res.result.BuyerDtls.Addr1).prop("disabled", true); $(".txt_buyeraddr2").val(res.result.BuyerDtls.Addr2).prop("disabled", true); $(".txt_buyergstin").val(res.result.BuyerDtls.Gstin).prop("disabled", true); $(".txt_buyerlglnm").val(res.result.BuyerDtls.LglNm).prop("disabled", true); $(".txt_buyerloc").val(res.result.BuyerDtls.Loc).prop("disabled", true); $(".txt_buyerph").val(res.result.BuyerDtls.Ph).prop("disabled", true); $(".txt_buyerpin").val(res.result.BuyerDtls.Pin).prop("disabled", true); $(".txt_buyerpos").val(res.result.BuyerDtls.Pos).prop("disabled", true); $(".txt_buyerstcd").val(res.result.BuyerDtls.Stcd).prop("disabled", true); $(".txt_buyertrdnm").val(res.result.BuyerDtls.TrdNm).prop("disabled", true); $(".txt_dispaddr1").val(res.result.DispDtls.Addr1).prop("disabled", true); $(".txt_dispaddr2").val(res.result.DispDtls.Addr2).prop("disabled", true); $(".txt_disploc").val(res.result.DispDtls.Loc).prop("disabled", true); $(".txt_dispnm").val(res.result.DispDtls.Nm).prop("disabled", true); $(".txt_disppin").val(res.result.DispDtls.Pin).prop("disabled", true); $(".txt_dispstcd").val(res.result.DispDtls.Stcd).prop("disabled", true); $(".date_docdt").val(res.result.DocDtls.Dt).prop("disabled", true); $(".txt_docno").val(res.result.DocDtls.No).prop("disabled", true); $(".txt_doctyp").val(res.result.DocDtls.Typ).prop("disabled", true); $(".txt_expcntcode").val(res.result.ExpDtls.CntCode).prop("disabled", true); $(".txt_expexpduty").val(res.result.ExpDtls.ExpDuty).prop("disabled", true); $(".txt_expforcur").val(res.result.ExpDtls.ForCur).prop("disabled", true); $(".txt_expport").val(res.result.ExpDtls.Port).prop("disabled", true); $(".txt_exprefclm").val(res.result.ExpDtls.RefClm).prop("disabled", true); $(".txt_expshipbdt").val(res.result.ExpDtls.ShipBDt).prop("disabled", true); $(".txt_expshipbno").val(res.result.ExpDtls.ShipBNo).prop("disabled", true); $(".txt_payaccdet").val(res.result.PayDtls.Accdet).prop("disabled", true); $(".txt_paycrday").val(res.result.PayDtls.Crday).prop("disabled", true); $(".txt_paycrtrn").val(res.result.PayDtls.Crtrn).prop("disabled", true); $(".txt_paydirdr").val(res.result.PayDtls.Dirdr).prop("disabled", true); $(".txt_payfininsbr").val(res.result.PayDtls.Fininsbr).prop("disabled", true); $(".txt_paymode").val(res.result.PayDtls.Mode).prop("disabled", true); $(".txt_paynm").val(res.result.PayDtls.Nm).prop("disabled", true); $(".txt_paypaidamt").val(res.result.PayDtls.Paidamt).prop("disabled", true); $(".txt_payinstr").val(res.result.PayDtls.Payinstr).prop("disabled", true); $(".txt_paymtdue").val(res.result.PayDtls.Paymtdue).prop("disabled", true); $(".txt_payterm").val(res.result.PayDtls.Payterm).prop("disabled", true); $(".date_refdocperdinvenddt").val(res.result.RefDtls.DocPerdDtls.InvEndDt).prop("disabled", true); $(".date_refdocperdinvstdt").val(res.result.RefDtls.DocPerdDtls.InvStDt).prop("disabled", true); $(".txt_refinvrm").val(res.result.RefDtls.InvRm).prop("disabled", true); $(".date_refprecdocinvdt").val(); $(".txt_refprecdocinvno").val(); $(".txt_refprecdocothrefno").val(); $(".txt_selleraddr1").val(res.result.SellerDtls.Addr1).prop("disabled", true); $(".txt_selleraddr2").val(res.result.SellerDtls.Addr2).prop("disabled", true); $(".txt_sellerem").val(res.result.SellerDtls.Em).prop("disabled", true); $(".txt_sellergstin").val(res.result.SellerDtls.Gstin).prop("disabled", true); $(".txt_sellerlglnm").val(res.result.SellerDtls.LglNm).prop("disabled", true); $(".txt_sellerloc").val(res.result.SellerDtls.Loc).prop("disabled", true); $(".txt_sellerph").val(res.result.SellerDtls.Ph).prop("disabled", true); $(".txt_sellerpin").val(res.result.SellerDtls.Pin).prop("disabled", true); $(".txt_sellerstcd").val(res.result.SellerDtls.Stcd).prop("disabled", true); $(".txt_sellertrdnm").val(res.result.SellerDtls.TrdNm).prop("disabled", true); $(".txt_shipaddr1").val(res.result.ShipDtls.Addr1).prop("disabled", true); $(".txt_shipaddr2").val(res.result.ShipDtls.Addr2).prop("disabled", true); $(".txt_shipgstin").val(res.result.ShipDtls.Gstin).prop("disabled", true); $(".txt_shiplglnm").val(res.result.ShipDtls.LglNm).prop("disabled", true); $(".txt_shiploc").val(res.result.ShipDtls.Loc).prop("disabled", true); $(".txt_shippin").val(res.result.ShipDtls.Pin).prop("disabled", true); $(".txt_shipstcd").val(res.result.ShipDtls.Stcd).prop("disabled", true); $(".txt_shiptrdnm").val(res.result.ShipDtls.TrdNm).prop("disabled", true); $(".txt_transecmgstin").val(res.result.TranDtls.EcmGstin).prop("disabled", true); $(".txt_transigstonintra").val(res.result.TranDtls.IgstOnIntra).prop("disabled", true); $(".txt_transregrev").val(res.result.TranDtls.RegRev).prop("disabled", true); $(".txt_transsuptyp").val(res.result.TranDtls.SupTyp).prop("disabled", true); $(".txt_transtaxsch").val(res.result.TranDtls.TaxSch).prop("disabled", true); if (isEWayBill == "true") { $(".hdn_isewaybill").val("true"); $(".section_E-WayBillDetails").removeClass("hidden"); $(".txt_frompincode").val(res.result.EwbDtls.FromPinCode).prop("disabled", true); $(".txt_topincode").val(res.result.EwbDtls.ToPinCode).prop("disabled", true); $(".hdn_frompincode").val(res.result.SellerDtls.Pin); $(".hdn_topincode").val(res.result.BuyerDtls.Pin); if (res.result.EwbDtls.ApproxDistance != 0) $(".txt_approxdistance").val(res.result.EwbDtls.ApproxDistance); $(".date_transporterdocdate").val(res.result.EwbDtls.TransdocDt).prop("disabled", true); $(".txt_transporterdocno").val(res.result.EwbDtls.Transdocno).prop("disabled", true); $(".txt_transportername").val(res.result.EwbDtls.Transname).prop("disabled", true); $(".txt_transportergstin").val(res.result.EwbDtls.TransporterGstIn).prop("disabled", true); $(".txt_vehicletype").val(res.result.EwbDtls.Vehtype).prop("disabled", true); $(".txt_transmode").val(res.result.EwbDtls.TransporterMode).prop("disabled", true); $(".txt_vehicleno").val(res.result.EwbDtls.Vehno).prop("disabled", true); if (res.result.EwbDtls.Vehtype == 'R') { $(".txt_vehicletype").val('Regular').prop("disabled", true); } if (res.result.EwbDtls.Vehtype == 'O') { $(".txt_vehicletype").val('Over Dimensional Cargo').prop("disabled", true); } $(".dropdown_transmode").val(res.result.EwbDtls.TransMode).prop("disabled", true); $(".txt_vehicleno").val(res.result.EwbDtls.Vehno).prop("disabled", true); $(".txt_approxdistance").addClass("required"); } else { $(".section_E-WayBillDetails").addClass("hidden"); $(".txt_approxdistance").val("0").removeClass("required"); $(".hdn_isewaybill").val("false"); } var dt = res.result; var itemlists = dt.ItemList; for (var i = 0; i < itemlists.length; i++) { var data = itemlists[i]; var html = '' + '' + data.AssAmt + ' ' + '' + data.Barcde + ' ' + '' + data.CesAmt + ' ' + '' + data.CesNonAdvlAmt + ' ' + '' + data.CesRt + ' ' + '' + data.CgstAmt + ' ' + '' + data.Discount + ' ' + '' + data.FreeQty + ' ' + ''; $("#tblgeteinvoiceitems").append(html); } instance.getDistance(); } }); }); } getInvoiceDetails() { var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; $(".hdn_einvoicestatusid").val("1"); if (installedAppId != 0) { var invoiceId = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_invoiceid").Value); var ewaybillid = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_ewaybillid").Value); var invoiceNo = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_invoiceno").Value); var vehicleNo = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_vehicleno").Value); var transporterdocdate = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_transporterdocdate").Value); var transporterdocno = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_transporterdocno").Value); var transportername = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_transportername").Value); var transportergstin = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_transportergstin").Value); var vehicletype = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_vehicletype").Value); var transmode = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_transmode").Value); $(".txtAutoComplete_invoiceid").empty(); $(".txtAutoComplete_invoiceid").append(new Option(invoiceNo, invoiceId, true)); $(".hfAutoCompleteId_invoiceid").val(invoiceId); $(".hdn_ewaybillid").val(ewaybillid); $(".txt_vehicleno").val(vehicleNo); $(".date_transporterdocdate").val(transporterdocdate); $(".txt_transporterdocno").val(transporterdocno); $(".txt_transportername").val(transportername); $(".txt_transportergstin").val(transportergstin); $(".dropdown_vehicletype").val(vehicletype); $(".dropdown_transmode").val(transmode); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/invoicemanager.js,apps/transact/enums/enum.js"], function () { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(invoiceId).then(function (response) { if (response.result != null) { $(".txt_itemassamt").val(); $(".txt_itemattribnm").val(); $(".txt_itemattribval").val(); $(".txt_itembarcode").val(); $(".txt_itembchexpdt").val(); $(".txt_itembchnm").val(); $(".txt_itembchwrdt").val(); $(".txt_itemcesamt").val(); $(".txt_itemcesnonadvlamt").val(); $(".txt_itemcesrt").val(); $(".txt_itemcgstamt").val(); $(".txt_itemdiscount").val(); $(".txt_itemfreeqty").val(); } }); }); } $(".txt_vehicleno").keyup(function () { $(".txt_vehicleno").val($(".txt_vehicleno").val().toString().toUpperCase()); }); } getDistance() { var fromplace = Number($('.txt_sellerpin').val()); var toplace = Number($('.txt_buyerpin').val()); var apikey = 'AIzaSyBGmahAAg3EVzAUJvttDZsjdZiJenJxGt8'; if (apikey == undefined) { } if (toplace == 0) { $('.number_approxdistance').val(0); } else { $.ajax({ url: "https://maps.googleapis.com/maps/api/geocode/json?address=" + fromplace + "%20%22&key=" + apikey + "&sensor=false", method: "POST", success: function (data) { let latitude, longitude, flatitude, flongitude; flatitude = data.results[0].geometry.location.lat; flongitude = data.results[0].geometry.location.lng; $.ajax({ url: "https://maps.googleapis.com/maps/api/geocode/json?address=" + toplace + "%20%22&key=" + apikey + "&sensor=false", method: "POST", success: function (_data) { latitude = _data.results[0].geometry.location.lat; longitude = _data.results[0].geometry.location.lng; var dd = getDistanceFromLatLonInKm(flatitude, flongitude, latitude, longitude); $('.number_approxdistance').val(Math.round(dd)); } }); } }); function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) { var R = 6371; var dLat = deg2rad(lat2 - lat1); var dLon = deg2rad(lon2 - lon1); var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); var d = R * c; return d; } function deg2rad(deg) { return deg * (Math.PI / 180); } } } checkstatus() { let instance = Bizgaze.Apps.Integrations.EInvoice.Components.EInvoice.Instance(); var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var einvoiceid = String(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_einvoiceid").Value); instance.fileCacheHelper.loadJsFiles(["apps/transact/managers/einvoice/einvoicemanager.js"], function () { Bizgaze.Apps.Transact.Managers.EInvoiceManager.Instance().geteinvoicebyid(einvoiceid).then(function (res) { if (res.result != null) { if (res.result.EInvoiceStatusId == 2 || res.result.AckNo == null) $(".DetailSetting_" + installedAppId + "_Cancele-invoice").addClass("hidden"); else $(".DetailSetting_" + installedAppId + "_Cancele-invoice").removeClass("hidden"); if (res.result.AckNo != null && res.result.AckNo != "") { $("#btn_Edite-Invoice").addClass("hidden"); } else $("#btn_Edite-Invoice").removeClass("hidden"); } }); }); } ShowOrHideEInvoiceButton() { let instance = Bizgaze.Apps.Integrations.EInvoice.Components.EInvoice.Instance(); var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var invoiceid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_invoiceid").Value); instance.fileCacheHelper.loadJsFiles(["apps/transact/managers/einvoice/einvoicemanager.js"], function () { Bizgaze.Apps.Transact.Managers.EInvoiceManager.Instance().geteinvoicebyinvoiceid(invoiceid).then(function (res) { if (res.result != null) { if (res.result.EInvoiceStatusId == 2 || res.result.AckNo == null) $(".DetailSetting_" + installedAppId + "_e-Invoice").removeClass("hidden"); else $(".DetailSetting_" + installedAppId + "_e-Invoice").addClass("hidden"); } }); }); } static Instance() { if (this.instance === undefined) { this.instance = new EInvoice(); } return this.instance; } } Components.EInvoice = EInvoice; })(Components = EInvoice_1.Components || (EInvoice_1.Components = {})); })(EInvoice = Integrations.EInvoice || (Integrations.EInvoice = {})); })(Integrations = Apps.Integrations || (Apps.Integrations = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));