fix: make ledger entries submittable and cleanup invalid test submissions#52921
fix: make ledger entries submittable and cleanup invalid test submissions#52921sagarvora merged 14 commits intofrappe:developfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #52921 +/- ##
========================================
Coverage 79.43% 79.44%
========================================
Files 1171 1171
Lines 124538 124568 +30
========================================
+ Hits 98932 98958 +26
- Misses 25606 25610 +4
🚀 New features to boost your workflow:
|
52a9fd3 to
33cfe8d
Compare
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (16)
📝 WalkthroughWalkthroughThis pull request makes five DocTypes submittable by adding the Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ions (frappe#52921) * fix: enable submittability for ledger entries and cleanup invalid test submissions * fix: reverted child table submittability * fix: added ignore_links flag for back gl entry * fix: add ignore_links for reconcile,cancelled PLE,cancelled SLE * fix: update test_recreate_stock_ledgers to use db.delete instead of doc.delete * chore: temporary test against frappe PR 37009 * fix: make Advance Payment Ledger Entry submittable * refactor: add extra line for create_shipping_rule * chore: revert temporary test against frappe PR 37009 * fix: use parent doc save with ignore_validate_update_after_submit for child table updates * chore: temporary test against frappe PR 37009 * chore: revert temporary test against frappe PR 37009 * fix: use skip_docstatus_validation
Details
This PR standardizes the behavior of transaction-related records by enabling submittability where required, adjusting core ledger logic to handle link validation, and fixing test cases that were incorrectly attempting to submit non-submittable doctypes.
1. Ledger Submittability (Accounts & Stock)
The following DocTypes have been updated with
is_submittable: 1:GL Entry,Payment Ledger Entry,Account Closing Balance,Advance Payment Ledger Entry.Stock Ledger Entry.2. Core Logic Adjustments
Updated ledger creation logic to handle link validation and submittability:
ignore_links: Truewhen creating reverse (cancelled) ledger entries ingeneral_ledger.pyandstock_ledger.py. This is necessary because during cancellation, the new offsetting entries must link back to the parent document (the Voucher), which is already in a "Cancelled" state. This flag preventsCancelledLinkError.ignore_links: Trueinutils.pyforPayment Ledger Entrycreation during reversal.3. Test Case Fixes
Identified and resolved several instances where tests were calling
.submit()on DocTypes that do not support the submission workflow:.submit()intest_shipping_rule.py..submit()calls intest_accounts_receivable.py.test_accounts_controller.pyto use.insert()instead of.submit().test_purchase_receipt.pyto usefrappe.db.deleteforStock Ledger Entryinstead ofdoc.delete(), as thedoc.delete()fails for submittable documents withdocstatus = 1.4. Child Table Update Pattern Fix
Child table doctypes in Frappe are not independently submittable — their
docstatusmirrors the parent. Several places were incorrectly calling.insert()/.submit()on child doc objects without handling the docstatus validation. All such patterns have been fixed by settingskip_docstatus_validation = Trueon the child doc before calling.insert()/.submit(), allowing the records to be correctly persisted with the appropriatedocstatus.tax_withholding_entry.py: Setskip_docstatus_validation = Trueon new entries created viafrappe.copy_docbefore.insert(). Applied to both the partial adjustment path (_adjust_against_old_entries) and the return invoice cancellation path (_handle_return_invoice_cancellation).subcontracting_inward_controller.py: Setskip_docstatus_validation = Truebefore.insert()/.submit()for newSubcontracting Inward Order Received ItemandSubcontracting Inward Order Secondary Itemchild docs.work_order.py: Setskip_docstatus_validation = Trueon the appended child row before.insert(). Removed the incorrect"docstatus": 1from the appended dict.pos_invoice.py: Replacedpayment.insert()on a standalone child doc withself.append("payments", payment)and a singleself.save()(with flag) after the loop.