Skip to content

Conversation

@nishkagosalia
Copy link
Contributor

The following fixes : #50949

In the scenario when we try updating the posting date in sales invoice through list view using the edit function, it used to not update the payment due date. This is fixed in this solution.

no-docs

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

📝 Walkthrough

Walkthrough

Reordered payment-date logic in invoices: validate_invoice_documents_schedule now calls set_due_date after set_payment_schedule. set_payment_schedule detects updates where posting_date changed (using doc_before_save) and, if payment terms exist, calls a new public helper recalculate_payment_due_date(posting_date, payment_schedule) to recompute each schedule entry's due_date via get_due_date. The controller's public exports were updated to include the new function. A test test_payment_date_recalculation was added to erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect recalculate_payment_due_date for correct iteration and in-place mutation of schedule entries and correct use of get_due_date (including date vs. datetime handling and timezone implications).
  • Verify set_payment_schedule correctly detects existing-doc updates via doc_before_save and triggers recalculation only when appropriate (no false positives on create or unrelated edits).
  • Confirm the reorder in validate_invoice_documents_schedule does not alter validation side effects.
  • Review the unit test test_payment_date_recalculation for determinism and coverage of multiple schedule lines and absence of payment terms.

Suggested reviewers

  • ruthra-kumar
  • diptanilsaha

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing payment recalculation logic when posting date is updated through list view.
Description check ✅ Passed The description explains the issue being fixed (posting date updates via list view not recalculating payment due dates) and relates directly to the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (1)

115-150: Strengthen test to exercise the actual set_payment_schedule integration

The test correctly verifies recalculate_payment_due_date in isolation, but it does not cover the real bug path: changing an existing invoice’s posting_date and letting AccountsController.set_payment_schedule (via validate_invoice_documents_schedule) recalc the payment schedule.

Consider extending or adding a test along these lines:

  • Create and insert a Sales Invoice with a payment terms template so that payment_schedule is auto-built.
  • Capture the original payment_schedule[0].due_date.
  • Change si.posting_date to a new date and call si.save() (or submit if that’s the realistic flow).
  • Reload and assert that payment_schedule due dates (and si.due_date) have shifted according to the new posting_date.

This will give you regression coverage on the wiring you added in set_payment_schedule, not just the helper itself.

erpnext/controllers/accounts_controller.py (1)

2570-2571: Make payment-due-date recalculation more defensive and targeted

The new branch and helper solve the core issue (recomputing schedule due dates when posting_date changes), but a couple of refinements would reduce surprise behaviour and align with existing expectations around get_due_date:

  1. Guard against posting_date being None and for non-template rows

    If a Payment Schedule row doesn’t originate from a payment term (i.e. has no due_date_based_on / is purely manual), recomputing via get_due_date(terms, posting_date) can either:

    • overwrite a user-entered due_date, or
    • produce None if due_date_based_on is unset or an unexpected value.

    Also, per earlier work in this module, the posting_date passed into get_due_date is expected to be non-None.

    You can make recalculate_payment_due_date safer with a small guard:

    -def recalculate_payment_due_date(posting_date, payment_schedule):
    -    for terms in payment_schedule:
    -        terms.due_date = get_due_date(terms, posting_date)
    +def recalculate_payment_due_date(posting_date, payment_schedule):
    +    # Defensive: nothing to recalculate if we don't have a posting_date
    +    if not posting_date:
    +        return
    +
    +    for terms in payment_schedule:
    +        # Only recalculate when term metadata is present
    +        if getattr(terms, "due_date_based_on", None):
    +            terms.due_date = get_due_date(terms, posting_date)

    This keeps the fix for template-driven schedules, while leaving fully manual schedules alone and avoiding accidental None due dates. Based on learnings, this also maintains the assumption that the posting_date passed into get_due_date is always valid.

  2. Align the “old vs new” date comparison with the computed posting_date

    Right now, the condition uses self.get_doc_before_save().posting_date != posting_date. For doctypes whose driver field is transaction_date (e.g., Sales Order / Purchase Order), this attribute is always None, so the condition will always be true even if the effective date didn’t change.

    If you want this comparison to work uniformly across doctypes, consider computing the “old” logical posting date the same way:

    -    elif not self.is_new() and self.get_doc_before_save().posting_date != posting_date:
    -        recalculate_payment_due_date(posting_date, self.payment_schedule)
    +    elif not self.is_new():
    +        prev_doc = self.get_doc_before_save()
    +        prev_posting_date = (
    +            prev_doc.get("bill_date")
    +            or prev_doc.get("posting_date")
    +            or prev_doc.get("transaction_date")
    +        )
    +
    +        if prev_posting_date != posting_date:
    +            recalculate_payment_due_date(posting_date, self.payment_schedule)

    This keeps the logic focused on “effective posting date changed” regardless of whether the doctype uses posting_date or transaction_date, and avoids unnecessary recalcs.

Overall behaviour for invoice/payment-term driven schedules stays the same, but these guards make the change safer for edge cases and manual schedules.

Also applies to: 4366-4368

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0bdbfe and 6ae036b.

📒 Files selected for processing (2)
  • erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (2 hunks)
  • erpnext/controllers/accounts_controller.py (3 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ljain112
Repo: frappe/erpnext PR: 48864
File: erpnext/controllers/accounts_controller.py:2586-2596
Timestamp: 2025-08-20T11:58:32.385Z
Learning: In erpnext/controllers/accounts_controller.py, the posting_date parameter passed to get_due_date() and get_discount_date() is mandatory and calculated from bill_date/posting_date/transaction_date, so it should not be None.
📚 Learning: 2025-12-16T05:33:58.723Z
Learnt from: Abdeali099
Repo: frappe/erpnext PR: 51078
File: erpnext/accounts/doctype/financial_report_template/financial_report_engine.py:486-491
Timestamp: 2025-12-16T05:33:58.723Z
Learning: In ERPNext/Frappe codebase, query.run(as_dict=True) returns frappe._dict objects that support both dict-style access (obj["key"]) and attribute-style access (obj.key). Therefore, attribute access on query results is valid and will not raise AttributeError. When reviewing Python code, prefer attribute access (obj.key) for readability where the key is known to exist, but ensure existence checks or fallback handling if there is any doubt about missing keys.

Applied to files:

  • erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
  • erpnext/controllers/accounts_controller.py
📚 Learning: 2025-08-20T11:58:32.385Z
Learnt from: ljain112
Repo: frappe/erpnext PR: 48864
File: erpnext/controllers/accounts_controller.py:2586-2596
Timestamp: 2025-08-20T11:58:32.385Z
Learning: In erpnext/controllers/accounts_controller.py, the posting_date parameter passed to get_due_date() and get_discount_date() is mandatory and calculated from bill_date/posting_date/transaction_date, so it should not be None.

Applied to files:

  • erpnext/controllers/accounts_controller.py
🧬 Code graph analysis (2)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (1)
erpnext/controllers/accounts_controller.py (1)
  • recalculate_payment_due_date (4366-4368)
erpnext/controllers/accounts_controller.py (1)
erpnext/accounts/party.py (1)
  • get_due_date (625-646)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Python Unit Tests (3)
  • GitHub Check: Python Unit Tests (4)
  • GitHub Check: Python Unit Tests (1)
  • GitHub Check: Python Unit Tests (2)
  • GitHub Check: Patch Test
  • GitHub Check: Summary
🔇 Additional comments (2)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (1)

30-34: Import of recalculate_payment_due_date is appropriate and scoped

Import is used only in the new test and keeps related controller helpers together; no issues from a dependency or style standpoint.

erpnext/controllers/accounts_controller.py (1)

647-666: Calling set_due_date() after set_payment_schedule() makes the invoice-level due date consistent

Moving self.set_due_date() into validate_invoice_documents_schedule right after self.set_payment_schedule() ensures self.due_date is always derived from the current payment_schedule before running amount/due-date validation, which aligns the header field with the schedule rows.

@mihir-kandoi
Copy link
Contributor

In the test case we are supposed to edit the posting_date of the document and then check if the due_date is recalculated correctly right?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (2)

119-126: Use frappe.new_doc for creating new documents.

As noted in previous reviews, prefer frappe.new_doc("Payment Term") over frappe.get_doc({...}) for better readability when creating new documents.

Apply this diff:

-	payment_term = frappe.get_doc(
-		{
-			"doctype": "Payment Term",
+	payment_term = frappe.new_doc("Payment Term")
+	payment_term.update(
+		{
 			"payment_term_name": "Test Term 2 Days",
 			"invoice_portion": 100,
 			"credit_days": 2,
-		}
-	).save()
+		}
+	)
+	payment_term.save()

128-134: Avoid abbreviations in variable names.

As previously noted, ptt is not immediately clear. Use payment_terms_template for better readability.

Apply this diff:

-	ptt = frappe.get_doc(
+	payment_terms_template = frappe.new_doc("Payment Terms Template")
+	payment_terms_template.update(
 		{
-			"doctype": "Payment Terms Template",
 			"template_name": "Test Template Recalc",
 			"terms": [{"payment_term": payment_term.name, "invoice_portion": 100, "credit_days": 2}],
-		}
-	).save()
+		}
+	)
+	payment_terms_template.save()
 
 	si = create_sales_invoice(do_not_save=1)
 	si.set_posting_time = 1
 	si.posting_date = posting_date
