Commit Graph
11 Commits
Author SHA1 Message Date
objecttothisandClaude Sonnet 5 054d01265e Merge remote-tracking branch 'OpensourcePOS/master' into feat-export-toggle-all
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-06 15:10:28 +04:00
objecttothis f5233b20e6 refactor(cashups): extract value object and focused methods in Cashups controller (#4786)
Introduce a CashupAmounts transfer object and break down large Cashups
controller methods into focused private helpers. Includes a breaking
change to constructor parameter order.

- Add CashupAmounts (TransferObjects/Cashups) to bundle open/transfer/
  closed cash, due, card, and check amounts; reorder constructor params
  to cash-before-due sequence
- Replace positional _calculate_total() with calculateTotal(CashupAmounts),
  eliminating argument-order errors
- Decompose getView() into buildEmployeeLookup(), normalizeCashupInfo(),
  initializeNewCashup(), isPendingClose(), closeCashup(),
  buildReportDateRangeInputs(), applyPaymentTotals(), subtractCashExpenses()
- Decompose postSave() with parseCashupDate() and getCashupAmountsFromPost()
  helpers; update both CashupAmounts call sites to new param order
- Rename snake_case vars/params to camelCase throughout Cashups controller
- Drop stale TODO comments in OSPOS.php and Cashups::getIndex filter block
- Scope escape => false to cashup_headers() note column rather than a
  broad regex exclusion in transform_headers()
- Add CashupFixtureTrait and ExpenseFixtureTrait under tests/Support;
  tighten cashup view test to assertSeeInField on specific form fields

BREAKING CHANGE: CashupAmounts constructor positional argument order
changed — closedAmountCash now precedes closedAmountDue; any callers
passing positional args must swap those two arguments.

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-11-02 03:59:07 +04:00
objecttothis 09e2c945fb test: replace OsposConfigFixtureTrait with Appconfig model persistence
- Remove OsposConfigFixtureTrait usage across test suite; settings are
  now written through model(Appconfig::class)->batch_save() instead of
  mocking the OSPOS config object directly
- OSPOSRulesTest keeps direct Config\OSPOS injection via
  Factories::injectMock since it tests config-object behavior directly
- CashupControllerTest, ItemKitsControllerTest, GetItemDataRowTest,
  LocaleHelperTest, export_helperTest, tabular_helperTest switch to
  real DB-backed settings via Appconfig model
- GetItemDataRowTest, LocaleHelperTest, export_helperTest,
  tabular_helperTest add DatabaseTestTrait/DatabaseBootstrapTrait and
  migrate/seed config plus resetDatabaseOnce() in setUp()
- export_helperTest consolidates redundant parent::setUp() calls
  scattered across individual test methods into a single call

This aligns tests with how settings are actually read at runtime
(DB-backed Appconfig) rather than relying on a config-mocking fixture
trait, reducing drift between test setup and production behavior.

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-10-23 15:36:11 +04:00
objecttothis 2a42079262 test: align export/report tests with shared fixtures and date filters
- CashupControllerTest: add start_date/end_date params to export-all
  CSV/PDF requests and update expected totals/body assertions to
  match seeded cashup data (closed_amount_total 169.42).
- ExpensesControllerTest: replace manual seeder bootstrap with shared
  DatabaseBootstrapTrait::resetDatabaseOnce, and grant
  expenses_categories permission to test employee for category access.
- ReportsControllerTest: invoke buildDownloadHeaders on response
  before asserting Content-Disposition, matching actual download flow.
- export_helperTest / tabular_helperTest: replace manual OSPOS config
  mock construction (Factories::injectMock) with shared
  OsposConfigFixtureTrait::injectOsposSettings, reducing duplication
  and adding missing number_locale/currency_symbol settings.

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-10-23 11:21:25 +04:00
objecttothis 33efb401bf Merge remote-tracking branch 'OpensourcePOS/master' into feat-export-toggle-all
# Conflicts:
#	composer.json
#	composer.lock
#	tests/Controllers/CashupControllerTest.php
#	tests/Controllers/EmployeesControllerTest.php
#	tests/Controllers/ItemKitsControllerTest.php
#	tests/Controllers/SalesControllerTest.php
#	tests/Controllers/TaxesControllerTest.php
#	tests/Helpers/export_helperTest.php
#	tests/Helpers/tabular_helperTest.php
#	tests/Helpers/tax_helperTest.php
2026-10-23 11:20:22 +04:00
objecttothisandClaude Sonnet 5 af48fa4357 fix(tests): standardize DB bootstrap/OSPOS mocking, fix stale-prefix bug (#4771)
Adds DatabaseBootstrapTrait and OsposConfigFixtureTrait to replace
duplicated per-file setUp()/tearDown() bootstrap and OSPOS config mock
boilerplate across test classes, bringing them in line with the
ItemsControllerTest gold-standard shape.

Fixes the real root cause of tabular_helperTest's suite-order-dependent
failure: dropAllForeignKeyConstraints()/foreignKeyExists()/
dropColumnIfExists() temporarily blank the shared connection's DBPrefix
via overridePrefix() but never restored it if the query between the two
calls threw (e.g. migration_helperTest's mocked-failure tests) -
permanently corrupting prefixed table lookups for the rest of the
process. Wrapped each in try/finally. Also widens executeScript() to
accept an explicit connection so migration SQL can't silently run
against the wrong DB group.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-23 10:10:37 +04:00
objecttothisandClaude Sonnet 5 0015b7575c Revert "Merge remote-tracking branch 'OpensourcePOS/master' into fix-unit-test-failures" and test-standardization commit (#4770)
These landed on master by accident via a local branch that was
mistakenly created tracking OpensourcePOS/master directly, rather than
pushed as its own branch. Reverting to restore master to its prior
state; the reverted work will come back through a proper PR instead.

This reverts commit 00bf4cb8af.
This reverts commit 37cc1b15e7.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-22 16:43:32 +04:00
objecttothisandClaude Sonnet 5 37cc1b15e7 fix(tests): standardize DB bootstrap/OSPOS mocking, fix stale-prefix bug
Adds DatabaseBootstrapTrait and OsposConfigFixtureTrait to replace
duplicated per-file setUp()/tearDown() bootstrap and OSPOS config mock
boilerplate across test classes, bringing them in line with the
ItemsControllerTest gold-standard shape.

Fixes the real root cause of tabular_helperTest's suite-order-dependent
failure: dropAllForeignKeyConstraints()/foreignKeyExists()/
dropColumnIfExists() temporarily blank the shared connection's DBPrefix
via overridePrefix() but never restored it if the query between the two
calls threw (e.g. migration_helperTest's mocked-failure tests) -
permanently corrupting prefixed table lookups for the rest of the
process. Wrapped each in try/finally. Also widens executeScript() to
accept an explicit connection so migration SQL can't silently run
against the wrong DB group.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-22 16:26:48 +04:00
objecttothis 41618feef4 fix(tests): improve DownloadResponse handling in export tests
- Add `downloadResponseBody()` helper to all controller export tests for asserting streamed download content (CSV/PDF).
- Update export test endpoints to explicitly include query parameters, e.g., `?search=` for consistency.
- Resolve private `$binary` access via reflection to verify download contents in exports.
- Fix issues with headers (`Content-Disposition` and `Content-Type`) and body assertions.

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-10-21 16:45:28 +04:00
objecttothis 4bc2bac204 test: add export-all coverage across controllers and helpers
Add feature tests verifying CSV/PDF/XML/SQL export endpoints work
correctly across many controllers, plus helper unit tests and shared
fixtures to support them.

- Add downloadResponseBody() reflection helper (reads private $binary
  property on DownloadResponse) to CashupControllerTest,
  EmployeesControllerTest, ItemKitsControllerTest for asserting
  streamed download content
- Add exportAll CSV/PDF tests for Attributes, Customers,
  Expenses_categories, Expenses, Giftcards, ItemKits, Cashup,
  Employees controllers
- Add export_helperTest covering CSV sanitization (formula injection
  guard), JSON/XML/SQL writers, tag sanitization, and file generation
- Add Tests/Support/ExportFixtureTrait with reusable fixture objects
  for sales, employees, customers, suppliers, items, giftcards,
  item kits, attributes, expenses, cashups, tax rates
- Update AGENTS.md: clarify `use` import rule applies to every
  reference including global-namespace classes
  (ReflectionClass/ReflectionProperty/Exception) and method-signature
  type-hints, not just namespaced app classes

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-10-21 15:47:09 +04:00
jekkos edcb4bb655 Fix GHSA-frx7-c5vv-m3mr: recompute cashup total server-side and force owner identity (#4706)
* Fix GHSA-frx7-c5vv-m3mr: recompute cashup total server-side and force owner identity

* Add required description field to cashup test POSTs
2026-09-21 17:37:07 +02:00