Skip to content

bank transfer and wallet - payment option added.#4540#4547

Merged
objecttothis merged 4 commits into
masterfrom
feat/payment-type-add
May 15, 2026
Merged

bank transfer and wallet - payment option added.#4540#4547
objecttothis merged 4 commits into
masterfrom
feat/payment-type-add

Conversation

@bhojkamal
Copy link
Copy Markdown
Collaborator

@bhojkamal bhojkamal commented May 14, 2026

image

[Feature]: Add support for additional payment types in Sales (Bank Transfer (QR), Wallet) #4540

Summary by CodeRabbit

  • New Features
    • Added Bank Transfer and Wallet as selectable payment methods.
    • Added filters to view and filter sales by Bank Transfer and Wallet in reports and listings.
  • Localization
    • Added translations for Bank Transfer and Wallet in English (UK/US), Spanish (ES/MX), and French.

Review Change Stack

@bhojkamal bhojkamal requested review from jekkos and objecttothis and removed request for objecttothis May 14, 2026 17:36
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 933f3dbf-cc1f-4a4f-a614-737ffea3828c

📥 Commits

Reviewing files that changed from the base of the PR and between e529d55 and df9d7b0.

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

📝 Walkthrough

Walkthrough

Adds two new payment types, bank_transfer and wallet, across Reports, Receiving, and locale helper options; wires new manage-view filters and boolean search flags in Sales controller; implements corresponding filter handling in Sale model payment-summary and query builder; and adds translations in English (GB/US), Spanish (ES/MX), and French.

Changes

Bank Transfer and Wallet Payment Types

Layer / File(s) Summary
Payment Type Options Registration
app/Controllers/Reports.php, app/Helpers/locale_helper.php, app/Models/Receiving.php
get_payment_type() and get_payment_options() methods now return bank_transfer and wallet entries alongside existing payment type options.
Sales Management Filtering and Query Logic
app/Controllers/Sales.php, app/Models/Sale.php
The manage view filter configuration adds only_bank_transfer and only_wallet options. getSearch() forwards boolean flags; Sale implements corresponding filter logic in get_payments_summary() and add_filters_to_query() using payment_type LIKE localized labels.
Multilingual Support
app/Language/en-GB/Sales.php, app/Language/en/Sales.php, app/Language/es-ES/Sales.php, app/Language/es-MX/Sales.php, app/Language/fr/Sales.php
Translations for bank_transfer and wallet added across five language variants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I hopped through code with a little twitch,
Two new payments found their niche,
Bank transfer and wallet now play,
Filters and languages join the day,
The rabbit smiles and hops away.

🚥 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 'bank transfer and wallet - payment option added' clearly and accurately summarizes the main change: adding Bank Transfer and Wallet as new payment type options throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/payment-type-add

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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/Models/Sale.php`:
- Around line 280-286: The accesses to $filters['only_bank_transfer'] and
$filters['only_wallet'] are not guarded and cause undefined-index warnings;
either add these keys with boolean defaults to the controller's filter
initialization in app/Controllers/Sales.php::getSearch() alongside other
defaults (e.g., only_cash, only_due, only_check) or change the checks in the
model (app/Models/Sale.php) to guard the array access using
!empty($filters['only_bank_transfer']) and !empty($filters['only_wallet']) (also
update the other two occurrences around lines 1521 and 1525) so the code only
reads those keys when present.
🪄 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: 6b7c3f46-6c0b-4198-a8ec-54b5942c2ff8

📥 Commits

Reviewing files that changed from the base of the PR and between 70fb347 and 9f4a2fa.

📒 Files selected for processing (10)
  • app/Controllers/Reports.php
  • app/Controllers/Sales.php
  • app/Helpers/locale_helper.php
  • app/Language/en-GB/Sales.php
  • app/Language/en/Sales.php
  • app/Language/es-ES/Sales.php
  • app/Language/es-MX/Sales.php
  • app/Language/fr/Sales.php
  • app/Models/Receiving.php
  • app/Models/Sale.php

Comment thread app/Models/Sale.php
@objecttothis
Copy link
Copy Markdown
Member

@bhojkamal As I understand it, this change is just adding the dropdown options for these payment types and not actually implementing the payment types themselves. There is a flaw in our implementation of the payment types in that they are being stored in the table as the string representation of whatever language the logged in employee was using at time of sale. We ought to have instead created a static table containing an id and name of the payment type then linked them using a foreign key and the payment method id is what gets stored in the table so you don't have inconsistent data.

Good: We leave your implementation as is and @CodeRabbit creates an issue describing the need I've just explained.
Better: We implement your change but also refactor the code to correctly model the data.

I'll leave it up to you what you want to do but the issue I brought up needs to be addressed at some point.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@objecttothis I'll create the GitHub issue now describing the payment type data modelling flaw you've outlined.


🏁 Script executed:

#!/bin/bash
gh issue create \
  --repo opensourcepos/opensourcepos \
  --title "Refactor: Store payment types using a foreign key instead of localized strings" \
  --body "## Summary

Payment types (e.g. Cash, Debit Card, Bank Transfer, Wallet, etc.) are currently stored in the sales table as the **string representation** of the payment type label in whatever language the logged-in employee was using at the time of sale.

This creates a data integrity problem: a sale recorded by an English-speaking employee is stored as \`\"Cash\"\`, while the same payment type recorded by a Spanish-speaking employee is stored as \`\"Efectivo\"\`. Querying, filtering, and reporting across these records becomes inconsistent and unreliable.

## Proposed Solution

1. Create a new static **\`payment_types\`** table with at minimum the following columns:
   - \`id\` (primary key, integer)
   - \`name\` (canonical/internal identifier, e.g. \`cash\`, \`debit_card\`, \`bank_transfer\`, \`wallet\`)

2. Update the sales (and receiving) tables to store the **\`payment_type_id\`** (foreign key → \`payment_types.id\`) instead of the localized string.

3. Update all queries, filters, and reports that currently match on the localized string (e.g. \`LIKE lang('Sales.bank_transfer')\`) to instead use the numeric foreign key.

4. Keep the language files for display/UI purposes only — translation happens at the presentation layer, not at the storage layer.

## Impact

- \`app/Models/Sale.php\` — \`get_payments_summary()\` and \`add_filters_to_query()\` use \`LIKE lang('Sales.*')\` conditions that are locale-dependent.
- \`app/Controllers/Reports.php\` — \`get_payment_type()\` returns localized labels used for filtering.
- \`app/Controllers/Sales.php\` — filter keys map to locale-dependent query conditions.
- \`app/Helpers/locale_helper.php\` — \`get_payment_options()\` builds options from language strings.
- \`app/Models/Receiving.php\` — \`get_payment_options()\` similarly builds options from language strings.

## Related PR

This issue was identified during the review of `#4547` (Bank Transfer and Wallet payment options), raised by `@objecttothis`."

Length of output: 59


@objecttothis The issue has been created: #4548

Here's a summary of what was captured in the issue:

  • Root cause: Payment types are stored as locale-dependent strings (e.g. "Cash" vs "Efectivo") rather than a stable identifier, leading to inconsistent data across employees using different languages.
  • Proposed fix: Introduce a static payment_types table (id, name) and store the foreign key payment_type_id in the sales/receiving tables instead. Translation stays at the presentation layer only.
  • Affected files called out: app/Models/Sale.php, app/Controllers/Reports.php, app/Controllers/Sales.php, app/Helpers/locale_helper.php, and app/Models/Receiving.php.

