From 2813e5ee2956f4667ecb9e02cb3a824c0fb7a0bd Mon Sep 17 00:00:00 2001 From: ruthra Date: Mon, 13 Dec 2021 12:26:23 +0530 Subject: [PATCH 01/18] feat: new column 'Time taken to Deliver' in sales order analysis --- .../sales_order_analysis/sales_order_analysis.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py index 82e5d0ce57..f1edca4cef 100644 --- a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py +++ b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py @@ -61,6 +61,7 @@ def get_data(conditions, filters): IF(so.status in ('Completed','To Bill'), 0, (SELECT delay_days)) as delay, soi.qty, soi.delivered_qty, (soi.qty - soi.delivered_qty) AS pending_qty, + IF((SELECT pending_qty) = 0, DATEDIFF(Max(dn.posting_date), so.transaction_date), 0) as time_taken_to_deliver, IFNULL(SUM(sii.qty), 0) as billed_qty, soi.base_amount as amount, (soi.delivered_qty * soi.base_rate) as delivered_qty_amount, @@ -70,9 +71,13 @@ def get_data(conditions, filters): so.company, soi.name FROM `tabSales Order` so, - `tabSales Order Item` soi + (`tabSales Order Item` soi LEFT JOIN `tabSales Invoice Item` sii - ON sii.so_detail = soi.name and sii.docstatus = 1 + ON sii.so_detail = soi.name and sii.docstatus = 1) + LEFT JOIN `tabDelivery Note Item` dni + on dni.so_detail = soi.name + RIGHT JOIN `tabDelivery Note` dn + on dni.parent = dn.name and dn.docstatus = 1 WHERE soi.parent = so.name and so.status not in ('Stopped', 'Closed', 'On Hold') @@ -259,6 +264,12 @@ def get_columns(filters): "fieldname": "delay", "fieldtype": "Data", "width": 100 + }, + { + "label": _("Time Taken to Deliver"), + "fieldname": "time_taken_to_deliver", + "fieldtype": "Data", + "width": 100 } ]) if not filters.get("group_by_so"): From 9232f7599870b755c23a7f179306c6eed93f60dc Mon Sep 17 00:00:00 2001 From: ruthra Date: Tue, 14 Dec 2021 19:45:09 +0530 Subject: [PATCH 02/18] refactor: change field to duration and fetch elapsed seconds --- .../report/sales_order_analysis/sales_order_analysis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py index f1edca4cef..0c0acc76e3 100644 --- a/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py +++ b/erpnext/selling/report/sales_order_analysis/sales_order_analysis.py @@ -61,7 +61,7 @@ def get_data(conditions, filters): IF(so.status in ('Completed','To Bill'), 0, (SELECT delay_days)) as delay, soi.qty, soi.delivered_qty, (soi.qty - soi.delivered_qty) AS pending_qty, - IF((SELECT pending_qty) = 0, DATEDIFF(Max(dn.posting_date), so.transaction_date), 0) as time_taken_to_deliver, + IF((SELECT pending_qty) = 0, (TO_SECONDS(Max(dn.posting_date))-TO_SECONDS(so.transaction_date)), 0) as time_taken_to_deliver, IFNULL(SUM(sii.qty), 0) as billed_qty, soi.base_amount as amount, (soi.delivered_qty * soi.base_rate) as delivered_qty_amount, @@ -268,7 +268,7 @@ def get_columns(filters): { "label": _("Time Taken to Deliver"), "fieldname": "time_taken_to_deliver", - "fieldtype": "Data", + "fieldtype": "Duration", "width": 100 } ]) From 1ed30ee7c7f2f270989ab65ed79e60f06d0a48d0 Mon Sep 17 00:00:00 2001 From: Ganga Manoj Date: Tue, 21 Dec 2021 13:59:53 +0530 Subject: [PATCH 03/18] fix: Reset value_after_depreciation on reversing journal entry during Asset return --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 64712b550f..321b45323f 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1049,6 +1049,8 @@ class SalesInvoice(SellingController): frappe.flags.is_reverse_depr_entry = False asset.flags.ignore_validate_update_after_submit = True schedule.journal_entry = None + depreciation_amount = self.get_depreciation_amount_in_je(reverse_journal_entry) + asset.finance_books[0].value_after_depreciation += depreciation_amount asset.save() def get_posting_date_of_sales_invoice(self): @@ -1071,6 +1073,12 @@ class SalesInvoice(SellingController): return False + def get_depreciation_amount_in_je(self, journal_entry): + if journal_entry.accounts[0].debit_in_account_currency: + return journal_entry.accounts[0].debit_in_account_currency + else: + return journal_entry.accounts[0].credit_in_account_currency + @property def enable_discount_accounting(self): if not hasattr(self, "_enable_discount_accounting"): From 076cb408db6577d3901e339d298064760f47edb0 Mon Sep 17 00:00:00 2001 From: Development for People <47140294+developmentforpeople@users.noreply.github.com> Date: Tue, 21 Dec 2021 10:18:31 +0000 Subject: [PATCH 04/18] fix: missed colon (#28979) --- erpnext/hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 9ceb6267a7..1d11f20ab7 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -374,7 +374,7 @@ scheduler_events = { "erpnext.selling.doctype.quotation.quotation.set_expired_status", "erpnext.buying.doctype.supplier_quotation.supplier_quotation.set_expired_status", "erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.send_auto_email", - "erpnext.non_profit.doctype.membership.membership.set_expired_status" + "erpnext.non_profit.doctype.membership.membership.set_expired_status", "erpnext.hr.doctype.interview.interview.send_daily_feedback_reminder" ], "daily_long": [ From db7aef2fef14a09053dfffe443b9099dae21c202 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 21 Dec 2021 17:39:27 +0530 Subject: [PATCH 05/18] style: better labels for SLE fields (#28988) * style: better labels for SLE fields * style: rename stock queue field [skip ci] Co-Authored-by: marination --- .../stock_ledger_entry/stock_ledger_entry.json | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json index 2651407d16..46ce9debf3 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json @@ -150,7 +150,7 @@ "fieldtype": "Float", "in_filter": 1, "in_list_view": 1, - "label": "Actual Quantity", + "label": "Qty Change", "oldfieldname": "actual_qty", "oldfieldtype": "Currency", "print_width": "150px", @@ -189,7 +189,7 @@ "fieldname": "qty_after_transaction", "fieldtype": "Float", "in_filter": 1, - "label": "Actual Qty After Transaction", + "label": "Qty After Transaction", "oldfieldname": "bin_aqat", "oldfieldtype": "Currency", "print_width": "150px", @@ -210,7 +210,7 @@ { "fieldname": "stock_value", "fieldtype": "Currency", - "label": "Stock Value", + "label": "Balance Stock Value", "oldfieldname": "stock_value", "oldfieldtype": "Currency", "options": "Company:company:default_currency", @@ -219,14 +219,14 @@ { "fieldname": "stock_value_difference", "fieldtype": "Currency", - "label": "Stock Value Difference", + "label": "Change in Stock Value", "options": "Company:company:default_currency", "read_only": 1 }, { "fieldname": "stock_queue", "fieldtype": "Text", - "label": "Stock Queue (FIFO)", + "label": "FIFO Stock Queue (qty, rate)", "oldfieldname": "fcfs_stack", "oldfieldtype": "Text", "print_hide": 1, @@ -317,10 +317,11 @@ "in_create": 1, "index_web_pages_for_search": 1, "links": [], - "modified": "2021-10-08 13:42:51.857631", + "modified": "2021-12-21 06:25:30.040801", "modified_by": "Administrator", "module": "Stock", "name": "Stock Ledger Entry", + "naming_rule": "Expression (old style)", "owner": "Administrator", "permissions": [ { @@ -338,5 +339,6 @@ } ], "sort_field": "modified", - "sort_order": "DESC" -} + "sort_order": "DESC", + "states": [] +} \ No newline at end of file From 8dc1ce12d4d3590b4496d5aa3f25e9ee89abba89 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 22 Dec 2021 12:12:24 +0530 Subject: [PATCH 06/18] chore: simplify bug report form --- .github/ISSUE_TEMPLATE/bug_report.yaml | 27 ++++---------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index a6e16a03d8..8f938112a7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -24,20 +24,6 @@ body: validations: required: true - - type: dropdown - id: version - attributes: - label: Version - description: Affected versions. - multiple: true - options: - - v12 - - v13 - - v14 - - develop - validations: - required: true - - type: dropdown id: module attributes: @@ -86,7 +72,7 @@ body: - manual install - FrappeCloud validations: - required: true + required: false - type: textarea id: logs @@ -95,12 +81,7 @@ body: description: Please copy and paste any relevant log output. This will be automatically formatted. render: shell - - - type: checkboxes - id: terms + - type: markdown attributes: - label: Code of Conduct - description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/frappe/erpnext/blob/develop/CODE_OF_CONDUCT.md) - options: - - label: I agree to follow this project's Code of Conduct - required: true + value: | + By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/frappe/erpnext/blob/develop/CODE_OF_CONDUCT.md) From f6d55346276a81ed5d6d2425cb98015903968ece Mon Sep 17 00:00:00 2001 From: Saqib Date: Wed, 22 Dec 2021 19:05:18 +0530 Subject: [PATCH 07/18] fix: set resolution by only if not on hold (#28995) --- erpnext/support/doctype/issue/test_issue.py | 1 + .../service_level_agreement/service_level_agreement.py | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/erpnext/support/doctype/issue/test_issue.py b/erpnext/support/doctype/issue/test_issue.py index 14cec46ad4..7a0a5e506f 100644 --- a/erpnext/support/doctype/issue/test_issue.py +++ b/erpnext/support/doctype/issue/test_issue.py @@ -98,6 +98,7 @@ class TestIssue(TestSetUp): issue.save() self.assertEqual(issue.on_hold_since, frappe.flags.current_time) + self.assertFalse(issue.resolution_by) creation = get_datetime("2020-03-04 5:00") frappe.flags.current_time = get_datetime("2020-03-04 5:00") diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py index c94700bdc5..b3348f1e1e 100644 --- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py +++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py @@ -476,7 +476,7 @@ def update_response_and_resolution_metrics(doc, apply_sla_for_resolution): priority = get_response_and_resolution_duration(doc) start_date_time = get_datetime(doc.get("service_level_agreement_creation") or doc.creation) set_response_by(doc, start_date_time, priority) - if apply_sla_for_resolution: + if apply_sla_for_resolution and not doc.get('on_hold_since'): # resolution_by is reset if on hold set_resolution_by(doc, start_date_time, priority) @@ -624,9 +624,6 @@ def reset_resolution_metrics(doc): if doc.meta.has_field("user_resolution_time"): doc.user_resolution_time = None - if doc.meta.has_field("agreement_status"): - doc.agreement_status = "First Response Due" - # called via hooks on communication update def on_communication_update(doc, status): From ae929d7a63352e05a70c31ac182611f8c9fb89fb Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 23 Dec 2021 19:18:05 +0530 Subject: [PATCH 08/18] fix(test): Leave Allocation validation against Leave Application after submit (#29005) * fix(test): Leave Allocation validation against Leave Application after submit * chore: clean-up Leave Allocation tests * fix(test): set holiday list for leave allocation test --- .../leave_allocation/test_leave_allocation.py | 72 +++++++++---------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/erpnext/hr/doctype/leave_allocation/test_leave_allocation.py b/erpnext/hr/doctype/leave_allocation/test_leave_allocation.py index 46401a2dd8..6dbe2eca32 100644 --- a/erpnext/hr/doctype/leave_allocation/test_leave_allocation.py +++ b/erpnext/hr/doctype/leave_allocation/test_leave_allocation.py @@ -4,6 +4,7 @@ import frappe from frappe.utils import add_days, add_months, getdate, nowdate import erpnext +from erpnext.hr.doctype.employee.test_employee import make_employee from erpnext.hr.doctype.leave_ledger_entry.leave_ledger_entry import process_expired_allocation from erpnext.hr.doctype.leave_type.test_leave_type import create_leave_type @@ -11,18 +12,25 @@ from erpnext.hr.doctype.leave_type.test_leave_type import create_leave_type class TestLeaveAllocation(unittest.TestCase): @classmethod def setUpClass(cls): + from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list + frappe.db.sql("delete from `tabLeave Period`") + emp_id = make_employee("test_emp_leave_allocation@salary.com") + cls.employee = frappe.get_doc("Employee", emp_id) + + make_holiday_list() + frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List") + + def tearDown(self): + frappe.db.rollback() def test_overlapping_allocation(self): - frappe.db.sql("delete from `tabLeave Allocation`") - - employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0]) leaves = [ { "doctype": "Leave Allocation", "__islocal": 1, - "employee": employee.name, - "employee_name": employee.employee_name, + "employee": self.employee.name, + "employee_name": self.employee.employee_name, "leave_type": "_Test Leave Type", "from_date": getdate("2015-10-01"), "to_date": getdate("2015-10-31"), @@ -32,8 +40,8 @@ class TestLeaveAllocation(unittest.TestCase): { "doctype": "Leave Allocation", "__islocal": 1, - "employee": employee.name, - "employee_name": employee.employee_name, + "employee": self.employee.name, + "employee_name": self.employee.employee_name, "leave_type": "_Test Leave Type", "from_date": getdate("2015-09-01"), "to_date": getdate("2015-11-30"), @@ -45,40 +53,36 @@ class TestLeaveAllocation(unittest.TestCase): self.assertRaises(frappe.ValidationError, frappe.get_doc(leaves[1]).save) def test_invalid_period(self): - employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0]) - doc = frappe.get_doc({ "doctype": "Leave Allocation", "__islocal": 1, - "employee": employee.name, - "employee_name": employee.employee_name, + "employee": self.employee.name, + "employee_name": self.employee.employee_name, "leave_type": "_Test Leave Type", "from_date": getdate("2015-09-30"), "to_date": getdate("2015-09-1"), "new_leaves_allocated": 5 }) - #invalid period + # invalid period self.assertRaises(frappe.ValidationError, doc.save) def test_allocated_leave_days_over_period(self): - employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0]) doc = frappe.get_doc({ "doctype": "Leave Allocation", "__islocal": 1, - "employee": employee.name, - "employee_name": employee.employee_name, + "employee": self.employee.name, + "employee_name": self.employee.employee_name, "leave_type": "_Test Leave Type", "from_date": getdate("2015-09-1"), "to_date": getdate("2015-09-30"), "new_leaves_allocated": 35 }) - #allocated leave more than period + + # allocated leave more than period self.assertRaises(frappe.ValidationError, doc.save) def test_carry_forward_calculation(self): - frappe.db.sql("delete from `tabLeave Allocation`") - frappe.db.sql("delete from `tabLeave Ledger Entry`") leave_type = create_leave_type(leave_type_name="_Test_CF_leave", is_carry_forward=1) leave_type.maximum_carry_forwarded_leaves = 10 leave_type.max_leaves_allowed = 30 @@ -114,8 +118,6 @@ class TestLeaveAllocation(unittest.TestCase): self.assertEqual(leave_allocation_2.unused_leaves, 5) def test_carry_forward_leaves_expiry(self): - frappe.db.sql("delete from `tabLeave Allocation`") - frappe.db.sql("delete from `tabLeave Ledger Entry`") leave_type = create_leave_type( leave_type_name="_Test_CF_leave_expiry", is_carry_forward=1, @@ -151,8 +153,6 @@ class TestLeaveAllocation(unittest.TestCase): self.assertEqual(leave_allocation_1.unused_leaves, leave_allocation.new_leaves_allocated) def test_creation_of_leave_ledger_entry_on_submit(self): - frappe.db.sql("delete from `tabLeave Allocation`") - leave_allocation = create_leave_allocation() leave_allocation.submit() @@ -168,9 +168,6 @@ class TestLeaveAllocation(unittest.TestCase): self.assertFalse(frappe.db.exists("Leave Ledger Entry", {'transaction_name':leave_allocation.name})) def test_leave_addition_after_submit(self): - frappe.db.sql("delete from `tabLeave Allocation`") - frappe.db.sql("delete from `tabLeave Ledger Entry`") - leave_allocation = create_leave_allocation() leave_allocation.submit() self.assertTrue(leave_allocation.total_leaves_allocated, 15) @@ -179,8 +176,6 @@ class TestLeaveAllocation(unittest.TestCase): self.assertTrue(leave_allocation.total_leaves_allocated, 40) def test_leave_subtraction_after_submit(self): - frappe.db.sql("delete from `tabLeave Allocation`") - frappe.db.sql("delete from `tabLeave Ledger Entry`") leave_allocation = create_leave_allocation() leave_allocation.submit() self.assertTrue(leave_allocation.total_leaves_allocated, 15) @@ -188,17 +183,14 @@ class TestLeaveAllocation(unittest.TestCase): leave_allocation.submit() self.assertTrue(leave_allocation.total_leaves_allocated, 10) - def test_against_leave_application_validation_after_submit(self): - frappe.db.sql("delete from `tabLeave Allocation`") - frappe.db.sql("delete from `tabLeave Ledger Entry`") - + def test_validation_against_leave_application_after_submit(self): leave_allocation = create_leave_allocation() leave_allocation.submit() self.assertTrue(leave_allocation.total_leaves_allocated, 15) - employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0]) + leave_application = frappe.get_doc({ "doctype": 'Leave Application', - "employee": employee.name, + "employee": self.employee.name, "leave_type": "_Test Leave Type", "from_date": add_months(nowdate(), 2), "to_date": add_months(add_days(nowdate(), 10), 2), @@ -208,15 +200,20 @@ class TestLeaveAllocation(unittest.TestCase): "leave_approver": 'test@example.com' }) leave_application.submit() - leave_allocation.new_leaves_allocated = 8 - leave_allocation.total_leaves_allocated = 8 + leave_application.reload() + + # allocate less leaves than the ones which are already approved + leave_allocation.new_leaves_allocated = leave_application.total_leave_days - 1 + leave_allocation.total_leaves_allocated = leave_application.total_leave_days - 1 self.assertRaises(frappe.ValidationError, leave_allocation.submit) def create_leave_allocation(**args): args = frappe._dict(args) - employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0]) - leave_allocation = frappe.get_doc({ + emp_id = make_employee("test_emp_leave_allocation@salary.com") + employee = frappe.get_doc("Employee", emp_id) + + return frappe.get_doc({ "doctype": "Leave Allocation", "__islocal": 1, "employee": args.employee or employee.name, @@ -227,6 +224,5 @@ def create_leave_allocation(**args): "carry_forward": args.carry_forward or 0, "to_date": args.to_date or add_months(nowdate(), 12) }) - return leave_allocation test_dependencies = ["Employee", "Leave Type"] From 7987a4650947a2ac551b9b76fdca6bb5b4836295 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 23 Dec 2021 21:13:22 +0530 Subject: [PATCH 09/18] chore: add running stock value difference in invariant report (#29012) [skip ci] --- .../stock_ledger_invariant_check.js | 3 ++- .../stock_ledger_invariant_check.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js index c484516a16..31f389f236 100644 --- a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js +++ b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js @@ -8,7 +8,8 @@ const DIFFERNCE_FIELD_NAMES = [ "fifo_value_diff", "fifo_valuation_diff", "valuation_diff", - "fifo_difference_diff" + "fifo_difference_diff", + "diff_value_diff" ]; frappe.query_reports["Stock Ledger Invariant Check"] = { diff --git a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py index ca47a1ec5b..48753b0edd 100644 --- a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py +++ b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py @@ -50,6 +50,7 @@ def get_stock_ledger_entries(filters): def add_invariant_check_fields(sles): balance_qty = 0.0 + balance_stock_value = 0.0 for idx, sle in enumerate(sles): queue = json.loads(sle.stock_queue) @@ -60,6 +61,7 @@ def add_invariant_check_fields(sles): fifo_value += qty * rate balance_qty += sle.actual_qty + balance_stock_value += sle.stock_value_difference if sle.voucher_type == "Stock Reconciliation" and not sle.batch_no: balance_qty = sle.qty_after_transaction @@ -70,6 +72,7 @@ def add_invariant_check_fields(sles): sle.stock_value / sle.qty_after_transaction if sle.qty_after_transaction else None ) sle.expected_qty_after_transaction = balance_qty + sle.stock_value_from_diff = balance_stock_value # set difference fields sle.difference_in_qty = sle.qty_after_transaction - sle.expected_qty_after_transaction @@ -81,6 +84,7 @@ def add_invariant_check_fields(sles): sle.valuation_diff = ( sle.valuation_rate - sle.balance_value_by_qty if sle.balance_value_by_qty else None ) + sle.diff_value_diff = sle.stock_value_from_diff - sle.stock_value if idx > 0: sle.fifo_stock_diff = sle.fifo_stock_value - sles[idx - 1].fifo_stock_value @@ -191,12 +195,21 @@ def get_columns(): "fieldtype": "Float", "label": "D - E", }, - { "fieldname": "stock_value_difference", "fieldtype": "Float", "label": "(F) Stock Value Difference", }, + { + "fieldname": "stock_value_from_diff", + "fieldtype": "Float", + "label": "Balance Stock Value using (F)", + }, + { + "fieldname": "diff_value_diff", + "fieldtype": "Float", + "label": "K - D", + }, { "fieldname": "fifo_stock_diff", "fieldtype": "Float", From 6eeea0a77a0fbb9d014831250c7f1e917b769903 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 24 Dec 2021 17:20:23 +0530 Subject: [PATCH 10/18] fix: ignore links while setting default notification templates in Settings (#29019) --- .../patches/v11_0/add_default_dispatch_notification_template.py | 1 + .../v13_0/add_default_interview_notification_templates.py | 1 + .../add_default_exit_questionnaire_notification_template.py | 1 + 3 files changed, 3 insertions(+) diff --git a/erpnext/patches/v11_0/add_default_dispatch_notification_template.py b/erpnext/patches/v11_0/add_default_dispatch_notification_template.py index 08006ad01b..c7771a5f19 100644 --- a/erpnext/patches/v11_0/add_default_dispatch_notification_template.py +++ b/erpnext/patches/v11_0/add_default_dispatch_notification_template.py @@ -22,4 +22,5 @@ def execute(): delivery_settings = frappe.get_doc("Delivery Settings") delivery_settings.dispatch_template = _("Dispatch Notification") + delivery_settings.flags.ignore_links = True delivery_settings.save() diff --git a/erpnext/patches/v13_0/add_default_interview_notification_templates.py b/erpnext/patches/v13_0/add_default_interview_notification_templates.py index 0208ca914e..6b5de52e2b 100644 --- a/erpnext/patches/v13_0/add_default_interview_notification_templates.py +++ b/erpnext/patches/v13_0/add_default_interview_notification_templates.py @@ -32,4 +32,5 @@ def execute(): hr_settings = frappe.get_doc('HR Settings') hr_settings.interview_reminder_template = _('Interview Reminder') hr_settings.feedback_reminder_notification_template = _('Interview Feedback Reminder') + hr_settings.flags.ignore_links = True hr_settings.save() diff --git a/erpnext/patches/v14_0/add_default_exit_questionnaire_notification_template.py b/erpnext/patches/v14_0/add_default_exit_questionnaire_notification_template.py index 8b1752b2c7..120182a80e 100644 --- a/erpnext/patches/v14_0/add_default_exit_questionnaire_notification_template.py +++ b/erpnext/patches/v14_0/add_default_exit_questionnaire_notification_template.py @@ -24,4 +24,5 @@ def execute(): hr_settings = frappe.get_doc("HR Settings") hr_settings.exit_questionnaire_notification_template = template + hr_settings.flags.ignore_links = True hr_settings.save() From 9c4455f77c133b142d40397141240b86e836bd70 Mon Sep 17 00:00:00 2001 From: Shariq Ansari <30859809+shariquerik@users.noreply.github.com> Date: Fri, 24 Dec 2021 18:52:35 +0530 Subject: [PATCH 11/18] fix: Removed ERPNext Integration Settings Workspace (#29023) --- .../erpnext_integrations_settings.json | 78 ------------------- erpnext/patches.txt | 3 +- 2 files changed, 2 insertions(+), 79 deletions(-) delete mode 100644 erpnext/erpnext_integrations/workspace/erpnext_integrations_settings/erpnext_integrations_settings.json diff --git a/erpnext/erpnext_integrations/workspace/erpnext_integrations_settings/erpnext_integrations_settings.json b/erpnext/erpnext_integrations/workspace/erpnext_integrations_settings/erpnext_integrations_settings.json deleted file mode 100644 index 5efafd67fe..0000000000 --- a/erpnext/erpnext_integrations/workspace/erpnext_integrations_settings/erpnext_integrations_settings.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "charts": [], - "content": "[{\"type\": \"header\", \"data\": {\"text\": \"Reports & Masters\", \"level\": 4, \"col\": 12}}, {\"type\": \"card\", \"data\": {\"card_name\": \"Integrations Settings\", \"col\": 4}}]", - "creation": "2020-07-31 10:38:54.021237", - "docstatus": 0, - "doctype": "Workspace", - "for_user": "", - "hide_custom": 0, - "icon": "setting", - "idx": 0, - "label": "ERPNext Integrations Settings", - "links": [ - { - "hidden": 0, - "is_query_report": 0, - "label": "Integrations Settings", - "link_count": 0, - "onboard": 0, - "type": "Card Break" - }, - { - "dependencies": "", - "hidden": 0, - "is_query_report": 0, - "label": "Woocommerce Settings", - "link_count": 0, - "link_to": "Woocommerce Settings", - "link_type": "DocType", - "onboard": 0, - "type": "Link" - }, - { - "dependencies": "", - "hidden": 0, - "is_query_report": 0, - "label": "Amazon MWS Settings", - "link_count": 0, - "link_to": "Amazon MWS Settings", - "link_type": "DocType", - "onboard": 0, - "type": "Link" - }, - { - "dependencies": "", - "hidden": 0, - "is_query_report": 0, - "label": "Plaid Settings", - "link_count": 0, - "link_to": "Plaid Settings", - "link_type": "DocType", - "onboard": 0, - "type": "Link" - }, - { - "dependencies": "", - "hidden": 0, - "is_query_report": 0, - "label": "Exotel Settings", - "link_count": 0, - "link_to": "Exotel Settings", - "link_type": "DocType", - "onboard": 0, - "type": "Link" - } - ], - "modified": "2021-11-23 04:30:33.106991", - "modified_by": "Administrator", - "module": "ERPNext Integrations", - "name": "ERPNext Integrations Settings", - "owner": "Administrator", - "parent_page": "", - "public": 1, - "restrict_to_domain": "", - "roles": [], - "sequence_id": 11, - "shortcuts": [], - "title": "ERPNext Integrations Settings" -} \ No newline at end of file diff --git a/erpnext/patches.txt b/erpnext/patches.txt index d9cedab52a..c75606afaa 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -317,4 +317,5 @@ erpnext.patches.v14_0.rename_ongoing_status_in_sla_documents erpnext.patches.v14_0.migrate_crm_settings erpnext.patches.v13_0.rename_ksa_qr_field erpnext.patches.v13_0.disable_ksa_print_format_for_others # 16-12-2021 -erpnext.patches.v14_0.add_default_exit_questionnaire_notification_template \ No newline at end of file +erpnext.patches.v14_0.add_default_exit_questionnaire_notification_template +execute:frappe.delete_doc_if_exists('Workspace', 'ERPNext Integrations Settings') \ No newline at end of file From cfb6b26e4776d164b4c9786bfe3cf517abe1432e Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Fri, 24 Dec 2021 19:13:28 +0530 Subject: [PATCH 12/18] fix: contact duplication on converting lead to customer (#29001) * fix: contact duplication on converting lead to customer * fix: added test case --- erpnext/crm/doctype/lead/test_lead.py | 11 ++++++++++ erpnext/selling/doctype/customer/customer.py | 23 ++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/erpnext/crm/doctype/lead/test_lead.py b/erpnext/crm/doctype/lead/test_lead.py index 56bfc8f145..3882974022 100644 --- a/erpnext/crm/doctype/lead/test_lead.py +++ b/erpnext/crm/doctype/lead/test_lead.py @@ -23,6 +23,17 @@ class TestLead(unittest.TestCase): customer.customer_group = "_Test Customer Group" customer.insert() + #check whether lead contact is carried forward to the customer. + contact = frappe.db.get_value('Dynamic Link', { + "parenttype": "Contact", + "link_doctype": "Lead", + "link_name": customer.lead_name, + }, "parent") + + if contact: + contact_doc = frappe.get_doc("Contact", contact) + self.assertEqual(contact_doc.has_link(customer.doctype, customer.name), True) + def test_make_customer_from_organization(self): from erpnext.crm.doctype.lead.lead import make_customer diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 0c8c53aabe..b7f74df105 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -196,20 +196,19 @@ class Customer(TransactionBase): if not lead.lead_name: frappe.throw(_("Please mention the Lead Name in Lead {0}").format(self.lead_name)) - if lead.company_name: - contact_names = frappe.get_all('Dynamic Link', filters={ - "parenttype":"Contact", - "link_doctype":"Lead", - "link_name":self.lead_name - }, fields=["parent as name"]) + contact_names = frappe.get_all('Dynamic Link', filters={ + "parenttype":"Contact", + "link_doctype":"Lead", + "link_name":self.lead_name + }, fields=["parent as name"]) - for contact_name in contact_names: - contact = frappe.get_doc('Contact', contact_name.get('name')) - if not contact.has_link('Customer', self.name): - contact.append('links', dict(link_doctype='Customer', link_name=self.name)) - contact.save(ignore_permissions=self.flags.ignore_permissions) + for contact_name in contact_names: + contact = frappe.get_doc('Contact', contact_name.get('name')) + if not contact.has_link('Customer', self.name): + contact.append('links', dict(link_doctype='Customer', link_name=self.name)) + contact.save(ignore_permissions=self.flags.ignore_permissions) - else: + if not contact_names: lead.lead_name = lead.lead_name.lstrip().split(" ") lead.first_name = lead.lead_name[0] lead.last_name = " ".join(lead.lead_name[1:]) From ab09dc545e77e93a918cea6fd93ab3c730739d9b Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 20 Dec 2021 12:16:14 +0530 Subject: [PATCH 13/18] fix(UX): Optimize rate updation of changing price list (cherry picked from commit 6087d5a6038d6e636ce1ba006ebd59e820b3cd8e) --- erpnext/public/js/controllers/transaction.js | 7 +++++-- erpnext/stock/get_item_details.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 773d53c552..2019bc0ae6 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1586,17 +1586,19 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe var items_rule_dict = {}; for(var i=0, l=children.length; i Date: Mon, 20 Dec 2021 13:26:16 +0530 Subject: [PATCH 14/18] fix: Linting issues (cherry picked from commit 0980c2f9816b3e4a11b5410b5997a72b1cad28fd) --- erpnext/public/js/controllers/transaction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 2019bc0ae6..92a6113e0f 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1587,7 +1587,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe for(var i=0, l=children.length; i Date: Wed, 22 Dec 2021 11:26:19 +0530 Subject: [PATCH 15/18] fix: Recalculate taxes irrespective of price list rate changed or not (cherry picked from commit 233f79bf960381b1c2bd753d783afd3020b377e0) # Conflicts: # erpnext/public/js/controllers/transaction.js --- erpnext/public/js/controllers/transaction.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 92a6113e0f..d04802b2fb 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1582,7 +1582,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe _set_values_for_item_list(children) { var me = this; - var price_list_rate_changed = false; var items_rule_dict = {}; for(var i=0, l=children.length; i>>>>>> 233f79bf96 (fix: Recalculate taxes irrespective of price list rate changed or not) apply_rule_on_other_items(args) { const me = this; From 2d0208ba1fc6808cad18de509ebb2e2cfa5cd152 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 22 Dec 2021 12:01:39 +0530 Subject: [PATCH 16/18] fix: Add round floats for price list rate (cherry picked from commit b60fbf5ba95350e79463f922b0e8dce518780383) --- erpnext/public/js/controllers/transaction.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index d04802b2fb..794e912eda 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -680,7 +680,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe var item = frappe.get_doc(cdt, cdn); frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]); - // check if child doctype is Sales Order Item/Qutation Item and calculate the rate + // check if child doctype is Sales Order Item/Quotation Item and calculate the rate if (in_list(["Quotation Item", "Sales Order Item", "Delivery Note Item", "Sales Invoice Item", "POS Invoice Item", "Purchase Invoice Item", "Purchase Order Item", "Purchase Receipt Item"]), cdt) this.apply_pricing_rule_on_item(item); else @@ -1601,6 +1601,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } } + frappe.model.round_floats_in(item_row, ["price_list_rate", "discount_percentage"]); + // if pricing rule set as blank from an existing value, apply price_list if(!me.frm.doc.ignore_pricing_rule && existing_pricing_rule && !d.pricing_rules) { me.apply_price_list(frappe.get_doc(d.doctype, d.name)); From 6eb3d6a814a1a86a6d606946779278488c0a8b68 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Sat, 25 Dec 2021 09:04:34 +0530 Subject: [PATCH 17/18] fix: Conflicts --- erpnext/public/js/controllers/transaction.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 794e912eda..3791741663 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1622,13 +1622,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe me.frm.refresh_field('items'); me.apply_rule_on_other_items(items_rule_dict); -<<<<<<< HEAD - if(!price_list_rate_changed) me.calculate_taxes_and_totals(); - } -======= me.calculate_taxes_and_totals(); - }, ->>>>>>> 233f79bf96 (fix: Recalculate taxes irrespective of price list rate changed or not) + } apply_rule_on_other_items(args) { const me = this; From 52397c97714fd5fd5ef75b32908006fc7c9af1e0 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Sun, 26 Dec 2021 02:15:57 +0100 Subject: [PATCH 18/18] fix: avoid `"string" in None` condition --- erpnext/patches/v12_0/create_itc_reversal_custom_fields.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/patches/v12_0/create_itc_reversal_custom_fields.py b/erpnext/patches/v12_0/create_itc_reversal_custom_fields.py index d157aad8f2..d4fbded5a3 100644 --- a/erpnext/patches/v12_0/create_itc_reversal_custom_fields.py +++ b/erpnext/patches/v12_0/create_itc_reversal_custom_fields.py @@ -97,6 +97,8 @@ def execute(): 'itc_central_tax': 0, 'itc_cess_amount': 0 }) + if not gst_accounts: + continue if d.account_head in gst_accounts.get('igst_account'): amount_map[d.parent]['itc_integrated_tax'] += d.amount