UNPKG

@salaxy/ng1

Version:

AngularJS libraries for Salaxy platform (Palkkaus.fi)

1,030 lines (1,027 loc) 6.57 MB
var xW = Object.defineProperty; var wW = (n, e, t) => e in n ? xW(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var pt = (n, e, t) => (wW(n, typeof e != "symbol" ? e + "" : e, t), t), AW = (n, e, t) => { if (!e.has(n)) throw TypeError("Cannot " + t); }; var UA = (n, e, t) => { if (e.has(n)) throw TypeError("Cannot add the same private member more than once"); e instanceof WeakSet ? e.add(n) : e.set(n, t); }; var bg = (n, e, t) => (AW(n, e, "access private method"), t); import { Configs as Bt, Cookies as VP, Token as Xl, PensionCompany as Gi, SettingsLogic as gM, Role as lC, Translations as P, AuthorizationType as CW, WebSiteUserRole as cr, OData as Cu, Dates as N, Texts as vr, ExportMethod as Za, Tables as Su, TableFormat as BA, JsonSchemaCache as SW, JsonSchemaUtils as yr, SitemapVisibility as ln, Arrays as xt, Objects as ua, RoleLogic as Ph, EmploymentRelationTaxcard as pn, TaxcardKind as Ma, TaxCard2019Logic as en, EmploymentLogic as un, Numeric as At, Payrolls as G$, CalculatorLogic as tn, PaymentChannel as Xe, InvoicesLogic as St, InvoiceStatus as tt, LegalEntityType as ko, PayrollStatus as dn, SalaryDateKind as rs, SalaryDateLogic as Qu, CalculationStatus as Ct, CalculationResultLogic as ow, Payrolls4 as Mu, InvoiceType as Et, ReportsLogic as cC, AccountingReportTableType as zA, PeriodType as Ro, CalcRowsLogic as To, CalculationRowType as Ke, CalculationRowSource as Cs, Years as ll, OAuthSalaxyAuthorizeMode as jP, Language as Jt, OnboardingLogic as qP, UsecaseStatus as vo, ApiItemType as Hr, StorageLogic as KP, AvatarPictureType as oi, SystemRole as lw, HrSuuntiImportLogic as vg, FileParser as F$, ValidationHelper as $W, DataMapper as hl, Brand as Xu, HouseholdUsecasesLogic as Nr, CalculationRowUnit as dC, UnionPaymentType as kW, BootstrapStyle as Gu, AbsenceCauseCode as na, IncomeTypesLogic as On, Unit as ai, IrRowSourceType as TW, ReportType as Rh, HelpersRoot as LW, HolidaysLogic as Nn, HolidayCode as Rt, WageBasis as hr, HolidayPayCalculation as jt, CostAccountingDimensionScope as Ci, RowsUsecaseLogic as $u, UserDefinedRowLogic as yM, EnumerationsLogic as ta, BicHelper as cw, Iban as H$, MessageThreadStatus as rm, ThreadedMessageType as wn, MessageFrom as Ts, ContactType as ur, ApiValidationErrorType as sn, kevaEmploymentRegCodes as bM, HolidayBonusPaymentMethod as xy, PensionCalculation as JP, cbaCodes as DW, Occupations as Fu, DateTimes as Si, CellRenderingLogic as vM, Calculations as jy, DataMappersLogic as Zu, Culture as xM, ImportBatch as EW, ExportLogic as IW, ApiImportStatus as fs, RowMergeOption as WA, DataMapperSelector as wM, ApiCheckStatus as AM, WorktimeApiConnector as QP, InvoicePaymentType as PW, PaymentChannelApi as uC, Promises as RW, SharingUriType as tu, HouseholdYearProcessingStatus as _W, TaxDeductionWorkCategories as NW, TimesheetInputModification as dh, PeriodDateKind as Zm, AccountingTargetLogic as YW, AccountingChannel as mr, irepr as xa, irpsr as xg, DatasetStatus as ZP, DatasetType as eR, PaidSickLeaveKind as Hu, TrainingKind as Uu, NonProfitOrgKind as tR, OtherCompensationKind as ts, RemunerationKind as au, WorkingTimeCompensationKind as Ni, EmploymentTerminationKind as Zp, AllowanceCode as wg, DailyAllowanceKind as eh, AccountantType as Yc, AccountingTargets as CM, FileLogic as Ag, FileDelimiter as OW, SettingsStatus as aR, WorkerSalarySlipDeliveryMethod as bi, LocalTapiolaInsuranceOrderType as VA, CalcRowConfigTypeGroup as nR, TranslationsInstance as Cg, FormHelpers as _h, Country as SM, EmploymentRelationSalaryPaymentMethod as MW, Validation as _n, HolidayAccrualSource as Sg, AnnualLeavePaymentKind as XW, TaxCardIncomeType as Ql, CalendarActionType as GW, ActionExecutor as pC, UsecaseActionType as FW, CustomerInvoices as HW, HouseholdYears as UW, ServiceModels as BW, Workers as zW, Usecases as WW, Test as VW, Taxcards as jW, Session as qW, Reports as KW, ReferenceObjects as JW, Records as QW, ProApi as ZW, PartnerServices as eV, Overview as tV, Onboardings as aV, OAuth2 as nV, MessageThreads as sV, IrPayerSummaries as iV, IrEarningsPayments as rV, Invoices as oV, Imports as lV, HolidayYears as cV, Files as dV, Employments as uV, Datasets as pV, Credentials as hV, Client as mV, Certificates as fV, CalendarEvents as gV, Calculator as yV, BusinessTemplates as bV, BeneficialOwnersApi as vV, AuthorizedAccounts as xV, AccountSettings as wV, Accounts as AV, Absences as CV } from "@salaxy/core"; import { TotalsReportConfigGenerator as $M, ESalaryMapper as SV, CalculationMapper as el, Templates as kd, CostCenterReportConfigGenerator as hC, RowsReportConfigGenerator as sR, IrRowsReportConfigGenerator as kM, Barcodes as rc, QrCodes as dw, InvoiceMapper as $g, AccountingMapper as jA, SummaryMapper as Bu, WorkerSummaryMapper as qA, UnionPaymentReportConfigGenerator as $V } from "@salaxy/reports"; const zc = class zc { /** * Creates a new instance of AjaxNg1 * @param $http - Angular http * @param $q - Angular q * @param config - Optional config containing keys which override the corresponding global Config keys. */ constructor(e, t, a = null) { this.$http = e, this.$q = t, this.useCookie = !0, this.useCredentials = !1, this.serverAddress = "https://test-api.salaxy.com"; const s = Bt.current; if (s || a) { const i = a?.apiServer ?? s.apiServer; i && (this.serverAddress = i); const r = a?.useCredentials ?? s.useCredentials; r != null && (this.useCredentials = r); const o = a?.useCookie ?? s.useCookie; o != null && (this.useCookie = o); } } /** * Gets the API address with version information. E.g. 'https://test-api.salaxy.com/v03/api'. * Default version, as of writing 2.0 */ getApiAddress() { return this.serverAddress + "/v03/api"; } /** Gets the Server address that is used as bases to the HTML queries. E.g. 'https://test-api.salaxy.com' */ getServerAddress() { return this.serverAddress; } /** * Gets a JSON-message from server using the API * @param method The API method is the url path after the api version segments (e.g. '/v03/api') * and starts with a forward slash, e.g. '/calculator/new'. * @returns A Promise with result data. Standard Promise rejection to be used for error handling. */ getJSON(e) { const t = {}, a = this.getCurrentToken(); return a && (t.headers = { Authorization: "Bearer " + a }), t.url = this.getUrl(e), t.method = "GET", t.responseType = "json", t.withCredentials = a ? !1 : this.useCredentials, this.$http(t).then( (s) => s.data, (s) => this.handleError(s) ); } /** * Gets a HTML-message from server using the API * @param method - The API method is the url path after the api version segments (e.g. '/v03/api') * and starts with a forward slash, e.g. '/calculator/new'. * @returns A Promise with result data. Standard Promise rejection to be used for error handling. */ getHTML(e) { const t = {}, a = this.getCurrentToken(); return a && (t.headers = { Authorization: "Bearer " + a }), t.url = this.getUrl(e), t.method = "GET", t.responseType = "text", t.withCredentials = a ? !1 : this.useCredentials, this.$http(t).then( (s) => s.data, (s) => this.handleError(s) ); } /** * Gets a blob (binary data) from the server using the API. * @param method - The API method is the url path after the api version segments (e.g. '/v03/api') * and starts with a forward slash, e.g. '/calculator/new'. * @returns A Promise that resolves to an object containing: * - data: The blob data from the response * - headers: An object containing the response headers as key-value pairs */ getBlob(e) { const t = {}, a = this.getCurrentToken(); return a && (t.headers = { Authorization: "Bearer " + a }), t.url = this.getUrl(e), t.method = "GET", t.responseType = "blob", t.withCredentials = a ? !1 : this.useCredentials, this.$http(t).then( (s) => { const i = {}, r = s.headers(); return Object.keys(r).forEach((o) => { i[o] = r[o]; }), { data: s.data, headers: i }; }, (s) => this.handleError(s) ); } /** * POSTS data to server and receives back a blob (binary data). * @param method - The API method is the url path after the api version segments (e.g. '/v03/api') * and starts with a forward slash, e.g. '/calculator/new'. * @param data - The data that is posted to the server. * @returns A Promise that resolves to an object containing: * - data: The blob data from the response * - headers: An object containing the response headers as key-value pairs */ postBlob(e, t) { const a = {}, s = this.getCurrentToken(); return s && (a.headers = { Authorization: "Bearer " + s }), a.url = this.getUrl(e), a.method = "POST", a.data = t, a.responseType = "blob", a.withCredentials = s ? !1 : this.useCredentials, this.$http(a).then( (i) => { const r = {}, o = i.headers(); return Object.keys(o).forEach((l) => { r[l] = o[l]; }), { data: i.data, headers: r }; }, (i) => this.handleError(i) ); } /** * POSTS data to server and receives back a JSON-message. * @param method - The API method is the url path after the api version segments (e.g. '/v03/api') * and starts with a forward slash, e.g. '/calculator/new'. * @param data - The data that is posted to the server. * @returns A Promise with result data. Standard Promise rejection to be used for error handling. */ postJSON(e, t) { const a = {}, s = this.getCurrentToken(); return s && (a.headers = { Authorization: "Bearer " + s }), a.url = this.getUrl(e), a.method = "POST", a.data = t, a.responseType = "json", a.withCredentials = s ? !1 : this.useCredentials, this.$http(a).then( (i) => i.data, (i) => this.handleError(i) ); } /** * POSTS data to server and receives back HTML. * @param method - The API method is the url path after the api version segments (e.g. '/v03/api') * and starts with a forward slash, e.g. '/calculator/new'. * @param data - The data that is posted to the server. * @returns A Promise with result data. Standard Promise rejection to be used for error handling. */ postHTML(e, t) { const a = {}, s = this.getCurrentToken(); return s && (a.headers = { Authorization: "Bearer " + s }), a.url = this.getUrl(e), a.method = "POST", a.data = t, a.responseType = "text", a.withCredentials = s ? !1 : this.useCredentials, this.$http(a).then( (i) => i.data, (i) => this.handleError(i) ); } /** * Sends a DELETE-message to server using the API * @param method - The API method is the url path after the api version segments (e.g. '/v03/api') * and starts with a forward slash, e.g. '/calculator/new'. * @returns A Promise with result data. Standard Promise rejection to be used for error handling. */ remove(e) { const t = {}, a = this.getCurrentToken(); return a && (t.headers = { Authorization: "Bearer " + a }), t.url = this.getUrl(e), t.method = "DELETE", t.responseType = "json", t.withCredentials = a ? !1 : this.useCredentials, this.$http(t).then( (s) => s.data, (s) => this.handleError(s) ); } /** * Gets the current token. * Will check the salaxy-token cookie if the token is persisted there */ getCurrentToken() { return !this.token && this.useCookie && (this.token = new VP().get("salaxy-token") || ""), this.token; } /** Gets the status of the current token. */ getTokenStatus() { const e = this.getCurrentToken(); return Xl.validate(e); } /** * Sets the current token. Persists it to cookie until the browser window * @param token - the authentication token to persist. */ setCurrentToken(e) { const t = !!Xl.parsePayload(e ?? "")?.act; this.useCookie && !t && new VP().setCookie("salaxy-token", e || ""), this.token = e; } /** If missing, append the API server address to the given url method string */ getUrl(e) { return !e || e.trim() === "" ? null : e.toLowerCase().startsWith("http") ? e : e.toLowerCase().startsWith("/v") ? this.getServerAddress() + e : this.getApiAddress() + e; } handleError(e) { let t; if (e ? e.data && e.data.messageHtml ? t = `<b>${e.data.error}:</b><br/>${e.data.messageHtml}` : e.data && e.data.message ? t = e.data.message : t = `HTTP error: ${e.statusText} (${e.status})` : t = "Unexpected error in HTTP request", zc.alertService) { if (zc.alertService.catchError) return zc.alertService.catchError(e); zc.alertService.addError(t); } return this.$q.reject(e); } }; zc.$inject = ["$http", "$q"]; let qy = zc; const xT = class xT { /** * Creates a new WizardController * @param $scope - The Angular scope * @param wizardService - Maintains the state of the wizard * @param data - Any data to the controller * @ignore */ constructor(e, t, a = null) { this.$scope = e, this.wizardService = t, this.data = a, this.colWidthClasses = ["col-sm-12", "col-sm-12", "col-sm-6", "col-sm-4", "col-sm-3", "col-sm-fifth", "col-sm-2"]; } /** * Implement IController */ $onInit() { } /** Gets all the steps in the Wizard */ get steps() { return this.wizardService.getSteps(); } /** Gets the number of the currently active step */ get step() { return this.wizardService.activeStepNumber; } /** Sets the number of the currently active step */ set step(e) { this.wizardService.activeStepNumber = e; } /** The currently selected step object */ get currentStep() { return this.wizardService.getCurrentStepObject(); } /** Active styling properties */ get style() { return { colWidthClass: this.colWidthClasses[this.steps.length] }; } /** Returns true if goNext is enabled */ get canGoNext() { return !!(this.steps.length > this.step && this.steps[this.step] && !this.steps[this.step].disabled); } /** Returns true if goNext is enabled */ get canGoPrevious() { return this.step > 1 && !this.steps[this.step - 2].disabled; } /** * Navigates to the next step if possible */ goNext() { this.canGoNext && this.step++; } /** Navigates to the previous step if possible */ goPrevious() { this.canGoPrevious && this.step--; } }; xT.$inject = ["$scope", "WizardService", "data"]; let Qr = xT; const wT = class wT extends Qr { constructor(e, t, a, s, i, r, o, l) { super(e, t, l), this.onboardingService = a, this.sessionService = s, this.authorizedAccountService = i, this.ajax = r, this.$location = o, this.isStepProceeding = !1, this.linkCopied = !1; } /** * Implement IController */ $onInit() { this.wizardService.setSteps(this.getWizardSteps()), this.model && this.model.company.resolvedId && this.model.signature.personalId != null ? this.wizardService.activeStepNumber = this.wizardService.getSteps().length : this.wizardService.activeStepNumber = 1; } /** Company wizard configuration */ getWizardSteps() { const e = []; return e.push( { title: "SALAXY.NG1.CustomerOnboardingComponent.stepUserInfo.title", heading: "", intro: "", view: "salaxy-components/modals/onboarding/customer/user.html", buttonsView: "salaxy-components/modals/onboarding/customer/user-buttons.html" }, { title: "SALAXY.NG1.CustomerOnboardingComponent.stepCompanyInfo.title", heading: "", intro: "", view: "salaxy-components/modals/onboarding/customer/company.html", buttonsView: "salaxy-components/modals/onboarding/customer/buttons.html" }, { title: "SALAXY.NG1.CustomerOnboardingComponent.stepCompanyLegal.title", heading: "", intro: "", view: "salaxy-components/modals/onboarding/customer/company-legal.html", buttonsView: "salaxy-components/modals/onboarding/customer/buttons.html" }, { title: "SALAXY.NG1.CustomerOnboardingComponent.stepInsurance.title", heading: "", intro: "", view: "salaxy-components/modals/onboarding/customer/insurance.html", buttonsView: "salaxy-components/modals/onboarding/customer/commit-buttons.html" }, { title: "SALAXY.NG1.CustomerOnboardingComponent.stepInviteCompany.title", heading: "", intro: "", view: "salaxy-components/modals/onboarding/customer/finish.html", buttonsView: "salaxy-components/modals/onboarding/customer/finish-buttons.html" } ), e; } /** * The onboarding model is provided by the onboarding service. * */ get model() { return this.onboardingService.model; } /** * Navigates to the next step if possible and saves the data. */ goNext() { this.isStepProceeding || (this.isStepProceeding = !0, this.save().then(() => { super.goNext(), this.isStepProceeding = !1; }).catch((e) => { this.isStepProceeding = !1; })); } /** * Navigates to the previous step if possible and saves the data. */ goPrevious() { this.isStepProceeding || (this.isStepProceeding = !0, this.save().then(() => { super.goPrevious(), this.isStepProceeding = !1; }).catch((e) => { this.isStepProceeding = !1; })); } /** Returns true if user can go forward in wizard */ get canGoNext() { return !!(this.steps.length > this.step && this.steps[this.step] && !this.steps[this.step].disabled && this.formDataValidity); } /** Sharing link for singing. */ get signingLink() { return this.model ? Bt.current.wwwServer + "/share/signing/" + encodeURIComponent(this.model.owner) + "/" + this.model.id : ""; } /** Sharing link for authorization mail. */ get sharingLink() { return this.model ? Bt.current.wwwServer + "/share/authorization/" + encodeURIComponent(this.model.owner) + "/" + this.model.id : ""; } /** Copies link to clipboard */ copyLink(e) { navigator.clipboard.writeText(e), this.linkCopied = !0; } /** Mailto-link with sharing link. */ get mailtoLink() { if (!this.model || !this.model.person) return ""; let e = "mailto:"; e += this.model.person.contact.email, e += "?subject=" + encodeURIComponent("Palkkaus.fi-palvelun valtakirjan allekirjoitus"); let t = "Hei " + this.model.person.firstName + " " + this.model.person.lastName + `, `; return t += "Olemme ottamassa käyttöön Palkkaus.fi-palvelun yrityksesi palkanmaksuun.", t += " Jotta he voivat hoitaa kaikki viranomaisvelvoitteet, tarvitaan allekirjoitus sinulta.", t += " Se hoituu helposti pankkitunnuksilla seuraamalla tätä linkkiä: ", t += this.sharingLink + `. `, t += `Ystävällisin terveisin, `, t += this.sessionService.getAvatar().displayName, e += "&body=" + encodeURIComponent(t), e; } /** * Existing company alert. */ get existingCompanyAlert() { const e = this.sessionService.session?.currentAccount?.id; return this.model?.company?.resolvedId && this.model.company.resolvedId != e; } /** * Proceeds to company selection in e-authorization service. */ goToCompanySelection() { this.model.company.doYtjUpdate = !0, this.goNext(); } /** Commit onboarding */ commit() { this.isStepProceeding || (this.isStepProceeding = !0, this.model.signature.email = this.model.person.contact.email, this.model.signature.telephone = this.model.person.contact.telephone, this.model.signature.personName = (this.model.person.firstName + " " + this.model.person.lastName).trim(), this.onboardingService.commit().then(() => { this.authorizedAccountService.reloadAuthorizingAccounts(), super.goNext(), this.isStepProceeding = !1; }).catch((e) => { this.isStepProceeding = !1; })); } /** Sets pension fields (defaults) after user input. */ checkPensionCompanySelection() { this.model.products.pension.isPensionContractDone || (this.model.products.pension.pensionCompany = Gi.None, this.model.products.pension.pensionContractNumber = null); const e = this.model.products.pension.pensionCompany; this.model.products.pension.isPensionContractDone && e === Gi.Varma && (this.model.products.pension.isPendingContract = !1), (e === Gi.Veritas || e === Gi.Apteekkien || e === Gi.Verso || e === Gi.Valio || (e ?? "").startsWith("keva") || e === Gi.Other) && (this.model.products.pension.isPensionSelfHandling = !0), this.model.products.pension.isPendingContract && (this.model.products.pension.isPensionSelfHandling = !1); } /** Sets insurance fields (defaults) after user input. */ checkInsuranceCompanySelection() { this.model.products.insurance.isInsuranceContractDone || (this.model.products.insurance.insuranceCompany = null, this.model.products.insurance.insuranceContractNumber = null); } /** * Saves the data to server */ save() { return this.onboardingService.save(); } /** * Sets the pension contract number as a test number according to the selected company. */ setPensionNumberForTest() { this.model.products.pension.pensionContractNumber = gM.getPensionNumberForTest(this.model.products.pension.pensionCompany); } /** * Launches the wizard. * @param accountId Optional account id. */ launch(e = null) { return this.onboardingService.launchCustomerOnboarding(e); } }; wT.$inject = ["$scope", "WizardService", "OnboardingService", "SessionService", "AuthorizedAccountService", "AjaxNg1", "$location", "data"]; let mC = wT; const AT = class AT extends Qr { constructor(e, t, a, s, i, r) { super(e, t), this.onboardingService = a, this.sessionService = s, this.uiHelpers = i, this.signatureService = r, this.wizardSteps = [ { title: "SALAXY.NG1.WorkerOnboardingComponent.stepUserInfo.title", heading: "SALAXY.NG1.WorkerOnboardingComponent.stepUserInfo.heading", intro: "", active: !0, view: "salaxy-components/modals/onboarding/worker/user-info.html", buttonsView: "salaxy-components/modals/onboarding/worker/firstPageButtons.html" }, /* { title: "SALAXY.NG1.WorkerOnboardingComponent.stepPhoneNumberVerify.title", heading: "SALAXY.NG1.WorkerOnboardingComponent.stepPhoneNumberVerify.heading", intro: "SALAXY.NG1.WorkerOnboardingComponent.stepPhoneNumberVerify.intro", view: "salaxy-components/modals/onboarding/worker/phonenumber-verify.html", buttonsView: "salaxy-components/modals/onboarding/worker/phoneNumberVerifyButtons.html", }, */ { title: "SALAXY.NG1.WorkerOnboardingComponent.stepContract.stepTitle", heading: "SALAXY.NG1.WorkerOnboardingComponent.stepContract.heading", intro: "SALAXY.NG1.WorkerOnboardingComponent.stepContract.intro", view: "salaxy-components/modals/onboarding/worker/contract-worker.html", buttonsView: "salaxy-components/modals/onboarding/worker/contractButtons.html" } ], this.isStepProceeding = !1; } /** * Implement IController */ $onInit() { this.wizardService.setSteps(this.wizardSteps), this.wizardService.activeStepNumber = 1, this.getSignatureMethods(); } /** * Navigates to the next step if possible and saves the data. */ goNext() { return this.isStepProceeding ? Promise.resolve(!1) : (this.isStepProceeding = !0, this.save().then(() => (super.goNext(), this.isStepProceeding = !1, !0)).catch((e) => (this.isStepProceeding = !1, !1))); } /** Returns true if user can go forward in wizard */ get canGoNext() { return !!(this.steps.length > this.step && this.steps[this.step] && !this.steps[this.step].disabled && this.formDataValidity); } /** Runs a check function before going forward */ goNextIf(e) { e(() => this.goNext()); } /** * Navigates to the previous step if possible and saves the data. */ goPrevious() { this.isStepProceeding || (this.isStepProceeding = !0, this.save().then(() => { super.goPrevious(), this.isStepProceeding = !1; }).catch((e) => { this.isStepProceeding = !1; })); } /** * Saves the data to server */ save() { return this.model.signature.email = this.model.person.contact.email, this.model.signature.telephone = this.model.person.contact.telephone, this.model.signature.personName = (this.model.person.firstName + " " + this.model.person.lastName).trim(), this.onboardingService.save(); } /** * Returns signing url. */ get vismaSignUrl() { const e = this.model.signature.method; return this.onboardingService.getDigitalSignUrl(e); } /** * The onboarding model is provided by the onboarding service. */ get model() { return this.onboardingService.model; } /** Returns the PDF preview address for the authorization pdf. */ getPdfPreviewAddress() { return this.onboardingService.getPdfPreviewAddress(); } /** * Returns validation error for key if exists. * @param key - Validation error key. */ getValidationError(e) { return this.model && this.model.validation ? this.model.validation.errors.find((t) => t.key === e) : null; } /** * Resets validation error for key if exists. * @param key - Validation error key. */ removeValidationError(e) { this.model && this.model.validation && (this.model.validation.errors = this.model.validation.errors.filter((t) => t.key !== e)); } /** * Checks if the given string is other identifier than Finnish Personal Identification Number * @param ssn given social security number */ isOtherIdentifier(e) { return /^.{7}[9]/.test((e || "").trim()); } /** * Launches the wizard. * @param id Optional onboarding id. */ launch(e = null) { return this.onboardingService.launchWorkerOnboarding(e); } getSignatureMethods() { const e = this.signatureService.getMethods("telia"); this.signatureMethods = e.map((t) => ({ value: t.value, label: t.title, imgSrc: t.img })); } }; AT.$inject = ["$scope", "WizardService", "OnboardingService", "SessionService", "UiHelpers", "SignatureService"]; let fC = AT; const CT = class CT extends Qr { constructor(e, t, a, s, i, r) { super(e, t, r), this.onboardingService = a, this.sessionService = s, this.signatureService = i, this.wizardSteps = [ { title: "Käyttäjän tiedot", heading: "Tervetuloa, Palkkamyllyyn!", intro: `Palkkamyllyn tarjoaa Rakennusliitto ry, joka toimii henkilötietojen käsittelijänä ja vastaa myös asiakaspalvelusta. Palvelun tuottajana, teknisenä toteuttajana ja myös henkilötietojen käsittelijä toimii Suomen Palkanlaskenta Oy (Palkkaus.fi).`, active: !0, view: "salaxy-components/modals/onboarding/household/wizard_index.html", buttonsView: "salaxy-components/modals/onboarding/household/firstPageButtons.html" }, /* { title: "Puhelinnumero", heading: "Puhelinnumero", intro: "Puhelinnumeroa tarvitsemme yhteydenpitoa varten. Jos rekisteröit Siirto-palvelussa olevan puhelinnumeron, voit maksaa ja vastaanottaa palkkoja mobiilimaksuilla. Vahvistamme antamasi numeron.", view: "salaxy-components/modals/onboarding/household/phoneNumber.html", buttonsView: "salaxy-components/modals/onboarding/household/phoneNumberButtons.html", }, { title: "Puhelinnumeron vahvistaminen", heading: "Puhelinnumeron vahvistaminen", intro: "Olemme lähettäneet sinulle SMS-viestin varmistaaksemme numerosi. Syötä viestissä oleva vahvistuskoodi tähän.", view: "salaxy-components/modals/onboarding/household/phoneNumberVerify.html", buttonsView: "salaxy-components/modals/onboarding/household/phoneNumberVerifyButtons.html", }, */ { title: "Palkanmaksun tiedot", heading: "Palkanmaksun tiedot", view: "salaxy-components/modals/onboarding/household/household.html", buttonsView: "salaxy-components/modals/onboarding/household/householdButtons.html" }, { title: "Palvelusopimus", heading: "Palvelusopimus ja valtuutus", view: "salaxy-components/modals/onboarding/household/contract.html", buttonsView: "salaxy-components/modals/onboarding/household/contractButtons.html" } ], this.isStepProceeding = !1; } /** * Implement IController */ $onInit() { this.wizardService.setSteps(this.wizardSteps), this.wizardService.activeStepNumber = 1; const e = this.signatureService.getMethods("telia"); this.visibleSignatureMethods = e.filter((t) => t.isPopular).map((t) => ({ value: t.value, label: t.title, imgSrc: t.img })); } /** * Navigates to the next step if possible and saves the data. */ goNext() { return this.isStepProceeding ? Promise.resolve(!1) : (this.isStepProceeding = !0, this.save().then(() => (super.goNext(), this.isStepProceeding = !1, !0)).catch((e) => (this.isStepProceeding = !1, !1))); } /** Returns true if user can go forward in wizard */ get canGoNext() { return !!(this.steps.length > this.step && this.steps[this.step] && !this.steps[this.step].disabled && this.formDataValidity); } /** Runs a check function before going forward */ goNextIf(e) { e(() => this.goNext()); } /** * Navigates to the previous step if possible and saves the data. */ goPrevious() { this.isStepProceeding || (this.isStepProceeding = !0, this.save().then(() => { super.goPrevious(), this.isStepProceeding = !1; }).catch((e) => { this.isStepProceeding = !1; })); } /** * Saves the data to server */ save() { return this.model.signature.email = this.model.person.contact.email, this.model.signature.telephone = this.model.person.contact.telephone, this.model.signature.personName = (this.model.person.firstName + " " + this.model.person.lastName).trim(), this.onboardingService.save(); } /** * Returns signing url. */ get vismaSignUrl() { const e = this.model.signature.method; return this.onboardingService.getDigitalSignUrl(e); } /** * The onboarding model is provided by the onboarding service. */ get model() { return this.onboardingService.model; } /** Returns the PDF preview address for the authorization pdf. */ getPdfPreviewAddress() { return this.onboardingService.getPdfPreviewAddress(); } /** * Returns validation error for key if exists. * @param key - Validation error key. */ getValidationError(e) { return this.model && this.model.validation ? this.model.validation.errors.find((t) => t.key === e) : null; } /** * Resets validation error for key if exists. * @param key - Validation error key. */ removeValidationError(e) { this.model && this.model.validation && (this.model.validation.errors = this.model.validation.errors.filter((t) => t.key !== e)); } /** * Launches the wizard. * @param id Optional onboarding id. */ launch(e = null) { return this.onboardingService.launchHouseholdOnboarding(e); } }; CT.$inject = ["$scope", "WizardService", "OnboardingService", "SessionService", "SignatureService", "data"]; let gC = CT; const ST = class ST extends Qr { constructor(e, t, a, s, i, r, o, l) { super(e, t, o), this.onboardingService = a, this.sessionService = s, this.ajax = i, this.$location = r, this.uiHelpers = l, this.isStepProceeding = !1; } /** * Implement IController */ $onInit() { this.wizardService.setSteps(this.getWizardSteps()), this.model && this.model.signature.isProcura ? this.wizardService.activeStepNumber = 3 : this.wizardService.activeStepNumber = 1; } /** Company wizard configuration */ getWizardSteps() { const e = []; return e.push( { title: "SALAXY.NG1.CompanyOnboardingComponent.step1.title", intro: "SALAXY.NG1.CompanyOnboardingComponent.step1.intro", active: !0, view: "salaxy-components/modals/onboarding/company/wizard_index.html", buttonsView: "salaxy-components/modals/onboarding/company/firstPageButtons.html" } ), this.showCompanySelection && e.push( { title: "SALAXY.NG1.CompanyOnboardingComponent.stepSuomiFi.title", intro: "SALAXY.NG1.CompanyOnboardingComponent.stepSuomiFi.intro", view: "salaxy-components/modals/onboarding/company/suomifi.html", buttonsView: "salaxy-components/modals/onboarding/company/suomifiButtons.html" } ), e.push( { title: "SALAXY.NG1.CompanyOnboardingComponent.stepCompanyInfo.title", intro: "SALAXY.NG1.CompanyOnboardingComponent.stepCompanyInfo.intro", view: "salaxy-components/modals/onboarding/company/company.html", buttonsView: "salaxy-components/modals/onboarding/company/defaultWizardButtons.html" }, /* { title: "SALAXY.NG1.CompanyOnboardingComponent.stepCompanyLegal.title", view: "salaxy-components/modals/onboarding/company/company-legal.html", buttonsView: "salaxy-components/modals/onboarding/company/defaultWizardButtons.html", }, */ { title: "SALAXY.NG1.CompanyOnboardingComponent.stepContract.title", view: "salaxy-components/modals/onboarding/company/contract.html", buttonsView: "salaxy-components/modals/onboarding/company/contractButtons.html" } ), e; } /** * Navigates to the next step if possible and saves the data. */ goNext() { return this.isStepProceeding ? Promise.resolve(!1) : (this.isStepProceeding = !0, this.save().then(() => (super.goNext(), this.isStepProceeding = !1, !0)).catch((e) => (this.isStepProceeding = !1, !1))); } /** Returns true if user can go forward in wizard */ get canGoNext() { return !!(this.steps.length > this.step && this.steps[this.step] && !this.steps[this.step].disabled && this.formDataValidity); } /** * Navigates to the previous step if possible and saves the data. */ goPrevious() { this.isStepProceeding || (this.isStepProceeding = !0, this.save().then(() => { super.goPrevious(), this.isStepProceeding = !1; }).catch((e) => { this.isStepProceeding = !1; })); } /** * Saves the data to server */ save() { return this.model.signature.email = this.model.person.contact.email, this.model.signature.telephone = this.model.person.contact.telephone, this.model.signature.personName = (this.model.person.firstName + " " + this.model.person.lastName).trim(), this.onboardingService.save(); } /** * Returns signing url. */ get vismaSignUrl() { return this.onboardingService.getDigitalSignUrl(); } /** * The onboarding model is provided by the onboarding service. */ get model() { return this.onboardingService.model; } /** IF true, the Suomi.fi company selection is used. */ get showCompanySelection() { return this.model && this.model.company && this.model.company.roles && this.model.company.roles.some((t) => t === lC.Accountant || t === lC.AccountantCandidate); } /** Returns the PDF preview address for the authorization pdf. */ getPdfPreviewAddress() { return this.onboardingService.getPdfPreviewAddress(); } /** * Existing company alert. */ get existingCompanyAlert() { const e = this.sessionService.session?.currentAccount?.id; return this.model?.company?.resolvedId && this.model.company.resolvedId != e; } /** Go to suomi fi ypa */ goToSuomifi() { const e = this.$location.url(); let t = this.$location.absUrl(); e.length > 1 && (t = t.substring(0, t.indexOf(e))), t = t.replace(/\/$/, "").trim(); const a = this.ajax.getCurrentToken(), s = a ? `${encodeURIComponent(a)}` : "", i = t.indexOf("&") >= 0 || t.indexOf("?") >= 0 ? "&url=" : "", r = `${t}${i}/onboarding/company/${this.model.id}${s ? "&ob_token=" + s : ""}`, o = `${t}${i}/onboarding/company/${this.model.id}${s ? "&ob_token=" + s : ""}`; this.save().then(() => { window.location.assign(`${this.ajax.getServerAddress()}/Onboarding/CompanySelection?OnboardingId=${encodeURIComponent(this.model.id)}&Language=${encodeURIComponent(P.getLanguage())}&SuccessUrl=${encodeURIComponent(o)}&CancelUrl=${encodeURIComponent(r)}${s ? "&access_token=" + s : ""}`); }); } /** * Launches the wizard. * @param id Optional onboarding id. */ launch(e = null) { return this.onboardingService.launchCompanyOnboarding(e); } /** * Sets the company's business id, clears the YTJ search results fetches other company info's via YTJ search and saves * @param businessId The business id that is set as the company's business id */ chooseBusinessId(e) { this.model.company.businessId = e, this.model.company.ytjSearch = null, this.searchYtj(); } /** * Sets the DoYtjUpdate flag to true and saves. * @param searchType - If true, sets the business ID to null * Use this option to force a YTJ name search, even if there already is something written in business ID field. */ searchYtj(e) { this.model.company.companyType = null, this.model.company.contact.street = null, this.model.company.contact.city = null, this.model.company.contact.postalCode = null, this.model.company.ytjSearch = null, this.model.company.doYtjUpdate = !0, e === "name" && (this.model.company.businessId = null), e === "businessId" && (this.model.company.name = null), this.save(); } /** * Returns validation error for key if exists. * @param key - Validation error key. */ getValidationError(e) { return this.model && this.model.validation ? this.model.validation.errors.find((t) => t.key === e) : null; } /** Opens wizard as modal dialog */ openSigningWizardDialog(e = null) { const t = this.sessionService.getCurrentCss(), a = this.sessionService.getOrigin(), s = a + (t ? `popup.html#settings/signing?skin=${t}&lang=${P.getLanguage()}&id=${this.onboardingService.model?.id ?? ""}#access_token=${this.ajax.getCurrentToken()}` : `popup.html#settings/signing?lang=${P.getLanguage()}&id=${this.onboardingService.model?.id ?? ""}#access_token=${this.ajax.getCurrentToken()}`); return this.uiHelpers.showExternalDialog(e, s, { id: e, origin: a }, { width: 1080, height: 800 }).then((i) => { if (i?.action != "cancel") return this.checkSession(); }); } /** Launches company wizard. */ launchSigningWizard() { const e = this.readTokenFromUrl(this.$location.absUrl(), "data="), t = JSON.parse(atob(decodeURIComponent(e)))?.id, a = JSON.parse(atob(decodeURIComponent(e)))?.origin; return this.onboardingService.getOnboardingData(t).then(() => { const s = this.sessionService.getCurrentCss(); return this.onboardingService.model.ui.successUrl = a + (s ? `popup.html#settings/signing-success?skin=${s}&lang=${P.getLanguage()}&id=${this.onboardingService.model?.id ?? ""}#access_token=${this.ajax.getCurrentToken()}` : `popup.html#settings/signing-success?lang=${P.getLanguage()}&id=${this.onboardingService.model?.id ?? ""}#access_token=${this.ajax.getCurrentToken()}`), this.onboardingService.model.ui.cancelUrl = this.onboardingService.model.ui.successUrl.replace("/signing-success?", "/signing-cancel?"), this.onboardingService.save().then(() => this.onboardingService.launchCompanyOnboarding(this.onboardingService.model.id)); }); } /** Reloads the current session*/ checkSession() { return this.sessionService.checkSession(); } readTokenFromUrl(e, t) { const a = e.toLowerCase().indexOf(t); if (a >= 0) { const s = e.indexOf("&", a); return s >= 0 ? e.substring(a + t.length, s) : e.substring(a + t.length); } return null; } }; ST.$inject = ["$scope", "WizardService", "OnboardingService", "SessionService", "AjaxNg1", "$location", "data", "UiHelpers"]; let yC = ST; const $T = class $T { constructor(e, t, a, s, i, r, o, l) { this.$scope = e, this.onboardingService = t, this.sessionService = a, this.signatureService = s, this.$sce = i, this.uiHelpers = r, this.ajax = o, this.$timeout = l, this.showInPopup = !1, this.isSigninStarted = !1, this.$onInit = () => { this.init(), this.sessionService.subscribe(this.$scope, () => { this.init(); }), this.isContactPersonSigner = !0; }; } /** Saves the current onboarding model. */ save() { return this.isContactPersonSigner && (this.model.company.contact.email = this.model.signature.email, this.model.company.contact.telephone = this.model.signature.telephone), this.onboardingService.save().then((e) => (this.pdfPreviewUrl = null, e)); } /** * The onboarding model is provided by the onboarding service. */ get model() { return this.onboardingService.model?.company && (this.onboardingService.model.company.language = P.getLanguage()), this.onboardingService.model?.person && (this.onboardingService.model.person.language = P.getLanguage()), this.onboardingService.model; } /** Returns the PDF preview address for the authorization pdf. */ getPdfPreviewAddress() { return !this.pdfPreviewUrl && this.model?.id && (this.pdfPreviewUrl = this.$sce.trustAsResourceUrl(this.onboardingService.getPdfPreviewAddress(!0) + "&t=" + (/* @__PURE__ */ new Date()).getTime() + "&language=" + this.model.company.language)), this.pdfPreviewUrl; } /** * Starts Visma sign * If this.showInPopup is false, saves the model and starts the signature. * If this.showInPopup is true, saves the model, starts the signature and then opens success dialog. * @param authMethod Method of authentication (bank selection). * Only used for Persons (Telia methods), ignored for companies. */ startDigitalSignature(e) { this.isSigninStarted = !0, this.showInPopup ? this.save().then(() => { let t = this.sessionService.getCurrentCss() || ""; t && (t = `skin=${t}&`); const a = this.sessionService.getOrigin() + `popup.html#settings/signing-success?${t}lang=${P.getLanguage()}&id=${this.onboardingService.model?.id ?? ""}#access_token=${this.ajax.getCurrentToken()}`, s = this.onboardingService.getDigitalSignUrl(e, null, null, a, a.replace("/signing-success?", "/signing-cancel?")); return this.$timeout(() => this.isSigninStarted = !1, 2e3), this.uiHelpers.showExternalDialog("vismaSignPopup", s, {}, { width: 1080, height: 800 }).then((i) => { if (i?.action != "cancel") return this.sessionService.checkSession(); }); }) : (this.uiHelpers.showLoading("SALAXY.NG1.SigningComponent.dialog.header", `Siirrytään allekirjoitukseen (${e})`), this.save().then(() => { window.top.location.href = this.onboardingService.getDigitalSignUrl(e); })); } /** List of supported Signature methods */ get methods() { return this.signatureService.getMethods(); } /** * Returns the SignatureMethod for given value. * @param value - value for SignatureMethod, e.g. tupas-nordea. */ getMethod(e) { const t = this.methods.filter((a) => a.value === e); return t.length > 0 ? t[0] : null; } /** * Signs the authorization contract for the current user. * Creates a partner contract authorization and updates the session. * @returns Promise that resolves when the contract is signed and session is updated * @throws Error if the contract signing fails */ async signPartnerContract() { const e = { authorizationType: CW.PartnerContract }, t = this.uiHelpers.showLoading("SALAXY.UI_Terms.wait"); try { await this.ajax.postJSON("/onboarding/contract", e), await this.sessionService.checkSession(); } catch (a) { console.error("Failed to sign partner contract:", a); } finally { t.dismiss(); } } init() { if (this.isSigningOk = this.sessionService.isSigningOk(), this.pdfPreviewUrl = null, this.isSigningRequired = !this.sessionService.isSigningOk(), this.sessionService.isSessionChecked && this.sessionService.isAuthenticated) { const e = this.sessionService.session.currentAccount.id; if (this.onboardingService.model && this.onboardingService.model.company.resolvedId === e) return; this.onboardingService.model = null, this.onboardingService.id = null, this.onboardingService.getOnboardingDataForAccount(this.sessionService.session.currentAccount.id).then(() => { if (this.onboardingService.model) { this.onboardingService.model.signature.isPep = null, this.onboardingService.model.company.ownership.isRequiredTracking = null, this.onboardingService.model.id || this.onboardingService.save(); return; } else this.onboardingService.model = { accountType: cr.Company, signature: {} }, this.onboardingService.save(); }); } } }; $T.$inject = ["$scope", "OnboardingService", "SessionService", "SignatureService", "$sce", "UiHelpers", "AjaxNg1", "$timeout"]; let Ky = $T; const kT = class kT { /** * Creates a new SignatureController * @param signatureService - Service that handles the communication to the server * @ignore */ constructor(e) { this.signatureService = e, this.$onInit = () => { }; } /** * Legacy list of supported Visma Sign Signature methods. */ get methods() { return this.getMethods("tupas"); } /** * List of supported Signature methods * @param methodGroup - Method group "telia" for Telia Tunnistus and "tupas" for Visma Sign. Default is "tupas". */ getMethods(e = "tupas") { return this.signatureService.getMethods(e); } /** * Returns the SignatureMethod for given value. * @param value - value for SignatureMethod, e.g. tupas-nordea. */ getMethod(e) { return this.signatureService.getMethods("tupas").find((t) => t.value === e) ?? this.signatureService.getMethods("telia").find((t) => t.value === e); } }; kT.$inject = [ "SignatureService" ]; let bC = kT; const TT = class TT { /** * Creates a new CrudControllerBase. * @param crudService The the BaseService instance that is used for communicating to server. * @param $location Angular.js Location service that is used for navigation. Especially the list views. * @param $attrs Angular.js Attisbutes for determining whether events have been bound to. * @param uiHelpers - Salaxy ui helpers service. */ constructor(e, t, a, s) { if (this.crudService = e, this.$location = t, this.$attrs = a, this.uiHelpers = s, this.copyIdAsNew = (i) => { const r = this.list.find((o) => o.id === i); return r ? this.copyAsNew(r) : null; }, this.listSelect = (i) => { this.$attrs.onListSelect ? this.onListSelect({ item: i }) : this.detailsUrl ? this.$location.url(this.detailsUrl + (i.id || i.rowIndex)) : this.setCurrent(i); }, this.listSelectId = (i) => { const r = this.list.find((o) => o.id === i); r && this.listSelect(r); }, this.delete = (i, r) => this.uiHelpers.showConfirm(r || "SALAXY.NG1.ApiCrudObjectComponent.deleteDialog").then((o) => o ? this.$attrs.onDelete ? this.onDelete({ deleteResult: this.deleteNoConfirm(i) }) : (this.listUrl && this.$location.url(this.listUrl), this.deleteNoConfirm(i)) : Promise.resolve(!1)), !e) throw new Error("crudService is undefined in CrudControllerBase"); if (!t) throw new Error("$location is undefined in CrudControllerBase"); if (!s) throw new Error("uiHelpers is undefined in CrudControllerBase"); if (!a) throw new Error("$attrs is undefined in CrudControllerBase"); } /** * Implement IController by providing onInit method. * We currently do nothing here, but if you override this function, * you should call this method in base class for future compatibility. */ $onInit() { } /** Gets the Current selected item. */ get current() { return this.getBindingMode() === "model" ? this.model.$viewValue : this.crudService.current; } /** Gets the list of all CRUD objects listed. */ get list() { return this.crudService.list; } /** * Creates a new item. The item is not saved in this process yet. * Item is set as current unless onCreateNew is specified => Then you are responsible for doing it yourself. * If detailsUrl is specified, the browser is redirectedted there. * Current item is set also in this case (as opposed to listSelect) because the new item does not yet have an id * and passing it in current item is the only way using router. * Use onCreateNew event or crudService.getBlank() if you do not want to set the current item. * @param newItem Specify the new item if you want to initialize it with specific values. * In most cases, you should let the system create it with defaults. */ createNew(e = null) { return e || (e = this.crudService.getBlank()), this.$attrs.onCreateNew ? this.onCreateNew({ item: e }) : (this.setCurrent(e), this.detailsUrl && this.$location.url(this.detailsUrl + "new#" + (/* @__PURE__ */ new Date()).getTime())), e; } /** Copies the current item and sets it as the new current */ copyCurrent() { this.current && this.setCurrent(this.crudService.copyAsNew(this.current)); } /** * Creates a copy of a given item and sets it as current * unless onCreateNew is specified => Then you are responsible for doing it yourself. * If detailsUrl is specified, the browser is redirectedted there. * Current item is set also in this case (as opposed to listSelect) because the new item does not yet have an id * and passing it in current item is the only way using router. * Use onCreateNew event or crudService.copyAsNew() if you do not want to set the current item. * @param copySource The item to copy as new. * @returns The new item that is created. */ copyAsNew(e) { const t = this.crudService.copyAsNew(e); return this.createNew(t); } /** * Mode for data binding is "singleton" by default. * This means that this.current is bound to crudService.current. * If ng-mode