/**
 * Calculate the total amount of all invoices for each client.
 *
 * Given a nested dictionary, where the keys are the account names and the values are dictionaries
 * of invoices, with each invoice containing the name of the client, description, and amount.
 * The function should calculate and return the total amount of all invoices for each client.
 *
 * @param invoices A nested dictionary with the account names as keys and the invoice dictionaries as values.
 * @return A dictionary with the account names as keys and the total amount of all invoices as values.
 */
fun calculateInvoiceTotal(invoices: Map<String, List<Map<String, Any>>>): Map<String, Any> {

    val invoiceTotals = mutableMapOf<String, Any>()

    for ((account, invoiceList) in invoices) {
        var totalAmount = 0

        for (invoice in invoiceList) {
            val invoiceAmount = invoice["amount"] as? Int ?: 0
            totalAmount += invoiceAmount
        }

        if (totalAmount > 100000) {
            invoiceTotals[account] = totalAmount
        } else {
            invoiceTotals[account] = "Not enough total amount: $totalAmount"
        }
    }

    return invoiceTotals
}
/**
 * Calculate the total amount of all invoices for each client.
 *
 * Given a nested dictionary, where the keys are the account names and the values are dictionaries
 * of invoices, with each invoice containing the name of the client, description, and amount.
 * The function should calculate and return the total amount of all invoices for each client.
 *
 * @param invoices A nested dictionary with the account names as keys and the invoice dictionaries as values.
 * @return A dictionary with the account names as keys and the total amount of all invoices as values.
 */
fun calculateInvoiceTotal(invoices: Map<String, List<Map<String, Any>>>): Map<String, Any> {
/**
 * Calculate the total amount of all invoices for each client.
 *
 * Given a nested dictionary, where the keys are the account names and the values are dictionaries
 * of invoices, with each invoice containing the name of the client, description, and amount.
 * The function should calculate and return the total amount of all invoices for each client.
 *
 * @param invoices A nested dictionary with the account names as keys and the invoice dictionaries as values.
 * @return A dictionary with the account names as keys and the total amount of all invoices as values.
 */
fun calculateInvoiceTotal(invoices: Map<String, List<Map<String, Any>>>): Map<String, Any> {

    val invoiceTotals = mutableMapOf<String, Any>()

    for ((account, invoiceList) in invoices) {
        var totalAmount = 0

        for (invoice in invoiceList) {
            val invoiceAmount = invoice["amount"] as? Int ?: 0
            totalAmount += invoiceAmount
        }

        if (totalAmount > 100000) {
            invoiceTotals[account] = totalAmount
        } else {
            invoiceTotals[account] = "Not enough total amount: $totalAmount"
        }
    }

    return invoiceTotals
}