Merge pull request #2134 from nabinhait/hotfix
Stock reconciliation fixes
This commit is contained in:
commit
ee2bc92ab2
@ -74,8 +74,8 @@ def get_data():
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Landed Cost Wizard",
|
"name": "Landed Cost Voucher",
|
||||||
"description": _("Distribute transport overhead across items."),
|
"description": _("Update additional costs to calculate landed cost of items"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
|
@ -71,8 +71,9 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"icon": "icon-usd",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2014-08-08 13:11:55.764550",
|
"modified": "2014-09-01 12:05:46.834513",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Landed Cost Voucher",
|
"name": "Landed Cost Voucher",
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"doctype": "Landed Cost Voucher",
|
||||||
|
"name": "_Test Landed Cost Voucher 1"
|
||||||
|
}
|
||||||
|
]
|
@ -74,7 +74,7 @@ class StockReconciliation(StockController):
|
|||||||
self.validation_messages.append(_get_msg(row_num, _("Warehouse not found in the system")))
|
self.validation_messages.append(_get_msg(row_num, _("Warehouse not found in the system")))
|
||||||
|
|
||||||
# if both not specified
|
# if both not specified
|
||||||
if row[2] == "" and row[3] == "":
|
if row[2] in ["", None] and row[3] in ["", None]:
|
||||||
self.validation_messages.append(_get_msg(row_num,
|
self.validation_messages.append(_get_msg(row_num,
|
||||||
_("Please specify either Quantity or Valuation Rate or both")))
|
_("Please specify either Quantity or Valuation Rate or both")))
|
||||||
|
|
||||||
@ -149,13 +149,13 @@ class StockReconciliation(StockController):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# check valuation rate mandatory
|
# check valuation rate mandatory
|
||||||
if row.qty != "" and not row.valuation_rate and \
|
if row.qty not in ["", None] and not row.valuation_rate and \
|
||||||
flt(previous_sle.get("qty_after_transaction")) <= 0:
|
flt(previous_sle.get("qty_after_transaction")) <= 0:
|
||||||
frappe.throw(_("Valuation Rate required for Item {0}").format(row.item_code))
|
frappe.throw(_("Valuation Rate required for Item {0}").format(row.item_code))
|
||||||
|
|
||||||
change_in_qty = row.qty not in ["", None] and \
|
change_in_qty = row.qty not in ["", None] and \
|
||||||
(flt(row.qty) - flt(previous_sle.get("qty_after_transaction")))
|
(flt(row.qty) - flt(previous_sle.get("qty_after_transaction")))
|
||||||
|
|
||||||
change_in_rate = row.valuation_rate not in ["", None] and \
|
change_in_rate = row.valuation_rate not in ["", None] and \
|
||||||
(flt(row.valuation_rate) - flt(previous_sle.get("valuation_rate")))
|
(flt(row.valuation_rate) - flt(previous_sle.get("valuation_rate")))
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ class StockReconciliation(StockController):
|
|||||||
if previous_valuation_rate == 0:
|
if previous_valuation_rate == 0:
|
||||||
return flt(valuation_rate)
|
return flt(valuation_rate)
|
||||||
else:
|
else:
|
||||||
if valuation_rate == "":
|
if valuation_rate in ["", None]:
|
||||||
valuation_rate = previous_valuation_rate
|
valuation_rate = previous_valuation_rate
|
||||||
return (qty * valuation_rate - previous_qty * previous_valuation_rate) \
|
return (qty * valuation_rate - previous_qty * previous_valuation_rate) \
|
||||||
/ flt(qty - previous_qty)
|
/ flt(qty - previous_qty)
|
||||||
@ -179,8 +179,7 @@ class StockReconciliation(StockController):
|
|||||||
if change_in_qty:
|
if change_in_qty:
|
||||||
# if change in qty, irrespective of change in rate
|
# if change in qty, irrespective of change in rate
|
||||||
incoming_rate = _get_incoming_rate(flt(row.qty), flt(row.valuation_rate),
|
incoming_rate = _get_incoming_rate(flt(row.qty), flt(row.valuation_rate),
|
||||||
flt(previous_sle.get("qty_after_transaction")),
|
flt(previous_sle.get("qty_after_transaction")), flt(previous_sle.get("valuation_rate")))
|
||||||
flt(previous_sle.get("valuation_rate")))
|
|
||||||
|
|
||||||
row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Actual Entry"
|
row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Actual Entry"
|
||||||
self.insert_entries({"actual_qty": change_in_qty, "incoming_rate": incoming_rate}, row)
|
self.insert_entries({"actual_qty": change_in_qty, "incoming_rate": incoming_rate}, row)
|
||||||
@ -211,7 +210,7 @@ class StockReconciliation(StockController):
|
|||||||
def _insert_entries():
|
def _insert_entries():
|
||||||
if previous_stock_queue != [[row.qty, row.valuation_rate]]:
|
if previous_stock_queue != [[row.qty, row.valuation_rate]]:
|
||||||
# make entry as per attachment
|
# make entry as per attachment
|
||||||
if row.qty:
|
if flt(row.qty):
|
||||||
row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Actual Entry"
|
row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Actual Entry"
|
||||||
self.insert_entries({"actual_qty": row.qty,
|
self.insert_entries({"actual_qty": row.qty,
|
||||||
"incoming_rate": flt(row.valuation_rate)}, row)
|
"incoming_rate": flt(row.valuation_rate)}, row)
|
||||||
@ -225,7 +224,7 @@ class StockReconciliation(StockController):
|
|||||||
|
|
||||||
|
|
||||||
if change_in_qty:
|
if change_in_qty:
|
||||||
if row.valuation_rate == "":
|
if row.valuation_rate in ["", None]:
|
||||||
# dont want change in valuation
|
# dont want change in valuation
|
||||||
if previous_stock_qty > 0:
|
if previous_stock_qty > 0:
|
||||||
# set valuation_rate as previous valuation_rate
|
# set valuation_rate as previous valuation_rate
|
||||||
|
@ -22,7 +22,7 @@ def repost(allow_negative_stock=False):
|
|||||||
(select item_code, warehouse from tabBin
|
(select item_code, warehouse from tabBin
|
||||||
union
|
union
|
||||||
select item_code, warehouse from `tabStock Ledger Entry`) a"""):
|
select item_code, warehouse from `tabStock Ledger Entry`) a"""):
|
||||||
repost_stock(d[0], d[1], allow_negative_stock)
|
repost_stock(d[0], d[1])
|
||||||
|
|
||||||
if allow_negative_stock:
|
if allow_negative_stock:
|
||||||
frappe.db.set_default("allow_negative_stock",
|
frappe.db.set_default("allow_negative_stock",
|
||||||
@ -33,7 +33,7 @@ def repost_stock(item_code, warehouse):
|
|||||||
repost_actual_qty(item_code, warehouse)
|
repost_actual_qty(item_code, warehouse)
|
||||||
|
|
||||||
if item_code and warehouse:
|
if item_code and warehouse:
|
||||||
update_bin(item_code, warehouse, {
|
update_bin_qty(item_code, warehouse, {
|
||||||
"reserved_qty": get_reserved_qty(item_code, warehouse),
|
"reserved_qty": get_reserved_qty(item_code, warehouse),
|
||||||
"indented_qty": get_indented_qty(item_code, warehouse),
|
"indented_qty": get_indented_qty(item_code, warehouse),
|
||||||
"ordered_qty": get_ordered_qty(item_code, warehouse),
|
"ordered_qty": get_ordered_qty(item_code, warehouse),
|
||||||
@ -116,7 +116,7 @@ def get_planned_qty(item_code, warehouse):
|
|||||||
return flt(planned_qty[0][0]) if planned_qty else 0
|
return flt(planned_qty[0][0]) if planned_qty else 0
|
||||||
|
|
||||||
|
|
||||||
def update_bin(item_code, warehouse, qty_dict=None):
|
def update_bin_qty(item_code, warehouse, qty_dict=None):
|
||||||
from erpnext.stock.utils import get_bin
|
from erpnext.stock.utils import get_bin
|
||||||
bin = get_bin(item_code, warehouse)
|
bin = get_bin(item_code, warehouse)
|
||||||
mismatch = False
|
mismatch = False
|
||||||
@ -201,11 +201,11 @@ def reset_serial_no_status_and_warehouse(serial_nos=None):
|
|||||||
last_sle = sr.get_last_sle()
|
last_sle = sr.get_last_sle()
|
||||||
if flt(last_sle.actual_qty) > 0:
|
if flt(last_sle.actual_qty) > 0:
|
||||||
sr.warehouse = last_sle.warehouse
|
sr.warehouse = last_sle.warehouse
|
||||||
|
|
||||||
sr.via_stock_ledger = True
|
sr.via_stock_ledger = True
|
||||||
sr.save()
|
sr.save()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
frappe.db.sql("""update `tabSerial No` set warehouse='' where status in ('Delivered', 'Purchase Returned')""")
|
frappe.db.sql("""update `tabSerial No` set warehouse='' where status in ('Delivered', 'Purchase Returned')""")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user