Giter Club home page Giter Club logo

Comments (13)

sbidoul avatar sbidoul commented on June 19, 2024 1

@kittiu I like the idea of logging commitments explicitly. This allows for good traceability and handling of corner cases.

Regarding the repository choice it does not matter much to me. What matter more for me is knowing who is stepping in to care of the maintenance of modules.

from account-budgeting.

sbidoul avatar sbidoul commented on June 19, 2024 1

@kittiu I'll try to answer your questions.

We do have PSC/maintainer for this repo, right?

This repo is part of the Accounting PSC which covers a huge amount of modules.
For such a vast domain one cannot really expect to have the PSC members to do active maintenance on everything. So it's better if some people declare themselves has maintainer on addons they care about and do more active maintenance work. That's the purpose of the maintainer role and the maintainers key in the manifest.

from account-budgeting.

sbidoul avatar sbidoul commented on June 19, 2024 1

Regarding computation, I indeed sent you on the wrong track with the evaluate method, which is too limited for what you want to do.

A better starting point is the compute() method of mis.report.instance, which prepares the data for preview, or the lower level ._compute_matrix() method which gives you a more detailed data structure.

So the geneal algorithm goes as follow.

  1. Find the well known mis.report.instance that has the budget calculation, and in that one, find the well known column (mis.report.instance.period) that has the available values => lets name it's id period_available_id.
  2. Find the KPI for which you want the available budget, using get_kpis_by_account_id(), and find the one that has the budgetable flag set. There should be only one, otherwise there is an ambiguity in your budget. Lets call it budgetable_kpi
  3. Use _compute_matrix() (possibly with a context containing analytic filters) and navigate the matrix to find the value you need with something like this:
        for row in kpi_matrix.iter_rows():
            if row.kpi == budgetable_kpi:
                for cell in row.iter_cells():
                    if cell.subcol.col.key == period_available.id:
                        return cell.val or 0.0

So yeah, it's a bit complex. OTOH the subject matter is not an easy one either :)

I'm open to discuss a higher level API that would make these kind of calculations easier.

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

@sbidoul the discussion moved here, the module can be here or in https://github.com/OCA/mis-builder-contrib ?

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

@kittiu I like the idea of logging commitments explicitly. This allows for good traceability and handling of corner cases.

Thank you, please come to comment. At this moment, I will try to make use of mis_builder as much. :) would need your support on mis_builder knowledge.

Regarding the repository choice it does not matter much to me. What matter more for me is knowing who is stepping in to care of the maintenance of modules.

I am not sure what you mean by this. We do have PSC/maintainer for this repo, right?

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

@sbidoul from the evaluate(), I could get kpi's figure form account.move.line, i..e, exp by time period.

How can I get figure from Budget, Commit and Available?

company = self.env.ref('base.main_company')
report = self.env.ref('mis_builder_demo.mis_report_expenses')
aep = report._prepare_aep(company)
r = report.evaluate(
    aep,
    date_from='2014-01-01',
    date_to='2020-12-31',
)
print(r)

{
    'sum': <function _sum at 0x7f743688e0d0>,
    'min': <function _min at 0x7f7436896a60>,
    'max': <function _max at 0x7f7436896ae8>,
    'len': <built-in function len>,
    'avg': <function _avg at 0x7f74368969d8>,
    'time': <module 'time' (built-in)>,
    'datetime': <module 'datetime' from '/usr/lib/python3.6/datetime.py'>,
    'dateutil': <module 'dateutil' from '/home/kittiu/.virtualenvs/odoo12/lib/python3.6/site-packages/dateutil/__init__.py'>,
    'AccountingNone': AccountingNone,
    'SimpleArray': <class 'odoo.addons.mis_builder.models.simple_array.SimpleArray_1'>,
    'date_from': datetime.date(2014, 1, 1),
    'date_to': datetime.date(2020, 12, 31),
    'exp': 31591.5,
    'equip': AccountingNone,
    'other': AccountingNone,
    'total': 31591.5
}

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

Got this, def _add_column_actuals_alt()

from account-budgeting.

sbidoul avatar sbidoul commented on June 19, 2024

Hm, indeed evaluate is the simplified api. I need to dig a little bit to give you an example. No time today, though.

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

Thank you, no worry if you are busy. :)
I am getting the better result for commitment by adding aml_model and target_move=None.

        r = report.evaluate(
            aep,
            date_from='2014-01-01',
            date_to='2020-12-31',
            aml_model='purchase.budget.commit',
            target_move=None,
        )

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

@sbidoul
As I try to dig into the code, a little more progress, it is quite complex for me.
Am I correct that,

  • evaluate() is only used to get account.move.line and alternate move.line values
  • For budget item, we may need to use self.env['mis.budget.item']._query_kpi_data() to get the amount.

To get the available amount (sum column) we can get from combine the two.

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

@sbidoul Thank you so much for taking your valuable time to explain. This helps a lot!
Got it about maintainers. I will do that.

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

@sbidoul
So far, your recommendation fit into what I try to achieve quite nicely, thanks to mis_builder.

image

As the check_budget() will be called quite often, i.e., every time a document is validate. I have one concern on _compute_matrix(), as it return the whole result set, which we only need only result of some kpi and some period. I worry about performance

https://github.com/ecosoft-odoo/account-budgeting/blob/12.0-add-purchase_budget_commit/budget_management/models/budget_management.py#L137-L144

Do you have answer to this yet (i..e, filters)?

Thank you!

Note: I have some good progress, and soon can push the first demo.

from account-budgeting.

kittiu avatar kittiu commented on June 19, 2024

Closed as moved to PR #32

from account-budgeting.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.