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: batch_no filtering not working when batch no is also a number in… #30770

Merged
merged 1 commit into from
Apr 21, 2022

Conversation

ankush
Copy link
Member

@ankush ankush commented Apr 21, 2022

Problem: Automatic fetching of serial nos fails if the batch filter is a batch number that's also a number in scientific notation. E.g. 3709E93 which gets converted to 3709 * 10^93 by safe_json_loads.

Fix: reuse batch query string if JSON parsed data isn't a list.

======================================================================
 FAIL  test_auto_fetch (erpnext.stock.doctype.serial_no.test_serial_no.TestSerialNo)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/frappe-bench/apps/erpnext/erpnext/stock/doctype/serial_no/test_serial_no.py", line 319, in test_auto_fetch
    self.assertEqual(fetched_sr, sorted(expected_serials))
    batch = '3709E93'
    batch1 = '3709E93'
    batch2 = '401DA09'
    batch_wise_serials = {'3709E93': ['TEST0000001', 'TEST0000002', 'TEST0000003', 'TEST0000004', 'TEST0000005'], '401DA09': ['TEST0000006', 'TEST0000007', 'TEST0000008', 'TEST0000009', 'TEST0000010']}
    expected_serials = ['TEST0000001', 'TEST0000002', 'TEST0000003', 'TEST0000004', 'TEST0000005']
    fetched_sr = []
    first_fetch = ['TEST0000001', 'TEST0000002', 'TEST0000003', 'TEST0000004', 'TEST0000005']
    in1 = <StockEntry: MAT-STE-2022-00024 docstatus=1>
    in2 = <StockEntry: MAT-STE-2022-00025 docstatus=1>
    item_code = '8c7de508cbda010d'
    partial_fetch = ['TEST0000001', 'TEST0000002']
    remaining = ['TEST0000003', 'TEST0000004', 'TEST0000005']
    self = <erpnext.stock.doctype.serial_no.test_serial_no.TestSerialNo testMethod=test_auto_fetch>
    warehouse = '_Test Warehouse - _TC'
AssertionError: Lists differ: [] != ['TEST0000001', 'TEST0000002', 'TEST0000003', 'TEST0000004', 'TEST0000005']

Second list contains 5 additional elements.
First extra element 0:
'TEST0000001'

- []
+ ['TEST0000001', 'TEST0000002', 'TEST0000003', 'TEST0000004', 'TEST0000005']

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Apr 21, 2022
@ankush ankush added backport version-13-hotfix and removed needs-tests This PR needs automated unit-tests. labels Apr 21, 2022
@ankush
Copy link
Member Author

ankush commented Apr 21, 2022

(not adding test for this crazy edge case 😆 this was caught via tests only)

@codecov
Copy link

codecov bot commented Apr 21, 2022

Codecov Report

Merging #30770 (5354611) into develop (5660b33) will increase coverage by 0.10%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop   #30770      +/-   ##
===========================================
+ Coverage    61.40%   61.50%   +0.10%     
===========================================
  Files         1080     1080              
  Lines        69493    69493              
===========================================
+ Hits         42669    42745      +76     
+ Misses       26824    26748      -76     
Impacted Files Coverage Δ
erpnext/regional/india/e_invoice/utils.py 42.57% <ø> (ø)
...eport/sales_order_analysis/sales_order_analysis.py 73.33% <ø> (ø)
...xt/hr/doctype/shift_assignment/shift_assignment.py 90.77% <100.00%> (+15.04%) ⬆️
erpnext/stock/doctype/serial_no/serial_no.py 89.22% <100.00%> (ø)
...eport/item_variant_details/item_variant_details.py 31.32% <0.00%> (-53.02%) ⬇️
erpnext/stock/doctype/manufacturer/manufacturer.py 80.00% <0.00%> (-20.00%) ⬇️
...rial_no_valuation/incorrect_serial_no_valuation.py 85.96% <0.00%> (-10.53%) ⬇️
...pnext/setup/doctype/sales_partner/sales_partner.py 65.21% <0.00%> (-4.35%) ⬇️
...vs_serial_no_count/stock_qty_vs_serial_no_count.py 92.85% <0.00%> (-3.58%) ⬇️
...e/asset_value_adjustment/asset_value_adjustment.py 86.04% <0.00%> (-3.49%) ⬇️
... and 43 more

