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
c0b30c38
Commit
c0b30c38
authored
Jan 11, 2023
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caissier can see the total amount of the transactions received since last fetch
parent
c8a82722
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
163 additions
and
4 deletions
+163
-4
PrestatairesController.php
src/Controller/PrestatairesController.php
+52
-1
Prestataire.php
src/Entity/Prestataire.php
+19
-0
Version20230111102816.php
src/Migrations/Version20230111102816.php
+31
-0
FluxRepository.php
src/Repository/FluxRepository.php
+9
-1
AppExtension.php
src/Twig/AppExtension.php
+21
-0
admin_caissier.html.twig
templates/themes/kohinos/block/admin_caissier.html.twig
+4
-2
caissier_get_last_transactions.html.twig
...ohinos/tav/block/caissier_get_last_transactions.html.twig
+13
-0
last_transactions_amount.html.twig
...tes/themes/kohinos/tav/last_transactions_amount.html.twig
+13
-0
payment_done_page.html.twig
templates/themes/kohinos/tav/payment_done_page.html.twig
+1
-0
No files found.
src/Controller/PrestatairesController.php
View file @
c0b30c38
...
...
@@ -5,20 +5,25 @@ namespace App\Controller;
use
App\Entity\Groupe
;
use
App\Entity\Prestataire
;
use
App\Entity\Rubrique
;
use
App\Entity\Flux
;
use
Doctrine\ORM\EntityManagerInterface
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\Routing\Annotation\Route
;
use
Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted
;
use
Symfony\Component\HttpFoundation\Session\SessionInterface
;
use
Symfony\Component\Routing\RouterInterface
;
class
PrestatairesController
extends
FrontController
{
protected
$em
;
private
$router
;
private
$session
;
public
function
__construct
(
EntityManagerInterface
$em
,
RouterInterface
$router
)
public
function
__construct
(
EntityManagerInterface
$em
,
RouterInterface
$router
,
SessionInterface
$session
)
{
$this
->
em
=
$em
;
$this
->
router
=
$router
;
$this
->
session
=
$session
;
}
/**
...
...
@@ -141,4 +146,50 @@ class PrestatairesController extends FrontController
'prestataires'
=>
$this
->
em
->
getRepository
(
Prestataire
::
class
)
->
findByRubrique
(
$rubrique
),
]);
}
/**
* Get the total transactions amount towards the Prestataire since the last time it was fetched
*
* @Route("/prestataires/get_last_transactions", name="get_presta_last_transactions")
* @IsGranted({"ROLE_CAISSIER", "ROLE_PRESTATAIRE"})
*/
public
function
getLastTransactionsAmount
()
{
if
(
!
$this
->
session
->
has
(
'_prestagere'
))
{
return
null
;
}
// Get last export datetime (presta creation if first export)
$presta
=
$this
->
em
->
getRepository
(
Prestataire
::
class
)
->
findOneById
(
$this
->
session
->
get
(
'_prestagere'
)
->
getId
());
$datetime_last_export
=
$presta
->
getLastTransactionsExportDatetime
();
if
(
null
==
$datetime_last_export
)
{
$datetime_last_export
=
$presta
->
getCreatedAt
();
}
// Get total amount
$flux
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getQueryByPrestataire
(
$this
->
session
->
get
(
'_prestagere'
),
null
,
null
,
$datetime_last_export
->
format
((
"Y-m-d H:i:s"
))
)
->
getResult
();
$total_amount
=
0
;
foreach
(
$flux
as
$flux_item
)
{
$total_amount
+=
$flux_item
->
getMontant
();
}
// Set now as this presta last export date
$presta
->
setLastTransactionsExportDatetime
(
new
\Datetime
(
'now'
));
$this
->
em
->
persist
(
$presta
);
$this
->
em
->
flush
();
$str_datetime
=
$datetime_last_export
->
format
(
'd/m/Y H\hi'
);
return
$this
->
render
(
'@kohinos/tav/last_transactions_amount.html.twig'
,
[
'amount'
=>
$total_amount
,
'datetime_last_export'
=>
$str_datetime
]);
}
}
src/Entity/Prestataire.php
View file @
c0b30c38
...
...
@@ -301,6 +301,13 @@ class Prestataire extends AccountableObject implements AccountableInterface
*/
private
$comments
;
/**
* Caissiers can export all the transactions since the last export.
*
* @ORM\Column(type="datetime", nullable=true)
*/
private
$lastTransactionsExportDatetime
;
public
function
__construct
()
{
$this
->
users
=
new
ArrayCollection
();
...
...
@@ -1101,4 +1108,16 @@ class Prestataire extends AccountableObject implements AccountableInterface
{
return
'mapcontentpresta'
;
}
public
function
getLastTransactionsExportDatetime
()
:
?
\DateTimeInterface
{
return
$this
->
lastTransactionsExportDatetime
;
}
public
function
setLastTransactionsExportDatetime
(
?
\DateTimeInterface
$lastTransactionsExportDatetime
)
:
self
{
$this
->
lastTransactionsExportDatetime
=
$lastTransactionsExportDatetime
;
return
$this
;
}
}
src/Migrations/Version20230111102816.php
0 → 100644
View file @
c0b30c38
<?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
Version20230111102816
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 prestataire ADD last_transactions_export_datetime DATETIME DEFAULT NULL, CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\''
);
}
public
function
down
(
Schema
$schema
)
:
void
{
// this down() migration is auto-generated, please modify it to your needs
$this
->
addSql
(
'ALTER TABLE prestataire DROP last_transactions_export_datetime, CHANGE iban iban LONGTEXT CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_general_ci` COMMENT \'(DC2Type:personal_data)\''
);
}
}
src/Repository/FluxRepository.php
View file @
c0b30c38
...
...
@@ -29,10 +29,12 @@ class FluxRepository extends ServiceEntityRepository
/**
* @param Prestataire $presta [description]
* @param string $parenttype Parent type of flux (cotisation, transfert, transaction, vente...)
* @param string $type Type of flux (cotisation, transfert, transaction, vente...)
* @param string $from Date from which to fetch the flux
*
* @return Query Returns a query fo finding an array of Flux
*/
public
function
getQueryByPrestataire
(
Prestataire
$presta
,
string
$parenttype
=
null
,
string
$type
=
null
)
public
function
getQueryByPrestataire
(
Prestataire
$presta
,
string
$parenttype
=
null
,
string
$type
=
null
,
$from
=
null
)
{
$sqlQuery
=
"SELECT f.id FROM
{
$this
->
tableName
}
f WHERE (f.prestataire_id = :id OR f.prestataire_dest_id = :id)"
;
if
(
null
!=
$parenttype
)
{
...
...
@@ -41,6 +43,9 @@ class FluxRepository extends ServiceEntityRepository
if
(
$type
!=
null
)
{
$sqlQuery
.=
" AND f.type = :type"
;
}
if
(
$from
!=
null
)
{
$sqlQuery
.=
" AND f.created_at >= :from"
;
}
$statement
=
$this
->
connection
->
prepare
(
$sqlQuery
);
if
(
null
!=
$parenttype
)
{
$statement
->
bindValue
(
':type'
,
$parenttype
);
...
...
@@ -48,6 +53,9 @@ class FluxRepository extends ServiceEntityRepository
if
(
$type
!=
null
)
{
$statement
->
bindValue
(
':type'
,
$type
);
}
if
(
$from
!=
null
)
{
$statement
->
bindValue
(
':from'
,
$from
);
}
$statement
->
bindValue
(
':id'
,
$presta
->
getId
());
$statement
->
execute
();
$results
=
$statement
->
fetchAll
();
...
...
src/Twig/AppExtension.php
View file @
c0b30c38
...
...
@@ -104,6 +104,7 @@ class AppExtension extends AbstractExtension
new
\Twig_SimpleFunction
(
'getPaymentReceiptUrlFromFlux'
,
[
$this
,
'getPaymentReceiptUrlFromFlux'
]),
new
\Twig_SimpleFunction
(
'getDonType'
,
[
$this
,
'getDonType'
]),
new
\Twig_SimpleFunction
(
'getLastTavCotisationForAdherent'
,
[
$this
,
'getLastTavCotisationForAdherent'
]),
new
\Twig_SimpleFunction
(
'getPrestaLastTransactionsExportDate'
,
[
$this
,
'getPrestaLastTransactionsExportDate'
]),
new
\Twig_SimpleFunction
(
'parameter'
,
function
(
$name
)
{
return
$this
->
container
->
getParameter
(
$name
);
}),
...
...
@@ -525,4 +526,24 @@ class AppExtension extends AbstractExtension
return
str_replace
(
'@'
,
'@'
,
$email
);
}
public
function
getPrestaLastTransactionsExportDate
(
?
Adherent
$adherent
=
null
)
{
if
(
!
$this
->
session
->
has
(
'_prestagere'
))
{
return
null
;
}
$presta
=
$this
->
em
->
getRepository
(
Prestataire
::
class
)
->
findOneById
(
$this
->
session
->
get
(
'_prestagere'
)
->
getId
());
$datetime_last_export
=
$presta
->
getLastTransactionsExportDatetime
();
$res
=
""
;
if
(
null
==
$datetime_last_export
)
{
$res
=
$presta
->
getCreatedAt
()
->
format
(
'd/m/Y H\hi'
);
}
else
{
$res
=
$datetime_last_export
->
format
(
'd/m/Y H\hi'
);
}
return
$res
;
}
}
templates/themes/kohinos/block/admin_caissier.html.twig
View file @
c0b30c38
...
...
@@ -3,5 +3,7 @@
{%
include
'@kohinos/block/solde.html.twig'
with
{
'compte'
:
getCurrentPrestataire
()
.
emlcAccount.balance
,
'soldelabel'
:
esoldelabel
,
'currency'
:
'e'
~
(
KOH_MLC_SYMBOL
|
default
(
''
))
}
%}
{%
include
'@kohinos/tav/block/encaisser_paiement.html.twig'
%}
{%
include
'@kohinos/tav/block/caissier_get_last_transactions.html.twig'
with
{
'title'
:
'Transactions'
}
%}
{%
else
%}
{%
include
'@kohinos/block/transactions.html.twig'
with
{
'title'
:
'Transactions'
}
%}
{%
endif
%}
\ No newline at end of file
{%
include
'@kohinos/block/transactions.html.twig'
with
{
'title'
:
'Transactions'
}
%}
\ No newline at end of file
templates/themes/kohinos/tav/block/caissier_get_last_transactions.html.twig
0 → 100644
View file @
c0b30c38
{%
extends
'@kohinos/block/block_collapse.html.twig'
%}
{%
block
blocktitle
%}
<i
class=
"fa fa-list-alt mr-4"
></i>
{{
'Transactions'
|
trans
}}
{%
endblock
blocktitle
%}
{%
block
blockcontent
%}
{%
set
datetime_last_export
=
getPrestaLastTransactionsExportDate
()
%}
<p>
Récupérer le montant total des transactions depuis le
<b>
{{
datetime_last_export
}}
</b></p>
<a
class=
'btn btn-xs btn-primary mt-2'
href=
'
{{
path
(
'get_presta_last_transactions'
)
}}
'
>
{{
'Exporter'
|
trans
}}
</a>
{%
endblock
blockcontent
%}
templates/themes/kohinos/tav/last_transactions_amount.html.twig
0 → 100644
View file @
c0b30c38
{%
extends
'@kohinos/common/layout.html.twig'
%}
{%
block
content
%}
<div
class=
'container'
style=
'max-width: 800px;'
>
{%
include
'@kohinos/block/breadcrumb.html.twig'
with
{
'label'
:
'Total des transactions'
}
%}
<div
class=
"text-center w-100"
>
<p
style=
"font-size:1.1em"
>
Montant total des transactions depuis le
{{
datetime_last_export
}}
:
<b>
{{
amount
}}
e-mlc
</b>
</p>
</div>
</div>
{%
endblock
%}
templates/themes/kohinos/tav/payment_done_page.html.twig
View file @
c0b30c38
...
...
@@ -24,6 +24,7 @@
{{
'Nouvel encaissement'
|
trans
}}
</a>
</div>
</div>
{%
endblock
%}
{%
block
footer
%}{%
endblock
footer
%}
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