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: cost of poor quality report time filters not working #28958

Merged
merged 13 commits into from
Jan 30, 2022

Conversation

aaronmenezes
Copy link
Contributor

Issue :

In the Cost of Poor Quality report, Time and date filter had no effect on the report.

Fix:

Update report query to fix this incorrect behavior.

@codecov
Copy link

codecov bot commented Dec 20, 2021

Codecov Report

Merging #28958 (1052203) into develop (087ebca) will increase coverage by 0.09%.
The diff coverage is 5.55%.

❗ Current head 1052203 differs from pull request most recent head 92c4ad9. Consider uploading reports for the commit 92c4ad9 to get more accurate results

@@             Coverage Diff             @@
##           develop   #28958      +/-   ##
===========================================
+ Coverage    55.64%   55.73%   +0.09%     
===========================================
  Files         1128     1131       +3     
  Lines        67335    67589     +254     
===========================================
+ Hits         37467    37674     +207     
- Misses       29868    29915      +47     
Impacted Files Coverage Δ
...poor_quality_report/cost_of_poor_quality_report.py 45.45% <5.55%> (-7.88%) ⬇️
...work_order_stock_report/work_order_stock_report.py 50.00% <0.00%> (-50.00%) ⬇️
...payroll/doctype/income_tax_slab/income_tax_slab.py 83.33% <0.00%> (-16.67%) ⬇️
...t/product_bundle_balance/product_bundle_balance.py 79.54% <0.00%> (-15.91%) ⬇️
...xt/stock/report/stock_analytics/stock_analytics.py 80.19% <0.00%> (-13.87%) ⬇️
.../manufacturing/report/bom_explorer/bom_explorer.py 94.44% <0.00%> (-5.56%) ⬇️
...ctype/woocommerce_settings/woocommerce_settings.py 80.00% <0.00%> (-4.00%) ⬇️
erpnext/stock/reorder_item.py 74.35% <0.00%> (-1.71%) ⬇️
...e/employee_benefit_claim/employee_benefit_claim.py 88.28% <0.00%> (-1.57%) ⬇️
.../hr/doctype/upload_attendance/upload_attendance.py 44.69% <0.00%> (-1.52%) ⬇️
... and 44 more

@aaronmenezes aaronmenezes force-pushed the fix_cost_of_poor_quality_filters branch from 4158435 to 3107e4d Compare December 21, 2021 11:38
@ankush ankush added the squash Meant to tell reviewers that this PR should be squashed into a single commit while merging. label Dec 24, 2021
@ankush ankush self-assigned this Dec 24, 2021
@ankush
Copy link
Member

ankush commented Dec 24, 2021

report not usable right now on develop due to date parsing issue, probably introduced via frappe/frappe#13504

edit: fixed via frappe/frappe#15454

))
)
query = append_filters(report_filters,operations,query,job_card)
data = query.run()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous function was returning a list of dicts. this is list of tuples. 🤔

.select(job_card_time_log.parent)
.where(job_card_time_log.parent == job_card.name)
.where(job_card_time_log.from_time >= report_filters.get('from_date',''))
.where(job_card_time_log.to_time <= report_filters.get('to_date',''))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if comparing an empty string like x <= '' nothing will show up I think? 🤔

These time filters should be conditionally chained like other filters.

job_card.serial_no, job_card.batch_no, job_card.workstation, job_card.total_time_in_mins, job_card.hour_rate,
operatingcost)
.where(job_card.docstatus==1)
.where(job_card.is_corrective_job_card==1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This condition should also be added in the subquery for faster filtering.
  • Sub-query should only be required when from/to time is specified.

@ankush ankush modified the milestones: v13.18, v13.19 Jan 4, 2022
@ankush ankush assigned aaronmenezes and unassigned ankush Jan 10, 2022
@ankush ankush marked this pull request as draft January 10, 2022 17:11
@ankush ankush modified the milestones: v13.19, v13.20 Jan 23, 2022
- optionally apply date filters
- join instead of expensive sub-query
- return as dictionary
@ankush ankush marked this pull request as ready for review January 30, 2022 14:50
@ankush ankush merged commit 0f7c2a1 into frappe:develop Jan 30, 2022
mergify bot pushed a commit that referenced this pull request Jan 30, 2022
* fix: cost of poor quality report time filters not working

* chore:update cost of poor quality report to use query builder

* fix: linter warnings

* chore: updated report query

* chore: added test filters

* fix : cleared linter warnings

* chore: formatting

* refactor: query generation

- optionally apply date filters
- join instead of expensive sub-query
- return as dictionary

* test: simplify test

Co-authored-by: Ankush Menat <ankush@frappe.io>
(cherry picked from commit 0f7c2a1)
ankush pushed a commit that referenced this pull request Jan 30, 2022
…29521)

* fix: cost of poor quality report time filters not working

* chore:update cost of poor quality report to use query builder

* fix: linter warnings

* chore: updated report query

* chore: added test filters

* fix : cleared linter warnings

* chore: formatting

* refactor: query generation

- optionally apply date filters
- join instead of expensive sub-query
- return as dictionary

* test: simplify test

Co-authored-by: Ankush Menat <ankush@frappe.io>
(cherry picked from commit 0f7c2a1)

Co-authored-by: aaronmenezes <ron2805@gmail.com>
KrithiRamani pushed a commit to KrithiRamani/erpnext that referenced this pull request Mar 14, 2022
…) (frappe#29521)

* fix: cost of poor quality report time filters not working

* chore:update cost of poor quality report to use query builder

* fix: linter warnings

* chore: updated report query

* chore: added test filters

* fix : cleared linter warnings

* chore: formatting

* refactor: query generation

- optionally apply date filters
- join instead of expensive sub-query
- return as dictionary

* test: simplify test

Co-authored-by: Ankush Menat <ankush@frappe.io>
(cherry picked from commit 0f7c2a1)

Co-authored-by: aaronmenezes <ron2805@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport version-13-hotfix manufacturing squash Meant to tell reviewers that this PR should be squashed into a single commit while merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants