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
cd0105f3
Commit
cd0105f3
authored
Dec 13, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 tav cotisation per month
parent
33b04f78
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
1 deletions
+64
-1
UserAdherentController.php
src/Controller/UserAdherentController.php
+12
-1
UserComptoirController.php
src/Controller/UserComptoirController.php
+10
-0
FluxRepository.php
src/Repository/FluxRepository.php
+25
-0
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+17
-0
No files found.
src/Controller/UserAdherentController.php
View file @
cd0105f3
...
...
@@ -2,6 +2,7 @@
namespace
App\Controller
;
use
App\Entity\Flux
;
use
App\Entity\AchatMonnaieAConfirmerAdherent
;
use
App\Entity\AchatMonnaieAdherent
;
use
App\Entity\Adherent
;
...
...
@@ -139,6 +140,16 @@ class UserAdherentController extends FluxController
// TODO: set CB payment when the functionality is validated
$flux
=
$form
->
getData
();
// Look for existing cotisation
if
(
$this
->
tavCotisationsUtils
->
checkExistingCotisation
(
$flux
))
{
$this
->
addFlash
(
'error'
,
$this
->
translator
->
trans
(
'Cotisation déjà payée ce mois-ci.'
)
);
return
$this
->
redirectToRoute
(
'index'
);
}
if
(
null
==
$flux
->
getDon
()
||
0
==
$flux
->
getDon
()
->
getMontant
())
{
$flux
->
setDon
(
null
);
}
...
...
@@ -152,7 +163,7 @@ class UserAdherentController extends FluxController
$this
->
em
->
flush
();
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Cotisation payée ! [Payzen désactivé en attent du compte
; mensualité pas encore implémentée
]'
)
$this
->
translator
->
trans
(
'Cotisation payée ! [Payzen désactivé en attent du compte]'
)
);
return
$this
->
redirectToRoute
(
'index'
);
...
...
src/Controller/UserComptoirController.php
View file @
cd0105f3
...
...
@@ -202,6 +202,16 @@ class UserComptoirController extends FluxController
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
{
$flux
=
$form
->
getData
();
// Look for existing cotisation
if
(
$this
->
tavCotisationsUtils
->
checkExistingCotisation
(
$flux
))
{
$this
->
addFlash
(
'error'
,
$this
->
translator
->
trans
(
'L\'adhérent•e a déjà payé sa cotisation ce mois-ci.'
)
);
return
$this
->
redirectToRoute
(
'index'
);
}
$destinataire
=
$flux
->
getDestinataire
();
$profile
=
$destinataire
->
getProfilDeCotisation
();
...
...
src/Repository/FluxRepository.php
View file @
cd0105f3
...
...
@@ -239,4 +239,29 @@ class FluxRepository extends ServiceEntityRepository
->
getQuery
()
->
getSingleScalarResult
();
}
/**
* @param Adherent $adherent the user to look the cotisations for
* @param String $from, $to dates (ISO format) between wich to look for
*
* @return Array list of cotisations between the dates
*/
public
function
getTavCotisationsBetweenDates
(
$adherent
,
$from
,
$to
)
{
$sqlQuery
=
"SELECT f.id
FROM
{
$this
->
tableName
}
f
WHERE f.type IN ('achat_monnaie_adherent', 'vente_emlc_adherent')
AND f.created_at >= :f
AND f.created_at <= :t
AND f.adherent_id = :adh_id"
;
$statement
=
$this
->
connection
->
prepare
(
$sqlQuery
);
$statement
->
bindValue
(
':f'
,
$from
);
$statement
->
bindValue
(
':t'
,
$to
);
$statement
->
bindValue
(
':adh_id'
,
$adherent
->
getId
());
$statement
->
execute
();
$results
=
$statement
->
fetchAll
();
return
$results
;
}
}
src/Utils/TAVCotisationUtils.php
View file @
cd0105f3
...
...
@@ -27,6 +27,23 @@ class TAVCotisationUtils
}
/**
* Check if cotisation already exist this month the the recipient of the given Flux.
*/
public
function
checkExistingCotisation
(
Flux
$flux
)
{
$first_day_this_month
=
date
(
'Y-m-01'
);
$last_day_this_month
=
date
(
'Y-m-t'
);
$existing
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getTavCotisationsBetweenDates
(
$flux
->
getDestinataire
(),
$first_day_this_month
,
$last_day_this_month
);
return
count
(
$existing
)
>
0
;
}
/**
* Apply the cotisation profile rate to the amount paid
* and register the complement as a new flux
*
...
...
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