123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Components;
- (function (Components) {
- let Invoices;
- (function (Invoices) {
- class PrintInvoice extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.sampleInvoiceNo = "";
- }
- jsFiles() {
- return ["platform/bundle/index.purchases.details.js"];
- }
- cssFiles() {
- return [];
- }
- html() {
- var html = `<input type="hidden" id="hf_SeriesId"/><input type="hidden" id="hf_LobId"/><input type="hidden" id="hf_InvoiceType"/><form id="Bizgazetransact_ConfirmInvoiceDetails" method="post" data-validate="parsley"><div class="b-b bg-white modal-header bg-white b-b modal-header pa-10"><strong id="spnModelHeading">Confirm Invoice Details</strong></div><div style = "height: 627px; overflow: hidden auto;" class="simple-scroll-bar modal-body bg-cyan-light-5"><div id="bizgaze_CreateErrorMessages" class="clear"></div><div class="card"><div class="card-header ">Select Template </div><div class="card-body"><div id="CurrentInvoiceNumber" class="row"><div class="col-sm-6 input-group d-felx align-items-center"><span>Your invoice number going to be : </span><span class="list-item-main-title ml-1" id="spnNextInvoiceNo"></span></div></div><div id="divInvoiceserise" class="row mt-5" ><div class="col-sm-4 div_SeriesId"><div class="floating-label-form-group floating-label-form-group-with-value"><label for= "ddl_InvoiceSeries"> Invoice Series <span class= "text-red">*</span></label><select id= "ddl_InvoiceSeries" class="form-control"></select></div></div><div class="col-sm-4 div_TemplateId"><div class="floating-label-form-group floating-label-form-group-with-value"><label for="ddl_TemplateId">Select Template<span class="text-red">*</span ></label><select id="ddl_TemplateId" class="form-control value-control confirm_print floating-label-control" data-placeholder="Select Template" placeholder="Select Template" data-label="Template Name"></select></div></div ></div></div></div><div class="card preview_card d-none"><div class="card-header">Template Preview</div><div class="card-body print-template-text" id="templateText"></div></div></div ><div class="b-t bg-white modal-footer pa-10"><a href="javascript:;" id = "btn_ClosePrintInvoice" class="btn btn-light btn-sm mr-auto">Close</a><a href="javascript:;" id="btnConfirmShipment_ConfirmPrint" style="width:150px" class="btnConfirmShipment_SaveAndPrint btn btn-primary btn-sm">Confirm & Print</a> <a href="javascript:;" id = "btnConfirmShipment_PrintPreview" style = "width:150px" class="btnConfirmShipment_PrintPreview btn btn-warning btn-sm"> Print Preview </a></div></form>`;
- return html;
- }
- load(item) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().addCacheFiles(["platform/series/managers/seriesmanager.js", "apps/transact/managers/invoicemanager.js"]);
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- let invoiceno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceno").Value;
- if (invoiceno != undefined) {
- var invoiceNo = invoiceno;
- var date = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_invoicedate").Value;
- var LobId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_lobid").Value;
- var JournalTypeId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_journaltypeid").Value;
- var InvoiceDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoicedate").Value;
- var invidate = Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().formatDate(InvoiceDate);
- invoiceNo = invoiceNo.toString().replace('#', '');
- var templateid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_templateid").Value;
- $('#ddl_InvoiceSeries').change(function () {
- Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().changeSeries($(this).val());
- });
- $('.btnConfirmShipment_SaveAndPrint').click(function () {
- $('.btnConfirmShipment_SaveAndPrint').addClass('disabled', "true");
- $('#hfinvoice_no').replaceWith(PrintInvoice.Instance().sampleInvoiceNo);
- Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceno").Value = "0";
- PrintInvoice.Instance().confirmPrint();
- });
- $("#btn_ClosePrintInvoice").click(function () {
- PrintInvoice.Instance().navigationHelper.closePopUp();
- });
- $('#btnConfirmShipment_PrintPreview').click(function () {
- PrintInvoice.Instance().printPreview(Unibase.Themes.Providers.DetailHelper.recordId);
- });
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoicetypeid").Value == "1" || templateid == "0") {
- $('#btnConfirmShipment_PrintPreview').hide();
- }
- var seriesid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_seriesid").Value;
- if (invoiceno.indexOf('#') >= 0) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().GetSampleInvoiceNo(invoiceNo, invidate, seriesid).then(function (response) {
- PrintInvoice.Instance().sampleInvoiceNo = response.result;
- $('#spnNextInvoiceNo').text(PrintInvoice.Instance().sampleInvoiceNo);
- });
- }
- else {
- PrintInvoice.Instance().sampleInvoiceNo = invoiceno;
- $('#spnNextInvoiceNo').text(invoiceno);
- }
- $(".confirm_print").change(function () {
- $(".preview_card").removeClass("d-none");
- let templateid = $(this).val();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/templates/components/templateprint.js', function () { Unibase.Platform.Templates.Components.TemplatePrint.Instance().loadtemplatehtmldata(templateid); });
- });
- $("#ddl_TemplateId").change(function () {
- if ($('#ddl_TemplateId').val() == 0) {
- $('.btnConfirmShipment_SaveAndPrint').addClass('disabled');
- }
- else {
- $('.btnConfirmShipment_SaveAndPrint').removeClass('disabled');
- }
- });
- PrintInvoice.Instance().loadSeries();
- PrintInvoice.Instance().loadTemplates();
- }
- }
- init() {
- let instance = this;
- let jsfiles = ["platform/bundle/index.purchases.details.js"];
- PrintInvoice.Instance().fileCacheHelper.addCacheFiles(["platform/series/managers/seriesmanager.js", "apps/transact/managers/invoicemanager.js"]);
- PrintInvoice.Instance().fileCacheHelper.loadJsFiles(jsfiles, null);
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- let invoiceno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceno").Value;
- let InvoiceId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid").Value;
- var invoicetypeid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoicetypeid").Value;
- let SystemLock = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_issystemlock");
- let IsSystemLock = "false";
- if ((invoiceno.indexOf('#') >= 0) && Number(invoicetypeid) == 1) {
- $(".DetailSetting_" + InstalledAppId + "_Print").text("Confirm & Print");
- $(".DetailSetting_" + InstalledAppId + "_Print").addClass("hidden");
- if (SystemLock == undefined) {
- instance.fileCacheHelper.loadJsFile("apps/transact/managers/invoicemanager.js", function () {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(InvoiceId).then(function (invres) {
- IsSystemLock = invres.result.IssystemLock.toString();
- if (IsSystemLock == "false") {
- $(".DetailSetting_" + InstalledAppId + "_Print").removeClass("hidden");
- }
- });
- });
- }
- else {
- IsSystemLock = SystemLock.Value;
- if (IsSystemLock == "true") {
- $(".DetailSetting_" + InstalledAppId + "_Print").addClass("hidden");
- }
- }
- }
- $(".DetailSetting_" + InstalledAppId + "_Print").click(function () {
- var templateid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_templateid").Value;
- if ((invoiceno.indexOf('#') >= 0 || templateid == "0") && Number(invoicetypeid) == 1) {
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, '', Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance(), null, Unibase.Platform.Helpers.Size.Large);
- }
- else {
- if (!Boolean(templateid)) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("/platform/core/helpers/printhelper/printhelper.js", function () {
- Unibase.Platform.Helpers.PrintHelper.Instance().showPrintErrorModal();
- return;
- });
- }
- else {
- PrintInvoice.Instance().sampleInvoiceNo = invoiceno;
- var invoiceid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoiceid").Value;
- PrintInvoice.Instance().printPreview(invoiceid);
- }
- }
- });
- }
- loadSeries() {
- let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var seriesid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_seriesid").Value);
- Unibase.Platform.Series.Managers.SeriesManager.Instance().getSeries(0, InstallAppId).then(function (response) {
- $('#ddl_InvoiceSeries').empty();
- var data = response.result;
- var cmbSeries = document.getElementById('ddl_InvoiceSeries');
- $('#ddl_InvoiceSeries').empty();
- for (var i = 0; i < data.length; i++) {
- if (data[i].StatusId == 1) {
- var option = new Option(data[i].SeriesName, data[i].SeriesId.toString());
- $("#ddl_InvoiceSeries").append(option);
- }
- }
- if (seriesid != 0) {
- $('#ddl_InvoiceSeries option[value=' + seriesid + ']').attr('selected', 'selected');
- Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().changeSeries(seriesid);
- }
- else
- Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().changeSeries(data[0].SeriesId);
- });
- }
- loadTemplates() {
- let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var templateid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_templateid").Value);
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().gettemplates(InstallAppId).then(function (response) {
- if (response.result.length > 0) {
- var ddlTemplate = document.getElementById('ddl_TemplateId');
- $('#ddl_TemplateId').empty();
- $("#ddl_TemplateId").append('<option value="0">--select--</option>');
- for (var i = 0; i < response.result.length; i++) {
- var option = new Option(response.result[i].TemplateName, response.result[i].TemplateId);
- $("#ddl_TemplateId").append(option);
- }
- }
- if (templateid != 0) {
- $('#ddl_TemplateId option[value=' + templateid + ']').attr('selected', 'selected');
- }
- else {
- var branchid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_branchid").Value);
- var lobid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_lobid").Value);
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().GetTemplateSetting(InstallAppId, branchid, lobid).then(function (res) {
- if (res.result != null) {
- $('#ddl_TemplateId option[value=' + res.result.TemplateId + ']').attr('selected', 'selected');
- }
- });
- }
- if (response.result.length <= 0) {
- $(".div_TemplateId").addClass('hidden');
- MessageHelper.Instance().showError("Please Create Template", "bizgaze_CreateErrorMessages");
- }
- let seletedTemplate = $(".confirm_print option:selected").val();
- if (seletedTemplate != 0) {
- $(".preview_card").removeClass("d-none");
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/templates/components/templateprint.js', function () { Unibase.Platform.Templates.Components.TemplatePrint.Instance().loadtemplatehtmldata(seletedTemplate); });
- }
- });
- }
- changeSeries(seriesId) {
- let InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var InvoiceDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_invoicedate").Value;
- var invidate = Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().formatDate(InvoiceDate);
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getTempNextNumber(seriesId, invidate).then(function (data) {
- if (data.status == 2) {
- MessageHelper.Instance().showError(data.message, "bizgaze_CreateErrorMessages");
- $('#spnNextInvoiceNo').text("");
- }
- else {
- $('#spnNextInvoiceNo').text(data.result.SeriesName);
- PrintInvoice.Instance().sampleInvoiceNo = data.result.SeriesName;
- $('#bizgaze_CreateErrorMessages').empty();
- }
- }, function (response) {
- MessageHelper.Instance().showError(response.message, "bizgaze_CreateErrorMessages");
- });
- }
- printPreview(InvoiceId) {
- var instance = this;
- instance.navigationHelper.showLoading();
- let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- PrintInvoice.Instance().fileCacheHelper.loadJsFile("apps/transact/managers/invoicemanager.js", function () {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getprintinvoice(InvoiceId, true, false).then(function (data) {
- instance.navigationHelper.hideLoading();
- var resp = data.result;
- if (isMobileApp()) {
- Unibase.Platform.Helpers.MobileHelper.Instance().previewHtml(data.result.PrintHTML);
- }
- else {
- if (resp.FilePath != "" && resp.FilePath != null) {
- var path = resp.FilePath.replace("~", "");
- instance.download(_appsettings.asset_url() + path, resp.FileName + ".pdf");
- }
- else {
- PrintInvoice.Instance().printPopup(resp);
- }
- }
- }, function (response) {
- MessageHelper.Instance().showError(response.responseText, "");
- });
- });
- }
- download(url, fileName) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', url, true);
- xhr.responseType = 'blob';
- xhr.onload = function (event) {
- if (this.status == 200) {
- PrintInvoice.Instance()._saveBlob(this.response, fileName);
- }
- };
- xhr.send();
- }
- _saveBlob(response, fileName) {
- if (navigator.msSaveBlob) {
- navigator.msSaveBlob(response, fileName);
- }
- else {
- this._html5Saver(response, fileName);
- }
- }
- _html5Saver(blob, fileName) {
- var a = document.createElement("a");
- document.body.appendChild(a);
- var url = window.URL.createObjectURL(blob);
- a.href = url;
- a.download = fileName;
- a.click();
- document.body.removeChild(a);
- }
- printPopup(data) {
- var mywindow = window.open('', 'my Print', 'height=400,width=850');
- var content = '<html><head><title>Print</title><link rel="stylesheet" href="lib/bizgaze/print.css" /><link rel="stylesheet" href="lib/bootstrap/bootstrap-theme.min.css" /></head><body>';
- content += data.PrintHTML;
- content += "<script>print();</script>";
- content += '</body></html>';
- mywindow.document.write(content);
- return true;
- }
- confirmPrint() {
- let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var seriesid = Number($('#ddl_InvoiceSeries').val());
- let invoiceno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoiceno").Value;
- invoiceno = invoiceno.toString().replace(/\//g, '.');
- if (seriesid == undefined) {
- seriesid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_seriesid").Value);
- }
- if ($('#ddl_TemplateId option').length == 0) {
- MessageHelper.Instance().showError("Please Create Template", "bizgaze_CreateErrorMessages");
- $('.btnConfirmShipment_SaveAndPrint').removeClass('disabled');
- return false;
- }
- if ($('#ddl_TemplateId').val() == '' || $('#ddl_TemplateId').val() == "0") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("/platform/core/helpers/printhelper/printhelper.js", function () {
- Unibase.Platform.Helpers.PrintHelper.Instance().showPrintErrorModal();
- return;
- });
- $('.btnConfirmShipment_SaveAndPrint').removeClass('disabled');
- return false;
- }
- var invoiceId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoiceid").Value);
- var templateid = Number($('#ddl_TemplateId').val());
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().updateinvoiceseries(invoiceId, seriesid, invoiceno, templateid).then(function (data) {
- if (data.status == 2) {
- MessageHelper.Instance().showError(data.message, 'bizgaze_CreateErrorMessages');
- return false;
- }
- PrintInvoice.Instance().navigationHelper.closePopUp();
- var detailobj = Unibase.Themes.Providers.DetailHelper.DetailInstance();
- detailobj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
- detailobj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- detailobj._containerId = detailobj._containerId;
- detailobj.loadPortlets(detailobj);
- var invoiceId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoiceid").Value);
- if (invoiceId == undefined || invoiceId == 0)
- invoiceId = Unibase.Themes.Providers.DetailHelper.recordId;
- PrintInvoice.Instance().printPreview(detailobj._recordId);
- });
- }
- formatDate(date) {
- var datearray = date.split("/");
- var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2];
- var d = new Date(newdate), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
- if (month.length < 2)
- month = '0' + month;
- if (day.length < 2)
- day = '0' + day;
- return [year, month, day].join('-');
- }
- print() {
- let InstallAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var invoiceNo = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoioceno").Value;
- if (invoiceNo.indexOf("#") >= 0) {
- invoiceNo = invoiceNo.replace('#', '');
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, "", Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance(), null, Unibase.Platform.Helpers.Size.Large);
- }
- else {
- var invoiceId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_invoioceid").Value);
- var TemplateId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstallAppId + "_templateid").Value);
- if (TemplateId == 0) {
- }
- else {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getprintinvoice(invoiceId, true, false).then(function (data) {
- var resp = data.result;
- var printhtml = '<div id="divPrint hidden"><span class="printDataN">' + resp.Html + '</span></div >';
- }, function (response) {
- MessageHelper.Instance().showError(response.responseText, "");
- });
- }
- }
- }
- downloadPrint(InvoiceId) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["platform/templates/managers/templatemanager.js", "platform/files/managers/filemanager.js", "platform/core/helpers/mobile/mobilehelper.js", "platform/core/helpers/mobile/interfaces/imobilehelper.js", "platform/core/helpers/mobile/android/androidhelper.js"], function () {
- Unibase.Platform.Templates.Managers.TemplateManager.Instance().getTemplatePdfFile("Bizgaze_Extension_Transact_Transact_PrintProvider_InvoicePrint", InvoiceId).then(function (responce) {
- if (responce.errors == null) {
- if (isMobileApp) {
- var filePath = responce.result.FilePath;
- if (filePath != null && filePath != undefined && filePath != "") {
- filePath = filePath.replace("file://" + '/', '');
- filePath = filePath.replace(window.location.origin + '/', '');
- Unibase.Platform.Helpers.MobileHelper.Instance().getMobileFilePath(responce, filePath, Bizgaze.Apps.Transact.Components.Invoices.PrintInvoice.Instance().MobileFilePathCallBack);
- }
- }
- else {
- var Filepath = responce.result.FilePath;
- Filepath = Filepath.substring(8) + ".pdf";
- var a = document.createElement("a");
- a.href = Filepath;
- a.download = responce.result.FileName;
- a.click();
- }
- }
- });
- });
- }
- MobileFilePathCallBack(responce, filePath, mobileFilePath) {
- mobileFilePath.replace(/^\//, '');
- filePath = filePath.replace(mobileFilePath + '/', '');
- var tempPath = filePath.split("~/");
- var checkPath = tempPath[tempPath.length - 1];
- filePath = checkPath;
- var server_url = _appsettings.server_url();
- if (!filePath.includes(server_url)) {
- filePath = server_url + "/" + filePath;
- }
- var a = document.createElement("a");
- a.href = filePath;
- a.download = responce.result.FileName;
- a.click();
- }
- downloadGstrReport(gstno) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["libs/xlsx/xlsx.core.min.js", "libs/alasql/alasql.min.js", "apps/transact/managers/invoicemanager.js"], function () {
- if (gstno == "" || gstno == "Select")
- gstno = 0;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getGSTRReport(gstno).then(function (result) {
- var GstSummary = JSON.parse(result.result[0]);
- var B2BData = JSON.parse(result.result[1]);
- var B2CSData = JSON.parse(result.result[2]);
- var B2CLdata = [""];
- if (result.result[3] != '[]')
- B2CLdata = JSON.parse(result.result[3]);
- var CDNRdata = [""];
- if (result.result[4] != '[]')
- CDNRdata = JSON.parse(result.result[4]);
- var CDNUdata = [""];
- if (result.result[5] != '[]')
- CDNUdata = JSON.parse(result.result[5]);
- var HSNSdata = [""];
- if (result.result[6] != '[]')
- HSNSdata = JSON.parse(result.result[6]);
- var PurchaseHSNSdata = [""];
- if (result.result[7] != '[]')
- PurchaseHSNSdata = JSON.parse(result.result[7]);
- var PurchaseB2B = [""];
- if (result.result[8] != '[]')
- PurchaseB2B = JSON.parse(result.result[8]);
- var Seriesdata = [""];
- if (result.result[9] != '[]')
- Seriesdata = JSON.parse(result.result[9]);
- var opts = [{ sheetid: 'GstSummary', header: true }, { sheetid: 'B2BDetails', header: true }, { sheetid: 'B2CSDetails', header: false }, { sheetid: 'B2CLDetails', header: false }, { sheetid: 'CDNR', header: false }, { sheetid: 'CDNU', header: false }, { sheetid: 'HSN', header: false }, { sheetid: 'PurchaseHSN', header: false }, { sheetid: 'PurchaseB2B', header: false }, { sheetid: 'DOCS', header: false }];
- let _alexcelclient = window['alasql'];
- var res = _alexcelclient('SELECT INTO XLSX("GSTRReturnsDetails.xlsx",?) FROM ?', [opts, [GstSummary, B2BData, B2CSData, B2CLdata, CDNRdata, CDNUdata, HSNSdata, PurchaseHSNSdata, PurchaseB2B, Seriesdata]]);
- }, function (response) {
- MessageHelper.Instance().showError(response.responseText, "");
- });
- });
- }
- refreshTaxclassifications() {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/transact/managers/invoicemanager.js"], function () {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().refreshTaxclassifications().then(function (result) {
- MessageHelper.Instance().showSuccess(result.message, "Invoice TaxClassifications refreshed successfully");
- });
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new PrintInvoice();
- }
- return this.instance;
- }
- }
- Invoices.PrintInvoice = PrintInvoice;
- })(Invoices = Components.Invoices || (Components.Invoices = {}));
- })(Components = Transact.Components || (Transact.Components = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|