Class InvoicesService
java.lang.Object
de.bytestore.hostinger.ecommerce.service.InvoicesService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecuteCreateWebhook(io.jmix.core.event.EntitySavingEvent<Invoice> eventIO) voidexecuteUpdateWebhook(io.jmix.core.event.EntityChangedEvent<Invoice> eventIO) booleanChecks if a given Invoice entity exists in the database.generateContent(Invoice invoiceIO) Generates the content for an invoice by retrieving associated products, calculating totals, and populating a template with the required data.voidgeneratePDF(Invoice invoiceIO) Generates a PDF for the provided invoice and saves it to a specified location.generatePDFStream(Invoice invoiceIO) Generates a PDF stream for the given invoice.getInvoicePath(Invoice invoiceIO) Generates the file path for the invoice PDF based on the given invoice object.getProductsCount(Invoice invoice) Calculates and returns the total count of products associated with a given invoice.getProductsFor(Invoice entity) Retrieves a list of InvoiceProduct entities associated with the given Invoice entity.doublegetProductsPrice(Invoice invoice) Calculates the total price of all products associated with the specified invoice.voidload()voidonApplicationStarted(org.springframework.boot.context.event.ApplicationStartedEvent event) voidwebhooks()
-
Constructor Details
-
InvoicesService
public InvoicesService()
-
-
Method Details
-
onApplicationStarted
@EventListener public void onApplicationStarted(org.springframework.boot.context.event.ApplicationStartedEvent event) -
load
public void load() -
getInvoicesByMonth
-
generatePDF
Generates a PDF for the provided invoice and saves it to a specified location.- Parameters:
invoiceIO- the Invoice object for which the PDF will be generated
-
generatePDFStream
Generates a PDF stream for the given invoice. The method takes an Invoice object, generates the corresponding PDF content, and returns it as a ByteArrayOutputStream. If the input invoice is null or does not contain a valid ID, the method will return null. If any exception occurs during the PDF generation process, a RuntimeException will be thrown.- Parameters:
invoiceIO- the Invoice object for which the PDF is to be generated; must not be null and must have a valid ID.- Returns:
- a ByteArrayOutputStream containing the generated PDF content, or null if the input is invalid.
-
generateContent
Generates the content for an invoice by retrieving associated products, calculating totals, and populating a template with the required data.- Parameters:
invoiceIO- the invoice object containing details such as the receiver and other metadata- Returns:
- a string representing the generated content, which is primarily HTML, or an error message in case of issues
-
getProductsCount
Calculates and returns the total count of products associated with a given invoice.- Parameters:
invoice- the Invoice object for which the product count is to be retrieved- Returns:
- the total count of products for the specified invoice
-
getProductsPrice
Calculates the total price of all products associated with the specified invoice.- Parameters:
invoice- the invoice object containing the details of the invoice whose products' total price needs to be calculated- Returns:
- the total price of all products for the specified invoice
-
exitsInDb
Checks if a given Invoice entity exists in the database.- Parameters:
entity- the Invoice entity to check for existence in the database- Returns:
- true if the Invoice entity exists in the database, false otherwise
-
getProductsFor
Retrieves a list of InvoiceProduct entities associated with the given Invoice entity.- Parameters:
entity- the Invoice entity for which associated InvoiceProduct entities are to be retrieved- Returns:
- a list of InvoiceProduct entities associated with the specified Invoice
-
getInvoicePath
Generates the file path for the invoice PDF based on the given invoice object.- Parameters:
invoiceIO- the Invoice object from which the file path is derived- Returns:
- the file path as a String for the invoice PDF
-
webhooks
public void webhooks() -
executeCreateWebhook
-
executeUpdateWebhook
-