From abc6fe0b060aec9fa82b255d91f2c10c98944f3d Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 2 Jun 2023 17:48:59 +0530 Subject: [PATCH] refactor!: Remove custom cashflow report mapper (#35523) * refactor: Remove custom cashflow mapper * chore: patch to delete docs * fix: Cleanup defaults during install * fix: Remove custom cashflow mapper from consolidated financial statement --- .../accounts_settings/accounts_settings.json | 16 +- .../doctype/cash_flow_mapper/__init__.py | 0 .../cash_flow_mapper/cash_flow_mapper.js | 6 - .../cash_flow_mapper/cash_flow_mapper.json | 275 --------- .../cash_flow_mapper/cash_flow_mapper.py | 9 - .../default_cash_flow_mapper.py | 25 - .../cash_flow_mapper/test_cash_flow_mapper.py | 8 - .../doctype/cash_flow_mapping/__init__.py | 0 .../cash_flow_mapping/cash_flow_mapping.js | 43 -- .../cash_flow_mapping/cash_flow_mapping.json | 359 ----------- .../cash_flow_mapping/cash_flow_mapping.py | 22 - .../test_cash_flow_mapping.py | 28 - .../cash_flow_mapping_accounts/__init__.py | 0 .../cash_flow_mapping_accounts.json | 73 --- .../cash_flow_mapping_accounts.py | 9 - .../cash_flow_mapping_template/__init__.py | 0 .../cash_flow_mapping_template.js | 6 - .../cash_flow_mapping_template.json | 123 ---- .../cash_flow_mapping_template.py | 9 - .../test_cash_flow_mapping_template.py | 8 - .../__init__.py | 0 .../cash_flow_mapping_template_details.js | 6 - .../cash_flow_mapping_template_details.json | 34 -- .../cash_flow_mapping_template_details.py | 9 - ...test_cash_flow_mapping_template_details.py | 8 - .../accounts/report/cash_flow/cash_flow.py | 7 +- .../report/cash_flow/custom_cash_flow.py | 567 ------------------ .../consolidated_financial_statement.py | 7 +- erpnext/patches.txt | 6 +- .../v10_0/add_default_cash_flow_mappers.py | 15 - erpnext/setup/install.py | 9 - 31 files changed, 8 insertions(+), 1679 deletions(-) delete mode 100644 erpnext/accounts/doctype/cash_flow_mapper/__init__.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.js delete mode 100644 erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.json delete mode 100644 erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapper/default_cash_flow_mapper.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapper/test_cash_flow_mapper.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping/__init__.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.js delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.json delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping/test_cash_flow_mapping.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_accounts/__init__.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.json delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template/__init__.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.js delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.json delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template/test_cash_flow_mapping_template.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template_details/__init__.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.js delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.json delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.py delete mode 100644 erpnext/accounts/doctype/cash_flow_mapping_template_details/test_cash_flow_mapping_template_details.py delete mode 100644 erpnext/accounts/report/cash_flow/custom_cash_flow.py delete mode 100644 erpnext/patches/v10_0/add_default_cash_flow_mappers.py diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 2996836de8..c59d90dfab 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -21,8 +21,6 @@ "allow_multi_currency_invoices_against_single_party_account", "journals_section", "merge_similar_account_heads", - "report_setting_section", - "use_custom_cash_flow", "deferred_accounting_settings_section", "book_deferred_entries_based_on", "column_break_18", @@ -173,13 +171,6 @@ "fieldtype": "Int", "label": "Stale Days" }, - { - "default": "0", - "description": "Only select this if you have set up the Cash Flow Mapper documents", - "fieldname": "use_custom_cash_flow", - "fieldtype": "Check", - "label": "Enable Custom Cash Flow Format" - }, { "default": "0", "description": "Payment Terms from orders will be fetched into the invoices as is", @@ -338,11 +329,6 @@ "fieldtype": "Tab Break", "label": "POS" }, - { - "fieldname": "report_setting_section", - "fieldtype": "Section Break", - "label": "Report Setting" - }, { "default": "0", "description": "Enabling this will allow creation of multi-currency invoices against single party account in company currency", @@ -397,7 +383,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2023-04-21 13:11:37.130743", + "modified": "2023-06-01 15:42:44.912316", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/doctype/cash_flow_mapper/__init__.py b/erpnext/accounts/doctype/cash_flow_mapper/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.js b/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.js deleted file mode 100644 index 13d223ad40..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Cash Flow Mapper', { - -}); diff --git a/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.json b/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.json deleted file mode 100644 index f0e984dc2a..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.json +++ /dev/null @@ -1,275 +0,0 @@ -{ - "allow_copy": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 1, - "autoname": "field:section_name", - "beta": 0, - "creation": "2018-02-08 10:00:14.066519", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", - "fields": [ - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "section_name", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Section Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "section_header", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Section Header", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "description": "e.g Adjustments for:", - "fieldname": "section_leader", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Section Leader", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "section_subtotal", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Section Subtotal", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "section_footer", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Section Footer", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "accounts", - "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Accounts", - "length": 0, - "no_copy": 0, - "options": "Cash Flow Mapping Template Details", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "position", - "fieldtype": "Int", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Position", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-02-15 18:28:55.034933", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Cash Flow Mapper", - "name_case": "", - "owner": "Administrator", - "permissions": [ - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 1 - } - ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "name", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0 -} \ No newline at end of file diff --git a/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.py b/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.py deleted file mode 100644 index d975f803a0..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapper/cash_flow_mapper.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - - -from frappe.model.document import Document - - -class CashFlowMapper(Document): - pass diff --git a/erpnext/accounts/doctype/cash_flow_mapper/default_cash_flow_mapper.py b/erpnext/accounts/doctype/cash_flow_mapper/default_cash_flow_mapper.py deleted file mode 100644 index 79feb2dae2..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapper/default_cash_flow_mapper.py +++ /dev/null @@ -1,25 +0,0 @@ -DEFAULT_MAPPERS = [ - { - "doctype": "Cash Flow Mapper", - "section_footer": "Net cash generated by operating activities", - "section_header": "Cash flows from operating activities", - "section_leader": "Adjustments for", - "section_name": "Operating Activities", - "position": 0, - "section_subtotal": "Cash generated from operations", - }, - { - "doctype": "Cash Flow Mapper", - "position": 1, - "section_footer": "Net cash used in investing activities", - "section_header": "Cash flows from investing activities", - "section_name": "Investing Activities", - }, - { - "doctype": "Cash Flow Mapper", - "position": 2, - "section_footer": "Net cash used in financing activites", - "section_header": "Cash flows from financing activities", - "section_name": "Financing Activities", - }, -] diff --git a/erpnext/accounts/doctype/cash_flow_mapper/test_cash_flow_mapper.py b/erpnext/accounts/doctype/cash_flow_mapper/test_cash_flow_mapper.py deleted file mode 100644 index 044f2aee72..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapper/test_cash_flow_mapper.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt - -import unittest - - -class TestCashFlowMapper(unittest.TestCase): - pass diff --git a/erpnext/accounts/doctype/cash_flow_mapping/__init__.py b/erpnext/accounts/doctype/cash_flow_mapping/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.js b/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.js deleted file mode 100644 index 00c71657c5..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Cash Flow Mapping', { - refresh: function(frm) { - frm.events.disable_unchecked_fields(frm); - }, - reset_check_fields: function(frm) { - frm.fields.filter(field => field.df.fieldtype === 'Check') - .map(field => frm.set_df_property(field.df.fieldname, 'read_only', 0)); - }, - has_checked_field(frm) { - const val = frm.fields.filter(field => field.value === 1); - return val.length ? 1 : 0; - }, - _disable_unchecked_fields: function(frm) { - // get value of clicked field - frm.fields.filter(field => field.value === 0) - .map(field => frm.set_df_property(field.df.fieldname, 'read_only', 1)); - }, - disable_unchecked_fields: function(frm) { - frm.events.reset_check_fields(frm); - const checked = frm.events.has_checked_field(frm); - if (checked) { - frm.events._disable_unchecked_fields(frm); - } - }, - is_working_capital: function(frm) { - frm.events.disable_unchecked_fields(frm); - }, - is_finance_cost: function(frm) { - frm.events.disable_unchecked_fields(frm); - }, - is_income_tax_liability: function(frm) { - frm.events.disable_unchecked_fields(frm); - }, - is_income_tax_expense: function(frm) { - frm.events.disable_unchecked_fields(frm); - }, - is_finance_cost_adjustment: function(frm) { - frm.events.disable_unchecked_fields(frm); - } -}); diff --git a/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.json b/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.json deleted file mode 100644 index bd7fd1c135..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.json +++ /dev/null @@ -1,359 +0,0 @@ -{ - "allow_copy": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 1, - "autoname": "field:mapping_name", - "beta": 0, - "creation": "2018-02-08 09:28:44.678364", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", - "fields": [ - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "mapping_name", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "label", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Label", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "accounts", - "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Accounts", - "length": 0, - "no_copy": 0, - "options": "Cash Flow Mapping Accounts", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "sb_1", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Select Maximum Of 1", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fieldname": "is_finance_cost", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Finance Cost", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fieldname": "is_working_capital", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Working Capital", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fieldname": "is_finance_cost_adjustment", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Finance Cost Adjustment", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fieldname": "is_income_tax_liability", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Income Tax Liability", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fieldname": "is_income_tax_expense", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Income Tax Expense", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-02-15 08:25:18.693533", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Cash Flow Mapping", - "name_case": "", - "owner": "Administrator", - "permissions": [ - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 1 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Administrator", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 1 - } - ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "name", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0 -} \ No newline at end of file diff --git a/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.py b/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.py deleted file mode 100644 index 402469fc1c..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping/cash_flow_mapping.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - - -import frappe -from frappe import _ -from frappe.model.document import Document - - -class CashFlowMapping(Document): - def validate(self): - self.validate_checked_options() - - def validate_checked_options(self): - checked_fields = [ - d for d in self.meta.fields if d.fieldtype == "Check" and self.get(d.fieldname) == 1 - ] - if len(checked_fields) > 1: - frappe.throw( - _("You can only select a maximum of one option from the list of check boxes."), - title=_("Error"), - ) diff --git a/erpnext/accounts/doctype/cash_flow_mapping/test_cash_flow_mapping.py b/erpnext/accounts/doctype/cash_flow_mapping/test_cash_flow_mapping.py deleted file mode 100644 index 19f2425b4c..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping/test_cash_flow_mapping.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt - -import unittest - -import frappe - - -class TestCashFlowMapping(unittest.TestCase): - def setUp(self): - if frappe.db.exists("Cash Flow Mapping", "Test Mapping"): - frappe.delete_doc("Cash Flow Mappping", "Test Mapping") - - def tearDown(self): - frappe.delete_doc("Cash Flow Mapping", "Test Mapping") - - def test_multiple_selections_not_allowed(self): - doc = frappe.new_doc("Cash Flow Mapping") - doc.mapping_name = "Test Mapping" - doc.label = "Test label" - doc.append("accounts", {"account": "Accounts Receivable - _TC"}) - doc.is_working_capital = 1 - doc.is_finance_cost = 1 - - self.assertRaises(frappe.ValidationError, doc.insert) - - doc.is_finance_cost = 0 - doc.insert() diff --git a/erpnext/accounts/doctype/cash_flow_mapping_accounts/__init__.py b/erpnext/accounts/doctype/cash_flow_mapping_accounts/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.json b/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.json deleted file mode 100644 index 470c87c0b8..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "allow_copy": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "autoname": "field:account", - "beta": 0, - "creation": "2018-02-08 09:25:34.353995", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", - "fields": [ - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "account", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "account", - "length": 0, - "no_copy": 0, - "options": "Account", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 1, - "max_attachments": 0, - "modified": "2018-02-08 09:25:34.353995", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Cash Flow Mapping Accounts", - "name_case": "", - "owner": "Administrator", - "permissions": [], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0 -} \ No newline at end of file diff --git a/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.py b/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.py deleted file mode 100644 index d8dd05ce1c..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_accounts/cash_flow_mapping_accounts.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - - -from frappe.model.document import Document - - -class CashFlowMappingAccounts(Document): - pass diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template/__init__.py b/erpnext/accounts/doctype/cash_flow_mapping_template/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.js b/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.js deleted file mode 100644 index 8611153cd8..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Cash Flow Mapping Template', { - -}); diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.json b/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.json deleted file mode 100644 index 27e19dc756..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "allow_copy": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "beta": 0, - "creation": "2018-02-08 10:20:18.316801", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", - "fields": [ - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "template_name", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Template Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "mapping", - "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Cash Flow Mapping", - "length": 0, - "no_copy": 0, - "options": "Cash Flow Mapping Template Details", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-02-08 10:20:18.316801", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Cash Flow Mapping Template", - "name_case": "", - "owner": "Administrator", - "permissions": [ - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 1 - } - ], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0 -} \ No newline at end of file diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.py b/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.py deleted file mode 100644 index 610428cf51..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_template/cash_flow_mapping_template.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - - -from frappe.model.document import Document - - -class CashFlowMappingTemplate(Document): - pass diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template/test_cash_flow_mapping_template.py b/erpnext/accounts/doctype/cash_flow_mapping_template/test_cash_flow_mapping_template.py deleted file mode 100644 index 1946146735..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_template/test_cash_flow_mapping_template.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt - -import unittest - - -class TestCashFlowMappingTemplate(unittest.TestCase): - pass diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template_details/__init__.py b/erpnext/accounts/doctype/cash_flow_mapping_template_details/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.js b/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.js deleted file mode 100644 index 2e5dce4fb5..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Cash Flow Mapping Template Details', { - -}); diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.json b/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.json deleted file mode 100644 index 02c6875fb3..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "actions": [], - "creation": "2018-02-08 10:18:48.513608", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "mapping" - ], - "fields": [ - { - "fieldname": "mapping", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Mapping", - "options": "Cash Flow Mapping", - "reqd": 1, - "unique": 1 - } - ], - "istable": 1, - "links": [], - "modified": "2022-02-21 03:34:57.902332", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Cash Flow Mapping Template Details", - "owner": "Administrator", - "permissions": [], - "quick_entry": 1, - "sort_field": "modified", - "sort_order": "DESC", - "states": [], - "track_changes": 1 -} \ No newline at end of file diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.py b/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.py deleted file mode 100644 index d15ab7e802..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_template_details/cash_flow_mapping_template_details.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - - -from frappe.model.document import Document - - -class CashFlowMappingTemplateDetails(Document): - pass diff --git a/erpnext/accounts/doctype/cash_flow_mapping_template_details/test_cash_flow_mapping_template_details.py b/erpnext/accounts/doctype/cash_flow_mapping_template_details/test_cash_flow_mapping_template_details.py deleted file mode 100644 index 5795e61aed..0000000000 --- a/erpnext/accounts/doctype/cash_flow_mapping_template_details/test_cash_flow_mapping_template_details.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors -# See license.txt - -import unittest - - -class TestCashFlowMappingTemplateDetails(unittest.TestCase): - pass diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py index cb3c78a2b0..d3b0692d7e 100644 --- a/erpnext/accounts/report/cash_flow/cash_flow.py +++ b/erpnext/accounts/report/cash_flow/cash_flow.py @@ -4,7 +4,7 @@ import frappe from frappe import _ -from frappe.utils import cint, cstr +from frappe.utils import cstr from erpnext.accounts.report.financial_statements import ( get_columns, @@ -20,11 +20,6 @@ from erpnext.accounts.utils import get_fiscal_year def execute(filters=None): - if cint(frappe.db.get_single_value("Accounts Settings", "use_custom_cash_flow")): - from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom - - return execute_custom(filters=filters) - period_list = get_period_list( filters.from_fiscal_year, filters.to_fiscal_year, diff --git a/erpnext/accounts/report/cash_flow/custom_cash_flow.py b/erpnext/accounts/report/cash_flow/custom_cash_flow.py deleted file mode 100644 index b165c88c06..0000000000 --- a/erpnext/accounts/report/cash_flow/custom_cash_flow.py +++ /dev/null @@ -1,567 +0,0 @@ -# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors -# For license information, please see license.txt - - -import frappe -from frappe import _ -from frappe.query_builder.functions import Sum -from frappe.utils import add_to_date, flt, get_date_str - -from erpnext.accounts.report.financial_statements import get_columns, get_data, get_period_list -from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import ( - get_net_profit_loss, -) - - -def get_mapper_for(mappers, position): - mapper_list = list(filter(lambda x: x["position"] == position, mappers)) - return mapper_list[0] if mapper_list else [] - - -def get_mappers_from_db(): - return frappe.get_all( - "Cash Flow Mapper", - fields=[ - "section_name", - "section_header", - "section_leader", - "section_subtotal", - "section_footer", - "name", - "position", - ], - order_by="position", - ) - - -def get_accounts_in_mappers(mapping_names): - cfm = frappe.qb.DocType("Cash Flow Mapping") - cfma = frappe.qb.DocType("Cash Flow Mapping Accounts") - result = ( - frappe.qb.select( - cfma.name, - cfm.label, - cfm.is_working_capital, - cfm.is_income_tax_liability, - cfm.is_income_tax_expense, - cfm.is_finance_cost, - cfm.is_finance_cost_adjustment, - cfma.account, - ) - .from_(cfm) - .join(cfma) - .on(cfm.name == cfma.parent) - .where(cfma.parent.isin(mapping_names)) - ).run() - - return result - - -def setup_mappers(mappers): - cash_flow_accounts = [] - - for mapping in mappers: - mapping["account_types"] = [] - mapping["tax_liabilities"] = [] - mapping["tax_expenses"] = [] - mapping["finance_costs"] = [] - mapping["finance_costs_adjustments"] = [] - doc = frappe.get_doc("Cash Flow Mapper", mapping["name"]) - mapping_names = [item.name for item in doc.accounts] - - if not mapping_names: - continue - - accounts = get_accounts_in_mappers(mapping_names) - - account_types = [ - dict( - name=account[0], - account_name=account[7], - label=account[1], - is_working_capital=account[2], - is_income_tax_liability=account[3], - is_income_tax_expense=account[4], - ) - for account in accounts - if not account[3] - ] - - finance_costs_adjustments = [ - dict( - name=account[0], - account_name=account[7], - label=account[1], - is_finance_cost=account[5], - is_finance_cost_adjustment=account[6], - ) - for account in accounts - if account[6] - ] - - tax_liabilities = [ - dict( - name=account[0], - account_name=account[7], - label=account[1], - is_income_tax_liability=account[3], - is_income_tax_expense=account[4], - ) - for account in accounts - if account[3] - ] - - tax_expenses = [ - dict( - name=account[0], - account_name=account[7], - label=account[1], - is_income_tax_liability=account[3], - is_income_tax_expense=account[4], - ) - for account in accounts - if account[4] - ] - - finance_costs = [ - dict(name=account[0], account_name=account[7], label=account[1], is_finance_cost=account[5]) - for account in accounts - if account[5] - ] - - account_types_labels = sorted( - set( - (d["label"], d["is_working_capital"], d["is_income_tax_liability"], d["is_income_tax_expense"]) - for d in account_types - ), - key=lambda x: x[1], - ) - - fc_adjustment_labels = sorted( - set( - [ - (d["label"], d["is_finance_cost"], d["is_finance_cost_adjustment"]) - for d in finance_costs_adjustments - if d["is_finance_cost_adjustment"] - ] - ), - key=lambda x: x[2], - ) - - unique_liability_labels = sorted( - set( - [ - (d["label"], d["is_income_tax_liability"], d["is_income_tax_expense"]) - for d in tax_liabilities - ] - ), - key=lambda x: x[0], - ) - - unique_expense_labels = sorted( - set( - [(d["label"], d["is_income_tax_liability"], d["is_income_tax_expense"]) for d in tax_expenses] - ), - key=lambda x: x[0], - ) - - unique_finance_costs_labels = sorted( - set([(d["label"], d["is_finance_cost"]) for d in finance_costs]), key=lambda x: x[0] - ) - - for label in account_types_labels: - names = [d["account_name"] for d in account_types if d["label"] == label[0]] - m = dict(label=label[0], names=names, is_working_capital=label[1]) - mapping["account_types"].append(m) - - for label in fc_adjustment_labels: - names = [d["account_name"] for d in finance_costs_adjustments if d["label"] == label[0]] - m = dict(label=label[0], names=names) - mapping["finance_costs_adjustments"].append(m) - - for label in unique_liability_labels: - names = [d["account_name"] for d in tax_liabilities if d["label"] == label[0]] - m = dict(label=label[0], names=names, tax_liability=label[1], tax_expense=label[2]) - mapping["tax_liabilities"].append(m) - - for label in unique_expense_labels: - names = [d["account_name"] for d in tax_expenses if d["label"] == label[0]] - m = dict(label=label[0], names=names, tax_liability=label[1], tax_expense=label[2]) - mapping["tax_expenses"].append(m) - - for label in unique_finance_costs_labels: - names = [d["account_name"] for d in finance_costs if d["label"] == label[0]] - m = dict(label=label[0], names=names, is_finance_cost=label[1]) - mapping["finance_costs"].append(m) - - cash_flow_accounts.append(mapping) - - return cash_flow_accounts - - -def add_data_for_operating_activities( - filters, company_currency, profit_data, period_list, light_mappers, mapper, data -): - has_added_working_capital_header = False - section_data = [] - - data.append( - { - "account_name": mapper["section_header"], - "parent_account": None, - "indent": 0.0, - "account": mapper["section_header"], - } - ) - - if profit_data: - profit_data.update( - {"indent": 1, "parent_account": get_mapper_for(light_mappers, position=1)["section_header"]} - ) - data.append(profit_data) - section_data.append(profit_data) - - data.append( - { - "account_name": mapper["section_leader"], - "parent_account": None, - "indent": 1.0, - "account": mapper["section_leader"], - } - ) - - for account in mapper["account_types"]: - if account["is_working_capital"] and not has_added_working_capital_header: - data.append( - { - "account_name": "Movement in working capital", - "parent_account": None, - "indent": 1.0, - "account": "", - } - ) - has_added_working_capital_header = True - - account_data = _get_account_type_based_data( - filters, account["names"], period_list, filters.accumulated_values - ) - - if not account["is_working_capital"]: - for key in account_data: - if key != "total": - account_data[key] *= -1 - - if account_data["total"] != 0: - account_data.update( - { - "account_name": account["label"], - "account": account["names"], - "indent": 1.0, - "parent_account": mapper["section_header"], - "currency": company_currency, - } - ) - data.append(account_data) - section_data.append(account_data) - - _add_total_row_account( - data, section_data, mapper["section_subtotal"], period_list, company_currency, indent=1 - ) - - # calculate adjustment for tax paid and add to data - if not mapper["tax_liabilities"]: - mapper["tax_liabilities"] = [ - dict(label="Income tax paid", names=[""], tax_liability=1, tax_expense=0) - ] - - for account in mapper["tax_liabilities"]: - tax_paid = calculate_adjustment( - filters, - mapper["tax_liabilities"], - mapper["tax_expenses"], - filters.accumulated_values, - period_list, - ) - - if tax_paid: - tax_paid.update( - { - "parent_account": mapper["section_header"], - "currency": company_currency, - "account_name": account["label"], - "indent": 1.0, - } - ) - data.append(tax_paid) - section_data.append(tax_paid) - - if not mapper["finance_costs_adjustments"]: - mapper["finance_costs_adjustments"] = [dict(label="Interest Paid", names=[""])] - - for account in mapper["finance_costs_adjustments"]: - interest_paid = calculate_adjustment( - filters, - mapper["finance_costs_adjustments"], - mapper["finance_costs"], - filters.accumulated_values, - period_list, - ) - - if interest_paid: - interest_paid.update( - { - "parent_account": mapper["section_header"], - "currency": company_currency, - "account_name": account["label"], - "indent": 1.0, - } - ) - data.append(interest_paid) - section_data.append(interest_paid) - - _add_total_row_account( - data, section_data, mapper["section_footer"], period_list, company_currency - ) - - -def calculate_adjustment( - filters, non_expense_mapper, expense_mapper, use_accumulated_values, period_list -): - liability_accounts = [d["names"] for d in non_expense_mapper] - expense_accounts = [d["names"] for d in expense_mapper] - - non_expense_closing = _get_account_type_based_data(filters, liability_accounts, period_list, 0) - - non_expense_opening = _get_account_type_based_data( - filters, liability_accounts, period_list, use_accumulated_values, opening_balances=1 - ) - - expense_data = _get_account_type_based_data( - filters, expense_accounts, period_list, use_accumulated_values - ) - - data = _calculate_adjustment(non_expense_closing, non_expense_opening, expense_data) - return data - - -def _calculate_adjustment(non_expense_closing, non_expense_opening, expense_data): - account_data = {} - for month in non_expense_opening.keys(): - if non_expense_opening[month] and non_expense_closing[month]: - account_data[month] = ( - non_expense_opening[month] - expense_data[month] + non_expense_closing[month] - ) - elif expense_data[month]: - account_data[month] = expense_data[month] - - return account_data - - -def add_data_for_other_activities( - filters, company_currency, profit_data, period_list, light_mappers, mapper_list, data -): - for mapper in mapper_list: - section_data = [] - data.append( - { - "account_name": mapper["section_header"], - "parent_account": None, - "indent": 0.0, - "account": mapper["section_header"], - } - ) - - for account in mapper["account_types"]: - account_data = _get_account_type_based_data( - filters, account["names"], period_list, filters.accumulated_values - ) - if account_data["total"] != 0: - account_data.update( - { - "account_name": account["label"], - "account": account["names"], - "indent": 1, - "parent_account": mapper["section_header"], - "currency": company_currency, - } - ) - data.append(account_data) - section_data.append(account_data) - - _add_total_row_account( - data, section_data, mapper["section_footer"], period_list, company_currency - ) - - -def compute_data(filters, company_currency, profit_data, period_list, light_mappers, full_mapper): - data = [] - - operating_activities_mapper = get_mapper_for(light_mappers, position=1) - other_mappers = [ - get_mapper_for(light_mappers, position=2), - get_mapper_for(light_mappers, position=3), - ] - - if operating_activities_mapper: - add_data_for_operating_activities( - filters, - company_currency, - profit_data, - period_list, - light_mappers, - operating_activities_mapper, - data, - ) - - if all(other_mappers): - add_data_for_other_activities( - filters, company_currency, profit_data, period_list, light_mappers, other_mappers, data - ) - - return data - - -def execute(filters=None): - if not filters.periodicity: - filters.periodicity = "Monthly" - period_list = get_period_list( - filters.from_fiscal_year, - filters.to_fiscal_year, - filters.period_start_date, - filters.period_end_date, - filters.filter_based_on, - filters.periodicity, - company=filters.company, - ) - - mappers = get_mappers_from_db() - - cash_flow_accounts = setup_mappers(mappers) - - # compute net profit / loss - income = get_data( - filters.company, - "Income", - "Credit", - period_list, - filters=filters, - accumulated_values=filters.accumulated_values, - ignore_closing_entries=True, - ignore_accumulated_values_for_fy=True, - ) - - expense = get_data( - filters.company, - "Expense", - "Debit", - period_list, - filters=filters, - accumulated_values=filters.accumulated_values, - ignore_closing_entries=True, - ignore_accumulated_values_for_fy=True, - ) - - net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company) - - company_currency = frappe.get_cached_value("Company", filters.company, "default_currency") - - data = compute_data( - filters, company_currency, net_profit_loss, period_list, mappers, cash_flow_accounts - ) - - _add_total_row_account(data, data, _("Net Change in Cash"), period_list, company_currency) - columns = get_columns( - filters.periodicity, period_list, filters.accumulated_values, filters.company - ) - - return columns, data - - -def _get_account_type_based_data( - filters, account_names, period_list, accumulated_values, opening_balances=0 -): - if not account_names or not account_names[0] or not type(account_names[0]) == str: - # only proceed if account_names is a list of account names - return {} - - from erpnext.accounts.report.cash_flow.cash_flow import get_start_date - - company = filters.company - data = {} - total = 0 - GLEntry = frappe.qb.DocType("GL Entry") - Account = frappe.qb.DocType("Account") - - for period in period_list: - start_date = get_start_date(period, accumulated_values, company) - - account_subquery = ( - frappe.qb.from_(Account) - .where((Account.name.isin(account_names)) | (Account.parent_account.isin(account_names))) - .select(Account.name) - .as_("account_subquery") - ) - - if opening_balances: - date_info = dict(date=start_date) - months_map = {"Monthly": -1, "Quarterly": -3, "Half-Yearly": -6} - years_map = {"Yearly": -1} - - if months_map.get(filters.periodicity): - date_info.update(months=months_map[filters.periodicity]) - else: - date_info.update(years=years_map[filters.periodicity]) - - if accumulated_values: - start, end = add_to_date(start_date, years=-1), add_to_date(period["to_date"], years=-1) - else: - start, end = add_to_date(**date_info), add_to_date(**date_info) - - start, end = get_date_str(start), get_date_str(end) - - else: - start, end = start_date if accumulated_values else period["from_date"], period["to_date"] - start, end = get_date_str(start), get_date_str(end) - - result = ( - frappe.qb.from_(GLEntry) - .select(Sum(GLEntry.credit) - Sum(GLEntry.debit)) - .where( - (GLEntry.company == company) - & (GLEntry.posting_date >= start) - & (GLEntry.posting_date <= end) - & (GLEntry.voucher_type != "Period Closing Voucher") - & (GLEntry.account.isin(account_subquery)) - ) - ).run() - - if result and result[0]: - gl_sum = result[0][0] - else: - gl_sum = 0 - - total += flt(gl_sum) - data.setdefault(period["key"], flt(gl_sum)) - - data["total"] = total - return data - - -def _add_total_row_account(out, data, label, period_list, currency, indent=0.0): - total_row = { - "indent": indent, - "account_name": "'" + _("{0}").format(label) + "'", - "account": "'" + _("{0}").format(label) + "'", - "currency": currency, - } - for row in data: - if row.get("parent_account"): - for period in period_list: - total_row.setdefault(period.key, 0.0) - total_row[period.key] += row.get(period.key, 0.0) - - total_row.setdefault("total", 0.0) - total_row["total"] += row["total"] - - out.append(total_row) - out.append({}) diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index 33da6ffe78..a6447549e6 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -6,7 +6,7 @@ from collections import defaultdict import frappe from frappe import _ -from frappe.utils import cint, flt, getdate +from frappe.utils import flt, getdate import erpnext from erpnext.accounts.report.balance_sheet.balance_sheet import ( @@ -58,11 +58,6 @@ def execute(filters=None): fiscal_year, companies, columns, filters ) else: - if cint(frappe.db.get_single_value("Accounts Settings", "use_custom_cash_flow")): - from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom - - return execute_custom(filters=filters) - data, report_summary = get_cash_flow_data(fiscal_year, companies, filters) return columns, data, message, chart, report_summary diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 47eced7c2e..18bd10f45f 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -15,7 +15,6 @@ erpnext.patches.v10_0.rename_price_to_rate_in_pricing_rule erpnext.patches.v10_0.set_currency_in_pricing_rule erpnext.patches.v10_0.update_translatable_fields execute:frappe.delete_doc('DocType', 'Production Planning Tool', ignore_missing=True) -erpnext.patches.v10_0.add_default_cash_flow_mappers erpnext.patches.v11_0.rename_duplicate_item_code_values erpnext.patches.v11_0.make_quality_inspection_template erpnext.patches.v11_0.merge_land_unit_with_location @@ -334,4 +333,9 @@ execute:frappe.delete_doc_if_exists("Report", "Tax Detail") erpnext.patches.v15_0.enable_all_leads erpnext.patches.v14_0.update_company_in_ldc erpnext.patches.v14_0.set_packed_qty_in_draft_delivery_notes +execute:frappe.delete_doc('DocType', 'Cash Flow Mapping Template Details', ignore_missing=True) +execute:frappe.delete_doc('DocType', 'Cash Flow Mapping', ignore_missing=True) +execute:frappe.delete_doc('DocType', 'Cash Flow Mapper', ignore_missing=True) +execute:frappe.delete_doc('DocType', 'Cash Flow Mapping Template', ignore_missing=True) +execute:frappe.delete_doc('DocType', 'Cash Flow Mapping Accounts', ignore_missing=True) erpnext.patches.v14_0.cleanup_workspaces diff --git a/erpnext/patches/v10_0/add_default_cash_flow_mappers.py b/erpnext/patches/v10_0/add_default_cash_flow_mappers.py deleted file mode 100644 index 5493258e3d..0000000000 --- a/erpnext/patches/v10_0/add_default_cash_flow_mappers.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2017, Frappe and Contributors -# License: GNU General Public License v3. See license.txt - - -import frappe - -from erpnext.setup.install import create_default_cash_flow_mapper_templates - - -def execute(): - frappe.reload_doc("accounts", "doctype", frappe.scrub("Cash Flow Mapping")) - frappe.reload_doc("accounts", "doctype", frappe.scrub("Cash Flow Mapper")) - frappe.reload_doc("accounts", "doctype", frappe.scrub("Cash Flow Mapping Template Details")) - - create_default_cash_flow_mapper_templates() diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index 0d780c2281..cf9600eb49 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -8,7 +8,6 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to from frappe.utils import cint -from erpnext.accounts.doctype.cash_flow_mapper.default_cash_flow_mapper import DEFAULT_MAPPERS from erpnext.setup.default_energy_point_rules import get_default_energy_point_rules from erpnext.setup.doctype.incoterm.incoterm import create_incoterms @@ -23,7 +22,6 @@ def after_install(): set_single_defaults() create_print_setting_custom_fields() add_all_roles_to("Administrator") - create_default_cash_flow_mapper_templates() create_default_success_action() create_default_energy_point_rules() create_incoterms() @@ -116,13 +114,6 @@ def create_print_setting_custom_fields(): ) -def create_default_cash_flow_mapper_templates(): - for mapper in DEFAULT_MAPPERS: - if not frappe.db.exists("Cash Flow Mapper", mapper["section_name"]): - doc = frappe.get_doc(mapper) - doc.insert(ignore_permissions=True) - - def create_default_success_action(): for success_action in get_default_success_action(): if not frappe.db.exists("Success Action", success_action.get("ref_doctype")):