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
0
Merge Requests
0
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
7bc57959
Commit
7bc57959
authored
Feb 04, 2026
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add error case management in case of duplicate flux in db
parent
e88447c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
+31
-7
CreateAllocationsFromExistingFlux.php
src/Command/CreateAllocationsFromExistingFlux.php
+25
-5
FluxRepository.php
src/Repository/FluxRepository.php
+6
-2
No files found.
src/Command/CreateAllocationsFromExistingFlux.php
View file @
7bc57959
...
@@ -66,7 +66,8 @@ class CreateAllocationsFromExistingFlux extends Command
...
@@ -66,7 +66,8 @@ class CreateAllocationsFromExistingFlux extends Command
// get cotisations that don't have an allocation set
// get cotisations that don't have an allocation set
$fluxRepository
=
$this
->
em
->
getRepository
(
Flux
::
class
);
$fluxRepository
=
$this
->
em
->
getRepository
(
Flux
::
class
);
$cotisations
=
$fluxRepository
->
getTavCotisationsWithoutAllocation
(
$batchAmount
);
$cotisations
=
$fluxRepository
->
getTavCotisationsWithoutAllocation
(
$batchAmount
);
$processedComplementaryFluxIds
=
[];
$count
=
0
;
$count
=
0
;
foreach
(
$cotisations
as
$key
=>
$cotis
)
{
foreach
(
$cotisations
as
$key
=>
$cotis
)
{
// $this->io->success(json_encode($cotis));
// $this->io->success(json_encode($cotis));
...
@@ -83,17 +84,36 @@ class CreateAllocationsFromExistingFlux extends Command
...
@@ -83,17 +84,36 @@ class CreateAllocationsFromExistingFlux extends Command
}
}
$allocation
->
setAdherent
(
$this
->
em
->
getRepository
(
Adherent
::
class
)
->
find
(
$adherent_id
));
$allocation
->
setAdherent
(
$this
->
em
->
getRepository
(
Adherent
::
class
)
->
find
(
$adherent_id
));
// set montant & complementary flux if exists
$complementaryFlux
=
$fluxRepository
->
getRelatedTavAllocationFlux
(
$cotis
[
"id"
]);
$amount
=
floatval
(
$cotis
[
"montant"
]);
$amount
=
floatval
(
$cotis
[
"montant"
]);
if
(
$complementaryFlux
[
"id"
]
!==
null
)
{
/**
* An error can have occured with online payment leading to a payment being processed twice.
* In this case, two flux with a complementary flux for each of them have been created at the same time.
* Then, getRelatedTavAllocationFlux() will return multiple results, so we need not to process the same flux twice.
*
* So we look for a complementary flux that exists and that's not been processed before
*/
$complementaryFlux
=
null
;
$possibleComplementaryFlux
=
$fluxRepository
->
getRelatedTavAllocationFlux
(
$cotis
[
"id"
]);
foreach
(
$possibleComplementaryFlux
as
$f
)
{
if
(
$f
[
"id"
]
!==
null
&&
array_search
(
$f
[
"id"
],
$processedComplementaryFluxIds
)
===
false
)
{
$complementaryFlux
=
$f
;
break
;
}
}
if
(
$complementaryFlux
!==
null
)
{
$allocation
->
setComplementaryFlux
(
$fluxRepository
->
find
(
$complementaryFlux
[
"id"
]));
$allocation
->
setComplementaryFlux
(
$fluxRepository
->
find
(
$complementaryFlux
[
"id"
]));
// mark as processed
$processedComplementaryFluxIds
[]
=
$complementaryFlux
[
"id"
];
// if there is a complementary flux, add or subsctract amount to get full allocation amount
if
(
$complementaryFlux
[
"type"
]
==
"reversement_cotisation_adherent"
)
{
if
(
$complementaryFlux
[
"type"
]
==
"reversement_cotisation_adherent"
)
{
$amount
+=
floatval
(
$complementaryFlux
[
"montant"
]);
$amount
+=
floatval
(
$complementaryFlux
[
"montant"
]);
}
else
if
(
$complementaryFlux
[
"type"
]
==
"prelevement_cotisation_adherent"
)
{
}
else
if
(
$complementaryFlux
[
"type"
]
==
"prelevement_cotisation_adherent"
)
{
$amount
-=
floatval
(
$complementaryFlux
[
"montant"
]);
$amount
-=
floatval
(
$complementaryFlux
[
"montant"
]);
}
}
}
}
$allocation
->
setAmount
(
$amount
);
$allocation
->
setAmount
(
$amount
);
...
...
src/Repository/FluxRepository.php
View file @
7bc57959
...
@@ -480,6 +480,8 @@ class FluxRepository extends ServiceEntityRepository
...
@@ -480,6 +480,8 @@ class FluxRepository extends ServiceEntityRepository
/**
/**
* Given a TAV cotisation flux, get the potential complementary flux that completes the full TAV allocation.
* Given a TAV cotisation flux, get the potential complementary flux that completes the full TAV allocation.
* Get a flux that's not been already saved as a complementary flux in allocation.
*
* @see App\Entity\Allocation
* @see App\Entity\Allocation
*
*
* @param int $fluxCotisId, cotisation flux id
* @param int $fluxCotisId, cotisation flux id
...
@@ -497,13 +499,15 @@ class FluxRepository extends ServiceEntityRepository
...
@@ -497,13 +499,15 @@ class FluxRepository extends ServiceEntityRepository
OR f.adherent_dest_id = fb.adherent_dest_id
OR f.adherent_dest_id = fb.adherent_dest_id
)
)
AND fb.type IN ('prelevement_cotisation_adherent', 'reversement_cotisation_adherent')
AND fb.type IN ('prelevement_cotisation_adherent', 'reversement_cotisation_adherent')
WHERE f.id = :fluxId"
;
LEFT JOIN allocation a ON a.complementary_flux_id = fb.id
WHERE f.id = :fluxId
AND a.id IS NULL"
;
$statement
=
$this
->
connection
->
prepare
(
$sqlQuery
);
$statement
=
$this
->
connection
->
prepare
(
$sqlQuery
);
$statement
->
bindValue
(
':fluxId'
,
$fluxCotisId
);
$statement
->
bindValue
(
':fluxId'
,
$fluxCotisId
);
$statement
->
execute
();
$statement
->
execute
();
$results
=
$statement
->
fetchAll
();
$results
=
$statement
->
fetchAll
();
return
$results
[
0
]
;
return
$results
;
}
}
}
}
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