Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manufacturing Over/Under Production #50

Merged
merged 15 commits into from
Feb 1, 2024
Merged

Manufacturing Over/Under Production #50

merged 15 commits into from
Feb 1, 2024

Conversation

fproldan
Copy link
Collaborator

#40

@fproldan fproldan marked this pull request as draft January 16, 2024 12:21
@agritheory agritheory requested a review from HKuz January 17, 2024 14:22
@fproldan fproldan marked this pull request as ready for review January 30, 2024 13:03
@fproldan
Copy link
Collaborator Author

@HKuz This is ready for review, thanks!

@HKuz
Copy link
Collaborator

HKuz commented Feb 1, 2024

This looks great, @fproldan ! Only thing I uncovered was the last test test_validate_job_card was failing locally for me. It wasn't a code issue (the feature is doing what it should) - I had the same (user) error in the UI. It's complaining because there was already a submitted job card for the production qty that the test data automatically completes. I made the following edits to the test and it's passing. I didn't want to push up these changes in case you weren't having the issues on your end:

def test_validate_job_card():
	work_order = frappe.get_doc("Work Order", {"item_name": "Ambrosia Pie"})
	jc = frappe.get_doc("Job Card", {"work_order": work_order.name, "operation": work_order.operations[0].operation})
	jc.cancel()
	job_card = create_job_card(work_order, work_order.operations[0].as_dict(), auto_create=True)
	job_card.append(
		"time_logs",
		{
			"from_time": now(),
			"to_time": now(),
			"completed_qty": work_order.qty,
		},
	)
	job_card.save()
	assert job_card.validate_job_card() == None

	overproduction_percentage_for_work_order = frappe.db.get_value(
		"BOM", work_order.bom_no, "overproduction_percentage_for_work_order"
	)
	over_production_qty = work_order.qty * (1 + overproduction_percentage_for_work_order / 100)
	job_card.time_logs[0].completed_qty = over_production_qty
	job_card.save()

	assert job_card.validate_job_card() == None

	job_card.time_logs[0].completed_qty = over_production_qty + 10
	job_card.save()

	with pytest.raises(ValidationError) as exc_info:
		job_card.validate_job_card()

	assert (
		f"The <strong>Total Completed Qty</strong> (<strong>{over_production_qty + 10}</strong>) must be equal to <strong>Qty to Manufacture</strong> (<strong>{job_card.for_quantity}</strong>)"
		in exc_info.value.args[0]
	)

@fproldan
Copy link
Collaborator Author

fproldan commented Feb 1, 2024

@HKuz Thanks!
For me both your solution and the original worked, only have to change the assertion (without the )

Let me know if is passing now.

@HKuz
Copy link
Collaborator

HKuz commented Feb 1, 2024

@fproldan - I think it was a version issue. I updated my ERPNext and Frappe apps locally and I no longer get the error when there's already a completed Job Card in place for a work order. (It still wants those strong tags, though? If it's passing in CI should be fine but we can always do a replace to remove the tags before we compare strings if it causes a problem).

@HKuz HKuz merged commit baeb469 into version-14 Feb 1, 2024
4 checks passed
@agritheory agritheory deleted the issue_40 branch March 13, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants