diff --git a/addons/account_cash_flow/__init__.py b/addons/account_cash_flow/__init__.py new file mode 100644 index 00000000..b5d57e37 --- /dev/null +++ b/addons/account_cash_flow/__init__.py @@ -0,0 +1,5 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +from . import models +from . import wizard +from . import report diff --git a/addons/account_cash_flow/__manifest__.py b/addons/account_cash_flow/__manifest__.py new file mode 100644 index 00000000..1b0c6853 --- /dev/null +++ b/addons/account_cash_flow/__manifest__.py @@ -0,0 +1,41 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +{ + 'name': 'Cash Flow', + 'version': '1.1', + 'author': 'Flectra', + 'website': 'https://flectrahq.com', + 'summary': "cash flow statement", + 'description': """ + +The cash flow statement is intended to: + +1 : provide information on a firm's liquidity and solvency and its ability to change cash flows in future circumstances + +2 : provide additional information for evaluating changes in assets, liabilities and equity + +3 : improve the comparability of different firms' operating performance by eliminating the effects of different accounting methods + +4 : indicate the amount, timing and probability of future cash flows + + + """, + 'category': 'Sales', + 'depends': ['account', 'account_invoicing'], + 'data': [ + 'data/data_account_type.xml', + 'wizard/account_cash_flow.xml', + 'views/account_view.xml', + 'views/account_move_line.xml', + 'wizard/account_cash_flow.xml', + 'report/report_menu.xml', + 'report/report_account_cash_flow.xml', + + ], + + 'demo': [ + + ], + + 'application': True, +} diff --git a/addons/account_cash_flow/data/data_account_type.xml b/addons/account_cash_flow/data/data_account_type.xml new file mode 100644 index 00000000..8e2109df --- /dev/null +++ b/addons/account_cash_flow/data/data_account_type.xml @@ -0,0 +1,66 @@ + + + + + operation_current_asset + + + investing + + + operation_current_liability + + + operation_current_asset + + + operation_income + + + operation_income + + + operation_expense + + + operation_expense + + + operation_expense + + + operation_current_liability + + + investing + + + financing + + + financing + + + financing + + + financing + + + + \ No newline at end of file diff --git a/addons/account_cash_flow/i18n/cash_flow.pot b/addons/account_cash_flow/i18n/cash_flow.pot new file mode 100644 index 00000000..72e6487a --- /dev/null +++ b/addons/account_cash_flow/i18n/cash_flow.pot @@ -0,0 +1,243 @@ +# Translation of Flectra Server. +# This file contains the translation of the following modules: +# * cash_flow +# +msgid "" +msgstr "" +"Project-Id-Version: Flectra Server 1.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-06 05:23+0000\n" +"PO-Revision-Date: 2018-04-06 05:23+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Financing Activities\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Investing Activities\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Bank\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Cash\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Operating\n" +" Activities\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Operating + Financing +\n" +" Investing\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Part\n" +" A\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Part\n" +" B\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Total of (A + B)\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Current Assets\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Current Liabilities\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Expense\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Income\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Total\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "\n" +" Total\n" +" " +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "Account" +msgstr "" + +#. module: cash_flow +#: model:ir.model,name:cash_flow.model_account_account_type +msgid "Account Type" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_account_type_activity_type +#: model:ir.model.fields,field_description:cash_flow.field_account_move_line_activity_type +msgid "Activity Type" +msgstr "" + +#. module: cash_flow +#: model:ir.actions.act_window,name:cash_flow.action_account_cash_flow +#: model:ir.model,name:cash_flow.model_account_cash_flow +#: model:ir.ui.menu,name:cash_flow.menu_cash_flow_report +msgid "Cash Flow" +msgstr "" + +#. module: cash_flow +#: model:ir.actions.report,name:cash_flow.action_cash_flow_report +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "Cash Flow Statement" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_cash_flow_create_uid +msgid "Created by" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_cash_flow_create_date +msgid "Created on" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_cash_flow_display_name +#: model:ir.model.fields,field_description:cash_flow.field_report_cash_flow_report_account_cash_flow_display_name +msgid "Display Name" +msgstr "" + +#. module: cash_flow +#: selection:account.account.type,activity_type:0 +msgid "Financing" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_cash_flow_id +#: model:ir.model.fields,field_description:cash_flow.field_report_cash_flow_report_account_cash_flow_id +msgid "ID" +msgstr "" + +#. module: cash_flow +#: selection:account.account.type,activity_type:0 +msgid "Investing" +msgstr "" + +#. module: cash_flow +#: model:ir.model,name:cash_flow.model_account_move_line +msgid "Journal Item" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_cash_flow___last_update +#: model:ir.model.fields,field_description:cash_flow.field_report_cash_flow_report_account_cash_flow___last_update +msgid "Last Modified on" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_cash_flow_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_cash_flow_write_date +msgid "Last Updated on" +msgstr "" + +#. module: cash_flow +#: model:ir.model.fields,field_description:cash_flow.field_account_cash_flow_no_of_year +msgid "Number of years" +msgstr "" + +#. module: cash_flow +#: selection:account.account.type,activity_type:0 +msgid "Operation-Current Asset" +msgstr "" + +#. module: cash_flow +#: selection:account.account.type,activity_type:0 +msgid "Operation-Cuurent Liability" +msgstr "" + +#. module: cash_flow +#: selection:account.account.type,activity_type:0 +msgid "Operation-Expense" +msgstr "" + +#. module: cash_flow +#: selection:account.account.type,activity_type:0 +msgid "Operation-Income" +msgstr "" + +#. module: cash_flow +#: model:ir.model,name:cash_flow.model_report_cash_flow_report_account_cash_flow +msgid "report.cash_flow.report_account_cash_flow" +msgstr "" + +#. module: cash_flow +#: model:ir.ui.view,arch_db:cash_flow.report_account_cash_flow +msgid "upto" +msgstr "" + diff --git a/addons/account_cash_flow/models/__init__.py b/addons/account_cash_flow/models/__init__.py new file mode 100644 index 00000000..fcf139e9 --- /dev/null +++ b/addons/account_cash_flow/models/__init__.py @@ -0,0 +1,4 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +from . import account +from . import account_move_line diff --git a/addons/account_cash_flow/models/account.py b/addons/account_cash_flow/models/account.py new file mode 100644 index 00000000..b94299a9 --- /dev/null +++ b/addons/account_cash_flow/models/account.py @@ -0,0 +1,15 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +from flectra import fields, models + + +class Account(models.Model): + _inherit = 'account.account.type' + + activity_type = fields.Selection( + [('operation_income', 'Operation-Income'), + ('operation_expense', 'Operation-Expense'), + ('operation_current_asset', 'Operation-Current Asset'), + ('operation_current_liability', 'Operation-Cuurent Liability'), + ('investing', 'Investing'), + ('financing', 'Financing')], string='Activity Type') diff --git a/addons/account_cash_flow/models/account_move_line.py b/addons/account_cash_flow/models/account_move_line.py new file mode 100644 index 00000000..a9027f23 --- /dev/null +++ b/addons/account_cash_flow/models/account_move_line.py @@ -0,0 +1,9 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +from flectra import fields, models + + +class AccountMoveLine(models.Model): + _inherit = 'account.move.line' + + activity_type = fields.Selection(related='user_type_id.activity_type') diff --git a/addons/account_cash_flow/report/__init__.py b/addons/account_cash_flow/report/__init__.py new file mode 100644 index 00000000..2a57c10f --- /dev/null +++ b/addons/account_cash_flow/report/__init__.py @@ -0,0 +1,3 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +from . import report_account_cash_flow diff --git a/addons/account_cash_flow/report/report_account_cash_flow.py b/addons/account_cash_flow/report/report_account_cash_flow.py new file mode 100644 index 00000000..79677353 --- /dev/null +++ b/addons/account_cash_flow/report/report_account_cash_flow.py @@ -0,0 +1,106 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +from flectra import models, api +import datetime +from datetime import timedelta +import calendar +from collections import Counter + + + +class ReportAccountCashFlow(models.AbstractModel): + _name = 'report.account_cash_flow.report_account_cash_flow' + + def get_years(self, data, is_getdata): + company_id = self.env['res.company'].browse( + data['form']['company_id'][0]) + date_dict = {} + year_list = [datetime.datetime.now().year - year for year in + range(0, data['form']['no_of_year'] + 1)] + for year in year_list: + no_days = calendar.isleap(year) and 365 or 364 + date_dict.update({year: [ + str(datetime.date(year, company_id.fiscalyear_last_month, + company_id.fiscalyear_last_day) - + timedelta(days=no_days)), + str(datetime.date(year, company_id.fiscalyear_last_month, + company_id.fiscalyear_last_day))]}) + year_list.sort(reverse=True) + if is_getdata: + return date_dict + return year_list + + def get_move_lines(self, date_from, date_to, key, dummy_list): + self._cr.execute("select CASE WHEN acc_type.activity_type is null THEN acc.name ELSE acc_type.activity_type END AS activity_type, " + "aml.account_id, " + "(sum(aml.debit) - sum(aml.credit)) * -1 as " + "balance " + "from account_move_line aml, " + "account_account acc, " + "account_account_type acc_type " + "where acc.id = aml.account_id and " + "aml.date >= '%s'" % date_from + "and " + "aml.date <= '%s'" % date_to + "and " + "acc.user_type_id = acc_type.id " + "group by aml.account_id, " + "acc_type.activity_type, acc.name") + balance_data = self._cr.dictfetchall() + [d.update({'year': {key: d['balance']}}) for d in balance_data] + for dummy in dummy_list: + [d['year'].update({dummy: 0.0}) for d in balance_data] + return balance_data + + def get_data(self, data): + final_dict = {} + balance_data = [] + date_dict = self.get_years(data, is_getdata=True) + for key in sorted(date_dict, reverse=True): + dummy_list = list(date_dict.keys()) + dummy_list.remove(key) + balance_data += self.get_move_lines(date_dict[key][0], + date_dict[key][1], key, dummy_list) + for data in balance_data: + if data['activity_type'] not in final_dict: + final_dict[data['activity_type']] = {'account': {}} + final_dict[data['activity_type']]['account'] = {data['account_id']: data['year']} + final_dict[data['activity_type']]['total'] = data['year'] + else: + if data['account_id'] not in \ + final_dict[data['activity_type']]['account']: + final_dict[data['activity_type']]['account'][data['account_id']] = data['year'] + else: + f_year = final_dict[data['activity_type']]['account'][data['account_id']] + d_year = data['year'] + total = {k : f_year.get(k, 0) + d_year.get(k,0) for k in set(f_year.keys()) | set(d_year.keys())} + final_dict[data['activity_type']]['account'][data['account_id']] = total + y_total = final_dict[data['activity_type']]['total'] + total = {k : y_total.get(k, 0) + data['year'].get(k,0) for k in set(y_total.keys()) | set(data['year'].keys())} + final_dict[data['activity_type']]['total'] = total + return final_dict + + def get_acc_details(self, account_id): + acc_details = {'ac_nm': self.env['account.account'].browse( + account_id).name, + 'ac_no': self.env['account.account'].browse( + account_id).code} + return acc_details + + def get_total(self, data_dict, year, type_list): + total_bal = 0.00 + for value in type_list: + if value in data_dict: + total_bal += data_dict[value]['total'][year] + return total_bal + + @api.model + def get_report_values(self, docids, data=None): + docs = self.env['account.move.line'].browse(docids) + docargs = { + 'doc_model': 'account.move.line', + 'docs': docs, + 'get_data': self.get_data(data), + 'get_years': self.get_years(data, is_getdata=False), + 'get_acc_details': self.get_acc_details, + 'get_total': self.get_total, + } + return docargs diff --git a/addons/account_cash_flow/report/report_account_cash_flow.xml b/addons/account_cash_flow/report/report_account_cash_flow.xml new file mode 100644 index 00000000..2faa6c82 --- /dev/null +++ b/addons/account_cash_flow/report/report_account_cash_flow.xml @@ -0,0 +1,357 @@ + + + + \ No newline at end of file diff --git a/addons/account_cash_flow/report/report_menu.xml b/addons/account_cash_flow/report/report_menu.xml new file mode 100644 index 00000000..9a75ec14 --- /dev/null +++ b/addons/account_cash_flow/report/report_menu.xml @@ -0,0 +1,29 @@ + + + + Cash flow report paperformat + + A4 + 0 + 0 + Portrait + 15 + 5 + 7 + 7 + + 10 + 70 + + + + \ No newline at end of file diff --git a/addons/account_cash_flow/views/account_move_line.xml b/addons/account_cash_flow/views/account_move_line.xml new file mode 100644 index 00000000..90c75841 --- /dev/null +++ b/addons/account_cash_flow/views/account_move_line.xml @@ -0,0 +1,15 @@ + + + + + account.move.line.form.inherit + account.move.line + + + + + + + + + diff --git a/addons/account_cash_flow/views/account_view.xml b/addons/account_cash_flow/views/account_view.xml new file mode 100644 index 00000000..c95bc470 --- /dev/null +++ b/addons/account_cash_flow/views/account_view.xml @@ -0,0 +1,15 @@ + + + + + account.account.type.form.inherit + account.account.type + + + + + + + + + diff --git a/addons/account_cash_flow/wizard/__init__.py b/addons/account_cash_flow/wizard/__init__.py new file mode 100644 index 00000000..2e811205 --- /dev/null +++ b/addons/account_cash_flow/wizard/__init__.py @@ -0,0 +1,3 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +from . import account_cash_flow diff --git a/addons/account_cash_flow/wizard/account_cash_flow.py b/addons/account_cash_flow/wizard/account_cash_flow.py new file mode 100644 index 00000000..943e6dd4 --- /dev/null +++ b/addons/account_cash_flow/wizard/account_cash_flow.py @@ -0,0 +1,21 @@ +# Part of Flectra See LICENSE file for full copyright and licensing details. + +from flectra import models, fields + + +class AccountCashFlow(models.TransientModel): + """Credit Notes""" + + _inherit = "account.common.report" + _name = "account.cash.flow" + _description = "Cash Flow" + + no_of_year = fields.Integer(string='Previous Period', default=0) + + def _print_report(self, data): + data['form'].update(self.read(['no_of_year', 'company_id'])[0]) + landscape = False + if self.no_of_year > 2: + landscape = True + return self.env.ref( + 'account_cash_flow.action_cash_flow_report').with_context(landscape=landscape).report_action(self, data=data) diff --git a/addons/account_cash_flow/wizard/account_cash_flow.xml b/addons/account_cash_flow/wizard/account_cash_flow.xml new file mode 100644 index 00000000..d2404e4a --- /dev/null +++ b/addons/account_cash_flow/wizard/account_cash_flow.xml @@ -0,0 +1,34 @@ + + + + account.cash.flow.form + account.cash.flow + + + + + + + + + 1 + + + 1 + + + + + Cash Flow + account.cash.flow + form + form + + {} + new + + + +