Commit a1ab80ba by Damien Moulard

Merge branch…

Merge branch '6228-6229-ne-pas-tenir-compte-des-transactions-ccas-dans-les-reconversions-non-ccas-partie-1' into 'ssa-gironde'

6228 6229 ne pas tenir compte des transactions ccas dans les reconversions non ccas partie 1

See merge request cooperatic/kohinos-tav!93
parents 58c040b6 f7374c53
......@@ -83,7 +83,9 @@ class ReconversionMonaPrestatairesCommand extends Command
$prestas = $this->em->getRepository(Prestataire::class)->findBy(['reconversionFrequency' => $reconvmode]);
foreach ($prestas as $p) {
$balance = $p->getEmlcAccount()->getBalance();
//in CCAS_MODE, ccas transactions reconversions are processed separately.
//getBalanceCcas will return 0 if CCAS_MODE is disabled
$balance = $p->getEmlcAccount()->getBalance() - $p->getEmlcAccount()->getBalanceCcas();
if ($balance <= 0) {
continue;
}
......
......@@ -31,6 +31,11 @@ class AccountPrestataire extends Account
*/
protected $operations;
/**
* @ORM\Column(type="decimal", scale=2, options={"default": 0.00})
*/
protected $balanceCcas = 0.00;
public function __construct()
{
$this->operations = new ArrayCollection();
......@@ -57,4 +62,21 @@ class AccountPrestataire extends Account
{
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;
}
}
<?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)\'');
}
}
......@@ -17,6 +17,7 @@ use App\Entity\OperationPrestataire;
use App\Entity\OperationSiege;
use App\Entity\Prestataire;
use App\Entity\Siege;
use App\Entity\Transaction;
use App\Enum\CurrencyEnum;
use App\Enum\MoyenEnum;
use App\Events\FluxEvent;
......@@ -134,6 +135,13 @@ class OperationUtils
);
// $account->addOperation($operation);
$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($account);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment