mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Stock reconciliation sl entries
This commit is contained in:
@@ -43,7 +43,17 @@ class Bin(Document):
|
|||||||
def update_qty(self, args):
|
def update_qty(self, args):
|
||||||
# update the stock values (for current quantities)
|
# update the stock values (for current quantities)
|
||||||
if args.get("voucher_type")=="Stock Reconciliation":
|
if args.get("voucher_type")=="Stock Reconciliation":
|
||||||
self.actual_qty = args.get("qty_after_transaction")
|
if args.get('is_cancelled') == 'No':
|
||||||
|
self.actual_qty = args.get("qty_after_transaction")
|
||||||
|
else:
|
||||||
|
qty_after_transaction = frappe.db.get_value("""select qty_after_transaction
|
||||||
|
from `tabStock Ledger Entry`
|
||||||
|
where item_code=%s and warehouse=%s
|
||||||
|
and not (voucher_type='Stock Reconciliation' and voucher_no=%s)
|
||||||
|
order by posting_date desc limit 1""",
|
||||||
|
(self.item_code, self.warehouse, args.get('voucher_no')))
|
||||||
|
|
||||||
|
self.actual_qty = flt(qty_after_transaction[0][0]) if qty_after_transaction else 0.0
|
||||||
else:
|
else:
|
||||||
self.actual_qty = flt(self.actual_qty) + flt(args.get("actual_qty"))
|
self.actual_qty = flt(self.actual_qty) + flt(args.get("actual_qty"))
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ class StockLedgerEntry(Document):
|
|||||||
if not self.get(k):
|
if not self.get(k):
|
||||||
frappe.throw(_("{0} is required").format(self.meta.get_label(k)))
|
frappe.throw(_("{0} is required").format(self.meta.get_label(k)))
|
||||||
|
|
||||||
|
if self.voucher_type != "Stock Reconciliation" and not self.actual_qty:
|
||||||
|
frappe.throw(_("Actual Qty is mandatory"))
|
||||||
|
|
||||||
def validate_item(self):
|
def validate_item(self):
|
||||||
item_det = frappe.db.sql("""select name, has_batch_no, docstatus, is_stock_item
|
item_det = frappe.db.sql("""select name, has_batch_no, docstatus, is_stock_item
|
||||||
from tabItem where name=%s""", self.item_code, as_dict=True)[0]
|
from tabItem where name=%s""", self.item_code, as_dict=True)[0]
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ class StockReconciliation(StockController):
|
|||||||
"voucher_no": self.name,
|
"voucher_no": self.name,
|
||||||
"company": self.company,
|
"company": self.company,
|
||||||
"stock_uom": frappe.db.get_value("Item", row.item_code, "stock_uom"),
|
"stock_uom": frappe.db.get_value("Item", row.item_code, "stock_uom"),
|
||||||
"voucher_detail_no": row.voucher_detail_no,
|
|
||||||
"fiscal_year": self.fiscal_year,
|
"fiscal_year": self.fiscal_year,
|
||||||
"is_cancelled": "No",
|
"is_cancelled": "No",
|
||||||
"qty_after_transaction": row.qty,
|
"qty_after_transaction": row.qty,
|
||||||
|
|||||||
@@ -13,16 +13,13 @@ def execute(filters=None):
|
|||||||
data = []
|
data = []
|
||||||
for sle in sl_entries:
|
for sle in sl_entries:
|
||||||
item_detail = item_details[sle.item_code]
|
item_detail = item_details[sle.item_code]
|
||||||
voucher_link_icon = """<a href="%s"><i class="icon icon-share"
|
|
||||||
style="cursor: pointer;"></i></a>""" \
|
|
||||||
% ("/".join(["#Form", sle.voucher_type, sle.voucher_no]),)
|
|
||||||
|
|
||||||
data.append([sle.date, sle.item_code, item_detail.item_name, item_detail.item_group,
|
data.append([sle.date, sle.item_code, item_detail.item_name, item_detail.item_group,
|
||||||
item_detail.brand, item_detail.description, sle.warehouse,
|
item_detail.brand, item_detail.description, sle.warehouse,
|
||||||
item_detail.stock_uom, sle.actual_qty, sle.qty_after_transaction,
|
item_detail.stock_uom, sle.actual_qty, sle.qty_after_transaction,
|
||||||
(sle.incoming_rate if sle.actual_qty > 0 else 0.0),
|
(sle.incoming_rate if sle.actual_qty > 0 else 0.0),
|
||||||
sle.valuation_rate, sle.stock_value, sle.voucher_type, sle.voucher_no,
|
sle.valuation_rate, sle.stock_value, sle.voucher_type, sle.voucher_no,
|
||||||
voucher_link_icon, sle.batch_no, sle.serial_no, sle.company])
|
sle.batch_no, sle.serial_no, sle.company])
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
@@ -31,7 +28,7 @@ def get_columns():
|
|||||||
_("Brand") + ":Link/Brand:100", _("Description") + "::200", _("Warehouse") + ":Link/Warehouse:100",
|
_("Brand") + ":Link/Brand:100", _("Description") + "::200", _("Warehouse") + ":Link/Warehouse:100",
|
||||||
_("Stock UOM") + ":Link/UOM:100", _("Qty") + ":Float:50", _("Balance Qty") + ":Float:100",
|
_("Stock UOM") + ":Link/UOM:100", _("Qty") + ":Float:50", _("Balance Qty") + ":Float:100",
|
||||||
_("Incoming Rate") + ":Currency:110", _("Valuation Rate") + ":Currency:110", _("Balance Value") + ":Currency:110",
|
_("Incoming Rate") + ":Currency:110", _("Valuation Rate") + ":Currency:110", _("Balance Value") + ":Currency:110",
|
||||||
_("Voucher Type") + "::110", _("Voucher #") + "::100", _("Link") + "::30", _("Batch") + ":Link/Batch:100",
|
_("Voucher Type") + "::110", _("Voucher #") + ":Dynamic Link/Voucher Type:100", _("Batch") + ":Link/Batch:100",
|
||||||
_("Serial #") + ":Link/Serial No:100", _("Company") + ":Link/Company:100"]
|
_("Serial #") + ":Link/Serial No:100", _("Company") + ":Link/Company:100"]
|
||||||
|
|
||||||
def get_stock_ledger_entries(filters):
|
def get_stock_ledger_entries(filters):
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def make_sl_entries(sl_entries, is_amended=None):
|
|||||||
if sle.get('is_cancelled') == 'Yes':
|
if sle.get('is_cancelled') == 'Yes':
|
||||||
sle['actual_qty'] = -flt(sle['actual_qty'])
|
sle['actual_qty'] = -flt(sle['actual_qty'])
|
||||||
|
|
||||||
if sle.get("actual_qty"):
|
if sle.get("actual_qty") or sle.voucher_type=="Stock Reconciliation":
|
||||||
sle_id = make_entry(sle)
|
sle_id = make_entry(sle)
|
||||||
|
|
||||||
args = sle.copy()
|
args = sle.copy()
|
||||||
|
|||||||
Reference in New Issue
Block a user