# Map the Retained Earnings account(s)

During each database build, Phocas takes all Profit & Loss (P\&L) transactions and maps them to a Balance Sheet account. By default, this account is the system Retained Earnings account, which might have been set during your implementation. You can update this mapping or choose to distribute the P\&L transactions across multiple accounts.

<details>

<summary>How Retained Earnings works in Phocas</summary>

Analytics forms the base value, which is calculated as follows:

* Retained Earnings appears on the Balance Sheet stream and can be mapped to an existing account code(s) via the steps below. If left unmapped, it is displayed as the Retained Earnings system account.&#x20;
* Retained Earnings is the sum of all the P\&L transactions within the P\&L stream plus any relevant Balance Sheet transactions. It is calculated as A + B, where: \
  A = Sum of all transactions for all dates for P\&L accounts from the database start date to the end of the current period. \
  B = The amount already in the Retained Earnings account, such as the opening Balance Sheet value and other transactions, such as a dividend payment.

In Financial Statements, if the financial year end has been set, the Retained Earnings value is adjusted by the Current Year Earnings, which appears as a separate row on the Balance Sheet statement.

</details>

To change the mapped account(s):

1. Click the **Settings** button > **Retained Earnings** in the top-right corner.
2. Choose whether to map to one account or multiple accounts:
   * **One account**:\
     Select an account from the list or enter an account code. If left blank, the system will use the default Retained Earnings account.<br>

     <div align="left"><figure><img src="/files/tU6j42pISQC0utsPHq39" alt="" width="312"><figcaption></figcaption></figure></div>
   * **Multiple accounts**:\
     Select the dimension, such as Company, to which to allocate the P\&L transactions. Then map each dimension entity to an account by selecting from the list or entering an account code. If left blank, the system will use the default Retained Earnings account for that dimension entity.<br>

     <div align="left"><figure><img src="/files/DCwsJ2DWGY1CqJDfxJrE" alt="" width="333"><figcaption></figcaption></figure></div>
3. Select one of these options:
   * Click **Save and close** to save your changes without triggering a database build. Your changes will take effect on the next database build.
   * Click **Build Now** to rebuild the database immediately and apply your changes. After a successful build, you’ll receive a message asking you to refresh the page, and then you’ll see the new dimensions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.phocassoftware.com/financial-statements/managing-statements/map-the-retained-earnings-account-s.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
