Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def check_batch_expiry_date(doc,method):

current_date_month = current_date.month
expiry_date_batch_month = expiry_date_batch.month



target_days = frappe.db.get_single_value('Aarthy Settings',"expiry_days")

if current_date_month == expiry_date_batch_month:
if current_date_month == expiry_date_batch_month and expiry_date_batch.year == current_date.year:
expiry_month.append((item_name, check_batch.get("batch_no"),check_batch.get("row_no")))


Expand All @@ -73,29 +74,31 @@ def check_batch_expiry_date(doc,method):


if len(expiry_month) == 1:
mes=f"In Row {expiry_month[0][2]}: Item-<b>{expiry_month[0][0]}</b>-Batch:<b>{expiry_month[0][1]}</b> is expired and please select a valid batch.<br>"
mes=f"In Row {expiry_month[0][2]}: Item-<b>{expiry_month[0][0]}</b>-Batch:<b>{expiry_month[0][1]}</b> is expired and please select a valid batch.<br>"
frappe.throw(title = "Restricted Batch",msg = mes)


elif len(expiry_month) > 1:
mes = " "
for item,batch,row in expiry_month:
mes += f"In Row {row}: Item:<b>{item}</b>-Batch:<b>{batch}</b> is expired and Please select a valid batch.<br><br>"

frappe.throw(title = "Restricted Batch",msg = mes)




if len(expiry_within_days) == 1:
mes = f"In Row {expiry_within_days[0][3]}: Item: <b>{expiry_within_days[0][0]}</b> with batch: <b>{expiry_within_days[0][1]}</b> will expire on <b>{expiry_within_days[0][2]}</b><br><br>"
mes = f"In Row {expiry_within_days[0][3]}: Item: <b>{expiry_within_days[0][0]}</b> with batch: <b>{expiry_within_days[0][1]}</b> will expire on <b>{expiry_within_days[0][2]}</b><br><br>"
frappe.msgprint(title = "Warning",msg = mes)


elif len(expiry_within_days) > 1:
mes = " "

for item, batch, date,row in expiry_within_days:
mes += f"In Row {row}: Item: <b>{item}</b> with batch: <b>{batch}</b> will expire on <b>{date}</b><br><br>"

frappe.msgprint(title = "Warning",msg = mes)




Expand Down
Loading