Receipt service technical description
The receipt service main purpose is to create receipts from carts that have been fully paid. When a receipt is created, the service gathers information from different services, it gets the articles of the cart and cartSum from the cart, the store data from masterdata service, the payments done to the cart from payment service and the cashier data from the JWT. All this data is put together to create receipt, and once is created is sent to the tlogcreator service through asynchronous messaging using Rabbitmq, where is then transformed to a data format for SAP processing.
There is another type of requests processed by receipt service where printing instructions in XML can be generated for JPOS printers or Epson printers, a template in XML is used where the different values of a receipt are processed, formatted and transformed using Thymeleaf library. To produce printing instructions for a specific type of printer a header named "printer" can be added to the request, JPOS printing instructions are generated by default, by setting the header value to "epson", the response will contain the printing instructions for Epson printers.
If the service is required to support generating printing instructions for other printer manufacturers is advised to add another value to the header that will generate the instructions for the new type of printer. Another thing to do is to create another template using the Thymeleaf template engine syntax, the structure and implementation to generate printing instructions will depend on the particular syntax and capabilities the new type of printer offers.
Receipts can be queried using the library QueryDSL, it allows flexible queries where many receipt attribute values can be given as request parameters, all sorts of combinations of request parameters can be provided in the requests.
Details of the endpoints provided by this service can be found here.
- spring-boot-starter-data-jpa: Starter for using Spring Data JPA with Hibernate.
- spring-boot-starter-thymeleaf: Starter for building MVC web applications using Thymeleaf views. (servlet-based) and non-web environments
- spring-boot-starter-data-mongodb: MongoDB support for Spring Data.
- spring-data-commons: Spring Data Core.
- thymeleaf: Thymeleaf is a Java XML/XHTML/HTML5 template engine that can work both in web.
- mongo-driver: MongoDB Driver uber-artifact that combines mongodb-driver-sync and the legacy driver.
- spring-data-querydsl-value-operators: Spring Data Querydsl Value Operators decorates Spring Data’s Querydsl integration by providing various value operators to create flexible and rich search (or querying) capabilities on RESTful resources. For folks in hurry, this library decorates on top of Spring Data and Querydsl to provide rich, reusable, plug-and-play type of framework for complex searches.
- spring-boot-starter-amqp: Starter for using Spring AMQP and Rabbit MQ.
- gson: Gson is a Java library that can be used to convert Java Objects into their JSON representation.
- authjwt: OneX dependency to access custom data in JWTs.
- spring-cloud-starter-openfeign: A declarative REST client for Spring Boot apps.
- spring-cloud-starter-netflix-ribbon: Ribbon is a client-side load balancer that gives you a lot of control over the behavior of HTTP and TCP clients.
- springfox-swagger2: JSON API documentation for spring based applications.
- flapdoodle: Embedded MongoDB will provide a platform neutral way for running mongodb in unittests.
- junit: JUnit is a unit testing framework for Java programming language. It plays a crucial role test-driven development, and is a family of unit testing frameworks collectively known as xUnit.