Skip to content

Commit

Permalink
Merge pull request #348 from Ecwid/ECWID-126274
Browse files Browse the repository at this point in the history
ECWID-126274 OE2: The discount Based on Customer Groups is deducted f…
  • Loading branch information
zont163 authored Nov 9, 2023
2 parents 6012f38 + 99b6ee8 commit 4ea84d1
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,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 @@ -142,6 +142,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 @@ -154,7 +154,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 @@ -186,7 +186,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 @@ -82,6 +82,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 @@ -210,6 +210,7 @@ private fun generateTestOrderItem() = UpdatedOrder.OrderItem(
fixedShippingRateOnly = randomBoolean(),
digital = randomBoolean(),
couponApplied = randomBoolean(),
giftCard = false,
isCustomerSetPrice = randomBoolean(),
taxable = randomBoolean(),

Expand Down

0 comments on commit 4ea84d1

Please sign in to comment.