-	si.payment_terms_template = ptt.name
+	si.payment_terms_template = payment_terms_template.name
🧹 Nitpick comments (1)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (1)

143-146: Consider direct attribute assignment for clarity.

While using .update() works, direct assignment is more explicit and idiomatic for updating a single field.

Apply this diff:

-	si.update({"posting_date": new_posting_date})
+	si.posting_date = new_posting_date
 	si.save()
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 258013c and a7648c5.

📒 Files selected for processing (1)
  • erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ljain112
Repo: frappe/erpnext PR: 48864
File: erpnext/controllers/accounts_controller.py:2586-2596
Timestamp: 2025-08-20T11:58:32.385Z
Learning: In erpnext/controllers/accounts_controller.py, the posting_date parameter passed to get_due_date() and get_discount_date() is mandatory and calculated from bill_date/posting_date/transaction_date, so it should not be None.
📚 Learning: 2025-12-16T05:33:58.723Z
Learnt from: Abdeali099
Repo: frappe/erpnext PR: 51078
File: erpnext/accounts/doctype/financial_report_template/financial_report_engine.py:486-491
Timestamp: 2025-12-16T05:33:58.723Z
Learning: In ERPNext/Frappe codebase, query.run(as_dict=True) returns frappe._dict objects that support both dict-style access (obj["key"]) and attribute-style access (obj.key). Therefore, attribute access on query results is valid and will not raise AttributeError. When reviewing Python code, prefer attribute access (obj.key) for readability where the key is known to exist, but ensure existence checks or fallback handling if there is any doubt about missing keys.

Applied to files:

  • erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
🧬 Code graph analysis (1)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (3)
erpnext/controllers/accounts_controller.py (2)
  • InvalidQtyError (86-87)
  • recalculate_payment_due_date (4373-4375)
erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py (1)
  • create_sales_invoice (1025-1055)
erpnext/accounts/doctype/payment_reconciliation/test_payment_reconciliation.py (1)
  • create_sales_invoice (146-176)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Python Unit Tests (1)
  • GitHub Check: Python Unit Tests (4)
  • GitHub Check: Python Unit Tests (3)
  • GitHub Check: Python Unit Tests (2)
  • GitHub Check: Patch Test
  • GitHub Check: Summary
🔇 Additional comments (2)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (2)

30-34: LGTM! Import correctly includes the new function.

The import of recalculate_payment_due_date is properly added and will be used in the test method below.


115-147: Test correctly validates payment due date recalculation.

The test successfully verifies that updating posting_date triggers recalculation of payment_schedule[0].due_date, which is exactly what the PR aims to fix. The test flow is clear and assertions are appropriate.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7648c5 and 3753552.

📒 Files selected for processing (2)
  • erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (2 hunks)
  • erpnext/controllers/accounts_controller.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ljain112