The issue also links back to this PR (#4547) and credits @objecttothis as the reporter.

@objecttothis
Copy link
Copy Markdown
Member

Also, I think the change as you have it is a core code change but likely implementing those payment methods (stripe, QR code, etc) we might want to do as a plugin rather than core code, since those plugins may require PCI Compliance work that I don't really want to deal with but plugin authors can manage if they want to develop them. @jekkos, what do you think?

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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/Sales.php`:
- Around line 95-98: The Sales UI uses language keys Sales.bank_transfer and
Sales.wallet but those keys are missing from many language files; open every
Sales.php language file and add entries for 'bank_transfer' and 'wallet' to the
returned translations array (using proper localized text or a sensible fallback
like English), ensuring the same key names used in the controller
('only_bank_transfer' => lang('Sales.bank_transfer') and 'only_wallet' =>
lang('Sales.wallet')) resolve everywhere; verify array syntax and run a quick
load of the app to confirm no untranslated key strings appear.
🪄 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: 9ee3726b-9397-4f18-be79-d51c4576950b

📥 Commits

Reviewing files that changed from the base of the PR and between 9f4a2fa and e529d55.

📒 Files selected for processing (1)
  • app/Controllers/Sales.php

Comment thread app/Controllers/Sales.php Outdated
Comment on lines +95 to +98
'only_debit' => lang('Sales.debit'),
'only_bank_transfer' => lang('Sales.bank_transfer'),
'only_wallet' => lang('Sales.wallet'),
'only_invoices' => lang('Sales.invoice_filter'),
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify that Sales.bank_transfer and Sales.wallet language keys exist in all Sales language files

echo "Checking for 'bank_transfer' key in Sales language files:"
rg -n "['\"](bank_transfer)['\"]" --type=php -g 'app/Language/*/Sales.php'

echo -e "\nChecking for 'wallet' key in Sales language files:"
rg -n "['\"](wallet)['\"]" --type=php -g 'app/Language/*/Sales.php'

echo -e "\nLanguage files that should contain these keys:"
fd -t f 'Sales.php' app/Language/

Repository: opensourcepos/opensourcepos

Length of output: 2349


Add language translations for bank_transfer and wallet keys to all language files.

The new filter options reference language keys Sales.bank_transfer and Sales.wallet, but these are only defined in 5 language files (en, en-GB, es-ES, es-MX, fr). They are missing from 39 other supported language files. This will cause the UI to display untranslated language key names instead of actual translations for the vast majority of users. Add these keys to all remaining language files in app/Language/*/Sales.php to prevent broken UI display.

🤖 Prompt for 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.

In `@app/Controllers/Sales.php` around lines 95 - 98, The Sales UI uses language
keys Sales.bank_transfer and Sales.wallet but those keys are missing from many
language files; open every Sales.php language file and add entries for
'bank_transfer' and 'wallet' to the returned translations array (using proper
localized text or a sensible fallback like English), ensuring the same key names
used in the controller ('only_bank_transfer' => lang('Sales.bank_transfer') and
'only_wallet' => lang('Sales.wallet')) resolve everywhere; verify array syntax
and run a quick load of the app to confirm no untranslated key strings appear.

@bhojkamal
Copy link
Copy Markdown
Collaborator Author

@objecttothis
I’ve added bank_transfer and wallet to the static payment types list. I have used these keys in my CI3 application for the past 4-5 years without issue, so I am implementing them here in CI4 to match the existing static structure. The database keys remain consistent, while the display labels handled by the localization.

The missing initialization is fixed too.
In Controllers/Sales.php in line 90-100 - $data['filters'] is now:
'only_cash' => lang('Sales.cash_filter'),
'only_due' => lang('Sales.due_filter'),
'only_check' => lang('Sales.check_filter'),
'only_creditcard' => lang('Sales.credit_filter'),
'only_debit' => lang('Sales.debit'),
'only_bank_transfer' => lang('Sales.bank_transfer'),
'only_wallet' => lang('Sales.wallet'),

The snapshot is below.

image image

I think, it can be merge now.

@objecttothis
Copy link
Copy Markdown
Member

@objecttothis I’ve added bank_transfer and wallet to the static payment types list. I have used these keys in my CI3 application for the past 4-5 years without issue, so I am implementing them here in CI4 to match the existing static structure. The database keys remain consistent, while the display labels handled by the localization.

The missing initialization is fixed too. In Controllers/Sales.php in line 90-100 - $data['filters'] is now: 'only_cash' => lang('Sales.cash_filter'), 'only_due' => lang('Sales.due_filter'), 'only_check' => lang('Sales.check_filter'), 'only_creditcard' => lang('Sales.credit_filter'), 'only_debit' => lang('Sales.debit'), 'only_bank_transfer' => lang('Sales.bank_transfer'), 'only_wallet' => lang('Sales.wallet'),

I think, it can be merge now.

For the purpose of this PR, this is good enough, but it doesn't resolve the issue I raised in #4548. For example, if you log in as another employee with a different language enabled (that has translations for those phrases) and complete a sale, the transaction history report will show different languages. It was probably done this way before because originally we didn't have per-employee language selection and the flaw only becomes apparent in situations where more than one language is being used. In our use case there are three languages used by our employees, so it becomes obvious quickly.

All that said, we can resolve #4548 in another PR. I'll do a code review right now.

Copy link
Copy Markdown
Member

@objecttothis objecttothis left a comment

Choose a reason for hiding this comment

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

Just these two changes. Otherwise looks good.

Comment thread app/Controllers/Reports.php
Comment thread app/Controllers/Sales.php Outdated
Copy link
Copy Markdown
Member

@objecttothis objecttothis left a comment

Choose a reason for hiding this comment

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

Approved. Let me know if you can't squash and merge.

@objecttothis objecttothis merged commit 8889732 into master May 15, 2026
11 checks passed
jekkos pushed a commit that referenced this pull request May 15, 2026
---------

Co-authored-by: Lotussoft Youngtech <lotussoftyoungtech@gmail.com>
Co-authored-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
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.

2 participants