Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ extension Networking.OrderGiftCard {
public func copy(
giftCardID: CopiableProp<Int64> = .copy,
code: CopiableProp<String> = .copy,
amount: CopiableProp<Int64> = .copy
amount: CopiableProp<Double> = .copy
) -> Networking.OrderGiftCard {
let giftCardID = giftCardID ?? self.giftCardID
let code = code ?? self.code
Expand Down
4 changes: 2 additions & 2 deletions Networking/Networking/Model/OrderGiftCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public struct OrderGiftCard: Codable, Equatable, GeneratedFakeable, GeneratedCop

/// Amount applied to the order
///
public let amount: Int64
public let amount: Double

/// OrderGiftCard struct initializer.
///
public init(giftCardID: Int64, code: String, amount: Int64) {
public init(giftCardID: Int64, code: String, amount: Double) {
self.giftCardID = giftCardID
self.code = code
self.amount = amount
Expand Down
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
13.8
-----
- [*] Product form: a share action is shown in the navigation bar if the product can be shared and no more than one action is displayed, in addition to the more menu > Share. [https://github.com/woocommerce/woocommerce-ios/pull/9789]
- [*] Orders: Fixes a bug where the Orders list would not load if an order had a non-integer gift card amount applied to the order (with the Gift Cards extension). [https://github.com/woocommerce/woocommerce-ios/pull/9795]

13.7
-----
Expand Down
4 changes: 3 additions & 1 deletion Storage/Storage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@
CCF3209E2927EBEE002114B1 /* Model 78.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 78.xcdatamodel"; sourceTree = "<group>"; };
CE12FBE22220515600C59248 /* WooCommerceModelV9toV10.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = WooCommerceModelV9toV10.xcmappingmodel; sourceTree = "<group>"; };
CE13681229FA8E6500EBF43C /* Model 86.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 86.xcdatamodel"; sourceTree = "<group>"; };
CE1999302A1C22B20093F863 /* Model 88.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 88.xcdatamodel"; sourceTree = "<group>"; };
CE3B7AD02225E62C0050FE4B /* OrderStatus+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderStatus+CoreDataClass.swift"; sourceTree = "<group>"; };
CE3B7AD12225E62C0050FE4B /* OrderStatus+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderStatus+CoreDataProperties.swift"; sourceTree = "<group>"; };
CE43A8FB229F498D00A4FF29 /* ProductDownload+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProductDownload+CoreDataClass.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1869,6 +1870,7 @@
DEC51AA4275B41BE009F3DF4 /* WooCommerce.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
CE1999302A1C22B20093F863 /* Model 88.xcdatamodel */,
CE831FE12A14F6C800E8BEFB /* Model 87.xcdatamodel */,
CE13681229FA8E6500EBF43C /* Model 86.xcdatamodel */,
CEE9188229F7E60C004B23FF /* Model 85.xcdatamodel */,
Expand Down Expand Up @@ -1957,7 +1959,7 @@
DEC51ADE275B41BE009F3DF4 /* Model 47.xcdatamodel */,
DEC51ADF275B41BE009F3DF4 /* Model 19.xcdatamodel */,
);
currentVersion = CE831FE12A14F6C800E8BEFB /* Model 87.xcdatamodel */;
currentVersion = CE1999302A1C22B20093F863 /* Model 88.xcdatamodel */;
path = WooCommerce.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
4 changes: 4 additions & 0 deletions Storage/Storage/Model/MIGRATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.

## Model 88 (Release 13.8.0.0)
- @rachelmcr 2023-05-22
- Update `amount` attribute on `OrderGiftCard` entity to `Double` type.

## Model 87 (Release 13.7.0.0)
- @rachelmcr 2023-05-17
- Added `parent` attribute to `OrderItem` entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension OrderGiftCard {

@NSManaged public var giftCardID: Int64
@NSManaged public var code: String?
@NSManaged public var amount: Int64
@NSManaged public var amount: Double
@NSManaged public var order: Order?

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Model 87.xcdatamodel</string>
<string>Model 88.xcdatamodel</string>
</dict>
</plist>

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions Storage/StorageTests/CoreData/MigrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,30 @@ final class MigrationTests: XCTestCase {
// New value is set correctly for parent attribute.
XCTAssertEqual(try XCTUnwrap(migratedOrderItem.value(forKey: "parent") as? Int64), parentID)
}

func test_migrating_from_87_to_88_updates_gift_card_amount_to_Double() throws {
// Given
let sourceContainer = try startPersistentContainer("Model 87")
let sourceContext = sourceContainer.viewContext

let orderGiftCard = insertOrderGiftCard(to: sourceContext)
orderGiftCard.setValue(1, forKey: "amount")
try sourceContext.save()

// Value for gift card amount is Int64.
XCTAssertEqual(try sourceContext.count(entityName: "OrderGiftCard"), 1)
XCTAssertEqual(try XCTUnwrap(orderGiftCard.value(forKey: "amount") as? Int64), 1)

// When
let targetContainer = try migrate(sourceContainer, to: "Model 88")

// Then
let targetContext = targetContainer.viewContext
let migratedOrderGiftCard = try XCTUnwrap(targetContext.first(entityName: "OrderGiftCard"))

// Migrated value for gift card amount is Double.
XCTAssertEqual(try XCTUnwrap(migratedOrderGiftCard.value(forKey: "amount") as? Double), 1.0)
}
}

// MARK: - Persistent Store Setup and Migrations
Expand Down