// -*- mode: protobuf -*-
// Configuration for the computation of returns.

syntax = "proto2";

package beancount.returns;

// Configuration for returns script.
message Config {

  // The list of source investments which each define a series of cash flows.
  optional InvestmentConfig investments = 1;

  // A list of named report groups which combine previously defined sets of
  // investments.
  optional ReportConfig reports = 2;
}

message InvestmentConfig {

  // A list of investments.
  repeated Investment investment = 1;

  // Patterns to match income and expenses accounts to for categorization.
  // These have defaults based on the root of the account name.
  optional string income_regexp = 2;
  optional string expenses_regexp = 3;
}

message ReportConfig {
  repeated ReportGroup report = 1;
}

// Configuration for extracting returns information for one investment
// (typically stored in one account).
message Investment {

  // Currency under consideration.
  optional string currency = 1;

  // Account containing assets of the investmnet. This is the key name for it.
  optional string asset_account = 2;

  // Account names allowing us to figure out this is a dividend. Typicaslly the
  // dividend income account. posting to this account).
  repeated string dividend_accounts = 3;

  // Other account names to include (if a transaction has at least one posting
  // to this account).
  repeated string match_accounts = 4;

  // Cash accounts to generate flows for.
  repeated string cash_accounts = 5;
}

// Configuration for report groups.
message ReportGroup {

  // Name of the report/group.
  optional string name = 1;

  // A list of investments (asset accounts) to include in the generated report.
  // This field supports a globbing pattern as well.
  repeated string investment = 2;

  // The reporting currency to convert all assets to. This is optional; by
  // default, this uses the unique currency of the group of investments. If
  // there are many, an exception is raised.
  optional string currency = 3;
}
