wooptoo

Ultimate Beneficial Owner

Jan 18th, 2024 (edited)
1,007
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.68 KB | Source Code | 0 0
  1. """
  2. * Every company has a shareholding structure (a.k.a. beneficial owners).
  3. * Beneficial owner can be either a individual person or another company.
  4. * Beneficial owner is characterized by % percentage in ownership.
  5. * Shareholding structures can be multi-layered (see examples below)
  6. * Ownership is transitive, so if person X owns 100% of company A which
  7.  owns 100% of company B, then, effectively, person X owns 100% of company B
  8. * Your goal is to write code that finds all ultimate (direct & indirect)
  9.  individual beneficial owners of a company & calculates their percentages of ownership.
  10.  
  11. ---------------------------------------
  12. Example 1:
  13. - Input (beneficial owners):
  14.           C
  15.        /      \
  16.     I1(40%)  I2(60%)
  17.  
  18. - Output (ultimate beneficial owners):
  19.  I1 (40%), I2 (60%)
  20. ---------------------------------------
  21. Example 2:
  22. - Input (beneficial owners):
  23.           C
  24.        /      \
  25.     C1(50%)  I1(50%)
  26.     /    \
  27. I2(50%)  I3(50%)
  28.  
  29. - Output (ultimate beneficial owners):
  30.  I1 (50%), I2 (25%), I3 (25%)
  31. ---------------------------------------
  32. Example 3:
  33. - Input (beneficial owners):
  34.               C
  35.            /      \
  36.        C1(50%)  I1(50%)
  37.        /    \
  38.    C2(40%)  I1(60%)
  39.    /     \
  40. I2(10%) I3(90%)
  41.  
  42. - Output (ultimate beneficial owners):
  43.  I1 (80%), I2 (2%), I3 (18%)
  44. ---------------------------------------
  45. """
  46.  
  47.  
  48. # Direct beneficial owner (aka shareholder) of a company.
  49. # In case of corporate owner, "registration_number" field contains company identifier.
  50. # In case of individual owner, "registration_number" is None.
  51. # Ownership is a float [0, 1]
  52. BeneficialOwner = tuple[
  53.     str, str | None, float
  54. ]  # (name, registration_number, ownership)
  55.  
  56.  
  57. # Ultimate beneficial owner of a company. Always an individual.
  58. # Ownership is a float [0, 1]
  59. UltimateBeneficialOwner = tuple[str, float]  # (name, ownership)
  60.  
  61.  
  62. class BusinessRegisterClient:
  63.     """
  64.    A client that contains business register integration implementation.
  65.    It has a method "get_beneficial_owners()" that returns a list of direct owners
  66.    of a given company based on its registration number.
  67.    """
  68.  
  69.     def get_beneficial_owners(
  70.         self, registration_number: str
  71.     ) -> list[BeneficialOwner]:
  72.         # 3rd party API call
  73.         # ASSUME IT'S ALREADY IMPLEMENTED
  74.         ...
  75.  
  76.  
  77. class UBOCalculator:
  78.     """
  79.    A class that finds a set of ultimate beneficial owners of a given company.
  80.    """
  81.  
  82.     def __init__(self, br_client: BusinessRegisterClient):
  83.         self.br_client = br_client
  84.  
  85.     def get_ultimate_beneficial_owners(
  86.         self, registration_number: str
  87.     ) -> set[UltimateBeneficialOwner]:
  88.         # YOUR CODE GOES HERE
  89.         ...
  90.  
Advertisement
Add Comment
Please, Sign In to add comment