docs: def get_available_splits_for_account(self, account: Account) -> List[Split]:
          """ Returns all unused splits in the account. Used for the calculation of avg.price.
          The split that has been partially used will have its quantity reduced to available
          quantity only. """
          available_splits = []
          # get all purchase splits in the account
          query = (
              self.get_splits_query()
              .filter(Split.account == account)
          )
          buy_splits = (
              query.filter(Split.quantity > 0)
              .join(Transaction)
              .order_by(desc(Transaction.post_date))
          ).all()
          buy_q = sum(split.quantity for split in buy_splits)
          sell_splits = query.filter(Split.quantity < 0).all()
          sell_q = sum(split.quantity for split in sell_splits)
          balance = buy_q + sell_q
          if balance == 0:
              return available_splits
  
          for real_split in buy_splits:
              split = splitmapper.map_split(real_split, SplitModel())
  
              if split.quantity < balance:
                  # take this split and reduce the balance.
                  balance -= split.quantity
              else:
                  # This is the last split.
                  price = split.value / split.quantity
                  # Take only the remaining quantity.
                  split.quantity -= balance
                  # Also adjust the value for easier calculation elsewhere.
                  split.value = balance * price
                  # The remaining balance is now distributed into splits.
                  balance = 0
              # add to the collection.
              available_splits.append(split)
              if balance == 0:
                  break
  
          return available_splits