From e2fc235cde6c63d9afd3d8711e6d568a2156fc73 Mon Sep 17 00:00:00 2001 From: zont Date: Mon, 1 Apr 2024 16:58:48 +0400 Subject: [PATCH 1/3] ECWID-134977 OE2: if an advanced discount is used for a product and more items are added to an order, the total is calculated incorrectly: added fields into DiscountInfo --- .../com/ecwid/apiclient/v3/converter/FetchedOrder.kt | 4 +++- .../ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt | 4 +++- .../ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt | 9 +++++++-- .../v3/rule/nullablepropertyrules/FetchedOrderRules.kt | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt index 37832bdf..3a95787a 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedOrder.kt @@ -106,7 +106,9 @@ fun FetchedOrder.DiscountInfo.toUpdated(): UpdatedOrder.DiscountInfo { type = type, base = base, orderTotal = orderTotal, - description = description + description = description, + appliesToProducts = appliesToProducts, + appliesToItems = appliesToItems, ) } diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt index a98b3cb7..be90b7ba 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt @@ -107,7 +107,9 @@ data class UpdatedOrder( val type: DiscountType? = null, val base: DiscountBase? = null, val orderTotal: Double? = null, - val description: String? = null + val description: String? = null, + val appliesToProducts: Set? = null, + val appliesToItems: Set? = null, ) data class DiscountCouponInfo( diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt index b63b25b8..c8c3f962 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt @@ -1,7 +1,10 @@ package com.ecwid.apiclient.v3.dto.order.result -import com.ecwid.apiclient.v3.dto.common.* +import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind +import com.ecwid.apiclient.v3.dto.common.ExtendedOrderTax +import com.ecwid.apiclient.v3.dto.common.OrderedStringToListStringMap +import com.ecwid.apiclient.v3.dto.common.OrderedStringToStringMap import com.ecwid.apiclient.v3.dto.order.enums.* import com.ecwid.apiclient.v3.dto.order.request.UpdatedOrder import java.util.* @@ -125,7 +128,9 @@ data class FetchedOrder( val type: DiscountType? = null, val base: DiscountBase? = null, val orderTotal: Double? = null, - val description: String? = null + val description: String? = null, + val appliesToProducts: Set? = null, + val appliesToItems: Set? = null, ) data class DiscountCouponInfo( diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt index b522d124..358eff6c 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt @@ -43,6 +43,8 @@ val fetchedOrderNullablePropertyRules: List> = listOf IgnoreNullable(FetchedOrder.DiscountInfo::orderTotal), IgnoreNullable(FetchedOrder.DiscountInfo::type), IgnoreNullable(FetchedOrder.DiscountInfo::value), + AllowNullable(FetchedOrder.DiscountInfo::appliesToProducts), + AllowNullable(FetchedOrder.DiscountInfo::appliesToItems), AllowNullable(FetchedOrder.ExtraFieldsInfo::customerInputType), AllowNullable(FetchedOrder.ExtraFieldsInfo::id), AllowNullable(FetchedOrder.ExtraFieldsInfo::orderBy), From f53a93eb0ad39284e5239191c1d36b72ca9db339 Mon Sep 17 00:00:00 2001 From: zont Date: Mon, 1 Apr 2024 17:12:48 +0400 Subject: [PATCH 2/3] ECWID-134977 OE2: if an advanced discount is used for a product and more items are added to an order, the total is calculated incorrectly: changed type to list to avoid exception on build --- .../com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt | 4 ++-- .../com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt index be90b7ba..218a6f97 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/request/UpdatedOrder.kt @@ -108,8 +108,8 @@ data class UpdatedOrder( val base: DiscountBase? = null, val orderTotal: Double? = null, val description: String? = null, - val appliesToProducts: Set? = null, - val appliesToItems: Set? = null, + val appliesToProducts: List? = null, + val appliesToItems: List? = null, ) data class DiscountCouponInfo( diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt index c8c3f962..0f63cdee 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/order/result/FetchedOrder.kt @@ -129,8 +129,8 @@ data class FetchedOrder( val base: DiscountBase? = null, val orderTotal: Double? = null, val description: String? = null, - val appliesToProducts: Set? = null, - val appliesToItems: Set? = null, + val appliesToProducts: List? = null, + val appliesToItems: List? = null, ) data class DiscountCouponInfo( From 3f128b54e9a7bb73c10e305c69d5d139f46e130d Mon Sep 17 00:00:00 2001 From: zont Date: Tue, 2 Apr 2024 21:21:55 +0400 Subject: [PATCH 3/3] ECWID-134977 OE2: if an advanced discount is used for a product and more items are added to an order, the total is calculated incorrectly: added fields to calculated order --- .../ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt | 4 +++- .../v3/dto/cart/result/CalculateOrderDetailsResult.kt | 4 +++- .../nullablepropertyrules/CalculateOrderDetailsResultRules.kt | 2 ++ .../v3/rule/nullablepropertyrules/OrderForCalculateRules.kt | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt index 589c669f..a5b27a50 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/request/OrderForCalculate.kt @@ -36,7 +36,9 @@ data class OrderForCalculate( val type: DiscountType? = null, val base: DiscountBase? = null, val orderTotal: Double? = null, - val description: String? = null + val description: String? = null, + val appliesToProducts: List? = null, + val appliesToItems: List? = null, ) data class OrderItemDiscountInfo( diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/CalculateOrderDetailsResult.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/CalculateOrderDetailsResult.kt index 6fd2f141..efc3823a 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/CalculateOrderDetailsResult.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/cart/result/CalculateOrderDetailsResult.kt @@ -95,7 +95,9 @@ data class CalculateOrderDetailsResult( val type: DiscountType? = null, val base: DiscountBase? = null, val orderTotal: Double? = null, - val description: String? = null + val description: String? = null, + val appliesToProducts: List? = null, + val appliesToItems: List? = null, ) data class OrderItemDiscountInfo( diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt index ff133251..e2e1b409 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt @@ -26,6 +26,8 @@ val calculateOrderDetailsResultNullablePropertyRules: List> = l IgnoreNullable(OrderForCalculate.DiscountInfo::orderTotal), IgnoreNullable(OrderForCalculate.DiscountInfo::type), IgnoreNullable(OrderForCalculate.DiscountInfo::value), + AllowNullable(OrderForCalculate.DiscountInfo::appliesToProducts), + AllowNullable(OrderForCalculate.DiscountInfo::appliesToItems), AllowNullable(OrderForCalculate.HandlingFee::description), AllowNullable(OrderForCalculate.HandlingFee::name), AllowNullable(OrderForCalculate.HandlingFee::taxes),