/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.api;

import static de.srsoftware.umbrella.core.Util.mapValues;

import de.srsoftware.tools.Mappable;
import de.srsoftware.umbrella.core.constants.Field;
import de.srsoftware.umbrella.core.model.Account;
import de.srsoftware.umbrella.core.model.Transaction;
import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface AccountingService {
	public record AccountData(Account account, List<Transaction> transactions, HashMap<Long, UmbrellaUser> userMap) implements Mappable {
		public static AccountData of(Account account, List<Transaction> transactions, HashMap<Long, UmbrellaUser> userMap) {
			return new AccountData(account, transactions, userMap);
		}

		@Override
		public Map<String, Object> toMap() {
			return Map.of(
				Field.ACCOUNT,account.toMap(),
				Field.TRANSACTIONS,transactions.stream().map(Transaction::toMap).toList(),
				Field.USER_LIST,mapValues(userMap)
			);
		}
	}

	AccountData loadAccount(long accountId);
}
