@@ -11,8 +11,6 @@ struct PointOfSaleOrderDetailsView: View {
1111
1212 @Environment ( \. horizontalSizeClass) private var horizontalSizeClass
1313
14- private let helper = PointOfSaleOrderDetailsViewHelper ( )
15-
1614 private var shouldShowBackButton : Bool {
1715 horizontalSizeClass == . compact
1816 }
@@ -150,7 +148,8 @@ private extension PointOfSaleOrderDetailsView {
150148 productAttributesView ( item. attributes)
151149 }
152150
153- Text ( Localization . quantityLabel ( item. quantity. intValue, helper. formatItemPrice ( item. price, with: order. currency) ) )
151+ Text ( Localization . quantityLabel ( item. quantity. intValue,
152+ item. formattedPrice) )
154153 . font ( . posBodySmallRegular( ) )
155154 . foregroundStyle ( Color . posOnSurfaceVariantHighest)
156155 }
@@ -166,7 +165,7 @@ private extension PointOfSaleOrderDetailsView {
166165
167166 @ViewBuilder
168167 func productTotalView( item: POSOrderItem , order: POSOrder ) -> some View {
169- Text ( helper . formatItemTotal ( item. total , with : order . currency ) )
168+ Text ( item. formattedTotal )
170169 . font ( . posBodyMediumRegular( ) )
171170 . foregroundStyle ( Color . posOnSurface)
172171 }
@@ -177,40 +176,35 @@ private extension PointOfSaleOrderDetailsView {
177176private extension PointOfSaleOrderDetailsView {
178177 @ViewBuilder
179178 func productsSubtotalRow( _ order: POSOrder ) -> some View {
180- if helper. shouldShowProductsSubtotal ( for: order) {
181- totalsRow (
182- title: Localization . productsLabel,
183- amount: helper. productsSubtotal ( for: order)
184- )
185- }
179+ totalsRow (
180+ title: Localization . productsLabel,
181+ amount: order. formattedSubtotal
182+ )
186183 }
187184
188185 @ViewBuilder
189186 func discountTotalRow( _ order: POSOrder ) -> some View {
190- if helper. shouldShowDiscount ( for: order) ,
191- let discountAmount = helper. formattedDiscountTotal ( for: order) {
187+ if let formattedDiscountTotal = order. formattedDiscountTotal {
192188 totalsRow (
193189 title: Localization . discountTotalLabel,
194- amount: discountAmount
190+ amount: formattedDiscountTotal
195191 )
196192 }
197193 }
198194
199195 @ViewBuilder
200196 func taxTotalRow( _ order: POSOrder ) -> some View {
201- if let taxAmount = helper. formattedTaxTotal ( for: order) {
202- totalsRow (
203- title: Localization . taxesLabel,
204- amount: taxAmount
205- )
206- }
197+ totalsRow (
198+ title: Localization . taxesLabel,
199+ amount: order. formattedTotalTax
200+ )
207201 }
208202
209203 @ViewBuilder
210204 func mainTotalRow( _ order: POSOrder ) -> some View {
211205 totalsRow (
212206 title: Localization . totalLabel,
213- amount: helper . formattedOrderTotal ( for : order) ,
207+ amount: order. formattedTotal ,
214208 titleFont: . posBodyMediumBold
215209 )
216210 }
@@ -220,13 +214,15 @@ private extension PointOfSaleOrderDetailsView {
220214 VStack ( alignment: . leading, spacing: POSSpacing . xSmall) {
221215 totalsRow (
222216 title: Localization . paidLabel,
223- amount: helper . formattedPaidAmount ( for : order) ,
217+ amount: order. formattedPaymentTotal ,
224218 titleFont: . posBodyMediumBold
225219 )
226220
227- Text ( order. paymentMethodTitle)
228- . font ( . posBodySmallRegular( ) )
229- . foregroundStyle ( Color . posOnSurfaceVariantHighest)
221+ if order. paymentMethodTitle. isNotEmpty {
222+ Text ( order. paymentMethodTitle)
223+ . font ( . posBodySmallRegular( ) )
224+ . foregroundStyle ( Color . posOnSurfaceVariantHighest)
225+ }
230226 }
231227 }
232228
@@ -237,8 +233,8 @@ private extension PointOfSaleOrderDetailsView {
237233 refundRow ( refund: refund, order: order)
238234 }
239235
240- if helper . shouldShowNetPayment ( for : order) {
241- netPaymentRow ( order : order )
236+ if let netAmount = order. formattedNetAmount {
237+ netPaymentRow ( netAmount : netAmount )
242238 }
243239 }
244240 }
@@ -248,7 +244,7 @@ private extension PointOfSaleOrderDetailsView {
248244 VStack ( alignment: . leading, spacing: POSSpacing . xSmall) {
249245 totalsRow (
250246 title: Localization . refundLabel,
251- amount: helper . formattedRefundTotal ( refund, currency : order . currency ) ,
247+ amount: refund. formattedTotal ,
252248 titleFont: . posBodyMediumBold
253249 )
254250
@@ -261,10 +257,10 @@ private extension PointOfSaleOrderDetailsView {
261257 }
262258
263259 @ViewBuilder
264- func netPaymentRow( order : POSOrder ) -> some View {
260+ func netPaymentRow( netAmount : String ) -> some View {
265261 totalsRow (
266262 title: Localization . netPaymentLabel,
267- amount: helper . netPaymentAfterRefunds ( for : order ) ,
263+ amount: netAmount ,
268264 titleFont: . posBodyMediumBold
269265 )
270266 }
0 commit comments