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: Include Stock Reco logic in update_qty_in_future_sle #26342

Merged

Conversation

marination
Copy link
Collaborator

Port of #26158

Issue:

  • On creating a backdated stock reconciliation, future quantity was not reposted due to incorrect logic in update_qty_in_future_sle and a missing case for stock reconciliations
    Screenshot 2021-06-22 at 9 38 18 PM
  • The actual_qty was used to adjust future SLEs, which is always 0 in stock reco SLEs
  • This allowed submission of Stock Recos that created insufficient stock for the future. It should have been blocked on submit

Fix:

  • Consider shift in qty i.e. difference between previous SLE and current Stock Reco SLE, for Stock Reconciliation while updating future SLEs
  • Add all future SLEs' Qty after Transaction by this shift in qty
  • Validate negative stock for Stock Reco too

Cases

Consider:

No. Document Date Qty Balance Qty
1 PR 2nd June 10 10
2 DN 3rd June -1 9
3 PR 5th June 1 10
  • Post a backdated reco 1 on the 1st for qty 8. The shift in qty is 8 since there is no transaction before this reco. The future SLE balances are shifted by 8.

    No. Document Date Qty Balance Qty Balance after Reco 1
    4 Reco 1 1st June 0 8 8
    1 PR 2nd June 10 10 18
    2 DN 3rd June -1 9 17
    3 PR 5th June 1 10 18
  • Post a backdated reco 2 on the 4th for qty 6. The shift in qty = current balance after reco 2 - previous balance before reco 2 = 6 - 9 = -3. The future SLE balances are shifted by -3

    No. Document Date Qty Balance Qty Balance after Reco 2
    1 PR 2nd June 10 10
    2 DN 3rd June -1 9
    4 Reco 2 4th June 0 6 6
    3 PR 5th June 1 10 7
  • If a reco (Reco 1) is posted on 4th (as previously seen) and then another reco (Reco 2) on the 1st, the qty recalculation after submitting Reco 2 must happen only till the 3rd (any time before Reco 1)

    No. Document Date Qty Balance Qty Balance after Reco 2
    5 Reco 2 1st June 0 8 8
    1 PR 2nd June 10 10 18
    2 DN 3rd June -1 9 17
    4 Reco 1 4th June 0 6
    3 PR 5th June 1 7
  • Posting a backdated reco that causes future negative stock should be stopped

    No. Document Date Qty Balance Qty Balance after Reco 1
    1 PR 2nd June 10 10
    4 Reco 1 3rd June 8am 0 0 NA due to blocked Reco
    2 DN 3rd June 10 am -1 9
    3 PR 5th June 1 10

@coveralls
Copy link

Coverage Status

Coverage remained the same at 42.805% when pulling 44c1e8d on marination:stock-reco-repost-qty-develop into 03f7bf6 on frappe:develop.

@rohitwaghchaure rohitwaghchaure merged commit 2fbe41d into frappe:develop Jul 6, 2021
asoral pushed a commit to asoral/erpnext that referenced this pull request Nov 12, 2021
…-develop

fix: Include Stock Reco logic in `update_qty_in_future_sle`
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.

None yet

3 participants