Promotion Calendar (Technical User Reference)

Promotion Calendar capability brings these core back-end enhancements

API: Filter to find all contracts & rebates for the given customer(s) and product(s) criteria

As a configuration engineer, I want to be able to efficiently fetch contracts & rebates based on customer group and product group so that I can display relevant records in a Gantt highchart in a dashboard.

New Groovy API methods

  • Filter productToRelatedObjectsFilter(String relatedObjectTypeCode, ProductGroup productGroup);

  • Filter customerToRelatedObjectsFilter(String relatedObjectTypeCode, CustomerGroup customerGroup);

  • Object getCalculableLineItemCollection(String typedId);

 

API: Filter to find all contracts & rebates for the given customer(s) and product(s) criteria

Allow customer/productToRelatedObjectsFilter() to accept the customer/product picker

methods to accept the customer/product picker

 

Allow getCalculableLineItemCollection() to accept Filter

method to provide full details of the contracts/rebates

 

Usage of newly introduced methods:

 

Filter getCustomerProductFilter(String typeCode, Collection customerIds, Collection skus, List contractStatus, String dateFrom, String dateTo) { def filters = Filter.and() if (customerIds != null) { Filter filterCustomers = Filter.or() if (customerIds) { customerIds.each { customerId -> filterCustomers.add(api.customerToRelatedObjectsFilter(typeCode, customerId)) } } else { filterCustomers.add( Filter.equal("customerId", null) ) } filters.add( Filter.or(filterCustomers, Filter.isNull("customerGroup")) ) } if (skus != null) { Filter filterProducts = Filter.or() if (skus) { skus.each { sku -> filterProducts.add(api.productToRelatedObjectsFilter(typeCode, sku)) } } else { filterProducts.add( Filter.equal("sku", null) ) } filters.add( Filter.or(filterProducts, Filter.isNull("productGroup")) ) } if (contractStatus) { filters.add( Filter.in("contractStatus", contractStatus) ) } if (dateFrom) { filters.add( Filter.greaterOrEqual("startDate", dateFrom), ) } if (dateTo) { filters.add( Filter.lessOrEqual("endDate", dateTo), ) } return filters }
def customerIds = out.Customers?.customerId def skus = out.Products?.sku def contractStatus = out.Status def productList = out.Products def tradeLeverCategory = out.TradeLevers?.TradeLeverCategory def tradeLeverType = out.TradeLevers?.TradeLeverType def contractTermTypes = out.ContractTermTypes def filter = Library.getCustomerProductFilter("CT", customerIds, skus, contractStatus, out.DateFrom, out.DateTo) def contracts = api.find("CT", 0, api.maxFindResultsLimit, "startDate", ["id"], filter) .collect { contract -> api.getCalculableLineItemCollection(contract.id + ".CT") }

Found an issue in documentation? Write to us.

Â