# Banking App

## Overview

The Banking App is a **free addon** provided by [TGG Banking](https://teamsgg.dev/scripts/banking) that integrates seamlessly with the [YSeries](https://teamsgg.dev/scripts/yseries) resource. This app allows players to manage their bank accounts directly from their phone, including viewing account balances, transaction history, transferring funds, and managing multiple account types.

## Requirements

### Required Resource

The Banking App **requires** the **tgg-banking** resource to be installed and running on your server. Without this resource, the Banking App will display an unavailable message and will not function.

* **Minimum Version**: tgg-banking v1.2.3+
* **Resource Link**: [Get TGG Banking](https://teamsgg.dev/scripts/banking)

### Resource Detection

The Banking App automatically detects when the tgg-banking resource starts or stops, updating its availability in real-time. If the resource is stopped, the app will show an unavailable screen. When the resource starts again, the app will automatically become available.

![Unavailable Screen](https://r2.fivemanage.com/image/RVRgosj6ouf9.png)

## Features

* **Account Management**: View all bank accounts (Personal, Business, Shared, Savings)
* **Transaction History**: Browse transaction history with pagination and infinite scroll
* **Money Transfers**: Transfer funds between accounts with validation
* **Account Details**: View detailed account information including IBAN, balance, and account type
* **Savings Accounts**: Special handling for savings accounts with maturity dates and interest information
* **Account Refresh**: Manual refresh button to update account balances and transactions
* **Multiple Account Types**: Support for personal, business, shared, and savings accounts
* **Managing Loan Accounts**: Support for loan accounts with repayment schedules and interest rates
* **Managing Savings accounts**: Support for savings accounts with maturity dates and interest information

### User Interface

The Banking App features a clean, modern interface with:

* **Accounts Tab**: Browse all available accounts with balance overview

![Accounts Dashboard](https://r2.fivemanage.com/image/lLcWQemdlFUp.png)

* **Transfer Tab**: Transfer money between accounts

![Transfer Screen](https://r2.fivemanage.com/image/QAnv10gqmK01.png)

* **Account Details**: Tap any account to view detailed information and transaction history

![Account Details](https://r2.fivemanage.com/image/9fkNQ8bs627H.png)

* **Refresh Button**: Manually refresh account data from the header
* **Responsive Design**: Works seamlessly on all YSeries phone models

## Banking App Limitations

⚠️ **Important**: The Banking App **only supports tgg-banking** and will not work with other banking systems. It is specifically designed as a free addon for tgg-banking users.

## Alternative: YPay Application

If you're using a different banking system, you can use the **YPay** application instead. YPay uses **framework functions only** and does not require any banking integration. It works seamlessly with any framework (QBCore, ESX, QBox, or Standalone) that provides standard account management functions.

### How YPay Works

YPay uses the framework abstraction layer (`Framework.GetPlayerFromId()`, `getAccount()`, `addAccountMoney()`, `removeAccountMoney()`) to interact with player bank accounts. This means:

* ✅ **No banking integration required** - YPay works with any framework out of the box
* ✅ **No tgg-banking dependency** - YPay operates independently
* ✅ **Framework-agnostic** - Works with QBCore, ESX, QBox, or Standalone frameworks

**Server-side integration**: `server/apps/framework/banking/your-banking.lua`\
**Client-side integration**: `client/apps/framework/banking/your-banking.lua`

YPay automatically uses your framework's built-in account management system, so no additional configuration or integration files are needed.

***

## Banking Integration for Companies App

⚠️ **Note**: The banking integration files (`server/apps/framework/banking/`) are used by the **Companies App** for managing company funds (deposits, withdrawals, etc.), not by YPay.

If you need to integrate a custom banking system for company management features:

1. **Set Banking Configuration**
   * Navigate to `config/config.companies.lua`
   * Set `Config.Companies.Banking = 'your_banking_resource_name'`
2. **Implement Required Functions**
   * Open `server/apps/framework/banking/your-banking.lua`
   * Implement the following functions:
     * `GetAccountMoney(accountName)` - Retrieve account balance
     * `AddAccountMoney(accountName, amount)` - Add money to account
     * `RemoveAccountMoney(accountName, amount)` - Remove money from account
     * `AddTransaction(sender, recipient, amount, description)` - Record transactions
3. **Test Integration**
   * Restart your server
   * Verify YPay transfers work correctly
   * Check transaction history is being recorded

For detailed implementation examples, refer to `server/apps/framework/banking/tgg-banking.lua` as a reference implementation.

## Troubleshooting

If the Banking App shows as unavailable:

1. Verify tgg-banking resource is installed and started
2. Check server console for any dependency errors
3. Ensure tgg-banking version meets minimum requirements (v1.2.2+)
4. Ensure yseries is updated to the latest version
5. Restart both yseries and tgg-banking resources if issues persist

***

* ⚠️ **Note**: The Banking App is provided free of charge as an addon for tgg-banking users.
