SessionSaleController
extends AbstractController
in package
Management of cash sessions on the web interface.
Allows opening and closing a session, attaching and listing a session's sales, cancelling a sale, validating a session (manager) and generating the detail PDF. Operations are scoped to the point of sale of the authenticated user.
Attributes
- #[IsGranted]
- 'IS_AUTHENTICATED_FULLY'
- #[Route]
- '/session/sale'
Table of Contents
Methods
- cancelSale() : Response
- Cancels a sale attached to a session.
- closeSession() : Response
- Method to end session in progress
- datatable() : JsonResponse
- Provides paginated/filtered cash-session data in the DataTables server-side format.
- generatePdfForSessionDetail() : Response
- Method for generating a pdf for single session
- index() : Response
- Method to displaying a list of sessions
- salesDatatable() : JsonResponse
- Provides the sales attached to a given session in the DataTables server-side format.
- startSession() : Response
- Method to start a new session sale
- valideSessionByManager() : RedirectResponse
- Method to validate a session
- viewSession() : Response
- Method for show a retail of single session
-
calculateSessionTotals()
: array{soldSession: float, montantParModePaiement: array
} - Computes a session's totals: total amount sold and breakdown by payment method.
Methods
cancelSale()
Cancels a sale attached to a session.
public
cancelSale(Sale $sale, int $sessionId, EntityManagerInterface $entityManager) : Response
Checks that the sale belongs to the given session before moving it to the cancelled status.
Parameters
- $sale : Sale
-
Sale to cancel.
- $sessionId : int
-
Identifier of the expected owning session.
- $entityManager : EntityManagerInterface
-
Doctrine entity manager.
Attributes
- #[Route]
- '/cancel-sale/{id}/{sessionId}'
- $name: 'session.sale.cancel'
Return values
Response —Redirect to the session detail.
closeSession()
Method to end session in progress
public
closeSession(EntityManagerInterface $entityManager, mixed $id) : Response
Parameters
- $entityManager : EntityManagerInterface
- $id : mixed
Attributes
- #[Route]
- '/end/{id}'
- $name: 'session.end'
Return values
Responsedatatable()
Provides paginated/filtered cash-session data in the DataTables server-side format.
public
datatable(EntityManagerInterface $entityManager, Request $request, DataTableService $dataTableService) : JsonResponse
Parameters
- $entityManager : EntityManagerInterface
-
Doctrine entity manager.
- $request : Request
-
Request carrying the DataTables parameters.
- $dataTableService : DataTableService
-
Service building the DataTables response.
Attributes
- #[Route]
- '/datatable'
- $name: 'session.datatable'
- $methods: ['GET']
Return values
JsonResponse —DataTables-compatible JSON response.
generatePdfForSessionDetail()
Method for generating a pdf for single session
public
generatePdfForSessionDetail(SessionSale $sessionSale, PdfService $pdfService, EntityManagerInterface $entityManager) : Response
Parameters
- $sessionSale : SessionSale
- $pdfService : PdfService
- $entityManager : EntityManagerInterface
Attributes
- #[Route]
- '/session-detail/{id}'
- $name: 'session.retail.pdf'
Return values
Responseindex()
Method to displaying a list of sessions
public
index(EntityManagerInterface $entityManager) : Response
Parameters
- $entityManager : EntityManagerInterface
Attributes
- #[Route]
- '/'
- $name: 'session.index'
Return values
ResponsesalesDatatable()
Provides the sales attached to a given session in the DataTables server-side format.
public
salesDatatable(SessionSale $sessionSale, EntityManagerInterface $entityManager, Request $request, DataTableService $dataTableService) : JsonResponse
Parameters
- $sessionSale : SessionSale
-
Session whose sales are listed.
- $entityManager : EntityManagerInterface
-
Doctrine entity manager.
- $request : Request
-
Request carrying the DataTables parameters.
- $dataTableService : DataTableService
-
Service building the DataTables response.
Attributes
- #[Route]
- '/session/{id}/sales/datatable'
- $name: 'session.sales.datatable'
- $methods: ['GET']
Return values
JsonResponse —DataTables-compatible JSON response.
startSession()
Method to start a new session sale
public
startSession(EntityManagerInterface $entityManager) : Response
Parameters
- $entityManager : EntityManagerInterface
Attributes
- #[Route]
- '/start'
- $name: 'session.start'
Return values
ResponsevalideSessionByManager()
Method to validate a session
public
valideSessionByManager(SessionSale $sessionSale, EntityManagerInterface $entityManager) : RedirectResponse
Parameters
- $sessionSale : SessionSale
- $entityManager : EntityManagerInterface
Attributes
- #[Route]
- '/valide-session/{id}'
- $name: 'session.valide'
Return values
RedirectResponseviewSession()
Method for show a retail of single session
public
viewSession(SessionSale $sessionSale) : Response
Parameters
- $sessionSale : SessionSale
Attributes
- #[Route]
- '/session/{id}'
- $name: 'session.retail'
Return values
ResponsecalculateSessionTotals()
Computes a session's totals: total amount sold and breakdown by payment method.
private
calculateSessionTotals(SessionSale $sessionSale) : array{soldSession: float, montantParModePaiement: array}
Cancelled sales are ignored; a pending sale with no payment is counted as a deferred payment.
Parameters
- $sessionSale : SessionSale
-
Session to aggregate.
Return values
array{soldSession: float, montantParModePaiement: arrayTotal sold and amounts per payment method.