Skip to content

Commit

Permalink
Merge pull request #2877 from wordpress-mobile/issue/9856-FC-delete-c…
Browse files Browse the repository at this point in the history
…ustomer-details-from-order

[ WC Manual Taxes] Add customerId to OrderEntity
  • Loading branch information
rossanafmenezes authored Oct 30, 2023
2 parents efe4bfd + 0a1a58f commit 27f4390
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ class MigrationTests {
}
}

@Test
fun testMigration28to29() {
helper.apply {
createDatabase(TEST_DB, 28).close()
runMigrationsAndValidate(TEST_DB, 29, false)
}
}

companion object {
private const val TEST_DB = "migration-test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ data class OrderEntity(
val discountTotal: String = "",
val discountCodes: String = "",
val refundTotal: BigDecimal = BigDecimal.ZERO, // The total refund value for this order (usually a negative number)
@ColumnInfo(name = "customerId", defaultValue = "0")
val customerId: Long = 0,
val billingFirstName: String = "",
val billingLastName: String = "",
val billingCompany: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class OrderDto : Response {
val total: String? = null
}

val customer_id: Long? = null
val billing: Billing? = null
val coupon_lines: List<CouponLine>? = null
val currency: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class OrderDtoMapper @Inject internal constructor(
// store their sum as a 'Double'.
refunds.sumOf { it.total?.toBigDecimalOrNull() ?: BigDecimal.ZERO }
} ?: BigDecimal.ZERO,
customerId = this.customer_id ?: 0,
billingFirstName = this.billing?.first_name ?: "",
billingLastName = this.billing?.last_name ?: "",
billingCompany = this.billing?.company ?: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import org.wordpress.android.fluxc.persistence.migrations.MIGRATION_8_9
import org.wordpress.android.fluxc.persistence.migrations.MIGRATION_9_10

@Database(
version = 28,
version = 29,
entities = [
AddonEntity::class,
AddonOptionEntity::class,
Expand All @@ -84,6 +84,7 @@ import org.wordpress.android.fluxc.persistence.migrations.MIGRATION_9_10
AutoMigration(from = 23, to = 24, spec = AutoMigration23to24::class),
AutoMigration(from = 25, to = 26),
AutoMigration(from = 26, to = 27),
AutoMigration(from = 28, to = 29),
]
)
@TypeConverters(
Expand Down

0 comments on commit 27f4390

Please sign in to comment.