Metadata-Version: 2.1
Name: odoo-addon-account_analytic_dynamic_full_cost
Version: 18.0.1.1.0.1
Requires-Python: >=3.10
Requires-Dist: odoo==18.0.*
Summary: Compute and store dynamic full cost in analytic lines
Home-page: https://github.com/OCA/account-analytic
License: AGPL-3
Author: Quim Rebull (Coopdevs), Odoo Community Association (OCA)
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 18.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Development Status :: 4 - Beta
Description-Content-Type: text/x-rst

==========================
Analytic Dynamic Full Cost
==========================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:41825484f4c9c8a50c8ef604a0be6c64765accdc8948b4ebe22c9a367bacca79
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
    :target: https://github.com/OCA/account-analytic/tree/18.0/account_analytic_dynamic_full_cost
    :alt: OCA/account-analytic
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/account-analytic-18-0/account-analytic-18-0-account_analytic_dynamic_full_cost
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/account-analytic&target_branch=18.0
    :alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends analytic accounting with a dynamic full-cost
calculation based on productive and reproductive analytic plan branches.

It includes the classification of analytic plans as productive,
reproductive, or not analyzed.

Functional Purpose
------------------

In many organisations, part of the activity is directly productive while
another part corresponds to reproductive or supporting activity such as
administration, coordination, infrastructure, shared services, or
delivery management.

Reproductive activity has associated analytic weight. This module
distributes that weight across productive branches in each analytic
dimension and stores the resulting full-cost amount on analytic lines,
producing a more realistic and traceable analytic cost structure.

How Full Cost Is Determined
---------------------------

The cost of the reproductive plans is spread over the productive ones,
proportionally to their **base lines**: their expenses or their revenue,
depending on the company weight basis (see below). Billing ten times
more, or spending ten times more, means bearing ten times more of the
reproductive cost.

For each company and reference date, the module:

1. Selects the computation window according to the company settings.
2. Computes, for each analytic plan, the amount of its base lines and
   the net cost of all its lines (expenses minus revenue), using the
   analytic account field that corresponds to that plan dimension.
3. At each productive plan, computes a rate: the net cost of its
   reproductive child branches divided by the base lines of its
   productive branch. When a productive plan has no base lines below it,
   its reproductive cost goes up to the parent level.
4. Adds the rates of the plan and all its ancestors.
5. Stores the resulting multiplier on the analytic plan: ``1 + rate``
   when the base lines are expenses (the cost grows), ``1 - rate`` when
   they are revenue (the margin shrinks).

For each analytic line, the module stores its full-cost amount:

- lines linked to reproductive plans: ``0.0``, whatever their sign,
  because their whole balance is redistributed over productive branches;
- base lines of productive plans:
  ``amount * product(plan_full_cost_multipliers)``;
- any other line: its original amount.

The full-cost amounts of the analysed lines therefore add up to their
original amounts: the reproductive cost is moved, never created nor
lost.

Plans marked as **Not Analyzed** and every descendant below them are
completely excluded from the computation. Their analytic lines keep
their original amount. When an analytic line also has productive
accounts in other dimensions, only the not-analyzed dimensions are
ignored.

Configurable Time Window
------------------------

The company parameter **Full Cost Period** controls the default
look-back window used to calculate plan weights. The default is the
two-year window. When the period is set to rolling, **Full Cost Window
(Days)** defines the number of days to look back.

Examples:

- Two-year window: full cost based on the same date two years earlier.
- Three-year window: full cost based on the same date three years
  earlier.
- Rolling window = 180 days: full cost based on the last six months.
- Current fiscal year: full cost based on the fiscal year of the
  reference date, from its first day. Every line of the year is valued
  with the same multipliers, so the full cost of the year adds up to its
  amount.

Weight Basis
------------

The company setting **Full Cost Weight Basis** defines the base lines,
which both weight the productive plans and carry the reproductive cost:

