Skip to content

Commit 623f608

Browse files
committed
Merge branch 'trunk' into issue/6961-refactor-new-order-flow
2 parents 8941b13 + 39b9582 commit 623f608

File tree

77 files changed

+1616
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1616
-444
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ extension Order {
323323
parentID: .fake(),
324324
customerID: .fake(),
325325
orderKey: .fake(),
326+
isEditable: .fake(),
327+
needsPayment: .fake(),
328+
needsProcessing: .fake(),
326329
number: .fake(),
327330
status: .fake(),
328331
currency: .fake(),

Hardware/Hardware/Printer/AirPrintReceipt/ReceiptRenderer.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public extension ReceiptRenderer {
7373
<h1>\(receiptTitle)</h1>
7474
<h3>\(Localization.amountPaidSectionTitle.uppercased())</h3>
7575
<p>
76-
\(content.parameters.formattedAmount) \(content.parameters.currency.uppercased())
76+
\(content.parameters.formattedAmount)
7777
</p>
7878
<h3>\(Localization.datePaidSectionTitle.uppercased())</h3>
7979
<p>
@@ -126,7 +126,7 @@ private extension ReceiptRenderer {
126126
title.append(". \(variations.trimmingCharacters(in: .whitespaces))")
127127
}
128128
let stripedTitle = title.htmlStripped()
129-
summaryContent += "<tr><td>\(stripedTitle) × \(line.quantity)</td><td>\(line.amount) \(content.parameters.currency.uppercased())</td></tr>"
129+
summaryContent += "<tr><td>\(stripedTitle) × \(line.quantity)</td><td>\(line.amount)</td></tr>"
130130
}
131131
summaryContent += totalRows()
132132
summaryContent += "</table>"
@@ -149,7 +149,7 @@ private extension ReceiptRenderer {
149149
\(title)
150150
</td>
151151
<td>
152-
\(amount) \(content.parameters.currency.uppercased())
152+
\(amount)
153153
</td>
154154
</tr>
155155
"""

Hardware/HardwareTests/AirPrintReceipt/ReceiptRendererTest.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import CryptoKit
66

77
final class ReceiptRendererTest: XCTestCase {
88
func test_TextWithoutHtmlSymbols() {
9-
let expectedResultWithoutHtmlSymbolsMd5Description = "MD5 digest: aaf7e9f13e65797745b27b35deb87d5e"
9+
let expectedResultWithoutHtmlSymbolsMd5Description = "MD5 digest: dcf62ae7ac29fc305c280193887350b6"
1010
let content = generateReceiptContent()
1111

1212
let renderer = ReceiptRenderer(content: content)
@@ -18,7 +18,7 @@ final class ReceiptRendererTest: XCTestCase {
1818
}
1919

2020
func test_TextWithHtmlSymbols() {
21-
let expectedResultWithHtmlSymbolsMd5Description = "MD5 digest: 3c24eae234431b76f371f6198858c90f"
21+
let expectedResultWithHtmlSymbolsMd5Description = "MD5 digest: 40083b7f6ef076c8d84f8fca79611823"
2222
let stringWithHtml = "<tt><table></table></footer>"
2323
let content = generateReceiptContent(stringToAppend: stringWithHtml)
2424

@@ -31,7 +31,7 @@ final class ReceiptRendererTest: XCTestCase {
3131
}
3232

3333
func test_TextWithVariationsSymbols() {
34-
let expectedResultWithHtmlSymbolsMd5Description = "MD5 digest: b28ce45f9b2be604b22ef68378529874"
34+
let expectedResultWithHtmlSymbolsMd5Description = "MD5 digest: a30f786359ebb6197b58fe1eaddbb04f"
3535
let attributeOne = ReceiptLineAttribute(name: "name_attr_1", value: "value_attr_1")
3636
let attributeTwo = ReceiptLineAttribute(name: "name_attr_2", value: "value_attr_2")
3737
let content = generateReceiptContent(attributes: [attributeOne, attributeTwo])
@@ -52,7 +52,7 @@ private extension ReceiptRendererTest {
5252
ReceiptContent(
5353
parameters: CardPresentReceiptParameters(
5454
amount: 1,
55-
formattedAmount: "1",
55+
formattedAmount: "$1",
5656
currency: "USD",
5757
date: .init(timeIntervalSince1970: 1636970486),
5858
storeName: "Test Store",
@@ -79,9 +79,9 @@ private extension ReceiptRendererTest {
7979
lineItems: [ReceiptLineItem(
8080
title: "Sample product #1\(stringToAppend)",
8181
quantity: "2",
82-
amount: "25",
82+
amount: "$25",
8383
attributes: attributes)],
84-
cartTotals: [ReceiptTotalLine(description: "description", amount: "13")],
84+
cartTotals: [ReceiptTotalLine(description: "description", amount: "$13")],
8585
orderNote: nil
8686
)
8787
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ extension Order {
242242
parentID: CopiableProp<Int64> = .copy,
243243
customerID: CopiableProp<Int64> = .copy,
244244
orderKey: CopiableProp<String> = .copy,
245+
isEditable: CopiableProp<Bool> = .copy,
246+
needsPayment: CopiableProp<Bool> = .copy,
247+
needsProcessing: CopiableProp<Bool> = .copy,
245248
number: CopiableProp<String> = .copy,
246249
status: CopiableProp<OrderStatusEnum> = .copy,
247250
currency: CopiableProp<String> = .copy,
@@ -273,6 +276,9 @@ extension Order {
273276
let parentID = parentID ?? self.parentID
274277
let customerID = customerID ?? self.customerID
275278
let orderKey = orderKey ?? self.orderKey
279+
let isEditable = isEditable ?? self.isEditable
280+
let needsPayment = needsPayment ?? self.needsPayment
281+
let needsProcessing = needsProcessing ?? self.needsProcessing
276282
let number = number ?? self.number
277283
let status = status ?? self.status
278284
let currency = currency ?? self.currency
@@ -305,6 +311,9 @@ extension Order {
305311
parentID: parentID,
306312
customerID: customerID,
307313
orderKey: orderKey,
314+
isEditable: isEditable,
315+
needsPayment: needsPayment,
316+
needsProcessing: needsProcessing,
308317
number: number,
309318
status: status,
310319
currency: currency,

Networking/Networking/Model/Order.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public struct Order: Decodable, GeneratedCopiable, GeneratedFakeable {
1010
public let customerID: Int64
1111
public let orderKey: String
1212

13+
public let isEditable: Bool
14+
public let needsPayment: Bool
15+
public let needsProcessing: Bool
1316
public let number: String
1417
/// The Order status.
1518
///
@@ -50,6 +53,9 @@ public struct Order: Decodable, GeneratedCopiable, GeneratedFakeable {
5053
parentID: Int64,
5154
customerID: Int64,
5255
orderKey: String,
56+
isEditable: Bool,
57+
needsPayment: Bool,
58+
needsProcessing: Bool,
5359
number: String,
5460
status: OrderStatusEnum,
5561
currency: String,
@@ -82,6 +88,9 @@ public struct Order: Decodable, GeneratedCopiable, GeneratedFakeable {
8288
self.customerID = customerID
8389
self.orderKey = orderKey
8490

91+
self.isEditable = isEditable
92+
self.needsPayment = needsPayment
93+
self.needsProcessing = needsProcessing
8594
self.number = number
8695
self.status = status
8796
self.currency = currency
@@ -127,6 +136,11 @@ public struct Order: Decodable, GeneratedCopiable, GeneratedFakeable {
127136
let customerID = try container.decode(Int64.self, forKey: .customerID)
128137
let orderKey = try container.decode(String.self, forKey: .orderKey)
129138

139+
// TODO: Update with local fallback implementation https://github.com/woocommerce/woocommerce-ios/issues/6977
140+
let isEditable = try container.decodeIfPresent(Bool.self, forKey: .isEditable) ?? false
141+
let needsPayment = try container.decodeIfPresent(Bool.self, forKey: .needsPayment) ?? false
142+
let needsProcessing = try container.decodeIfPresent(Bool.self, forKey: .needsProcessing) ?? false
143+
130144
let number = try container.decode(String.self, forKey: .number)
131145
let status = try container.decode(OrderStatusEnum.self, forKey: .status)
132146

@@ -183,6 +197,9 @@ public struct Order: Decodable, GeneratedCopiable, GeneratedFakeable {
183197
parentID: parentID,
184198
customerID: customerID,
185199
orderKey: orderKey,
200+
isEditable: isEditable,
201+
needsPayment: needsPayment,
202+
needsProcessing: needsProcessing,
186203
number: number,
187204
status: status,
188205
currency: currency,
@@ -216,6 +233,9 @@ public struct Order: Decodable, GeneratedCopiable, GeneratedFakeable {
216233
parentID: 0,
217234
customerID: 0,
218235
orderKey: "",
236+
isEditable: false,
237+
needsPayment: false,
238+
needsProcessing: false,
219239
number: "",
220240
status: .pending,
221241
currency: "",
@@ -255,6 +275,9 @@ internal extension Order {
255275
case customerID = "customer_id"
256276
case orderKey = "order_key"
257277

278+
case isEditable = "is_editable"
279+
case needsPayment = "needs_payment"
280+
case needsProcessing = "needs_processing"
258281
case number = "number"
259282
case status = "status"
260283
case currency = "currency"
@@ -297,6 +320,9 @@ extension Order: Equatable {
297320
lhs.parentID == rhs.parentID &&
298321
lhs.customerID == rhs.customerID &&
299322
lhs.orderKey == rhs.orderKey &&
323+
lhs.isEditable == rhs.isEditable &&
324+
lhs.needsPayment == rhs.needsPayment &&
325+
lhs.needsProcessing == rhs.needsProcessing &&
300326
lhs.number == rhs.number &&
301327
lhs.status == rhs.status &&
302328
lhs.dateCreated == rhs.dateCreated &&

Networking/Networking/Remote/OrdersRemote.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ public extension OrdersRemote {
294294
private static let commonOrderFieldValues = [
295295
"id", "parent_id", "number", "status", "currency", "customer_id", "customer_note", "date_created_gmt", "date_modified_gmt", "date_paid_gmt",
296296
"discount_total", "discount_tax", "shipping_total", "shipping_tax", "total", "total_tax", "payment_method", "payment_method_title",
297-
"payment_url", "billing", "coupon_lines", "shipping_lines", "refunds", "fee_lines", "order_key", "tax_lines", "meta_data"
297+
"payment_url", "billing", "coupon_lines", "shipping_lines", "refunds", "fee_lines", "order_key", "tax_lines", "meta_data", "is_editable",
298+
"needs_payment", "needs_processing"
298299
]
299300
// Use with caution. Any fields in here will be overwritten with empty values by
300301
// `Order+ReadOnlyConvertible.swift: Order.update(with:)` when the list of orders is fetched.

Networking/NetworkingTests/Remote/OrdersRemoteTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,26 @@ final class OrdersRemoteTests: XCTestCase {
110110
wait(for: [expectation], timeout: Constants.expectationTimeout)
111111
}
112112

113+
func test_load_single_order_properly_returns_WC6_6_new_fields() {
114+
// Given
115+
let remote = OrdersRemote(network: network)
116+
network.simulateResponse(requestUrlSuffix: "orders/\(sampleOrderID)", filename: "order")
117+
118+
// When
119+
let order: Order = waitFor { promise in
120+
remote.loadOrder(for: self.sampleSiteID, orderID: self.sampleOrderID) { order, error in
121+
if let order = order {
122+
promise(order)
123+
}
124+
}
125+
}
126+
127+
// Then
128+
XCTAssertTrue(order.isEditable)
129+
XCTAssertTrue(order.needsPayment)
130+
XCTAssertTrue(order.needsProcessing)
131+
}
132+
113133
/// Verifies that loadOrder properly relays any Networking Layer errors.
114134
///
115135
func testLoadSingleOrderProperlyRelaysNetworkingErrors() {

Networking/NetworkingTests/Responses/order.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"data": {
33
"id": 963,
44
"parent_id": 0,
5+
"is_editable": true,
6+
"needs_payment": true,
7+
"needs_processing": true,
58
"number": "963",
69
"status": "processing",
710
"order_key": "abc123",

Networking/NetworkingTests/Responses/orders-load-all.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
{
44
"id": 963,
55
"parent_id": 0,
6+
"is_editable": true,
7+
"needs_payment": true,
8+
"needs_processing": true,
69
"number": "963",
710
"status": "processing",
811
"order_key": "abc123",

Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ target 'WooCommerce' do
6464
pod 'CocoaLumberjack', '~> 3.7.4'
6565
pod 'CocoaLumberjack/Swift', '~> 3.7.4'
6666
pod 'XLPagerTabStrip', '~> 9.0'
67-
pod 'Charts', '~> 3.6.0'
6867
pod 'ZendeskSupportSDK', '~> 5.0'
6968
pod 'StripeTerminal', '~> 2.7'
7069
pod 'Kingfisher', '~> 7.2.2'

0 commit comments

Comments
 (0)