From 835c85a0877b03a3c73f2a11a505091f357621c5 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 28 Nov 2023 15:42:30 +0530 Subject: [PATCH 1/8] feat: add currency column for allocated entries --- .../payment_reconciliation_allocation.json | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json index 6a21692c6ac..9eed7b1c82a 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json +++ b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json @@ -20,7 +20,8 @@ "section_break_5", "difference_amount", "column_break_7", - "difference_account" + "difference_account", + "currency" ], "fields": [ { @@ -37,7 +38,7 @@ "fieldtype": "Currency", "in_list_view": 1, "label": "Allocated Amount", - "options": "Currency", + "options": "currency", "reqd": 1 }, { @@ -64,7 +65,7 @@ "fieldtype": "Currency", "in_list_view": 1, "label": "Difference Amount", - "options": "Currency", + "options": "currency", "read_only": 1 }, { @@ -112,7 +113,7 @@ "fieldtype": "Currency", "hidden": 1, "label": "Unreconciled Amount", - "options": "Currency", + "options": "currency", "read_only": 1 }, { @@ -120,7 +121,7 @@ "fieldtype": "Currency", "hidden": 1, "label": "Amount", - "options": "Currency", + "options": "currency", "read_only": 1 }, { @@ -129,11 +130,17 @@ "hidden": 1, "label": "Reference Row", "read_only": 1 + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "options": "Currency" } ], "istable": 1, "links": [], - "modified": "2021-10-06 11:48:59.616562", + "modified": "2023-11-28 15:37:42.336096", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Allocation", From 3dfc1450a1551640c6105040e8425b8e3c933b63 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 28 Nov 2023 15:43:36 +0530 Subject: [PATCH 2/8] fix: update voucher currency for allocated entry --- .../doctype/payment_reconciliation/payment_reconciliation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 1e99e4d791c..d7274d7d317 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -295,6 +295,7 @@ class PaymentReconciliation(Document): "amount": pay.get("amount"), "allocated_amount": allocated_amount, "difference_amount": pay.get("difference_amount"), + "currency": inv.get("currency"), } ) From b7944a7c075f50e652860a2c89bda8e639b64c8d Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 28 Nov 2023 15:51:33 +0530 Subject: [PATCH 3/8] chore: hide currency column --- .../payment_reconciliation_allocation.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json index 9eed7b1c82a..fec8a6d4c7d 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json +++ b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json @@ -134,13 +134,14 @@ { "fieldname": "currency", "fieldtype": "Link", + "hidden": 1, "label": "Currency", "options": "Currency" } ], "istable": 1, "links": [], - "modified": "2023-11-28 15:37:42.336096", + "modified": "2023-11-28 15:50:42.336096", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Allocation", From 6f44a1630f56a940dda7ff69cf9e9d06040ae813 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Tue, 28 Nov 2023 16:31:40 +0530 Subject: [PATCH 4/8] fix: show difference amount in default currency --- .../payment_reconciliation_allocation.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json index fec8a6d4c7d..7b94eb0ea4a 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json +++ b/erpnext/accounts/doctype/payment_reconciliation_allocation/payment_reconciliation_allocation.json @@ -65,7 +65,7 @@ "fieldtype": "Currency", "in_list_view": 1, "label": "Difference Amount", - "options": "currency", + "options": "Currency", "read_only": 1 }, { @@ -141,7 +141,7 @@ ], "istable": 1, "links": [], - "modified": "2023-11-28 15:50:42.336096", + "modified": "2023-11-28 16:30:43.344612", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Allocation", From 2c4cee025bcc08bc57f7974be8f0b0559a364607 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:36:31 +0100 Subject: [PATCH 5/8] ci: pin semgrep to old version (#38426) * ci: pin semgrep to old version current version has problem with PRs originating from fork * ci: unpin semgrep --------- Co-authored-by: Ankush Menat Co-authored-by: Ankush Menat --- .github/workflows/linters.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index ebb88c9edac..751b46f4b35 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: '3.10' - name: Install and Run Pre-commit uses: pre-commit/action@v2.0.3 @@ -22,10 +22,8 @@ jobs: - name: Download Semgrep rules run: git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules - - uses: returntocorp/semgrep-action@v1 - env: - SEMGREP_TIMEOUT: 120 - with: - config: >- - r/python.lang.correctness - ./frappe-semgrep-rules/rules + - name: Download semgrep + run: pip install semgrep + + - name: Run Semgrep rules + run: semgrep ci --config ./frappe-semgrep-rules/rules --config r/python.lang.correctness From bd371e697cdef11293dc25eca40b5553e3e872a1 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:33:35 +0530 Subject: [PATCH 6/8] fix: make create button translatable (backport #38165) (#38412) fix: make create button translatable (#38165) * fix: make all create buttons translatable * style: use double quotes --------- Co-authored-by: PatrickDenis-stack <77415730+PatrickDenis-stack@users.noreply.github.com> Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> (cherry picked from commit 8e4b591ea2ad420a7c861a06414d3bee6e6ee042) Co-authored-by: Patrick Eissler <77415730+PatrickDEissler@users.noreply.github.com> --- erpnext/public/js/communication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/communication.js b/erpnext/public/js/communication.js index 7ce8b0913c3..f205d889658 100644 --- a/erpnext/public/js/communication.js +++ b/erpnext/public/js/communication.js @@ -13,7 +13,7 @@ frappe.ui.form.on("Communication", { frappe.confirm(__(confirm_msg, [__("Issue")]), () => { frm.trigger('make_issue_from_communication'); }) - }, "Create"); + }, __("Create")); } if(!in_list(["Lead", "Opportunity"], frm.doc.reference_doctype)) { From 77e01ebacfa91a03d9ec9ec8de9e153633d7e9ad Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:32:57 +0530 Subject: [PATCH 7/8] feat: `Company` filter in `Stock Ledger Variance` report (backport #38553) (#38575) feat: `Company` filter in `Stock Ledger Variance` report (cherry picked from commit fb3421fccee518799a36a27d79bf4f6632736f81) Co-authored-by: s-aga-r --- .../stock_ledger_variance.js | 16 ++++++++++++---- .../stock_ledger_variance.py | 7 ++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js index b1e4a74571e..bf3a397feef 100644 --- a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js +++ b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.js @@ -13,10 +13,18 @@ const DIFFERENCE_FIELD_NAMES = [ frappe.query_reports["Stock Ledger Variance"] = { "filters": [ + { + "fieldname": "company", + "label": __("Company"), + "fieldtype": "Link", + "options": "Company", + "reqd": 1, + "default": frappe.defaults.get_user_default("Company") + }, { "fieldname": "item_code", "fieldtype": "Link", - "label": "Item", + "label": __("Item"), "options": "Item", get_query: function() { return { @@ -27,7 +35,7 @@ frappe.query_reports["Stock Ledger Variance"] = { { "fieldname": "warehouse", "fieldtype": "Link", - "label": "Warehouse", + "label": __("Warehouse"), "options": "Warehouse", get_query: function() { return { @@ -38,7 +46,7 @@ frappe.query_reports["Stock Ledger Variance"] = { { "fieldname": "difference_in", "fieldtype": "Select", - "label": "Difference In", + "label": __("Difference In"), "options": [ "", "Qty", @@ -49,7 +57,7 @@ frappe.query_reports["Stock Ledger Variance"] = { { "fieldname": "include_disabled", "fieldtype": "Check", - "label": "Include Disabled", + "label": __("Include Disabled"), } ], diff --git a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py index 732f108ac41..acbbe9039ac 100644 --- a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py +++ b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py @@ -230,7 +230,12 @@ def get_item_warehouse_combinations(filters: dict = None) -> dict: bin.item_code, bin.warehouse, ) - .where((item.is_stock_item == 1) & (item.has_serial_no == 0) & (warehouse.is_group == 0)) + .where( + (item.is_stock_item == 1) + & (item.has_serial_no == 0) + & (warehouse.is_group == 0) + & (warehouse.company == filters.company) + ) ) if filters.item_code: From 1b78dd17c97c0565d20857fff4af7a201ea67959 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 18:14:19 +0530 Subject: [PATCH 8/8] fix: consider the `Valuation Method` while picking incorrect SLE (backport #38592) (#38596) * fix: incorrect SLE for `Moving Average` valuation method (cherry picked from commit 8beec586709dcd716de4fb46476218baed2ec972) * feat: add `Valuation Method` column in `Stock Ledger Variance` report (cherry picked from commit 16c297c2ecbc9a174e90597756cf46170bbd7c4a) --------- Co-authored-by: s-aga-r --- .../stock_ledger_variance.py | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py index acbbe9039ac..189a90aa471 100644 --- a/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py +++ b/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py @@ -55,6 +55,11 @@ def get_columns(): "label": _("Warehouse"), "options": "Warehouse", }, + { + "fieldname": "valuation_method", + "fieldtype": "Data", + "label": _("Valuation Method"), + }, { "fieldname": "voucher_type", "fieldtype": "Link", @@ -194,6 +199,7 @@ def get_columns(): def get_data(filters=None): filters = frappe._dict(filters or {}) item_warehouse_map = get_item_warehouse_combinations(filters) + valuation_method = frappe.db.get_single_value("Stock Settings", "valuation_method") data = [] if item_warehouse_map: @@ -206,8 +212,17 @@ def get_data(filters=None): continue for row in report_data: - if has_difference(row, precision, filters.difference_in): - data.append(add_item_warehouse_details(row, item_warehouse)) + if has_difference( + row, precision, filters.difference_in, item_warehouse.valuation_method or valuation_method + ): + row.update( + { + "item_code": item_warehouse.item_code, + "warehouse": item_warehouse.warehouse, + "valuation_method": item_warehouse.valuation_method or valuation_method, + } + ) + data.append(row) break return data @@ -229,6 +244,7 @@ def get_item_warehouse_combinations(filters: dict = None) -> dict: .select( bin.item_code, bin.warehouse, + item.valuation_method, ) .where( (item.is_stock_item == 1) @@ -248,37 +264,27 @@ def get_item_warehouse_combinations(filters: dict = None) -> dict: return query.run(as_dict=1) -def has_difference(row, precision, difference_in): - has_qty_difference = flt(row.difference_in_qty, precision) or flt(row.fifo_qty_diff, precision) - has_value_difference = ( - flt(row.diff_value_diff, precision) - or flt(row.fifo_value_diff, precision) - or flt(row.fifo_difference_diff, precision) - ) - has_valuation_difference = flt(row.valuation_diff, precision) or flt( - row.fifo_valuation_diff, precision - ) +def has_difference(row, precision, difference_in, valuation_method): + if valuation_method == "Moving Average": + qty_diff = flt(row.difference_in_qty, precision) + value_diff = flt(row.diff_value_diff, precision) + valuation_diff = flt(row.valuation_diff, precision) + else: + qty_diff = flt(row.difference_in_qty, precision) or flt(row.fifo_qty_diff, precision) + value_diff = ( + flt(row.diff_value_diff, precision) + or flt(row.fifo_value_diff, precision) + or flt(row.fifo_difference_diff, precision) + ) + valuation_diff = flt(row.valuation_diff, precision) or flt(row.fifo_valuation_diff, precision) - if difference_in == "Qty" and has_qty_difference: + if difference_in == "Qty" and qty_diff: return True - elif difference_in == "Value" and has_value_difference: + elif difference_in == "Value" and value_diff: return True - elif difference_in == "Valuation" and has_valuation_difference: + elif difference_in == "Valuation" and valuation_diff: return True elif difference_in not in ["Qty", "Value", "Valuation"] and ( - has_qty_difference or has_value_difference or has_valuation_difference + qty_diff or value_diff or valuation_diff ): return True - - return False - - -def add_item_warehouse_details(row, item_warehouse): - row.update( - { - "item_code": item_warehouse.item_code, - "warehouse": item_warehouse.warehouse, - } - ) - - return row