Skip to content

Commit

Permalink
Merge branch 'liferay:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
liferay-frontend authored Aug 24, 2023
2 parents ddd5438 + f357090 commit 0c70dd5
Show file tree
Hide file tree
Showing 181 changed files with 4,538 additions and 728 deletions.
2 changes: 1 addition & 1 deletion modules/apps/commerce/commerce-api/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Bundle-Name: Liferay Commerce API
Bundle-SymbolicName: com.liferay.commerce.api
Bundle-Version: 75.0.0
Bundle-Version: 75.1.0
Export-Package:\
com.liferay.commerce.address,\
com.liferay.commerce.checkout.helper,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class CommerceWebKeys {
public static final String COMMERCE_ORDER_IMPORTER_ITEM =
"COMMERCE_ORDER_IMPORTER_ITEM";

public static final String COMMERCE_ORDER_ITEM = "COMMERCE_ORDER_ITEM";

public static final String COMMERCE_ORDER_ITEM_CONTEXT_MAP =
"COMMERCE_ORDER_ITEM_CONTEXT_MAP";

public static final String COMMERCE_PAYMENT_METHOD_REGISTRY =
"COMMERCE_PAYMENT_METHOD_REGISTRY";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,19 @@ private void _updateCommerceInventoryWarehouseItem(
ActionRequest actionRequest)
throws PortalException {

long mvccVersion = ParamUtil.getLong(actionRequest, "mvccVersion");
long commerceInventoryWarehouseItemId = ParamUtil.getLong(
actionRequest, "commerceInventoryWarehouseItemId");

int quantity = ParamUtil.getInteger(actionRequest, "quantity");
int reservedQuantity = ParamUtil.getInteger(
actionRequest, "reservedQuantity");
BigDecimal quantity = (BigDecimal)ParamUtil.getNumber(
actionRequest, "quantity", BigDecimal.ZERO);
BigDecimal reservedQuantity = (BigDecimal)ParamUtil.getNumber(
actionRequest, "reservedQuantity", BigDecimal.ZERO);
long mvccVersion = ParamUtil.getLong(actionRequest, "mvccVersion");

_commerceInventoryWarehouseItemService.
updateCommerceInventoryWarehouseItem(
commerceInventoryWarehouseItemId, BigDecimal.valueOf(quantity),
BigDecimal.valueOf(reservedQuantity), mvccVersion);
commerceInventoryWarehouseItemId, quantity, reservedQuantity,
mvccVersion);
}

private static final Log _log = LogFactoryUtil.getLog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ private void _updateCommerceInventoryWarehouse(ActionRequest actionRequest)
long commerceInventoryWarehouseId = ParamUtil.getLong(
actionRequest, "commerceInventoryWarehouseId");

int quantity = ParamUtil.getInteger(actionRequest, "quantity");
BigDecimal quantity = (BigDecimal)ParamUtil.getNumber(
actionRequest, "quantity", BigDecimal.ZERO);
String sku = ParamUtil.getString(actionRequest, "sku");

String unitOfMeasureKey = ParamUtil.getString(
actionRequest, "unitOfMeasureKey");

Expand All @@ -132,15 +132,15 @@ private void _updateCommerceInventoryWarehouse(ActionRequest actionRequest)
if (commerceInventoryWarehouseItem == null) {
_commerceInventoryWarehouseItemService.
addCommerceInventoryWarehouseItem(
StringPool.BLANK, commerceInventoryWarehouseId,
BigDecimal.valueOf(quantity), sku, unitOfMeasureKey);
StringPool.BLANK, commerceInventoryWarehouseId, quantity,
sku, unitOfMeasureKey);
}
else {
_commerceInventoryWarehouseItemService.
increaseCommerceInventoryWarehouseItemQuantity(
commerceInventoryWarehouseItem.
getCommerceInventoryWarehouseItemId(),
BigDecimal.valueOf(quantity));
quantity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ private void _moveQuantities(ActionRequest actionRequest) throws Exception {
actionRequest, "fromCommerceInventoryWarehouseId");
long toCommerceInventoryWarehouseId = ParamUtil.getLong(
actionRequest, "toCommerceInventoryWarehouseId");
int quantity = ParamUtil.getInteger(actionRequest, "quantity");
BigDecimal quantity = (BigDecimal)ParamUtil.getNumber(
actionRequest, "quantity", BigDecimal.ZERO);
String sku = ParamUtil.getString(actionRequest, "sku");
String unitOfMeasureKey = ParamUtil.getString(
actionRequest, "unitOfMeasureKey");

_commerceInventoryWarehouseItemService.moveQuantitiesBetweenWarehouses(
fromCommerceInventoryWarehouseId, toCommerceInventoryWarehouseId,
BigDecimal.valueOf(quantity), sku, unitOfMeasureKey);
quantity, sku, unitOfMeasureKey);
}

