feat: add detailed item sales report - #4538
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds a complete "Detailed Item Sales" report feature: a new report model that stages and queries sales-items with pricing/cost/profit metrics, two controller endpoints (form + report), two routes, language translations, and small view updates to list and preserve selected form values. ChangesDetailed Item Sales Report
Sequence Diagram(s)sequenceDiagram
participant Route
participant Controller
participant Model
participant View
Route->>Controller: date_input_item_sales()
Controller->>View: render date input
Route->>Controller: detailed_item_sales(start,end,sale,loc,discount)
Controller->>Model: create(inputs)
Controller->>Model: getData(inputs)
Controller->>Model: getSummaryData(inputs)
Controller->>View: render tabular
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/Config/Routes.php`:
- Line 35: The route declaration defines five segments but only supplies four
parameters to Reports::detailed_item_sales; update the route pattern to four
segments so it matches the method signature (start_date, end_date, sale_type,
location_id) — change the route in Routes.php from
'reports/detailed_item_sales/(:segment)/(:segment)/(:segment)/(:segment)/(:segment)'
to a four-segment pattern (four (:segment) placeholders) so the controller
method receives the correct $1/$2/$3/$4 parameters.
In `@app/Controllers/Reports.php`:
- Around line 704-713: The view expects $mode and $sale_type_options but
date_input_item_sales() doesn't set them; update date_input_item_sales() to
mirror date_input_sales()/date_input() by assigning $data['mode'] = 'sale' and
$data['sale_type_options'] = (the same sale type options array used in
date_input_sales()/date_input()), then pass $data into
view('reports/date_input', $data) so the sale_type dropdown and mode checks in
the view work without undefined variable warnings.
- Around line 1901-1910: The method detailed_item_sales declares an unused
parameter $sale_type while hardcoding 'sale_type' => 'sales' in the $inputs
array; remove $sale_type from the method signature of detailed_item_sales and
delete any internal references if present, and update the $inputs array to keep
'sale_type' => 'sales' as-is; also update any caller/route that passed four
parameters (e.g. the route in app/Config/Routes.php) to pass only three
parameters to match the new signature.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 844656ca-b8af-4f09-8946-e37c5df200bd
📒 Files selected for processing (6)
app/Config/Routes.phpapp/Controllers/Reports.phpapp/Language/en-GB/Reports.phpapp/Language/en/Reports.phpapp/Models/Reports/Detailed_item_sales.phpapp/Views/reports/listing.php
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/Controllers/Reports.php`:
- Around line 1906-1916: In detailed_item_sales, sanitize and validate the route
params before putting them into $inputs: validate $sale_type against an
allowlist (e.g., 'sales','returns', etc.) and default to 'sales' if invalid;
validate $discount_type against its allowlist (e.g., 'all','percentage','fixed')
and default to 'all' if invalid; normalize/cast $location_id to either 'all' or
an integer (use intval and reject/convert non-numeric to 'all'); then populate
$inputs with the validated values so downstream filtering uses only allowed,
well-typed values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d0cbf1aa-ac1c-4907-8798-b32d2ffbeec7
📒 Files selected for processing (4)
app/Config/Routes.phpapp/Controllers/Reports.phpapp/Models/Reports/Detailed_item_sales.phpapp/Views/reports/date_input.php
🚧 Files skipped from review as they are similar to previous changes (2)
- app/Config/Routes.php
- app/Models/Reports/Detailed_item_sales.php
650ef6e to
cffb634
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
@objecttothis good for review since updated branch already |
|
@coderabbitai review |
|
The current detailed transaction sales report doesn't show the item sold per row and it's not included in the report export. The items summary report doesn't classify by sale as well. The detatailed item sales report is added to show all items sold in an exportable manner while keeping the sale transaction informationi as well.
… for other languages
a7485f3 to
f68dd0f
Compare
objecttothis
left a comment
There was a problem hiding this comment.
This will be merged after 3.4.2 is released since 3.4.2 is now locked to security updates and bugfixes.
The current detailed transaction sales report doesn't show the item sold per row and it's not included in the report export. The items summary report doesn't classify by sale as well. The detatailed item sales report is added to show all items sold in an exportable manner while keeping the sale transaction informationi as well.
Summary by CodeRabbit
New Features
Improvements