From 98500255a8e76dde406874636204fbc0e2ebe50b Mon Sep 17 00:00:00 2001 From: Rachel McRoberts Date: Mon, 22 May 2023 23:22:21 +0100 Subject: [PATCH 1/4] Update gift card amount type to Double --- .../Networking/Model/Copiable/Models+Copiable.generated.swift | 2 +- Networking/Networking/Model/OrderGiftCard.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Networking/Networking/Model/Copiable/Models+Copiable.generated.swift b/Networking/Networking/Model/Copiable/Models+Copiable.generated.swift index fd5c7e689d1..ff11c41c5ac 100644 --- a/Networking/Networking/Model/Copiable/Models+Copiable.generated.swift +++ b/Networking/Networking/Model/Copiable/Models+Copiable.generated.swift @@ -683,7 +683,7 @@ extension Networking.OrderGiftCard { public func copy( giftCardID: CopiableProp = .copy, code: CopiableProp = .copy, - amount: CopiableProp = .copy + amount: CopiableProp = .copy ) -> Networking.OrderGiftCard { let giftCardID = giftCardID ?? self.giftCardID let code = code ?? self.code diff --git a/Networking/Networking/Model/OrderGiftCard.swift b/Networking/Networking/Model/OrderGiftCard.swift index 2dcc347b1b6..e60da4a1ea7 100644 --- a/Networking/Networking/Model/OrderGiftCard.swift +++ b/Networking/Networking/Model/OrderGiftCard.swift @@ -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 From 34efb2464e5e764af08545f1af4cbd33e798a409 Mon Sep 17 00:00:00 2001 From: Rachel McRoberts Date: Mon, 22 May 2023 23:23:01 +0100 Subject: [PATCH 2/4] Add Core Data model 88 --- Storage/Storage.xcodeproj/project.pbxproj | 4 +- .../.xccurrentversion | 2 +- .../Model 88.xcdatamodel/contents | 900 ++++++++++++++++++ 3 files changed, 904 insertions(+), 2 deletions(-) create mode 100644 Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 88.xcdatamodel/contents diff --git a/Storage/Storage.xcodeproj/project.pbxproj b/Storage/Storage.xcodeproj/project.pbxproj index cea16aa5a1e..52327356219 100644 --- a/Storage/Storage.xcodeproj/project.pbxproj +++ b/Storage/Storage.xcodeproj/project.pbxproj @@ -463,6 +463,7 @@ CCF3209E2927EBEE002114B1 /* Model 78.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 78.xcdatamodel"; sourceTree = ""; }; CE12FBE22220515600C59248 /* WooCommerceModelV9toV10.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = WooCommerceModelV9toV10.xcmappingmodel; sourceTree = ""; }; CE13681229FA8E6500EBF43C /* Model 86.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 86.xcdatamodel"; sourceTree = ""; }; + CE1999302A1C22B20093F863 /* Model 88.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 88.xcdatamodel"; sourceTree = ""; }; CE3B7AD02225E62C0050FE4B /* OrderStatus+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderStatus+CoreDataClass.swift"; sourceTree = ""; }; CE3B7AD12225E62C0050FE4B /* OrderStatus+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderStatus+CoreDataProperties.swift"; sourceTree = ""; }; CE43A8FB229F498D00A4FF29 /* ProductDownload+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProductDownload+CoreDataClass.swift"; sourceTree = ""; }; @@ -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 */, @@ -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 = ""; versionGroupType = wrapper.xcdatamodel; diff --git a/Storage/Storage/Model/WooCommerce.xcdatamodeld/.xccurrentversion b/Storage/Storage/Model/WooCommerce.xcdatamodeld/.xccurrentversion index 2abdbc6e748..efeff3447ad 100644 --- a/Storage/Storage/Model/WooCommerce.xcdatamodeld/.xccurrentversion +++ b/Storage/Storage/Model/WooCommerce.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - Model 87.xcdatamodel + Model 88.xcdatamodel diff --git a/Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 88.xcdatamodel/contents b/Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 88.xcdatamodel/contents new file mode 100644 index 00000000000..267fbda3c42 --- /dev/null +++ b/Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 88.xcdatamodel/contents @@ -0,0 +1,900 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 886c9c5fe50b03bb15bc63e4d26be61d22535f04 Mon Sep 17 00:00:00 2001 From: Rachel McRoberts Date: Mon, 22 May 2023 23:34:16 +0100 Subject: [PATCH 3/4] Update gift card amount attribute to Double --- Storage/Storage/Model/MIGRATIONS.md | 4 ++++ .../OrderGiftCard+CoreDataProperties.swift | 2 +- .../Model 88.xcdatamodel/contents | 2 +- .../CoreData/MigrationTests.swift | 24 +++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Storage/Storage/Model/MIGRATIONS.md b/Storage/Storage/Model/MIGRATIONS.md index 7730188006f..a40d375a87d 100644 --- a/Storage/Storage/Model/MIGRATIONS.md +++ b/Storage/Storage/Model/MIGRATIONS.md @@ -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. diff --git a/Storage/Storage/Model/OrderGiftCard+CoreDataProperties.swift b/Storage/Storage/Model/OrderGiftCard+CoreDataProperties.swift index 9ea673aad22..d8b7594e3cf 100644 --- a/Storage/Storage/Model/OrderGiftCard+CoreDataProperties.swift +++ b/Storage/Storage/Model/OrderGiftCard+CoreDataProperties.swift @@ -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? } diff --git a/Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 88.xcdatamodel/contents b/Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 88.xcdatamodel/contents index 267fbda3c42..fb0569f0226 100644 --- a/Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 88.xcdatamodel/contents +++ b/Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 88.xcdatamodel/contents @@ -218,7 +218,7 @@ - + diff --git a/Storage/StorageTests/CoreData/MigrationTests.swift b/Storage/StorageTests/CoreData/MigrationTests.swift index 82fe7595a6c..0ae7ec2f917 100644 --- a/Storage/StorageTests/CoreData/MigrationTests.swift +++ b/Storage/StorageTests/CoreData/MigrationTests.swift @@ -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 From 9ff10124f55523792875623b49f8e1b45c368127 Mon Sep 17 00:00:00 2001 From: Rachel McRoberts Date: Mon, 22 May 2023 23:53:20 +0100 Subject: [PATCH 4/4] Add gift card bug fix to 13.8 release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index a3a6626ab7e..7518a07de65 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -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 -----