- **Expenses**: analytic lines with negative amount. The reproductive
  cost is added to the expenses of the productive plans.
- **Revenue**: analytic lines with positive amount. The reproductive
  cost is deducted from the revenue of the productive plans, as a
  percentage of their billing.

Recalculation
-------------

A daily cron recomputes recent analytic lines.

A wizard allows recomputing multipliers and analytic line full-cost
amounts for a company, useful when:

- the full-cost window is changed,
- analytic entries are backdated,
- productive or reproductive weights change significantly.

Operational recalculation only updates analytic lines inside the current
full-cost window. Lines outside that window keep their latest calculated
``full_cost_amount``. This is intentional: once an entry falls outside
the active calculation window, its operational value is treated as a
stable historical result instead of being continuously rewritten by
later cost structures. For historical analysis at another date, use the
historical full-cost report; it calculates the applicable window and
ratios on the fly without changing stored analytic lines.

Typical Use Cases
-----------------

1. Project costing
2. Cooperative / social economy organisations
3. Internal rate validation
4. Management accounting / controlling
5. Forecasting and budgeting

**Table of contents**

.. contents::
   :local:

Usage
=====

1. Configure Analytic Plans
---------------------------

Each analytic plan can be marked as:

- **Productive**: activity that receives full-cost allocation.
- **Reproductive**: supporting activity whose weight must be spread.
- **Not Analyzed**: activity excluded from full-cost analysis together
  with all descendants.

To configure:

1. Go to *Accounting -> Configuration -> Analytic Accounting -> Analytic
   Plans*.
2. Open a plan.
3. Set **Full Cost Role** to *Productive*, *Reproductive*, or *Not
   Analyzed*.

Analytic lines derive their full-cost role from the analyzed analytic
accounts set on the line. In Odoo's multidimensional analytic model,
each root analytic plan has its own account field; dimensions marked as
*Not Analyzed* are ignored.

2. Configure Company Full-Cost Settings
---------------------------------------

Go to *Accounting -> Configuration -> Settings*, in the **Analytics**
block (with the analytic accounting enabled), and set for the current
company:

- **Full Cost Period**
- **Full Cost Window (Days)** (only for the rolling window)
- **Full Cost Weight Basis**

The block also links to the recompute wizard.

The window determines which analytic lines are considered when
recomputing plan weights. The weight basis determines whether those
weights come from expenses or revenue.

3. Recompute Multipliers and Amounts
------------------------------------

Use *Accounting -> Analytic Accounting -> Recompute analytic full cost*.

Select:

- Company
- Whether analytic lines should also be recomputed

The wizard recomputes the current plan multipliers using today's date
and the company window configuration. If line recomputation is enabled,
it then updates ``full_cost_amount`` only on analytic lines inside the
current full-cost window.

Analytic lines outside the current window keep their latest calculated
``full_cost_amount``. This avoids continuously rewriting old operational
analytic figures when today's cost structure changes. To analyse another
date or an old period, use the historical full-cost report, which
calculates the relevant window and ratios on the fly without updating
stored analytic lines.

4. Reporting
------------

Use *Accounting -> Reporting -> Historical Full-Cost Analysis* to select
an analysis date. The report calculates the window and multipliers on
the fly for that date; it does not store historical ratios.

You can also analyse current full cost in analytic reporting views by
using:

- ``full_cost_amount``
- ``full_cost_role``

This allows reporting at analytic account and full-cost role level.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20account_analytic_dynamic_full_cost%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Quim Rebull (Coopdevs)

Contributors
------------

- `Coopdevs <https://coopdevs.org>`__:

  - Quim Rebull <quim.rebull@coopdevs.org>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-QuiJoQuim| image:: https://github.com/QuiJoQuim.png?size=40px
    :target: https://github.com/QuiJoQuim
    :alt: QuiJoQuim

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-QuiJoQuim| 

This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/18.0/account_analytic_dynamic_full_cost>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
