Commit 8c015025 by Damien Moulard

add entity for third party allocation fundings, keep track of fundings at…

add entity for third party allocation fundings, keep track of fundings at cotisation, add admin menu
parent 50b074b8
......@@ -99,6 +99,12 @@ $(document).ready(function() {
linksToProductsFamily[i].parentNode.style.display = (tav_env === "1") ? "" : "none";
}
}
let linksToThirdPartyFinancers = $('a[href="/admin/app/thirdpartyfinancer/list"]');
for(let i = 0 ; i < linksToThirdPartyFinancers.length ; i++) {
if(linksToThirdPartyFinancers[i].innerText === "Liste") {
linksToThirdPartyFinancers[i].closest("li.treeview").style.display = (tav_env === "1" && household_based_allowance === "1") ? "" : "none";
}
}
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
......
......@@ -263,6 +263,7 @@ sonata_admin:
icon: '<i class="fa fa-handshake-o"></i>'
items:
- admin.thirdPartyFinancers
- admin.thirdPartyAllocationFunding
# sonata.admin.group.helloasso:
# keep_open: false
# on_top: true
......
......@@ -725,6 +725,17 @@ services:
calls:
- [ setSecurity, ['@security.helper']]
admin.thirdPartyAllocationFunding:
class: App\Admin\ThirdPartyAllocationFundingAdmin
arguments: [~, App\Entity\ThirdPartyAllocationFunding, 'App\Controller\CRUD\CRUDController']
tags:
- name: sonata.admin
manager_type: orm
group: "thirdPartyFinancers"
label: "Prises en charge"
pager_type: "simple"
public: true
sonata.media.provider.csv:
class: App\Admin\ImportProvider
tags:
......
......@@ -3359,9 +3359,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001589",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz",
"integrity": "sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==",
"version": "1.0.30001760",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001760.tgz",
"integrity": "sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw==",
"dev": true,
"funding": [
{
......@@ -3376,7 +3376,8 @@
"type": "github",
"url": "https://github.com/sponsors/ai"
}
]
],
"license": "CC-BY-4.0"
},
"node_modules/chalk": {
"version": "2.4.2",
......@@ -12880,9 +12881,9 @@
}
},
"caniuse-lite": {
"version": "1.0.30001589",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz",
"integrity": "sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==",
"version": "1.0.30001760",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001760.tgz",
"integrity": "sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw==",
"dev": true
},
"chalk": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,7 +12,7 @@
"admin": {
"js": [
"/build/runtime.6ad5c9da.js",
"/build/admin.3f7739a8.js"
"/build/admin.63735322.js"
],
"css": [
"/build/admin.4de55830.css"
......
......@@ -2,7 +2,7 @@
"build/app.css": "/build/app.ec67f059.css",
"build/app.js": "/build/app.3644f7b2.js",
"build/admin.css": "/build/admin.4de55830.css",
"build/admin.js": "/build/admin.3f7739a8.js",
"build/admin.js": "/build/admin.63735322.js",
"build/runtime.js": "/build/runtime.6ad5c9da.js",
"build/images/fa-solid-900.svg": "/build/images/fa-solid-900.a838c42a.svg",
"build/images/fa-brands-400.svg": "/build/images/fa-brands-400.05d20183.svg",
......
<?php
namespace App\Admin;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\Form\Type\DateTimeRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Sonata\AdminBundle\Route\RouteCollection;
use App\Entity\Adherent;
/**
* Administration des simili flux représentant les prises en charges des tiers financeurs.
* Un flux dans le Kohinos comprend un échange d'eMlc, c'est pourquoi cette entité n'est pas un flux.
*
* KOHINOS : Outil de gestion de Monnaie Locale Complémentaire
*/
class ThirdPartyAllocationFundingAdmin extends AbstractAdmin
{
protected function configureDatagridFilters(DatagridMapper $datagrid): void
{
$datagrid
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type' => DateTimeRangePickerType::class,
'show_filter' => true,
'label' => 'Date',
])
->add('thirdPartyFinancer', null, [
'label' => 'Tiers financeur',
'show_filter' => true,
'advanced_filter' => false,
])
->add('adherent', null, [
'label' => 'Adhérent',
'show_filter' => true,
'advanced_filter' => false,
])
;
}
protected function configureListFields(ListMapper $list): void
{
$subject = $this->getSubject();
$list
->addIdentifier('created_at', 'datetime', [
'label' => 'Date'
])
->addIdentifier('amount', null, [
'label' => 'Montant'
])
->addIdentifier('adherent', null, [
'label' => 'Adhérent'
])
->addIdentifier('thirdPartyFinancer', null, [
'label' => 'Tiers financeur'
])
->addIdentifier('cotisationFlux.montant', null, [
'label' => 'Montant cotisé'
])
->addIdentifier('allocationAmount', null, [
'label' => 'Allocation'
])
->addIdentifier('reference', null, [
'label' => 'Référence'
])
;
}
public function getExportFields()
{
return [
'Date' => 'created_at',
'Montant' => 'amount',
'Adhérent' => 'adherent.fullname',
'Tiers financeur' => 'thirdPartyFinancer',
'Montant cotisé' => 'cotisationFlux.montant',
'Allocation' => 'allocationAmount',
'Référence' => 'reference',
];
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(['list', 'export']);
}
}
\ No newline at end of file
......@@ -7,6 +7,9 @@ use Gedmo\Timestampable\Traits\TimestampableEntity;
use Doctrine\ORM\Mapping as ORM;
/**
* Stores the information that a third party financer funded an adherent as (s)he gets their allocation.
* This is not a Flux as it doesn't includes an eMlc exchange.
*
* @ORM\Entity(repositoryClass=ThirdPartyAllocationFundingRepository::class)
*/
class ThirdPartyAllocationFunding
......@@ -47,6 +50,11 @@ class ThirdPartyAllocationFunding
private $allocationFlux;
/**
* @ORM\Column(type="float", options={"default": 0.00})
*/
private $allocationAmount = 0;
/**
* @ORM\Column(type="string", length=255)
*/
private $reference;
......@@ -127,4 +135,16 @@ class ThirdPartyAllocationFunding
return $this;
}
public function getAllocationAmount(): ?float
{
return $this->allocationAmount;
}
public function setAllocationAmount(float $allocationAmount): self
{
$this->allocationAmount = $allocationAmount;
return $this;
}
}
......@@ -9,6 +9,12 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Third party entities that participate to fund adherent allocations.
* Each Adhérent can only be supported by one Third Party Financer.
* Each time an adherent gets his allowance :
* - the flux of cosisation and reversement are created as usual
* - create a ThirdPartyAllocationFunding instance to save the information that the financer supported funded [fundingAmount] among the reversement amount
*
* @ORM\Entity(repositoryClass=ThirdPartyFinancerRepository::class)
*/
class ThirdPartyFinancer
......
<?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 Version20260107094340 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 third_party_allocation_funding ADD allocation_amount DOUBLE PRECISION DEFAULT \'0\' NOT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE third_party_allocation_funding DROP allocation_amount');
}
}
......@@ -12,6 +12,7 @@ use App\Entity\Siege;
use App\Entity\Flux;
use App\Entity\CotisationTavReversement;
use App\Entity\CotisationTavPrelevement;
use App\Entity\ThirdPartyAllocationFunding;
use App\Enum\MoyenEnum;
use App\Repository\PaymentRepository;
use App\Utils\CustomEntityManager;
......@@ -307,7 +308,8 @@ class TAVCotisationUtils
/**
* Method called to create Flux based on allowance amount (for household based allowance).
* Only create flux if amount paid != allowance amount.
* Only create flux if amount paid != allowance amount.
* Also creates a ThirdPartyAllocationFunding instance if needed.
*/
public function applyHouseholdAllowance(Flux $flux) {
// get allowance
......@@ -345,7 +347,30 @@ class TAVCotisationUtils
$fluxCotis->setExpediteur($siege);
$fluxCotis->setDestinataire($adherent);
$fluxCotis->setMontant($amountDiff);
$fluxCotis->setReference("Versement de l'allocation complémentaire après paiement de " . $cotisationAmount . "€ pour atteindre une allocation de " . $mlcAllowanceAmount . " MonA.");
$fluxCotisRef = "Versement de l'allocation complémentaire après paiement de " . $cotisationAmount . "€ pour atteindre une allocation de " . $mlcAllowanceAmount . " MonA";
$fluxCotis->setReference($fluxCotisRef);
// Create third party funding instance if required
if ($adherent->getThirdPartyFinancer() !== null) {
$thirdparty = $adherent->getThirdPartyFinancer();
$fundingAmount = $thirdparty->getFundingAmount();
$thirdPartyAllocationFunding = new ThirdPartyAllocationFunding();
$thirdPartyAllocationFunding->setThirdPartyFinancer($thirdparty);
$thirdPartyAllocationFunding->setAmount($fundingAmount);
$thirdPartyAllocationFunding->setAdherent($adherent);
$thirdPartyAllocationFunding->setCotisationFlux($flux);
$thirdPartyAllocationFunding->setAllocationFlux($fluxCotis);
$thirdPartyAllocationFunding->setAllocationAmount($mlcAllowanceAmount);
$ref = "Prise en charge du tiers financeur $thirdparty d'un montant de " . $fundingAmount . "€ pour l'adhérent " . $adherent . ", pour sa cotisation de " . $cotisationAmount . "€ avec reversement de $amountDiff MonA";
$thirdPartyAllocationFunding->setReference($ref);
$this->em->persist($thirdPartyAllocationFunding);
// Update allocation flux reference to include third party
$fluxCotisRef .= " ; dont prise en charge de " . $fundingAmount . "€ par le tiers financeur $thirdparty";
$fluxCotis->setReference($fluxCotisRef);
}
} else {
// User should receive less than he•she paid: fetch the difference from his account
$fluxCotis = new CotisationTavPrelevement();
......
......@@ -35,7 +35,7 @@ Modified for MLC from Sonata package.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
{% block favicon %}
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon/favicon-16x16.png">
{% endblock favicon %}
......
......@@ -1852,9 +1852,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001489:
version "1.0.30001589"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz"
integrity sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==
version "1.0.30001760"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001760.tgz"
integrity sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw==
chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.2:
version "2.4.2"
......
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