Skip to content

feat(economy): add economy module with wallet and transaction system#177

Merged
danielhe4rt merged 1 commit into4.xfrom
feat/economy-module
Mar 17, 2026
Merged

feat(economy): add economy module with wallet and transaction system#177
danielhe4rt merged 1 commit into4.xfrom
feat/economy-module

Conversation

@danielhe4rt
Copy link
Contributor

@danielhe4rt danielhe4rt commented Mar 17, 2026

Summary

  • Adds a new economy module with wallet and transaction functionality
  • Integrates wallet support into the Character model via HasWallet trait

Changes

New Economy Module (app-modules/economy/)

Models:

  • Wallet - Stores balance per currency for any model
  • Transaction - Records all credit/debit/transfer operations

Actions:

  • CreateWallet - Initialize a wallet for a model
  • Credit - Add funds to a wallet
  • Debit - Remove funds from a wallet
  • Transfer - Move funds between wallets

DTOs:

  • CreditDTO, DebitDTO, TransferDTO - Type-safe data transfer objects

Enums:

  • Currency - Supported currency types
  • TransactionType - Transaction categorization

Exceptions:

  • InsufficientBalanceException - Thrown when debit/transfer exceeds balance

Integration

  • Added HasWallet trait to Character model for wallet functionality

Testing

  • Unit tests for Credit, Debit, and Transfer actions
  • Feature tests for complete economy flows

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced a wallet and economy system for managing in-game currency balances
    • Added the ability to credit wallet balances with rewards
    • Added the ability to debit wallet balances for purchases
    • Implemented money transfer functionality between wallets
    • Integrated wallet capabilities with character accounts
    • Added transaction history tracking with balance records for all wallet operations

- Add Wallet and Transaction models with relationships
- Implement Credit, Debit, and Transfer actions with DTOs
- Add HasWallet trait for models that need wallet functionality
- Add Currency and TransactionType enums
- Add InsufficientBalanceException for balance validation
- Integrate HasWallet trait into Character model
- Add comprehensive tests for economy flows
Copy link

@thalesmengue thalesmengue left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@fernanduandrade fernanduandrade left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@DiogoKaster DiogoKaster left a comment

Choose a reason for hiding this comment

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

LGTM!

@danielhe4rt danielhe4rt merged commit c4ceeca into 4.x Mar 17, 2026
5 of 6 checks passed
@danielhe4rt danielhe4rt deleted the feat/economy-module branch March 17, 2026 00:42
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request introduces a new economy module as a Laravel package at app-modules/economy/. The module implements wallet and transaction management through Eloquent models, database migrations, and action classes. It includes factories for seeding test data, DTOs for type-safe data handling, enums for currency and transaction types, exception handling, and Blade view templates. A reusable HasWallet trait enables models to manage wallets. Unit and feature tests validate the credit, debit, and transfer operations. The module is registered as a service provider and integrated into the existing Character model. The package is added as a dependency in the root composer.json.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: introducing a new economy module with wallet and transaction functionality.

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

📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can use your project's `phpmd` ruleset to improve the quality of PHP code reviews.

You can customize the ruleset in your CodeRabbit configuration, or provide a path to a custom ruleset file.

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.

6 participants