Skip to content

test: Fix validation error in Asset Repair when expense item is missing from Purchase Invoice - #280

Merged
Satya8848 merged 2 commits into
pre-prod-developfrom
issue_id_271
Aug 29, 2025
Merged

test: Fix validation error in Asset Repair when expense item is missing from Purchase Invoice#280
Satya8848 merged 2 commits into
pre-prod-developfrom
issue_id_271

Conversation

@ashishverma8848

Copy link
Copy Markdown
Collaborator

Bug Description

  • When running the test test_capitalize_repair_cost_asset_repair_submit_on_complete_status_TC_FA_140, the system raises a ValidationError stating:
  • "Expense item not present in Purchase Invoice" during the validate_purchase_invoice() method in the Asset Repair DocType.

Root Cause

  • The Asset Repair document is being inserted without a corresponding Expense Item being recorded in the related Purchase Invoice.
  • This is enforced in the validate_purchase_invoice() method, which checks for a specific item type or entry in the linked Purchase Invoice. When it is not found, the method throws a ValidationError.

Expected Result

  • The system should allow the submission of an Asset Repair document only if the related Purchase Invoice contains an expense item (likely a service/repair cost).

Actual Result

  • The system raises a ValidationError, blocking submission, because the Purchase Invoice does not contain the expected expense item.
  • This causes the test case to fail.

Fix Summary

  • Ensure that during the test (or real usage), the Purchase Invoice linked to the Asset Repair document includes an appropriate expense item.
  • Update the test setup to create a Purchase Invoice with the required expense item.
  • Alternatively, modify the validation logic to handle edge cases or provide a more descriptive error if additional context is needed.

Affected Module

  • Module: Assets
  • DocType: Asset Repair
  • Method: validate_purchase_invoice()
  • File: apps/assets/assets/assets/doctype/asset_repair/asset_repair.py

Test Case Id's:

-TC_FA_14

  • test_gl_entries_with_periodical_inventory
  • test_increase_in_asset_life
  • test_increase_in_asset_value_due_to_repair_cost_capitalisation
  • test_purchase_invoice

Issue ID:

#271

@Satya8848
Satya8848 merged commit 5faa123 into pre-prod-develop Aug 29, 2025
3 checks passed
@VishvParikh
VishvParikh deleted the issue_id_271 branch February 9, 2026 05:07
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.

TC_FA_140, TC_FA_139 - ValidationError: Expense item not present in Purchase Invoice

2 participants