Skip to content

feat: add detailed item sales report - #4538

Open
enricodelarosa wants to merge 7 commits into
opensourcepos:masterfrom
enricodelarosa:feat/detailed-sales-report
Open

feat: add detailed item sales report#4538
enricodelarosa wants to merge 7 commits into
opensourcepos:masterfrom
enricodelarosa:feat/detailed-sales-report

Conversation

@enricodelarosa

@enricodelarosa enricodelarosa commented May 9, 2026

Copy link
Copy Markdown
Contributor

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

    • Added a Detailed Item Sales Report with item-level sales, pricing, discounts, totals, profitability, and transaction details.
    • Added filters for date range, sale type, location, and discount type.
    • Added access through the reports listing and dedicated report navigation.
  • Improvements

    • Date and filter selections are now preserved when revisiting report inputs.
    • Added report labels across supported locales.

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

This 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.

Changes

Detailed Item Sales Report

Layer / File(s) Summary
Report Model Definition
app/Models/Reports/Detailed_item_sales.php
New Detailed_item_sales model extends Report and implements create() to populate sales_items_temp, getDataColumns() for column defs and numeric sorters, getData() for item-level rows (quantity/price/discount/subtotal/tax/total/cost/profit and metadata), getSummaryData() to aggregate totals, and applyFilters() for sale_type/location/discount predicates.
Controller Integration
app/Controllers/Reports.php
Import and wire Detailed_item_sales model (import, private property, constructor). Add date_input_item_sales() to load allowed sales locations and render the date input form (lines ~704–718). Add detailed_item_sales(start_date,end_date,sale_type,location_id,discount_type) to normalize inputs, call model create/getData/getSummaryData, transform rows into tabular output, and render reports/tabular (lines ~1906–1960).
Route Registration
app/Config/Routes.php
Register two routes: reports/detailed_item_salesReports::date_input_item_sales and reports/detailed_item_sales/(:segment)/(:segment)/(:segment)/(:segment)/(:segment)Reports::detailed_item_sales/$1/$2/$3/$4/$5.
View Listing
app/Views/reports/listing.php
Render an additional "Detailed Item Sales" link within the detailed reports loop for the sales reports category.
Date Input View
app/Views/reports/date_input.php
Preserve previously selected sale_type and discount_type by preferring passed-in selections with fallbacks to existing defaults.
Translations
app/Language/*/Reports.php
Add detailed_item_sales_report key with label "Detailed Item Sales Report" across locale files (en-GB, en, and many others).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • objecttothis

Poem

🐰 A new report hops into view,
Rows of sales with price and cost,
Discounts, taxes, profit too—
Each item captured through and through.
Hooray for numbers, neat and glossed!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add detailed item sales report' clearly and specifically describes the main change—adding a new detailed item sales report feature. It is concise, accurate, and directly summarizes the primary addition across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 144e73e and 4610035.

📒 Files selected for processing (6)
  • app/Config/Routes.php
  • app/Controllers/Reports.php
  • app/Language/en-GB/Reports.php
  • app/Language/en/Reports.php
  • app/Models/Reports/Detailed_item_sales.php
  • app/Views/reports/listing.php

Comment thread app/Config/Routes.php Outdated
Comment thread app/Controllers/Reports.php Outdated
Comment thread app/Controllers/Reports.php Outdated
@enricodelarosa enricodelarosa changed the title feat: add detailed item sales report feat: add detailed item sales report Enhancement May 9, 2026
@enricodelarosa enricodelarosa changed the title feat: add detailed item sales report Enhancement feat: add detailed item sales report May 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4610035 and 9abcd74.

📒 Files selected for processing (4)
  • app/Config/Routes.php
  • app/Controllers/Reports.php
  • app/Models/Reports/Detailed_item_sales.php
  • app/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

Comment thread app/Controllers/Reports.php Outdated
Comment thread app/Language/en-GB/Reports.php Outdated
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@enricodelarosa
enricodelarosa requested a review from jekkos May 11, 2026 17:03
@enricodelarosa
enricodelarosa force-pushed the feat/detailed-sales-report branch 3 times, most recently from 650ef6e to cffb634 Compare May 14, 2026 13:26
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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.

@enricodelarosa

Copy link
Copy Markdown
Contributor Author

@objecttothis good for review since updated branch already

Comment thread app/Controllers/Reports.php Outdated
Comment thread app/Controllers/Reports.php Outdated
Comment thread app/Controllers/Reports.php Outdated
@objecttothis

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.
@enricodelarosa
enricodelarosa force-pushed the feat/detailed-sales-report branch from a7485f3 to f68dd0f Compare August 11, 2026 15:28

@objecttothis objecttothis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will be merged after 3.4.2 is released since 3.4.2 is now locked to security updates and bugfixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants