async def _create_certificates_chain(order_amount: int, card_rows: list[tuple[Card]]) -> list[Card] | None: """Create chain of codes to give for client if amount not covered send massage to Telegram :param order_amount: _description_ :type order_amount: int :param card_rows: _description_ :type card_rows: list[tuple[Card]] :return: _description_ :rtype: list[Card] | None """ card_list = list() amount = order_amount if amount > 0: for card in card_rows: logger.info(f"\n{card[0].amount=} {amount=}") if amount - card[0].amount > 0: amount -= card[0].amount card_list.append(card[0]) elif amount - card[0].amount == 0: amount -= card[0].amount card_list.append(card[0]) return card_list else: continue text = f"_create_certificates_chain amount not covered {amount=} You must buy codes!!!" logger.critical(text) await send_telegram_message(text) return None