From bd9e0e8b5a87ecb3cefa0392456c2aac15625d62 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 21 Jul 2023 16:15:31 +0530 Subject: [PATCH 01/19] chore: release version 14 (#36233) * fix: broken overallocation validation in payment entry In a multi term payment schedule, overallocation logic broke. Fixing it using individual term outstanding amount in references. this should work for the simple, one term payment schedule as well (cherry picked from commit f8d4b19cb987b267dbd18d6ef1ab52426d7f51d1) * refactor: payment term outstanding in party account currency (cherry picked from commit ee83f94bb0ad22e487d63e41cb878ffc27f974fc) * fix: Default fiscal year in accounting, buying and sellingcharts (cherry picked from commit 3759a41b8358302ff8d33857a0461cc2da3d06d8) * fix: Trial Balance report considering cancelled entries (cherry picked from commit fd58bbff6bbed96367544f0ab0be9d992fafef56) * fix: made item or warehouse filter mandatory (backport #36208) (#36215) fix: made item or warehouse filter mandatory (cherry picked from commit 16498627cec1e416fcc9a911b11ca522268eb622) Co-authored-by: Rohit Waghchaure * fix: Ambiguous column error while submitting stock entry (backport #36209) (#36222) fix: Ambiguous column error while submitting stock entry Stock Entry Type=Manufacture request.js:457 Traceback (most recent call last): File "apps/frappe/frappe/app.py", line 94, in application response = frappe.api.handle() File "apps/frappe/frappe/api.py", line 54, in handle return frappe.handler.handle() File "apps/frappe/frappe/handler.py", line 47, in handle data = execute_cmd(cmd) File "apps/frappe/frappe/handler.py", line 85, in execute_cmd return frappe.call(method, **frappe.form_dict) File "apps/frappe/frappe/__init__.py", line 1610, in call return fn(*args, **newargs) File "apps/frappe/frappe/desk/form/save.py", line 28, in savedocs doc.save() File "apps/frappe/frappe/model/document.py", line 305, in save return self._save(*args, **kwargs) File "apps/frappe/frappe/model/document.py", line 327, in _save return self.insert() File "apps/frappe/frappe/model/document.py", line 259, in insert self.run_before_save_methods() File "apps/frappe/frappe/model/document.py", line 1045, in run_before_save_methods self.run_method("validate") File "apps/frappe/frappe/model/document.py", line 914, in run_method out = Document.hook(fn)(self, *args, **kwargs) File "apps/frappe/frappe/model/document.py", line 1264, in composer return composed(self, method, *args, **kwargs) File "apps/frappe/frappe/model/document.py", line 1246, in runner add_to_return_value(self, fn(self, *args, **kwargs)) File "apps/frappe/frappe/model/document.py", line 911, in fn return method_object(*args, **kwargs) File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 122, in validate self.validate_qty() File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 433, in validate_qty transferred_materials = frappe.db.sql( File "apps/frappe/frappe/database/database.py", line 220, in sql self._cursor.execute(query, values) File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute result = self._query(query) File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query conn.query(q) File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result result.read() File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read first_packet = self.connection._read_packet() File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet packet.raise_for_error() File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error err.raise_mysql_exception(self._data) File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception raise errorclass(errno, errval) pymysql.err.OperationalError: (1052, "Column 'qty' in field list is ambiguous") (cherry picked from commit c21fd45883d3b2a6d2ba32c5f91d5151c8df0650) Co-authored-by: MohsinAli * fix: Ignore permissions while submitting account closing balance record (#35536) (cherry picked from commit f11d9b019ddf8238c9e53369262a89fb4041e0ab) * fix: FY in naming series variable for orders (cherry picked from commit 7a7d32db817ab6619168ad3582abe23c197d6419) --------- Co-authored-by: ruthra kumar Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Rohit Waghchaure Co-authored-by: MohsinAli Co-authored-by: Nabin Hait --- .../account_closing_balance/account_closing_balance.py | 1 + erpnext/accounts/utils.py | 3 ++- erpnext/stock/doctype/stock_entry/stock_entry.py | 2 +- .../batch_wise_balance_history.py | 7 +++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.py b/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.py index ea67051fb49..e75af7047f1 100644 --- a/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.py +++ b/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.py @@ -36,6 +36,7 @@ def make_closing_entries(closing_entries, voucher_name, company, closing_date): "closing_date": closing_date, } ) + cle.flags.ignore_permissions = True cle.submit() diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 84c71b376ef..aa861a48eff 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1108,7 +1108,8 @@ def get_autoname_with_number(number_value, doc_title, company): def parse_naming_series_variable(doc, variable): if variable == "FY": - return get_fiscal_year(date=doc.get("posting_date"), company=doc.get("company"))[0] + date = doc.get("posting_date") or doc.get("transaction_date") or getdate() + return get_fiscal_year(date=date, company=doc.get("company"))[0] @frappe.whitelist() diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index ae9adc826c6..b93ffc437cb 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -433,7 +433,7 @@ class StockEntry(StockController): transferred_materials = frappe.db.sql( """ select - sum(qty) as qty + sum(sed.qty) as qty from `tabStock Entry` se,`tabStock Entry Detail` sed where se.name = sed.parent and se.docstatus=1 and diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py index 0d57938e31f..0f319554763 100644 --- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py +++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py @@ -9,11 +9,18 @@ from pypika import functions as fn from erpnext.stock.doctype.warehouse.warehouse import apply_warehouse_filter +SLE_COUNT_LIMIT = 10_000 + def execute(filters=None): if not filters: filters = {} + sle_count = frappe.db.count("Stock Ledger Entry", {"is_cancelled": 0}) + + if sle_count > SLE_COUNT_LIMIT and not filters.get("item_code") and not filters.get("warehouse"): + frappe.throw(_("Please select either the Item or Warehouse filter to generate the report.")) + if filters.from_date > filters.to_date: frappe.throw(_("From Date must be before To Date")) From cf93714a7cce465d241bf4e713ee7492c5c01bfa Mon Sep 17 00:00:00 2001 From: gouravengineer <63018500+gouravengineer@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:23:36 +0530 Subject: [PATCH 02/19] fix:show invoices name instead of object address comma_and function in expecting a list but it gets a tuple so it is returning a object instead of a string --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index f29be181e7b..957403bf895 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -441,7 +441,7 @@ class PaymentEntry(AccountsController): _( "References {0} of type {1} had no outstanding amount left before submitting the Payment Entry. Now they have a negative outstanding amount." ).format( - frappe.bold(comma_and((d.reference_name for d in references))), + frappe.bold(comma_and([d.reference_name for d in references])), _(reference_doctype), ) + "

" From c4b07900034883de89ecdbc25616a82ff5945e8d Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Wed, 26 Jul 2023 04:10:45 +0000 Subject: [PATCH 03/19] chore(release): Bumped to Version 14.32.0 # [14.32.0](https://github.com/frappe/erpnext/compare/v14.31.3...v14.32.0) (2023-07-26) ### Bug Fixes * added missing option Partially Received in the status dropdown field ([4fa93b0](https://github.com/frappe/erpnext/commit/4fa93b05c62b7f340a94e9e84d9d2e132ea35b99)) * allocation logic on 'Get Outstanding Invoices' btn in PE ([14600fa](https://github.com/frappe/erpnext/commit/14600fa19007e3a00bc2d987f04f2a7b29d99536)) * allow both custodian and location while creating asset ([#36263](https://github.com/frappe/erpnext/issues/36263)) ([2b47f58](https://github.com/frappe/erpnext/commit/2b47f5815e17d0f2733de68b1a8b493d9eeb898d)) * Ambiguous column error while submitting stock entry (backport [#36209](https://github.com/frappe/erpnext/issues/36209)) ([#36222](https://github.com/frappe/erpnext/issues/36222)) ([844ec58](https://github.com/frappe/erpnext/commit/844ec58f6bc69c70606032aa1c02366f19656f79)) * apply discount on item after applying price list ([#36316](https://github.com/frappe/erpnext/issues/36316)) ([cff6e72](https://github.com/frappe/erpnext/commit/cff6e72838b9a118de269f1ed4d6806d1474bbbd)) * apply terms validaton only in Sales/Purchase documents ([8f24292](https://github.com/frappe/erpnext/commit/8f24292155c0112b0f5d2a394e6fbf1e8d138db3)) * broken overallocation validation in payment entry ([e1d31aa](https://github.com/frappe/erpnext/commit/e1d31aad4d8f3d5276022732d5d35f0c77639df4)) * clear accounting dimension value when based on field changes ([1fe6d4e](https://github.com/frappe/erpnext/commit/1fe6d4ef1f9550854bd357bb961cc2c74d81bf44)) * customer filter in process soa ([5938af9](https://github.com/frappe/erpnext/commit/5938af9c3f4752034991188ae2f4eec89f8a8ba5)) * Default fiscal year in accounting, buying and sellingcharts ([8ca3d6b](https://github.com/frappe/erpnext/commit/8ca3d6b7f3554617f8fb5131a7bd570418c1dac5)) * fetch acc dimension fieldname ([542c804](https://github.com/frappe/erpnext/commit/542c80433d55c12109c28333c5e3e56910e6f162)) * FY in naming series variable for orders ([6a6a3ae](https://github.com/frappe/erpnext/commit/6a6a3ae3c3b8c8c52788cdbab0ca265e0621da46)) * group by in fixed asset register ([#36310](https://github.com/frappe/erpnext/issues/36310)) ([6cca18e](https://github.com/frappe/erpnext/commit/6cca18e1689a4ef66a77cc224c3a128b2877a93a)) * Ignore permissions while submitting account closing balance record ([#35536](https://github.com/frappe/erpnext/issues/35536)) ([c2976ef](https://github.com/frappe/erpnext/commit/c2976ef6430385391aa939e18c86984e43c49b1e)) * itemised tax breakup ([6f2e639](https://github.com/frappe/erpnext/commit/6f2e6391822564f771a92a01435ec4923c59a05f)) * made item or warehouse filter mandatory (backport [#36208](https://github.com/frappe/erpnext/issues/36208)) ([#36215](https://github.com/frappe/erpnext/issues/36215)) ([57cf3c2](https://github.com/frappe/erpnext/commit/57cf3c28f896bf619563917d63b6f718ef5c8cbe)) * no default email account causing reposting issue ([026f9f5](https://github.com/frappe/erpnext/commit/026f9f5a69400c2bd2b076dd05a7551b35cfdffb)) * **regional:** set `frappe.flags.company` temporarily, where required ([73e9b38](https://github.com/frappe/erpnext/commit/73e9b38cda37b52f917f9d781a11d3035f0e055e)) * set new purchase_receipt_amount on asset split ([#36272](https://github.com/frappe/erpnext/issues/36272)) ([e867fe7](https://github.com/frappe/erpnext/commit/e867fe77a40a5d2abbc66fcda42d2615bb49bf5f)) * timeout error while cancelling the Purchase Receipt ([0575005](https://github.com/frappe/erpnext/commit/0575005c8708a0c1b0dd2601c04b04a96fa6d613)) * Trial Balance report considering cancelled entries ([ca4f86d](https://github.com/frappe/erpnext/commit/ca4f86d5af917a67042df6d78ec264d2a78e5fef)) ### Features * filter based on accounting dimension in profitability analysis ([ba95df2](https://github.com/frappe/erpnext/commit/ba95df2a74fb3a637a2865882cc267ac9cdbd29f)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 5bc2c53cdc3..9d6576461f9 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.31.3" +__version__ = "14.32.0" def get_default_company(user=None): From a20d78ad9e17318ce9f5c5a1954a91f1a064a7ec Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Wed, 26 Jul 2023 11:04:46 +0530 Subject: [PATCH 04/19] fix: filter by cost center in trial balance (cherry picked from commit 02428b446d959784c546f30c176d6af10e6ed250) --- erpnext/accounts/report/trial_balance/trial_balance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 599c8a312a5..3f0e971be6f 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -253,7 +253,7 @@ def get_opening_balance( lft, rgt = frappe.db.get_value("Cost Center", filters.cost_center, ["lft", "rgt"]) cost_center = frappe.qb.DocType("Cost Center") opening_balance = opening_balance.where( - closing_balance.cost_center.in_( + closing_balance.cost_center.isin( frappe.qb.from_(cost_center) .select("name") .where((cost_center.lft >= lft) & (cost_center.rgt <= rgt)) From d9aa4057d7b27fbce195531c2552b5b8689624b6 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Wed, 26 Jul 2023 06:28:35 +0000 Subject: [PATCH 05/19] chore(release): Bumped to Version 14.32.1 ## [14.32.1](https://github.com/frappe/erpnext/compare/v14.32.0...v14.32.1) (2023-07-26) ### Bug Fixes * filter by cost center in trial balance ([a20d78a](https://github.com/frappe/erpnext/commit/a20d78ad9e17318ce9f5c5a1954a91f1a064a7ec)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 9d6576461f9..67700c52cd4 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.32.0" +__version__ = "14.32.1" def get_default_company(user=None): From 710ec1808604c9288519c2d858aa831bf8117ec8 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Tue, 1 Aug 2023 18:06:33 +0000 Subject: [PATCH 06/19] chore(release): Bumped to Version 14.33.0 # [14.33.0](https://github.com/frappe/erpnext/compare/v14.32.1...v14.33.0) (2023-08-01) ### Bug Fixes * allow fully depreciated existing assets ([#36378](https://github.com/frappe/erpnext/issues/36378)) ([43b85c5](https://github.com/frappe/erpnext/commit/43b85c571101d3d8d5d2f5a9f041ba176ceb243e)) * change fieldtype from Currency to Float for the valuation rate in the stock report ([93bd4c7](https://github.com/frappe/erpnext/commit/93bd4c7ff342a329ffa02d4f22bc642750311428)) * cost center filter for fetching payments ([c9daa85](https://github.com/frappe/erpnext/commit/c9daa85985e998f96a885100b7763c7ea7a5b49f)) * Defined "Open" Status as default (backport [#36421](https://github.com/frappe/erpnext/issues/36421)) ([#36424](https://github.com/frappe/erpnext/issues/36424)) ([33a9477](https://github.com/frappe/erpnext/commit/33a947726ddf61691f7a36e99bcc75318c59b173)) * filter by cost center in trial balance ([02428b4](https://github.com/frappe/erpnext/commit/02428b446d959784c546f30c176d6af10e6ed250)) * german translations ([9c8e2a3](https://github.com/frappe/erpnext/commit/9c8e2a33e9f418ce3569e584ff05a5b1f7d149ec)) * GL Entries should not be splitted based on cost center allocation in PCV ([ade13e6](https://github.com/frappe/erpnext/commit/ade13e6d36a17777d3547c4bf7c279c4be0e9a28)) * group item reorder by (warehouse, material_request_type) (backport [#35818](https://github.com/frappe/erpnext/issues/35818)) ([#36425](https://github.com/frappe/erpnext/issues/36425)) ([516191b](https://github.com/frappe/erpnext/commit/516191bf2ba9cb9f00613dc5c6bf3985caa95a4c)) * Ignore account closing balance for financial statement ([800417e](https://github.com/frappe/erpnext/commit/800417eeed04e29be372f30f08b9acce74adb6fc)) * in payment_entry 'Unallocated Amount' cal is broken ([#36369](https://github.com/frappe/erpnext/issues/36369)) ([cd3b85c](https://github.com/frappe/erpnext/commit/cd3b85ccff227cf18db950d5e2a883d1a681b021)) * incorrect `idx` on JE's after reconciliation ([80eb875](https://github.com/frappe/erpnext/commit/80eb8754dbcfdc27b9ccc03c1a5581df161a2e66)) * incorrect qty set in the serial no picker ([57b19a5](https://github.com/frappe/erpnext/commit/57b19a523efd4f6d22da8e25c6370710b8320579)) * incorrect usage `get_cached_value` on single doctypes ([8f72a68](https://github.com/frappe/erpnext/commit/8f72a6814bd8343a88499c21e677b1751a72af36)) * **Item Group:** allow root deletion ([1a6be5e](https://github.com/frappe/erpnext/commit/1a6be5e19bf5d0aea9e456d18e51b19b43013690)) * job card suggest holiday as start date (backport [#35958](https://github.com/frappe/erpnext/issues/35958)) ([#36423](https://github.com/frappe/erpnext/issues/36423)) ([29ddd26](https://github.com/frappe/erpnext/commit/29ddd26ba107f770c1ec78dc2ff600376ba97bbd)) * Job Card validation fixed when displaying total completed quantity ([7b3bcd3](https://github.com/frappe/erpnext/commit/7b3bcd3bc4933513daa05b2edad667f1bc30abf7)) * multiple issues related to Production Plan (backport [#36377](https://github.com/frappe/erpnext/issues/36377)) ([#36381](https://github.com/frappe/erpnext/issues/36381)) ([a799e1b](https://github.com/frappe/erpnext/commit/a799e1b2179114bbde036454ffbd86015cffcbfd)) * not able to make material request (backport [#36416](https://github.com/frappe/erpnext/issues/36416)) ([#36426](https://github.com/frappe/erpnext/issues/36426)) ([99e7406](https://github.com/frappe/erpnext/commit/99e7406b5b2a27ecd81c1ccb76472ff9c7ca43ff)) * only publish repost progress to doc subscriber (backport [#36400](https://github.com/frappe/erpnext/issues/36400)) ([#36402](https://github.com/frappe/erpnext/issues/36402)) ([32bdb7c](https://github.com/frappe/erpnext/commit/32bdb7cccdf60b49496f778667a8eba03a5d98d4)) * overallocation validation misfire on normal invoices ([#36349](https://github.com/frappe/erpnext/issues/36349)) ([09af485](https://github.com/frappe/erpnext/commit/09af485d549cd8873b81c7e7bb2b2a45b6c21735)) * paid_amount when the group is mode of payment ([50ef358](https://github.com/frappe/erpnext/commit/50ef35845a216a8e13def39e06e95fd821caec55)) * process_owner is not link User (backport [#36420](https://github.com/frappe/erpnext/issues/36420)) ([#36422](https://github.com/frappe/erpnext/issues/36422)) ([289dc36](https://github.com/frappe/erpnext/commit/289dc3669610ee17681aab7cd4436f653fb5bd6a)) * removed "fetch_from" (backport [#36365](https://github.com/frappe/erpnext/issues/36365)) ([#36386](https://github.com/frappe/erpnext/issues/36386)) ([6d051f5](https://github.com/frappe/erpnext/commit/6d051f57322f9404718815341b8a61f7bb37d5cb)) * root type in account map for balance sheet ([#36303](https://github.com/frappe/erpnext/issues/36303)) ([5b56296](https://github.com/frappe/erpnext/commit/5b562961e39de1875028bd50f5fc66e80262c683)) * show invoices name instead of object address ([e802f0c](https://github.com/frappe/erpnext/commit/e802f0c3526c7529039683bd9ff176eab7afcb4f)) * show tds & tcs separately ([619b0fe](https://github.com/frappe/erpnext/commit/619b0feb5f7f5827f5a0ec4e140dbda4da8fe262)) * test with None conditon in PE ([479cab0](https://github.com/frappe/erpnext/commit/479cab0336cd024477367bd8f7e535ce638f7251)) * typo in loyalty program throw message ([#36432](https://github.com/frappe/erpnext/issues/36432)) ([782a4d1](https://github.com/frappe/erpnext/commit/782a4d1fa83cea6f7b277bab0c36ac33d7dbbb8c)) ### Features * add party type filter ([32fea64](https://github.com/frappe/erpnext/commit/32fea643cd6c0cd8759c24d4a51299abe74279d5)) ### Performance Improvements * avoid full table scan in sle count check ([#36428](https://github.com/frappe/erpnext/issues/36428)) ([04f9915](https://github.com/frappe/erpnext/commit/04f99150098c033fe2f27ec92c789bae9209be0e)) * move project status reminder to hourly (backport [#36372](https://github.com/frappe/erpnext/issues/36372)) ([#36373](https://github.com/frappe/erpnext/issues/36373)) ([4ac60cd](https://github.com/frappe/erpnext/commit/4ac60cd73bf953c9eac218e170d3fe09e1790a81)) * use `LEFT JOIN` instead of `NOT EXISTS` (backport [#36221](https://github.com/frappe/erpnext/issues/36221)) ([#36383](https://github.com/frappe/erpnext/issues/36383)) ([26a0b3b](https://github.com/frappe/erpnext/commit/26a0b3b3800b06866c9b6c5de76f3c086cd7f1ca)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 67700c52cd4..0ffff542012 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.32.1" +__version__ = "14.33.0" def get_default_company(user=None): From 4605bc51ae3d0217a7f06d0e908214fb0c31b168 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:59:31 +0530 Subject: [PATCH 07/19] fix: search not working for so in the Production Plan (backport #36459) (#36460) fix: search not working for so in the Production Plan (#36459) fix: search not working for so (cherry picked from commit 8c57d56240d2c35ae09350af5d3598b4773e9ac2) Co-authored-by: rohitwaghchaure --- .../manufacturing/doctype/production_plan/production_plan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index 261aa76b706..8d75c3cb60d 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -1731,7 +1731,7 @@ def sales_order_query( query = query.where(so_table.name.isin(filters.get("sales_orders"))) if txt: - query = query.where(table.item_code.like(f"{txt}%")) + query = query.where(table.parent.like(f"%{txt}%")) if page_len: query = query.limit(page_len) From 75012c17d49856d1a18640f8119df42be8c7c709 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Wed, 2 Aug 2023 07:31:21 +0000 Subject: [PATCH 08/19] chore(release): Bumped to Version 14.33.1 ## [14.33.1](https://github.com/frappe/erpnext/compare/v14.33.0...v14.33.1) (2023-08-02) ### Bug Fixes * search not working for so in the Production Plan (backport [#36459](https://github.com/frappe/erpnext/issues/36459)) ([#36460](https://github.com/frappe/erpnext/issues/36460)) ([4605bc5](https://github.com/frappe/erpnext/commit/4605bc51ae3d0217a7f06d0e908214fb0c31b168)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 0ffff542012..cf8d50b7209 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.33.0" +__version__ = "14.33.1" def get_default_company(user=None): From a09777c406a8c29a2f76926123697ebacb990a5d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:16:55 +0530 Subject: [PATCH 09/19] fix: serial no not able to reject for the internal transfer (backport #36467) (#36475) fix: serial no not able to reject for the internal transfer (#36467) (cherry picked from commit c1819a4b21f09b1775cb20c79a8683c734961ec3) Co-authored-by: rohitwaghchaure --- erpnext/controllers/buying_controller.py | 21 +++++- .../purchase_receipt/test_purchase_receipt.py | 64 +++++++++++++++++++ erpnext/stock/stock_ledger.py | 2 + 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index fa94a4a88d4..1de39967730 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -475,6 +475,10 @@ class BuyingController(SubcontractingController): if d.item_code not in stock_items: continue + rejected_qty = 0.0 + if flt(d.rejected_qty) != 0: + rejected_qty = flt(flt(d.rejected_qty) * flt(d.conversion_factor), d.precision("stock_qty")) + if d.warehouse: pr_qty = flt(flt(d.qty) * flt(d.conversion_factor), d.precision("stock_qty")) @@ -495,6 +499,11 @@ class BuyingController(SubcontractingController): }, ) + if flt(rejected_qty) != 0: + from_warehouse_sle["actual_qty"] += -1 * rejected_qty + if d.rejected_serial_no: + from_warehouse_sle["serial_no"] += "\n" + cstr(d.rejected_serial_no).strip() + sl_entries.append(from_warehouse_sle) sle = self.get_sl_entries( @@ -520,6 +529,7 @@ class BuyingController(SubcontractingController): else 0, } ) + sl_entries.append(sle) if d.from_warehouse and ( @@ -530,23 +540,30 @@ class BuyingController(SubcontractingController): d, {"actual_qty": -1 * pr_qty, "warehouse": d.from_warehouse, "recalculate_rate": 1} ) + if flt(rejected_qty) != 0: + from_warehouse_sle["actual_qty"] += -1 * rejected_qty + if d.rejected_serial_no: + from_warehouse_sle["serial_no"] += "\n" + cstr(d.rejected_serial_no).strip() + sl_entries.append(from_warehouse_sle) - if flt(d.rejected_qty) != 0: + if flt(rejected_qty) != 0: sl_entries.append( self.get_sl_entries( d, { "warehouse": d.rejected_warehouse, - "actual_qty": flt(flt(d.rejected_qty) * flt(d.conversion_factor), d.precision("stock_qty")), + "actual_qty": rejected_qty, "serial_no": cstr(d.rejected_serial_no).strip(), "incoming_rate": 0.0, + "allow_zero_valuation_rate": True, }, ) ) if self.get("is_old_subcontracting_flow"): self.make_sl_entries_for_supplier_warehouse(sl_entries) + self.make_sl_entries( sl_entries, allow_negative_stock=allow_negative_stock, diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 585871cf391..c9433cf5106 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -1258,6 +1258,70 @@ class TestPurchaseReceipt(FrappeTestCase): self.assertEqual(query[0].value, 0) + def test_rejected_qty_for_internal_transfer(self): + from erpnext.stock.doctype.delivery_note.delivery_note import make_inter_company_purchase_receipt + from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note + + prepare_data_for_internal_transfer() + customer = "_Test Internal Customer 2" + company = "_Test Company with perpetual inventory" + + from_warehouse = create_warehouse("_Test Internal From Warehouse New", company=company) + to_warehouse = create_warehouse("_Test Internal To Warehouse New", company=company) + rejected_warehouse = create_warehouse( + "_Test Rejected Internal To Warehouse New", company=company + ) + item_doc = make_item( + "Test Internal Transfer Item DS", + { + "is_purchase_item": 1, + "is_stock_item": 1, + "has_serial_no": 1, + "serial_no_series": "SBNS.#####", + }, + ) + + target_warehouse = create_warehouse("_Test Internal GIT Warehouse New", company=company) + + pr = make_purchase_receipt( + item_code=item_doc.name, + company=company, + posting_date=add_days(today(), -1), + warehouse=from_warehouse, + qty=2, + rate=100, + ) + + dn1 = create_delivery_note( + item_code=item_doc.name, + company=company, + customer=customer, + serial_no=pr.items[0].serial_no, + cost_center="Main - TCP1", + expense_account="Cost of Goods Sold - TCP1", + qty=2, + rate=500, + warehouse=from_warehouse, + target_warehouse=target_warehouse, + ) + + sns = get_serial_nos(dn1.items[0].serial_no) + + self.assertEqual(len(sns), 2) + + pr1 = make_inter_company_purchase_receipt(dn1.name) + pr1.items[0].qty = 1.0 + pr1.items[0].rejected_qty = 1.0 + pr1.items[0].serial_no = sns[0] + pr1.items[0].rejected_serial_no = sns[1] + pr1.items[0].warehouse = to_warehouse + pr1.items[0].rejected_warehouse = rejected_warehouse + pr1.submit() + + rejected_serial_no_wh = frappe.get_cached_value("Serial No", sns[1], "warehouse") + + self.assertEqual(rejected_warehouse, rejected_serial_no_wh) + def test_backdated_transaction_for_internal_transfer_in_trasit_warehouse_for_purchase_receipt( self, ): diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 3a419195353..d52d59a0d18 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -74,6 +74,7 @@ def make_sl_entries(sl_entries, allow_negative_stock=False, via_landed_cost_vouc sle_doc = make_entry(sle, allow_negative_stock, via_landed_cost_voucher) args = sle_doc.as_dict() + args["allow_zero_valuation_rate"] = sle.get("allow_zero_valuation_rate") or False if sle.get("voucher_type") == "Stock Reconciliation": # preserve previous_qty_after_transaction for qty reposting @@ -109,6 +110,7 @@ def repost_current_voucher(args, allow_negative_stock=False, via_landed_cost_vou "sle_id": args.get("name"), "creation": args.get("creation"), }, + allow_zero_rate=args.get("allow_zero_valuation_rate") or False, allow_negative_stock=allow_negative_stock, via_landed_cost_voucher=via_landed_cost_voucher, ) From 2d43ba0c90566be8d6c0b7b5b7520f79f36d1340 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Thu, 3 Aug 2023 07:48:49 +0000 Subject: [PATCH 10/19] chore(release): Bumped to Version 14.33.2 ## [14.33.2](https://github.com/frappe/erpnext/compare/v14.33.1...v14.33.2) (2023-08-03) ### Bug Fixes * serial no not able to reject for the internal transfer (backport [#36467](https://github.com/frappe/erpnext/issues/36467)) ([#36475](https://github.com/frappe/erpnext/issues/36475)) ([a09777c](https://github.com/frappe/erpnext/commit/a09777c406a8c29a2f76926123697ebacb990a5d)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index cf8d50b7209..7b7e2142ee6 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.33.1" +__version__ = "14.33.2" def get_default_company(user=None): From 8770aa59559a7a8235ba1bbe564462606a9e0918 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 00:20:53 +0530 Subject: [PATCH 11/19] chore: don't merge asset capitalization gl entries (backport #36514) (#36516) chore: don't merge asset capitalization gl entries (#36514) (cherry picked from commit 2d7d86039aa5487f841aa63247d2305a1f6d3b0b) Co-authored-by: Anand Baburajan --- .../doctype/asset_capitalization/asset_capitalization.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py index 5625fbb523b..fb480420b97 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py @@ -325,7 +325,7 @@ class AssetCapitalization(StockController): gl_entries = self.get_gl_entries() if gl_entries: - make_gl_entries(gl_entries, from_repost=from_repost) + make_gl_entries(gl_entries, merge_entries=False, from_repost=from_repost) elif self.docstatus == 2: make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name) @@ -355,9 +355,6 @@ class AssetCapitalization(StockController): gl_entries, target_account, target_against, precision ) - if not self.stock_items and not self.service_items and self.are_all_asset_items_non_depreciable: - return [] - self.get_gl_entries_for_target_item(gl_entries, target_against, precision) return gl_entries From 259f3422d5a3ca75a40cc83717847e28fb8aa3e5 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Wed, 9 Aug 2023 03:06:43 +0000 Subject: [PATCH 12/19] chore(release): Bumped to Version 14.34.0 # [14.34.0](https://github.com/frappe/erpnext/compare/v14.33.2...v14.34.0) (2023-08-09) ### Bug Fixes * **accounts:** Translate columns in AP/AR report ([#36503](https://github.com/frappe/erpnext/issues/36503)) ([6739369](https://github.com/frappe/erpnext/commit/67393694de3ee4f37e40c8fe1e3a9963acc0ed8b)) * AP and AR summary ([769d7d7](https://github.com/frappe/erpnext/commit/769d7d7554ff808f0d14b4ed7e276ef44ea15259)) * check root type only when not none ([46bb309](https://github.com/frappe/erpnext/commit/46bb309b8a56edf800cc4ca6b418a3ffc339d99c)) * cross connect delivery note and sales invoice ([#36183](https://github.com/frappe/erpnext/issues/36183)) ([8501a11](https://github.com/frappe/erpnext/commit/8501a1182ae8323d91438da30ddc8d93cf8c2789)) * Debit credit difference while submitting Sales Invoice ([#36523](https://github.com/frappe/erpnext/issues/36523)) ([240d866](https://github.com/frappe/erpnext/commit/240d866ef495e09e4da8a3064c33bcccd319cb27)) * don't allow negative rate (backport [#36027](https://github.com/frappe/erpnext/issues/36027)) ([#36465](https://github.com/frappe/erpnext/issues/36465)) ([caa4f33](https://github.com/frappe/erpnext/commit/caa4f331694937a6768fa3180562e947d6996e7f)) * enqueue submit/cancel action for stock entry having more than 50 line items (backport [#36532](https://github.com/frappe/erpnext/issues/36532)) ([#36536](https://github.com/frappe/erpnext/issues/36536)) ([9c108a8](https://github.com/frappe/erpnext/commit/9c108a8ef70ec6f440cddeccc640c363bcf02196)) * fetch ple for all party types ([674dba8](https://github.com/frappe/erpnext/commit/674dba8cd7ef97103c706a19066872622f965bf2)) * fetch ple with party type employee in AP ([1ca9aca](https://github.com/frappe/erpnext/commit/1ca9aca0d5e2002e1175581df05aa1700bd745ab)) * Fix query for financial statement report ([d1590f2](https://github.com/frappe/erpnext/commit/d1590f266bffc55fa76f799276c1f96fc4cef930)) * get incoming rate instead of BOM rate (backport [#36496](https://github.com/frappe/erpnext/issues/36496)) ([#36506](https://github.com/frappe/erpnext/issues/36506)) ([bdfbccd](https://github.com/frappe/erpnext/commit/bdfbccd38eefd5c7a3385f3e25bcb3fcb442f2ae)) * handle None value in payment_term_outstanding ([b033b3b](https://github.com/frappe/erpnext/commit/b033b3b0d6a7a286e253a24d7432b607eaa14d09)) * Lower deduction certificate for multi-company ([#36491](https://github.com/frappe/erpnext/issues/36491)) ([2216875](https://github.com/frappe/erpnext/commit/2216875bd6f22f695e19e9af6219628760b42a88)) * payment allocation in invoice payment schedule ([#36440](https://github.com/frappe/erpnext/issues/36440)) ([0e87c86](https://github.com/frappe/erpnext/commit/0e87c86aab93255f57d7b691f7c4843c0274ba70)) * search not working for so in the Production Plan ([#36459](https://github.com/frappe/erpnext/issues/36459)) ([8c57d56](https://github.com/frappe/erpnext/commit/8c57d56240d2c35ae09350af5d3598b4773e9ac2)) * serial no not able to reject for the internal transfer ([#36467](https://github.com/frappe/erpnext/issues/36467)) ([c1819a4](https://github.com/frappe/erpnext/commit/c1819a4b21f09b1775cb20c79a8683c734961ec3)) * stock entry decimal issue (backport [#36530](https://github.com/frappe/erpnext/issues/36530)) ([#36533](https://github.com/frappe/erpnext/issues/36533)) ([5b04708](https://github.com/frappe/erpnext/commit/5b047081646ad9131ffbe925d57904597aa454ea)) * stock reconciliation negative stock error (backport [#36544](https://github.com/frappe/erpnext/issues/36544)) ([#36549](https://github.com/frappe/erpnext/issues/36549)) ([00b9df0](https://github.com/frappe/erpnext/commit/00b9df0bc5199d6c08d14cf7dd4f9f4d01ec93c2)) * Tax withholding against order via Payment Entry ([#36493](https://github.com/frappe/erpnext/issues/36493)) ([a234b89](https://github.com/frappe/erpnext/commit/a234b8932e34b7f726c54a720c3199ed1e3bfb64)) * use correct lang separator for frappe (backport [#36519](https://github.com/frappe/erpnext/issues/36519)) ([#36520](https://github.com/frappe/erpnext/issues/36520)) ([f9981d1](https://github.com/frappe/erpnext/commit/f9981d1ff3527057cebc132eede74638b88ebfeb)) * **ux:** add `Ordered Qty` column in Get Items From > MR (backport [#36486](https://github.com/frappe/erpnext/issues/36486)) ([#36505](https://github.com/frappe/erpnext/issues/36505)) ([0d7a4b6](https://github.com/frappe/erpnext/commit/0d7a4b6ff64dbe5cca0cc6999557c2a9fdbd54fb)) ### Features * ledger comparison report ([#36485](https://github.com/frappe/erpnext/issues/36485)) ([07f235c](https://github.com/frappe/erpnext/commit/07f235cf7d251573a789f014becd0c5956cefc54)) * **RFQ:** make sending attachments configurable (backport [#36359](https://github.com/frappe/erpnext/issues/36359)) ([#36535](https://github.com/frappe/erpnext/issues/36535)) ([5881960](https://github.com/frappe/erpnext/commit/5881960001fa55e3d24ddd009e6b897fd4109936)) ### Performance Improvements * asset depreciation entry posting ([#36461](https://github.com/frappe/erpnext/issues/36461)) ([cd1c175](https://github.com/frappe/erpnext/commit/cd1c175439dc58ba78224f8a2abd4d9bd8c1a39b)) * defer holiday list imports ([7adad42](https://github.com/frappe/erpnext/commit/7adad4272af06ac3bf50b9dd27affc507f4b931b)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 7b7e2142ee6..89ea6e4289b 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.33.2" +__version__ = "14.34.0" def get_default_company(user=None): From d6ebd1b6f8e1ceed4245eba75f624a057dece13d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:34:36 +0530 Subject: [PATCH 13/19] fix: precision issue while submitting the stock entry (backport #36575) (#36576) fix: precision issue while submitting the stock entry (#36575) fix: precision issue while submmiting the stock entry (cherry picked from commit a864e07d4ff2cf2d22754ad9d23a2a3718ece770) Co-authored-by: rohitwaghchaure --- erpnext/stock/doctype/material_request/material_request.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index cf61f9657f4..159fd32c123 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -223,12 +223,13 @@ class MaterialRequest(BuyingController): mr_qty_allowance = frappe.db.get_single_value("Stock Settings", "mr_qty_allowance") for d in self.get("items"): + precision = d.precision("ordered_qty") if d.name in mr_items: if self.material_request_type in ("Material Issue", "Material Transfer", "Customer Provided"): d.ordered_qty = flt(mr_items_ordered_qty.get(d.name)) if mr_qty_allowance: - allowed_qty = flt((d.qty + (d.qty * (mr_qty_allowance / 100))), d.precision("ordered_qty")) + allowed_qty = flt((d.qty + (d.qty * (mr_qty_allowance / 100))), precision) if d.ordered_qty and d.ordered_qty > allowed_qty: frappe.throw( @@ -237,11 +238,11 @@ class MaterialRequest(BuyingController): ).format(d.ordered_qty, d.parent, allowed_qty, d.item_code) ) - elif d.ordered_qty and d.ordered_qty > d.stock_qty: + elif d.ordered_qty and flt(d.ordered_qty, precision) > flt(d.stock_qty, precision): frappe.throw( _( "The total Issue / Transfer quantity {0} in Material Request {1} cannot be greater than requested quantity {2} for Item {3}" - ).format(d.ordered_qty, d.parent, d.qty, d.item_code) + ).format(d.ordered_qty, d.parent, d.stock_qty, d.item_code) ) elif self.material_request_type == "Manufacture": From 10e25972e177518d3cf6932cae374704fdcf074c Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Thu, 10 Aug 2023 08:06:21 +0000 Subject: [PATCH 14/19] chore(release): Bumped to Version 14.34.1 ## [14.34.1](https://github.com/frappe/erpnext/compare/v14.34.0...v14.34.1) (2023-08-10) ### Bug Fixes * precision issue while submitting the stock entry (backport [#36575](https://github.com/frappe/erpnext/issues/36575)) ([#36576](https://github.com/frappe/erpnext/issues/36576)) ([d6ebd1b](https://github.com/frappe/erpnext/commit/d6ebd1b6f8e1ceed4245eba75f624a057dece13d)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 89ea6e4289b..9db7e24dc39 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.34.0" +__version__ = "14.34.1" def get_default_company(user=None): From bb112eca054e11975265eaaeaf283a052c5d8c45 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 17:57:17 +0530 Subject: [PATCH 15/19] fix: incorrect available qty for backdated stock reco with batch (backport #36581) (#36585) fix: incorrect available qty for backdated stock reco with batch (#36581) (cherry picked from commit 2800ad39d2adc40b932b4626a1be4df89916973c) Co-authored-by: rohitwaghchaure --- .../stock_reconciliation.py | 62 +++++++++++------- .../test_stock_reconciliation.py | 63 ++++++++++++++++--- erpnext/stock/stock_ledger.py | 41 +++++------- 3 files changed, 110 insertions(+), 56 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index c6c8571b9ef..0d15bd75ad3 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -6,7 +6,7 @@ from typing import Optional import frappe from frappe import _, bold, msgprint from frappe.query_builder.functions import CombineDatetime, Sum -from frappe.utils import cint, cstr, flt +from frappe.utils import add_to_date, cint, cstr, flt import erpnext from erpnext.accounts.utils import get_company_default @@ -570,44 +570,58 @@ class StockReconciliation(StockController): else: self._cancel() - def recalculate_current_qty(self, item_code, batch_no): + def recalculate_current_qty(self, voucher_detail_no, sle_creation, add_new_sle=False): from erpnext.stock.stock_ledger import get_valuation_rate sl_entries = [] for row in self.items: - if not (row.item_code == item_code and row.batch_no == batch_no): + if voucher_detail_no != row.name: continue current_qty = get_batch_qty_for_stock_reco( - item_code, row.warehouse, batch_no, self.posting_date, self.posting_time, self.name + row.item_code, row.warehouse, row.batch_no, self.posting_date, self.posting_time, self.name ) precesion = row.precision("current_qty") - if flt(current_qty, precesion) == flt(row.current_qty, precesion): - continue + if flt(current_qty, precesion) != flt(row.current_qty, precesion): + val_rate = get_valuation_rate( + row.item_code, + row.warehouse, + self.doctype, + self.name, + company=self.company, + batch_no=row.batch_no, + ) - val_rate = get_valuation_rate( - item_code, row.warehouse, self.doctype, self.name, company=self.company, batch_no=batch_no - ) + row.current_valuation_rate = val_rate + row.current_qty = current_qty + row.db_set( + { + "current_qty": row.current_qty, + "current_valuation_rate": row.current_valuation_rate, + "current_amount": flt(row.current_qty * row.current_valuation_rate), + } + ) - row.current_valuation_rate = val_rate - if not row.current_qty and current_qty: - sle = self.get_sle_for_items(row) - sle.actual_qty = current_qty * -1 - sle.valuation_rate = val_rate - sl_entries.append(sle) - - row.current_qty = current_qty - row.db_set( - { - "current_qty": row.current_qty, - "current_valuation_rate": row.current_valuation_rate, - "current_amount": flt(row.current_qty * row.current_valuation_rate), - } - ) + if ( + add_new_sle + and not frappe.db.get_value( + "Stock Ledger Entry", + {"voucher_detail_no": row.name, "actual_qty": ("<", 0), "is_cancelled": 0}, + "name", + ) + and current_qty + ): + new_sle = self.get_sle_for_items(row) + new_sle.actual_qty = current_qty * -1 + new_sle.valuation_rate = row.current_valuation_rate + new_sle.creation_time = add_to_date(sle_creation, seconds=-1) + sl_entries.append(new_sle) if sl_entries: self.make_sl_entries(sl_entries, allow_negative_stock=True) + if frappe.db.exists("Repost Item Valuation", {"voucher_no": self.name, "status": "Queued"}): + self.repost_future_sle_and_gle(force=True) def get_batch_qty_for_stock_reco( diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 88d4e468977..1d8b72cec9a 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -759,13 +759,6 @@ class TestStockReconciliation(FrappeTestCase, StockTestMixin): se2.cancel() - self.assertTrue(frappe.db.exists("Repost Item Valuation", {"voucher_no": stock_reco.name})) - - self.assertEqual( - frappe.db.get_value("Repost Item Valuation", {"voucher_no": stock_reco.name}, "status"), - "Completed", - ) - sle = frappe.get_all( "Stock Ledger Entry", filters={"item_code": item_code, "warehouse": warehouse, "is_cancelled": 0}, @@ -775,6 +768,62 @@ class TestStockReconciliation(FrappeTestCase, StockTestMixin): self.assertEqual(flt(sle[0].qty_after_transaction), flt(50.0)) + def test_backdated_stock_reco_entry_with_batch(self): + from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry + + item_code = self.make_item( + "Test New Batch Item ABCVSD", + { + "is_stock_item": 1, + "has_batch_no": 1, + "batch_number_series": "BNS9.####", + "create_new_batch": 1, + }, + ).name + + warehouse = "_Test Warehouse - _TC" + + # Stock Reco for 100, Balace Qty 100 + stock_reco = create_stock_reconciliation( + item_code=item_code, + posting_date=nowdate(), + posting_time="11:00:00", + warehouse=warehouse, + qty=100, + rate=100, + ) + + sles = frappe.get_all( + "Stock Ledger Entry", + fields=["actual_qty", "batch_no"], + filters={"voucher_no": stock_reco.name, "is_cancelled": 0}, + ) + + self.assertEqual(len(sles), 1) + + # Stock Reco for 100, Balace Qty 100 + create_stock_reconciliation( + item_code=item_code, + posting_date=add_days(nowdate(), -1), + posting_time="11:00:00", + batch_no=sles[0].batch_no, + warehouse=warehouse, + qty=60, + rate=100, + ) + + sles = frappe.get_all( + "Stock Ledger Entry", + fields=["actual_qty"], + filters={"voucher_no": stock_reco.name, "is_cancelled": 0}, + ) + + self.assertEqual(len(sles), 2) + + for row in sles: + if row.actual_qty < 0: + self.assertEqual(row.actual_qty, -60) + def test_update_stock_reconciliation_while_reposting(self): from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index d52d59a0d18..0c3056cc705 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -199,6 +199,11 @@ def make_entry(args, allow_negative_stock=False, via_landed_cost_voucher=False): sle.allow_negative_stock = allow_negative_stock sle.via_landed_cost_voucher = via_landed_cost_voucher sle.submit() + + # Added to handle the case when the stock ledger entry is created from the repostig + if args.get("creation_time") and args.get("voucher_type") == "Stock Reconciliation": + sle.db_set("creation", args.get("creation_time")) + return sle @@ -564,12 +569,7 @@ class update_entries_after(object): if not self.args.get("sle_id"): self.get_dynamic_incoming_outgoing_rate(sle) - if ( - sle.voucher_type == "Stock Reconciliation" - and sle.batch_no - and sle.voucher_detail_no - and sle.actual_qty < 0 - ): + if sle.voucher_type == "Stock Reconciliation" and sle.batch_no and sle.voucher_detail_no: self.reset_actual_qty_for_stock_reco(sle) if ( @@ -634,14 +634,17 @@ class update_entries_after(object): self.update_outgoing_rate_on_transaction(sle) def reset_actual_qty_for_stock_reco(self, sle): - current_qty = frappe.get_cached_value( - "Stock Reconciliation Item", sle.voucher_detail_no, "current_qty" - ) + doc = frappe.get_cached_doc("Stock Reconciliation", sle.voucher_no) + doc.recalculate_current_qty(sle.voucher_detail_no, sle.creation, sle.actual_qty > 0) - if current_qty: - sle.actual_qty = current_qty * -1 - elif current_qty == 0: - sle.is_cancelled = 1 + if sle.actual_qty < 0: + sle.actual_qty = ( + flt(frappe.db.get_value("Stock Reconciliation Item", sle.voucher_detail_no, "current_qty")) + * -1 + ) + + if abs(sle.actual_qty) == 0.0: + sle.is_cancelled = 1 def validate_negative_stock(self, sle): """ @@ -1433,8 +1436,6 @@ def update_qty_in_future_sle(args, allow_negative_stock=False): next_stock_reco_detail = get_next_stock_reco(args) if next_stock_reco_detail: detail = next_stock_reco_detail[0] - if detail.batch_no: - regenerate_sle_for_batch_stock_reco(detail) # add condition to update SLEs before this date & time datetime_limit_condition = get_datetime_limit_condition(detail) @@ -1463,16 +1464,6 @@ def update_qty_in_future_sle(args, allow_negative_stock=False): validate_negative_qty_in_future_sle(args, allow_negative_stock) -def regenerate_sle_for_batch_stock_reco(detail): - doc = frappe.get_cached_doc("Stock Reconciliation", detail.voucher_no) - doc.recalculate_current_qty(detail.item_code, detail.batch_no) - - if not frappe.db.exists( - "Repost Item Valuation", {"voucher_no": doc.name, "status": "Queued", "docstatus": "1"} - ): - doc.repost_future_sle_and_gle(force=True) - - def get_stock_reco_qty_shift(args): stock_reco_qty_shift = 0 if args.get("is_cancelled"): From 35450d7bd93e38d679c65dee8953f7b0f4709ff7 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Thu, 10 Aug 2023 12:28:54 +0000 Subject: [PATCH 16/19] chore(release): Bumped to Version 14.34.2 ## [14.34.2](https://github.com/frappe/erpnext/compare/v14.34.1...v14.34.2) (2023-08-10) ### Bug Fixes * incorrect available qty for backdated stock reco with batch (backport [#36581](https://github.com/frappe/erpnext/issues/36581)) ([#36585](https://github.com/frappe/erpnext/issues/36585)) ([bb112ec](https://github.com/frappe/erpnext/commit/bb112eca054e11975265eaaeaf283a052c5d8c45)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 9db7e24dc39..2d9400749ff 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.34.1" +__version__ = "14.34.2" def get_default_company(user=None): From 9821f903507da403111367fb098260db0884c61e Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 11 Aug 2023 10:55:43 +0530 Subject: [PATCH 17/19] chore: update permissions for Process Payment Reconciliation (cherry picked from commit cd28d15292a77060c2ec9b582e4b0f5635f7b112) --- .../process_payment_reconciliation.json | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.json b/erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.json index 8bb7092dc50..1a1ab4d800e 100644 --- a/erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.json +++ b/erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.json @@ -146,7 +146,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2023-04-21 17:19:30.912953", + "modified": "2023-08-11 10:56:51.699137", "modified_by": "Administrator", "module": "Accounts", "name": "Process Payment Reconciliation", @@ -154,15 +154,25 @@ "owner": "Administrator", "permissions": [ { + "amend": 1, + "cancel": 1, "create": 1, "delete": 1, - "email": 1, - "export": 1, - "print": 1, "read": 1, - "report": 1, - "role": "System Manager", + "role": "Accounts Manager", "share": 1, + "submit": 1, + "write": 1 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "delete": 1, + "read": 1, + "role": "Accounts User", + "share": 1, + "submit": 1, "write": 1 } ], From e4e1f03bacc1b0093063a57e554cb8e94e0cba27 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 18:56:29 +0530 Subject: [PATCH 18/19] fix: wrap none type rate under flt (backport #36602) (backport #36604) (#36605) fix: wrap none type rate under flt (backport #36602) (#36604) fix: wrap none type rate under flt (#36602) (cherry picked from commit 627986efa1a29ccf419f0e845cdca4f49589bac3) Co-authored-by: Anand Baburajan (cherry picked from commit 63c061e5e823cb05c3fb2264c032bec7e90955a4) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- erpnext/controllers/status_updater.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index a4bc4a9c69e..f3663cc5271 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -233,7 +233,7 @@ class StatusUpdater(Document): if hasattr(d, "qty") and d.qty > 0 and self.get("is_return"): frappe.throw(_("For an item {0}, quantity must be negative number").format(d.item_code)) - if hasattr(d, "item_code") and hasattr(d, "rate") and d.rate < 0: + if hasattr(d, "item_code") and hasattr(d, "rate") and flt(d.rate) < 0: frappe.throw(_("For an item {0}, rate must be a positive number").format(d.item_code)) if d.doctype == args["source_dt"] and d.get(args["join_field"]): From ddcf555486e550b831e9d2610b7d6ecfaed36492 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Fri, 11 Aug 2023 13:28:22 +0000 Subject: [PATCH 19/19] chore(release): Bumped to Version 14.34.3 ## [14.34.3](https://github.com/frappe/erpnext/compare/v14.34.2...v14.34.3) (2023-08-11) ### Bug Fixes * wrap none type rate under flt (backport [#36602](https://github.com/frappe/erpnext/issues/36602)) (backport [#36604](https://github.com/frappe/erpnext/issues/36604)) ([#36605](https://github.com/frappe/erpnext/issues/36605)) ([e4e1f03](https://github.com/frappe/erpnext/commit/e4e1f03bacc1b0093063a57e554cb8e94e0cba27)) --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 2d9400749ff..24573a20c12 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -3,7 +3,7 @@ import inspect import frappe -__version__ = "14.34.2" +__version__ = "14.34.3" def get_default_company(user=None):