* refactor: if() to CASE WHEN
* fix: remove duplicate order by
* fix: remove extraneous table
* style: reformat to black spec
Co-authored-by: Ankush Menat <ankush@frappe.io>
* refactor: DB independent quoting and truthy/falsy values
* style: reformat to black spec
* fix: ifnull -> coalesce
* fix: coalesce -> Coalesce
* fix: revert pypika comparison
* refactor: convert queries to QB
* fix: incorrect value types for query
`=` query makes no sense with list of values
* fix: remove warehouse docstatus condition
* fix: keep using base rate as rate
Co-authored-by: Ankush Menat <ankush@frappe.io>
* fix: Respect system precision for user facing balance qty values
- `get_precision` -> `set_precision`
- Use system wide currency precision for `stock_value`
- Round of qty defiiciency as per user defined precision (system flt precision), so that it is WYSIWYG for users
* fix: Consider system precision when validating future negative qty
* test: Immediate Negative Qty precision test
- Test for Immediate Negative Qty precision
- Stock Entry Negative Qty message: Format available qty in system precision
- Pass `stock_uom` as confugrable option in `make_item`
* test: Future Negative Qty validation with precision
* fix: Use `get_field_precision` for currency precision as it used to
- `get_field_precision` defaults to number format for precision (maintain old behaviour)
- Don't pass `currency` to `get_field_precision` as its not used anymore
* refactor: use CURRENT_DATE instead of CURDATE()
* style: reformat to black spec
* refactor: use QB for auto_close queries
Co-authored-by: Ankush Menat <ankush@frappe.io>
If stock voucher count goes >1000 then fetching all gles and reposting
them all at once requires much more memory and can cause crash.
- This PR ensures that GLE reposting is done in chunks of 100 vouchers.
- This PR also starts keeping track of how many such chunks were
processed so in future progress is resumed in event of timeout.
- Use `get_default_bom` in sales_order.py (reduce duplicate utility functions)
- Remove redundant if else in `get_work_order_items`
- `get_default_bom`: If no BOM and template exists try to fetch template BOM
- test: `get_work_order_items` via SO and if right BOM is picked
- Sales Team already had fetch from set up
- Set up fetch from on sales partner in sales transaction
Reason for removal: the JS code applies arbitrarily to any field called "sales_person"
* 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>
If item_name is already set and for some reason becomes outdated then
it's not updated in backend.
Fix: always set item_name and stock_uom when fetching item details