UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

47 lines (46 loc) 3.33 kB
try { let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack; n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "62f5a8a3-82c8-43f5-8f42-357475f5cc13", e._sentryDebugIdIdentifier = "sentry-dbid-62f5a8a3-82c8-43f5-8f42-357475f5cc13"); } catch (e) {} import { t as TaskTypes } from "./taskTypes-NawDTp5n.js"; import { i as getDirectEntityAssociations } from "./entityAssociationUtil-C-wflW8q.js"; import { t as DecisionMakerTypes } from "./decision-maker-type-NR4GFAeT.js"; import { r as getDecisionMakerRequirements } from "./decisionMaker-Dt53wKqO.js"; //#region src/utils/decisionMakerRoles.ts var getOwnDecisionMakers = (rootLegalEntity) => { if (!rootLegalEntity?.entityAssociations) return []; return rootLegalEntity.entityAssociations.filter((entityAssociation) => Object.values(DecisionMakerTypes).includes(entityAssociation.type) && entityAssociation.associatorId === rootLegalEntity.id); }; var getDecisionMakers = (rootLegalEntity, companyLegalEntityId) => getDirectEntityAssociations(rootLegalEntity, companyLegalEntityId).filter((association) => Object.values(DecisionMakerTypes).includes(association.type)); var getOwnSignatories = (rootLegalEntity) => getOwnDecisionMakers(rootLegalEntity).filter((decisionMaker) => decisionMaker.type === DecisionMakerTypes.SIGNATORY); var getOwnDecisionMakersLegalEntityIds = (rootLegalEntity) => getOwnDecisionMakers(rootLegalEntity).map((ea) => ea.legalEntityId).filter((id) => id !== void 0); var getDecisionMakerCount = (rootLegalEntity) => { return getOwnDecisionMakers(rootLegalEntity).reduce((decisionMakerCount, decisionMaker) => { decisionMakerCount[decisionMaker.type] = (decisionMakerCount[decisionMaker.type] ?? 0) + 1; return decisionMakerCount; }, {}); }; var getAllowedDecisionMakerRoles = (rootLegalEntity, taskType, scenarios) => { if (taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER) return [DecisionMakerTypes.OWNER]; const existingDecisionMakerCount = getDecisionMakerCount(rootLegalEntity); const registeredCountry = rootLegalEntity?.organization?.registeredAddress?.country; const allowedRoles = getDecisionMakerRequirements(registeredCountry, scenarios).reduce((acc, requirements) => { const { roleTypes, max } = requirements; if (roleTypes.length === 1) { const role = roleTypes[0]; if ((existingDecisionMakerCount?.[role] ?? 0) < max) acc.push(role); } return acc; }, []); return [...new Set(allowedRoles)]; }; var hasMinRequiredDecisionMakerCount = (rootLegalEntity) => { const existingDecisionMakerCount = getDecisionMakerCount(rootLegalEntity); const registeredCountry = rootLegalEntity?.organization?.registeredAddress?.country; return getDecisionMakerRequirements(registeredCountry).every((requirements) => { const { roleTypes, min } = requirements; return roleTypes.some((role) => min ? existingDecisionMakerCount?.[role] ?? min <= 0 : true); }); }; //#endregion export { getOwnSignatories as a, getOwnDecisionMakersLegalEntityIds as i, getDecisionMakers as n, hasMinRequiredDecisionMakerCount as o, getOwnDecisionMakers as r, getAllowedDecisionMakerRoles as t };