Repo: frappe/erpnext PR: 48864
File: erpnext/controllers/accounts_controller.py:2586-2596
Timestamp: 2025-08-20T11:58:32.385Z
Learning: In erpnext/controllers/accounts_controller.py, the posting_date parameter passed to get_due_date() and get_discount_date() is mandatory and calculated from bill_date/posting_date/transaction_date, so it should not be None.
📚 Learning: 2025-08-20T11:58:32.385Z
Learnt from: ljain112
Repo: frappe/erpnext PR: 48864
File: erpnext/controllers/accounts_controller.py:2586-2596
Timestamp: 2025-08-20T11:58:32.385Z
Learning: In erpnext/controllers/accounts_controller.py, the posting_date parameter passed to get_due_date() and get_discount_date() is mandatory and calculated from bill_date/posting_date/transaction_date, so it should not be None.

Applied to files:

  • erpnext/controllers/accounts_controller.py
📚 Learning: 2025-12-16T05:33:58.723Z
Learnt from: Abdeali099
Repo: frappe/erpnext PR: 51078
File: erpnext/accounts/doctype/financial_report_template/financial_report_engine.py:486-491
Timestamp: 2025-12-16T05:33:58.723Z
Learning: In ERPNext/Frappe codebase, query.run(as_dict=True) returns frappe._dict objects that support both dict-style access (obj["key"]) and attribute-style access (obj.key). Therefore, attribute access on query results is valid and will not raise AttributeError. When reviewing Python code, prefer attribute access (obj.key) for readability where the key is known to exist, but ensure existence checks or fallback handling if there is any doubt about missing keys.

Applied to files:

  • erpnext/controllers/accounts_controller.py
🧬 Code graph analysis (1)
erpnext/controllers/accounts_controller.py (1)
erpnext/accounts/party.py (1)
  • get_due_date (625-646)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Python Unit Tests (3)
  • GitHub Check: Python Unit Tests (2)
  • GitHub Check: Python Unit Tests (1)
  • GitHub Check: Python Unit Tests (4)
  • GitHub Check: Patch Test
  • GitHub Check: Summary
🔇 Additional comments (1)
erpnext/controllers/accounts_controller.py (1)

662-662: LGTM! Correct ordering of due date calculation.

The repositioning of set_due_date() after set_payment_schedule() is correct, as the payment schedule must be populated before extracting the due date from it.

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.03%. Comparing base (0563fac) to head (3d37ce0).
⚠️ Report is 35 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #51118      +/-   ##
===========================================
+ Coverage    78.97%   79.03%   +0.05%     
===========================================
  Files         1175     1175              
  Lines       120026   120200     +174     
===========================================
+ Hits         94791    94998     +207     
+ Misses       25235    25202      -33     
Files with missing lines Coverage Δ
...counts/doctype/sales_invoice/test_sales_invoice.py 98.60% <100.00%> (+0.01%) ⬆️
erpnext/controllers/accounts_controller.py 85.28% <100.00%> (+0.22%) ⬆️

... and 17 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
erpnext/controllers/accounts_controller.py (1)

4378-4380: Add validation and filter to only update entries with payment terms.

The function has several concerns that should be addressed:

  1. Missing docstring: Add documentation explaining the function's purpose and parameters.

  2. No posting_date validation: Based on learnings, the posting_date parameter should be validated as non-None before calling get_due_date.

  3. Critical: Updates all entries without checking payment_term: The function currently recalculates due dates for ALL payment schedule entries. If an entry doesn't have a payment_term, get_due_date() will return None (since due_date_based_on won't be set), which would overwrite manually set due dates. This affects mixed scenarios where some entries use payment terms and others have manual due dates.

Apply this diff to add validation and filtering:

 def recalculate_payment_due_date(posting_date, payment_schedule):
+	"""
+	Recalculate due dates for payment schedule entries when the posting date changes.
+	Only updates entries that have an associated payment term.
+	
+	Args:
+		posting_date: The new posting date to calculate due dates from (must not be None)
+		payment_schedule: List of payment schedule entries
+	"""
+	if not posting_date:
+		return
+	
 	for terms in payment_schedule:
-		terms.due_date = get_due_date(terms, posting_date)
+		# Only recalculate if a payment term is defined
+		if terms.payment_term:
+			terms.due_date = get_due_date(terms, posting_date)

Based on learnings, the posting_date parameter should be mandatory and validated.

🧹 Nitpick comments (2)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (2)

30-34: Remove unused import.

The recalculate_payment_due_date function is imported but never used in this test file. The test correctly relies on the automatic recalculation triggered by the controller's save() method rather than calling this utility function directly.

Apply this diff:

 from erpnext.controllers.accounts_controller import (
 	InvalidQtyError,
-	recalculate_payment_due_date,
 	update_invoice_status,
 )

115-141: Good test implementation with a minor suggestion.

The test correctly verifies that updating posting_date triggers recalculation of due_date in the payment schedule, which addresses the issue described in the PR objectives. The test logic is sound and follows the codebase conventions (using frappe.new_doc, calling save() instead of insert()).

However, consider checking if the payment term and template already exist before creating them, or use more unique names to prevent potential duplicate key errors if tests are run multiple times in scenarios where rollback doesn't occur:

payment_term_name = f"Test Term 2 Days {nowdate()}"
template_name = f"Test Template Recalc {nowdate()}"

Alternatively, you could check and reuse existing records:

if not frappe.db.exists("Payment Term", "Test Term 2 Days"):
    payment_term = frappe.new_doc("Payment Term")
    # ... rest of the creation logic
else:
    payment_term = frappe.get_doc("Payment Term", "Test Term 2 Days")
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f99850 and 3d37ce0.

📒 Files selected for processing (2)
  • erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (2 hunks)
  • erpnext/controllers/accounts_controller.py (3 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ljain112
Repo: frappe/erpnext PR: 48864
File: erpnext/controllers/accounts_controller.py:2586-2596
Timestamp: 2025-08-20T11:58:32.385Z
Learning: In erpnext/controllers/accounts_controller.py, the posting_date parameter passed to get_due_date() and get_discount_date() is mandatory and calculated from bill_date/posting_date/transaction_date, so it should not be None.
📚 Learning: 2025-12-16T05:33:58.723Z
Learnt from: Abdeali099
Repo: frappe/erpnext PR: 51078
File: erpnext/accounts/doctype/financial_report_template/financial_report_engine.py:486-491
Timestamp: 2025-12-16T05:33:58.723Z
Learning: In ERPNext/Frappe codebase, query.run(as_dict=True) returns frappe._dict objects that support both dict-style access (obj["key"]) and attribute-style access (obj.key). Therefore, attribute access on query results is valid and will not raise AttributeError. When reviewing Python code, prefer attribute access (obj.key) for readability where the key is known to exist, but ensure existence checks or fallback handling if there is any doubt about missing keys.

Applied to files:

  • erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
  • erpnext/controllers/accounts_controller.py
📚 Learning: 2025-08-20T11:58:32.385Z
Learnt from: ljain112
Repo: frappe/erpnext PR: 48864
File: erpnext/controllers/accounts_controller.py:2586-2596
Timestamp: 2025-08-20T11:58:32.385Z
Learning: In erpnext/controllers/accounts_controller.py, the posting_date parameter passed to get_due_date() and get_discount_date() is mandatory and calculated from bill_date/posting_date/transaction_date, so it should not be None.

Applied to files:

  • erpnext/controllers/accounts_controller.py
🧬 Code graph analysis (2)
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py (1)
erpnext/controllers/accounts_controller.py (3)
  • InvalidQtyError (86-87)
  • recalculate_payment_due_date (4378-4380)
  • update_invoice_status (3502-3555)
erpnext/controllers/accounts_controller.py (1)
erpnext/accounts/party.py (1)
  • get_due_date (625-646)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Python Unit Tests (3)
  • GitHub Check: Python Unit Tests (4)
  • GitHub Check: Python Unit Tests (1)
  • GitHub Check: Python Unit Tests (2)
  • GitHub Check: Patch Test
  • GitHub Check: Summary
🔇 Additional comments (2)
erpnext/controllers/accounts_controller.py (2)

662-662: LGTM: Correct ordering of due date calculation.

Calling set_due_date() after set_payment_schedule() ensures the due date is calculated from the finalized payment schedule, which is the correct logical sequence.


2570-2583: LGTM: Safe posting date change detection.

The logic properly detects posting date changes on existing documents and safely checks for payment terms using any(), which avoids the IndexError that existed in earlier versions. The guards ensure the recalculation only runs when appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sales Invoice - Payment Due Date not recalculated

3 participants