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: Auto Insert Item Price If Missing when discount & blank UOM #31168

Merged

Conversation

maharshivpatel
Copy link
Contributor

@maharshivpatel maharshivpatel commented May 28, 2022

Problem: Auto Insert Item Price If Missing will save the "price after discount" instead of "price before discount".

Solution: I have added price_list_rate = item_price + discount instead of price_list_rate = item_price and the reason for doing it this way instead of directly getting price_list_rate from args is that in cases where price_list_rate is not available this will still work and is less prone to bugs IMHO.

Problem: UOM is set to blank which should be set as stock_uom of the item because the price is converted to stock_uom.

Solution: I have added uom=stock_uom instead of blank and this will fix the item price being wrong due to non-conversion from stock_uom to sale_uom.

Before

before.mp4

After

after.mp4

This closes #31167

fixes wrong item price insert when discount is used and adds uom=stock_uom instead of blank as price is converted to stock uom
@github-actions github-actions bot added needs-tests This PR needs automated unit-tests. stock labels May 28, 2022
@ankush
Copy link
Member

ankush commented May 30, 2022

@maharshivpatel can you add 1 unit test for this behaviour (where discount is present)

I have added test  for auto_insert_price where discount is used.
fixed make_sales_order as some of the test that depended on it were failing due to passing of incorrect parameters.
@maharshivpatel
Copy link
Contributor Author

maharshivpatel commented May 30, 2022

I have ran all of the failed tests of Python Unit Tests (1) on my local setup and they were successful but they failed on CI.

can someone please take a look.

what is the suggested approach for semgrep error [ Avoid using args as only argument unless absolutely necessary. ]

@ankush ankush added squash Meant to tell reviewers that this PR should be squashed into a single commit while merging. and removed needs-tests This PR needs automated unit-tests. labels May 31, 2022
@ankush ankush merged commit b3ccc4b into frappe:develop May 31, 2022
mergify bot pushed a commit that referenced this pull request Jun 7, 2022
)

* fix: Auto Insert Item Price If Missing when discount and blank UOM

fixes wrong item price insert when discount is used and adds uom=stock_uom instead of blank as price is converted to stock uom

* unit tests added for item with discount

I have added test  for auto_insert_price where discount is used.

* unit test issue fixed

fixed make_sales_order as some of the test that depended on it were failing due to passing of incorrect parameters.

Co-authored-by: Ankush Menat <me@ankush.dev>
(cherry picked from commit b3ccc4b)
ankush pushed a commit that referenced this pull request Jun 7, 2022
…kport #31168) (#31267)

fix: Auto Insert Item Price If Missing when discount & blank UOM (#31168)

* fix: Auto Insert Item Price If Missing when discount and blank UOM

fixes wrong item price insert when discount is used and adds uom=stock_uom instead of blank as price is converted to stock uom

* unit tests added for item with discount

I have added test  for auto_insert_price where discount is used.

* unit test issue fixed

fixed make_sales_order as some of the test that depended on it were failing due to passing of incorrect parameters.

Co-authored-by: Ankush Menat <me@ankush.dev>
(cherry picked from commit b3ccc4b)

Co-authored-by: maharshivpatel <39730881+maharshivpatel@users.noreply.github.com>
frappe-pr-bot pushed a commit that referenced this pull request Jun 14, 2022
# [13.34.0](v13.33.0...v13.34.0) (2022-06-14)

### Bug Fixes

* (auto-merge) Use `frappe.log_error` instead of `doc.log_error` ([bced6a0](bced6a0))
* `test_work_order_with_non_stock_item` ([b827c3b](b827c3b))
* Add cost center in loan document ([c19dfbe](c19dfbe))
* **asset:** failing test case ([#31277](#31277)) ([8a4c9d1](8a4c9d1))
* Auto Insert Item Price If Missing when discount & blank UOM (backport [#31168](#31168)) ([#31267](#31267)) ([e69bff0](e69bff0))
* Call `calculate_cost` for Draft BOM and typo in argument ([d035aa2](d035aa2))
* Company address filter in quotation ([d375939](d375939))
* DB update child items, remove redundancy, fix perf ([cbc52a2](cbc52a2))
* Depreciate Asset before generating GL Entries on sale ([#30759](#30759)) ([dfbfe40](dfbfe40))
* Get fresh RM rate in `calculate_rm_cost` ([9a513fd](9a513fd))
* **India:** Incorrect taxable in GSTR-3B report ([e5d2c59](e5d2c59))
* **India:** Sales taxes and charges template fetching in quotation ([a1ba847](a1ba847))
* locale Currency and Float setting in update_employee ([391ed9c](391ed9c))
* misaligned columns in print format of AR/AP report ([81e32e2](81e32e2))
* Partially Ordered status for quotation ([37ba550](37ba550))
* purchase invoice standalone return GLEs (backport [#31209](#31209)) ([#31263](#31263)) ([6d99b5a](6d99b5a))
* Reset represents company on disabling internal customer and supplier (backport [#31302](#31302)) ([#31306](#31306)) ([fb9b302](fb9b302))
* Safe cast `row.rate` (in case of faulty exploded items, edge case but oh well) ([6d65e2b](6d65e2b))
* Supplied Qty not updated on Stock Entry cancel ([79b2062](79b2062))
* Trial Balance failing to ignore Finance Book ([00371f4](00371f4))
* typo in sql condition ([894f945](894f945))
* update fr translation (backport [#31232](#31232)) ([#31334](#31334)) ([5d0f271](5d0f271))
* update Period Closing Voucher per Company ([5ebbe81](5ebbe81))
* update ru translate (backport [#31200](#31200)) ([#31304](#31304)) ([77e4755](77e4755))
* Use `frappe.as_unicode` to decode output of redis module list (backport [#31282](#31282)) ([#31283](#31283)) ([633a452](633a452))
* **ux:** hide new version btn on unsaved BOM (backport [#31297](#31297)) ([#31298](#31298)) ([9f6b32a](9f6b32a))
* **UX:** use doc.status for Job Card status ([#31320](#31320)) ([78473b8](78473b8))

### Features

* Add german translations ([a3f2cf3](a3f2cf3))
* Level-wise BOM cost updation ([74d7d81](74d7d81))
* Only update exploded items rate and amount ([a26da58](a26da58))
* Track progress in Log Batch/Job wise ([3b2a8bf](3b2a8bf))

### Performance Improvements

* `get_boms_in_bottom_up_order` ([87c2b3b](87c2b3b))
* `get_next_higher_level_boms` ([767a775](767a775))
* Use cached doc instead of `get_doc` ([faa69c9](faa69c9))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-13-hotfix squash Meant to tell reviewers that this PR should be squashed into a single commit while merging. stock
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto Insert Item Price If Missing doesn't work as intended.
2 participants