mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-03 06:44:27 -04:00
- Create app/Libraries/Reward_lib.php with reward point business logic: - calculatePointsEarned(): calculate rewards from purchase amount - adjustRewardPoints(): deduct/restore/adjust customer points - handleCustomerChange(): handle points when customer changes on sale - adjustRewardDelta(): adjust delta for same customer payment changes - hasSufficientPoints(): validate customer has enough points - getPointsBalance(): get customer points balance - calculateRewardPaymentAmount(): sum reward payments from array - Add tests/Libraries/Reward_libTest.php with 20+ test cases covering: - Points calculation edge cases - Customer change scenarios - Deletion/restore operations - Sufficient points validation - Payment amount calculation - Update tests/phpunit.xml to include Libraries testsuite This extraction centralizes reward logic for better testability and follows the existing library pattern (Tax_lib, Sale_lib, etc.).
652 B
652 B