-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from byjg/bump
Bump
- Loading branch information
Showing
26 changed files
with
2,032 additions
and
1,456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: PHPUnit | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "*.*.*" | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
Build: | ||
runs-on: 'ubuntu-latest' | ||
container: 'byjg/php:${{ matrix.php-version }}-cli' | ||
strategy: | ||
matrix: | ||
php-version: | ||
- "8.1" | ||
- "8.0" | ||
- "7.4" | ||
- "7.3" | ||
- "7.2" | ||
- "7.1" | ||
|
||
services: | ||
mysql: | ||
image: bitnami/mysql:8.0.20 | ||
env: | ||
MYSQL_ROOT_PASSWORD: password | ||
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password | ||
ports: | ||
- "3306:3306" | ||
options: >- | ||
--health-cmd="mysqladmin ping" | ||
--health-interval=10s | ||
--health-timeout=20s | ||
--health-retries=10 | ||
env: | ||
MYSQL_TEST_URI: "mysql://root:password@mysql/accounttest" | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: composer install | ||
- run: ./vendor/bin/phpunit | ||
|
||
# Documentation: | ||
# runs-on: 'ubuntu-latest' | ||
# needs: Build | ||
# if: github.ref == 'refs/heads/master' | ||
# env: | ||
# DOC_GITHUB_TOKEN: '${{ secrets.DOC_TOKEN }}' | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - run: curl https://opensource.byjg.com/add-doc.sh | bash /dev/stdin php accounts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ vendor | |
/src/*.db | ||
node_modules | ||
.usdocker | ||
.phpunit.result.cache |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug current Script in Console", | ||
"type": "php", | ||
"request": "launch", | ||
"program": "${file}", | ||
"cwd": "${fileDirname}", | ||
"port": 9003, | ||
"runtimeArgs": [ | ||
"-dxdebug.start_with_request=yes" | ||
], | ||
"env": { | ||
"XDEBUG_MODE": "debug,develop", | ||
"XDEBUG_CONFIG": "client_port=${port}" | ||
} | ||
}, | ||
{ | ||
"name": "PHPUnit Debug", | ||
"type": "php", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/vendor/bin/phpunit", | ||
"cwd": "${workspaceFolder}", | ||
"port": 9003, | ||
"runtimeArgs": [ | ||
"-dxdebug.start_with_request=yes" | ||
], | ||
"env": { | ||
"XDEBUG_MODE": "debug,develop", | ||
"XDEBUG_CONFIG": "client_port=${port}" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,87 @@ | ||
[WIP] Basic PHP Account Statements | ||
# Basic PHP Account Statements | ||
|
||
This is a simple PHP application that allows you to create and manage account statements. It consists of a set of classes to allow control and get statements of any account. | ||
|
||
It supports the following features: | ||
|
||
- Multiple accounts per user; | ||
- Multiple currencies per account | ||
- Transaction history to avoid changes in the balance; | ||
|
||
## How to use | ||
|
||
### Installation | ||
|
||
```bash | ||
composer require "byjg/account-statements" | ||
``` | ||
|
||
### Basic usage | ||
|
||
```php | ||
use ByJG\AccountStatements\Bll\AccountBLL; | ||
use ByJG\AccountStatements\Bll\AccountTypeBLL; | ||
use ByJG\AccountStatements\Bll\StatementBLL; | ||
use ByJG\AccountStatements\Entity\AccountTypeEntity; | ||
use ByJG\AccountStatements\Repository\AccountRepository; | ||
use ByJG\AccountStatements\Repository\AccountTypeRepository; | ||
use ByJG\AccountStatements\Repository\StatementRepository; | ||
use ByJG\AccountStatements\DTO\StatementDTO; | ||
|
||
|
||
// Initiate Repositories | ||
$accountTypeRepo = new AccountTypeRepository($this->dbDriver); | ||
$statementRepo = new StatementRepository($this->dbDriver); | ||
$accountRepo = new AccountRepository($this->dbDriver); | ||
|
||
// Initiate BLLs | ||
$accountTypeBLL = new AccountTypeBLL($accountTypeRepo); | ||
$statementBLL = new StatementBLL($statementRepo, $accountRepo); | ||
$accountBLL = new AccountBLL($accountRepo, $accountTypeBLL, $statementBLL); | ||
|
||
// Create a new Account Type | ||
$accountType = new AccountTypeEntity(); | ||
$accountType->setAccountTypeId('USD'); | ||
$accountType->setName('Dollar Account'); | ||
|
||
$accountTypeBLL = new AccountTypeBLL($accountTypeRepo); | ||
$accountTypeBLL->update($accountType); | ||
|
||
// Create a new Account | ||
$accountRepo = new AccountRepository($this->dbDriver); | ||
$accountId = $accountBLL->createAccount($accountType->getAccountTypeId(), '34', 0); | ||
|
||
// Add 200 USD to the account | ||
$statement = new StatementDTO($accountId, 200); | ||
$statementBLL->addFunds($statement); | ||
|
||
// Withdraw 100 USD from the account | ||
$statement = new StatementDTO($accountId, 100); | ||
$statementBLL->withdrawFunds($statement); | ||
|
||
// Add 50 USD hold to the account | ||
$statement = new StatementDTO($accountId, 50); | ||
$statementId = $statementBLL->reserveFundsForDeposit($statement); | ||
|
||
// Accept the hold | ||
$statementBLL->acceptFundsById($statementId); | ||
``` | ||
|
||
## Installation | ||
|
||
```bash | ||
composer require byjg/account-statements | ||
``` | ||
|
||
## Testing | ||
|
||
```bash | ||
docker run --name mysql-container --rm -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 -d mysql:8.0 | ||
vendor/bin/phpunit | ||
``` | ||
|
||
|
||
|
||
|
||
@todo Documentation | ||
@todo Rest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
ALTER TABLE `account` | ||
CHANGE COLUMN `iduser` `iduser` INT(11) NOT NULL ; | ||
CHANGE COLUMN `userid` `userid` INT(11) NOT NULL ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
ALTER TABLE `account` | ||
CHANGE COLUMN `iduser` `iduser` INT(11) NULL ; | ||
CHANGE COLUMN `userid` `userid` varchar(50) NULL ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
ALTER TABLE `statement` | ||
ADD COLUMN `code` CHAR(3) NULL AFTER `netbalance`; | ||
ADD COLUMN `code` CHAR(5) NULL AFTER `netbalance`; | ||
|
||
ALTER TABLE `statement` | ||
RENAME COLUMN `reference` TO `referenceid`; | ||
|
||
ALTER TABLE `statement` | ||
ADD COLUMN `referencesource` VARCHAR(50) NULL AFTER `referenceid`, | ||
ADD INDEX `fk_statement_referenceid_idx` (`referenceid`), | ||
ADD INDEX `fk_statement_referencesource_idx` (`referencesource`); |
Oops, something went wrong.