mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-09-21 10:15:01 -04:00
* fix(items): validate item_number and skip receiving quantity default for temp items - Validate item_number against alpha_numeric_punct rule, return JSON error on failure - Add item_number_invalid language string * i18n: reorder Items language keys and add item_number_invalid string Add item_number_invalid translation across all locale files and resort surrounding keys alphabetically to match key ordering convention. * PSR-12 refactoring. - Change local variable to camelCase. - Use single quote in language files. * i18n: translate item_number_invalid string in ta, th, tl, zh-Hans Item_number_invalid key had English placeholder text in Tamil, Thai, Tagalog, Chinese Simplified language files. Translate to match each locale. * fix(items): use FormatRules for item_number validation * refactor(items): use camelCase for variable names * refactor(items): use camelCase for variable names in Items controller
2.7 KiB
2.7 KiB
Agent Instructions
This document provides guidance for AI agents working on the Open Source Point of Sale (OSPOS) codebase.
Code Style
- PSR-12 enforced via PHP-CS-Fixer (config:
.php-cs-fixer.no-header.php) - Follow PHP CodeIgniter 4 coding standards
camelCasefor variables and methods;PascalCasefor classes;UPPER_CASEfor constants- PHP 8.2+ features acceptable (named arguments, enums, readonly properties)
- Write PHP 8.2+ compatible code with proper type declarations
- Views in
app/Views/errors/html/are excluded from the fixer - Run fixer before committing:
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.no-header.php - JavaScript: use
constfor variables that are never reassigned,letfor variables that are. Never usevar.
Development
- Create a new git worktree for each issue, based on the latest state of
origin/master - Commit fixes to the worktree and push to the remote
Testing
- Run PHPUnit tests:
composer test - Tests must pass before submitting changes
Build
- Install dependencies:
composer install && npm install - Build assets:
npm run buildorgulp
Conventions
- Controllers go in
app/Controllers/ - Models go in
app/Models/ - Views go in
app/Views/ - Database migrations in
app/Database/Migrations/ - Use CodeIgniter 4 framework patterns and helpers
- Sanitize user input; escape output using
esc()helper
Localization
- When adding new keys to language files, add the key to all
app/Language/*/variants - New keys must be inserted in alphabetical order within the language array
- Non-English files must use an empty string (
'') as the value when no translation is provided — CodeIgniter automatically falls back to the default (en) language. This applies only when a translation genuinely isn't available yet. - When explicitly asked to translate a phrase for a non-English language file, always provide the actual translation — never leave the value as an empty string, and never leave source English text in a non-English language file
- Never copy English text from a neighboring key as a value for a non-English language file, even if that neighboring key is already untranslated — evaluate each key independently
- Only
app/Language/en/andapp/Language/en-GB/should contain English strings - Plugin language files (
app/Plugins/*/Language/) follow the same localization rules asapp/Language/ - Use
'to encapsulate key and string values. If the value contains'then it should be escaped as\'
Security
- Never commit secrets, credentials, or
.envfiles - Use parameterized queries to prevent SQL injection
- Validate and sanitize all user input