mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 15:39:20 +00:00
stock reco fixes
This commit is contained in:
@@ -26,7 +26,7 @@ class Bin(Document):
|
|||||||
def update_stock(self, args):
|
def update_stock(self, args):
|
||||||
self.update_qty(args)
|
self.update_qty(args)
|
||||||
|
|
||||||
if args.get("actual_qty"):
|
if args.get("actual_qty") or args.get("voucher_type") == "Stock Reconciliation":
|
||||||
from erpnext.stock.stock_ledger import update_entries_after
|
from erpnext.stock.stock_ledger import update_entries_after
|
||||||
|
|
||||||
if not args.get("posting_date"):
|
if not args.get("posting_date"):
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"default": "Today",
|
||||||
"fieldname": "posting_date",
|
"fieldname": "posting_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
@@ -118,7 +119,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"max_attachments": 1,
|
"max_attachments": 1,
|
||||||
"modified": "2014-05-26 03:05:54.024413",
|
"modified": "2014-10-07 12:43:52.825575",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Reconciliation",
|
"name": "Stock Reconciliation",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import date_diff
|
from frappe.utils import date_diff, flt
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
|
|
||||||
@@ -42,9 +42,14 @@ def get_columns():
|
|||||||
|
|
||||||
def get_fifo_queue(filters):
|
def get_fifo_queue(filters):
|
||||||
item_details = {}
|
item_details = {}
|
||||||
|
prev_qty = 0.0
|
||||||
for d in get_stock_ledger_entries(filters):
|
for d in get_stock_ledger_entries(filters):
|
||||||
item_details.setdefault(d.name, {"details": d, "fifo_queue": []})
|
item_details.setdefault(d.name, {"details": d, "fifo_queue": []})
|
||||||
fifo_queue = item_details[d.name]["fifo_queue"]
|
fifo_queue = item_details[d.name]["fifo_queue"]
|
||||||
|
|
||||||
|
if d.voucher_type == "Stock Reconciliation":
|
||||||
|
d.actual_qty = flt(d.qty_after_transaction) - flt(prev_qty)
|
||||||
|
|
||||||
if d.actual_qty > 0:
|
if d.actual_qty > 0:
|
||||||
fifo_queue.append([d.actual_qty, d.posting_date])
|
fifo_queue.append([d.actual_qty, d.posting_date])
|
||||||
else:
|
else:
|
||||||
@@ -61,12 +66,14 @@ def get_fifo_queue(filters):
|
|||||||
batch[0] -= qty_to_pop
|
batch[0] -= qty_to_pop
|
||||||
qty_to_pop = 0
|
qty_to_pop = 0
|
||||||
|
|
||||||
|
prev_qty = d.qty_after_transaction
|
||||||
|
|
||||||
return item_details
|
return item_details
|
||||||
|
|
||||||
def get_stock_ledger_entries(filters):
|
def get_stock_ledger_entries(filters):
|
||||||
return frappe.db.sql("""select
|
return frappe.db.sql("""select
|
||||||
item.name, item.item_name, item_group, brand, description, item.stock_uom,
|
item.name, item.item_name, item_group, brand, description, item.stock_uom,
|
||||||
actual_qty, posting_date
|
actual_qty, posting_date, voucher_type, qty_after_transaction
|
||||||
from `tabStock Ledger Entry` sle,
|
from `tabStock Ledger Entry` sle,
|
||||||
(select name, item_name, description, stock_uom, brand, item_group
|
(select name, item_name, description, stock_uom, brand, item_group
|
||||||
from `tabItem` {item_conditions}) item
|
from `tabItem` {item_conditions}) item
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ def update_entries_after(args, verbose=1):
|
|||||||
|
|
||||||
entries_to_fix = get_sle_after_datetime(previous_sle or \
|
entries_to_fix = get_sle_after_datetime(previous_sle or \
|
||||||
{"item_code": args["item_code"], "warehouse": args["warehouse"]}, for_update=True)
|
{"item_code": args["item_code"], "warehouse": args["warehouse"]}, for_update=True)
|
||||||
|
|
||||||
valuation_method = get_valuation_method(args["item_code"])
|
valuation_method = get_valuation_method(args["item_code"])
|
||||||
stock_value_difference = 0.0
|
stock_value_difference = 0.0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user