@Reference
Expand Down
2 changes: 2 additions & 0 deletions modules/apps/commerce/commerce-order-content-web/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dependencies {
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "default"
compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "default"
compileOnly group: "javax.portlet", name: "portlet-api", version: "3.0.1"
compileOnly group: "javax.servlet.jsp", name: "javax.servlet.jsp-api", version: "2.3.1"
compileOnly group: "org.apache.commons", name: "commons-csv", version: "1.9.0"
compileOnly group: "org.apache.felix", name: "org.apache.felix.http.servlet-api", version: "1.1.2"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning", version: "1.1.0"
Expand Down Expand Up @@ -32,6 +33,7 @@ dependencies {
compileOnly project(":apps:frontend-taglib:frontend-taglib")
compileOnly project(":apps:frontend-taglib:frontend-taglib-clay")
compileOnly project(":apps:info:info-api")
compileOnly project(":apps:info:info-taglib")
compileOnly project(":apps:item-selector:item-selector-api")
compileOnly project(":apps:item-selector:item-selector-criteria-api")
compileOnly project(":apps:item-selector:item-selector-taglib")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@

package com.liferay.commerce.order.content.web.internal.frontend.data.set.provider;

import com.liferay.commerce.constants.CommercePriceConstants;
import com.liferay.commerce.constants.CommerceWebKeys;
import com.liferay.commerce.context.CommerceContext;
import com.liferay.commerce.currency.model.CommerceMoney;
import com.liferay.commerce.model.CommerceOrder;
import com.liferay.commerce.model.CommerceOrderItem;
import com.liferay.commerce.order.CommerceOrderValidatorRegistry;
import com.liferay.commerce.order.CommerceOrderValidatorResult;
import com.liferay.commerce.order.content.web.internal.constants.CommerceOrderFDSNames;
import com.liferay.commerce.order.content.web.internal.model.OrderItem;
import com.liferay.commerce.order.content.web.internal.util.CommerceOrderItemUtil;
import com.liferay.commerce.price.CommerceOrderItemPrice;
import com.liferay.commerce.price.CommerceOrderPriceCalculation;
import com.liferay.commerce.product.model.CPInstance;
Expand All @@ -39,21 +38,16 @@
import com.liferay.portal.kernel.search.BaseModelSearchResult;
import com.liferay.portal.kernel.search.Sort;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.BigDecimalUtil;
import com.liferay.portal.kernel.util.KeyValuePair;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Portal;
import com.liferay.portal.kernel.util.StringUtil;

import java.math.BigDecimal;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringJoiner;

import javax.servlet.http.HttpServletRequest;

Expand Down Expand Up @@ -105,66 +99,6 @@ public int getItemsCount(
return baseModelSearchResult.getLength();
}

private String _formatDiscountAmount(
CommerceOrderItemPrice commerceOrderItemPrice, Locale locale)
throws Exception {

if (commerceOrderItemPrice.isPriceOnApplication()) {
return StringPool.DASH;
}

if (commerceOrderItemPrice.getDiscountAmount() == null) {
return StringPool.BLANK;
}

CommerceMoney discountAmountCommerceMoney =
commerceOrderItemPrice.getDiscountAmount();

return discountAmountCommerceMoney.format(locale);
}

private String _formatFinalPrice(
CommerceOrderItemPrice commerceOrderItemPrice, Locale locale)
throws Exception {

if (commerceOrderItemPrice.isPriceOnApplication()) {
return StringPool.DASH;
}

if (commerceOrderItemPrice.getFinalPrice() == null) {
return StringPool.BLANK;
}

CommerceMoney finalPriceCommerceMoney =
commerceOrderItemPrice.getFinalPrice();

return finalPriceCommerceMoney.format(locale);
}

private String _formatPromoPrice(
CommerceOrderItemPrice commerceOrderItemPrice, Locale locale)
throws Exception {

if (commerceOrderItemPrice.isPriceOnApplication()) {
return StringPool.DASH;
}

CommerceMoney promoPriceCommerceMoney =
commerceOrderItemPrice.getPromoPrice();

if (promoPriceCommerceMoney == null) {
return StringPool.BLANK;
}

BigDecimal price = promoPriceCommerceMoney.getPrice();

if (price.compareTo(BigDecimal.ZERO) <= 0) {
return StringPool.BLANK;
}

return promoPriceCommerceMoney.format(locale);
}

private String _formatSubscriptionPeriod(
CommerceOrderItem commerceOrderItem, Locale locale)
throws Exception {
Expand Down Expand Up @@ -203,40 +137,6 @@ private String _formatSubscriptionPeriod(
new Object[] {cpSubscriptionInfo.getSubscriptionLength(), period});
}

private String _formatUnitPrice(
CommerceOrderItemPrice commerceOrderItemPrice, Locale locale)
throws Exception {

if (commerceOrderItemPrice.isPriceOnApplication()) {
return _language.get(
locale,
CommercePriceConstants.PRICE_VALUE_PRICE_ON_APPLICATION);
}

CommerceMoney unitPriceCommerceMoney =
commerceOrderItemPrice.getUnitPrice();

if (unitPriceCommerceMoney == null) {
return StringPool.BLANK;
}

CommerceMoney promoPriceCommerceMoney =
commerceOrderItemPrice.getPromoPrice();

if (BigDecimalUtil.eq(
unitPriceCommerceMoney.getPrice(), BigDecimal.ZERO) &&
(promoPriceCommerceMoney != null) &&
BigDecimalUtil.gt(
promoPriceCommerceMoney.getPrice(), BigDecimal.ZERO)) {

return _language.get(
locale,
CommercePriceConstants.PRICE_VALUE_PRICE_ON_APPLICATION);
}

return unitPriceCommerceMoney.format(locale);
}

private BaseModelSearchResult<CommerceOrderItem> _getBaseModelSearchResult(
FDSKeywords fdsKeywords, FDSPagination fdsPagination,
HttpServletRequest httpServletRequest, Sort sort)
Expand Down Expand Up @@ -268,16 +168,6 @@ private List<OrderItem> _getChildOrderItems(
httpServletRequest);
}

private long _getCommerceOptionValueCPDefinitionId(
CommerceOrderItem commerceOrderItem) {

if (!commerceOrderItem.hasParentCommerceOrderItem()) {
return commerceOrderItem.getCPDefinitionId();
}

return commerceOrderItem.getParentCommerceOrderItemCPDefinitionId();
}

private String[] _getCommerceOrderErrorMessages(
CommerceOrderItem commerceOrderItem,
Map<Long, List<CommerceOrderValidatorResult>>
Expand All @@ -299,25 +189,6 @@ private String[] _getCommerceOrderErrorMessages(
return ArrayUtil.toStringArray(errorMessages);
}

private String _getCommerceOrderOptions(
CommerceOrderItem commerceOrderItem, Locale locale)
throws Exception {

StringJoiner stringJoiner = new StringJoiner(
StringPool.COMMA_AND_SPACE);

List<KeyValuePair> commerceOptionValueKeyValuePairs =
_cpInstanceHelper.getKeyValuePairs(
_getCommerceOptionValueCPDefinitionId(commerceOrderItem),
commerceOrderItem.getJson(), locale);

for (KeyValuePair keyValuePair : commerceOptionValueKeyValuePairs) {
stringJoiner.add(keyValuePair.getValue());
}

return stringJoiner.toString();
}

private Map<Long, List<CommerceOrderValidatorResult>>
_getCommerceOrderValidatorResultsMap(
List<CommerceOrderItem> commerceOrderItems, Locale locale)
Expand Down Expand Up @@ -363,27 +234,32 @@ private List<OrderItem> _getOrderItems(

return new OrderItem(
commerceOrderItem.getCPInstanceId(),
_formatDiscountAmount(commerceOrderItemPrice, locale),
CommerceOrderItemUtil.formatDiscountAmount(
commerceOrderItemPrice, locale),
_getCommerceOrderErrorMessages(
commerceOrderItem, commerceOrderValidatorResultsMap),
_commerceOrderItemQuantityFormatter.format(
commerceOrderItem, locale),
_formatSubscriptionPeriod(commerceOrderItem, locale),
commerceOrderItem.getName(locale),
_getCommerceOrderOptions(commerceOrderItem, locale),
CommerceOrderItemUtil.getOptions(
commerceOrderItem, _cpInstanceHelper, locale),
commerceOrderItem.getCommerceOrderId(),
commerceOrderItem.getCommerceOrderItemId(),
_getChildOrderItems(commerceOrderItem, httpServletRequest),
commerceOrderItem.getParentCommerceOrderItemId(),
_formatUnitPrice(commerceOrderItemPrice, locale),
_formatPromoPrice(commerceOrderItemPrice, locale), 0,
commerceOrderItem.getSku(),
CommerceOrderItemUtil.formatUnitPrice(
commerceOrderItemPrice, _language, locale),
CommerceOrderItemUtil.formatPromoPrice(
commerceOrderItemPrice, locale),
0, commerceOrderItem.getSku(),
_cpInstanceHelper.getCPInstanceThumbnailSrc(
CommerceUtil.getCommerceAccountId(
(CommerceContext)httpServletRequest.getAttribute(
CommerceWebKeys.COMMERCE_CONTEXT)),
commerceOrderItem.getCPInstanceId()),
_formatFinalPrice(commerceOrderItemPrice, locale));
CommerceOrderItemUtil.formatTotalPrice(
commerceOrderItemPrice, locale));
});
}

Expand Down
Loading

0 comments on commit 0c70dd5

Please sign in to comment.