Skip to content
Merged
Changes from all 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 @@ -71,6 +71,12 @@ final class OrderDetailsDataSource: NSObject {
!isEligibleForCardPresentPayment
}

/// Whether the row for amount paid should be visible.
///
private var shouldShowCustomerPaidRow: Bool {
order.datePaid != nil
}

/// Whether the option to re-create shipping labels should be visible.
///
var shouldAllowRecreatingShippingLabels: Bool {
Expand Down Expand Up @@ -515,7 +521,7 @@ private extension OrderDetailsDataSource {
}

private func configureRefund(cell: TwoColumnHeadlineFootnoteTableViewCell, at indexPath: IndexPath) {
let index = indexPath.row - Constants.paymentCell - Constants.paidByCustomerCell
let index = indexPath.row - Constants.paymentCell - Constants.paidByCustomerCell(isDisplayed: shouldShowCustomerPaidRow)
let condensedRefund = condensedRefunds[index]
let refund = lookUpRefund(by: condensedRefund.refundID)
let paymentViewModel = OrderPaymentDetailsViewModel(order: order, refund: refund)
Expand Down Expand Up @@ -1030,8 +1036,6 @@ extension OrderDetailsDataSource {
let payment: Section = {
var rows: [Row] = [.payment]

let shouldShowCustomerPaidRow = order.datePaid != nil

if shouldShowCustomerPaidRow {
rows.append(.customerPaid)
}
Expand Down Expand Up @@ -1109,7 +1113,7 @@ extension OrderDetailsDataSource {
}

func refund(at indexPath: IndexPath) -> Refund? {
let index = indexPath.row - Constants.paymentCell - Constants.paidByCustomerCell
let index = indexPath.row - Constants.paymentCell - Constants.paidByCustomerCell(isDisplayed: shouldShowCustomerPaidRow)
let condensedRefund = condensedRefunds[index]
let refund = refunds.first { $0.refundID == condensedRefund.refundID }

Expand Down Expand Up @@ -1501,10 +1505,15 @@ extension OrderDetailsDataSource {
case editShippingAddress
}

struct Constants {
enum Constants {
static let addOrderCell = 1
static let paymentCell = 1
static let paidByCustomerCell = 1

/// Input value required because cell is displayed conditionally
///
static func paidByCustomerCell(isDisplayed: Bool) -> Int {
isDisplayed ? 1 : 0
}
}
}

Expand Down