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

fix: Recalculate advance_paid in SO/PO after unlinking from advance entry #37069

Merged
merged 2 commits into from
Sep 22, 2023

Conversation

marination
Copy link
Collaborator

@marination marination commented Sep 13, 2023

Issue:

  • Create a Sales Order for Rs.100
  • Create an Advance Payment Entry against the Sales Order for Rs.40
  • Now advance_paid in SO = 40
  • Create a final Sales Invoice against this Sales Order. Fetch advance payments and submit. Outstanding = 100 - 40 = Rs.60

Now the PE is not linked to the Sales Order anymore but to the Sales Invoice. Yet, the advance_paid in the Sales Order shows as Rs.40, it isn't recalculated.

Issues are faced when we want to cancel the advance PE (case: some data in the Sales Invoice was wrong, we had to create a credit note for the customer and cancel the Payment Entry to issue new documents).

On trying to create a new advance PE it shows allocated amount as total - advance (wrong) = 100 - 40 = 60

Fix:

Recalculate the SO/PO advance while it is being unlinked/replaced by an invoice in the PE reference

ToDo:

  • Unit Test

@github-actions github-actions bot added accounts needs-tests This PR needs automated unit-tests. labels Sep 13, 2023
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #37069 (426350e) into develop (1c78a5a) will increase coverage by 0.00%.
Report is 9 commits behind head on develop.
The diff coverage is 75.00%.

❗ Current head 426350e differs from pull request most recent head 8a4954d. Consider uploading reports for the commit 8a4954d to get more accurate results

@@           Coverage Diff            @@
##           develop   #37069   +/-   ##
========================================
  Coverage    66.03%   66.03%           
========================================
  Files          796      796           
  Lines        62761    62765    +4     
========================================
+ Hits         41442    41448    +6     
+ Misses       21319    21317    -2     
Files Changed Coverage
erpnext/accounts/utils.py 75.00%

@marination marination marked this pull request as ready for review September 13, 2023 13:58
@marination marination added backport version-13-hotfix backport version-14-hotfix backport to version 14 and removed needs-tests This PR needs automated unit-tests. labels Sep 13, 2023
@marination
Copy link
Collaborator Author

Unrelated job card test failing

@ruthra-kumar ruthra-kumar self-assigned this Sep 15, 2023
@marination marination changed the title fix: Update advance_paid in SO/PO after unlinking from advance entry fix: Recalculate advance_paid in SO/PO after unlinking from advance entry Sep 20, 2023
@ruthra-kumar ruthra-kumar merged commit d477387 into frappe:develop Sep 22, 2023
14 of 16 checks passed
ruthra-kumar added a commit that referenced this pull request Sep 22, 2023
…-37069

fix: Recalculate `advance_paid` in SO/PO after unlinking from advance entry (backport #37069)
ruthra-kumar added a commit that referenced this pull request Sep 23, 2023
…-37069

fix: Recalculate `advance_paid` in SO/PO after unlinking from advance entry (backport #37069)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants