Browse Source

fix: added patch to fix incorrect stock qty and account value (#24628)

develop
rohitwaghchaure 4 years ago
committed by GitHub
parent
commit
d60ff83b6f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      erpnext/accounts/utils.py
  2. 1
      erpnext/patches.txt
  3. 27
      erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py

9
erpnext/accounts/utils.py

@ -895,7 +895,8 @@ def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for
if not warehouse_account:
warehouse_account = get_warehouse_account_map(company)
future_stock_vouchers = get_future_stock_vouchers(posting_date, posting_time, for_warehouses, for_items)
future_stock_vouchers = get_future_stock_vouchers(posting_date, posting_time,
for_warehouses, for_items, company)
gle = get_voucherwise_gl_entries(future_stock_vouchers, posting_date)
for voucher_type, voucher_no in future_stock_vouchers:
@ -909,7 +910,7 @@ def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for
else:
_delete_gl_entries(voucher_type, voucher_no)
def get_future_stock_vouchers(posting_date, posting_time, for_warehouses=None, for_items=None):
def get_future_stock_vouchers(posting_date, posting_time, for_warehouses=None, for_items=None, company=None):
future_stock_vouchers = []
values = []
@ -922,6 +923,10 @@ def get_future_stock_vouchers(posting_date, posting_time, for_warehouses=None, f
condition += " and warehouse in ({})".format(", ".join(["%s"] * len(for_warehouses)))
values += for_warehouses
if company:
condition += " and company = %s "
values.append(company)
for d in frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no
from `tabStock Ledger Entry` sle
where

1
erpnext/patches.txt

@ -753,3 +753,4 @@ erpnext.patches.v13_0.convert_qi_parameter_to_link_field
erpnext.patches.v13_0.setup_patient_history_settings_for_standard_doctypes
erpnext.patches.v13_0.add_naming_series_to_old_projects # 1-02-2021
erpnext.patches.v12_0.add_state_code_for_ladakh
erpnext.patches.v13_0.item_reposting_for_incorrect_sl_and_gl

27
erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py

@ -0,0 +1,27 @@
import frappe
from frappe import _
from erpnext.stock.stock_ledger import update_entries_after
from erpnext.accounts.utils import update_gl_entries_after
data = frappe.db.sql(''' SELECT name, item_code, warehouse, voucher_type, voucher_no, posting_date, posting_time
from `tabStock Ledger Entry` where creation > '2020-12-26 12:58:55.903836' and is_cancelled = 0
order by timestamp(posting_date, posting_time) asc, creation asc''', as_dict=1)
for index, d in enumerate(data):
update_entries_after({
"item_code": d.item_code,
"warehouse": d.warehouse,
"posting_date": d.posting_date,
"posting_time": d.posting_time,
"voucher_type": d.voucher_type,
"voucher_no": d.voucher_no,
"sle_id": d.name
}, allow_negative_stock=True)
frappe.db.auto_commit_on_many_writes = 1
for row in frappe.get_all('Company', filters= {'enable_perpetual_inventory': 1}):
update_gl_entries_after('2020-12-25', '01:58:55', company=row.name)
frappe.db.auto_commit_on_many_writes = 0
Loading…
Cancel
Save