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
557bb863
Commit
557bb863
authored
Mar 20, 2024
by
Yvon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SEPA file generation for all on going reconversions
parent
6e65ae81
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
3 deletions
+114
-3
.gitignore
.gitignore
+3
-0
twig.yaml
config/packages/twig.yaml
+3
-2
ReconversionAdmin.php
src/Admin/ReconversionAdmin.php
+4
-0
FluxController.php
src/Controller/FluxController.php
+98
-1
list.html.twig
...mes/kohinos/bundles/SonataAdminBundle/CRUD/list.html.twig
+6
-0
No files found.
.gitignore
View file @
557bb863
...
...
@@ -66,3 +66,6 @@ templates/themes/custom/
#INTELLIJ
.idea/
#dir containg exported reconversions xml
/reconversions/
config/packages/twig.yaml
View file @
557bb863
...
...
@@ -14,4 +14,5 @@ twig:
tav_env
:
'
%env(TAV_ENV)%'
presta_self_init_and_eval
:
'
%env(PRESTA_SELF_INIT_AND_EVAL)%'
presta_extra_data
:
'
%env(PRESTA_EXTRA_DATA)%'
household_based_allowance
:
'
%env(HOUSEHOLD_BASED_ALLOWANCE)%'
\ No newline at end of file
household_based_allowance
:
'
%env(HOUSEHOLD_BASED_ALLOWANCE)%'
automatisation_reconversion
:
'
%env(AUTOMATISATION_RECONVERSION)%'
\ No newline at end of file
src/Admin/ReconversionAdmin.php
View file @
557bb863
...
...
@@ -96,4 +96,8 @@ class ReconversionAdmin extends FluxAdmin
'Reconverti ?'
=>
'reconverti'
,
];
}
public
function
isReconversionAdmin
()
{
return
true
;
}
}
src/Controller/FluxController.php
View file @
557bb863
...
...
@@ -2,11 +2,13 @@
namespace
App\Controller
;
use
AndrewSvirin\Ebics\Builders\CustomerCreditTransfer\CustomerCreditTransferBuilder
;
use
App\Entity\Adherent
;
use
App\Entity\Don
;
use
App\Entity\Flux
;
use
App\Entity\Groupe
;
use
App\Entity\Prestataire
;
use
App\Entity\Reconversion
;
use
App\Entity\User
;
use
App\Enum\CurrencyEnum
;
use
App\Flux\FluxInterface
;
...
...
@@ -16,6 +18,7 @@ use App\Utils\TAVCotisationUtils;
use
FOS\UserBundle\Model\UserManagerInterface
;
use
FOS\UserBundle\Util\TokenGeneratorInterface
;
use
Gamez\Symfony\Component\Serializer\Normalizer\UuidNormalizer
;
use
Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted
;
use
Sonata\Exporter\Handler
;
use
Sonata\Exporter\Source\DoctrineORMQuerySourceIterator
;
use
Sonata\Exporter\Writer\CsvWriter
;
...
...
@@ -30,6 +33,7 @@ use Symfony\Component\HttpFoundation\Response;
use
Symfony\Component\HttpFoundation\Session\SessionInterface
;
use
Symfony\Component\HttpFoundation\StreamedResponse
;
use
Symfony\Component\Routing\Annotation\Route
;
use
Symfony\Component\Routing\RouterInterface
;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\Security\Csrf\CsrfTokenManagerInterface
;
use
Symfony\Component\Serializer\Encoder\JsonEncoder
;
...
...
@@ -75,6 +79,7 @@ class FluxController extends AbstractController
protected
$tokenGenerator
;
protected
$validator
;
protected
$userManager
;
protected
$router
;
public
function
__construct
(
Security
$security
,
...
...
@@ -88,7 +93,8 @@ class FluxController extends AbstractController
TokenGeneratorInterface
$tokenGenerator
,
ValidatorInterface
$validator
,
CsrfTokenManagerInterface
$tokenManager
,
UserManagerInterface
$userManager
UserManagerInterface
$userManager
,
RouterInterface
$router
)
{
$this
->
security
=
$security
;
$this
->
em
=
$em
;
...
...
@@ -102,6 +108,7 @@ class FluxController extends AbstractController
$this
->
tokenManager
=
$tokenManager
;
$this
->
tavCotisationsUtils
=
$tavCotisationsUtils
;
$this
->
userManager
=
$userManager
;
$this
->
router
=
$router
;
}
protected
function
manageFluxForm
(
Request
$request
,
Form
$form
,
$template
=
'@kohinos/flux/transaction.html.twig'
,
$params
=
[])
...
...
@@ -171,6 +178,96 @@ class FluxController extends AbstractController
}
/**
* @param Request $request
* @Route("/credit-transfer-file", name="credit_transfer_file")
* @IsGranted({"ROLE_TRESORIER", "ROLE_SUPER_ADMIN"})
* @return Response
*/
public
function
creditTransferFileAction
(
Request
$request
)
{
//fetch mlc prestataire and make sure bic, iban are not empty
$mlcPrestataire
=
$this
->
em
->
getRepository
(
Prestataire
::
class
)
->
findOneBy
([
'mlc'
=>
true
]);
if
(
!
$mlcPrestataire
->
getIban
()
||
!
$mlcPrestataire
->
getBic
())
{
$this
->
addFlash
(
'sonata_flash_error'
,
"Opération annulée car l'IBAN ou le BIC du prestataire mlc est vide."
);
return
$this
->
redirect
(
$this
->
router
->
generate
(
'index'
)
.
'admin/app/reconversion/list'
);
}
//SEPA
$builder
=
new
CustomerCreditTransferBuilder
();
$customerCreditTransfer
=
$builder
->
createInstance
(
$mlcPrestataire
->
getBic
(),
$mlcPrestataire
->
getIban
(),
$mlcPrestataire
->
getRaison
()
);
$reconversions
=
$this
->
em
->
getRepository
(
Reconversion
::
class
)
->
findBy
([
"reconverti"
=>
false
]);
if
(
!
$reconversions
)
{
$this
->
addFlash
(
'sonata_flash_error'
,
"Aucune reconversion à traiter."
);
return
$this
->
redirect
(
$this
->
router
->
generate
(
'index'
)
.
'admin/app/reconversion/list'
);
}
foreach
(
$reconversions
as
$r
)
{
/* @var Reconversion $r */
/* @var Prestataire $presta */
$presta
=
$r
->
getExpediteur
();
if
(
!
$presta
||
!
$presta
->
isEnabled
())
{
//fail ; do not flush : we don't want to toggle reconverti when file can't be generated
$this
->
addFlash
(
'sonata_flash_error'
,
"Opération annulée car le prestataire "
.
$presta
->
getRaison
()
.
" est désactivé ou introuvable."
);
return
$this
->
redirect
(
$this
->
router
->
generate
(
'index'
)
.
'admin/app/reconversion/list'
);
}
if
(
!
$presta
->
getIban
()
||
!
$presta
->
getBic
())
{
//fail ; do not flush : we don't want to toggle reconverti when file can't be generated
$this
->
addFlash
(
'sonata_flash_error'
,
"Opération annulée car l'IBAN ou le BIC du prestataire "
.
$presta
->
getRaison
()
.
" est vide."
);
return
$this
->
redirect
(
$this
->
router
->
generate
(
'index'
)
.
'admin/app/reconversion/list'
);
}
$customerCreditTransfer
->
addTransaction
(
$presta
->
getBic
(),
$presta
->
getIban
(),
$presta
->
getRaison
(),
$r
->
getMontant
(),
'EUR'
,
'Reconversion MonA vers EUR'
);
$r
->
setReconverti
(
true
);
}
$filename
=
sprintf
(
'credit_transfer_file_%s.%s'
,
date
(
'Y_m_d_H_i_s'
,
strtotime
(
'now'
)),
'xml'
);
//projectDir is composer.json
$dir
=
$this
->
getParameter
(
'kernel.project_dir'
)
.
"/reconversions"
;
if
(
!
is_dir
(
$dir
))
{
mkdir
(
$dir
,
0777
,
true
);
}
$path
=
$dir
.
"/"
.
$filename
;
$customerCreditTransfer
->
popInstance
()
->
save
(
$path
);
$this
->
em
->
flush
();
return
$this
->
file
(
$path
);
}
/**
* Export all operations for a user role.
*
* @param Request $request Request
...
...
templates/themes/kohinos/bundles/SonataAdminBundle/CRUD/list.html.twig
View file @
557bb863
...
...
@@ -33,6 +33,12 @@
</li>
{%
endfor
%}
</ul>
{%
if
tav_env
and
automatisation_reconversion
and
admin.isReconversionAdmin
is
defined
and
admin.isReconversionAdmin
%}
<a
href=
"
{{
path
(
'credit_transfer_file'
)
}}
"
type=
"button"
class=
"btn btn-default"
>
<i
class=
"fa fa-share-square-o"
aria-hidden=
"true"
></i>
Générer SEPA
</a>
{%
endif
%}
</div>
</div>
{%
if
admin.total
is
defined
and
admin.total
>
0
%}
...
...
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