create order with payment
This commit is contained in:
parent
37f0008ec8
commit
137f3d9636
@ -66,6 +66,46 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
|
|||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
failureOrOrder = await _repository.createOrderWithPayment(
|
||||||
|
request: request,
|
||||||
|
paymentMethodId: state.paymentMethod?.id ?? '',
|
||||||
|
);
|
||||||
|
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
isCreating: false,
|
||||||
|
failureOrCreateOrder: optionOf(failureOrOrder),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
createOrder: (e) async {
|
||||||
|
Either<OrderFailure, Order> failureOrOrder;
|
||||||
|
|
||||||
|
emit(state.copyWith(isCreating: true, failureOrCreateOrder: none()));
|
||||||
|
|
||||||
|
final outlet = await _outletRepository.currentOutlet();
|
||||||
|
|
||||||
|
final request = OrderRequest(
|
||||||
|
outletId: outlet.id,
|
||||||
|
customerId: state.customer?.id ?? '',
|
||||||
|
tableNumber: e.table?.tableName ?? '',
|
||||||
|
tableId: e.table?.id ?? '',
|
||||||
|
orderType: e.orderType.name,
|
||||||
|
notes: '',
|
||||||
|
customerName: state.customerName ?? "",
|
||||||
|
orderItems: e.items
|
||||||
|
.map(
|
||||||
|
(item) => OrderItemRequest(
|
||||||
|
productId: item.product.id,
|
||||||
|
productVariantId: item.variant?.id ?? "",
|
||||||
|
quantity: item.quantity,
|
||||||
|
unitPrice: item.product.price.toInt(),
|
||||||
|
notes: item.notes,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
|
||||||
failureOrOrder = await _repository.createOrder(request: request);
|
failureOrOrder = await _repository.createOrder(request: request);
|
||||||
|
|
||||||
emit(
|
emit(
|
||||||
|
|||||||
@ -28,6 +28,12 @@ mixin _$OrderFormEvent {
|
|||||||
Table? table,
|
Table? table,
|
||||||
)
|
)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)
|
||||||
|
createOrder,
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
@ -40,6 +46,12 @@ mixin _$OrderFormEvent {
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult? Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
@ -52,6 +64,12 @@ mixin _$OrderFormEvent {
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -61,6 +79,7 @@ mixin _$OrderFormEvent {
|
|||||||
required TResult Function(_CustomerChanged value) customerChanged,
|
required TResult Function(_CustomerChanged value) customerChanged,
|
||||||
required TResult Function(_CreateOrderWithPayment value)
|
required TResult Function(_CreateOrderWithPayment value)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(_CreateOrder value) createOrder,
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
@ -68,6 +87,7 @@ mixin _$OrderFormEvent {
|
|||||||
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult? Function(_CustomerChanged value)? customerChanged,
|
TResult? Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult? Function(_CreateOrder value)? createOrder,
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
@ -75,6 +95,7 @@ mixin _$OrderFormEvent {
|
|||||||
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult Function(_CustomerChanged value)? customerChanged,
|
TResult Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult Function(_CreateOrder value)? createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
@ -194,6 +215,12 @@ class _$CustomerNameChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)
|
)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)
|
||||||
|
createOrder,
|
||||||
}) {
|
}) {
|
||||||
return customerNameChanged(customerName);
|
return customerNameChanged(customerName);
|
||||||
}
|
}
|
||||||
@ -210,6 +237,12 @@ class _$CustomerNameChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult? Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
}) {
|
}) {
|
||||||
return customerNameChanged?.call(customerName);
|
return customerNameChanged?.call(customerName);
|
||||||
}
|
}
|
||||||
@ -226,6 +259,12 @@ class _$CustomerNameChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (customerNameChanged != null) {
|
if (customerNameChanged != null) {
|
||||||
@ -242,6 +281,7 @@ class _$CustomerNameChangedImpl
|
|||||||
required TResult Function(_CustomerChanged value) customerChanged,
|
required TResult Function(_CustomerChanged value) customerChanged,
|
||||||
required TResult Function(_CreateOrderWithPayment value)
|
required TResult Function(_CreateOrderWithPayment value)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(_CreateOrder value) createOrder,
|
||||||
}) {
|
}) {
|
||||||
return customerNameChanged(this);
|
return customerNameChanged(this);
|
||||||
}
|
}
|
||||||
@ -253,6 +293,7 @@ class _$CustomerNameChangedImpl
|
|||||||
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult? Function(_CustomerChanged value)? customerChanged,
|
TResult? Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult? Function(_CreateOrder value)? createOrder,
|
||||||
}) {
|
}) {
|
||||||
return customerNameChanged?.call(this);
|
return customerNameChanged?.call(this);
|
||||||
}
|
}
|
||||||
@ -264,6 +305,7 @@ class _$CustomerNameChangedImpl
|
|||||||
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult Function(_CustomerChanged value)? customerChanged,
|
TResult Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult Function(_CreateOrder value)? createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (customerNameChanged != null) {
|
if (customerNameChanged != null) {
|
||||||
@ -391,6 +433,12 @@ class _$PaymentMethodChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)
|
)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)
|
||||||
|
createOrder,
|
||||||
}) {
|
}) {
|
||||||
return paymentMethodChanged(payment);
|
return paymentMethodChanged(payment);
|
||||||
}
|
}
|
||||||
@ -407,6 +455,12 @@ class _$PaymentMethodChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult? Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
}) {
|
}) {
|
||||||
return paymentMethodChanged?.call(payment);
|
return paymentMethodChanged?.call(payment);
|
||||||
}
|
}
|
||||||
@ -423,6 +477,12 @@ class _$PaymentMethodChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (paymentMethodChanged != null) {
|
if (paymentMethodChanged != null) {
|
||||||
@ -439,6 +499,7 @@ class _$PaymentMethodChangedImpl
|
|||||||
required TResult Function(_CustomerChanged value) customerChanged,
|
required TResult Function(_CustomerChanged value) customerChanged,
|
||||||
required TResult Function(_CreateOrderWithPayment value)
|
required TResult Function(_CreateOrderWithPayment value)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(_CreateOrder value) createOrder,
|
||||||
}) {
|
}) {
|
||||||
return paymentMethodChanged(this);
|
return paymentMethodChanged(this);
|
||||||
}
|
}
|
||||||
@ -450,6 +511,7 @@ class _$PaymentMethodChangedImpl
|
|||||||
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult? Function(_CustomerChanged value)? customerChanged,
|
TResult? Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult? Function(_CreateOrder value)? createOrder,
|
||||||
}) {
|
}) {
|
||||||
return paymentMethodChanged?.call(this);
|
return paymentMethodChanged?.call(this);
|
||||||
}
|
}
|
||||||
@ -461,6 +523,7 @@ class _$PaymentMethodChangedImpl
|
|||||||
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult Function(_CustomerChanged value)? customerChanged,
|
TResult Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult Function(_CreateOrder value)? createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (paymentMethodChanged != null) {
|
if (paymentMethodChanged != null) {
|
||||||
@ -592,6 +655,12 @@ class _$CustomerChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)
|
)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)
|
||||||
|
createOrder,
|
||||||
}) {
|
}) {
|
||||||
return customerChanged(customer);
|
return customerChanged(customer);
|
||||||
}
|
}
|
||||||
@ -608,6 +677,12 @@ class _$CustomerChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult? Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
}) {
|
}) {
|
||||||
return customerChanged?.call(customer);
|
return customerChanged?.call(customer);
|
||||||
}
|
}
|
||||||
@ -624,6 +699,12 @@ class _$CustomerChangedImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (customerChanged != null) {
|
if (customerChanged != null) {
|
||||||
@ -640,6 +721,7 @@ class _$CustomerChangedImpl
|
|||||||
required TResult Function(_CustomerChanged value) customerChanged,
|
required TResult Function(_CustomerChanged value) customerChanged,
|
||||||
required TResult Function(_CreateOrderWithPayment value)
|
required TResult Function(_CreateOrderWithPayment value)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(_CreateOrder value) createOrder,
|
||||||
}) {
|
}) {
|
||||||
return customerChanged(this);
|
return customerChanged(this);
|
||||||
}
|
}
|
||||||
@ -651,6 +733,7 @@ class _$CustomerChangedImpl
|
|||||||
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult? Function(_CustomerChanged value)? customerChanged,
|
TResult? Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult? Function(_CreateOrder value)? createOrder,
|
||||||
}) {
|
}) {
|
||||||
return customerChanged?.call(this);
|
return customerChanged?.call(this);
|
||||||
}
|
}
|
||||||
@ -662,6 +745,7 @@ class _$CustomerChangedImpl
|
|||||||
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult Function(_CustomerChanged value)? customerChanged,
|
TResult Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult Function(_CreateOrder value)? createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (customerChanged != null) {
|
if (customerChanged != null) {
|
||||||
@ -831,6 +915,12 @@ class _$CreateOrderWithPaymentImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)
|
)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)
|
||||||
|
createOrder,
|
||||||
}) {
|
}) {
|
||||||
return createOrderWithPayment(items, orderType, table);
|
return createOrderWithPayment(items, orderType, table);
|
||||||
}
|
}
|
||||||
@ -847,6 +937,12 @@ class _$CreateOrderWithPaymentImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult? Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
}) {
|
}) {
|
||||||
return createOrderWithPayment?.call(items, orderType, table);
|
return createOrderWithPayment?.call(items, orderType, table);
|
||||||
}
|
}
|
||||||
@ -863,6 +959,12 @@ class _$CreateOrderWithPaymentImpl
|
|||||||
Table? table,
|
Table? table,
|
||||||
)?
|
)?
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (createOrderWithPayment != null) {
|
if (createOrderWithPayment != null) {
|
||||||
@ -879,6 +981,7 @@ class _$CreateOrderWithPaymentImpl
|
|||||||
required TResult Function(_CustomerChanged value) customerChanged,
|
required TResult Function(_CustomerChanged value) customerChanged,
|
||||||
required TResult Function(_CreateOrderWithPayment value)
|
required TResult Function(_CreateOrderWithPayment value)
|
||||||
createOrderWithPayment,
|
createOrderWithPayment,
|
||||||
|
required TResult Function(_CreateOrder value) createOrder,
|
||||||
}) {
|
}) {
|
||||||
return createOrderWithPayment(this);
|
return createOrderWithPayment(this);
|
||||||
}
|
}
|
||||||
@ -890,6 +993,7 @@ class _$CreateOrderWithPaymentImpl
|
|||||||
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult? Function(_CustomerChanged value)? customerChanged,
|
TResult? Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult? Function(_CreateOrder value)? createOrder,
|
||||||
}) {
|
}) {
|
||||||
return createOrderWithPayment?.call(this);
|
return createOrderWithPayment?.call(this);
|
||||||
}
|
}
|
||||||
@ -901,6 +1005,7 @@ class _$CreateOrderWithPaymentImpl
|
|||||||
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
TResult Function(_CustomerChanged value)? customerChanged,
|
TResult Function(_CustomerChanged value)? customerChanged,
|
||||||
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult Function(_CreateOrder value)? createOrder,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (createOrderWithPayment != null) {
|
if (createOrderWithPayment != null) {
|
||||||
@ -928,6 +1033,263 @@ abstract class _CreateOrderWithPayment implements OrderFormEvent {
|
|||||||
get copyWith => throw _privateConstructorUsedError;
|
get copyWith => throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$CreateOrderImplCopyWith<$Res> {
|
||||||
|
factory _$$CreateOrderImplCopyWith(
|
||||||
|
_$CreateOrderImpl value,
|
||||||
|
$Res Function(_$CreateOrderImpl) then,
|
||||||
|
) = __$$CreateOrderImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({List<ProductQuantity> items, OrderType orderType, Table? table});
|
||||||
|
|
||||||
|
$TableCopyWith<$Res>? get table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$CreateOrderImplCopyWithImpl<$Res>
|
||||||
|
extends _$OrderFormEventCopyWithImpl<$Res, _$CreateOrderImpl>
|
||||||
|
implements _$$CreateOrderImplCopyWith<$Res> {
|
||||||
|
__$$CreateOrderImplCopyWithImpl(
|
||||||
|
_$CreateOrderImpl _value,
|
||||||
|
$Res Function(_$CreateOrderImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of OrderFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? items = null,
|
||||||
|
Object? orderType = null,
|
||||||
|
Object? table = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(
|
||||||
|
_$CreateOrderImpl(
|
||||||
|
items: null == items
|
||||||
|
? _value._items
|
||||||
|
: items // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<ProductQuantity>,
|
||||||
|
orderType: null == orderType
|
||||||
|
? _value.orderType
|
||||||
|
: orderType // ignore: cast_nullable_to_non_nullable
|
||||||
|
as OrderType,
|
||||||
|
table: freezed == table
|
||||||
|
? _value.table
|
||||||
|
: table // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Table?,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a copy of OrderFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$TableCopyWith<$Res>? get table {
|
||||||
|
if (_value.table == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $TableCopyWith<$Res>(_value.table!, (value) {
|
||||||
|
return _then(_value.copyWith(table: value));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$CreateOrderImpl with DiagnosticableTreeMixin implements _CreateOrder {
|
||||||
|
const _$CreateOrderImpl({
|
||||||
|
required final List<ProductQuantity> items,
|
||||||
|
required this.orderType,
|
||||||
|
this.table,
|
||||||
|
}) : _items = items;
|
||||||
|
|
||||||
|
final List<ProductQuantity> _items;
|
||||||
|
@override
|
||||||
|
List<ProductQuantity> get items {
|
||||||
|
if (_items is EqualUnmodifiableListView) return _items;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_items);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
final OrderType orderType;
|
||||||
|
@override
|
||||||
|
final Table? table;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||||
|
return 'OrderFormEvent.createOrder(items: $items, orderType: $orderType, table: $table)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
super.debugFillProperties(properties);
|
||||||
|
properties
|
||||||
|
..add(DiagnosticsProperty('type', 'OrderFormEvent.createOrder'))
|
||||||
|
..add(DiagnosticsProperty('items', items))
|
||||||
|
..add(DiagnosticsProperty('orderType', orderType))
|
||||||
|
..add(DiagnosticsProperty('table', table));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$CreateOrderImpl &&
|
||||||
|
const DeepCollectionEquality().equals(other._items, _items) &&
|
||||||
|
(identical(other.orderType, orderType) ||
|
||||||
|
other.orderType == orderType) &&
|
||||||
|
(identical(other.table, table) || other.table == table));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType,
|
||||||
|
const DeepCollectionEquality().hash(_items),
|
||||||
|
orderType,
|
||||||
|
table,
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Create a copy of OrderFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$CreateOrderImplCopyWith<_$CreateOrderImpl> get copyWith =>
|
||||||
|
__$$CreateOrderImplCopyWithImpl<_$CreateOrderImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(String customerName) customerNameChanged,
|
||||||
|
required TResult Function(PaymentMethod payment) paymentMethodChanged,
|
||||||
|
required TResult Function(Customer? customer) customerChanged,
|
||||||
|
required TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)
|
||||||
|
createOrderWithPayment,
|
||||||
|
required TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)
|
||||||
|
createOrder,
|
||||||
|
}) {
|
||||||
|
return createOrder(items, orderType, table);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(String customerName)? customerNameChanged,
|
||||||
|
TResult? Function(PaymentMethod payment)? paymentMethodChanged,
|
||||||
|
TResult? Function(Customer? customer)? customerChanged,
|
||||||
|
TResult? Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrderWithPayment,
|
||||||
|
TResult? Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
|
}) {
|
||||||
|
return createOrder?.call(items, orderType, table);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(String customerName)? customerNameChanged,
|
||||||
|
TResult Function(PaymentMethod payment)? paymentMethodChanged,
|
||||||
|
TResult Function(Customer? customer)? customerChanged,
|
||||||
|
TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrderWithPayment,
|
||||||
|
TResult Function(
|
||||||
|
List<ProductQuantity> items,
|
||||||
|
OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
)?
|
||||||
|
createOrder,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (createOrder != null) {
|
||||||
|
return createOrder(items, orderType, table);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||||
|
required TResult Function(_PaymentMethodChanged value) paymentMethodChanged,
|
||||||
|
required TResult Function(_CustomerChanged value) customerChanged,
|
||||||
|
required TResult Function(_CreateOrderWithPayment value)
|
||||||
|
createOrderWithPayment,
|
||||||
|
required TResult Function(_CreateOrder value) createOrder,
|
||||||
|
}) {
|
||||||
|
return createOrder(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||||
|
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
|
TResult? Function(_CustomerChanged value)? customerChanged,
|
||||||
|
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult? Function(_CreateOrder value)? createOrder,
|
||||||
|
}) {
|
||||||
|
return createOrder?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||||
|
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
|
||||||
|
TResult Function(_CustomerChanged value)? customerChanged,
|
||||||
|
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
|
||||||
|
TResult Function(_CreateOrder value)? createOrder,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (createOrder != null) {
|
||||||
|
return createOrder(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _CreateOrder implements OrderFormEvent {
|
||||||
|
const factory _CreateOrder({
|
||||||
|
required final List<ProductQuantity> items,
|
||||||
|
required final OrderType orderType,
|
||||||
|
final Table? table,
|
||||||
|
}) = _$CreateOrderImpl;
|
||||||
|
|
||||||
|
List<ProductQuantity> get items;
|
||||||
|
OrderType get orderType;
|
||||||
|
Table? get table;
|
||||||
|
|
||||||
|
/// Create a copy of OrderFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$CreateOrderImplCopyWith<_$CreateOrderImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$OrderFormState {
|
mixin _$OrderFormState {
|
||||||
PaymentMethod? get paymentMethod => throw _privateConstructorUsedError;
|
PaymentMethod? get paymentMethod => throw _privateConstructorUsedError;
|
||||||
@ -935,7 +1297,10 @@ mixin _$OrderFormState {
|
|||||||
Customer? get customer => throw _privateConstructorUsedError;
|
Customer? get customer => throw _privateConstructorUsedError;
|
||||||
Option<Either<OrderFailure, Order>> get failureOrCreateOrder =>
|
Option<Either<OrderFailure, Order>> get failureOrCreateOrder =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
Option<Either<OrderFailure, Order>> get failureOrCreateOrderWithPayment =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
bool get isCreating => throw _privateConstructorUsedError;
|
bool get isCreating => throw _privateConstructorUsedError;
|
||||||
|
bool get isCreatingWithPayment => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
/// Create a copy of OrderFormState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -956,7 +1321,9 @@ abstract class $OrderFormStateCopyWith<$Res> {
|
|||||||
String? customerName,
|
String? customerName,
|
||||||
Customer? customer,
|
Customer? customer,
|
||||||
Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
||||||
|
Option<Either<OrderFailure, Order>> failureOrCreateOrderWithPayment,
|
||||||
bool isCreating,
|
bool isCreating,
|
||||||
|
bool isCreatingWithPayment,
|
||||||
});
|
});
|
||||||
|
|
||||||
$PaymentMethodCopyWith<$Res>? get paymentMethod;
|
$PaymentMethodCopyWith<$Res>? get paymentMethod;
|
||||||
@ -982,7 +1349,9 @@ class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState>
|
|||||||
Object? customerName = freezed,
|
Object? customerName = freezed,
|
||||||
Object? customer = freezed,
|
Object? customer = freezed,
|
||||||
Object? failureOrCreateOrder = null,
|
Object? failureOrCreateOrder = null,
|
||||||
|
Object? failureOrCreateOrderWithPayment = null,
|
||||||
Object? isCreating = null,
|
Object? isCreating = null,
|
||||||
|
Object? isCreatingWithPayment = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(
|
return _then(
|
||||||
_value.copyWith(
|
_value.copyWith(
|
||||||
@ -1002,10 +1371,19 @@ class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState>
|
|||||||
? _value.failureOrCreateOrder
|
? _value.failureOrCreateOrder
|
||||||
: failureOrCreateOrder // ignore: cast_nullable_to_non_nullable
|
: failureOrCreateOrder // ignore: cast_nullable_to_non_nullable
|
||||||
as Option<Either<OrderFailure, Order>>,
|
as Option<Either<OrderFailure, Order>>,
|
||||||
|
failureOrCreateOrderWithPayment:
|
||||||
|
null == failureOrCreateOrderWithPayment
|
||||||
|
? _value.failureOrCreateOrderWithPayment
|
||||||
|
: failureOrCreateOrderWithPayment // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Option<Either<OrderFailure, Order>>,
|
||||||
isCreating: null == isCreating
|
isCreating: null == isCreating
|
||||||
? _value.isCreating
|
? _value.isCreating
|
||||||
: isCreating // ignore: cast_nullable_to_non_nullable
|
: isCreating // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,
|
as bool,
|
||||||
|
isCreatingWithPayment: null == isCreatingWithPayment
|
||||||
|
? _value.isCreatingWithPayment
|
||||||
|
: isCreatingWithPayment // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
)
|
)
|
||||||
as $Val,
|
as $Val,
|
||||||
);
|
);
|
||||||
@ -1054,7 +1432,9 @@ abstract class _$$OrderFormStateImplCopyWith<$Res>
|
|||||||
String? customerName,
|
String? customerName,
|
||||||
Customer? customer,
|
Customer? customer,
|
||||||
Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
||||||
|
Option<Either<OrderFailure, Order>> failureOrCreateOrderWithPayment,
|
||||||
bool isCreating,
|
bool isCreating,
|
||||||
|
bool isCreatingWithPayment,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1081,7 +1461,9 @@ class __$$OrderFormStateImplCopyWithImpl<$Res>
|
|||||||
Object? customerName = freezed,
|
Object? customerName = freezed,
|
||||||
Object? customer = freezed,
|
Object? customer = freezed,
|
||||||
Object? failureOrCreateOrder = null,
|
Object? failureOrCreateOrder = null,
|
||||||
|
Object? failureOrCreateOrderWithPayment = null,
|
||||||
Object? isCreating = null,
|
Object? isCreating = null,
|
||||||
|
Object? isCreatingWithPayment = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(
|
return _then(
|
||||||
_$OrderFormStateImpl(
|
_$OrderFormStateImpl(
|
||||||
@ -1101,10 +1483,18 @@ class __$$OrderFormStateImplCopyWithImpl<$Res>
|
|||||||
? _value.failureOrCreateOrder
|
? _value.failureOrCreateOrder
|
||||||
: failureOrCreateOrder // ignore: cast_nullable_to_non_nullable
|
: failureOrCreateOrder // ignore: cast_nullable_to_non_nullable
|
||||||
as Option<Either<OrderFailure, Order>>,
|
as Option<Either<OrderFailure, Order>>,
|
||||||
|
failureOrCreateOrderWithPayment: null == failureOrCreateOrderWithPayment
|
||||||
|
? _value.failureOrCreateOrderWithPayment
|
||||||
|
: failureOrCreateOrderWithPayment // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Option<Either<OrderFailure, Order>>,
|
||||||
isCreating: null == isCreating
|
isCreating: null == isCreating
|
||||||
? _value.isCreating
|
? _value.isCreating
|
||||||
: isCreating // ignore: cast_nullable_to_non_nullable
|
: isCreating // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,
|
as bool,
|
||||||
|
isCreatingWithPayment: null == isCreatingWithPayment
|
||||||
|
? _value.isCreatingWithPayment
|
||||||
|
: isCreatingWithPayment // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1120,7 +1510,9 @@ class _$OrderFormStateImpl
|
|||||||
this.customerName,
|
this.customerName,
|
||||||
this.customer,
|
this.customer,
|
||||||
required this.failureOrCreateOrder,
|
required this.failureOrCreateOrder,
|
||||||
|
required this.failureOrCreateOrderWithPayment,
|
||||||
this.isCreating = false,
|
this.isCreating = false,
|
||||||
|
this.isCreatingWithPayment = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1132,12 +1524,17 @@ class _$OrderFormStateImpl
|
|||||||
@override
|
@override
|
||||||
final Option<Either<OrderFailure, Order>> failureOrCreateOrder;
|
final Option<Either<OrderFailure, Order>> failureOrCreateOrder;
|
||||||
@override
|
@override
|
||||||
|
final Option<Either<OrderFailure, Order>> failureOrCreateOrderWithPayment;
|
||||||
|
@override
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
final bool isCreating;
|
final bool isCreating;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool isCreatingWithPayment;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||||
return 'OrderFormState(paymentMethod: $paymentMethod, customerName: $customerName, customer: $customer, failureOrCreateOrder: $failureOrCreateOrder, isCreating: $isCreating)';
|
return 'OrderFormState(paymentMethod: $paymentMethod, customerName: $customerName, customer: $customer, failureOrCreateOrder: $failureOrCreateOrder, failureOrCreateOrderWithPayment: $failureOrCreateOrderWithPayment, isCreating: $isCreating, isCreatingWithPayment: $isCreatingWithPayment)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1149,7 +1546,16 @@ class _$OrderFormStateImpl
|
|||||||
..add(DiagnosticsProperty('customerName', customerName))
|
..add(DiagnosticsProperty('customerName', customerName))
|
||||||
..add(DiagnosticsProperty('customer', customer))
|
..add(DiagnosticsProperty('customer', customer))
|
||||||
..add(DiagnosticsProperty('failureOrCreateOrder', failureOrCreateOrder))
|
..add(DiagnosticsProperty('failureOrCreateOrder', failureOrCreateOrder))
|
||||||
..add(DiagnosticsProperty('isCreating', isCreating));
|
..add(
|
||||||
|
DiagnosticsProperty(
|
||||||
|
'failureOrCreateOrderWithPayment',
|
||||||
|
failureOrCreateOrderWithPayment,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..add(DiagnosticsProperty('isCreating', isCreating))
|
||||||
|
..add(
|
||||||
|
DiagnosticsProperty('isCreatingWithPayment', isCreatingWithPayment),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1165,8 +1571,16 @@ class _$OrderFormStateImpl
|
|||||||
other.customer == customer) &&
|
other.customer == customer) &&
|
||||||
(identical(other.failureOrCreateOrder, failureOrCreateOrder) ||
|
(identical(other.failureOrCreateOrder, failureOrCreateOrder) ||
|
||||||
other.failureOrCreateOrder == failureOrCreateOrder) &&
|
other.failureOrCreateOrder == failureOrCreateOrder) &&
|
||||||
|
(identical(
|
||||||
|
other.failureOrCreateOrderWithPayment,
|
||||||
|
failureOrCreateOrderWithPayment,
|
||||||
|
) ||
|
||||||
|
other.failureOrCreateOrderWithPayment ==
|
||||||
|
failureOrCreateOrderWithPayment) &&
|
||||||
(identical(other.isCreating, isCreating) ||
|
(identical(other.isCreating, isCreating) ||
|
||||||
other.isCreating == isCreating));
|
other.isCreating == isCreating) &&
|
||||||
|
(identical(other.isCreatingWithPayment, isCreatingWithPayment) ||
|
||||||
|
other.isCreatingWithPayment == isCreatingWithPayment));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1176,7 +1590,9 @@ class _$OrderFormStateImpl
|
|||||||
customerName,
|
customerName,
|
||||||
customer,
|
customer,
|
||||||
failureOrCreateOrder,
|
failureOrCreateOrder,
|
||||||
|
failureOrCreateOrderWithPayment,
|
||||||
isCreating,
|
isCreating,
|
||||||
|
isCreatingWithPayment,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
/// Create a copy of OrderFormState
|
||||||
@ -1197,7 +1613,10 @@ abstract class _OrderFormState implements OrderFormState {
|
|||||||
final String? customerName,
|
final String? customerName,
|
||||||
final Customer? customer,
|
final Customer? customer,
|
||||||
required final Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
required final Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
||||||
|
required final Option<Either<OrderFailure, Order>>
|
||||||
|
failureOrCreateOrderWithPayment,
|
||||||
final bool isCreating,
|
final bool isCreating,
|
||||||
|
final bool isCreatingWithPayment,
|
||||||
}) = _$OrderFormStateImpl;
|
}) = _$OrderFormStateImpl;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1209,7 +1628,11 @@ abstract class _OrderFormState implements OrderFormState {
|
|||||||
@override
|
@override
|
||||||
Option<Either<OrderFailure, Order>> get failureOrCreateOrder;
|
Option<Either<OrderFailure, Order>> get failureOrCreateOrder;
|
||||||
@override
|
@override
|
||||||
|
Option<Either<OrderFailure, Order>> get failureOrCreateOrderWithPayment;
|
||||||
|
@override
|
||||||
bool get isCreating;
|
bool get isCreating;
|
||||||
|
@override
|
||||||
|
bool get isCreatingWithPayment;
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
/// Create a copy of OrderFormState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
|||||||
@ -13,4 +13,10 @@ class OrderFormEvent with _$OrderFormEvent {
|
|||||||
required OrderType orderType,
|
required OrderType orderType,
|
||||||
Table? table,
|
Table? table,
|
||||||
}) = _CreateOrderWithPayment;
|
}) = _CreateOrderWithPayment;
|
||||||
|
|
||||||
|
const factory OrderFormEvent.createOrder({
|
||||||
|
required List<ProductQuantity> items,
|
||||||
|
required OrderType orderType,
|
||||||
|
Table? table,
|
||||||
|
}) = _CreateOrder;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,14 @@ class OrderFormState with _$OrderFormState {
|
|||||||
String? customerName,
|
String? customerName,
|
||||||
Customer? customer,
|
Customer? customer,
|
||||||
required Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
required Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
||||||
|
required Option<Either<OrderFailure, Order>>
|
||||||
|
failureOrCreateOrderWithPayment,
|
||||||
@Default(false) bool isCreating,
|
@Default(false) bool isCreating,
|
||||||
|
@Default(false) bool isCreatingWithPayment,
|
||||||
}) = _OrderFormState;
|
}) = _OrderFormState;
|
||||||
|
|
||||||
factory OrderFormState.initial() =>
|
factory OrderFormState.initial() => OrderFormState(
|
||||||
OrderFormState(failureOrCreateOrder: none());
|
failureOrCreateOrder: none(),
|
||||||
|
failureOrCreateOrderWithPayment: none(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,4 +7,5 @@ class ApiPath {
|
|||||||
static const String customers = '/api/v1/customers';
|
static const String customers = '/api/v1/customers';
|
||||||
static const String paymentMethods = '/api/v1/payment-methods';
|
static const String paymentMethods = '/api/v1/payment-methods';
|
||||||
static const String orders = '/api/v1/orders';
|
static const String orders = '/api/v1/orders';
|
||||||
|
static const String payments = '/api/v1/payments';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class Order with _$Order {
|
|||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
required DateTime updatedAt,
|
required DateTime updatedAt,
|
||||||
required List<OrderItem> orderItems,
|
required List<OrderItem> orderItems,
|
||||||
required List<PaymentOrder> payments,
|
required List<Payment> payments,
|
||||||
required int totalPaid,
|
required int totalPaid,
|
||||||
required int paymentCount,
|
required int paymentCount,
|
||||||
required String splitType,
|
required String splitType,
|
||||||
@ -115,40 +115,3 @@ class OrderItem with _$OrderItem {
|
|||||||
paidQuantity: 0,
|
paidQuantity: 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
|
||||||
class PaymentOrder with _$PaymentOrder {
|
|
||||||
const factory PaymentOrder({
|
|
||||||
required String id,
|
|
||||||
required String orderId,
|
|
||||||
required String paymentMethodId,
|
|
||||||
required String paymentMethodName,
|
|
||||||
required String paymentMethodType,
|
|
||||||
required int amount,
|
|
||||||
required String status,
|
|
||||||
required int splitNumber,
|
|
||||||
required int splitTotal,
|
|
||||||
required String splitDescription,
|
|
||||||
required int refundAmount,
|
|
||||||
required Map<String, dynamic> metadata,
|
|
||||||
required DateTime createdAt,
|
|
||||||
required DateTime updatedAt,
|
|
||||||
}) = _PaymentOrder;
|
|
||||||
|
|
||||||
factory PaymentOrder.empty() => PaymentOrder(
|
|
||||||
id: '',
|
|
||||||
orderId: '',
|
|
||||||
paymentMethodId: '',
|
|
||||||
paymentMethodName: '',
|
|
||||||
paymentMethodType: '',
|
|
||||||
amount: 0,
|
|
||||||
status: '',
|
|
||||||
splitNumber: 0,
|
|
||||||
splitTotal: 0,
|
|
||||||
splitDescription: '',
|
|
||||||
refundAmount: 0,
|
|
||||||
metadata: const {},
|
|
||||||
createdAt: DateTime(1970),
|
|
||||||
updatedAt: DateTime(1970),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
38
lib/domain/order/entities/payment_entity.dart
Normal file
38
lib/domain/order/entities/payment_entity.dart
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
part of '../order.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class Payment with _$Payment {
|
||||||
|
const factory Payment({
|
||||||
|
required String id,
|
||||||
|
required String orderId,
|
||||||
|
required String paymentMethodId,
|
||||||
|
required String paymentMethodName,
|
||||||
|
required String paymentMethodType,
|
||||||
|
required int amount,
|
||||||
|
required String status,
|
||||||
|
required int splitNumber,
|
||||||
|
required int splitTotal,
|
||||||
|
required String splitDescription,
|
||||||
|
required int refundAmount,
|
||||||
|
required Map<String, dynamic> metadata,
|
||||||
|
required DateTime createdAt,
|
||||||
|
required DateTime updatedAt,
|
||||||
|
}) = _Payment;
|
||||||
|
|
||||||
|
factory Payment.empty() => Payment(
|
||||||
|
id: '',
|
||||||
|
orderId: '',
|
||||||
|
paymentMethodId: '',
|
||||||
|
paymentMethodName: '',
|
||||||
|
paymentMethodType: '',
|
||||||
|
amount: 0,
|
||||||
|
status: '',
|
||||||
|
splitNumber: 0,
|
||||||
|
splitTotal: 0,
|
||||||
|
splitDescription: '',
|
||||||
|
refundAmount: 0,
|
||||||
|
metadata: const {},
|
||||||
|
createdAt: DateTime(1970),
|
||||||
|
updatedAt: DateTime(1970),
|
||||||
|
);
|
||||||
|
}
|
||||||
37
lib/domain/order/entities/payment_request_entity.dart
Normal file
37
lib/domain/order/entities/payment_request_entity.dart
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
part of '../order.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class PaymentRequest with _$PaymentRequest {
|
||||||
|
const factory PaymentRequest({
|
||||||
|
required String orderId,
|
||||||
|
required String paymentMethodId,
|
||||||
|
required int amount,
|
||||||
|
required String transactionId,
|
||||||
|
required int splitNumber,
|
||||||
|
required int splitTotal,
|
||||||
|
required String splitDescription,
|
||||||
|
required List<PaymentItemRequest> paymentOrderItems,
|
||||||
|
}) = _PaymentRequest;
|
||||||
|
|
||||||
|
factory PaymentRequest.empty() => const PaymentRequest(
|
||||||
|
orderId: '',
|
||||||
|
paymentMethodId: '',
|
||||||
|
amount: 0,
|
||||||
|
transactionId: '',
|
||||||
|
splitNumber: 0,
|
||||||
|
splitTotal: 0,
|
||||||
|
splitDescription: '',
|
||||||
|
paymentOrderItems: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class PaymentItemRequest with _$PaymentItemRequest {
|
||||||
|
const factory PaymentItemRequest({
|
||||||
|
required String orderItemId,
|
||||||
|
required int amount,
|
||||||
|
}) = _PaymentItemRequest;
|
||||||
|
|
||||||
|
factory PaymentItemRequest.empty() =>
|
||||||
|
const PaymentItemRequest(orderItemId: '', amount: 0);
|
||||||
|
}
|
||||||
@ -7,5 +7,7 @@ part 'order.freezed.dart';
|
|||||||
|
|
||||||
part 'entities/order_entity.dart';
|
part 'entities/order_entity.dart';
|
||||||
part 'entities/order_request_entity.dart';
|
part 'entities/order_request_entity.dart';
|
||||||
|
part 'entities/payment_request_entity.dart';
|
||||||
|
part 'entities/payment_entity.dart';
|
||||||
part 'failures/order_failure.dart';
|
part 'failures/order_failure.dart';
|
||||||
part 'repositories/i_order_repository.dart';
|
part 'repositories/i_order_repository.dart';
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -13,4 +13,9 @@ abstract class IOrderRepository {
|
|||||||
Future<Either<OrderFailure, Order>> createOrder({
|
Future<Either<OrderFailure, Order>> createOrder({
|
||||||
required OrderRequest request,
|
required OrderRequest request,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Future<Either<OrderFailure, Order>> createOrderWithPayment({
|
||||||
|
required OrderRequest request,
|
||||||
|
required String paymentMethodId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,4 +83,72 @@ class OrderRemoteDataProvider {
|
|||||||
return DC.error(OrderFailure.serverError(e));
|
return DC.error(OrderFailure.serverError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<DC<OrderFailure, OrderDto>> storeWithPaymentOrder({
|
||||||
|
required OrderRequestDto request,
|
||||||
|
required String paymentMethodId,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final response = await _apiClient.post(
|
||||||
|
ApiPath.orders,
|
||||||
|
data: request.toRequest(),
|
||||||
|
headers: getAuthorizationHeader(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.data['success'] == false) {
|
||||||
|
return DC.error(OrderFailure.unexpectedError());
|
||||||
|
} else {
|
||||||
|
final order = OrderDto.fromJson(
|
||||||
|
response.data['data'] as Map<String, dynamic>,
|
||||||
|
);
|
||||||
|
final paymentRequest = PaymentRequestDto(
|
||||||
|
orderId: order.id,
|
||||||
|
amount: order.totalAmount,
|
||||||
|
paymentMethodId: paymentMethodId,
|
||||||
|
splitNumber: 1,
|
||||||
|
splitTotal: 1,
|
||||||
|
splitDescription: '',
|
||||||
|
paymentOrderItems: order.orderItems
|
||||||
|
?.map(
|
||||||
|
(item) => PaymentItemRequestDto(
|
||||||
|
amount: item.totalPrice,
|
||||||
|
orderItemId: item.id,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
storePayment(paymentRequest);
|
||||||
|
|
||||||
|
return DC.data(order);
|
||||||
|
}
|
||||||
|
} on ApiFailure catch (e, s) {
|
||||||
|
log('storeOrderError', name: _logName, error: e, stackTrace: s);
|
||||||
|
return DC.error(OrderFailure.serverError(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<DC<OrderFailure, PaymentDto>> storePayment(
|
||||||
|
PaymentRequestDto request,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
final response = await _apiClient.post(
|
||||||
|
ApiPath.payments,
|
||||||
|
data: request.toJson(),
|
||||||
|
headers: getAuthorizationHeader(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.data['success'] == false) {
|
||||||
|
return DC.error(OrderFailure.unexpectedError());
|
||||||
|
}
|
||||||
|
|
||||||
|
final payment = PaymentDto.fromJson(
|
||||||
|
response.data['data'] as Map<String, dynamic>,
|
||||||
|
);
|
||||||
|
|
||||||
|
return DC.data(payment);
|
||||||
|
} on ApiFailure catch (e, s) {
|
||||||
|
log('storePaymentError', name: _logName, error: e, stackTrace: s);
|
||||||
|
return DC.error(OrderFailure.serverError(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class OrderDto with _$OrderDto {
|
|||||||
@JsonKey(name: "created_at") String? createdAt,
|
@JsonKey(name: "created_at") String? createdAt,
|
||||||
@JsonKey(name: "updated_at") String? updatedAt,
|
@JsonKey(name: "updated_at") String? updatedAt,
|
||||||
@JsonKey(name: "order_items") List<OrderItemDto>? orderItems,
|
@JsonKey(name: "order_items") List<OrderItemDto>? orderItems,
|
||||||
@JsonKey(name: "payments") List<PaymentOrderDto>? payments,
|
@JsonKey(name: "payments") List<PaymentDto>? payments,
|
||||||
@JsonKey(name: "total_paid") int? totalPaid,
|
@JsonKey(name: "total_paid") int? totalPaid,
|
||||||
@JsonKey(name: "payment_count") int? paymentCount,
|
@JsonKey(name: "payment_count") int? paymentCount,
|
||||||
@JsonKey(name: "split_type") String? splitType,
|
@JsonKey(name: "split_type") String? splitType,
|
||||||
@ -137,46 +137,3 @@ class OrderItemDto with _$OrderItemDto {
|
|||||||
paidQuantity: paidQuantity ?? 0,
|
paidQuantity: paidQuantity ?? 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
|
||||||
class PaymentOrderDto with _$PaymentOrderDto {
|
|
||||||
const PaymentOrderDto._();
|
|
||||||
|
|
||||||
const factory PaymentOrderDto({
|
|
||||||
@JsonKey(name: "id") String? id,
|
|
||||||
@JsonKey(name: "order_id") String? orderId,
|
|
||||||
@JsonKey(name: "payment_method_id") String? paymentMethodId,
|
|
||||||
@JsonKey(name: "payment_method_name") String? paymentMethodName,
|
|
||||||
@JsonKey(name: "payment_method_type") String? paymentMethodType,
|
|
||||||
@JsonKey(name: "amount") int? amount,
|
|
||||||
@JsonKey(name: "status") String? status,
|
|
||||||
@JsonKey(name: "split_number") int? splitNumber,
|
|
||||||
@JsonKey(name: "split_total") int? splitTotal,
|
|
||||||
@JsonKey(name: "split_description") String? splitDescription,
|
|
||||||
@JsonKey(name: "refund_amount") int? refundAmount,
|
|
||||||
@JsonKey(name: "metadata") Map<String, dynamic>? metadata,
|
|
||||||
@JsonKey(name: "created_at") String? createdAt,
|
|
||||||
@JsonKey(name: "updated_at") String? updatedAt,
|
|
||||||
}) = _PaymentOrderDto;
|
|
||||||
|
|
||||||
factory PaymentOrderDto.fromJson(Map<String, dynamic> json) =>
|
|
||||||
_$PaymentOrderDtoFromJson(json);
|
|
||||||
|
|
||||||
// Optional mapper ke domain entity
|
|
||||||
PaymentOrder toDomain() => PaymentOrder(
|
|
||||||
id: id ?? '',
|
|
||||||
orderId: orderId ?? '',
|
|
||||||
paymentMethodId: paymentMethodId ?? '',
|
|
||||||
paymentMethodName: paymentMethodName ?? '',
|
|
||||||
paymentMethodType: paymentMethodType ?? '',
|
|
||||||
amount: amount ?? 0,
|
|
||||||
status: status ?? '',
|
|
||||||
splitNumber: splitNumber ?? 0,
|
|
||||||
splitTotal: splitTotal ?? 0,
|
|
||||||
splitDescription: splitDescription ?? '',
|
|
||||||
refundAmount: refundAmount ?? 0,
|
|
||||||
metadata: metadata ?? const {},
|
|
||||||
createdAt: createdAt != null ? DateTime.parse(createdAt!) : DateTime(1970),
|
|
||||||
updatedAt: updatedAt != null ? DateTime.parse(updatedAt!) : DateTime(1970),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
44
lib/infrastructure/order/dtos/payment_dto.dart
Normal file
44
lib/infrastructure/order/dtos/payment_dto.dart
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
part of '../order_dtos.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class PaymentDto with _$PaymentDto {
|
||||||
|
const PaymentDto._();
|
||||||
|
|
||||||
|
const factory PaymentDto({
|
||||||
|
@JsonKey(name: "id") String? id,
|
||||||
|
@JsonKey(name: "order_id") String? orderId,
|
||||||
|
@JsonKey(name: "payment_method_id") String? paymentMethodId,
|
||||||
|
@JsonKey(name: "payment_method_name") String? paymentMethodName,
|
||||||
|
@JsonKey(name: "payment_method_type") String? paymentMethodType,
|
||||||
|
@JsonKey(name: "amount") int? amount,
|
||||||
|
@JsonKey(name: "status") String? status,
|
||||||
|
@JsonKey(name: "split_number") int? splitNumber,
|
||||||
|
@JsonKey(name: "split_total") int? splitTotal,
|
||||||
|
@JsonKey(name: "split_description") String? splitDescription,
|
||||||
|
@JsonKey(name: "refund_amount") int? refundAmount,
|
||||||
|
@JsonKey(name: "metadata") Map<String, dynamic>? metadata,
|
||||||
|
@JsonKey(name: "created_at") String? createdAt,
|
||||||
|
@JsonKey(name: "updated_at") String? updatedAt,
|
||||||
|
}) = _PaymentOrderDto;
|
||||||
|
|
||||||
|
factory PaymentDto.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$PaymentDtoFromJson(json);
|
||||||
|
|
||||||
|
// Optional mapper ke domain entity
|
||||||
|
Payment toDomain() => Payment(
|
||||||
|
id: id ?? '',
|
||||||
|
orderId: orderId ?? '',
|
||||||
|
paymentMethodId: paymentMethodId ?? '',
|
||||||
|
paymentMethodName: paymentMethodName ?? '',
|
||||||
|
paymentMethodType: paymentMethodType ?? '',
|
||||||
|
amount: amount ?? 0,
|
||||||
|
status: status ?? '',
|
||||||
|
splitNumber: splitNumber ?? 0,
|
||||||
|
splitTotal: splitTotal ?? 0,
|
||||||
|
splitDescription: splitDescription ?? '',
|
||||||
|
refundAmount: refundAmount ?? 0,
|
||||||
|
metadata: metadata ?? const {},
|
||||||
|
createdAt: createdAt != null ? DateTime.parse(createdAt!) : DateTime(1970),
|
||||||
|
updatedAt: updatedAt != null ? DateTime.parse(updatedAt!) : DateTime(1970),
|
||||||
|
);
|
||||||
|
}
|
||||||
51
lib/infrastructure/order/dtos/payment_request_dto.dart
Normal file
51
lib/infrastructure/order/dtos/payment_request_dto.dart
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
part of '../order_dtos.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class PaymentRequestDto with _$PaymentRequestDto {
|
||||||
|
const PaymentRequestDto._();
|
||||||
|
|
||||||
|
const factory PaymentRequestDto({
|
||||||
|
@JsonKey(name: "order_id") String? orderId,
|
||||||
|
@JsonKey(name: "payment_method_id") String? paymentMethodId,
|
||||||
|
@JsonKey(name: "amount") int? amount,
|
||||||
|
@JsonKey(name: "transaction_id") String? transactionId,
|
||||||
|
@JsonKey(name: "split_number") int? splitNumber,
|
||||||
|
@JsonKey(name: "split_total") int? splitTotal,
|
||||||
|
@JsonKey(name: "split_description") String? splitDescription,
|
||||||
|
@JsonKey(name: "payment_order_items")
|
||||||
|
List<PaymentItemRequestDto>? paymentOrderItems,
|
||||||
|
}) = _PaymentRequestDto;
|
||||||
|
|
||||||
|
factory PaymentRequestDto.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$PaymentRequestDtoFromJson(json);
|
||||||
|
|
||||||
|
// Optional mapper ke domain
|
||||||
|
PaymentRequest toDomain() => PaymentRequest(
|
||||||
|
orderId: orderId ?? '',
|
||||||
|
paymentMethodId: paymentMethodId ?? '',
|
||||||
|
amount: amount ?? 0,
|
||||||
|
transactionId: transactionId ?? '',
|
||||||
|
splitNumber: splitNumber ?? 0,
|
||||||
|
splitTotal: splitTotal ?? 0,
|
||||||
|
splitDescription: splitDescription ?? '',
|
||||||
|
paymentOrderItems:
|
||||||
|
paymentOrderItems?.map((e) => e.toDomain()).toList() ?? const [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class PaymentItemRequestDto with _$PaymentItemRequestDto {
|
||||||
|
const PaymentItemRequestDto._();
|
||||||
|
|
||||||
|
const factory PaymentItemRequestDto({
|
||||||
|
@JsonKey(name: "order_item_id") String? orderItemId,
|
||||||
|
@JsonKey(name: "amount") int? amount,
|
||||||
|
}) = _PaymentItemRequestDto;
|
||||||
|
|
||||||
|
factory PaymentItemRequestDto.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$PaymentItemRequestDtoFromJson(json);
|
||||||
|
|
||||||
|
// Optional: mapper ke domain entity
|
||||||
|
PaymentItemRequest toDomain() =>
|
||||||
|
PaymentItemRequest(orderItemId: orderItemId ?? '', amount: amount ?? 0);
|
||||||
|
}
|
||||||
@ -7,3 +7,5 @@ part 'order_dtos.g.dart';
|
|||||||
|
|
||||||
part 'dtos/order_dto.dart';
|
part 'dtos/order_dto.dart';
|
||||||
part 'dtos/order_request_dto.dart';
|
part 'dtos/order_request_dto.dart';
|
||||||
|
part 'dtos/payment_request_dto.dart';
|
||||||
|
part 'dtos/payment_dto.dart';
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -53,7 +53,7 @@ _$OrderDtoImpl _$$OrderDtoImplFromJson(Map<String, dynamic> json) =>
|
|||||||
?.map((e) => OrderItemDto.fromJson(e as Map<String, dynamic>))
|
?.map((e) => OrderItemDto.fromJson(e as Map<String, dynamic>))
|
||||||
.toList(),
|
.toList(),
|
||||||
payments: (json['payments'] as List<dynamic>?)
|
payments: (json['payments'] as List<dynamic>?)
|
||||||
?.map((e) => PaymentOrderDto.fromJson(e as Map<String, dynamic>))
|
?.map((e) => PaymentDto.fromJson(e as Map<String, dynamic>))
|
||||||
.toList(),
|
.toList(),
|
||||||
totalPaid: (json['total_paid'] as num?)?.toInt(),
|
totalPaid: (json['total_paid'] as num?)?.toInt(),
|
||||||
paymentCount: (json['payment_count'] as num?)?.toInt(),
|
paymentCount: (json['payment_count'] as num?)?.toInt(),
|
||||||
@ -130,44 +130,6 @@ Map<String, dynamic> _$$OrderItemDtoImplToJson(_$OrderItemDtoImpl instance) =>
|
|||||||
'paid_quantity': instance.paidQuantity,
|
'paid_quantity': instance.paidQuantity,
|
||||||
};
|
};
|
||||||
|
|
||||||
_$PaymentOrderDtoImpl _$$PaymentOrderDtoImplFromJson(
|
|
||||||
Map<String, dynamic> json,
|
|
||||||
) => _$PaymentOrderDtoImpl(
|
|
||||||
id: json['id'] as String?,
|
|
||||||
orderId: json['order_id'] as String?,
|
|
||||||
paymentMethodId: json['payment_method_id'] as String?,
|
|
||||||
paymentMethodName: json['payment_method_name'] as String?,
|
|
||||||
paymentMethodType: json['payment_method_type'] as String?,
|
|
||||||
amount: (json['amount'] as num?)?.toInt(),
|
|
||||||
status: json['status'] as String?,
|
|
||||||
splitNumber: (json['split_number'] as num?)?.toInt(),
|
|
||||||
splitTotal: (json['split_total'] as num?)?.toInt(),
|
|
||||||
splitDescription: json['split_description'] as String?,
|
|
||||||
refundAmount: (json['refund_amount'] as num?)?.toInt(),
|
|
||||||
metadata: json['metadata'] as Map<String, dynamic>?,
|
|
||||||
createdAt: json['created_at'] as String?,
|
|
||||||
updatedAt: json['updated_at'] as String?,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$$PaymentOrderDtoImplToJson(
|
|
||||||
_$PaymentOrderDtoImpl instance,
|
|
||||||
) => <String, dynamic>{
|
|
||||||
'id': instance.id,
|
|
||||||
'order_id': instance.orderId,
|
|
||||||
'payment_method_id': instance.paymentMethodId,
|
|
||||||
'payment_method_name': instance.paymentMethodName,
|
|
||||||
'payment_method_type': instance.paymentMethodType,
|
|
||||||
'amount': instance.amount,
|
|
||||||
'status': instance.status,
|
|
||||||
'split_number': instance.splitNumber,
|
|
||||||
'split_total': instance.splitTotal,
|
|
||||||
'split_description': instance.splitDescription,
|
|
||||||
'refund_amount': instance.refundAmount,
|
|
||||||
'metadata': instance.metadata,
|
|
||||||
'created_at': instance.createdAt,
|
|
||||||
'updated_at': instance.updatedAt,
|
|
||||||
};
|
|
||||||
|
|
||||||
_$OrderRequestDtoImpl _$$OrderRequestDtoImplFromJson(
|
_$OrderRequestDtoImpl _$$OrderRequestDtoImplFromJson(
|
||||||
Map<String, dynamic> json,
|
Map<String, dynamic> json,
|
||||||
) => _$OrderRequestDtoImpl(
|
) => _$OrderRequestDtoImpl(
|
||||||
@ -215,3 +177,83 @@ Map<String, dynamic> _$$OrderItemRequestDtoImplToJson(
|
|||||||
'unit_price': instance.unitPrice,
|
'unit_price': instance.unitPrice,
|
||||||
'notes': instance.notes,
|
'notes': instance.notes,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_$PaymentRequestDtoImpl _$$PaymentRequestDtoImplFromJson(
|
||||||
|
Map<String, dynamic> json,
|
||||||
|
) => _$PaymentRequestDtoImpl(
|
||||||
|
orderId: json['order_id'] as String?,
|
||||||
|
paymentMethodId: json['payment_method_id'] as String?,
|
||||||
|
amount: (json['amount'] as num?)?.toInt(),
|
||||||
|
transactionId: json['transaction_id'] as String?,
|
||||||
|
splitNumber: (json['split_number'] as num?)?.toInt(),
|
||||||
|
splitTotal: (json['split_total'] as num?)?.toInt(),
|
||||||
|
splitDescription: json['split_description'] as String?,
|
||||||
|
paymentOrderItems: (json['payment_order_items'] as List<dynamic>?)
|
||||||
|
?.map((e) => PaymentItemRequestDto.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$PaymentRequestDtoImplToJson(
|
||||||
|
_$PaymentRequestDtoImpl instance,
|
||||||
|
) => <String, dynamic>{
|
||||||
|
'order_id': instance.orderId,
|
||||||
|
'payment_method_id': instance.paymentMethodId,
|
||||||
|
'amount': instance.amount,
|
||||||
|
'transaction_id': instance.transactionId,
|
||||||
|
'split_number': instance.splitNumber,
|
||||||
|
'split_total': instance.splitTotal,
|
||||||
|
'split_description': instance.splitDescription,
|
||||||
|
'payment_order_items': instance.paymentOrderItems,
|
||||||
|
};
|
||||||
|
|
||||||
|
_$PaymentItemRequestDtoImpl _$$PaymentItemRequestDtoImplFromJson(
|
||||||
|
Map<String, dynamic> json,
|
||||||
|
) => _$PaymentItemRequestDtoImpl(
|
||||||
|
orderItemId: json['order_item_id'] as String?,
|
||||||
|
amount: (json['amount'] as num?)?.toInt(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$PaymentItemRequestDtoImplToJson(
|
||||||
|
_$PaymentItemRequestDtoImpl instance,
|
||||||
|
) => <String, dynamic>{
|
||||||
|
'order_item_id': instance.orderItemId,
|
||||||
|
'amount': instance.amount,
|
||||||
|
};
|
||||||
|
|
||||||
|
_$PaymentOrderDtoImpl _$$PaymentOrderDtoImplFromJson(
|
||||||
|
Map<String, dynamic> json,
|
||||||
|
) => _$PaymentOrderDtoImpl(
|
||||||
|
id: json['id'] as String?,
|
||||||
|
orderId: json['order_id'] as String?,
|
||||||
|
paymentMethodId: json['payment_method_id'] as String?,
|
||||||
|
paymentMethodName: json['payment_method_name'] as String?,
|
||||||
|
paymentMethodType: json['payment_method_type'] as String?,
|
||||||
|
amount: (json['amount'] as num?)?.toInt(),
|
||||||
|
status: json['status'] as String?,
|
||||||
|
splitNumber: (json['split_number'] as num?)?.toInt(),
|
||||||
|
splitTotal: (json['split_total'] as num?)?.toInt(),
|
||||||
|
splitDescription: json['split_description'] as String?,
|
||||||
|
refundAmount: (json['refund_amount'] as num?)?.toInt(),
|
||||||
|
metadata: json['metadata'] as Map<String, dynamic>?,
|
||||||
|
createdAt: json['created_at'] as String?,
|
||||||
|
updatedAt: json['updated_at'] as String?,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$PaymentOrderDtoImplToJson(
|
||||||
|
_$PaymentOrderDtoImpl instance,
|
||||||
|
) => <String, dynamic>{
|
||||||
|
'id': instance.id,
|
||||||
|
'order_id': instance.orderId,
|
||||||
|
'payment_method_id': instance.paymentMethodId,
|
||||||
|
'payment_method_name': instance.paymentMethodName,
|
||||||
|
'payment_method_type': instance.paymentMethodType,
|
||||||
|
'amount': instance.amount,
|
||||||
|
'status': instance.status,
|
||||||
|
'split_number': instance.splitNumber,
|
||||||
|
'split_total': instance.splitTotal,
|
||||||
|
'split_description': instance.splitDescription,
|
||||||
|
'refund_amount': instance.refundAmount,
|
||||||
|
'metadata': instance.metadata,
|
||||||
|
'created_at': instance.createdAt,
|
||||||
|
'updated_at': instance.updatedAt,
|
||||||
|
};
|
||||||
|
|||||||
@ -65,4 +65,27 @@ class OrderRepository implements IOrderRepository {
|
|||||||
return left(const OrderFailure.unexpectedError());
|
return left(const OrderFailure.unexpectedError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Either<OrderFailure, Order>> createOrderWithPayment({
|
||||||
|
required OrderRequest request,
|
||||||
|
required String paymentMethodId,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final result = await _dataProvider.storeWithPaymentOrder(
|
||||||
|
request: OrderRequestDto.fromDomain(request),
|
||||||
|
paymentMethodId: paymentMethodId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result.hasError) {
|
||||||
|
return left(result.error!);
|
||||||
|
}
|
||||||
|
|
||||||
|
final order = result.data!.toDomain();
|
||||||
|
return right(order);
|
||||||
|
} catch (e) {
|
||||||
|
log('createOrderError', name: _logName, error: e);
|
||||||
|
return left(const OrderFailure.unexpectedError());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class OrderListPayment extends StatelessWidget {
|
|||||||
(index) => Padding(
|
(index) => Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 8.0),
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
child: _buildPaymentItem(
|
child: _buildPaymentItem(
|
||||||
order?.payments[index] ?? PaymentOrder.empty(),
|
order?.payments[index] ?? Payment.empty(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -124,7 +124,7 @@ class OrderListPayment extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row _buildPaymentItem(PaymentOrder payment) {
|
Row _buildPaymentItem(Payment payment) {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user