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

feat: Ledger for advance payment #43709

Merged
merged 22 commits into from
Nov 1, 2024

Conversation

ruthra-kumar
Copy link
Member

@ruthra-kumar ruthra-kumar commented Oct 17, 2024

Issue

System allows advance payment to exceed Sales / Purchase Order grand total.

Consider below scenario,

  1. Sales Order of 10000 /-
  2. Make an Advance Payment of 2000 /-
  3. Make a Partial Invoice (2000 /-) for Sales Order and Reconcile the advance against the invoice
  4. Now, try making an Advance payment of 10000 /-. System allows this. It should've only allowed up to 8000 /-

Current Limitation

This happens because technically there is no distinction between a Normal Payment and an Advance Payment. So there is no persistent data structure to track the Advance Amount received for a Sales / Purchase Order. This distinction is inferred solely based on the allocation. If the Payment is allocated to a Sales / Purchase Order, then it is considered as an Advance Payment.

The problem with this approach is once reconciliation happens, the allocation to Sales / Purchase Order are replaced with an Invoice. So, we loose the critical information: A certain amount was received as an Advance, but it is now allocated to an Invoice.

Solution

A separate ledger to track Advance Payments against Sales Order or Purchase Order that only captures Submit and Cancel events. This way Reconciliation / Un-Reconciliation doesn't affect the advance amount calculation.

Event Ledger Effect
Submit Update
Reconcile -
Unreconcile -
Cancel Update

todo:

  • Refactor code; move logic to controller class
  • Patch to migrate existing records
  • Test for Foreign currency Transaction
  • [ ] Refactor HR code as well

For Employee Advance and Gratuity, reference is maintained even after the advance has been allocated. So, HRMS will continue to use GL Entry for calculating advance_paid,

no-docs

@ruthra-kumar ruthra-kumar force-pushed the ledger_for_advance_payment branch 2 times, most recently from ed05638 to 20b25c6 Compare October 18, 2024 11:01
@ruthra-kumar ruthra-kumar self-assigned this Oct 31, 2024
@ruthra-kumar ruthra-kumar merged commit b3b7b1a into frappe:develop Nov 1, 2024
20 checks passed
ruthra-kumar added a commit that referenced this pull request Nov 4, 2024
…-43709

feat: Ledger for advance payment (backport #43709)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant