Skip to content

Fix: Add Debit Card filter to Daily Sales and Takings - #4440

Merged
jekkos merged 1 commit into
masterfrom
fix/debit-filter-missing
Mar 16, 2026
Merged

jekkos merged 1 commit into
masterfrom
fix/debit-filter-missing

Conversation

@jekkos

@jekkos jekkos commented Mar 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds only_debit filter to Daily Sales and Takings dropdown
  • Fixes the debit_filter language key (was empty) in en and en-GB locales
  • Adds filter handling in Sale model for both payment summary and sales listing queries

Details

The Daily Sales/Takings view was missing the Debit Card filter in the dropdown, even though Debit is a valid payment type. This PR adds:

  1. Controller (Sales.php): Added 'only_debit' => lang('Sales.debit_filter') to the filters array
  2. Model (Sale.php): Added two filter conditions for debit payments (one for payment summary, one for sales listing)
  3. Language files: Updated debit_filter from empty string to "Debit Card" in en and en-GB

Fixes #4439

Summary by CodeRabbit

  • New Features
    • Added debit payment filtering capability. Users can now filter sales records and search results to display only debit transactions, providing better organization alongside existing payment type filters.

@coderabbitai

coderabbitai Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b3ff7e63-cdb1-4766-9155-f237eac0fdcf

📥 Commits

Reviewing files that changed from the base of the PR and between ea7ec23 and 80826b4.

📒 Files selected for processing (2)
  • app/Controllers/Sales.php
  • app/Models/Sale.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/Models/Sale.php
  • app/Controllers/Sales.php

📝 Walkthrough

Walkthrough

This PR adds support for filtering debit payment types in the Sales module. The changes introduce a new "only_debit" filter to the Sales controller and corresponding query-building logic in the Sale model, following the established patterns for cash, credit, and due payment filters.

Changes

Cohort / File(s) Summary
Debit Filter Implementation
app/Controllers/Sales.php, app/Models/Sale.php
Added "only_debit" filter key to Sales controller filter declarations (getManage, getSearch) and implemented debit payment type filtering logic in the Sale model (get_payments_summary, add_filters_to_query) to mirror existing payment type filter patterns.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A debit filter hops into view,
Where payments of all types shine through,
No more missing from the list,
This debit option can't be missed!
Our daily sales now complete and bright, ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a Debit Card filter to Daily Sales and Takings functionality, which is the primary objective of the PR.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #4439: adds debit filter to dropdown, implements filtering logic in the model, and restores the language key for display.
Out of Scope Changes check ✅ Passed All changes are scoped to the debit filter functionality across the Sales controller and Sale model with no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/debit-filter-missing
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

@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 the current code and only fix it if needed.

Inline comments:
In `@app/Controllers/Sales.php`:
- Line 95: The defaults returned by the Sales controller's getSearch() are
missing the 'only_debit' key which causes PHP warnings when
App\Models\Sale::add_filters_to_query() and ::get_payments_summary() read it;
add the 'only_debit' entry to the defaults array in getSearch() (initialize it
to a boolean, e.g. false) so the key always exists and has the correct type
before those Sale methods access it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8abaf8b8-d0e8-4b32-81d2-15d717877990

📥 Commits

Reviewing files that changed from the base of the PR and between 234f930 and ea7ec23.

📒 Files selected for processing (4)
  • app/Controllers/Sales.php
  • app/Language/en-GB/Sales.php
  • app/Language/en/Sales.php
  • app/Models/Sale.php

Comment thread app/Controllers/Sales.php Resolved
Add 'only_debit' filter to Daily Sales and Takings dropdown. Reuses
existing 'Sales.debit' language string for the filter label. Includes
filter default initialization in getSearch() to prevent PHP warnings.

Fixes #4439
@jekkos
jekkos force-pushed the fix/debit-filter-missing branch from ea7ec23 to 80826b4 Compare March 16, 2026 17:51
@jekkos
jekkos merged commit 9820beb into master Mar 16, 2026
11 checks passed
@jekkos
jekkos deleted the fix/debit-filter-missing branch March 16, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Debit filter not found in Daily Sales or Takings dropdown.

1 participant