Skip to content

Commit 85d3ce6

Browse files
authored
Merge pull request #7107 from woocommerce/issue/6902-bug-refunds-in-products-list-order-details
[Order Details] Fix duplicated entries in products and refund items lists
2 parents 3938d56 + 5015c2b commit 85d3ce6

File tree

20 files changed

+929
-11
lines changed

20 files changed

+929
-11
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ extension OrderItemRefund {
431431
name: .fake(),
432432
productID: .fake(),
433433
variationID: .fake(),
434+
refundedItemID: .fake(),
434435
quantity: .fake(),
435436
price: .fake(),
436437
sku: .fake(),

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@
494494
B5C6FCD420A373BB00A4F8E4 /* OrderMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6FCD320A373BA00A4F8E4 /* OrderMapper.swift */; };
495495
B5C6FCD620A3768900A4F8E4 /* order.json in Resources */ = {isa = PBXBuildFile; fileRef = B5C6FCD520A3768900A4F8E4 /* order.json */; };
496496
B5DAEFF02180DD5A0002356A /* NotificationsRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DAEFEF2180DD5A0002356A /* NotificationsRemote.swift */; };
497+
B963A5CC2853870000EFADA0 /* OrderItemRefundMetaData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B963A5CB2853870000EFADA0 /* OrderItemRefundMetaData.swift */; };
497498
BAB373722795A1FB00837B4A /* OrderTaxLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB373712795A1FB00837B4A /* OrderTaxLine.swift */; };
498499
CC07865F267799EE00BA9AC1 /* ShippingLabelPurchase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC07865E267799EE00BA9AC1 /* ShippingLabelPurchase.swift */; };
499500
CC0786612677B2DA00BA9AC1 /* ShippingLabelPurchaseMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0786602677B2DA00BA9AC1 /* ShippingLabelPurchaseMapper.swift */; };
@@ -1174,6 +1175,7 @@
11741175
B5C6FCD320A373BA00A4F8E4 /* OrderMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderMapper.swift; sourceTree = "<group>"; };
11751176
B5C6FCD520A3768900A4F8E4 /* order.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = order.json; sourceTree = "<group>"; };
11761177
B5DAEFEF2180DD5A0002356A /* NotificationsRemote.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationsRemote.swift; sourceTree = "<group>"; };
1178+
B963A5CB2853870000EFADA0 /* OrderItemRefundMetaData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderItemRefundMetaData.swift; sourceTree = "<group>"; };
11771179
BAB373712795A1FB00837B4A /* OrderTaxLine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderTaxLine.swift; sourceTree = "<group>"; };
11781180
BD9439D9B8F2C1ED2EADAA51 /* Pods-NetworkingTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NetworkingTests.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-NetworkingTests/Pods-NetworkingTests.debug.xcconfig"; sourceTree = "<group>"; };
11791181
C8F9A8CC6F90A8C9B5EF2EE2 /* Pods-Networking.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Networking.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Networking/Pods-Networking.release.xcconfig"; sourceTree = "<group>"; };
@@ -1460,6 +1462,7 @@
14601462
CE43066923465F340073CBFF /* Refund.swift */,
14611463
CE43066B2347C5F90073CBFF /* OrderItemRefund.swift */,
14621464
CE43066D2347CBA70073CBFF /* OrderItemTaxRefund.swift */,
1465+
B963A5CB2853870000EFADA0 /* OrderItemRefundMetaData.swift */,
14631466
);
14641467
path = Refund;
14651468
sourceTree = "<group>";
@@ -2938,6 +2941,7 @@
29382941
77CE40602514CB3E003FF69D /* ProductDownloadDragAndDrop.swift in Sources */,
29392942
2685C0FE263B5D8900D9EE97 /* AddOnGroupRemote.swift in Sources */,
29402943
450106912399B2C800E24722 /* TaxClassListMapper.swift in Sources */,
2944+
B963A5CC2853870000EFADA0 /* OrderItemRefundMetaData.swift in Sources */,
29412945
0329CF9B27A82E19008AFF91 /* WCPayCharge.swift in Sources */,
29422946
74749B97224134FF005C4CF2 /* ProductMapper.swift in Sources */,
29432947
26455E2A25F669F0008A1D32 /* ProductAttributeTermMapper.swift in Sources */,

Networking/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ extension OrderItemRefund {
493493
name: CopiableProp<String> = .copy,
494494
productID: CopiableProp<Int64> = .copy,
495495
variationID: CopiableProp<Int64> = .copy,
496+
refundedItemID: CopiableProp<String> = .copy,
496497
quantity: CopiableProp<Decimal> = .copy,
497498
price: CopiableProp<NSDecimalNumber> = .copy,
498499
sku: NullableCopiableProp<String> = .copy,
@@ -507,6 +508,7 @@ extension OrderItemRefund {
507508
let name = name ?? self.name
508509
let productID = productID ?? self.productID
509510
let variationID = variationID ?? self.variationID
511+
let refundedItemID = refundedItemID ?? self.refundedItemID
510512
let quantity = quantity ?? self.quantity
511513
let price = price ?? self.price
512514
let sku = sku ?? self.sku
@@ -522,6 +524,7 @@ extension OrderItemRefund {
522524
name: name,
523525
productID: productID,
524526
variationID: variationID,
527+
refundedItemID: refundedItemID,
525528
quantity: quantity,
526529
price: price,
527530
sku: sku,

Networking/Networking/Model/Refund/OrderItemRefund.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public struct OrderItemRefund: Codable, Equatable, GeneratedFakeable, GeneratedC
88
public let name: String
99
public let productID: Int64
1010
public let variationID: Int64
11+
public let refundedItemID: String?
1112
public let quantity: Decimal
1213

1314
/// Price is a currency.
@@ -30,6 +31,7 @@ public struct OrderItemRefund: Codable, Equatable, GeneratedFakeable, GeneratedC
3031
name: String,
3132
productID: Int64,
3233
variationID: Int64,
34+
refundedItemID: String?,
3335
quantity: Decimal,
3436
price: NSDecimalNumber,
3537
sku: String?,
@@ -43,6 +45,7 @@ public struct OrderItemRefund: Codable, Equatable, GeneratedFakeable, GeneratedC
4345
self.name = name
4446
self.productID = productID
4547
self.variationID = variationID
48+
self.refundedItemID = refundedItemID
4649
self.quantity = quantity
4750
self.price = price
4851
self.sku = sku
@@ -76,11 +79,15 @@ public struct OrderItemRefund: Codable, Equatable, GeneratedFakeable, GeneratedC
7679
let total = try container.decode(String.self, forKey: .total)
7780
let totalTax = try container.decode(String.self, forKey: .totalTax)
7881

82+
let allOrderItemRefundMetaData = try container.decode([OrderItemRefundMetaData].self, forKey: .metadata)
83+
let refundedItemID = allOrderItemRefundMetaData.first(where: { $0.key == "_refunded_item_id" })?.value
84+
7985
// initialize the struct
8086
self.init(itemID: itemID,
8187
name: name,
8288
productID: productID,
8389
variationID: variationID,
90+
refundedItemID: refundedItemID,
8491
quantity: quantity,
8592
price: price,
8693
sku: sku,
@@ -131,6 +138,7 @@ private extension OrderItemRefund {
131138
case total
132139
case totalTax = "total_tax"
133140
case taxes
141+
case metadata = "meta_data"
134142
}
135143

136144
enum EncodingKeys: String, CodingKey {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
import Foundation
3+
4+
typealias OrderItemRefundMetaData = OrderMetaData

Networking/NetworkingTests/Mapper/RefundMapperTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private extension RefundMapperTests {
184184
name: "",
185185
productID: 1,
186186
variationID: 1,
187+
refundedItemID: "1",
187188
quantity: 1,
188189
price: 18.0,
189190
sku: nil,

Storage/Storage.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@
420420
B5B914C420EFF03500F2F832 /* Site+CoreDataProperties.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Site+CoreDataProperties.swift"; sourceTree = "<group>"; };
421421
B5FD111C21D4046E00560344 /* OrderSearchResults+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderSearchResults+CoreDataProperties.swift"; sourceTree = "<group>"; };
422422
B5FD111D21D4046E00560344 /* OrderSearchResults+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderSearchResults+CoreDataClass.swift"; sourceTree = "<group>"; };
423+
B963A5CA2853859400EFADA0 /* Model 70.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 70.xcdatamodel"; sourceTree = "<group>"; };
423424
BAB373732796310100837B4A /* Model 61.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 61.xcdatamodel"; sourceTree = "<group>"; };
424425
BAB373742796327000837B4A /* OrderTaxLine+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderTaxLine+CoreDataClass.swift"; sourceTree = "<group>"; };
425426
BAB373752796327000837B4A /* OrderTaxLine+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderTaxLine+CoreDataProperties.swift"; sourceTree = "<group>"; };
@@ -1792,6 +1793,7 @@
17921793
DEC51AA4275B41BE009F3DF4 /* WooCommerce.xcdatamodeld */ = {
17931794
isa = XCVersionGroup;
17941795
children = (
1796+
B963A5CA2853859400EFADA0 /* Model 70.xcdatamodel */,
17951797
268FEC8528513A470005E4C2 /* Model 69.xcdatamodel */,
17961798
45260E412823E7990080C548 /* Model 68.xcdatamodel */,
17971799
265A462127FDDAAF003AB1DA /* Model 67.xcdatamodel */,
@@ -1862,7 +1864,7 @@
18621864
DEC51ADE275B41BE009F3DF4 /* Model 47.xcdatamodel */,
18631865
DEC51ADF275B41BE009F3DF4 /* Model 19.xcdatamodel */,
18641866
);
1865-
currentVersion = 268FEC8528513A470005E4C2 /* Model 69.xcdatamodel */;
1867+
currentVersion = B963A5CA2853859400EFADA0 /* Model 70.xcdatamodel */;
18661868
path = WooCommerce.xcdatamodeld;
18671869
sourceTree = "<group>";
18681870
versionGroupType = wrapper.xcdatamodel;

Storage/Storage/Model/OrderItemRefund+CoreDataProperties.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ extension OrderItemRefund {
1212
@NSManaged public var name: String?
1313
@NSManaged public var productID: Int64
1414
@NSManaged public var variationID: Int64
15+
@NSManaged public var refundedItemID: String?
1516
@NSManaged public var quantity: NSDecimalNumber?
1617
@NSManaged public var price: NSDecimalNumber?
1718
@NSManaged public var sku: String?

Storage/Storage/Model/WooCommerce.xcdatamodeld/.xccurrentversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<plist version="1.0">
44
<dict>
55
<key>_XCCurrentVersionName</key>
6-
<string>Model 69.xcdatamodel</string>
6+
<string>Model 70.xcdatamodel</string>
77
</dict>
88
</plist>

0 commit comments

Comments
 (0)