fix: Calcellation logic for reconciliation of serialized items
This commit is contained in:
parent
6e264701cb
commit
ca25b925f5
@ -122,8 +122,8 @@ class Batch(Document):
|
|||||||
self.expiry_date = add_days(self.manufacturing_date, shelf_life_in_days)
|
self.expiry_date = add_days(self.manufacturing_date, shelf_life_in_days)
|
||||||
|
|
||||||
if has_expiry_date and not self.expiry_date:
|
if has_expiry_date and not self.expiry_date:
|
||||||
frappe.throw(_('Expiry date is mandatory for selected item'))
|
frappe.msgprint(_('Expiry date is mandatory for selected item.'))
|
||||||
frappe.msgprint(_('Set items shelf life in days, to set expiry based on manufacturing_date plus self life'))
|
frappe.throw(_("Set item's shelf life in days, to set expiry based on manufacturing date plus shelf-life."))
|
||||||
|
|
||||||
def get_name_from_naming_series(self):
|
def get_name_from_naming_series(self):
|
||||||
"""
|
"""
|
||||||
|
@ -415,6 +415,9 @@ def update_serial_nos_after_submit(controller, parentfield):
|
|||||||
if not stock_ledger_entries: return
|
if not stock_ledger_entries: return
|
||||||
|
|
||||||
for d in controller.get(parentfield):
|
for d in controller.get(parentfield):
|
||||||
|
if d.serial_no:
|
||||||
|
continue
|
||||||
|
|
||||||
update_rejected_serial_nos = True if (controller.doctype in ("Purchase Receipt", "Purchase Invoice")
|
update_rejected_serial_nos = True if (controller.doctype in ("Purchase Receipt", "Purchase Invoice")
|
||||||
and d.rejected_qty) else False
|
and d.rejected_qty) else False
|
||||||
accepted_serial_nos_updated = False
|
accepted_serial_nos_updated = False
|
||||||
@ -426,7 +429,6 @@ def update_serial_nos_after_submit(controller, parentfield):
|
|||||||
warehouse = d.warehouse
|
warehouse = d.warehouse
|
||||||
qty = (d.qty if controller.doctype == "Stock Reconciliation"
|
qty = (d.qty if controller.doctype == "Stock Reconciliation"
|
||||||
else d.stock_qty)
|
else d.stock_qty)
|
||||||
|
|
||||||
for sle in stock_ledger_entries:
|
for sle in stock_ledger_entries:
|
||||||
if sle.voucher_detail_no==d.name:
|
if sle.voucher_detail_no==d.name:
|
||||||
if not accepted_serial_nos_updated and qty and abs(sle.actual_qty)==qty \
|
if not accepted_serial_nos_updated and qty and abs(sle.actual_qty)==qty \
|
||||||
|
@ -359,7 +359,7 @@ class StockEntry(StockController):
|
|||||||
d.basic_rate = 0.0
|
d.basic_rate = 0.0
|
||||||
elif d.t_warehouse and not d.basic_rate:
|
elif d.t_warehouse and not d.basic_rate:
|
||||||
d.basic_rate = get_valuation_rate(d.item_code, d.t_warehouse,
|
d.basic_rate = get_valuation_rate(d.item_code, d.t_warehouse,
|
||||||
self.doctype, d.name, d.allow_zero_valuation_rate,
|
self.doctype, self.name, d.allow_zero_valuation_rate,
|
||||||
currency=erpnext.get_company_currency(self.company))
|
currency=erpnext.get_company_currency(self.company))
|
||||||
|
|
||||||
def set_actual_qty(self):
|
def set_actual_qty(self):
|
||||||
|
@ -52,7 +52,6 @@ class StockReconciliation(StockController):
|
|||||||
def _changed(item):
|
def _changed(item):
|
||||||
item_dict = get_stock_balance_for(item.item_code, item.warehouse,
|
item_dict = get_stock_balance_for(item.item_code, item.warehouse,
|
||||||
self.posting_date, self.posting_time, batch_no=item.batch_no)
|
self.posting_date, self.posting_time, batch_no=item.batch_no)
|
||||||
|
|
||||||
if (((item.qty is None or item.qty==item_dict.get("qty")) and
|
if (((item.qty is None or item.qty==item_dict.get("qty")) and
|
||||||
(item.valuation_rate is None or item.valuation_rate==item_dict.get("rate")) and not item.serial_no)
|
(item.valuation_rate is None or item.valuation_rate==item_dict.get("rate")) and not item.serial_no)
|
||||||
or (item.serial_no and item.serial_no == item_dict.get("serial_nos"))):
|
or (item.serial_no and item.serial_no == item_dict.get("serial_nos"))):
|
||||||
@ -261,16 +260,7 @@ class StockReconciliation(StockController):
|
|||||||
|
|
||||||
sl_entries.append(new_args)
|
sl_entries.append(new_args)
|
||||||
|
|
||||||
if self.docstatus == 2:
|
if row.qty:
|
||||||
args.update({
|
|
||||||
'actual_qty': 1,
|
|
||||||
'incoming_rate': row.valuation_rate,
|
|
||||||
'valuation_rate': row.valuation_rate
|
|
||||||
})
|
|
||||||
|
|
||||||
sl_entries.append(args)
|
|
||||||
|
|
||||||
if self.docstatus == 1 and row.qty:
|
|
||||||
args = self.get_sle_for_items(row)
|
args = self.get_sle_for_items(row)
|
||||||
|
|
||||||
args.update({
|
args.update({
|
||||||
|
@ -55,10 +55,12 @@ def get_conditions(filters):
|
|||||||
#get all details
|
#get all details
|
||||||
def get_stock_ledger_entries(filters):
|
def get_stock_ledger_entries(filters):
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
return frappe.db.sql("""select item_code, batch_no, warehouse,
|
return frappe.db.sql("""
|
||||||
posting_date, actual_qty
|
select item_code, batch_no, warehouse, posting_date, sum(actual_qty) as actual_qty
|
||||||
from `tabStock Ledger Entry`
|
from `tabStock Ledger Entry`
|
||||||
where docstatus < 2 and ifnull(batch_no, '') != '' %s order by item_code, warehouse""" %
|
where docstatus < 2 and ifnull(batch_no, '') != '' %s
|
||||||
|
group by voucher_no, batch_no, item_code, warehouse
|
||||||
|
order by item_code, warehouse""" %
|
||||||
conditions, as_dict=1)
|
conditions, as_dict=1)
|
||||||
|
|
||||||
def get_item_warehouse_batch_map(filters, float_precision):
|
def get_item_warehouse_batch_map(filters, float_precision):
|
||||||
|
@ -486,6 +486,7 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
|||||||
if not allow_zero_rate and not valuation_rate and raise_error_if_no_rate \
|
if not allow_zero_rate and not valuation_rate and raise_error_if_no_rate \
|
||||||
and cint(erpnext.is_perpetual_inventory_enabled(company)):
|
and cint(erpnext.is_perpetual_inventory_enabled(company)):
|
||||||
frappe.local.message_log = []
|
frappe.local.message_log = []
|
||||||
frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a zero valuation rate item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting/cancelling this entry").format(item_code, voucher_type, voucher_no))
|
frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a zero valuation rate item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting / cancelling this entry.")
|
||||||
|
.format(item_code, voucher_type, voucher_no))
|
||||||
|
|
||||||
return valuation_rate
|
return valuation_rate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user