Project 'cooperatic/kohinos-tav' was moved to 'agplv3/kohinos-tav'. Please update any links and bookmarks that may still have the old path.
Commit 58c040b6 by Damien Moulard

Merge branch '6178-mark-ccas-transactions' into 'ssa-gironde'

6178 mark ccas transactions

See merge request cooperatic/kohinos-tav!92
parents 8cb62efb 9a862467
......@@ -294,6 +294,11 @@ class UserController extends AbstractController
$flux->setMontant($montant);
$flux->setMoyen(MoyenEnum::MOYEN_EMLC);
// The flux to cancel a ccas flux is also marked as ccas
if ($this->getParameter('ccas_mode')) {
$flux->setIsCcas($transactionAdherentPrestataire->getIsCcas());
}
$now = (new \Datetime('now'))->format('d/m/Y H:i:s');
$flux->setReference(
'Remboursement en Monnaie Solidaire du ' . $now . ' annule ' . $transactionAdherentPrestataire->getReference()
......@@ -459,6 +464,16 @@ class UserController extends AbstractController
$now = (new \Datetime('now'))->format('d/m/Y H:i:s');
$flux->setReference('Achat en Monnaie Solidaire du ' . $now);
// Mark transaction as CCAS if at the time of the transation, both adherent & presta are CCAS complient
if (
$this->getParameter('ccas_mode')
&& $adherent->getCcasEligible()
&& $adherent->getCcasAccepted()
&& $presta->getCcasOk()
) {
$flux->setIsCcas(true);
}
$this->em->persist($flux);
$this->operationUtils->executeOperations($flux);
$this->em->flush();
......
......@@ -152,7 +152,7 @@ class Adherent extends AccountableObject implements AccountableInterface
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private $ccasEligible;
private $ccasEligible = false;
/**
* @ORM\Column(type="string", length=36, nullable=true, unique=true)
......
......@@ -381,7 +381,7 @@ class Prestataire extends AccountableObject implements AccountableInterface
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private $ccasOk;
private $ccasOk = false;
public function __construct()
......
......@@ -31,6 +31,13 @@ class Transaction extends Flux
const TYPE_TRANSACTION_PRESTATAIRE_ADHERENT = 'prestataire_adherent';
const TYPE_TRANSACTION_PRESTATAIRE_PRESTATAIRE = 'prestataire_prestataire';
/**
* A transaction is marked as CCAS if both parties are CCAS compliant.
*
* @ORM\Column(type="boolean", options={"default": false})
*/
protected $isCcas = false;
public static function getAvailableTypes(): array
{
return [
......@@ -84,4 +91,16 @@ class Transaction extends Flux
{
return [];
}
public function getIsCcas(): ?bool
{
return $this->isCcas;
}
public function setIsCcas(bool $isCcas): self
{
$this->isCcas = $isCcas;
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 Version20240503101225 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 flux ADD is_ccas TINYINT(1) DEFAULT \'0\'');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE flux DROP is_ccas');
}
}
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