Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
e09330cc
Commit
e09330cc
authored
May 06, 2024
by
Yvon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ccas : 6228 : create balanceCcas and update amount at each transaction if required
parent
8dd2a2a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
AccountPrestataire.php
src/Entity/AccountPrestataire.php
+22
-0
Version20240506132104.php
src/Migrations/Version20240506132104.php
+33
-0
OperationUtils.php
src/Utils/OperationUtils.php
+8
-0
No files found.
src/Entity/AccountPrestataire.php
View file @
e09330cc
...
@@ -31,6 +31,11 @@ class AccountPrestataire extends Account
...
@@ -31,6 +31,11 @@ class AccountPrestataire extends Account
*/
*/
protected
$operations
;
protected
$operations
;
/**
* @ORM\Column(type="decimal", scale=2, options={"default": 0.00})
*/
protected
$balanceCcas
=
0.00
;
public
function
__construct
()
public
function
__construct
()
{
{
$this
->
operations
=
new
ArrayCollection
();
$this
->
operations
=
new
ArrayCollection
();
...
@@ -57,4 +62,21 @@ class AccountPrestataire extends Account
...
@@ -57,4 +62,21 @@ class AccountPrestataire extends Account
{
{
return
$this
->
getPrestataire
();
return
$this
->
getPrestataire
();
}
}
public
function
getBalanceCcas
()
:
?
float
{
return
$this
->
balanceCcas
;
}
/**
* Can be negative amount.
*
* @param float $montant Used during a transaction to ncrement or decrement balance of CCAS transactions
*/
public
function
addAmountCcas
(
float
$montant
)
:
self
{
$this
->
balanceCcas
+=
$montant
;
return
$this
;
}
}
}
src/Migrations/Version20240506132104.php
0 → 100644
View file @
e09330cc
<?php
declare
(
strict_types
=
1
);
namespace
DoctrineMigrations
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\Migrations\AbstractMigration
;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final
class
Version20240506132104
extends
AbstractMigration
{
public
function
getDescription
()
:
string
{
return
''
;
}
public
function
up
(
Schema
$schema
)
:
void
{
// this up() migration is auto-generated, please modify it to your needs
$this
->
addSql
(
'ALTER TABLE account_prestataire ADD balance_ccas NUMERIC(10, 2) DEFAULT \'0\' NOT NULL'
);
$this
->
addSql
(
'ALTER TABLE prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\''
);
}
public
function
down
(
Schema
$schema
)
:
void
{
// this down() migration is auto-generated, please modify it to your needs
$this
->
addSql
(
'ALTER TABLE account_prestataire DROP balance_ccas'
);
$this
->
addSql
(
'ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_general_ci` COMMENT \'(DC2Type:personal_data)\''
);
}
}
src/Utils/OperationUtils.php
View file @
e09330cc
...
@@ -17,6 +17,7 @@ use App\Entity\OperationPrestataire;
...
@@ -17,6 +17,7 @@ use App\Entity\OperationPrestataire;
use
App\Entity\OperationSiege
;
use
App\Entity\OperationSiege
;
use
App\Entity\Prestataire
;
use
App\Entity\Prestataire
;
use
App\Entity\Siege
;
use
App\Entity\Siege
;
use
App\Entity\Transaction
;
use
App\Enum\CurrencyEnum
;
use
App\Enum\CurrencyEnum
;
use
App\Enum\MoyenEnum
;
use
App\Enum\MoyenEnum
;
use
App\Events\FluxEvent
;
use
App\Events\FluxEvent
;
...
@@ -134,6 +135,13 @@ class OperationUtils
...
@@ -134,6 +135,13 @@ class OperationUtils
);
);
// $account->addOperation($operation);
// $account->addOperation($operation);
$account
->
addAmount
(
$operation
->
getMontant
());
$account
->
addAmount
(
$operation
->
getMontant
());
if
(
$flux
instanceof
Transaction
//only process $flux with getIsCcas method
&&
$flux
->
getIsCcas
()
//check if this flux should increment ccas balance
&&
$account
instanceof
AccountPrestataire
//only process the prestataire side of the flux
)
{
$account
->
addAmountCcas
(
$operation
->
getMontant
());
}
$em
->
persist
(
$operation
);
$em
->
persist
(
$operation
);
$em
->
persist
(
$account
);
$em
->
persist
(
$account
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment