feat(education/fee_category): Enforce validation for mandatory accoun… #351
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a crucial validation to the Fee Category Doctype to ensure accounting defaults are defined for all active, non-group companies in a multi-company environment. This prevents fatal errors in downstream financial transactions.
What has been changed?
Validation Added: A new method, validate_all_companies_covered, is added to the FeeCategory class in fee_category.py.
Validation Trigger: This method is called during the validate hook, checking if every active company in the system has a corresponding entry in the item_defaults (Accounting Defaults) table.
New Test Case: A new unit test, test_missing_company_default, has been added to test_fee_category.py to confirm the validation throws a ValidationError when a company's defaults are missing.
Why is this necessary? (Problem Solved)
In a multi-company setup, if a user creates a Fees Invoice for a company whose accounting defaults were not set in the Fee Category, the system will crash because it cannot find the mandatory Income Account and Selling Cost Center for that specific entity. This change forces the user to complete the setup at the master data level, guaranteeing that fee transactions will not fail later due to missing configuration.