Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECWID-126274 OE2: The discount Based on Customer Groups is deducted f… #348

Merged
merged 7 commits into from
Nov 9, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ fun FetchedOrder.OrderItem.toUpdated(): UpdatedOrder.OrderItem {
fixedShippingRateOnly = fixedShippingRateOnly,
digital = digital,
couponApplied = couponApplied,
giftCard = giftCard,

discountsAllowed = discountsAllowed,
isCustomerSetPrice = isCustomerSetPrice,
isGiftCard = isGiftCard,
nameTranslated = nameTranslated,
selectedPrice = selectedPrice?.toUpdated(),
shortDescriptionTranslated = shortDescriptionTranslated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ data class OrderForCalculate(
val fixedShippingRateOnly: Boolean? = null,
val digital: Boolean? = null,
val couponApplied: Boolean? = null,
val giftCard: Boolean? = null,

val selectedOptions: List<OrderItemOption>? = null,
val combinationId: Int? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ data class CalculateOrderDetailsResult(
val fixedShippingRateOnly: Boolean? = null,
val digital: Boolean? = null,
val couponApplied: Boolean? = null,
val giftCard: Boolean? = null,

val selectedOptions: List<OrderItemOption>? = null,
val combinationId: Int? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ data class FetchedCart(
val fixedShippingRateOnly: Boolean? = null,
val digital: Boolean? = null,
val couponApplied: Boolean? = null,
val giftCard: Boolean? = null,

val selectedOptions: List<OrderItemOption>? = null,
val combinationId: Int? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ data class UpdatedOrder(
val fixedShippingRateOnly: Boolean? = null,
val digital: Boolean? = null,
val couponApplied: Boolean? = null,
val isGiftCard: Boolean? = null,
val giftCard: Boolean? = null,

val selectedOptions: List<OrderItemSelectedOption>? = null,
val combinationId: Int? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ data class FetchedOrder(
val digital: Boolean? = null,
val productAvailable: Boolean? = null, // TODO Probably this field is always true
val couponApplied: Boolean? = null,
val isGiftCard: Boolean? = null,
val giftCard: Boolean? = null,

val recurringChargeSettings: RecurringChargeSettings? = null,
val subscriptionId: Long? = null,
Expand Down
3 changes: 3 additions & 0 deletions src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class CartsTest : BaseEntityTest() {
assertEquals(orderItem.fixedShippingRateOnly, cartItem.fixedShippingRateOnly)
assertEquals(orderItem.digital, cartItem.digital)
assertEquals(orderItem.couponApplied, cartItem.couponApplied)
assertEquals(orderItem.giftCard, cartItem.giftCard)

assertEquals(orderItem.dimensions?.length, cartItem.dimensions?.length)
assertEquals(orderItem.dimensions?.width, cartItem.dimensions?.width)
Expand Down Expand Up @@ -305,6 +306,7 @@ class CartsTest : BaseEntityTest() {
assertEquals(forCalculateItem.fixedShippingRateOnly, calculatedItem.fixedShippingRateOnly)
assertEquals(forCalculateItem.digital, calculatedItem.digital)
assertEquals(false, calculatedItem.couponApplied)
assertEquals(false, calculatedItem.giftCard)

assertEquals(forCalculateItem.selectedOptions?.count(), calculatedItem.selectedOptions?.count())
calculatedItem.selectedOptions?.forEachIndexed { selectedOptionIndex, calculatedOrderItemOptions ->
Expand Down Expand Up @@ -485,6 +487,7 @@ class CartsTest : BaseEntityTest() {
fixedShippingRateOnly = true,
digital = true,
couponApplied = true,
giftCard = false,
selectedOptions = listOf(
generateChoiceSelectedOption(),
generateChoicesSelectedOption(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ val calculateOrderDetailsResultNullablePropertyRules: List<NullablePropertyRule<
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::categoryId),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::couponAmount),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::couponApplied),
AllowNullable(CalculateOrderDetailsResult.OrderItem::giftCard),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::digital),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::dimensions),
IgnoreNullable(CalculateOrderDetailsResult.OrderItem::discounts),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ val fetchedCartNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
IgnoreNullable(FetchedCart.OrderItem::categoryId),
IgnoreNullable(FetchedCart.OrderItem::couponAmount),
IgnoreNullable(FetchedCart.OrderItem::couponApplied),
AllowNullable(FetchedCart.OrderItem::giftCard),
IgnoreNullable(FetchedCart.OrderItem::digital),
IgnoreNullable(FetchedCart.OrderItem::dimensions),
IgnoreNullable(FetchedCart.OrderItem::discounts),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ val fetchedOrderNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf
IgnoreNullable(FetchedOrder.OrderItem::id),
IgnoreNullable(FetchedOrder.OrderItem::imageUrl),
AllowNullable(FetchedOrder.OrderItem::isCustomerSetPrice),
AllowNullable(FetchedOrder.OrderItem::isGiftCard),
AllowNullable(FetchedOrder.OrderItem::giftCard),
IgnoreNullable(FetchedOrder.OrderItem::isShippingRequired),
IgnoreNullable(FetchedOrder.OrderItem::name),
AllowNullable(FetchedOrder.OrderItem::nameTranslated),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ val orderForCalculateNullablePropertyRules: List<NullablePropertyRule<*, *>> = l
IgnoreNullable(OrderForCalculate.OrderItem::categoryId),
IgnoreNullable(OrderForCalculate.OrderItem::couponAmount),
IgnoreNullable(OrderForCalculate.OrderItem::couponApplied),
AllowNullable(OrderForCalculate.OrderItem::giftCard),
IgnoreNullable(OrderForCalculate.OrderItem::digital),
IgnoreNullable(OrderForCalculate.OrderItem::dimensions),
IgnoreNullable(OrderForCalculate.OrderItem::discounts),
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private fun generateTestOrderItem() = UpdatedOrder.OrderItem(
fixedShippingRateOnly = randomBoolean(),
digital = randomBoolean(),
couponApplied = randomBoolean(),
giftCard = false,
isCustomerSetPrice = randomBoolean(),
taxable = randomBoolean(),

Expand Down