Class ProductListService
java.lang.Object
sk.iway.iwcm.components.basket.rest.ProductListService
Provides product-category administration and invoice calculation helpers for the basket module.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the outcome of creating a product category. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddItemToInvoice(Long invoiceId, List<Integer> itemIdsToAdd, BasketInvoiceItemsRepository biir, int userId, jakarta.servlet.http.HttpServletRequest request) Adds or increments selected products in an existing invoice.addProductGroup(Identity currentUser, String customData, EditorFacade editorFacade) Creates a product category and its default category page for an authorized user.static DatatablePageImpl<DocDetails>getAllItems(GetAllItemsDocOptions options) Loads products from the selected category tree and prepares prices in the requested currency.getGroupTreeIds(int rootGroupId, DocDetailsRepository repo) Resolves product group identifiers for a selected subtree or all configured product groups.static final IntegergetInvoiceStatusByValues(BigDecimal priceToPayVat, BigDecimal totalPayedPrice) Derives an invoice status by comparing its total price with received payments.static List<LabelValueInteger>getListOfProductGroupsViaIds(String idsString) Parses configured product group identifiers and validates them against the group cache.static List<LabelValueInteger>getListOfProductGroupsViaInclude(DocDetailsRepository docDetailsRepository) Finds product groups from pages containing a basket product-list application.static List<LabelValueInteger>getListOfProductsGroups(DocDetailsRepository docDetailsRepository) Returns product groups from explicit configuration or automatic include detection.static BigDecimalgetPayedPrice(Long invoiceId, BasketInvoicePaymentsRepository bipr) Calculates the total amount of confirmed payments for an invoice.getPriceInfo(Long invoiceId, BasketInvoiceItemsRepository biir, BasketInvoicePaymentsRepository bipr) Returns invoice totals and the status derived from its confirmed payments.static BigDecimalgetPriceToPay(Long invoiceId, BasketInvoiceItemsRepository biir) Calculates the VAT-inclusive total price of all items in an invoice.static voidupdateInvoiceStats(Long invoiceId, boolean updateStatus) static voidupdateInvoiceStats(Long invoiceId, Long browserId, boolean updateStatus) Recalculates invoice item count, totals, balance, and optionally payment status.
-
Method Details
-
getAllItems
Loads products from the selected category tree and prepares prices in the requested currency.- Parameters:
options- repositories, request data, paging, and selected group information- Returns:
- prepared product page for the administration DataTable
-
getGroupTreeIds
Resolves product group identifiers for a selected subtree or all configured product groups.- Parameters:
rootGroupId- root group identifier, or a value below one to use all product groupsrepo- document repository used to detect configured product groups- Returns:
- identifiers of groups included in the product listing
-
addProductGroup
public static ProductListService.AddingStatus addProductGroup(Identity currentUser, String customData, EditorFacade editorFacade) Creates a product category and its default category page for an authorized user.- Parameters:
currentUser- user requesting category creationcustomData- JSON containing the parent group identifier and new group nameeditorFacade- editor facade used to create the category page- Returns:
- status describing whether the category was created, already existed, or failed validation
-
getListOfProductsGroups
public static List<LabelValueInteger> getListOfProductsGroups(DocDetailsRepository docDetailsRepository) Returns product groups from explicit configuration or automatic include detection.- Parameters:
docDetailsRepository- repository used to detect pages containing product-list applications- Returns:
- configured product groups sorted as a tree
-
getListOfProductGroupsViaInclude
public static List<LabelValueInteger> getListOfProductGroupsViaInclude(DocDetailsRepository docDetailsRepository) Finds product groups from pages containing a basket product-list application. Detected groups are expanded to their complete subtrees and sorted for selection.- Parameters:
docDetailsRepository- repository used to search page content- Returns:
- detected product groups sorted as a tree
-
getListOfProductGroupsViaIds
Parses configured product group identifiers and validates them against the group cache. An identifier followed by*includes the complete subtree of that group.- Parameters:
idsString- comma- or plus-separated group identifiers- Returns:
- valid configured product groups sorted as a tree
-
updateInvoiceStats
-
updateInvoiceStats
Recalculates invoice item count, totals, balance, and optionally payment status.- Parameters:
invoiceId- invoice whose totals are updatedbrowserId- browser identifier used to select items, ornullto use the invoice identifierupdateStatus- whether to derive the invoice status from invoice and payment totals
-
getPriceToPay
Calculates the VAT-inclusive total price of all items in an invoice.- Parameters:
invoiceId- invoice identifierbiir- invoice item repository- Returns:
- total price, zero for an empty invoice, or
-1for an invalid identifier
-
getPayedPrice
Calculates the total amount of confirmed payments for an invoice.- Parameters:
invoiceId- invoice identifierbipr- invoice payment repository- Returns:
- confirmed payment total, zero when no payments exist, or
-1for a null identifier
-
getPriceInfo
public static Map<String,String> getPriceInfo(Long invoiceId, BasketInvoiceItemsRepository biir, BasketInvoicePaymentsRepository bipr) Returns invoice totals and the status derived from its confirmed payments.- Parameters:
invoiceId- invoice identifierbiir- invoice item repositorybipr- invoice payment repository- Returns:
- string values for price to pay, paid price, and derived status
-
getInvoiceStatusByValues
public static final Integer getInvoiceStatusByValues(BigDecimal priceToPayVat, BigDecimal totalPayedPrice) Derives an invoice status by comparing its total price with received payments.- Parameters:
priceToPayVat- VAT-inclusive invoice totaltotalPayedPrice- total confirmed payments- Returns:
- paid, partially paid, or new invoice status identifier
-
addItemToInvoice
public static void addItemToInvoice(Long invoiceId, List<Integer> itemIdsToAdd, BasketInvoiceItemsRepository biir, int userId, jakarta.servlet.http.HttpServletRequest request) Adds or increments selected products in an existing invoice.- Parameters:
invoiceId- target invoice identifieritemIdsToAdd- product document identifiers to addbiir- invoice item repositoryuserId- identifier of the user modifying the invoicerequest- current request used to resolve product prices
-