@ankush ankush merged commit ee30366 into frappe:develop Apr 21, 2022
@ankush ankush deleted the batch_no_fix branch April 21, 2022 11:04
mergify bot pushed a commit that referenced this pull request Apr 21, 2022
… scientific notation (#30770)

[skip ci]

(cherry picked from commit ee30366)
ankush added a commit that referenced this pull request Apr 21, 2022
… scientific notation (#30770) (#30771)

[skip ci]

(cherry picked from commit ee30366)

Co-authored-by: Ankush Menat <ankush@frappe.io>
frappe-pr-bot pushed a commit that referenced this pull request Apr 26, 2022
## [13.27.1](v13.27.0...v13.27.1) (2022-04-26)

### Bug Fixes

* Add accounting dimensions for round off GL Entry ([dedb90e](dedb90e))
* batch_no filtering not working when batch no is also a number in scientific notation ([#30770](#30770)) ([#30771](#30771)) ([c339305](c339305))
* Check if accounting dimension exists ([1834671](1834671))
* dependent gle reposting (backport [#30726](#30726)) ([#30772](#30772)) ([a6d0938](a6d0938))
* Do not validate while creating accounting dimension ([153b41a](153b41a))
* e_commerce_settings.js ([3a5f5d5](3a5f5d5))
* e_commerce_settings.py ([86c5f4d](86c5f4d))
* First preference to parent cost center rather than round off cost center ([a2d95fc](a2d95fc))
* Handle Multiselect field mapping separately ([dc2f694](dc2f694))
* **india:** 401 & 403 client error while generating IRN ([198bdcf](198bdcf))
* **india:** cess value not considered while validating e-invoice totals ([#30800](#30800)) ([f70fca1](f70fca1))
* **india:** transporter name is null while generating e-way bill ([#30736](#30736)) ([6291b28](6291b28))
* linter ([6dddbb9](6dddbb9))
* Loan doctypes in bank reconciliation ([e69c715](e69c715))
* Mistyped variable name in patch ([e76220e](e76220e))
* monthly attendance sheet ([#30748](#30748)) ([0b4e3f1](0b4e3f1))
* Must not be able to start Job Card if it is related to Work Order that is not started yet ([#29072](#29072)) ([#30755](#30755)) ([b656ffa](b656ffa))
* Query filter fields from Website Item instead of Item master ([bed9e09](bed9e09))
* select doctype as payment_document ([44f0b69](44f0b69))
* **Selling,E-Commerce:** Shopping cart quotation without website item. ([#29085](#29085)) ([ea0fe5e](ea0fe5e))
* SO analysis rpt will fetch SO's without Delivery note as well ([f9d89c7](f9d89c7))
* translation ([#30781](#30781)) ([#30783](#30783)) ([8335ca6](8335ca6))
* Update token to allow updates on protected branch ([baab379](baab379))
* update translation ([#30725](#30725)) ([#30776](#30776)) ([b585262](b585262))
* Use parent cost center for Sales and Purchase Invoice ([fe9f329](fe9f329))
* Use right precision for asset value after full schedule ([#30745](#30745)) ([269e192](269e192))
* Validate field filter wrt to Website Item & re-use validation in Item Group ([34437a8](34437a8))
deepeshgarg007 pushed a commit to deepeshgarg007/erpnext that referenced this pull request May 13, 2022
## [13.27.1](frappe/erpnext@v13.27.0...v13.27.1) (2022-04-26)

### Bug Fixes

* Add accounting dimensions for round off GL Entry ([dedb90e](frappe@dedb90e))
* batch_no filtering not working when batch no is also a number in scientific notation ([frappe#30770](frappe#30770)) ([frappe#30771](frappe#30771)) ([c339305](frappe@c339305))
* Check if accounting dimension exists ([1834671](frappe@1834671))
* dependent gle reposting (backport [frappe#30726](frappe#30726)) ([frappe#30772](frappe#30772)) ([a6d0938](frappe@a6d0938))
* Do not validate while creating accounting dimension ([153b41a](frappe@153b41a))
* e_commerce_settings.js ([3a5f5d5](frappe@3a5f5d5))
* e_commerce_settings.py ([86c5f4d](frappe@86c5f4d))
* First preference to parent cost center rather than round off cost center ([a2d95fc](frappe@a2d95fc))
* Handle Multiselect field mapping separately ([dc2f694](frappe@dc2f694))
* **india:** 401 & 403 client error while generating IRN ([198bdcf](frappe@198bdcf))
* **india:** cess value not considered while validating e-invoice totals ([frappe#30800](frappe#30800)) ([f70fca1](frappe@f70fca1))
* **india:** transporter name is null while generating e-way bill ([frappe#30736](frappe#30736)) ([6291b28](frappe@6291b28))
* linter ([6dddbb9](frappe@6dddbb9))
* Loan doctypes in bank reconciliation ([e69c715](frappe@e69c715))
* Mistyped variable name in patch ([e76220e](frappe@e76220e))
* monthly attendance sheet ([frappe#30748](frappe#30748)) ([0b4e3f1](frappe@0b4e3f1))
* Must not be able to start Job Card if it is related to Work Order that is not started yet ([frappe#29072](frappe#29072)) ([frappe#30755](frappe#30755)) ([b656ffa](frappe@b656ffa))
* Query filter fields from Website Item instead of Item master ([bed9e09](frappe@bed9e09))
* select doctype as payment_document ([44f0b69](frappe@44f0b69))
* **Selling,E-Commerce:** Shopping cart quotation without website item. ([frappe#29085](frappe#29085)) ([ea0fe5e](frappe@ea0fe5e))
* SO analysis rpt will fetch SO's without Delivery note as well ([f9d89c7](frappe@f9d89c7))
* translation ([frappe#30781](frappe#30781)) ([frappe#30783](frappe#30783)) ([8335ca6](frappe@8335ca6))
* Update token to allow updates on protected branch ([baab379](frappe@baab379))
* update translation ([frappe#30725](frappe#30725)) ([frappe#30776](frappe#30776)) ([b585262](frappe@b585262))
* Use parent cost center for Sales and Purchase Invoice ([fe9f329](frappe@fe9f329))
* Use right precision for asset value after full schedule ([frappe#30745](frappe#30745)) ([269e192](frappe@269e192))
* Validate field filter wrt to Website Item & re-use validation in Item Group ([34437a8](frappe@34437a8))
mergify bot pushed a commit that referenced this pull request May 15, 2022
## [13.27.1](v13.27.0...v13.27.1) (2022-04-26)

### Bug Fixes

* Add accounting dimensions for round off GL Entry ([dedb90e](dedb90e))
* batch_no filtering not working when batch no is also a number in scientific notation ([#30770](#30770)) ([#30771](#30771)) ([c339305](c339305))
* Check if accounting dimension exists ([1834671](1834671))
* dependent gle reposting (backport [#30726](#30726)) ([#30772](#30772)) ([a6d0938](a6d0938))
* Do not validate while creating accounting dimension ([153b41a](153b41a))
* e_commerce_settings.js ([3a5f5d5](3a5f5d5))
* e_commerce_settings.py ([86c5f4d](86c5f4d))
* First preference to parent cost center rather than round off cost center ([a2d95fc](a2d95fc))
* Handle Multiselect field mapping separately ([dc2f694](dc2f694))
* **india:** 401 & 403 client error while generating IRN ([198bdcf](198bdcf))
* **india:** cess value not considered while validating e-invoice totals ([#30800](#30800)) ([f70fca1](f70fca1))
* **india:** transporter name is null while generating e-way bill ([#30736](#30736)) ([6291b28](6291b28))
* linter ([6dddbb9](6dddbb9))
* Loan doctypes in bank reconciliation ([e69c715](e69c715))
* Mistyped variable name in patch ([e76220e](e76220e))
* monthly attendance sheet ([#30748](#30748)) ([0b4e3f1](0b4e3f1))
* Must not be able to start Job Card if it is related to Work Order that is not started yet ([#29072](#29072)) ([#30755](#30755)) ([b656ffa](b656ffa))
* Query filter fields from Website Item instead of Item master ([bed9e09](bed9e09))
* select doctype as payment_document ([44f0b69](44f0b69))
* **Selling,E-Commerce:** Shopping cart quotation without website item. ([#29085](#29085)) ([ea0fe5e](ea0fe5e))
* SO analysis rpt will fetch SO's without Delivery note as well ([f9d89c7](f9d89c7))
* translation ([#30781](#30781)) ([#30783](#30783)) ([8335ca6](8335ca6))
* Update token to allow updates on protected branch ([baab379](baab379))
* update translation ([#30725](#30725)) ([#30776](#30776)) ([b585262](b585262))
* Use parent cost center for Sales and Purchase Invoice ([fe9f329](fe9f329))
* Use right precision for asset value after full schedule ([#30745](#30745)) ([269e192](269e192))
* Validate field filter wrt to Website Item & re-use validation in Item Group ([34437a8](34437a8))

(cherry picked from commit 096dcf0)

# Conflicts:
#	erpnext/__init__.py
hrwX pushed a commit to hrwX/erpnext that referenced this pull request May 20, 2022
## [13.27.1](frappe/erpnext@v13.27.0...v13.27.1) (2022-04-26)

### Bug Fixes

* Add accounting dimensions for round off GL Entry ([dedb90e](frappe@dedb90e))
* batch_no filtering not working when batch no is also a number in scientific notation ([frappe#30770](frappe#30770)) ([frappe#30771](frappe#30771)) ([c339305](frappe@c339305))
* Check if accounting dimension exists ([1834671](frappe@1834671))
* dependent gle reposting (backport [frappe#30726](frappe#30726)) ([frappe#30772](frappe#30772)) ([a6d0938](frappe@a6d0938))
* Do not validate while creating accounting dimension ([153b41a](frappe@153b41a))
* e_commerce_settings.js ([3a5f5d5](frappe@3a5f5d5))
* e_commerce_settings.py ([86c5f4d](frappe@86c5f4d))
* First preference to parent cost center rather than round off cost center ([a2d95fc](frappe@a2d95fc))
* Handle Multiselect field mapping separately ([dc2f694](frappe@dc2f694))
* **india:** 401 & 403 client error while generating IRN ([198bdcf](frappe@198bdcf))
* **india:** cess value not considered while validating e-invoice totals ([frappe#30800](frappe#30800)) ([f70fca1](frappe@f70fca1))
* **india:** transporter name is null while generating e-way bill ([frappe#30736](frappe#30736)) ([6291b28](frappe@6291b28))
* linter ([6dddbb9](frappe@6dddbb9))
* Loan doctypes in bank reconciliation ([e69c715](frappe@e69c715))
* Mistyped variable name in patch ([e76220e](frappe@e76220e))
* monthly attendance sheet ([frappe#30748](frappe#30748)) ([0b4e3f1](frappe@0b4e3f1))
* Must not be able to start Job Card if it is related to Work Order that is not started yet ([frappe#29072](frappe#29072)) ([frappe#30755](frappe#30755)) ([b656ffa](frappe@b656ffa))
* Query filter fields from Website Item instead of Item master ([bed9e09](frappe@bed9e09))
* select doctype as payment_document ([44f0b69](frappe@44f0b69))
* **Selling,E-Commerce:** Shopping cart quotation without website item. ([frappe#29085](frappe#29085)) ([ea0fe5e](frappe@ea0fe5e))
* SO analysis rpt will fetch SO's without Delivery note as well ([f9d89c7](frappe@f9d89c7))
* translation ([frappe#30781](frappe#30781)) ([frappe#30783](frappe#30783)) ([8335ca6](frappe@8335ca6))
* Update token to allow updates on protected branch ([baab379](frappe@baab379))
* update translation ([frappe#30725](frappe#30725)) ([frappe#30776](frappe#30776)) ([b585262](frappe@b585262))
* Use parent cost center for Sales and Purchase Invoice ([fe9f329](frappe@fe9f329))
* Use right precision for asset value after full schedule ([frappe#30745](frappe#30745)) ([269e192](frappe@269e192))
* Validate field filter wrt to Website Item & re-use validation in Item Group ([34437a8](frappe@34437a8))

(cherry picked from commit 096dcf0)

# Conflicts:
#	erpnext/__init__.py
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 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.

1 participant