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: Validation in POS for item batch no stock quantity #28907

Merged

Conversation

nemesis189
Copy link
Contributor

@nemesis189 nemesis189 commented Dec 15, 2021

Issue:

  • When adding batch items to cart in POS, the stock quantity doesn't get updated and batch items are allowed to be added and submitted as well.
  • Validation is thrown during consolidation when it is already too late
Issue walkthrough(Steps):
  • Created Item with `Has Batch No` option checked
  • Created batches for the item through material receipt - total qty 2
  • The total batch qty for the batch no batch 02 is 2
  • Created a pos transaction with that item and batch no and qty as 1
  • Created another transaction with the item and qty as 2
  • Tried consolidating(closing entry) both invoices and error is thrown because qty is not available

Solution:

  • Added a validation at the time of checkout of the POS invoice itself to check for batch qty availability
  • Checking qty with unconsolidated pos invoices, available qty and current pos invoice
  • if available_qty - pos_reserved_qty - current_needed_qty < 0 then throw error

@codecov
Copy link

codecov bot commented Dec 16, 2021

Codecov Report

Merging #28907 (7385497) into develop (f02e6b4) will increase coverage by 0.05%.
The diff coverage is 88.00%.

@@             Coverage Diff             @@
##           develop   #28907      +/-   ##
===========================================
+ Coverage    55.72%   55.77%   +0.05%     
===========================================
  Files         1131     1131              
  Lines        67550    67574      +24     
===========================================
+ Hits         37639    37690      +51     
+ Misses       29911    29884      -27     
Impacted Files Coverage Δ
...rpnext/accounts/doctype/pos_invoice/pos_invoice.py 71.58% <86.66%> (+1.10%) ⬆️
erpnext/stock/doctype/batch/batch.py 82.00% <90.00%> (+0.57%) ⬆️
...work_order_stock_report/work_order_stock_report.py 50.00% <0.00%> (-50.00%) ⬇️
.../manufacturing/report/bom_explorer/bom_explorer.py 94.44% <0.00%> (-5.56%) ⬇️
...ctype/accounting_dimension/accounting_dimension.py 64.06% <0.00%> (-1.57%) ⬇️
...e/period_closing_voucher/period_closing_voucher.py 88.23% <0.00%> (-1.48%) ⬇️
erpnext/portal/utils.py 28.98% <0.00%> (-1.45%) ⬇️
.../report/stock_projected_qty/stock_projected_qty.py 88.15% <0.00%> (-1.32%) ⬇️
...eport/production_analytics/production_analytics.py 69.51% <0.00%> (-1.22%) ⬇️
erpnext/accounts/deferred_revenue.py 75.87% <0.00%> (-0.88%) ⬇️
... and 27 more

@ankush ankush linked an issue Dec 21, 2021 that may be closed by this pull request
@nextchamp-saqib nextchamp-saqib merged commit 842a6cd into frappe:develop Jan 3, 2022
@nextchamp-saqib
Copy link
Member

@Mergifyio backport version-13-hotfix

@mergify
Copy link
Contributor

mergify bot commented Jan 3, 2022

backport version-13-hotfix

✅ Backports have been created

nextchamp-saqib added a commit that referenced this pull request Jan 3, 2022
…-28907

fix: Validation in POS for item batch no stock quantity (backport #28907)
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.

Allowing Negative Batch item In POS VOUCHER In V13 beta 10
2 participants