From a0783de23253de6fa0509d77b94810d77b23144a Mon Sep 17 00:00:00 2001 From: Saqib Date: Thu, 22 Apr 2021 14:31:46 +0530 Subject: [PATCH 1/7] fix: remove invalid changes added due to merge conflict (#25405) * fix: merge conflict * fix: recover lost method --- erpnext/regional/india/e_invoice/utils.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index 7637d2d4583..c9f0b0b2592 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -139,10 +139,6 @@ def get_party_details(address_name, is_shipping_address=False): address_line1=sanitize_for_json(addr.address_line1), address_line2=sanitize_for_json(addr.address_line2) )) - if d.gstin: - party_address_details.gstin = d.gstin - - return party_address_details return party_address_details @@ -427,7 +423,7 @@ def make_einvoice(invoice): item_list = get_item_list(invoice) doc_details = get_doc_details(invoice) invoice_value_details = get_invoice_value_details(invoice) - seller_details = get_party_details(invoice.company_address, company_address=1) + seller_details = get_party_details(invoice.company_address) if invoice.gst_category == 'Overseas': buyer_details = get_overseas_address_details(invoice.customer_address) @@ -448,7 +444,7 @@ def make_einvoice(invoice): if invoice.gst_category == 'Overseas': shipping_details = get_overseas_address_details(invoice.shipping_address_name) else: - shipping_details = get_party_details(invoice.shipping_address_name, shipping_address=True) + shipping_details = get_party_details(invoice.shipping_address_name, is_shipping_address=True) if invoice.is_pos and invoice.base_paid_amount: payment_details = get_payment_details(invoice) @@ -550,6 +546,13 @@ def safe_json_load(json_string): snippet = json_string[start:end] frappe.throw(_("Error in input data. Please check for any special characters near following input:
{}").format(snippet)) +def throw_error_list(errors, title): + if len(errors) > 1: + li = ['
  • '+ d +'
  • ' for d in errors] + frappe.throw("".format(''.join(li)), title=title) + else: + frappe.throw(errors[0], title=title) + class RequestFailed(Exception): pass class GSPConnector(): @@ -576,7 +579,7 @@ class GSPConnector(): gstin = self.get_seller_gstin() credentials_for_gstin = [d for d in self.e_invoice_settings.credentials if d.gstin == gstin] if credentials_for_gstin: - self.credentials = credentials_for_gstin[0] + credentials = credentials_for_gstin[0] else: frappe.throw(_('Cannot find e-invoicing credentials for selected Company GSTIN. Please check E-Invoice Settings')) else: From 96c099c6090eafc08b2954056111d2540a65eed2 Mon Sep 17 00:00:00 2001 From: Saqib Date: Mon, 26 Apr 2021 15:40:29 +0530 Subject: [PATCH 2/7] fix: remove invalid changes added due to merge conflicts (#25404) * fix: merge conflicts * fix: merge conflict * fix: recover lost method --- erpnext/regional/india/e_invoice/utils.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index 7637d2d4583..c9f0b0b2592 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -139,10 +139,6 @@ def get_party_details(address_name, is_shipping_address=False): address_line1=sanitize_for_json(addr.address_line1), address_line2=sanitize_for_json(addr.address_line2) )) - if d.gstin: - party_address_details.gstin = d.gstin - - return party_address_details return party_address_details @@ -427,7 +423,7 @@ def make_einvoice(invoice): item_list = get_item_list(invoice) doc_details = get_doc_details(invoice) invoice_value_details = get_invoice_value_details(invoice) - seller_details = get_party_details(invoice.company_address, company_address=1) + seller_details = get_party_details(invoice.company_address) if invoice.gst_category == 'Overseas': buyer_details = get_overseas_address_details(invoice.customer_address) @@ -448,7 +444,7 @@ def make_einvoice(invoice): if invoice.gst_category == 'Overseas': shipping_details = get_overseas_address_details(invoice.shipping_address_name) else: - shipping_details = get_party_details(invoice.shipping_address_name, shipping_address=True) + shipping_details = get_party_details(invoice.shipping_address_name, is_shipping_address=True) if invoice.is_pos and invoice.base_paid_amount: payment_details = get_payment_details(invoice) @@ -550,6 +546,13 @@ def safe_json_load(json_string): snippet = json_string[start:end] frappe.throw(_("Error in input data. Please check for any special characters near following input:
    {}").format(snippet)) +def throw_error_list(errors, title): + if len(errors) > 1: + li = ['
  • '+ d +'
  • ' for d in errors] + frappe.throw("".format(''.join(li)), title=title) + else: + frappe.throw(errors[0], title=title) + class RequestFailed(Exception): pass class GSPConnector(): @@ -576,7 +579,7 @@ class GSPConnector(): gstin = self.get_seller_gstin() credentials_for_gstin = [d for d in self.e_invoice_settings.credentials if d.gstin == gstin] if credentials_for_gstin: - self.credentials = credentials_for_gstin[0] + credentials = credentials_for_gstin[0] else: frappe.throw(_('Cannot find e-invoicing credentials for selected Company GSTIN. Please check E-Invoice Settings')) else: From 5946c2f28e5a2c0733260399277349e6e54f6758 Mon Sep 17 00:00:00 2001 From: casesolved-co-uk Date: Wed, 14 Apr 2021 10:15:34 +0000 Subject: [PATCH 3/7] fix: plaid NoneType error #24675 --- .../doctype/plaid_settings/plaid_settings.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py index ae8abf2eb15..05b7d11b794 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py @@ -146,8 +146,9 @@ def sync_transactions(bank, bank_account): transactions = get_transactions(bank=bank, bank_account=bank_account, start_date=start_date, end_date=end_date) result = [] - for transaction in reversed(transactions): - result += new_bank_transaction(transaction) + if transactions: + for transaction in reversed(transactions): + result += new_bank_transaction(transaction) if result: last_transaction_date = frappe.db.get_value('Bank Transaction', result.pop(), 'date') From 0b45d5e1ecdb5e246f76bba77251d8a1774bb575 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 13 May 2021 01:37:12 +0530 Subject: [PATCH 4/7] fix: timeout error while loading warehouse tree --- erpnext/stock/doctype/warehouse/warehouse.py | 47 ++++++++++++++++--- .../stock/doctype/warehouse/warehouse_tree.js | 2 +- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py index 312488984cd..5a55635d334 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.py +++ b/erpnext/stock/doctype/warehouse/warehouse.py @@ -3,8 +3,9 @@ from __future__ import unicode_literals import frappe, erpnext -from frappe.utils import cint, nowdate +from frappe.utils import cint, flt from frappe import throw, _ +from collections import defaultdict from frappe.utils.nestedset import NestedSet from erpnext.stock import get_warehouse_account from frappe.contacts.address_and_contact import load_address_and_contact @@ -29,7 +30,6 @@ class Warehouse(NestedSet): self.set_onload('account', account) load_address_and_contact(self) - def on_update(self): self.update_nsm_model() @@ -140,8 +140,6 @@ class Warehouse(NestedSet): @frappe.whitelist() def get_children(doctype, parent=None, company=None, is_root=False): - from erpnext.stock.utils import get_stock_value_from_bin - if is_root: parent = "" @@ -154,13 +152,48 @@ def get_children(doctype, parent=None, company=None, is_root=False): warehouses = frappe.get_list(doctype, fields=fields, filters=filters, order_by='name') + company_currency = '' + if company: + company_currency = frappe.get_cached_value('Company', company, 'default_currency') + + warehouse_wise_value = get_warehouse_wise_stock_value(company) + # return warehouses for wh in warehouses: - wh["balance"] = get_stock_value_from_bin(warehouse=wh.value) - if company: - wh["company_currency"] = frappe.db.get_value('Company', company, 'default_currency') + wh["balance"] = warehouse_wise_value.get(wh.value) + if company_currency: + wh["company_currency"] = company_currency return warehouses +def get_warehouse_wise_stock_value(company): + warehouses = frappe.get_all('Warehouse', + fields = ['name', 'parent_warehouse'], filters = {'company': company}) + parent_warehouse = {d.name : d.parent_warehouse for d in warehouses} + + filters = {'warehouse': ('in', [data.name for data in warehouses])} + bin_data = frappe.get_all('Bin', fields = ['sum(stock_value) as stock_value', 'warehouse'], + filters = filters, group_by = 'warehouse') + + warehouse_wise_stock_value = defaultdict(float) + for row in bin_data: + if not row.stock_value: + continue + + warehouse_wise_stock_value[row.warehouse] = row.stock_value + update_value_in_parent_warehouse(warehouse_wise_stock_value, + parent_warehouse, row.warehouse, row.stock_value) + + return warehouse_wise_stock_value + +def update_value_in_parent_warehouse(warehouse_wise_stock_value, parent_warehouse_dict, warehouse, stock_value): + parent_warehouse = parent_warehouse_dict.get(warehouse) + if not parent_warehouse: + return + + warehouse_wise_stock_value[parent_warehouse] += flt(stock_value) + update_value_in_parent_warehouse(warehouse_wise_stock_value, parent_warehouse_dict, + parent_warehouse, stock_value) + @frappe.whitelist() def add_node(): from frappe.desk.treeview import make_tree_args diff --git a/erpnext/stock/doctype/warehouse/warehouse_tree.js b/erpnext/stock/doctype/warehouse/warehouse_tree.js index 918d2f15593..a69660ffa2b 100644 --- a/erpnext/stock/doctype/warehouse/warehouse_tree.js +++ b/erpnext/stock/doctype/warehouse/warehouse_tree.js @@ -20,7 +20,7 @@ frappe.treeview_settings['Warehouse'] = { onrender: function(node) { if (node.data && node.data.balance!==undefined) { $('' - + format_currency(Math.abs(node.data.balance), node.data.company_currency) + + format_currency((node.data.balance), node.data.company_currency) + '').insertBefore(node.$ul); } } From df51aa30879410d49a90c8e35ccb9d8eb34e23db Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 14 May 2021 21:31:22 +0530 Subject: [PATCH 5/7] fix: Ignore rounding diff while importig JV using data import --- erpnext/accounts/doctype/journal_entry/journal_entry.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 709dccd2230..dbe8fe40923 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -29,7 +29,11 @@ class JournalEntry(AccountsController): self.validate_entries_for_advance() self.validate_multi_currency() self.set_amounts_in_company_currency() - self.validate_total_debit_and_credit() + + # Do not validate while importing via data import + if not frappe.flags.in_import: + self.validate_total_debit_and_credit() + self.validate_against_jv() self.validate_reference_doc() self.set_against_account() @@ -1047,4 +1051,4 @@ def make_reverse_journal_entry(source_name, target_doc=None): }, }, target_doc) - return doclist \ No newline at end of file + return doclist \ No newline at end of file From 4d9c9db295ea780f3c3dea1bcb806c426a6716dc Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 20 May 2021 18:49:42 +0530 Subject: [PATCH 6/7] chore: Added change log for v12.21.0 --- erpnext/change_log/v12/v12_21_0.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 erpnext/change_log/v12/v12_21_0.md diff --git a/erpnext/change_log/v12/v12_21_0.md b/erpnext/change_log/v12/v12_21_0.md new file mode 100644 index 00000000000..946bf09d9e4 --- /dev/null +++ b/erpnext/change_log/v12/v12_21_0.md @@ -0,0 +1,21 @@ +## Version 12.21.0 Release Notes + + +### Fixes & Enhancements + +- Incorrect qty calculated for sub-contracted raw materials in purchase receipt ([#25443](https://github.com/frappe/erpnext/pull/25443)) +- Update cost center in the item table fetched from POS Profile in v12 ([#25612](https://github.com/frappe/erpnext/pull/25612)) +- Total stock summary report not working ([#25552](https://github.com/frappe/erpnext/pull/25552)) +- Timeout error while loading warehouse tree ([#25693](https://github.com/frappe/erpnext/pull/25693)) +- RCM rounding precision ([#25410](https://github.com/frappe/erpnext/pull/25410)) +- Change subcontracted item display ([#25426](https://github.com/frappe/erpnext/pull/25426)) +- Remove invalid changes added due to merge conflict ([#25437](https://github.com/frappe/erpnext/pull/25437)) +- Add document type field for e-invoicing (Italy) ([#25420](https://github.com/frappe/erpnext/pull/25420)) +- Issue in project custom status ([#25453](https://github.com/frappe/erpnext/pull/25453)) +- Employee Separation ([#25504](https://github.com/frappe/erpnext/pull/25504)) +- State code for Other Territory ([#25422](https://github.com/frappe/erpnext/pull/25422)) +- Remove invalid changes added due to merge conflict ([#25405](https://github.com/frappe/erpnext/pull/25405)) +- Check for None in item.schedule_date before setting ([#25589](https://github.com/frappe/erpnext/pull/25589)) +- Can't multiply sequence by non-int of type 'float' ([#25385](https://github.com/frappe/erpnext/pull/25385)) +- Filter using purpose, make requested changes ([#25388](https://github.com/frappe/erpnext/pull/25388)) +- Purchase from registered composition dealer ([#25419](https://github.com/frappe/erpnext/pull/25419)) \ No newline at end of file From 65b7b57c70a7e429098711e8803bb000529a2ed8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 20 May 2021 19:11:42 +0550 Subject: [PATCH 7/7] bumped to version 12.21.0 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 566dd158a67..1fdf73a0595 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '12.20.0' +__version__ = '12.21.0' def get_default_company(user=None): '''Get default company for user'''